-
Notifications
You must be signed in to change notification settings - Fork 618
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.CoinFlip #2577
Rework ops.random.CoinFlip #2577
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>
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>
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
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.
LGTM
dali/operators/util/randomizer.cuh
Outdated
: probability_(probability) {} | ||
|
||
__device__ inline bool operator()(curandState *state) const { | ||
return curand_uniform(state) <= probability_ ? true : false; |
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
return curand_uniform(state) <= probability_ ? true : false; | |
return !(curand_uniform(state) > probability_); |
;) Up to you
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.
I could do return curand_uniform(state) <= probability_
.
The negation just complicates things I believe
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.
Yeah, that's true ;)
DALIDataType DefaultDataType() const { | ||
return DALI_INT32; | ||
} |
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 used anywhere?
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.
See my comment above
|
||
def test_coin_flip(): | ||
batch_size = 8 | ||
shape = [100000] |
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.
AFAIU, there's also a single-input version of this op, right? Maybe we should test it also?
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.
OK
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
def test_coin_flip(): | ||
batch_size = 8 | ||
for device in ['cpu', 'gpu']: | ||
for max_shape, use_shape_like_in in [([100000], False), | ||
([100000], True), | ||
(None, False)]: | ||
for probability in [None, 0.7, 0.5, 0.0, 1.0]: | ||
yield check_coin_flip, device, batch_size, max_shape, probability, use_shape_like_in |
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.
Probably it would be cleaner, if you'd go with two check...
functions instead of the use_shape_like_in
:
def test_coin_flip():
batch_size = 8
for device in ['cpu', 'gpu']:
for max_shape in [100000, None]:
for probability in [None, 0.7, 0.5, 0.0, 1.0]:
yield check_coin_flip_input, device, batch_size, max_shape, probability
yield check_coin_flip, device, batch_size, max_shape, probability
But that's up to you
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.
I'd have to duplicate a lot of boilerplate, so I prefer it as is
Signed-off-by: Joaquin Anton <janton@nvidia.com>
!build |
CI MESSAGE: [1993407]: BUILD STARTED |
CI MESSAGE: [1993407]: BUILD FAILED |
!build |
CI MESSAGE: [1997031]: BUILD STARTED |
CI MESSAGE: [1997031]: BUILD FAILED |
Signed-off-by: Joaquin Anton <janton@nvidia.com>
!build |
CI MESSAGE: [1998822]: BUILD STARTED |
CI MESSAGE: [1998822]: BUILD PASSED |
(#2531 should be merged first)
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.CoinFlip in terms of RNGBase
Moved ops.CoinFlip to ops.random.CoinFlip
ops.random.CoinFlip
CoinFlip implementation
Tests extended
Existing documentation
JIRA TASK: [DALI-1197]