Skip to content

Commit

Permalink
add empty string to not to check the error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
chilo-ms committed Feb 15, 2025
1 parent ea8f11e commit e6f4fcf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
10 changes: 10 additions & 0 deletions onnxruntime/test/providers/base_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ void BaseTester::ExecuteModel(Model& model, SessionType& session,
ASSERT_EQ(expect_result, ExpectResult::kExpectFailure) << "Initialize failed but expected success: "
<< status.ErrorMessage();

// No need to check expected failure string is empty string is given.
if (expected_failure_string.empty()) {
return;
}

// Disable expected_failure_string checks for OpenVINO EP
if (provider_type != kOpenVINOExecutionProvider) {
EXPECT_THAT(status.ErrorMessage(), testing::HasSubstr(expected_failure_string));
Expand All @@ -337,6 +342,11 @@ void BaseTester::ExecuteModel(Model& model, SessionType& session,
ASSERT_EQ(expect_result, ExpectResult::kExpectFailure) << "Run failed but expected success: "
<< status.ErrorMessage();

// No need to check expected failure string is empty string is given.
if (expected_failure_string.empty()) {
return;
}

// Disable expected_failure_string checks for MKL-DNN and OpenVINO EP's
if (provider_type != kDnnlExecutionProvider &&
provider_type != kOpenVINOExecutionProvider) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,21 @@ TEST(NonMaxSuppressionOpTest, TwoClasses) {
test.AddInput<int64_t>("max_output_boxes_per_class", {}, {6L});
test.AddInput<float>("iou_threshold", {}, {0.5f});
test.AddInput<float>("score_threshold", {}, {0.0f});
// The selected_indices in ORT is sorted by class, whereas in TRT the selected_indices is sorted by score,
// So it needs to sort the output to pass the output check when there is more than one class using TRT EP.
#ifdef USE_TENSORRT
bool sort_output = true;
#else
bool sort_output = false; // default
#endif
test.AddOutput<int64_t>("selected_indices", {6, 3},
{0L, 0L, 3L,
0L, 0L, 0L,
0L, 0L, 5L,
0L, 1L, 3L,
0L, 1L, 0L,
0L, 1L, 5L});
0L, 1L, 5L},
sort_output);
test.Run();
}

Expand Down Expand Up @@ -125,6 +133,13 @@ TEST(NonMaxSuppressionOpTest, TwoBatches_TwoClasses) {
0.1f, 0.2f, 0.6f, 0.3f, 0.9f});
test.AddInput<int64_t>("max_output_boxes_per_class", {}, {2L});
test.AddInput<float>("iou_threshold", {}, {0.8f});
// The selected_indices in ORT is sorted by class, whereas in TRT the selected_indices is sorted by score,
// So it needs to sort the output to pass the output check when there is more than one class using TRT EP.
#ifdef USE_TENSORRT
bool sort_output = true;
#else
bool sort_output = false; // default
#endif
test.AddOutput<int64_t>("selected_indices", {8, 3},
{0L, 0L, 4L,
0L, 0L, 2L,
Expand All @@ -134,7 +149,8 @@ TEST(NonMaxSuppressionOpTest, TwoBatches_TwoClasses) {
1L, 0L, 4L,
1L, 0L, 1L,
1L, 1L, 4L,
1L, 1L, 1L});
1L, 1L, 1L},
sort_output);
test.Run();
}

Expand Down Expand Up @@ -302,7 +318,11 @@ TEST(NonMaxSuppressionOpTest, InconsistentBoxAndScoreShapes) {
test.AddInput<float>("iou_threshold", {}, {0.5f});
test.AddInput<float>("score_threshold", {}, {0.0f});
test.AddOutput<int64_t>("selected_indices", {0, 3}, {});
#ifdef USE_TENSORRT
test.Run(OpTester::ExpectResult::kExpectFailure, ""); // TensorRT EP will output different failure message, providing empty string simply skips checking the error message.
#else
test.Run(OpTester::ExpectResult::kExpectFailure, "boxes and scores should have same spatial_dimension.");
#endif
}

TEST(NonMaxSuppressionOpTest, InvalidIOUThreshold) {
Expand Down

0 comments on commit e6f4fcf

Please sign in to comment.