-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 resize shape inference issue in opset10 #2294
Fix resize shape inference issue in opset10 #2294
Conversation
d720827
to
5d5853a
Compare
int64_t dim_value = static_cast<int64_t>(std::floor( | ||
static_cast<float>(input_shape.dim(i).dim_value()) * scales_data[i])); | ||
// If output_shape has dim_value, we validate the caculated result | ||
// If output_shape doesn's have one, we set it to the scaled result |
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 utility function unifyDim (see
onnx/onnx/defs/shape_inference.h
Line 734 in 95252c2
inline void unifyDim(Dim& dim, int64_t value) { |
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'm only reverting back a change that causes regression in resize shape inference. Thus I want to avoid modifying the original code as much as possible ...
auto* output_shape = getOutputShape(ctx, 0); | ||
const auto scales = ctx.getInputData(1); | ||
|
||
if (output_shape->dim_size() > 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.
These checks are fine, but I believe that they are not needed. The way inference works, these functions return an output type and shape, and the caller will check for compatibility with existing type/shape and combine them appropriately.
Is it feasible to add a test to prevent this problem? |
Some description of what went wrong would also be helpful (if we know) along with the testcase. |
That's a good point. For shape inference tests we rarely test with specified opset version. That implies by default whenever an operator gets updated, their previous versions are no longer tested. |
* fix resize shape inference issue in opset10 * include opset10 upsample as well * nit: const auto* * rename 'opset7' to 'opset7_to_10'
The issue is found in microsoft/onnxruntime#1756, that the updated opset 10 resize shape inference in defs/tensor/old.cc is failing Yolov3 https://github.com/onnx/models/tree/master/vision/object_detection_segmentation/yolov3.
This is a simple fix to bring back and use the version of shape inference functions before opset11.
@daquexian @hariharans29 @yuslepukhin