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
Fix Uniform discrete distribution #2635
Fix Uniform discrete distribution #2635
Conversation
Signed-off-by: Joaquin Anton <janton@nvidia.com>
dali/pipeline/operator/arg_helper.h
Outdated
@@ -116,7 +116,7 @@ class ArgValue { | |||
DALI_ENFORCE(is_uniform(view_.shape) && expected_shape == view_.shape[0], | |||
make_string("Expected uniform shape for argument \"", arg_name_, | |||
"\" but got shape ", view_.shape)); | |||
} else { | |||
} else if (view_.empty()) { |
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 assumes that non-tensor data is constant (and we may change that at some point)
- It validates the hidden (and dangerous) assumption that Acquire is no-op - I think that hoisting this logic outside of Acquire violates encapsulation of ArgValue.
- It makes clear that the way we obtain non-tensor arguments is inefficient, as it results in reallocation of the internal vector - use TryGetArgument / TryGetRepeatedArgument which will resize and populate an existing vector.
Signed-off-by: Joaquin Anton <janton@nvidia.com>
fcdbf0e
to
fbc56d6
Compare
per_sample_values_.resize(nsamples); | ||
per_sample_nvalues_.resize(nsamples); |
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.
per_sample_values_.resize(nsamples); | |
per_sample_nvalues_.resize(nsamples); | |
per_sample_values_.resize(values_.size()); | |
per_sample_nvalues_.resize(values_.size()); |
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.
and similarly in the loops below
Signed-off-by: Joaquin Anton <janton@nvidia.com>
55b7876
to
aa1bb5a
Compare
!build |
CI MESSAGE: [2015068]: BUILD STARTED |
CI MESSAGE: [2015068]: BUILD FAILED |
Signed-off-by: Joaquin Anton <janton@nvidia.com>
@@ -83,17 +83,17 @@ TEST(ArgValue, TensorInput_3D) { | |||
|
|||
TEST(ArgValueTests, Constant_0D) { | |||
int nsamples = 5; | |||
auto spec = OpSpec("opname").AddArg("argname", 0.123f); | |||
ArgValue<float, 0> arg("argname", spec); | |||
auto spec = OpSpec("Erase").AddArg("shape", 0.123f); |
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.
Note: Using TryGetArgument* required that the spec points to an existing operator.
!build |
CI MESSAGE: [2015569]: BUILD STARTED |
CI MESSAGE: [2015569]: BUILD PASSED |
Signed-off-by: Joaquin Anton janton@nvidia.com
Why we need this PR?
Pick one, remove the rest
What happened in this PR?
Fill relevant points, put NA otherwise. Replace anything inside []
An extra ArgValue Acquire call every iteration was overriding the values pointer inside ArgValue implementation while the per_sample_values data was kept unmodified due to the assumption that the pointer won't change.
As a solution, we Acquire the values only once when a non-tensor argument is given
Using TryGetArgument/TryGetRepeatedArgument to avoid reallocation
Uniform distribution and other operators using ArgValue
All
Added niter to uniform tests
N/A
JIRA TASK: [DALI-1824