diff --git a/onnxruntime/test/optimizer/qdq_test_utils.cc b/onnxruntime/test/optimizer/qdq_test_utils.cc index 44b5aee686b96..08c1c751991b4 100644 --- a/onnxruntime/test/optimizer/qdq_test_utils.cc +++ b/onnxruntime/test/optimizer/qdq_test_utils.cc @@ -8,8 +8,10 @@ namespace test { GetQDQTestCaseFn BuildQDQResizeTestCase( const std::vector& input_shape, - const std::vector& sizes_data) { - return [input_shape, sizes_data](ModelTestBuilder& builder) { + const std::vector& sizes_data, + const std::string& mode, + const std::string& coordinate_transformation_mode) { + return [input_shape, sizes_data, mode, coordinate_transformation_mode](ModelTestBuilder& builder) { auto* input1_arg = builder.MakeInput(input_shape, std::numeric_limits::min(), std::numeric_limits::max()); @@ -26,14 +28,9 @@ GetQDQTestCaseFn BuildQDQResizeTestCase( auto* resize_output = builder.MakeIntermediate(); Node& resize_node = builder.AddNode("Resize", {dq_output, roi, scales, sizes}, {resize_output}); -// NNAPI EP does not support the default setting of Resize Op -// Use bi-linear and asymmetric for NNAPI EP only -#ifdef USE_NNAPI - resize_node.AddAttribute("mode", "linear"); - resize_node.AddAttribute("coordinate_transformation_mode", "asymmetric"); -#else - ORT_UNUSED_PARAMETER(resize_node); -#endif + resize_node.AddAttribute("mode", mode); + resize_node.AddAttribute("coordinate_transformation_mode", coordinate_transformation_mode); + // add Q builder.AddQuantizeLinearNode(resize_output, .003f, 1, output_arg); }; diff --git a/onnxruntime/test/optimizer/qdq_test_utils.h b/onnxruntime/test/optimizer/qdq_test_utils.h index 7ae23ba3611a0..118ed8697dae0 100644 --- a/onnxruntime/test/optimizer/qdq_test_utils.h +++ b/onnxruntime/test/optimizer/qdq_test_utils.h @@ -78,7 +78,10 @@ GetQDQTestCaseFn BuildQDQConvTestCase(const std::vector& input_shape, c }; } -GetQDQTestCaseFn BuildQDQResizeTestCase(const std::vector& input_shape, const std::vector& sizes_data); +GetQDQTestCaseFn BuildQDQResizeTestCase(const std::vector& input_shape, + const std::vector& sizes_data, + const std::string& mode = "nearest", + const std::string& coordinate_transformation_mode = "half_pixel"); } // namespace test } // namespace onnxruntime \ No newline at end of file diff --git a/onnxruntime/test/providers/nnapi/nnapi_basic_test.cc b/onnxruntime/test/providers/nnapi/nnapi_basic_test.cc index 98077c480f643..d0cd2bb786653 100644 --- a/onnxruntime/test/providers/nnapi/nnapi_basic_test.cc +++ b/onnxruntime/test/providers/nnapi/nnapi_basic_test.cc @@ -278,8 +278,12 @@ TEST(NnapiExecutionProviderTest, TestQDQConv) { } TEST(NnapiExecutionProviderTest, TestQDQResize) { + // NNAPI EP does not support the default setting of Resize Op + // Use bi-linear and asymmetric for NNAPI EP only RunQDQModelTest(BuildQDQResizeTestCase({1, 3, 64, 64} /* input_shape */, - {1, 3, 32, 32} /* sizes_data */), + {1, 3, 32, 32} /* sizes_data */, + "linear" /* mode */, + "asymmetric" /* coordinate_transformation_mode */), "nnapi_qdq_test_graph_resize"); }