Skip to content

Commit

Permalink
Added test for wrong type v2 exception
Browse files Browse the repository at this point in the history
  • Loading branch information
gkrivor committed Mar 14, 2024
1 parent 9ca9768 commit a60c525
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 3 deletions.
48 changes: 48 additions & 0 deletions src/frontends/onnx/tests/models/reduce_wrong_type_v2.prototxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
ir_version: 3
producer_name: "OpenVINO ONNX Frontend"
graph {
node {
input: "A"
output: "B"
op_type: "ReduceSum"
}
name: "compute_graph"
input {
name: "A"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 1
}
dim {
dim_value: 1
}
dim {
dim_value: 4
}
dim {
dim_value: 4
}
}
}
}
}
output {
name: "B"
type {
tensor_type {
elem_type: 3
shape {
dim {
dim_value: 1
}
}
}
}
}
}
opset_import {
version: 13
}
22 changes: 19 additions & 3 deletions src/frontends/onnx/tests/onnx_import_exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,35 @@ TEST(onnx_importer, exception_msg_std_err_wrapped) {
}
}


TEST(onnx_importer, exception_msg_onnx_reduce_wrong_type_v1) {
try {
convert_model("reduce_wrong_type_v1.onnx");
// Should have thrown, so fail if it didn't
FAIL() << "ONNX Importer did not detected incorrect model!";
} catch (const ::ov::Exception& e) {
EXPECT_HAS_SUBSTRING(e.what(), std::string("While validating ONNX node '<Node(ReduceProd)"));
EXPECT_HAS_SUBSTRING(e.what(), std::string("Unsupported input type bf16"));
}
// On MacOS after we re-throw ov::Exception exception, we couldn't catch it as is,
// thus below workaround.
catch (const std::exception& e) {
EXPECT_HAS_SUBSTRING(e.what(), std::string("Unsupported input type bf16"));
} catch (...) {
FAIL() << "The ONNX model importer failed for unexpected reason";
}
}

TEST(onnx_importer, exception_msg_onnx_reduce_wrong_type_v2) {
try {
convert_model("reduce_wrong_type_v2.onnx");
// Should have thrown, so fail if it didn't
FAIL() << "ONNX Importer did not detected incorrect model!";
} catch (const ::ov::Exception& e) {
EXPECT_HAS_SUBSTRING(e.what(), std::string("Unsupported input type i8"));
}
// On MacOS after we re-throw ov::Exception exception, we couldn't catch it as is,
// thus below workaround.
catch (const std::exception& e) {
EXPECT_HAS_SUBSTRING(e.what(), std::string("While validating ONNX node '<Node(ReduceProd)"));
EXPECT_HAS_SUBSTRING(e.what(), std::string("Unsupported input type i8"));
} catch (...) {
FAIL() << "The ONNX model importer failed for unexpected reason";
}
Expand Down

0 comments on commit a60c525

Please sign in to comment.