diff --git a/src/frontends/onnx/frontend/src/exceptions.cpp b/src/frontends/onnx/frontend/src/exceptions.cpp index af49f722744c9e..95cc74d5009d16 100644 --- a/src/frontends/onnx/frontend/src/exceptions.cpp +++ b/src/frontends/onnx/frontend/src/exceptions.cpp @@ -8,12 +8,13 @@ #include "openvino/core/deprecated.hpp" -namespace ngraph { -namespace onnx_import { -namespace error { -namespace detail { OPENVINO_SUPPRESS_DEPRECATED_START -std::string get_error_msg_prefix(const Node& node) { + +namespace ov { +namespace frontend { +namespace onnx_error { +namespace detail { +std::string get_error_msg_prefix(const ngraph::onnx_import::Node& node) { std::stringstream ss; ss << "While validating ONNX node '" << node << "'"; return ss.str(); @@ -23,12 +24,13 @@ std::string get_error_msg_prefix(const Node& node) { void OnnxNodeValidationFailure::create(const char* file, int line, const char* check_string, - const Node& node, + const ngraph::onnx_import::Node& node, const std::string& explanation) { throw OnnxNodeValidationFailure( make_what(file, line, check_string, detail::get_error_msg_prefix(node), explanation)); } +} // namespace onnx_error +} // namespace frontend +} // namespace ov + OPENVINO_SUPPRESS_DEPRECATED_END -} // namespace error -} // namespace onnx_import -} // namespace ngraph diff --git a/src/frontends/onnx/frontend/src/exceptions.hpp b/src/frontends/onnx/frontend/src/exceptions.hpp index 05dcbfbbddd6b5..b8a40bef9ad010 100644 --- a/src/frontends/onnx/frontend/src/exceptions.hpp +++ b/src/frontends/onnx/frontend/src/exceptions.hpp @@ -6,19 +6,18 @@ #include -#include "ngraph/check.hpp" -#include "ngraph/except.hpp" #include "onnx_import/core/node.hpp" #include "openvino/core/deprecated.hpp" #include "openvino/core/except.hpp" #include "utils/tensor_external_data.hpp" -namespace ngraph { -namespace onnx_import { -namespace error { +namespace ov { +namespace frontend { +namespace onnx_error { + namespace detail { OPENVINO_SUPPRESS_DEPRECATED_START -std::string get_error_msg_prefix(const Node& node); +std::string get_error_msg_prefix(const ngraph::onnx_import::Node& node); OPENVINO_SUPPRESS_DEPRECATED_END } // namespace detail @@ -27,7 +26,7 @@ class OnnxNodeValidationFailure : public ov::AssertFailure { OPENVINO_SUPPRESS_DEPRECATED_START [[noreturn]] static void create(const char* file, int line, const char* check_string, - const Node& node, + const ngraph::onnx_import::Node& node, const std::string& explanation); OPENVINO_SUPPRESS_DEPRECATED_END @@ -36,18 +35,24 @@ class OnnxNodeValidationFailure : public ov::AssertFailure { }; OPENVINO_SUPPRESS_DEPRECATED_START -struct invalid_external_data : ngraph_error { - invalid_external_data(const onnx_import::detail::TensorExternalData& external_data) - : ngraph_error{std::string{"invalid external data: "} + external_data.to_string()} {} - invalid_external_data(const std::string& what_arg) : ngraph_error{what_arg} {} +struct invalid_external_data : ov::Exception { + invalid_external_data(const ngraph::onnx_import::detail::TensorExternalData& external_data) + : ov::Exception{std::string{"invalid external data: "} + external_data.to_string()} {} + invalid_external_data(const std::string& what_arg) : ov::Exception{what_arg} {} }; OPENVINO_SUPPRESS_DEPRECATED_END -} // namespace error +} // namespace onnx_error +} // namespace frontend +} // namespace ov -} // namespace onnx_import - -} // namespace ngraph +namespace ngraph { +namespace onnx_import { +namespace error { +using namespace ov::frontend::onnx_error; +} // namespace error +} // namespace onnx_import +} // namespace ngraph #define CHECK_VALID_NODE(node_, cond_, ...) \ - OPENVINO_ASSERT_HELPER(::ngraph::onnx_import::error::OnnxNodeValidationFailure, (node_), (cond_), ##__VA_ARGS__) + OPENVINO_ASSERT_HELPER(ov::frontend::onnx_error::OnnxNodeValidationFailure, (node_), (cond_), ##__VA_ARGS__) diff --git a/src/frontends/onnx/tests/onnx_import_dyn_shapes.in.cpp b/src/frontends/onnx/tests/onnx_import_dyn_shapes.in.cpp index d9a3b81507f99f..723845347edc0a 100644 --- a/src/frontends/onnx/tests/onnx_import_dyn_shapes.in.cpp +++ b/src/frontends/onnx/tests/onnx_import_dyn_shapes.in.cpp @@ -16,32 +16,26 @@ #include #include "common_test_utils/file_utils.hpp" -#include "default_opset.hpp" #include "common_test_utils/test_case.hpp" -#include "gtest/gtest.h" -#include "ngraph/file_util.hpp" -#include "onnx_import/onnx.hpp" #include "common_test_utils/test_control.hpp" #include "common_test_utils/test_tools.hpp" #include "common_test_utils/type_prop.hpp" +#include "gtest/gtest.h" #include "onnx_utils.hpp" +#include "openvino/op/constant.hpp" -using namespace ngraph; -using namespace ngraph::onnx_import; +using namespace ov; +using namespace ov::frontend::onnx::tests; -OPENVINO_SUPPRESS_DEPRECATED_START - -static std::string s_manifest = ngraph::file_util::path_join(ov::test::utils::getExecutableDirectory(), "${MANIFEST}"); +static std::string s_manifest = onnx_backend_manifest("${MANIFEST}"); static std::string s_device = backend_name_to_device("${BACKEND_NAME}"); -OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_onnx_dynamic_dims_to_ngraph_dynamic_dims) { - // the model represents a linear function A * x + B +OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_onnx_dynamic_dims_to_ov_dynamic_dims) { + // the model represents a linear model A * x + B // where all 3 operands are model inputs (no initializers) - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/ab_plus_c.onnx")); + const auto model = convert_model("dynamic_shapes/ab_plus_c.onnx"); - const auto& graph_inputs = function->get_parameters(); + const auto& graph_inputs = model->get_parameters(); EXPECT_EQ(graph_inputs.size(), 3); // all inputs in the model have a 2D partial shape {?, 2} @@ -57,7 +51,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_onnx_dynamic_dims_to_ngraph_dynam EXPECT_EQ(input_ps[1].get_length(), 2); } - const auto& graph_outputs = function->get_results(); + const auto& graph_outputs = model->get_results(); EXPECT_EQ(graph_outputs.size(), 1); const auto out = *(graph_outputs.cbegin()); @@ -71,11 +65,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_onnx_dynamic_dims_to_ngraph_dynam } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_ab_plus_c_inference) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/ab_plus_c.onnx")); + const auto model = convert_model("dynamic_shapes/ab_plus_c.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); struct ExpectedValuesGenerator { int64_t i = 1; @@ -110,13 +102,10 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_ab_plus_c_inference) { OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_scalar_initializers_shape_check) { // initializers defined witout the "dims" field should produce Constants with an empty Shape // initializers with "dims: 0" should be have the same way (Shape{} not Shape{0}) - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/scalar_initializers.onnx")); + const auto model = convert_model("dynamic_shapes/scalar_initializers.onnx"); - for (auto ng_node : function->get_ordered_ops()) { - if (as_type_ptr(ng_node)) { + for (auto ng_node : model->get_ordered_ops()) { + if (as_type_ptr(ng_node)) { EXPECT_EQ(ng_node->get_shape(), Shape{}); } } @@ -124,12 +113,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_scalar_initializers_shape_check) OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_dynamic_rank_input_check) { // the model contains a single Add operation that takes a fully dynamic input and a scalar - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/a_plus_b_dyn_rank.onnx")); + const auto model = convert_model("dynamic_shapes/a_plus_b_dyn_rank.onnx"); - const auto& graph_inputs = function->get_parameters(); + const auto& graph_inputs = model->get_parameters(); ASSERT_EQ(graph_inputs.size(), 2); const auto dyn_rank_input = graph_inputs[0]; @@ -140,7 +126,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_dynamic_rank_input_check) { ASSERT_TRUE(scalar_input->get_partial_shape().is_static()); EXPECT_EQ(scalar_input->get_partial_shape().to_shape(), Shape{}); - const auto& graph_outputs = function->get_results(); + const auto& graph_outputs = model->get_results(); EXPECT_EQ(graph_outputs.size(), 1); const auto out = *(graph_outputs.cbegin()); @@ -149,12 +135,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_dynamic_rank_input_check) { OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_dynamic_rank_input_inference) { // the model contains a single Add operation that takes a fully dynamic input and a scalar - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/a_plus_b_dyn_rank.onnx")); + const auto model = convert_model("dynamic_shapes/a_plus_b_dyn_rank.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const size_t RANKS_TO_TEST = 3; const int64_t SCALAR_INPUT_VAL = 5; @@ -178,11 +161,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_dynamic_rank_input_inference) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_acosh_1_3) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/acosh_dyn_shape.onnx")); + auto model = convert_model("dynamic_shapes/acosh_dyn_shape.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{1, 3}, {1.0f, 2.5f, 4.3f}); test_case.add_expected_output(Shape{1, 3}, {0.0f, 1.5667993f, 2.1379586f}); @@ -190,11 +171,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_acosh_1_3) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_acosh_3_2) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/acosh_dyn_shape.onnx")); + auto model = convert_model("dynamic_shapes/acosh_dyn_shape.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{3, 2}, {1.0f, 2.5f, 4.3f, 1.0f, 2.5f, 4.3f}); test_case.add_expected_output(Shape{3, 2}, {0.0f, 1.5667993f, 2.1379586f, 0.0f, 1.5667993f, 2.1379586f}); @@ -202,11 +181,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_acosh_3_2) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_asinh_1_3) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/asinh_dyn_shape.onnx")); + auto model = convert_model("dynamic_shapes/asinh_dyn_shape.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{1, 3}, {-1.5f, 0.0f, 1.5f}); test_case.add_expected_output(Shape{1, 3}, {-1.1947632f, 0.0f, 1.1947632f}); @@ -214,11 +191,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_asinh_1_3) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_asinh_3_2) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/asinh_dyn_shape.onnx")); + auto model = convert_model("dynamic_shapes/asinh_dyn_shape.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{3, 2}, {-1.5f, 0.0f, 1.5f, -1.5f, 0.0f, 1.5f}); test_case.add_expected_output(Shape{3, 2}, {-1.1947632f, 0.0f, 1.1947632f, -1.1947632f, 0.0f, 1.1947632f}); @@ -226,11 +201,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_asinh_3_2) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_atanh_1_3) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/atanh_dyn_shape.onnx")); + auto model = convert_model("dynamic_shapes/atanh_dyn_shape.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{1, 3}, {-0.9f, 0.0f, 0.9f}); test_case.add_expected_output(Shape{1, 3}, {-1.47221948f, 0.0f, 1.47221948f}); @@ -238,11 +211,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_atanh_1_3) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_atanh_3_2) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/atanh_dyn_shape.onnx")); + auto model = convert_model("dynamic_shapes/atanh_dyn_shape.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{3, 2}, {-0.9f, 0.0f, 0.9f, -0.9f, 0.0f, 0.9f}); test_case.add_expected_output(Shape{3, 2}, {-1.47221948f, 0.0f, 1.47221948f, -1.47221948f, 0.0f, 1.47221948f}); @@ -251,12 +222,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_atanh_3_2) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_conv_with_dynamic_batch) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/conv_with_dynamic_batch.onnx")); + const auto model = convert_model("dynamic_shapes/conv_with_dynamic_batch.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const auto data_shape = Shape{1, 3, 7, 7}; const auto filters_shape = Shape{10, 3, 2, 2}; @@ -275,12 +243,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_conv_with_dynamic_batch) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_conv_with_dynamic_bias) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/conv_with_dynamic_bias.onnx")); + const auto model = convert_model("dynamic_shapes/conv_with_dynamic_bias.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const auto data_shape = Shape{1, 3, 7, 7}; const auto filters_shape = Shape{10, 3, 2, 2}; @@ -299,12 +264,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_conv_with_dynamic_bias) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_avg_pool_dyn_shape) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/average_pool_2d_dyn.onnx")); + const auto model = convert_model("dynamic_shapes/average_pool_2d_dyn.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const Shape shape{1, 1, 4, 4}; const auto elems_in_tensor = shape_size(shape); @@ -320,12 +282,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_avg_pool_dyn_shape) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_max_pool_dyn_shape) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/max_pool_2d_dyn.onnx")); + const auto model = convert_model("dynamic_shapes/max_pool_2d_dyn.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const Shape shape{1, 1, 4, 4}; const auto elems_in_tensor = shape_size(shape); @@ -341,12 +300,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_max_pool_dyn_shape) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_max_pool_with_indices_output) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/max_pool_with_indices_output.onnx")); + const auto model = convert_model("dynamic_shapes/max_pool_with_indices_output.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const Shape shape{1, 1, 5, 5}; std::vector input_values(shape_size(shape)); @@ -365,12 +321,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_max_pool_with_indices_output) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_global_avg_pool_dyn_shape) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/global_average_pool_dyn.onnx")); + const auto model = convert_model("dynamic_shapes/global_average_pool_dyn.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const Shape shape{1, 3, 5, 5}; const auto elems_in_tensor = shape_size(shape); @@ -386,12 +339,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_global_avg_pool_dyn_shape) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_global_max_pool_dyn_shape) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/global_max_pool_dyn.onnx")); + const auto model = convert_model("dynamic_shapes/global_max_pool_dyn.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const Shape shape{1, 3, 5, 5}; const auto elems_in_tensor = shape_size(shape); @@ -407,11 +357,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_global_max_pool_dyn_shape) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_arg_max_dyn_shape) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/argmax_dyn.onnx")); + const auto model = convert_model("dynamic_shapes/argmax_dyn.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const Shape shape{3, 2, 2}; const auto elems_in_tensor = shape_size(shape); @@ -427,12 +375,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_arg_max_dyn_shape) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_arg_min_no_keep_dims_dyn_shape) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/argmin_no_keep_dims_dyn.onnx")); + const auto model = convert_model("dynamic_shapes/argmin_no_keep_dims_dyn.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const Shape shape{3, 2, 2}; const auto elems_in_tensor = shape_size(shape); @@ -448,14 +393,11 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_arg_min_no_keep_dims_dyn_shape) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_constant_of_shape_float_zeros) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/constant_of_shape_float_zeros.onnx")); + auto model = convert_model("dynamic_shapes/constant_of_shape_float_zeros.onnx"); std::vector expected_values(24, 0); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{3}, std::vector{2, 3, 4}); test_case.add_expected_output(Shape{2, 3, 4}, expected_values); @@ -464,14 +406,11 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_constant_of_shape_float_zeros) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_constant_of_shape_int_ones) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/constant_of_shape_int_ones.onnx")); + auto model = convert_model("dynamic_shapes/constant_of_shape_int_ones.onnx"); std::vector expected_values(6, 1); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{2}, std::vector{2, 3}); test_case.add_expected_output(Shape{2, 3}, expected_values); @@ -480,11 +419,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_constant_of_shape_int_ones) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_expand_1_dyn_shape) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/expand_dyn.onnx")); + const auto model = convert_model("dynamic_shapes/expand_dyn.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{3, 1}, std::vector{1.f, 2.f, 3.f}); test_case.add_input(Shape{3}, std::vector{2, 1, 6}); @@ -498,11 +435,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_expand_1_dyn_shape) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_expand_2_dyn_shape) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/expand_dyn.onnx")); + const auto model = convert_model("dynamic_shapes/expand_dyn.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{3, 1}, std::vector{1.f, 2.f, 3.f}); test_case.add_input(Shape{3}, std::vector{2, 3, 4}); @@ -515,11 +450,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_expand_2_dyn_shape) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_expand_3_dyn_shape) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/expand_dyn.onnx")); + const auto model = convert_model("dynamic_shapes/expand_dyn.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{2, 1}, std::vector{4.f, 5.f}); test_case.add_input(Shape{2}, std::vector{2, 4}); @@ -531,11 +464,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_expand_3_dyn_shape) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_expand_4_dyn_shape) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/expand_dyn.onnx")); + const auto model = convert_model("dynamic_shapes/expand_dyn.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{1, 3, 1}, std::vector{7.f, 8.f, 9.f}); test_case.add_input(Shape{2}, std::vector{3, 1}); @@ -547,11 +478,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_expand_4_dyn_shape) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_expand_5_dyn_shape) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/expand_dyn.onnx")); + const auto model = convert_model("dynamic_shapes/expand_dyn.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{1, 4, 1}, std::vector{7.f, 8.f, 9.f, 10.f}); test_case.add_input(Shape{2}, std::vector{1, 4}); @@ -564,11 +493,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_expand_5_dyn_shape) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_expand_6_dyn_shape) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/expand_dyn.onnx")); + const auto model = convert_model("dynamic_shapes/expand_dyn.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{1, 3, 1}, std::vector{7.f, 8.f, 9.f}); test_case.add_input(Shape{3}, std::vector{3, 1, 3}); @@ -581,12 +508,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_expand_6_dyn_shape) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_expand_uint16_dyn_shape) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/expand_uint16_dyn.onnx")); + const auto model = convert_model("dynamic_shapes/expand_uint16_dyn.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{1, 2, 1}, std::vector{1, 2}); test_case.add_input(Shape{4}, std::vector{2, 2, 1, 2}); @@ -598,10 +522,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_expand_uint16_dyn_shape) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_tile) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/tile.onnx")); + auto model = convert_model("tile.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input({0, 1, 2, 3, 4, 5}); // input test_case.add_input({2, 1}); // repeats test_case.add_expected_output(Shape{4, 3}, {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5}); @@ -609,10 +532,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_tile) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_tile_static) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/tile_static.onnx")); + auto model = convert_model("tile_static.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input({0, 1, 2, 3, 4, 5}); // input test_case.add_expected_output(Shape{4, 6}, {0, 1, 2, 0, 1, 2, 3, 4, 5, 3, 4, 5, 0, 1, 2, 0, 1, 2, 3, 4, 5, 3, 4, 5}); @@ -620,9 +542,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_tile_static) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_convtranspose_dyn_data) { - auto ct_fn = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/convtranspose_dyn_data.onnx")); + auto ct_fn = convert_model("convtranspose_dyn_data.onnx"); auto test_case = ov::test::TestCase(ct_fn); @@ -662,9 +582,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_convtranspose_dyn_data) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_convtranspose_dyn_filters) { - auto ct_fn = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/convtranspose_dyn_filters.onnx")); + auto ct_fn = convert_model("convtranspose_dyn_filters.onnx"); auto test_case = ov::test::TestCase(ct_fn); @@ -704,10 +622,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_convtranspose_dyn_filters) } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_transpose) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/transpose.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("dynamic_shapes/transpose.onnx"); + auto test_case = ov::test::TestCase(model, s_device); Shape shape{2, 2, 4, 3}; const auto elems_in_tensor = shape_size(shape); @@ -740,11 +656,8 @@ Shape get_flattened_shape(const Shape& in_shape, size_t axis) { } // namespace OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_flatten_axis_0) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/flatten_dyn_shape_axis0.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("dynamic_shapes/flatten_dyn_shape_axis0.onnx"); + auto test_case = ov::test::TestCase(model, s_device); const size_t RANKS_TO_TEST = 4; const size_t AXIS = 0; @@ -767,11 +680,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_flatten_axis_0) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_flatten_axis) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/flatten_dyn_shape_axis.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("dynamic_shapes/flatten_dyn_shape_axis.onnx"); + auto test_case = ov::test::TestCase(model, s_device); const size_t RANKS_TO_TEST = 4; const size_t AXIS = 3; @@ -794,11 +704,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_flatten_axis) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_flatten_neg_axis) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/flatten_dyn_shape_neg_axis.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("dynamic_shapes/flatten_dyn_shape_neg_axis.onnx"); + auto test_case = ov::test::TestCase(model, s_device); const size_t RANKS_TO_TEST = 4; const int64_t AXIS = -3; @@ -821,11 +728,10 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_flatten_neg_axis) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_flatten) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/flatten.onnx")); + auto model = convert_model("flatten.onnx"); std::vector data{1, 2, 3, 4, 5, 6, 7, 8}; - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{1, 2, 2, 2}, data); test_case.add_expected_output(Shape{1, 8}, data); @@ -833,11 +739,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_flatten) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_global_lp_dynamic_hw) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/global_lp_pool_dynamic_hw.onnx")); + auto model = convert_model("global_lp_pool_dynamic_hw.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{1, 2, 3, 4}, {1, 0, -4, 0, 2, 1, -6, 1, 0, 0, 0, 0, -7, 1, -1, 0, -1, 8, 0, 10, 9, 0, 0, 5}); test_case.add_expected_output(Shape{1, 2, 1, 1}, std::vector{6, 8}); @@ -846,11 +750,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_model_global_lp_dynamic_hw) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_2d_input) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/slice_2d_input.onnx")); + auto model = convert_model("dynamic_shapes/slice_2d_input.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(std::vector{1, 2, 3, 4, 5, 6, 7, 8}); test_case.add_input({1, 0}); test_case.add_input({2, 3}); @@ -860,12 +762,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_2d_input) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_default_steps) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/slice_default_steps.onnx")); + auto model = convert_model("dynamic_shapes/slice_default_steps.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input({1, 2, 3, 4, 5, 6, 7, 8}); test_case.add_input({1, 0}); test_case.add_input({2, 3}); @@ -874,12 +773,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_default_steps) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_slice_2d_default_steps_dyn_begin_end) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/slice_2d_default_steps_dyn_begin_end.onnx")); + auto model = convert_model("dynamic_shapes/slice_2d_default_steps_dyn_begin_end.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input({1, 2, 3, 4}); test_case.add_input({2}, {1, 1}); test_case.add_input({2}, {2, 2}); @@ -888,12 +784,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_slice_2d_default_steps_d } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_clamp_neg_ends) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/slice_default_steps.onnx")); + auto model = convert_model("dynamic_shapes/slice_default_steps.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(std::vector{1, 2, 3, 4, 5, 6, 7, 8}); test_case.add_input({0, 1}); test_case.add_input({-1, 1000}); @@ -902,11 +795,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_clamp_neg_ends) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_3d_input) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/slice_3d_input.onnx")); + auto model = convert_model("dynamic_shapes/slice_3d_input.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const Shape input_shape{3, 4, 1}; std::vector input_values(shape_size(input_shape)); @@ -920,12 +811,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_3d_input) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_3d_input_neg_axes) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/slice_3d_input_neg_axes.onnx")); + auto model = convert_model("dynamic_shapes/slice_3d_input_neg_axes.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const Shape input_shape{3, 4, 1}; std::vector input_values(shape_size(input_shape)); @@ -939,12 +827,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_3d_input_neg_axes) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_3d_input_12_axes) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/slice_3d_input_12_axes.onnx")); + auto model = convert_model("dynamic_shapes/slice_3d_input_12_axes.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const Shape input_shape{4, 3, 2}; std::vector input_values(shape_size(input_shape)); @@ -957,12 +842,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_3d_input_12_axes) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_3d_input_20_axes) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/slice_3d_input_20_axes.onnx")); + auto model = convert_model("dynamic_shapes/slice_3d_input_20_axes.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const Shape input_shape{4, 3, 2}; std::vector input_values(shape_size(input_shape)); @@ -976,12 +858,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_3d_input_20_axes) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_4d_input_23_axes) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/slice_4d_input_23_axes.onnx")); + auto model = convert_model("dynamic_shapes/slice_4d_input_23_axes.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const Shape input_shape{2, 2, 2, 2}; std::vector input_values(shape_size(input_shape)); @@ -994,12 +873,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_4d_input_23_axes) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_4d_input_0231_axes_ends_max) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/slice_4d_input_0231_axes_ends_max.onnx")); + auto model = convert_model("dynamic_shapes/slice_4d_input_0231_axes_ends_max.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const Shape input_shape{2, 2, 2, 2}; std::vector input_values(shape_size(input_shape)); @@ -1015,12 +891,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_4d_input_0231_axes_ends_ } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_4d_input_2103_axes_ends_max) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/slice_4d_input_2103_axes.onnx")); + auto model = convert_model("dynamic_shapes/slice_4d_input_2103_axes.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const Shape input_shape{2, 2, 2, 5}; std::vector input_values(shape_size(input_shape)); @@ -1037,12 +910,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_4d_input_2103_axes_ends_ } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_4d_input_23_axes_21_steps) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/slice_4d_input_23_axes_21_steps.onnx")); + auto model = convert_model("dynamic_shapes/slice_4d_input_23_axes_21_steps.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const Shape input_shape{2, 2, 6, 2}; std::vector input_values(shape_size(input_shape)); @@ -1055,11 +925,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_4d_input_23_axes_21_step } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_default_axes) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/slice_default_axes.onnx")); + auto model = convert_model("dynamic_shapes/slice_default_axes.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const Shape input_shape{4, 3, 2}; std::vector input_values(shape_size(input_shape)); @@ -1071,12 +939,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_default_axes) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_the_same_output_same) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/slice_2d_the_same_out_shape.onnx")); + auto model = convert_model("dynamic_shapes/slice_2d_the_same_out_shape.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(std::vector{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f}); test_case.add_input(std::vector{1.0f, 1.0f}); test_case.add_expected_output(Shape{3, 2}, {2.0f, 1.0f, 4.0f, 3.0f, 6.0f, 5.0f}); @@ -1084,10 +949,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_10_the_same_output_same) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_model_hardmax) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/hardmax.onnx")); + auto model = convert_model("hardmax.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input( {-2.02458119f, 0.00126542f, -0.58045743f, -0.75186814f, 0.9406899f, -0.513188f, 0.85887463f, 1.61444086f, 0.23801147f, -0.26816885f, 0.6597208f, 1.43889519f, 0.28798895f, 1.44769952f, @@ -1115,8 +979,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_model_hardmax) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_model_softmax_axis_2) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/softmax_axis_2.onnx")); + auto model = convert_model("softmax_axis_2.onnx"); const std::vector input = { 2.75793882f, -0.50841322f, 0.82013929f, -0.62409912f, -0.96136118f, 0.21004745f, 1.38337255f, @@ -1131,7 +994,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_model_softmax_axis_2) { -1.24478184f, 2.65316853f, 1.19509542f, -0.95523998f, 0.5149006f, -0.01151649f, 0.68327026f, -0.4589638f, -0.46554745f, 0.21055324f, 0.39266729f, 2.05098086f, 1.83207919f}; - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(input); test_case.add_expected_output( @@ -1152,10 +1015,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_model_softmax_axis_2) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_range_positive_step) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/range.onnx")); + const auto model = convert_model("range.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input({1.f}); test_case.add_input({10.f}); @@ -1166,10 +1028,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_range_positive_step) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_range_negative_step) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/range.onnx")); + const auto model = convert_model("range.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input({10.f}); test_case.add_input({1.f}); @@ -1180,16 +1041,13 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_range_negative_step) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_instance_normalization_dyn_shape) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/instance_norm_dyn_shape.onnx")); + const auto model = convert_model("dynamic_shapes/instance_norm_dyn_shape.onnx"); Shape data_shape{1, 2, 3, 4}; std::vector data(shape_size(data_shape)); std::iota(std::begin(data), std::end(data), 1.f); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(data_shape, data); test_case.add_input(Shape{2}, std::vector{2.134f, 3.256f}); @@ -1203,16 +1061,13 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_instance_normalization_dyn_shape) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_instance_normalization_dyn_shape2) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/instance_norm_dyn_shape2.onnx")); + const auto model = convert_model("dynamic_shapes/instance_norm_dyn_shape2.onnx"); Shape data_shape{1, 2, 3, 4}; std::vector data(shape_size(data_shape)); std::iota(std::begin(data), std::end(data), 1.f); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(data_shape, data); test_case.add_input(std::vector{2.134f, 3.256f}); @@ -1227,15 +1082,15 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_instance_normalization_dyn_shape2) { // OPENVINO_TEST(${BACKEND_NAME}, onnx_upsample9_scales_input_nearest_infer) // { -// const auto function = onnx_import::import_onnx_model( -// file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, -// "onnx/upsample9_scales_input_nearest.onnx")); +// const auto model = convert_model( +// +// "upsample9_scales_input_nearest.onnx"); // // // Input data shape (1, 1, 2, 2) // // mode: nearest // // Shape expected_output_shape{1, 1, 4, 6}; -// auto test_case = ov::test::TestCase(function, s_device); +// auto test_case = ov::test::TestCase(model, s_device); // test_case.add_input({1.0, 2.0, 3.0, 4.0}); // test_case.add_input({1.0, 1.0, 2.0, 3.0}); // test_case.add_expected_output( @@ -1245,36 +1100,27 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_instance_normalization_dyn_shape2) { // } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_1_2d_input) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/slice_2d_input_opset1.onnx")); + auto model = convert_model("dynamic_shapes/slice_2d_input_opset1.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(std::vector{1, 2, 3, 4, 5, 6, 7, 8}); test_case.add_expected_output(Shape{1, 4}, {5, 6, 7, 8}); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_1_clamp_neg_ends) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/slice_2d_clamp_neg_ends_opset1.onnx")); + auto model = convert_model("dynamic_shapes/slice_2d_clamp_neg_ends_opset1.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(std::vector{1, 2, 3, 4, 5, 6, 7, 8}); test_case.add_expected_output(Shape{1, 3}, {2, 3, 4}); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_1_3d_input_21_axes_ends_max) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/slice_3d_input_21_axes_ends_max_opset1.onnx")); + auto model = convert_model("dynamic_shapes/slice_3d_input_21_axes_ends_max_opset1.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); const Shape input_shape{1, 2, 3, 4}; std::vector input_values(shape_size(input_shape)); @@ -1286,35 +1132,27 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_slice_1_3d_input_21_axes_ends_max OPENVINO_TEST(${BACKEND_NAME}, onnx_dyn_shapes_reduce_max_dynamic_input_rank_negative_axis) { // the ReduceMax node has a fully dynamic input and the reduction axis is -1 - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/reduce_max_dynamic_input_rank_negative_axis.onnx")); + auto model = convert_model("dynamic_shapes/reduce_max_dynamic_input_rank_negative_axis.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{2, 4}, std::vector{1, 2, 3, 4, 5, 6, 7, 8}); test_case.add_expected_output(Shape{2, 1}, {4, 8}); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_size_dyn_op) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/size_op_dyn.onnx")); + const auto model = convert_model("dynamic_shapes/size_op_dyn.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{2, 3}, {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}); test_case.add_expected_output(Shape{}, {6}); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_max_pool_dyn_rank_without_default_attrs) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/max_pool_dyn_rank_without_default_attrs.onnx")); + auto model = convert_model("dynamic_shapes/max_pool_dyn_rank_without_default_attrs.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); Shape input_shape{1, 1, 4, 4}; std::vector input(shape_size(input_shape)); @@ -1325,9 +1163,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_max_pool_dyn_rank_without_default_attr } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_depth_to_space_dynamic_input) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/depth_to_space.onnx")); + auto model = convert_model("dynamic_shapes/depth_to_space.onnx"); std::vector input(32); std::iota(input.begin(), input.end(), 0.f); @@ -1336,16 +1172,14 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_depth_to_space_dynamic_input) { 11.f, 18.f, 26.f, 19.f, 27.f, 4.f, 12.f, 5.f, 13.f, 20.f, 28.f, 21.f, 29.f, 6.f, 14.f, 7.f, 15.f, 22.f, 30.f, 23.f, 31.f}; - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{1, 8, 2, 2}, input); test_case.add_expected_output(Shape{1, 2, 4, 4}, expected_output); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_space_to_depth_dynamic_input) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/space_to_depth.onnx")); + auto model = convert_model("dynamic_shapes/space_to_depth.onnx"); std::vector input(32); std::iota(input.begin(), input.end(), 0.f); @@ -1355,19 +1189,16 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_space_to_depth_dynamic_input) { 4.f, 6.f, 12.f, 14.f, 20.f, 22.f, 28.f, 30.f, 5.f, 7.f, 13.f, 15.f, 21.f, 23.f, 29.f, 31.f, }; - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{1, 2, 4, 4}, input); test_case.add_expected_output(Shape{1, 8, 2, 2}, expected_output); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_eye_like_dyn_shape) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/eye_like_dyn_shape.onnx")); + const auto model = convert_model("dynamic_shapes/eye_like_dyn_shape.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{3, 4}, {5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f}); test_case.add_expected_output(Shape{3, 4}, {0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f}); @@ -1375,12 +1206,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_eye_like_dyn_shape) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_eye_like_dyn_rank) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/dynamic_shapes/eye_like_dyn_rank.onnx")); + const auto model = convert_model("dynamic_shapes/eye_like_dyn_rank.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{3, 4}, {5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f, 5.f}); test_case.add_expected_output(Shape{3, 4}, {0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f, 0.f, 0.f, 1.f, 0.f, 0.f}); diff --git a/src/frontends/onnx/tests/onnx_import_exceptions.cpp b/src/frontends/onnx/tests/onnx_import_exceptions.cpp index 66398cb4d405dd..3af1c53c9cc55d 100644 --- a/src/frontends/onnx/tests/onnx_import_exceptions.cpp +++ b/src/frontends/onnx/tests/onnx_import_exceptions.cpp @@ -8,29 +8,22 @@ #include "common_test_utils/type_prop.hpp" #include "exceptions.hpp" #include "gtest/gtest.h" -#include "ngraph/file_util.hpp" -#include "ngraph/ngraph.hpp" #include "onnx_import/onnx.hpp" +#include "onnx_utils.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +using namespace ov; +using namespace ov::frontend::onnx::tests; -using namespace ngraph; - -TEST(onnx_importer, exception_throws_ngraph_error) { - EXPECT_THROW(onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/depth_to_space_bad_blocksize.onnx")), - ngraph_error); +TEST(onnx_importer, exception_throws_Exception) { + EXPECT_THROW(convert_model("depth_to_space_bad_blocksize.onnx"), Exception); } -TEST(onnx_importer, exception_msg_ngraph_error) { +TEST(onnx_importer, exception_msg_Exception) { try { - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/depth_to_space_bad_blocksize.onnx")); + convert_model("depth_to_space_bad_blocksize.onnx"); // Should have thrown, so fail if it didn't FAIL() << "ONNX Importer did not detected incorrect model!"; - } catch (const ngraph_error& e) { + } catch (const Exception& e) { EXPECT_HAS_SUBSTRING(e.what(), std::string("must be a multiple of divisor")); } catch (...) { FAIL() << "The ONNX model importer failed for unexpected reason"; @@ -39,12 +32,10 @@ TEST(onnx_importer, exception_msg_ngraph_error) { TEST(onnx_importer, exception_msg_onnx_node_validation_failure) { try { - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/instance_norm_bad_scale_type.onnx")); + convert_model("instance_norm_bad_scale_type.onnx"); // Should have thrown, so fail if it didn't FAIL() << "ONNX Importer did not detected incorrect model!"; - } catch (const ::ngraph::onnx_import::error::OnnxNodeValidationFailure& e) { + } catch (const ::ov::frontend::onnx_error::OnnxNodeValidationFailure& e) { EXPECT_HAS_SUBSTRING(e.what(), std::string("While validating ONNX node '>; using Outputs = std::vector>; OPENVINO_TEST(${BACKEND_NAME}, onnx_prior_box) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/prior_box.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("prior_box.onnx"); + auto test_case = ov::test::TestCase(model, s_device); std::vector A(3 * 2 * 2); std::vector B(3 * 6 * 6); std::vector output = { @@ -73,11 +67,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_prior_box) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_priorbox_clustered) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/priorbox_clustered.onnx")); + auto model = convert_model("priorbox_clustered.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); std::vector A{15.0f}; std::vector B{10.0f}; std::vector output = { @@ -91,12 +83,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_priorbox_clustered) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_priorbox_clustered_most_attrs_default) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/priorbox_clustered_most_attrs_default.onnx")); + auto model = convert_model("priorbox_clustered_most_attrs_default.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); std::vector A(1 * 1 * 2 * 1); std::iota(std::begin(A), std::end(A), 0.0f); std::vector B(1 * 1 * 3 * 3); @@ -125,12 +114,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_priorbox_clustered_most_attrs_default) { OPENVINO_TEST(${BACKEND_NAME}, onnx_priorbox_clustered_first_input_bad_shape) { try { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/priorbox_clustered_first_input_bad_shape.onnx")); + auto model = convert_model("priorbox_clustered_first_input_bad_shape.onnx"); FAIL() << "Expected exception was not thrown"; - } catch (const ngraph::ngraph_error& e) { + } catch (const ov::Exception& e) { EXPECT_HAS_SUBSTRING(e.what(), std::string("Only 4D inputs are supported. First input rank: 5 (should be 4)")); } catch (...) { FAIL() << "Expected OnnxNodeValidationFailure exception was not thrown"; @@ -139,12 +125,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_priorbox_clustered_first_input_bad_shape) { OPENVINO_TEST(${BACKEND_NAME}, onnx_priorbox_clustered_second_input_bad_shape) { try { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/priorbox_clustered_second_input_bad_shape.onnx")); + auto model = convert_model("priorbox_clustered_second_input_bad_shape.onnx"); FAIL() << "Expected exception was not thrown"; - } catch (const ngraph::ngraph_error& e) { + } catch (const ov::Exception& e) { EXPECT_HAS_SUBSTRING(e.what(), std::string("Only 4D inputs are supported. Second input rank: 5 (should be 4)")); } catch (...) { FAIL() << "Expected OnnxNodeValidationFailure exception was not thrown"; @@ -152,9 +135,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_priorbox_clustered_second_input_bad_shape) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_detection_output) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/detection_output.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("detection_output.onnx"); + auto test_case = ov::test::TestCase(model, s_device); auto gen_vector = [](size_t size, float min, float max) -> std::vector { float step = (max - min) / size; @@ -184,9 +166,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_detection_output) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_group_norm) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/group_norm.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("group_norm.onnx"); + auto test_case = ov::test::TestCase(model, s_device); Shape shape{2, 8, 2, 2}; const auto size = shape_size(shape); std::vector data(size); @@ -208,11 +189,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_group_norm) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_group_norm_squeeze_bias_and_scale) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/group_norm_4D_bias_and_scale.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("group_norm_4D_bias_and_scale.onnx"); + auto test_case = ov::test::TestCase(model, s_device); Shape shape{2, 8, 2, 2}; const auto size = shape_size(shape); std::vector data(size); @@ -234,9 +212,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_group_norm_squeeze_bias_and_scale) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_group_norm_5d) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/group_norm_5d.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("group_norm_5d.onnx"); + auto test_case = ov::test::TestCase(model, s_device); Shape shape{2, 8, 1, 2, 1}; const auto size = shape_size(shape); std::vector data(size); @@ -255,9 +232,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_group_norm_5d) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_normalize) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/normalize.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("normalize.onnx"); + auto test_case = ov::test::TestCase(model, s_device); std::vector data(12); std::iota(data.begin(), data.end(), 1.f); std::vector output = { @@ -280,11 +256,10 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_normalize) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_swish_with_beta) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/swish_with_beta.onnx")); + auto model = convert_model("swish_with_beta.onnx"); const Shape expected_output_shape{3}; - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); std::vector input_data{-0.5f, 0, 0.5f}; test_case.add_input(input_data); test_case.add_expected_output(expected_output_shape, {-0.2036667f, 0.0f, 0.2963333f}); @@ -293,12 +268,10 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_swish_with_beta) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_swish_without_beta) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/swish_without_beta.onnx")); + auto model = convert_model("swish_without_beta.onnx"); const Shape expected_output_shape{3}; - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); std::vector input_data{-0.5f, 0, 0.5f}; test_case.add_input(input_data); test_case.add_expected_output(expected_output_shape, {-0.18877034f, 0.0f, 0.31122968f}); @@ -307,12 +280,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_swish_without_beta) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_detection_output) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/org.openvinotoolkit/experimental_detectron/detection_output.onnx")); + auto model = convert_model("org.openvinotoolkit/experimental_detectron/detection_output.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // rois test_case.add_input({1.0f, 1.0f, 10.0f, 10.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 4.0f, 1.0f, 8.0f, 5.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, @@ -367,13 +337,10 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_detection_outpu } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_detection_output_most_attrs_default) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/org.openvinotoolkit/experimental_detectron/" - "detection_output_most_attrs_default.onnx")); + auto model = convert_model("org.openvinotoolkit/experimental_detectron/" + "detection_output_most_attrs_default.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // rois test_case.add_input({1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, @@ -410,13 +377,10 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_detection_outpu } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_generate_proposals_single_image) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/org.openvinotoolkit/experimental_detectron/" - "generate_proposals_single_image.onnx")); + auto model = convert_model("org.openvinotoolkit/experimental_detectron/" + "generate_proposals_single_image.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // im_info test_case.add_input({1.0f, 1.0f, 1.0f}); // anchors @@ -460,12 +424,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_generate_propos } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_group_norm) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/org.openvinotoolkit/experimental_detectron/group_norm.onnx")); + auto model = convert_model("org.openvinotoolkit/experimental_detectron/group_norm.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); Shape shape{2, 8, 2, 2}; const auto size = shape_size(shape); std::vector data(size); @@ -487,12 +448,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_group_norm) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_prior_grid_generator) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/org.openvinotoolkit/experimental_detectron/prior_grid_generator.onnx")); + auto model = convert_model("org.openvinotoolkit/experimental_detectron/prior_grid_generator.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); std::vector priors(shape_size(Shape{3, 4})); std::iota(priors.begin(), priors.end(), 0.f); @@ -514,12 +472,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_prior_grid_gene } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_roi_feature_extractor) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/org.openvinotoolkit/experimental_detectron/roi_feature_extractor.onnx")); + auto model = convert_model("org.openvinotoolkit/experimental_detectron/roi_feature_extractor.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); std::vector rois(shape_size(Shape{2, 4})); std::iota(rois.begin(), rois.end(), 0.f); @@ -573,12 +528,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_roi_feature_ext } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_topk_rios) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/org.openvinotoolkit/experimental_detectron/topk_rios.onnx")); + auto model = convert_model("org.openvinotoolkit/experimental_detectron/topk_rios.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input({1.0f, 1.0f, 3.0f, 4.0f, 2.0f, 1.0f, 5.0f, 7.0f}); test_case.add_input({0.5f, 0.3f}); @@ -588,12 +540,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_experimental_detectron_topk_rios) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_deformable_conv_2d) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/org.openvinotoolkit/deformable_conv_2d.onnx")); + auto model = convert_model("org.openvinotoolkit/deformable_conv_2d.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // data test_case.add_input( @@ -621,12 +570,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_deformable_conv_2d) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_generate_proposals) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/org.openvinotoolkit/generate_proposals.onnx")); + auto model = convert_model("org.openvinotoolkit/generate_proposals.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // scores test_case.add_input( @@ -674,12 +620,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_generate_proposals) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_generate_proposals_batch) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/org.openvinotoolkit/generate_proposals_batch2.onnx")); + auto model = convert_model("org.openvinotoolkit/generate_proposals_batch2.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // scores test_case.add_input(Shape{2, 3, 2, 3}, {5, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 7, 1, 1, 1, 1, diff --git a/src/frontends/onnx/tests/onnx_import_org_pytorch.in.cpp b/src/frontends/onnx/tests/onnx_import_org_pytorch.in.cpp index da55566c38bf8e..0e055717a5cdeb 100644 --- a/src/frontends/onnx/tests/onnx_import_org_pytorch.in.cpp +++ b/src/frontends/onnx/tests/onnx_import_org_pytorch.in.cpp @@ -14,27 +14,22 @@ // clang-format on #include "common_test_utils/file_utils.hpp" -#include "default_opset.hpp" #include "common_test_utils/test_case.hpp" -#include "onnx_import/onnx.hpp" #include "common_test_utils/test_control.hpp" -#include "ngraph/file_util.hpp" +#include "default_opset.hpp" +#include "onnx_import/onnx.hpp" #include "onnx_utils.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START - -using namespace ngraph; +using namespace ov; +using namespace ov::frontend::onnx::tests; -static std::string s_manifest = ngraph::file_util::path_join(ov::test::utils::getExecutableDirectory(), "${MANIFEST}"); +static std::string s_manifest = onnx_backend_manifest("${MANIFEST}"); static std::string s_device = backend_name_to_device("${BACKEND_NAME}"); OPENVINO_TEST(${BACKEND_NAME}, onnx_model_adaptive_avg_pooling2d_nchw) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/org.pytorch/adaptive_avg_pooling2d_nchw.onnx")); + const auto model = convert_model("org.pytorch/adaptive_avg_pooling2d_nchw.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input({0.9945f, 0.3466f, 0.2894f, @@ -56,12 +51,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_adaptive_avg_pooling2d_nchw) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_adaptive_avg_pooling2d_chw) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/org.pytorch/adaptive_avg_pooling2d_chw.onnx")); + const auto model = convert_model("org.pytorch/adaptive_avg_pooling2d_chw.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input({12.0f, -1.0f, -56.0f, 20.0f, 1.0f, -8.0f, 7.0f, 9.0f}); test_case.add_expected_output(Shape{1, 2, 2}, {5.5f, -18.0f, -3.5f, 8.0f});