diff --git a/src/frontends/onnx/tests/models/castlike_bfloat16_to_float32.prototxt b/src/frontends/onnx/tests/models/castlike_bfloat16_to_float32.prototxt new file mode 100644 index 00000000000..bd932116f02 --- /dev/null +++ b/src/frontends/onnx/tests/models/castlike_bfloat16_to_float32.prototxt @@ -0,0 +1,63 @@ +ir_version: 8 +producer_name: "onnx-importer-test" +graph { + node { + input: "input" + input: "like" + output: "output" + op_type: "CastLike" + } + name: "test-model" + input { + name: "input" + type { + tensor_type { + elem_type: 16 + shape { + dim { + dim_value: 3 + } + dim { + dim_value: 4 + } + } + } + } + } + input { + name: "like" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 3 + } + dim { + dim_value: 4 + } + } + } + } + } + output { + name: "output" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 3 + } + dim { + dim_value: 4 + } + } + } + } + } +} +opset_import { + domain: "" + version: 15 +} diff --git a/src/frontends/onnx/tests/models/castlike_float16_to_int64.prototxt b/src/frontends/onnx/tests/models/castlike_float16_to_int64.prototxt new file mode 100644 index 00000000000..ec765ef052c --- /dev/null +++ b/src/frontends/onnx/tests/models/castlike_float16_to_int64.prototxt @@ -0,0 +1,72 @@ +ir_version: 8 +producer_name: "onnx-importer-test" +graph { + node { + input: "input" + input: "like" + output: "output" + op_type: "CastLike" + } + name: "test-model" + input { + name: "input" + type { + tensor_type { + elem_type: 10 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "like" + type { + tensor_type { + elem_type: 7 + shape { + dim { + dim_value: 4 + } + } + } + } + } + output { + name: "output" + type { + tensor_type { + elem_type: 7 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } +} +opset_import { + domain: "" + version: 15 +} diff --git a/src/frontends/onnx/tests/models/castlike_float16_to_uint32.prototxt b/src/frontends/onnx/tests/models/castlike_float16_to_uint32.prototxt new file mode 100644 index 00000000000..01466c26fa1 --- /dev/null +++ b/src/frontends/onnx/tests/models/castlike_float16_to_uint32.prototxt @@ -0,0 +1,72 @@ +ir_version: 8 +producer_name: "onnx-importer-test" +graph { + node { + input: "input" + input: "like" + output: "output" + op_type: "CastLike" + } + name: "test-model" + input { + name: "input" + type { + tensor_type { + elem_type: 10 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "like" + type { + tensor_type { + elem_type: 12 + shape { + dim { + dim_value: 4 + } + } + } + } + } + output { + name: "output" + type { + tensor_type { + elem_type: 12 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } +} +opset_import { + domain: "" + version: 15 +} diff --git a/src/frontends/onnx/tests/models/castlike_float32_to_bfloat16.prototxt b/src/frontends/onnx/tests/models/castlike_float32_to_bfloat16.prototxt new file mode 100644 index 00000000000..c99069ef646 --- /dev/null +++ b/src/frontends/onnx/tests/models/castlike_float32_to_bfloat16.prototxt @@ -0,0 +1,63 @@ +ir_version: 8 +producer_name: "onnx-importer-test" +graph { + node { + input: "input" + input: "like" + output: "output" + op_type: "CastLike" + } + name: "test-model" + input { + name: "input" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 3 + } + dim { + dim_value: 4 + } + } + } + } + } + input { + name: "like" + type { + tensor_type { + elem_type: 16 + shape { + dim { + dim_value: 3 + } + dim { + dim_value: 4 + } + } + } + } + } + output { + name: "output" + type { + tensor_type { + elem_type: 16 + shape { + dim { + dim_value: 3 + } + dim { + dim_value: 4 + } + } + } + } + } +} +opset_import { + domain: "" + version: 15 +} diff --git a/src/frontends/onnx/tests/models/castlike_float64_to_int32.prototxt b/src/frontends/onnx/tests/models/castlike_float64_to_int32.prototxt new file mode 100644 index 00000000000..5020ff816bd --- /dev/null +++ b/src/frontends/onnx/tests/models/castlike_float64_to_int32.prototxt @@ -0,0 +1,72 @@ +ir_version: 8 +producer_name: "onnx-importer-test" +graph { + node { + input: "input" + input: "like" + output: "output" + op_type: "CastLike" + } + name: "test-model" + input { + name: "input" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "like" + type { + tensor_type { + elem_type: 6 + shape { + dim { + dim_value: 4 + } + } + } + } + } + output { + name: "output" + type { + tensor_type { + elem_type: 6 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } +} +opset_import { + domain: "" + version: 15 +} diff --git a/src/frontends/onnx/tests/models/castlike_float64_to_int64.prototxt b/src/frontends/onnx/tests/models/castlike_float64_to_int64.prototxt new file mode 100644 index 00000000000..383e3ca3df1 --- /dev/null +++ b/src/frontends/onnx/tests/models/castlike_float64_to_int64.prototxt @@ -0,0 +1,72 @@ +ir_version: 8 +producer_name: "onnx-importer-test" +graph { + node { + input: "input" + input: "like" + output: "output" + op_type: "CastLike" + } + name: "test-model" + input { + name: "input" + type { + tensor_type { + elem_type: 11 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "like" + type { + tensor_type { + elem_type: 7 + shape { + dim { + dim_value: 4 + } + } + } + } + } + output { + name: "output" + type { + tensor_type { + elem_type: 7 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } +} +opset_import { + domain: "" + version: 15 +} diff --git a/src/frontends/onnx/tests/models/castlike_int32_to_float64.prototxt b/src/frontends/onnx/tests/models/castlike_int32_to_float64.prototxt new file mode 100644 index 00000000000..7bdfd6b6461 --- /dev/null +++ b/src/frontends/onnx/tests/models/castlike_int32_to_float64.prototxt @@ -0,0 +1,72 @@ +ir_version: 8 +producer_name: "onnx-importer-test" +graph { + node { + input: "input" + input: "like" + output: "output" + op_type: "CastLike" + } + name: "test-model" + input { + name: "input" + type { + tensor_type { + elem_type: 6 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "like" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 4 + } + } + } + } + } + output { + name: "output" + type { + tensor_type { + elem_type: 1 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } +} +opset_import { + domain: "" + version: 15 +} diff --git a/src/frontends/onnx/tests/models/castlike_int8_to_float16.prototxt b/src/frontends/onnx/tests/models/castlike_int8_to_float16.prototxt new file mode 100644 index 00000000000..213ebdf2f06 --- /dev/null +++ b/src/frontends/onnx/tests/models/castlike_int8_to_float16.prototxt @@ -0,0 +1,72 @@ +ir_version: 8 +producer_name: "onnx-importer-test" +graph { + node { + input: "input" + input: "like" + output: "output" + op_type: "CastLike" + } + name: "test-model" + input { + name: "input" + type { + tensor_type { + elem_type: 3 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "like" + type { + tensor_type { + elem_type: 10 + shape { + dim { + dim_value: 4 + } + } + } + } + } + output { + name: "output" + type { + tensor_type { + elem_type: 10 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } +} +opset_import { + domain: "" + version: 15 +} diff --git a/src/frontends/onnx/tests/models/castlike_int8_to_int16.prototxt b/src/frontends/onnx/tests/models/castlike_int8_to_int16.prototxt new file mode 100644 index 00000000000..ad950fdbfdd --- /dev/null +++ b/src/frontends/onnx/tests/models/castlike_int8_to_int16.prototxt @@ -0,0 +1,72 @@ +ir_version: 8 +producer_name: "onnx-importer-test" +graph { + node { + input: "input" + input: "like" + output: "output" + op_type: "CastLike" + } + name: "test-model" + input { + name: "input" + type { + tensor_type { + elem_type: 3 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "like" + type { + tensor_type { + elem_type: 5 + shape { + dim { + dim_value: 4 + } + } + } + } + } + output { + name: "output" + type { + tensor_type { + elem_type: 5 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } +} +opset_import { + domain: "" + version: 15 +} diff --git a/src/frontends/onnx/tests/models/castlike_int8_to_uint16.prototxt b/src/frontends/onnx/tests/models/castlike_int8_to_uint16.prototxt new file mode 100644 index 00000000000..ef3dfc33a1b --- /dev/null +++ b/src/frontends/onnx/tests/models/castlike_int8_to_uint16.prototxt @@ -0,0 +1,72 @@ +ir_version: 8 +producer_name: "onnx-importer-test" +graph { + node { + input: "input" + input: "like" + output: "output" + op_type: "CastLike" + } + name: "test-model" + input { + name: "input" + type { + tensor_type { + elem_type: 3 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "like" + type { + tensor_type { + elem_type: 4 + shape { + dim { + dim_value: 4 + } + } + } + } + } + output { + name: "output" + type { + tensor_type { + elem_type: 4 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } +} +opset_import { + domain: "" + version: 15 +} diff --git a/src/frontends/onnx/tests/onnx_import.in.cpp b/src/frontends/onnx/tests/onnx_import.in.cpp index 51f32508cf8..6c77ca2cb3c 100644 --- a/src/frontends/onnx/tests/onnx_import.in.cpp +++ b/src/frontends/onnx/tests/onnx_import.in.cpp @@ -6141,3 +6141,129 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_constant_of_shape_null_node) { test_case.add_expected_output(Shape{}, {1}); test_case.run(); } + +NGRAPH_TEST(${BACKEND_NAME}, castlike_float16_to_uint32) { + auto function = onnx_import::import_onnx_model(file_util::path_join(CommonTestUtils::getExecutableDirectory(), + SERIALIZED_ZOO, + "onnx/castlike_float16_to_uint32.onnx")); + + auto test_case = test::TestCase(function, s_device); + + test_case.add_input(Shape{1, 1, 2, 2}, std::vector{1.5, 2.3, 3, 4}); + test_case.add_input(Shape{4}, {1, 2, 3, 4}); + test_case.add_expected_output(std::vector{1, 2, 3, 4}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, castlike_float16_to_int64) { + auto function = onnx_import::import_onnx_model(file_util::path_join(CommonTestUtils::getExecutableDirectory(), + SERIALIZED_ZOO, + "onnx/castlike_float16_to_int64.onnx")); + + auto test_case = test::TestCase(function, s_device); + + test_case.add_input(Shape{1, 1, 2, 2}, std::vector{1.5, 2.3, 3, 4}); + test_case.add_input(Shape{4}, {1, 2, 3, 4}); + test_case.add_expected_output(std::vector{1, 2, 3, 4}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, DISABLED_castlike_int8_to_uint16) { + auto function = onnx_import::import_onnx_model(file_util::path_join(CommonTestUtils::getExecutableDirectory(), + SERIALIZED_ZOO, + "onnx/castlike_int8_to_uint16.onnx")); + + auto test_case = test::TestCase(function, s_device); + + test_case.add_input(Shape{1, 1, 2, 2}, std::vector{-1, -2, 3, 4}); + test_case.add_input(Shape{4}, {1, 2, 3, 4}); + test_case.add_expected_output(std::vector{65535, 65534, 3, 4}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, castlike_float64_to_int64) { + auto function = onnx_import::import_onnx_model(file_util::path_join(CommonTestUtils::getExecutableDirectory(), + SERIALIZED_ZOO, + "onnx/castlike_float64_to_int64.onnx")); + + auto test_case = test::TestCase(function, s_device); + + test_case.add_input(Shape{1, 1, 2, 2}, std::vector{1.5, 2.3, 3, 4}); + test_case.add_input(Shape{4}, {1, 2, 3, 4}); + test_case.add_expected_output(std::vector{1, 2, 3, 4}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, castlike_int8_to_float16) { + auto function = onnx_import::import_onnx_model(file_util::path_join(CommonTestUtils::getExecutableDirectory(), + SERIALIZED_ZOO, + "onnx/castlike_int8_to_float16.onnx")); + + auto test_case = test::TestCase(function, s_device); + + test_case.add_input(Shape{1, 1, 2, 2}, std::vector{-127, -2, 3, 4}); + test_case.add_input(Shape{4}, {1, 2, 3, 4}); + test_case.add_expected_output(std::vector{-127.0, -2.0, 3.0, 4.0}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, castlike_int32_to_float) { + auto function = onnx_import::import_onnx_model(file_util::path_join(CommonTestUtils::getExecutableDirectory(), + SERIALIZED_ZOO, + "onnx/castlike_int32_to_float64.onnx")); + + auto test_case = test::TestCase(function, s_device); + + test_case.add_input(Shape{1, 1, 2, 2}, std::vector{-1, 2, 3, 4}); + test_case.add_input(Shape{4}, {1, 2, 3, 4}); + test_case.add_expected_output(std::vector{-1.0, 2.0, 3.0, 4.0}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, castlike_float64_to_int32) { + auto function = onnx_import::import_onnx_model(file_util::path_join(CommonTestUtils::getExecutableDirectory(), + SERIALIZED_ZOO, + "onnx/castlike_float64_to_int32.onnx")); + + auto test_case = test::TestCase(function, s_device); + + test_case.add_input(Shape{1, 1, 2, 2}, std::vector{-107374.9876543, -2.2, 3.3, 4.4}); + test_case.add_input(Shape{4}, {1, 2, 3, 4}); + test_case.add_expected_output(std::vector{-107374, -2, 3, 4}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, DISABLED_castlike_float32_to_bfloat16) { + auto function = onnx_import::import_onnx_model(file_util::path_join(CommonTestUtils::getExecutableDirectory(), + SERIALIZED_ZOO, + "onnx/castlike_float32_to_bfloat16.onnx")); + + auto test_case = test::TestCase(function, s_device); + + test_case.add_input(Shape{3, 4}, std::vector{121.5, 122.7, 3, 4, 5, 6, 7, 8.8, 9, 10, 11, 12}); + test_case.add_input(Shape{3, 4}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}); + test_case.add_expected_output(std::vector{121.5, 122.7, 3, 4, 5, 6, 7, 8.8, 9, 10, 11, 12}); + + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, DISABLED_castlike_bfloat16_to_float32) { + auto function = onnx_import::import_onnx_model(file_util::path_join(CommonTestUtils::getExecutableDirectory(), + SERIALIZED_ZOO, + "onnx/castlike_bfloat16_to_float32.onnx")); + + auto test_case = test::TestCase(function, s_device); + + test_case.add_input(Shape{3, 4}, std::vector{121.5, 122.7, 3, 4, 5, 6, 7, 8.8, 9, 10, 11, 12}); + test_case.add_input(Shape{3, 4}, {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}); + test_case.add_expected_output(std::vector{121.5, 122.7, 3, 4, 5, 6, 7, 8.75, 9, 10, 11, 12}); + + test_case.run(); +}