-
Notifications
You must be signed in to change notification settings - Fork 217
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
feature: rng primitive refactoring #3040
base: main
Are you sure you want to change the base?
feature: rng primitive refactoring #3040
Conversation
/intelci: run |
/intelci: run |
/intelci: run |
/intelci: run |
/intelci: run |
/intelci: run |
/intelci: run |
/intelci: run |
cpp/daal/src/algorithms/engines/mrg32k3a/mrg32k3a_batch_container.h
Outdated
Show resolved
Hide resolved
cpp/oneapi/dal/backend/primitives/rng/dpc_engine_collection.hpp
Outdated
Show resolved
Hide resolved
/intelci: run |
/// @param[in] queue The SYCL queue used to manage device operations. | ||
/// @param[in] seed The initial seed for the random number generator. Defaults to `777`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move those to the constructor's description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be also good to provide the descriptions to every public method, not only to the class.
template <typename Type, typename Size, engine_method EngineType> | ||
void uniform(Size count, Type* dst, dpc_engine<EngineType>& engine_, Type a, Type b) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to have Size
as a template parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide descriptions to all those APIs. Because from the first glance it is not clear which of them are for CPU only.
seed_(seed) { | ||
engines_.reserve(count_); | ||
for (Size i = 0; i < count_; ++i) { | ||
engines_.push_back(dpc_engine<EngineType>(queue, seed_)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This initialization looks meaningless for mt2203. Because different engine_idx
should also be provided to have independent sequences of random numbers:
https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-dpcpp/2023-0/oneapi-mkl-rng-mt2203.html
#define INSTANTIATE_(F, Size, EngineType) \ | ||
template ONEDAL_EXPORT void uniform(sycl::queue& queue, \ | ||
Size count_, \ | ||
F* dst, \ | ||
dpc_engine<EngineType>& engine_, \ | ||
F a, \ | ||
F b, \ | ||
const event_vector& deps); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to just add uniform_without_replacement
and shuffle
instantiations to this macro.
You'll not need INSTANTIATE_uniform_without_replacement_FLOAT
and other similar macros then.
/intelci: run |
@@ -0,0 +1,132 @@ | |||
/******************************************************************************* | |||
* Copyright 2021 Intel Corporation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Copyright 2021 Intel Corporation | |
* Copyright contributors to the oneDAL project |
/// | ||
/// @tparam EngineType The RNG engine type to be used. Defaults to `engine_method::mt2203`. | ||
/// | ||
/// @param[in] seed The initial seed for the random number generator. Defaults to `777`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The came comment as for dpc_engine
apply here: need to add descriptions to the methods and functions; need to fix rule of five.
|
||
for (std::int64_t el = 0; el < arr_2_host.get_count(); el++) { | ||
// Due to MKL inside generates floats on GPU and doubles on CPU, it makes sense to add minor eps. | ||
REQUIRE(abs(val_arr_1_host_ptr[el] - val_arr_2_host_ptr[el]) < 0.1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like 0.1
is a too big difference.
Description
Add a comprehensive description of proposed changes
List associated issue number(s) if exist(s): #6 (for example)
Documentation PR (if needed): #1340 (for example)
Benchmarks PR (if needed): IntelPython/scikit-learn_bench#155 (for example)
PR should start as a draft, then move to ready for review state after CI is passed and all applicable checkboxes are closed.
This approach ensures that reviewers don't spend extra time asking for regular requirements.
You can remove a checkbox as not applicable only if it doesn't relate to this PR in any way.
For example, PR with docs update doesn't require checkboxes for performance while PR with any change in actual code should have checkboxes and justify how this code change is expected to affect performance (or justification should be self-evident).
Checklist to comply with before moving PR from draft:
PR completeness and readability
Testing
Performance