Skip to content

Commit 8b1d889

Browse files
ENH: update random.standart_t (#677)
* ENH: update random.standart_t
1 parent 3d50cc0 commit 8b1d889

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

dpnp/backend/kernels/dpnp_krnl_random.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,11 +1068,10 @@ void dpnp_rng_standard_normal_c(void* result, size_t size)
10681068
template <typename _DataType>
10691069
void dpnp_rng_standard_t_c(void* result, const _DataType df, const size_t size)
10701070
{
1071-
if (!size)
1071+
if (!size || !result)
10721072
{
10731073
return;
10741074
}
1075-
cl::sycl::vector_class<cl::sycl::event> no_deps;
10761075

10771076
_DataType* result1 = reinterpret_cast<_DataType*>(result);
10781077
const _DataType d_zero = 0.0, d_one = 1.0;
@@ -1082,18 +1081,17 @@ void dpnp_rng_standard_t_c(void* result, const _DataType df, const size_t size)
10821081
if (dpnp_queue_is_cpu_c())
10831082
{
10841083
mkl_rng::gamma<_DataType> gamma_distribution(shape, d_zero, 1.0 / shape);
1085-
auto event_out = mkl_rng::generate(gamma_distribution, DPNP_RNG_ENGINE, size, result1);
1086-
event_out.wait();
1087-
event_out = mkl_vm::invsqrt(DPNP_QUEUE, size, result1, result1, no_deps, mkl_vm::mode::ha);
1088-
event_out.wait();
1084+
auto gamma_distr_event = mkl_rng::generate(gamma_distribution, DPNP_RNG_ENGINE, size, result1);
1085+
1086+
auto invsqrt_event = mkl_vm::invsqrt(DPNP_QUEUE, size, result1, result1, {gamma_distr_event}, mkl_vm::mode::ha);
10891087

10901088
sn = reinterpret_cast<_DataType*>(dpnp_memory_alloc_c(size * sizeof(_DataType)));
10911089

10921090
mkl_rng::gaussian<_DataType> gaussian_distribution(d_zero, d_one);
1093-
event_out = mkl_rng::generate(gaussian_distribution, DPNP_RNG_ENGINE, size, sn);
1094-
event_out.wait();
1091+
auto gaussian_distr_event = mkl_rng::generate(gaussian_distribution, DPNP_RNG_ENGINE, size, sn);
10951092

1096-
event_out = mkl_vm::mul(DPNP_QUEUE, size, result1, sn, result1, no_deps, mkl_vm::mode::ha);
1093+
auto event_out = mkl_vm::mul(
1094+
DPNP_QUEUE, size, result1, sn, result1, {invsqrt_event, gaussian_distr_event}, mkl_vm::mode::ha);
10971095
dpnp_memory_free_c(sn);
10981096
event_out.wait();
10991097
}

0 commit comments

Comments
 (0)