-
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
Improved Reshape #1634
Improved Reshape #1634
Conversation
* Add relative extents * Add "remaining volume" extent (-1) support Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
!build |
CI MESSAGE: [1064365]: BUILD STARTED |
"is preserved if number of dimension matches existing layout " | ||
"or reset to empty otherwise", | ||
""); | ||
.AddOptionalArg<float>("rel_shape", "The relative shape of the output. Number of dimensions " |
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.
you should point out that "shape" and "rel_shape" are mutually exclusive
bool has_rel_shape_arg = spec.HasArgument("rel_shape") || spec.HasTensorArgument("rel_shape"); | ||
DALI_ENFORCE(has_shape_input + has_shape_arg + has_rel_shape_arg == 1, | ||
"Reshape: shape input, `shape` argument and `rel_shape` argument are mutually exclusive"); | ||
DALI_ENFORCE(has_shape_input || has_shape_arg || has_rel_shape_arg || has_layout_arg, |
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: you are already checking that at least one shape argument is provided, you don't need to check that again.
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.
There's a bug - it should be <= 1.
CI MESSAGE: [1064365]: BUILD FAILED |
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
!build |
CI MESSAGE: [1064465]: BUILD STARTED |
CI MESSAGE: [1064465]: BUILD PASSED |
TYPE_SWITCH(tl.type().id(), type2id, type, | ||
(int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t), | ||
(this->ShapeFromInput(view<const type>(tl));), | ||
(DALI_FAIL("Reshape: shape input must have integral type; got: " + tl.type().name() + |
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.
must have integral type
unless it's the if above and we handle 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.
Shape input is only for absolute shape. Relative shape is specified as an argument input.
The regular input is only here for historical reasons (from before CPU/support unification).
dali/operators/util/reshape.cc
Outdated
@@ -28,34 +29,75 @@ DALI_SCHEMA(Reshape) | |||
.AllowSequences() | |||
.SupportVolumetric() | |||
.AddOptionalArg<int>("shape", "The desired shape of the output. Number of elements 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.
It would be nice to provide the information, that Reshape can also take optional input with shapes. Now there is no such information.
dali/operators/util/reshape.cc
Outdated
break; | ||
case ShapeSource::Input: | ||
ShapeFromInput(ws.template InputRef<CPUBackend>(1)); | ||
ShapeFromInput(ws.template InputRef<CPUBackend>(1), use_rel_shape_); |
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 won't ever work with relative shapes provided as inputs, as even if we get second input with float values, we won't set use_rel_shape_=true
.
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.
Also, does it actually work on GPU to receive the shapes as CPU input? (It's not like it will be widely used due to it's limitations).
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 will always be false.
- It does work and is actually tested.
dali/operators/util/reshape.cc
Outdated
if (use_rel_shape_) | ||
ShapeFromInput(ws.ArgumentInput("shape"), false); | ||
else | ||
ShapeFromInput(ws.ArgumentInput("rel_shape"), 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.
...lol, bug.
!build |
CI MESSAGE: [1066198]: BUILD STARTED |
for test in test_reshape_arg(): | ||
test[0](*test[1:]) | ||
for test in test_reshape_input(): | ||
#for test in test_reshape_arg(): |
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.
??
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
65a9861
to
30778fd
Compare
!build |
CI MESSAGE: [1066265]: BUILD STARTED |
CI MESSAGE: [1066198]: BUILD PASSED |
|
||
rng = ops.Uniform(range=[100,128]) | ||
cast = ops.Cast(dtype=types.INT32) | ||
widths = cast(rng()) * 2.0 |
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 makes sure we always get even width - we're halving it, so it must not be odd or the volume will not match.
CI MESSAGE: [1066265]: BUILD PASSED |
Signed-off-by: Michal Zientkiewicz michalz@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 []
JIRA TASK: N/A