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.
The utility function unifyDim (see
onnx/onnx/defs/shape_inference.h
Line 734 in 95252c2
There was a problem hiding this comment.
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.
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