-
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
Enable named Slice arguments: start/rel_start, end/rel_end, shape/rel_shape #2625
Conversation
!build |
CI MESSAGE: [2005916]: BUILD STARTED |
CI MESSAGE: [2005916]: BUILD PASSED |
Relative and absolute arguments can be used for different arguments (e.g. ``rel_start`` | ||
and ``shape``) but should not be specified for the same argument (e.g. ``start`` and ``rel_start`` | ||
should not be provided together). |
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.
Relative and absolute arguments can be used for different arguments (e.g. ``rel_start`` | |
and ``shape``) but should not be specified for the same argument (e.g. ``start`` and ``rel_start`` | |
should not be provided together). | |
Relative and absolute arguments can be mixed (for example, ``rel_start`` can be used with ``shape``) as long | |
as start and shape or end are uniquely defined. |
72b0c92
to
4a22d0f
Compare
if (has_end_ || has_shape_) { // ``start`` can be omitted | ||
DALI_ENFORCE(!spec_.HasArgument("normalized_anchor") | ||
&& !spec_.HasArgument("normalized_shape"), | ||
"``normalized_anchor``/``normalized_shape`` is only relevant when using positional " |
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 fact that they are irrelevant doesn't mean they are forbidden (could be ignored, for example).
"``normalized_anchor``/``normalized_shape`` is only relevant when using positional " | |
"``normalized_anchor`` and ``normalized_shape`` can be used only with positional " |
else if (rel_shape_.IsDefined()) | ||
rel_shape_.Acquire(spec_, ws, curr_batch_size, args_shape); | ||
|
||
if (has_end_ || has_shape_) { // ``start`` can be omitted |
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.
Food for thought: maybe we could live with only the start - which would work like a[start:]
@@ -122,14 +222,17 @@ class SliceAttr { | |||
axes = GetDimIndices(shape_layout, axis_names_).to_vector(); | |||
} | |||
|
|||
constexpr double i64min = std::numeric_limits<int64_t>::min(); |
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.
constexpr double i64min = std::numeric_limits<int64_t>::min(); | |
constexpr double i64min = static_cast<double>(std::numeric_limits<int64_t>::min()); |
...or you'll fall victim to clang's warnings.
dali/pipeline/workspace/workspace.h
Outdated
return GetInputShape<GPUBackend>(input_idx).num_samples(); | ||
} | ||
return GetInputShape<CPUBackend>(input_idx).num_samples(); | ||
return GetInputShape(input_idx).num_samples(); |
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 is extremely wasteful - the shape is returned by value, making a copy of an std::vector.
dali/pipeline/workspace/workspace.h
Outdated
DALI_ENFORCE(NumInput() > 0, "No inputs found"); | ||
DALI_ENFORCE(input_idx >= 0 && input_idx < NumInput(), | ||
make_string("Invalid input index: ", input_idx, "; while NumInput: ", NumInput())); | ||
return GetInputShape(input_idx).sample_dim(); |
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.
Likewise.
!build |
CI MESSAGE: [2038719]: BUILD STARTED |
CI MESSAGE: [2038719]: BUILD FAILED |
void ProcessPositionalInputArgs(int data_idx, | ||
const AnchorT *slice_anchor_data, | ||
const ShapeT *slice_shape_data, | ||
const EndT *slice_end_data) { |
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 raised a warning in clang in the lambda - but slice_end_data is not used in this function at all. Do we need this argument at all here?
!build |
CI MESSAGE: [2044839]: BUILD STARTED |
CI MESSAGE: [2044839]: BUILD FAILED |
!build |
CI MESSAGE: [2045077]: BUILD STARTED |
CI MESSAGE: [2045077]: BUILD FAILED |
Signed-off-by: Joaquin Anton <janton@nvidia.com>
…hape 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>
* This argument was captured by lambda but not used, which caused a warning in clang build Signed-off-by: Michał Zientkiewicz <mzient@gmail.com>
…nalInputArgs. Signed-off-by: Michał Zientkiewicz <mzient@gmail.com>
2c1112e
to
41dc054
Compare
!build |
CI MESSAGE: [2058496]: BUILD STARTED |
CI MESSAGE: [2058496]: BUILD FAILED |
Signed-off-by: Joaquin Anton <janton@nvidia.com>
!build |
CI MESSAGE: [2058664]: BUILD STARTED |
CI MESSAGE: [2058664]: BUILD PASSED |
Signed-off-by: Joaquin Anton janton@nvidia.com
Why we need this PR?
What happened in this PR?
Fill relevant points, put NA otherwise. Replace anything inside []
Introduced named arguments
start
,rel_start
,end
,rel_end
,shape
,rel_shape
to define the slice parameters instead of the regular (positional) inputs anchor and shapeSlice, ImageDecoderSlice
SliceAttr implementation, error checking
Tests added
Operator doc updated
JIRA TASK: [DALI-1544]