Skip to content

Commit efd9f84

Browse files
committed
Add normal(), rand(), randint(), randn(), random_sample(), standard_normal()
1 parent 884cc6a commit efd9f84

19 files changed

+1437
-651
lines changed

.github/workflows/conda-package.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ jobs:
253253

254254
# TODO: run the whole scope once the issues on CPU are resolved
255255
- name: Run tests
256-
run: python -m pytest -q -ra --disable-warnings -vv test_arraycreation.py test_dparray.py test_fft.py test_linalg.py test_mathematical.py test_special.py
256+
run: |
257+
python -m pytest -q -ra --disable-warnings -vv test_arraycreation.py test_dparray.py test_fft.py test_linalg.py test_mathematical.py test_random_state.py test_special.py
257258
env:
258259
OCL_ICD_FILENAMES: 'libintelocl.so'
259260
working-directory: ${{ env.tests-path }}
@@ -428,7 +429,8 @@ jobs:
428429

429430
# TODO: run the whole scope once the issues on CPU are resolved
430431
- name: Run tests
431-
run: python -m pytest -q -ra --disable-warnings -vv test_arraycreation.py test_dparray.py test_fft.py test_linalg.py test_mathematical.py test_special.py
432+
run: |
433+
python -m pytest -q -ra --disable-warnings -vv test_arraycreation.py test_dparray.py test_fft.py test_linalg.py test_mathematical.py test_random_state.py test_special.py
432434
working-directory: ${{ env.tests-path }}
433435

434436
upload_linux:

dpnp/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
from dpnp.dpnp_array import dpnp_array as ndarray
4646
from dpnp.dpnp_flatiter import flatiter as flatiter
4747

48+
from dpnp.dpnp_iface_types import *
4849
from dpnp.dpnp_iface import *
4950
from dpnp.dpnp_iface import __all__ as _iface__all__
50-
from dpnp.dpnp_iface_types import *
5151
from dpnp.version import __version__
5252

5353

dpnp/backend/include/dpnp_iface_fptr.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//*****************************************************************************
2-
// Copyright (c) 2016-2020, Intel Corporation
2+
// Copyright (c) 2016-2022, Intel Corporation
33
// All rights reserved.
44
//
55
// Redistribution and use in source and binary forms, with or without
@@ -315,7 +315,6 @@ enum class DPNPFuncName : size_t
315315
DPNP_FN_RNG_STANDARD_GAMMA, /**< Used in numpy.random.standard_gamma() impl */
316316
DPNP_FN_RNG_STANDARD_GAMMA_EXT, /**< Used in numpy.random.standard_gamma() impl, requires extra parameters */
317317
DPNP_FN_RNG_STANDARD_NORMAL, /**< Used in numpy.random.standard_normal() impl */
318-
DPNP_FN_RNG_STANDARD_NORMAL_EXT, /**< Used in numpy.random.standard_normal() impl */
319318
DPNP_FN_RNG_STANDARD_T, /**< Used in numpy.random.standard_t() impl */
320319
DPNP_FN_RNG_STANDARD_T_EXT, /**< Used in numpy.random.standard_t() impl, requires extra parameters */
321320
DPNP_FN_RNG_TRIANGULAR, /**< Used in numpy.random.triangular() impl */

dpnp/backend/include/dpnp_iface_random.hpp

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -438,18 +438,20 @@ INP_DLLEXPORT void
438438
* @brief math library implementation of random number generator (normal continious distribution)
439439
*
440440
* @param [in] q_ref Reference to SYCL queue.
441-
* @param [out] result Output array.
441+
* @param [out] result_out Output array.
442442
* @param [in] mean Mean value.
443443
* @param [in] stddev Standard deviation.
444444
* @param [in] size Number of elements in `result` arrays.
445+
* @param [in] random_state_in Pointer on random state.
445446
* @param [in] dep_event_vec_ref Reference to vector of SYCL events.
446447
*/
447448
template <typename _DataType>
448449
INP_DLLEXPORT DPCTLSyclEventRef dpnp_rng_normal_c(DPCTLSyclQueueRef q_ref,
449-
void* result,
450-
const _DataType mean,
451-
const _DataType stddev,
452-
const size_t size,
450+
void* result_out,
451+
const double mean,
452+
const double stddev,
453+
const int64_t size,
454+
void* random_state_in,
453455
const DPCTLEventVectorRef dep_event_vec_ref);
454456

455457
template <typename _DataType>
@@ -629,17 +631,11 @@ INP_DLLEXPORT void dpnp_rng_standard_gamma_c(void* result, const _DataType shape
629631
* @brief math library implementation of random number generator (standard normal distribution)
630632
*
631633
* @param [in] q_ref Reference to SYCL queue.
632-
* @param [out] result Output array.
634+
* @param [out] result_out Output array.
633635
* @param [in] size Number of elements in `result` arrays.
634636
* @param [in] dep_event_vec_ref Reference to vector of SYCL events.
635637
*/
636638
template <typename _DataType>
637-
INP_DLLEXPORT DPCTLSyclEventRef dpnp_rng_standard_normal_c(DPCTLSyclQueueRef q_ref,
638-
void* result,
639-
const size_t size,
640-
const DPCTLEventVectorRef dep_event_vec_ref);
641-
642-
template <typename _DataType>
643639
INP_DLLEXPORT void dpnp_rng_standard_normal_c(void* result, const size_t size);
644640

645641
/**
@@ -692,7 +688,7 @@ INP_DLLEXPORT void dpnp_rng_triangular_c(
692688
* @brief math library implementation of random number generator (uniform distribution)
693689
*
694690
* @param [in] q_ref Reference to SYCL queue.
695-
* @param [out] result Output array.
691+
* @param [out] result_out Output array.
696692
* @param [in] low Left bound of array values.
697693
* @param [in] high Right bound of array values.
698694
* @param [in] size Number of elements in `result` array.
@@ -701,10 +697,10 @@ INP_DLLEXPORT void dpnp_rng_triangular_c(
701697
*/
702698
template <typename _DataType>
703699
INP_DLLEXPORT DPCTLSyclEventRef dpnp_rng_uniform_c(DPCTLSyclQueueRef q_ref,
704-
void* result,
705-
const long low,
706-
const long high,
707-
const size_t size,
700+
void* result_out,
701+
const double low,
702+
const double high,
703+
const int64_t size,
708704
void* random_state_in,
709705
const DPCTLEventVectorRef dep_event_vec_ref);
710706

0 commit comments

Comments
 (0)