-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Support trilinear sampling in Resize CPU and CUDA kernels #5300
Conversation
@@ -363,8 +385,8 @@ void UpsampleBilinear(int64_t batch_size, | |||
in_x1[x] = std::min(static_cast<int64_t>(in_x), input_width - 1); | |||
in_x2[x] = std::min(in_x1[x] + 1, input_width - 1); | |||
|
|||
dx1[x] = std::abs(in_x - in_x1[x]); | |||
dx2[x] = std::abs(in_x - in_x2[x]); | |||
dx1[x] = std::fabs(in_x - in_x1[x]); |
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.
For consistency's sake - we use fabs everywhere else in this file
@@ -197,7 +197,66 @@ TEST(ResizeOpTest, ResizeOpLineartUpSampleTest_2DBilinear_align_corners) { | |||
test.Run(); | |||
} | |||
|
|||
TEST(ResizeOpTest, ResizeOpLineartScalesNoOpTest) { | |||
TEST(ResizeOpTest, ResizeOpLinearDownSampleTest_3DTrilinear_pytorch_half_pixel) { |
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.
3D input + downsample
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kTensorrtExecutionProvider}); // TensorRT: results mismatch | ||
} | ||
|
||
TEST(ResizeOpTest, ResizeOpLinearUpSampleTest_5DTrilinear_pytorch_half_pixel) { |
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.
5D input + upsample
@@ -23,7 +23,7 @@ void ResizeImpl( | |||
TArray<int64_t>& input_strides, | |||
TArray<fast_divmod>& output_div_pitches, | |||
TArray<float>& scales_vals, | |||
TArray<float>& roi, | |||
TArray<float, 10>& roi, |
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.
default capacity is 8 which doesn't compile when input is 5D and roi vector contains 10 elements
@@ -310,24 +310,46 @@ void UpsampleBilinear(int64_t batch_size, | |||
AllocatorPtr& alloc, | |||
GetOriginalCoordinateFunc get_original_coordinate) { | |||
std::vector<float> y_original; | |||
y_original.reserve(output_height); |
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.
best to reserve memory - we know the number of elements that we are going to put into this container.
Can you validate these newly supported scenarios using onnx's implementation of resize. Basically use the test data from your test cases with the resize implementation here https://github.com/onnx/onnx/blob/master/onnx/backend/test/case/node/resize.py and see whether the output's match. |
I believe I did that for the upsampling test. Let me run the downsampling test data for completeness’ sake. |
I ran both the test inputs to the |
Description: Support 3-D input (or 5-D input with outermost 2 scales being 1.0 - batched multi-channel volumes [N,C, D, H, W]) for the "Linear" mode in the CPU and CUDA Resize kernels
Motivation and Context
Support a first party ONNX model in ORT