Skip to content

Add random_state class #1139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dc7888a
Add random_state class
LukichevaPolina Feb 18, 2022
396efab
Replace class on struct
LukichevaPolina Mar 4, 2022
e9d4b15
Add RandomState class to random module
LukichevaPolina Mar 5, 2022
3b6c181
Delete cython layer for uniform
LukichevaPolina Mar 9, 2022
91fa104
Merge branch 'master' into random_cfd
Alexander-Makaryev Mar 11, 2022
ea0ea33
Merge branch 'master' into random_cfd
LukichevaPolina Mar 17, 2022
38c5f24
Add ifdef to random_state.h and rename dpnp_random_state
LukichevaPolina Mar 21, 2022
17b2443
Merge branch 'random_cfd' of https://github.com/LukichevaPolina/dpnp …
LukichevaPolina Mar 21, 2022
27628a5
Merge branch 'master' into random_cfd
antonwolfy Aug 3, 2022
3a980c1
Merge branch 'master' into random_cfd
antonwolfy Aug 3, 2022
37a3464
Resolve faults after the last rebase & implement minor improvements
antonwolfy Aug 8, 2022
e4c3187
Merge branch 'master' into random_cfd
antonwolfy Aug 8, 2022
9db5e4f
Formatting and minor fixes
antonwolfy Aug 9, 2022
369419a
Fix build issue due to gcc knows nothing about OneAPI headers (detach…
antonwolfy Aug 9, 2022
365d671
Fix issues for legacy behavior with dpnp.random.uniform() and dpnp.ra…
antonwolfy Aug 9, 2022
97c7737
Merge branch 'master' into random_cfd
antonwolfy Aug 10, 2022
039780a
Add more tests for RandomState and RandomState.uniform
antonwolfy Aug 11, 2022
a789726
Merge branch 'master' into random_cfd
antonwolfy Aug 11, 2022
18c1868
Secure support of int32 for RandomState.uniform in tests.
antonwolfy Aug 11, 2022
10399e7
Exclude a test with dtype=numpy.intc from allowed integer types due t…
antonwolfy Aug 11, 2022
884cc6a
Merge branch 'master' into random_cfd
antonwolfy Oct 18, 2022
efd9f84
Add normal(), rand(), randint(), randn(), random_sample(), standard_n…
antonwolfy Oct 18, 2022
a697ab7
Default dtype to be dependent on fp64 support
antonwolfy Nov 3, 2022
37fad3b
Broken CFD in fallback on numpy
antonwolfy Nov 8, 2022
1e2def8
Merge branch 'master' into random_cfd
antonwolfy Nov 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ jobs:

# TODO: run the whole scope once the issues on CPU are resolved
- name: Run tests
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
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_random_state.py test_special.py
env:
OCL_ICD_FILENAMES: 'libintelocl.so'
working-directory: ${{ env.tests-path }}
Expand Down Expand Up @@ -408,7 +409,8 @@ jobs:

# TODO: run the whole scope once the issues on CPU are resolved
- name: Run tests
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
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_random_state.py test_special.py
working-directory: ${{ env.tests-path }}

upload_linux:
Expand Down
2 changes: 1 addition & 1 deletion dpnp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
from dpnp.dpnp_array import dpnp_array as ndarray
from dpnp.dpnp_flatiter import flatiter as flatiter

from dpnp.dpnp_iface_types import *
from dpnp.dpnp_iface import *
from dpnp.dpnp_iface import __all__ as _iface__all__
from dpnp.dpnp_iface_types import *
from dpnp.version import __version__


Expand Down
1 change: 1 addition & 0 deletions dpnp/backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ set(DPNP_SRC
src/memory_sycl.cpp
src/queue_sycl.cpp
src/verbose.cpp
src/dpnp_random_state.cpp
)

if(DPNP_STATIC_LIB_ENABLE)
Expand Down
1 change: 0 additions & 1 deletion dpnp/backend/include/dpnp_iface_fptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ enum class DPNPFuncName : size_t
DPNP_FN_RNG_STANDARD_GAMMA, /**< Used in numpy.random.standard_gamma() impl */
DPNP_FN_RNG_STANDARD_GAMMA_EXT, /**< Used in numpy.random.standard_gamma() impl, requires extra parameters */
DPNP_FN_RNG_STANDARD_NORMAL, /**< Used in numpy.random.standard_normal() impl */
DPNP_FN_RNG_STANDARD_NORMAL_EXT, /**< Used in numpy.random.standard_normal() impl */
DPNP_FN_RNG_STANDARD_T, /**< Used in numpy.random.standard_t() impl */
DPNP_FN_RNG_STANDARD_T_EXT, /**< Used in numpy.random.standard_t() impl, requires extra parameters */
DPNP_FN_RNG_TRIANGULAR, /**< Used in numpy.random.triangular() impl */
Expand Down
34 changes: 16 additions & 18 deletions dpnp/backend/include/dpnp_iface_random.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//*****************************************************************************
// Copyright (c) 2016-2020, Intel Corporation
// Copyright (c) 2016-2022, Intel Corporation
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -438,18 +438,20 @@ INP_DLLEXPORT void
* @brief math library implementation of random number generator (normal continious distribution)
*
* @param [in] q_ref Reference to SYCL queue.
* @param [out] result Output array.
* @param [out] result_out Output array.
* @param [in] mean Mean value.
* @param [in] stddev Standard deviation.
* @param [in] size Number of elements in `result` arrays.
* @param [in] random_state_in Pointer on random state.
* @param [in] dep_event_vec_ref Reference to vector of SYCL events.
*/
template <typename _DataType>
INP_DLLEXPORT DPCTLSyclEventRef dpnp_rng_normal_c(DPCTLSyclQueueRef q_ref,
void* result,
const _DataType mean,
const _DataType stddev,
const size_t size,
void* result_out,
const double mean,
const double stddev,
const int64_t size,
void* random_state_in,
const DPCTLEventVectorRef dep_event_vec_ref);

template <typename _DataType>
Expand Down Expand Up @@ -629,17 +631,11 @@ INP_DLLEXPORT void dpnp_rng_standard_gamma_c(void* result, const _DataType shape
* @brief math library implementation of random number generator (standard normal distribution)
*
* @param [in] q_ref Reference to SYCL queue.
* @param [out] result Output array.
* @param [out] result_out Output array.
* @param [in] size Number of elements in `result` arrays.
* @param [in] dep_event_vec_ref Reference to vector of SYCL events.
*/
template <typename _DataType>
INP_DLLEXPORT DPCTLSyclEventRef dpnp_rng_standard_normal_c(DPCTLSyclQueueRef q_ref,
void* result,
const size_t size,
const DPCTLEventVectorRef dep_event_vec_ref);

template <typename _DataType>
INP_DLLEXPORT void dpnp_rng_standard_normal_c(void* result, const size_t size);

/**
Expand Down Expand Up @@ -692,18 +688,20 @@ INP_DLLEXPORT void dpnp_rng_triangular_c(
* @brief math library implementation of random number generator (uniform distribution)
*
* @param [in] q_ref Reference to SYCL queue.
* @param [out] result Output array.
* @param [out] result_out Output array.
* @param [in] low Left bound of array values.
* @param [in] high Right bound of array values.
* @param [in] size Number of elements in `result` array.
* @param [in] random_state_in Pointer on random state.
* @param [in] dep_event_vec_ref Reference to vector of SYCL events.
*/
template <typename _DataType>
INP_DLLEXPORT DPCTLSyclEventRef dpnp_rng_uniform_c(DPCTLSyclQueueRef q_ref,
void* result,
const long low,
const long high,
const size_t size,
void* result_out,
const double low,
const double high,
const int64_t size,
void* random_state_in,
const DPCTLEventVectorRef dep_event_vec_ref);

template <typename _DataType>
Expand Down
Loading