-
Notifications
You must be signed in to change notification settings - Fork 621
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
Rework ops.random.Uniform #2531
Conversation
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
5c7c8ce
to
3125063
Compare
Signed-off-by: Joaquin Anton <janton@nvidia.com>
3125063
to
397e259
Compare
Signed-off-by: Joaquin Anton <janton@nvidia.com>
98e1169
to
63966f9
Compare
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
!build |
CI MESSAGE: [1940512]: BUILD STARTED |
CI MESSAGE: [1940512]: BUILD FAILED |
Signed-off-by: Joaquin Anton <janton@nvidia.com>
4440ba6
to
7e3b443
Compare
!build |
CI MESSAGE: [1940603]: BUILD STARTED |
CI MESSAGE: [1940603]: BUILD PASSED |
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.
Couple of questions from my side
dali/operators/util/randomizer.cuh
Outdated
|
||
template <typename T> | ||
struct curand_uniform_dist {}; | ||
|
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.
How about creating
template<typename T>
struct curand_uniform_dist {
static_assert( /* check if T is double or float */ );
DALI_HOST_DEV curand_uniform_dist(T start, T end)
/* etc... */
};
And specializing only curand_uniform
/curand_uniform_double
? This way we have this extra static verification of type with meaningful error msg (and less code duplication). Cause after
curand_uniform_dist<int> d;
We're getting something peculiar I guess
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.
Fixed. I changed it to a forward declaration, so it won't compile for other types.
dali/operators/util/randomizer.cuh
Outdated
|
||
struct curand_uniform_int_range_dist { | ||
DALI_HOST_DEV curand_uniform_int_range_dist(int start, int end) | ||
: range_start_(start), range_size_(end-start) {} |
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.
How about adding assert(start < end)
line?
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.
Will do
dali/operators/util/randomizer.cuh
Outdated
template <> | ||
struct curand_uniform_dist<double> { | ||
DALI_HOST_DEV curand_uniform_dist(float start, float end) | ||
: range_start_(start), range_size_(end-start) {} |
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.
Here as well?
Signed-off-by: Joaquin Anton <janton@nvidia.com>
dali/operators/util/randomizer.cuh
Outdated
struct curand_uniform_dist {}; | ||
|
||
template <> | ||
struct curand_uniform_dist<float> { |
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.
As Michał suggested, you can move the common parts to the same place and specialize only the operator()
.
.DocStr(R"code(Generates random numbers following a uniform distribution. | ||
|
||
The shape of the generated data can be either specified explicitly with a ``shape`` argument, | ||
or chosen to match the shape of the input, if provided. If none are present, a single number is |
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.
A single number means a batch of scalars, right? If so, maybe it could be phrased this way in the doc str.
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
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.
My only doubt is uniform distribution CPU vs GPU, expressed offline
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
!build |
CI MESSAGE: [1973816]: BUILD STARTED |
CI MESSAGE: [1973816]: BUILD PASSED |
Why we need this PR?
Pick one, remove the rest
What happened in this PR?
Fill relevant points, put NA otherwise. Replace anything inside []
Implemented ops.random.Uniform in terms of RNGBase
Moved ops.Uniform to ops.random.Uniform
ops.random.Uniform
Uniform implementation
Tests extended
Existing documentation
JIRA TASK: [DALI-1196]