-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Introduce CenterCropPad, add axes
to Pad
#4190
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
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>
axes
to Pad and Shape
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
onnx/defs/tensor/defs.cc
Outdated
.SetContextDependentFunctionBodyBuilder( | ||
[](const FunctionBodyBuildContext& ctx, const OpSchema& schema, FunctionProto& functionProto) { | ||
const auto& input_shape = ctx.getInputType(0)->tensor_type().shape(); | ||
const int64_t input_rank = input_shape.dim_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.
Unfortunately, this is going to be a problem. The shape we can get is only a static-shape, not a dynamic-shape. Statically, we may not know the rank of the input.
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.
Instead, one alternative is to get the (full) shape, convert the axes attribute into a tensor, and use it to index into the full-shape using some form of gather op.
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 went with a separate code path when axes are not provided. Also, I took your suggestion and used Gather
instead of extending Shape
.
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>
axes
to Pad and Shapeaxes
to Pad
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
LGTM, thanks. Have the test-cases been validated with ORT? Unfortunately, there is no other way to validate function definitions. |
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>
Yes. I have validated the test cases that don't depend on |
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.
Left one comment, LGTM otherwise.
3, | ||
"axes", | ||
"1-D tensor of axes that `pads` apply to. Negative value means counting dimensions " | ||
"from the back. Accepted range is [-r, r-1] where r = rank(data). Behavior is undefined if an " |
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 possible to add a warning/exception when an axis is repeated, like in case of Resize-18?
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.
Done
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>
* Introduce ai.onnx.image.CenterCropPad Signed-off-by: Joaquin Anton <janton@nvidia.com> * Remove ai.onnx.image domain Signed-off-by: Joaquin Anton <janton@nvidia.com> * Add Pad axes Signed-off-by: Joaquin Anton <janton@nvidia.com> * Add axes to Shape, update CenterCropPad to work with arbitrary axes Signed-off-by: Joaquin Anton <janton@nvidia.com> * Fix shape inference file Signed-off-by: Joaquin Anton <janton@nvidia.com> * Undo Shape-17 Signed-off-by: Joaquin Anton <janton@nvidia.com> * Update doc Signed-off-by: Joaquin Anton <janton@nvidia.com> * Linter fix Signed-off-by: Joaquin Anton <janton@nvidia.com> * Create Const directly from attribute Signed-off-by: Joaquin Anton <janton@nvidia.com> * Move to opset 18 Signed-off-by: Joaquin Anton <janton@nvidia.com> * Apply clang-format Signed-off-by: Joaquin Anton <janton@nvidia.com> * Update opset in shape_inference_tests Signed-off-by: Joaquin Anton <janton@nvidia.com> * Fix shape inference tests Signed-off-by: Joaquin Anton <janton@nvidia.com> * Add automatic upgrade test Signed-off-by: Joaquin Anton <janton@nvidia.com> * Update CenterCropPad tests Signed-off-by: Joaquin Anton <janton@nvidia.com> * Refactor tests Signed-off-by: Joaquin Anton <janton@nvidia.com> * Update tests Signed-off-by: Joaquin Anton <janton@nvidia.com> * Check for repeated axes Signed-off-by: Joaquin Anton <janton@nvidia.com> * Fix flake8 issues Signed-off-by: Joaquin Anton <janton@nvidia.com> * Fix clang-format issue Signed-off-by: Joaquin Anton <janton@nvidia.com> * Fix CenterCropPad tests with axes Signed-off-by: Joaquin Anton <janton@nvidia.com> * Update doc Signed-off-by: Joaquin Anton <janton@nvidia.com>
The documentation currently lacks these salient details - https://onnx.ai/onnx/operators/onnx__CenterCropPad.html#l-onnx-doc-centercroppad. Is the following correct?
|
You are right, the documentation is ambiguous in those cases. |
Signed-off-by: Joaquin Anton janton@nvidia.com
Description
Motivation and Context
Enables writing image preprocessing pipelines (such as ResNet-50)