Skip to content

Commit

Permalink
fix android UT failure
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyu-wang committed Feb 1, 2022
1 parent 52146cf commit d460f5b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
17 changes: 7 additions & 10 deletions onnxruntime/test/optimizer/qdq_test_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ namespace test {

GetQDQTestCaseFn BuildQDQResizeTestCase(
const std::vector<int64_t>& input_shape,
const std::vector<int64_t>& sizes_data) {
return [input_shape, sizes_data](ModelTestBuilder& builder) {
const std::vector<int64_t>& 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<uint8_t>(input_shape,
std::numeric_limits<uint8_t>::min(),
std::numeric_limits<uint8_t>::max());
Expand All @@ -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<uint8_t>(resize_output, .003f, 1, output_arg);
};
Expand Down
5 changes: 4 additions & 1 deletion onnxruntime/test/optimizer/qdq_test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ GetQDQTestCaseFn BuildQDQConvTestCase(const std::vector<int64_t>& input_shape, c
};
}

GetQDQTestCaseFn BuildQDQResizeTestCase(const std::vector<int64_t>& input_shape, const std::vector<int64_t>& sizes_data);
GetQDQTestCaseFn BuildQDQResizeTestCase(const std::vector<int64_t>& input_shape,
const std::vector<int64_t>& sizes_data,
const std::string& mode = "nearest",
const std::string& coordinate_transformation_mode = "half_pixel");

} // namespace test
} // namespace onnxruntime
6 changes: 5 additions & 1 deletion onnxruntime/test/providers/nnapi/nnapi_basic_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down

0 comments on commit d460f5b

Please sign in to comment.