From 0972de4da81f2d35459f54e7ce170c677dec5f1d Mon Sep 17 00:00:00 2001 From: Georgy Krivoruchko Date: Sun, 17 Dec 2023 23:31:32 -0800 Subject: [PATCH] [ONNX] Refactoring tests on API 2.0 (#21712) * Moved test in onnx_import_com_microsoft to new API * Updated onnx_import_constant_folding.in.cpp to new API * Tests in onnx_import_controlflow.in.cpp moved to new API * Tests in onnx_import_convpool.in.cpp moved to new API * Test in onnx_import_deprecated.in.cpp moved to API 2.0 --- .../tests/onnx_import_com_microsoft.in.cpp | 218 ++++-------- .../tests/onnx_import_const_folding.in.cpp | 42 +-- .../onnx/tests/onnx_import_controlflow.in.cpp | 313 ++++++------------ .../onnx/tests/onnx_import_convpool.in.cpp | 147 +++----- .../onnx/tests/onnx_import_deprecated.in.cpp | 24 +- 5 files changed, 243 insertions(+), 501 deletions(-) diff --git a/src/frontends/onnx/tests/onnx_import_com_microsoft.in.cpp b/src/frontends/onnx/tests/onnx_import_com_microsoft.in.cpp index cace755ed4ab20..b45bcd342bb519 100644 --- a/src/frontends/onnx/tests/onnx_import_com_microsoft.in.cpp +++ b/src/frontends/onnx/tests/onnx_import_com_microsoft.in.cpp @@ -14,26 +14,22 @@ // clang-format on #include "common_test_utils/file_utils.hpp" -#include "default_opset.hpp" #include "common_test_utils/test_case.hpp" +#include "common_test_utils/test_control.hpp" +#include "default_opset.hpp" #include "onnx_import/onnx.hpp" #include "onnx_utils.hpp" -#include "ngraph/file_util.hpp" -#include "common_test_utils/test_control.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_bias_gelu) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/bias_gelu.onnx")); + const auto model = convert_model("com.microsoft/bias_gelu.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input({0.5488135f, 0.71518934f, 0.60276335f, @@ -59,10 +55,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_bias_gelu) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_skip_layer_normalization_with_gamma_beta_bias) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/skip_layer_normalization_with_gamma_beta_bias.onnx")); + const auto model = convert_model("com.microsoft/skip_layer_normalization_with_gamma_beta_bias.onnx"); std::vector input = { 0.54881352f, 0.71518934f, 0.60276335f, 0.54488319f, 0.42365479f, 0.64589411f, 0.43758720f, 0.89177299f, @@ -79,7 +72,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_skip_layer_normalization_with_gamma_be 0.04256713f, -0.71902490f, 0.23107991f, 0.17300847f, -0.04390603f, -0.31109563f, 0.51021838f, -0.66914201f, -0.20009395f, -0.43313017f, 0.67281967f, -0.01712347f, 0.09767530f, -0.43024653f, -0.01836969f, -0.29238200f, }; - 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_input(skip); test_case.add_expected_output(expected); @@ -87,10 +80,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_skip_layer_normalization_with_gamma_be } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_skip_layer_normalization_with_gamma_beta) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/skip_layer_normalization_with_gamma_beta.onnx")); + const auto model = convert_model("com.microsoft/skip_layer_normalization_with_gamma_beta.onnx"); std::vector input = { 0.54881352f, 0.71518934f, 0.60276335f, 0.54488319f, 0.42365479f, 0.64589411f, 0.43758720f, 0.89177299f, @@ -107,7 +97,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_skip_layer_normalization_with_gamma_be 0.07773457f, -0.51403606f, -0.13661698f, 0.11262375f, -0.05096011f, -0.10416907f, 0.10070466f, -0.50876135f, -0.22290939f, -0.27663514f, 0.55416691f, -0.08064821f, 0.04857478f, -0.25121087f, -0.15912610f, -0.26637587f, }; - 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_input(skip); test_case.add_expected_output(expected); @@ -115,10 +105,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_skip_layer_normalization_with_gamma_be } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_skip_layer_normalization_with_gamma) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/skip_layer_normalization_with_gamma.onnx")); + const auto model = convert_model("com.microsoft/skip_layer_normalization_with_gamma.onnx"); std::vector input = { 0.54881352f, 0.71518934f, 0.60276335f, 0.54488319f, 0.42365479f, 0.64589411f, 0.43758720f, 0.89177299f, @@ -135,7 +122,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_skip_layer_normalization_with_gamma) { 0.14773457f, -0.11403608f, -0.35661697f, 0.11262375f, 0.01903989f, 0.29583094f, -0.11929534f, -0.50876135f, -0.15290938f, 0.12336487f, 0.33416691f, -0.08064821f, 0.11857478f, 0.14878914f, -0.37912610f, -0.26637587f, }; - 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_input(skip); test_case.add_expected_output(expected); @@ -143,10 +130,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_skip_layer_normalization_with_gamma) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_skip_layer_normalization_dynamic_shapes) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/skip_layer_normalization_dynamic_shapes.onnx")); + const auto model = convert_model("com.microsoft/skip_layer_normalization_dynamic_shapes.onnx"); std::vector input = { 0.54881352f, 0.71518934f, 0.60276335f, 0.54488319f, 0.42365479f, 0.64589411f, 0.43758720f, 0.89177299f, @@ -182,7 +166,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_skip_layer_normalization_dynamic_shape 0.64228040f, 0.21059875f, 1.05966032f, -0.14278713f, 1.46366918f, 0.21215858f, -0.31640187f, -0.22832340f, }; - 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, 4}, input); test_case.add_input(Shape{3, 2, 4}, skip); test_case.add_input(Shape{4}, gamma); @@ -193,10 +177,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_skip_layer_normalization_dynamic_shape } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_embed_layer_normalization) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/embed_layer_normalization.onnx")); + const auto model = convert_model("com.microsoft/embed_layer_normalization.onnx"); std::vector input_ids = { 8, 1, 5, 9, 8, 9, 4, 3, 0, 3, 5, 0, 2, 3, 8, 1, 3, 3, 3, 7, 0, 1, 9, 9, @@ -219,17 +200,14 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_embed_layer_normalization) { -0.03054028f, -0.03603891f, -0.08479506f, -0.00034568f, 0.03713699f, 0.00163411f, -0.01738501f, -0.18267182f, }; - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(input_ids); test_case.add_expected_output(expected_output); test_case.run_with_tolerance_as_fp(1e-7f); } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_embed_layer_normalization_with_segment_embedding) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/embed_layer_normalization_with_segment_embedding.onnx")); + const auto model = convert_model("com.microsoft/embed_layer_normalization_with_segment_embedding.onnx"); std::vector input_ids = { 8, 1, 5, 9, 8, 9, 4, 3, 0, 3, 5, 0, 2, 3, 8, 1, 3, 3, 3, 7, 0, 1, 9, 9, @@ -261,7 +239,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_embed_layer_normalization_with_segment 0, }; - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(input_ids); test_case.add_input(segment_ids); test_case.add_expected_output(expected_output); @@ -270,10 +248,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_embed_layer_normalization_with_segment } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_embed_layer_normalization_with_segment_embedding_and_mask) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/embed_layer_normalization_with_segment_embedding_and_mask.onnx")); + const auto model = convert_model("com.microsoft/embed_layer_normalization_with_segment_embedding_and_mask.onnx"); std::vector input_ids = { 8, 1, 5, 9, 8, 9, 4, 3, 0, 3, 5, 0, 2, 3, 8, 1, 3, 3, 3, 7, 0, 1, 9, 9, @@ -307,7 +282,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_embed_layer_normalization_with_segment 4, }; - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(input_ids); test_case.add_input(segment_ids); test_case.add_input(mask); @@ -317,10 +292,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_embed_layer_normalization_with_segment } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_embed_layer_normalization_dynamic_shapes) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/embed_layer_normalization_dynamic_shapes.onnx")); + const auto model = convert_model("com.microsoft/embed_layer_normalization_dynamic_shapes.onnx"); std::vector input_ids = { 8, 1, 5, 9, 8, 9, 4, 3, 0, 3, 5, 0, 2, 3, 8, 1, 3, 3, 3, 7, 0, 1, 9, 9, @@ -401,7 +373,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_embed_layer_normalization_dynamic_shap 5, }; - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{3, 8}, input_ids); test_case.add_input(Shape{3, 8}, segment_ids); test_case.add_input(Shape{10, 5}, word_embeddings); @@ -416,10 +388,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_embed_layer_normalization_dynamic_shap } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_embed_layer_normalization_diff_seq_len_pos_embed_len) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/embed_layer_normalization_dynamic_shapes.onnx")); + const auto model = convert_model("com.microsoft/embed_layer_normalization_dynamic_shapes.onnx"); std::vector input_ids = { 8, 1, 5, 9, 8, 9, 4, 3, 0, 3, 5, 0, 2, 3, 8, 1, 3, 3, 3, 7, 0, 1, 9, 9, @@ -501,7 +470,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_embed_layer_normalization_diff_seq_len 5, }; - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{3, 8}, input_ids); test_case.add_input(Shape{3, 8}, segment_ids); test_case.add_input(Shape{10, 5}, word_embeddings); @@ -516,10 +485,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_embed_layer_normalization_diff_seq_len } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_embed_layer_normalization_with_position_ids) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/embed_layer_normalization_dynamic_shapes_with_position_ids.onnx")); + const auto model = convert_model("com.microsoft/embed_layer_normalization_dynamic_shapes_with_position_ids.onnx"); std::vector input_ids = { 8, 1, 5, 9, 8, 9, 4, 3, 0, 3, 5, 0, 2, 3, 8, 1, 3, 3, 3, 7, 0, 1, 9, 9, @@ -604,7 +570,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_embed_layer_normalization_with_positio 5, }; - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{3, 8}, input_ids); test_case.add_input(Shape{3, 8}, segment_ids); test_case.add_input(Shape{10, 5}, word_embeddings); @@ -620,10 +586,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_embed_layer_normalization_with_positio } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/attention.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/attention.onnx"); + auto test_case = ov::test::TestCase(model, s_device); std::vector input = { 0.91475844f, 0.91523546f, 0.82536930f, 0.37491974f, 0.22384071f, 0.05941105f, 0.01902100f, 0.70131350f, @@ -643,11 +607,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_qkv_hidden_sizes) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/attention_qkv_hidden_sizes.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/attention_qkv_hidden_sizes.onnx"); + auto test_case = ov::test::TestCase(model, s_device); std::vector input = { 0.56477863f, 0.60309958f, 0.35158035f, 0.03123519f, 0.81918180f, 0.76905495f, 0.47219241f, 0.72016627f, @@ -671,11 +632,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_qkv_hidden_sizes) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_unidirectional) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/attention_unidirectional.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/attention_unidirectional.onnx"); + auto test_case = ov::test::TestCase(model, s_device); std::vector input = { 0.89578921f, 0.42421508f, 0.35630688f, 0.77461642f, 0.65753633f, 0.09723099f, 0.62597734f, 0.72117692f, @@ -706,11 +664,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_unidirectional) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_mask_index_1f) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/attention_mask_index_1.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/attention_mask_index_1.onnx"); + auto test_case = ov::test::TestCase(model, s_device); std::vector input = { 0.02841483f, 0.47845092f, 0.14633700f, 0.54597300f, 0.40160629f, 0.55281311f, 0.14931096f, 0.64483738f, @@ -746,11 +701,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_mask_index_1f) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_mask_index_2) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/attention_mask_index_2.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/attention_mask_index_2.onnx"); + auto test_case = ov::test::TestCase(model, s_device); std::vector input = { 0.75259578f, 0.81492645f, 0.46713001f, 0.29483622f, 0.06768602f, 0.95105755f, 0.32065326f, 0.52417183f, @@ -788,11 +740,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_mask_index_2) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_mask_index_3) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/attention_mask_index_3.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/attention_mask_index_3.onnx"); + auto test_case = ov::test::TestCase(model, s_device); std::vector input = { 0.33093750f, 0.39181390f, 0.14586255f, 0.39709702f, 0.98086524f, 0.03891133f, 0.72234219f, 0.21966648f, @@ -834,11 +783,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_mask_index_3) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_mask_index_4) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/attention_mask_index_4.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/attention_mask_index_4.onnx"); + auto test_case = ov::test::TestCase(model, s_device); std::vector input = { 0.23565151f, 0.58627969f, 0.75137484f, 0.68586946f, 0.62750375f, 0.13284931f, 0.13347220f, 0.36357051f, @@ -873,11 +819,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_mask_index_4) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_past) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/attention_past.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/attention_past.onnx"); + auto test_case = ov::test::TestCase(model, s_device); std::vector input = { 0.82966000f, 0.77751911f, 0.08977074f, 0.06076468f, 0.40659550f, 0.19995944f, 0.55544919f, 0.83971608f, @@ -952,11 +895,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_past) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_extra_add) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/attention_extra_add.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/attention_extra_add.onnx"); + auto test_case = ov::test::TestCase(model, s_device); std::vector input = { 0.14930259f, 0.11199699f, 0.81292826f, 0.08368169f, 0.05704883f, 0.41276145f, 0.38760167f, 0.00146112f, @@ -1009,11 +949,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_extra_add) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_dynamic_shapes) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/attention_dynamic_shapes.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/attention_dynamic_shapes.onnx"); + auto test_case = ov::test::TestCase(model, s_device); std::vector input = { 0.42226878f, 0.50984067f, 0.80440795f, 0.68040705f, 0.93614250f, 0.45104721f, 0.71767306f, 0.48596525f, @@ -1111,10 +1048,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_dynamic_shapes) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_fusedgemm_abc) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/fusedgemm.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/fusedgemm.onnx"); + auto test_case = ov::test::TestCase(model, s_device); std::vector inputA = { 0.760289272f, @@ -1182,11 +1117,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_fusedgemm_abc) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_fused_conv_hard_sigmoid) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/fused_conv_hard_sigmoid.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/fused_conv_hard_sigmoid.onnx"); + auto test_case = ov::test::TestCase(model, s_device); const std::vector X{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; const std::vector W{0.125f, 0.125f, 0.125f, 0.125f, -0.125f, -0.125f, -0.125f, -0.125f}; @@ -1199,11 +1131,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_fused_conv_hard_sigmoid) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_fused_conv_relu) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/fused_conv_relu.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/fused_conv_relu.onnx"); + auto test_case = ov::test::TestCase(model, s_device); const std::vector X{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; const std::vector W{1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f}; @@ -1216,11 +1145,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_fused_conv_relu) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_fused_conv_tanh) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/fused_conv_tanh.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/fused_conv_tanh.onnx"); + auto test_case = ov::test::TestCase(model, s_device); const std::vector X{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; const std::vector W{1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -2.0f, -1.0f, -2.0f}; @@ -1233,11 +1159,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_fused_conv_tanh) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_fused_conv_sigmoid) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/fused_conv_sigmoid.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/fused_conv_sigmoid.onnx"); + auto test_case = ov::test::TestCase(model, s_device); const std::vector X{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; const std::vector W{1.0f, 1.0f, 5.0f, 1.0f, -1.0f, -2.0f, -5.0f, -2.0f}; @@ -1250,11 +1173,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_fused_conv_sigmoid) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_fused_conv_clip) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/fused_conv_clip.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/fused_conv_clip.onnx"); + auto test_case = ov::test::TestCase(model, s_device); const std::vector X{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; const std::vector W{1.0f, 1.0f, 5.0f, 1.0f, -1.0f, -2.0f, -5.0f, -2.0f}; @@ -1267,11 +1187,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_fused_conv_clip) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_fused_conv_leaky_relu) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/fused_conv_leaky_relu.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/fused_conv_leaky_relu.onnx"); + auto test_case = ov::test::TestCase(model, s_device); const std::vector X{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; const std::vector W{1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f}; @@ -1284,11 +1201,8 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_fused_conv_leaky_relu) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_fused_conv_relu_z_input) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/fused_conv_relu_z_input.onnx")); - auto test_case = ov::test::TestCase(function, s_device); + const auto model = convert_model("com.microsoft/fused_conv_relu_z_input.onnx"); + auto test_case = ov::test::TestCase(model, s_device); const std::vector X{1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}; const std::vector W{1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f, -1.0f}; @@ -1305,11 +1219,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_fused_conv_relu_z_input) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_trilu_lower) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/com.microsoft/trilu_lower.onnx")); + const auto model = convert_model("com.microsoft/trilu_lower.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // clang-format off test_case.add_input(Shape{4, 5}, std::vector{ 1, 2, 3, 4, 5, diff --git a/src/frontends/onnx/tests/onnx_import_const_folding.in.cpp b/src/frontends/onnx/tests/onnx_import_const_folding.in.cpp index a9a3afa5d6c816..24e5c45271e6d6 100644 --- a/src/frontends/onnx/tests/onnx_import_const_folding.in.cpp +++ b/src/frontends/onnx/tests/onnx_import_const_folding.in.cpp @@ -8,33 +8,28 @@ #include "common_test_utils/file_utils.hpp" #include "common_test_utils/test_control.hpp" #include "common_test_utils/type_prop.hpp" -#include "default_opset.hpp" #include "gtest/gtest.h" -#include "ngraph/file_util.hpp" -#include "ngraph/op/util/op_types.hpp" -#include "ngraph/pass/constant_folding.hpp" -#include "ngraph/pass/manager.hpp" -#include "onnx_import/onnx.hpp" +#include "onnx_utils.hpp" +#include "openvino/pass/constant_folding.hpp" +#include "openvino/pass/manager.hpp" -OPENVINO_SUPPRESS_DEPRECATED_START +using namespace ov; +using namespace ov::frontend::onnx::tests; -using namespace ngraph; -using namespace ngraph::onnx_import; - -static std::string s_manifest = ngraph::file_util::path_join(ov::test::utils::getExecutableDirectory(), "${MANIFEST}"); +static std::string s_manifest = onnx_backend_manifest("${MANIFEST}"); namespace { template void test_constant_folding(std::shared_ptr ng_function, const std::vector expected_output, const PartialShape expected_shape = PartialShape::dynamic()) { - ngraph::pass::Manager pass_manager; + pass::Manager pass_manager; pass_manager.register_pass(); pass_manager.run_passes(ng_function); for (auto ng_node : ng_function->get_ordered_ops()) { - if (op::is_constant(ng_node)) { - const auto folded_node = ov::as_type_ptr(ng_node); + if (ov::is_type(ng_node)) { + const auto folded_node = ov::as_type_ptr(ng_node); const auto output_values = folded_node->cast_vector(); EXPECT_TRUE(ov::test::utils::all_close(expected_output, output_values)); @@ -52,37 +47,31 @@ void test_constant_folding(std::shared_ptr ng_function, } // namespace OPENVINO_TEST(${BACKEND_NAME}, onnx_const_folding_model_scatter_elements) { - const auto fn = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/scatter_elements_opset11.onnx")); + const auto fn = convert_model("scatter_elements_opset11.onnx"); test_constant_folding(fn, {1.0f, 1.1f, 3.0f, 2.1f, 5.0f}, Shape{1, 5}); } OPENVINO_TEST(${BACKEND_NAME}, onnx_const_folding_model_non_zero_scalar) { - const auto fn = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/non_zero_scalar.onnx")); + const auto fn = convert_model("non_zero_scalar.onnx"); test_constant_folding(fn, {0}, Shape{1, 1}); } OPENVINO_TEST(${BACKEND_NAME}, onnx_const_folding_model_non_zero_1d) { - const auto fn = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/non_zero_1d.onnx")); + const auto fn = convert_model("non_zero_1d.onnx"); test_constant_folding(fn, {1, 2, 4}, Shape{1, 3}); } OPENVINO_TEST(${BACKEND_NAME}, onnx_const_folding_model_non_zero_1d_float) { - const auto fn = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/non_zero_1d_float.onnx")); + const auto fn = convert_model("non_zero_1d_float.onnx"); test_constant_folding(fn, {0, 1, 3, 4, 5, 6, 7, 8, 9}); } OPENVINO_TEST(${BACKEND_NAME}, onnx_const_folding_model_non_zero_3d) { - const auto fn = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/non_zero_3d.onnx")); + const auto fn = convert_model("non_zero_3d.onnx"); // Vertical slices are 3D indices of non-zero elements in the input tensor // {0, 0, 0, 1, 1, 2, 2} @@ -92,8 +81,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_const_folding_model_non_zero_3d) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_const_folding_model_non_zero_2d_bool) { - const auto fn = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/non_zero_2d_bool.onnx")); + const auto fn = convert_model("non_zero_2d_bool.onnx"); test_constant_folding(fn, {0, 1, 1, 0}); } diff --git a/src/frontends/onnx/tests/onnx_import_controlflow.in.cpp b/src/frontends/onnx/tests/onnx_import_controlflow.in.cpp index f6a10af3d5af77..165cf755e85782 100644 --- a/src/frontends/onnx/tests/onnx_import_controlflow.in.cpp +++ b/src/frontends/onnx/tests/onnx_import_controlflow.in.cpp @@ -9,18 +9,14 @@ #include "common_test_utils/type_prop.hpp" #include "default_opset.hpp" #include "gtest/gtest.h" -#include "ngraph/file_util.hpp" -#include "ngraph/type.hpp" -#include "ngraph/type/element_type.hpp" -#include "onnx_import/onnx.hpp" #include "onnx_utils.hpp" +#include "openvino/op/loop.hpp" +#include "openvino/op/multiply.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}"); // ~~~~~~~~TERMINATION CONDITION/TRIP COUNT COMBINATIONS TESTS:~~~~~~~~ @@ -31,27 +27,25 @@ static std::string s_device = backend_name_to_device("${BACKEND_NAME}"); // cond = ...; // ignored // } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_add) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_add.onnx")); + const auto model = convert_model("controlflow/loop_2d_add.onnx"); // Shape inference tests - const auto& parameters = function->get_parameters(); + const auto& parameters = model->get_parameters(); EXPECT_EQ(parameters.size(), 1); - EXPECT_EQ(parameters.at(0)->get_element_type(), ngraph::element::f32); + EXPECT_EQ(parameters.at(0)->get_element_type(), element::f32); EXPECT_TRUE(parameters.at(0)->get_partial_shape().is_static()); EXPECT_EQ(parameters.at(0)->get_partial_shape().to_shape(), (Shape{1, 2})); - const auto& results = function->get_results(); + const auto& results = model->get_results(); EXPECT_EQ(results.size(), 2); - EXPECT_EQ(function->get_output_element_type(0), ngraph::element::f32); - EXPECT_TRUE(function->get_output_partial_shape(0).is_static()); - EXPECT_EQ(function->get_output_shape(0), (Shape{1, 2})); - EXPECT_EQ(function->get_output_element_type(1), ngraph::element::f32); - EXPECT_TRUE(function->get_output_partial_shape(1).is_static()); - EXPECT_EQ(function->get_output_shape(1), (Shape{3, 1, 2})); - - auto test_case = ov::test::TestCase(function, s_device); + EXPECT_EQ(model->get_output_element_type(0), element::f32); + EXPECT_TRUE(model->get_output_partial_shape(0).is_static()); + EXPECT_EQ(model->get_output_shape(0), (Shape{1, 2})); + EXPECT_EQ(model->get_output_element_type(1), element::f32); + EXPECT_TRUE(model->get_output_partial_shape(1).is_static()); + EXPECT_EQ(model->get_output_shape(1), (Shape{3, 1, 2})); + + auto test_case = ov::test::TestCase(model, s_device); // a_init test_case.add_input({0.f, 0.f}); @@ -66,12 +60,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_add) { // cond = ...; // } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_no_identity_termination_cond) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_add_no_identity_termination_cond.onnx")); + const auto model = convert_model("controlflow/loop_2d_add_no_identity_termination_cond.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // termination condition test_case.add_input({true}); // a_init @@ -83,12 +74,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_no_identity_termination_ } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_trip_count_max_int) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_add_trip_count_max_int.onnx")); + const auto model = convert_model("controlflow/loop_2d_add_trip_count_max_int.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // termination condition test_case.add_input({true}); // a_init @@ -100,12 +88,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_trip_count_max_int) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_no_identity_termination_cond_static_shapes) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_add_no_identity_termination_cond_static_shapes.onnx")); + const auto model = convert_model("controlflow/loop_2d_add_no_identity_termination_cond_static_shapes.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // termination condition test_case.add_input({true}); // a_init @@ -118,12 +103,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_no_identity_termination_ // cond = false // input ("", cond) // Note this is analogous to a while loop OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_no_identity_termination_cond_false) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_add_no_identity_termination_cond_false.onnx")); + const auto model = convert_model("controlflow/loop_2d_add_no_identity_termination_cond_false.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // a_init test_case.add_input({3.f, 4.f}); @@ -138,12 +120,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_no_identity_termination_ // cond = ...; // } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_const_no_identity_termination_cond) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_add_const_no_identity_termination_cond.onnx")); + const auto model = convert_model("controlflow/loop_2d_add_const_no_identity_termination_cond.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // a_init test_case.add_input({0.f, 0.f}); @@ -153,12 +132,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_const_no_identity_termin } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_const_no_identity_termination_cond_static_shapes) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_add_const_no_identity_termination_cond_static_shapes.onnx")); + const auto model = convert_model("controlflow/loop_2d_add_const_no_identity_termination_cond_static_shapes.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // a_init test_case.add_input({0.f, 0.f}); @@ -173,12 +149,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_const_no_identity_termin // cond = ...; // } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_both_cond_and_trip_count_as_inputs) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_add_cond_and_trip_count_as_inputs.onnx")); + const auto model = convert_model("controlflow/loop_2d_add_cond_and_trip_count_as_inputs.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // trip count test_case.add_input({10}); @@ -194,12 +167,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_both_cond_and_trip_count } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_both_cond_and_trip_count_as_inputs_static_shapes) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_add_cond_and_trip_count_as_inputs_static_shapes.onnx")); + const auto model = convert_model("controlflow/loop_2d_add_cond_and_trip_count_as_inputs_static_shapes.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // trip count test_case.add_input({10}); @@ -216,12 +186,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_both_cond_and_trip_count // ~~~~~~~~SCOPES VISIBILITY TESTS:~~~~~~~~ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_add_initializer_from_parent_scope) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_add_initializer_from_parent_scope.onnx")); + const auto model = convert_model("controlflow/loop_2d_add_initializer_from_parent_scope.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // a_init test_case.add_input({0.f, 0.f}); @@ -232,12 +199,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_add_initializer_from_parent } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_add_node_from_parent_scope) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_add_node_from_parent_scope.onnx")); + const auto model = convert_model("controlflow/loop_2d_add_node_from_parent_scope.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // a_init test_case.add_input({0.f, 0.f}); @@ -247,12 +211,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_add_node_from_parent_scope) } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_add_node_from_parent_scope_used_in_parent_and_in_body) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_add_node_from_parent_scope_used_in_parent_and_in_body.onnx")); + const auto model = convert_model("controlflow/loop_add_node_from_parent_scope_used_in_parent_and_in_body.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // a_init test_case.add_input({0.f, 0.f}); // parent_input @@ -266,12 +227,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_add_node_from_parent_scope_ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_add_value_access_to_body_scope_exception) { try { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_add_incorrect_access_body_scope.onnx")); + const auto model = convert_model("controlflow/loop_2d_add_incorrect_access_body_scope.onnx"); FAIL() << "Incorrect access to body scope not detected"; - } catch (const ngraph_error& e) { + } catch (const ov::Exception& e) { // patent graph should have no access to subgraph (body Loop) scope EXPECT_HAS_SUBSTRING(e.what(), std::string("from_body_scope node not found in graph cache")); } catch (...) { @@ -280,12 +238,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_add_value_access_to_body_sc } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_add_value_the_same_node_from_parent_and_subgraph) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_add_the_same_name.onnx")); + const auto model = convert_model("controlflow/loop_2d_add_the_same_name.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // a_init test_case.add_input({0.f, 0.f}); @@ -295,12 +250,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_add_value_the_same_node_fro } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_add_input_from_parent_graph) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_add_input_from_parent_graph.onnx")); + const auto model = convert_model("controlflow/loop_2d_add_input_from_parent_graph.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // a_init test_case.add_input({0.f, 0.f}); // b input @@ -312,32 +264,26 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_add_input_from_parent_graph } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_the_proper_opset_in_subgraph) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_mul_opset1.onnx")); + const auto model = convert_model("controlflow/loop_2d_mul_opset1.onnx"); - const auto parent_ops = function->get_ops(); + const auto parent_ops = model->get_ops(); const auto loop_node_it = std::find_if(parent_ops.begin(), parent_ops.end(), [](const std::shared_ptr& op) { return std::string{op->get_type_name()} == "Loop"; }); - const auto body_ops = ngraph::as_type_ptr(*loop_node_it)->get_function()->get_ops(); + const auto body_ops = ov::as_type_ptr(*loop_node_it)->get_function()->get_ops(); const auto body_mul_node_it = std::find_if(body_ops.begin(), body_ops.end(), [](const std::shared_ptr& op) { return std::string{op->get_type_name()} == "Multiply"; }); - const auto body_mul_node = ngraph::as_type_ptr(*body_mul_node_it); + const auto body_mul_node = ov::as_type_ptr(*body_mul_node_it); EXPECT_TRUE(body_mul_node); } // ~~~~~~~~STATIC/DYNAMIC/CONSTANT INPUTS TESTS:~~~~~~~~ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_scalars) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_scalars_add.onnx")); + const auto model = convert_model("controlflow/loop_scalars_add.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // a_init test_case.add_input({0.f}); @@ -347,12 +293,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_scalars) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_add_const_cond) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_add_const_cond.onnx")); + const auto model = convert_model("controlflow/loop_2d_add_const_cond.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // a_init test_case.add_input({0.f, 0.f}); @@ -362,12 +305,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_add_const_cond) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_trip_count_dynamic) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_add_trip_count_dynamic.onnx")); + const auto model = convert_model("controlflow/loop_2d_add_trip_count_dynamic.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // trip count test_case.add_input({3}); // a_init @@ -380,12 +320,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_trip_count_dynamic) { // ~~~~~~~~SUBGRAPH TYPES INFERENCE:~~~~~~~~ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_infer_types) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/onnx_controlflow_loop_2d_infer_types.onnx")); + const auto model = convert_model("controlflow/onnx_controlflow_loop_2d_infer_types.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // trip count test_case.add_input({10}); @@ -400,12 +337,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_infer_types) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_add_node_from_parent_scope_infer_types) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_add_node_from_parent_scope_infer_types.onnx")); + const auto model = convert_model("controlflow/loop_add_node_from_parent_scope_infer_types.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // a_init test_case.add_input({0.f, 0.f}); // parent_input @@ -420,12 +354,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_add_node_from_parent_scope_ // ~~~~~~~~ADDITIONAL TESTS:~~~~~~~~ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_concat_values) { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_concat_values.onnx")); + const auto model = convert_model("controlflow/loop_concat_values.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // trip_count test_case.add_input({5}); // init condition @@ -446,29 +377,24 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_concat_values) { // cond = ... // Note this value is ignored, but is required in the body // } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_2d_trip_count_and_cond_skipped_shape_inference) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_2d_add_trip_count_and_cond_skipped.onnx")); + const auto model = convert_model("controlflow/loop_2d_add_trip_count_and_cond_skipped.onnx"); - const auto& results = function->get_results(); + const auto& results = model->get_results(); EXPECT_EQ(results.size(), 2); - EXPECT_EQ(function->get_output_element_type(0), ngraph::element::f32); - EXPECT_TRUE(function->get_output_partial_shape(0).is_static()); - EXPECT_EQ(function->get_output_shape(0), (Shape{1, 2})); - EXPECT_EQ(function->get_output_element_type(1), ngraph::element::f32); - EXPECT_TRUE(function->get_output_partial_shape(1).rank().is_static()); - EXPECT_EQ(function->get_output_partial_shape(1).rank(), 3); - EXPECT_EQ(function->get_output_partial_shape(1), (PartialShape{Dimension::dynamic(), 1, 2})); + EXPECT_EQ(model->get_output_element_type(0), element::f32); + EXPECT_TRUE(model->get_output_partial_shape(0).is_static()); + EXPECT_EQ(model->get_output_shape(0), (Shape{1, 2})); + EXPECT_EQ(model->get_output_element_type(1), element::f32); + EXPECT_TRUE(model->get_output_partial_shape(1).rank().is_static()); + EXPECT_EQ(model->get_output_partial_shape(1).rank(), 3); + EXPECT_EQ(model->get_output_partial_shape(1), (PartialShape{Dimension::dynamic(), 1, 2})); } // infinitive loop execution OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_infinite) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_infinite.onnx")); + const auto model = convert_model("controlflow/loop_infinite.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // trip_count test_case.add_input({std::numeric_limits::max()}); // init condition @@ -486,12 +412,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_infinite) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_no_variadic_inputs_and_outputs) { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_no_variadic_inputs_and_outputs.onnx")); + const auto model = convert_model("controlflow/loop_no_variadic_inputs_and_outputs.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // trip_count test_case.add_input({1}); // init condition @@ -503,11 +426,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_no_variadic_inputs_and_outp } OPENVINO_TEST(${BACKEND_NAME}, onnx_controlflow_loop_power) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/loop_pow.onnx")); + const auto model = convert_model("controlflow/loop_pow.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // trip_count test_case.add_input({5}); // pow init @@ -528,12 +449,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_if_branches_with_same_inputs) { mul(x, y) } */ - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/if_branches_with_same_inputs.onnx")); + const auto model = convert_model("controlflow/if_branches_with_same_inputs.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); std::vector x(40, 2); std::vector y(40); std::iota(y.begin(), y.end(), -20.f); @@ -568,12 +486,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_if_branches_with_different_inputs) { abs(y) } */ - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/if_branches_with_different_inputs.onnx")); + const auto model = convert_model("controlflow/if_branches_with_different_inputs.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); std::vector x(40, 2); std::vector y(40); std::iota(y.begin(), y.end(), -20.f); @@ -608,12 +523,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_if_branches_without_inputs) { return const tensor {0, 5, 10, 15, 20, 25, 20} } */ - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/if_branches_without_inputs.onnx")); + const auto model = convert_model("controlflow/if_branches_without_inputs.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // condition test_case.add_input({true}); @@ -638,11 +550,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_if_inside_if) { sub(x, y) } */ - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/if_inside_if.onnx")); + const auto model = convert_model("controlflow/if_inside_if.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // case when condition == true and any(x > y) // expected value == x * y @@ -693,12 +603,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_if_branches_with_multiple_outputs) { transpose(part1), transpose(part2), transpose(part3) } */ - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/if_branches_with_multiple_outputs.onnx")); + const auto model = convert_model("controlflow/if_branches_with_multiple_outputs.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // case when condition == true so split is along axis 0 std::vector x(36); @@ -734,11 +641,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_if_inside_loop) { a = a * b } */ - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/if_inside_loop.onnx")); + const auto model = convert_model("controlflow/if_inside_loop.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // a_init test_case.add_input({0.f, 0.f}); @@ -759,12 +664,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_if_with_only_indentity_in_else_branch) { } output = add(input, if_output) */ - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/if_with_only_indentity_in_else_branch.onnx")); + const auto model = convert_model("controlflow/if_with_only_indentity_in_else_branch.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); std::vector x(shape_size(Shape{1, 5, 2, 2})); std::iota(x.begin(), x.end(), 0.f); @@ -790,12 +692,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_if_inside_if_inside_loop) { } */ - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/if_inside_if_inside_loop.onnx")); + const auto model = convert_model("controlflow/if_inside_if_inside_loop.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); // out_init test_case.add_input({1.f}); @@ -812,12 +711,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_if_dynamic_inputs) { mul(x, y) } */ - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/if_dynamic_inputs.onnx")); + const auto model = convert_model("controlflow/if_dynamic_inputs.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); std::vector x(40, 2); std::vector y(40); std::iota(y.begin(), y.end(), -20.f); @@ -844,24 +740,18 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_if_dynamic_inputs) { OPENVINO_TEST(${BACKEND_NAME}, onnx_if_negative_missing_branches) { try { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/if_missing_then_branch.onnx")); + const auto model = convert_model("controlflow/if_missing_then_branch.onnx"); FAIL() << "Model import succeed, but it shouldn't"; - } catch (const ngraph_error& e) { + } catch (const ov::Exception& e) { EXPECT_HAS_SUBSTRING(e.what(), std::string("Missing 'then_branch' attribute")); } catch (...) { FAIL() << "Model import failed for unexpected reason"; } try { - const auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/if_missing_else_branch.onnx")); + const auto model = convert_model("controlflow/if_missing_else_branch.onnx"); FAIL() << "Model import succeed, but it shouldn't"; - } catch (const ngraph_error& e) { + } catch (const ov::Exception& e) { EXPECT_HAS_SUBSTRING(e.what(), std::string("Missing 'else_branch' attribute")); } catch (...) { FAIL() << "Model import failed for unexpected reason"; @@ -870,12 +760,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_if_negative_missing_branches) { OPENVINO_TEST(${BACKEND_NAME}, onnx_if_negative_mismatch_between_branches_output) { try { - const auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/controlflow/if_negative_mismatch_between_branches_output.onnx")); + const auto model = convert_model("controlflow/if_negative_mismatch_between_branches_output.onnx"); FAIL() << "Model import succeed, but it shouldn't"; - } catch (const ngraph_error& e) { + } catch (const ov::Exception& e) { EXPECT_HAS_SUBSTRING(e.what(), std::string("'then' and 'else' branches have to have the same number of outputs")); } catch (...) { diff --git a/src/frontends/onnx/tests/onnx_import_convpool.in.cpp b/src/frontends/onnx/tests/onnx_import_convpool.in.cpp index d2b84034c1d413..464ee806755bd5 100644 --- a/src/frontends/onnx/tests/onnx_import_convpool.in.cpp +++ b/src/frontends/onnx/tests/onnx_import_convpool.in.cpp @@ -20,16 +20,14 @@ #include "common_test_utils/test_control.hpp" #include "common_test_utils/test_tools.hpp" #include "gtest/gtest.h" -#include "ngraph/file_util.hpp" -#include "ngraph/ngraph.hpp" #include "onnx_import/onnx.hpp" #include "onnx_utils.hpp" +#include "openvino/op/max_pool.hpp" -using namespace ngraph; +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}"); using Inputs = std::vector>; @@ -37,9 +35,7 @@ using Outputs = std::vector>; OPENVINO_TEST(${BACKEND_NAME}, onnx_model_conv2d_strides_padding) { // Convolution with strides=2 and padding=1 - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/conv_with_strides_padding.onnx")); + auto model = convert_model("conv_with_strides_padding.onnx"); Inputs inputs; // data (1, 1, 7, 5) input tensor @@ -62,7 +58,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_conv2d_strides_padding) { {{{{12.f, 27.f, 24.f}, {63.f, 108.f, 81.f}, {123.f, 198.f, 141.f}, {112.f, 177.f, 124.f}}}}) .get_vector(); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_multiple_inputs(inputs); test_case.add_expected_output(expected_output); test_case.run(); @@ -70,9 +66,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_conv2d_strides_padding) { OPENVINO_TEST(${BACKEND_NAME}, onnx_model_conv2d_strides_no_padding) { // Convolution with strides=2 and padding=1 - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/conv_with_strides_no_padding.onnx")); + auto model = convert_model("conv_with_strides_no_padding.onnx"); Inputs inputs; // data (1, 1, 7, 5) input tensor @@ -92,7 +86,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_conv2d_strides_no_padding) { // (1, 1, 3, 2) auto expected_output = ov::test::NDArray({{{{54.f, 72.f}, {144.f, 162.f}, {234.f, 252.f}}}}).get_vector(); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_multiple_inputs(inputs); test_case.add_expected_output(expected_output); test_case.run(); @@ -100,10 +94,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_conv2d_strides_no_padding) { OPENVINO_TEST(${BACKEND_NAME}, onnx_model_conv2d_strides_assymetric_padding) { // Convolution with strides=2 and padding=1 - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/conv_with_strides_and_asymmetric_padding.onnx")); + auto model = convert_model("conv_with_strides_and_asymmetric_padding.onnx"); Inputs inputs; // data (1, 1, 7, 5) input tensor @@ -124,17 +115,14 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_conv2d_strides_assymetric_padding) { auto expected_output = ov::test::NDArray({{{{21.f, 33.f}, {99.f, 117.f}, {189.f, 207.f}, {171.f, 183.f}}}}).get_vector(); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_multiple_inputs(inputs); test_case.add_expected_output(expected_output); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_conv2d_dilation_assymetric_pads_strides) { - auto function = - onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/conv2d_dilation_assym_pads_strides.onnx")); + auto model = convert_model("conv2d_dilation_assym_pads_strides.onnx"); // "", // auto_pad // vector{1, 1}, // dilations @@ -164,15 +152,14 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_conv2d_dilation_assymetric_pads_stride {{{-0.04396762326359749f, 0.10081233829259872f}}, {{-0.10154513269662857f, -0.13448859751224518f}}}}) .get_vector(); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_multiple_inputs(inputs); test_case.add_expected_output(expected_output); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_conv3d_bias) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/conv3d_bias.onnx")); + auto model = convert_model("conv3d_bias.onnx"); // "", // auto_pad // vector{2, 2, 2}, // dilations @@ -268,16 +255,14 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_conv3d_bias) { -0.39770257472991943f, -0.45317384600639343f, -0.5598302483558655f, -0.2542789578437805f, -0.5359901785850525f, -0.48090484738349915f, -0.38603779673576355f, -0.4991581439971924f}; - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_multiple_inputs(inputs); test_case.add_expected_output(expected_output); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_conv_transpose_w_groups) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/conv_transpose_w_groups.onnx")); + auto model = convert_model("conv_transpose_w_groups.onnx"); Inputs inputs; inputs.emplace_back( @@ -288,7 +273,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_conv_transpose_w_groups) { std::vector expected_output{28.f, 34.f, 252.f, 274.f, 732.f, 770.f, 1468.f, 1522.f}; - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_multiple_inputs(inputs); test_case.add_expected_output(expected_output); test_case.run(); @@ -296,8 +281,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_conv_transpose_w_groups) { OPENVINO_TEST(${BACKEND_NAME}, onnx_model_average_pool_2d) { // Pooling with strides=2 and no padding - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/average_pool_2d.onnx")); + auto model = convert_model("average_pool_2d.onnx"); // input data shape (1, 1, 4, 4) Inputs inputs; @@ -309,7 +293,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_average_pool_2d) { // (1, 1, 2, 2) auto expected_output = ov::test::NDArray({{{{2.5f, 4.5f}, {10.5f, 12.5f}}}}).get_vector(); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_multiple_inputs(inputs); test_case.add_expected_output(expected_output); test_case.run(); @@ -317,9 +301,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_average_pool_2d) { OPENVINO_TEST(${BACKEND_NAME}, onnx_model_average_pool_2d_pads) { // Pooling with strides=2 and padding=1 - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/average_pool_2d_pads.onnx")); + auto model = convert_model("average_pool_2d_pads.onnx"); // input data shape (1, 1, 4, 4) Inputs inputs; @@ -332,18 +314,16 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_average_pool_2d_pads) { auto expected_output = ov::test::NDArray({{{{0.f, 1.5f, 3.f}, {6.f, 7.5f, 9.f}, {12.f, 13.5f, 15.f}}}}).get_vector(); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_multiple_inputs(inputs); test_case.add_expected_output(expected_output); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_average_pool_empty_auto_pad) { - const auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/average_pool_empty_auto_pad.onnx")); + const auto model = convert_model("average_pool_empty_auto_pad.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, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f}); test_case.add_expected_output( Shape{1, 1, 3, 3}, @@ -352,9 +332,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_average_pool_empty_auto_pad) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_max_pool_empty_auto_pad) { - const auto model = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/max_pool_empty_auto_pad.onnx")); + const auto model = convert_model("max_pool_empty_auto_pad.onnx"); for (const auto& op : model->get_ops()) { if (const auto max_pool = std::dynamic_pointer_cast(op)) { @@ -368,8 +346,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_max_pool_empty_auto_pad) { OPENVINO_TEST(${BACKEND_NAME}, onnx_model_max_pool_2d_pads) { // Pooling with strides=2 and padding=1 - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/max_pool_2d_pads.onnx")); + auto model = convert_model("max_pool_2d_pads.onnx"); // input data shape (1, 1, 4, 4) Inputs inputs; @@ -382,99 +359,90 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_max_pool_2d_pads) { auto expected_output = ov::test::NDArray({{{{0.f, 2.f, 3.f}, {8.f, 10.f, 11.f}, {12.f, 14.f, 15.f}}}}).get_vector(); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_multiple_inputs(inputs); test_case.add_expected_output(expected_output); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_global_lp_pool_p0) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/global_lp_pool_p0.onnx")); + auto model = convert_model("global_lp_pool_p0.onnx"); std::vector input{1, 0, -4, 0, 2, 1, -6, 1, 0, 0, 0, 0, -7, 1, -1, 0, -1, 8, 0, 10, 9, 0, 0, 5}; std::vector expected_output{6, 8}; - 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(expected_output); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_global_lp_pool_p1) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/global_lp_pool_p1.onnx")); + auto model = convert_model("global_lp_pool_p1.onnx"); Inputs inputs{std::vector(2 * 3 * 4)}; std::iota(std::begin(inputs.front()), std::end(inputs.front()), 0.f); std::vector expected_output{66.f, 210.f}; - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_multiple_inputs(inputs); test_case.add_expected_output(expected_output); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_global_lp_pool_p2) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/global_lp_pool_p2.onnx")); + auto model = convert_model("global_lp_pool_p2.onnx"); Inputs inputs{std::vector(2 * 3 * 4)}; std::iota(std::begin(inputs.front()), std::end(inputs.front()), 0.f); std::vector expected_output{22.494444f, 61.789967f}; - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_multiple_inputs(inputs); test_case.add_expected_output(expected_output); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_global_lp_pool_p3) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/global_lp_pool_p3.onnx")); + auto model = convert_model("global_lp_pool_p3.onnx"); Inputs inputs{std::vector(2 * 3 * 4)}; std::iota(std::begin(inputs.front()), std::end(inputs.front()), 0.f); std::vector expected_output{16.331620904278438f, 41.56697946707537f}; - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_multiple_inputs(inputs); test_case.add_expected_output(expected_output); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_convtranspose_output_shape) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/convtranspose_output_shape.onnx")); - - auto test_case = ov::test::TestCase(function, s_device); - - test_case.add_input_from_file(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/files/convtranspose_output_shape/x.bin")); - test_case.add_input_from_file(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/files/convtranspose_output_shape/w.bin")); + auto model = convert_model("convtranspose_output_shape.onnx"); + + auto test_case = ov::test::TestCase(model, s_device); + + test_case.add_input_from_file(util::path_join({ov::test::utils::getExecutableDirectory(), + TEST_ONNX_MODELS_DIRNAME, + "files/convtranspose_output_shape/x.bin"})); + test_case.add_input_from_file(util::path_join({ov::test::utils::getExecutableDirectory(), + TEST_ONNX_MODELS_DIRNAME, + "files/convtranspose_output_shape/w.bin"})); test_case.add_expected_output_from_file({1, 2, 10, 8}, - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/files/convtranspose_output_shape/y.bin")); + util::path_join({ov::test::utils::getExecutableDirectory(), + TEST_ONNX_MODELS_DIRNAME, + "files/convtranspose_output_shape/y.bin"})); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_convtranspose_output_shape_auto_pads_same_upper) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/convtranspose_output_shape_auto_pads_same_upper.onnx")); + auto model = convert_model("convtranspose_output_shape_auto_pads_same_upper.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input({0.f, 0.25f, 0.5f, 0.75f, 1.f, 1.25f, 1.5f, 1.75f, 2.f, 2.25f, 2.5f, 2.75f}); test_case.add_input({0.f, 0.25f, 0.5f, 0.75f, 1.f, 1.25f, 1.5f, 1.75f, 2.f, 2.25f, 2.5f, 2.75f, @@ -496,12 +464,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_convtranspose_output_shape_auto_pads_s } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_convtranspose_output_shape_auto_pads_same_lower) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/convtranspose_output_shape_auto_pads_same_lower.onnx")); + auto model = convert_model("convtranspose_output_shape_auto_pads_same_lower.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input({0.f, 0.25f, 0.5f, 0.75f, 1.f, 1.25f, 1.5f, 1.75f, 2.f, 2.25f, 2.5f, 2.75f}); test_case.add_input({0.f, 0.25f, 0.5f, 0.75f, 1.f, 1.25f, 1.5f, 1.75f, 2.f, 2.25f, 2.5f, 2.75f, @@ -523,11 +488,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_convtranspose_output_shape_auto_pads_s } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_convtranspose_groups_w_pads) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/convtranspose_groups_w_pads.onnx")); + auto model = convert_model("convtranspose_groups_w_pads.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input({ 0.f, @@ -576,11 +539,9 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_convtranspose_groups_w_pads) { } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_convtranspose_groups_pads_bias) { - auto function = onnx_import::import_onnx_model(file_util::path_join(ov::test::utils::getExecutableDirectory(), - SERIALIZED_ZOO, - "onnx/convtranspose_groups_pads_bias.onnx")); + auto model = convert_model("convtranspose_groups_pads_bias.onnx"); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input({0.f, 0.25f, diff --git a/src/frontends/onnx/tests/onnx_import_deprecated.in.cpp b/src/frontends/onnx/tests/onnx_import_deprecated.in.cpp index 70df93755ab2c9..79fefe8d80a612 100644 --- a/src/frontends/onnx/tests/onnx_import_deprecated.in.cpp +++ b/src/frontends/onnx/tests/onnx_import_deprecated.in.cpp @@ -20,35 +20,30 @@ #include "common_test_utils/test_control.hpp" #include "common_test_utils/test_tools.hpp" #include "gtest/gtest.h" -#include "ngraph/file_util.hpp" -#include "ngraph/ngraph.hpp" #include "onnx_import/onnx.hpp" #include "onnx_utils.hpp" -using namespace ngraph; +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_model_affine) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/affine.onnx")); + auto model = convert_model("affine.onnx"); // input/output shape (1, 3) auto input = ov::test::NDArray{{{0.f, 1.f, 2.f}}}.get_vector(); auto expected_output = ov::test::NDArray{{{50.f, 50.5f, 51.f}}}.get_vector(); - 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}, input); test_case.add_expected_output(Shape{1, 3}, expected_output); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_crop) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/crop.onnx")); + auto model = convert_model("crop.onnx"); // input shape (1, 1, 4, 4) auto input = ov::test::NDArray({{{{19.f, 20.f, 21.f, 22.f}, @@ -60,15 +55,14 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_crop) { // output shape (1, 1, 2, 2) auto expected_output = ov::test::NDArray{{{{24.f, 25.f}, {28.f, 29.f}}}}.get_vector(); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{1, 1, 4, 4}, input); test_case.add_expected_output(Shape{1, 1, 2, 2}, expected_output); test_case.run(); } OPENVINO_TEST(${BACKEND_NAME}, onnx_model_crop_with_scale) { - auto function = onnx_import::import_onnx_model( - file_util::path_join(ov::test::utils::getExecutableDirectory(), SERIALIZED_ZOO, "onnx/crop_with_scale.onnx")); + auto model = convert_model("crop_with_scale.onnx"); // input shape (1, 1, 4, 4) auto input = ov::test::NDArray({{{{19.f, 20.f, 21.f, 22.f}, @@ -80,7 +74,7 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_crop_with_scale) { // output shape (1, 1, 2, 3) auto expected_output = ov::test::NDArray{{{{24.f, 25.f, 26.f}, {28.f, 29.f, 30.f}}}}.get_vector(); - auto test_case = ov::test::TestCase(function, s_device); + auto test_case = ov::test::TestCase(model, s_device); test_case.add_input(Shape{1, 1, 4, 4}, input); test_case.add_expected_output(Shape{1, 1, 2, 3}, expected_output); test_case.run();