OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[Snippets][CPU][TESTS] Make Convert tests platform independent (#32105)
Arseniy Obolenskiy65a8cf5acee1
diff --git a/src/plugins/intel_cpu/tests/functional/CMakeLists.txt b/src/plugins/intel_cpu/tests/functional/CMakeLists.txtindex afea5309eeb..53e90cf26aa 100644--- a/src/plugins/intel_cpu/tests/functional/CMakeLists.txt+++ b/src/plugins/intel_cpu/tests/functional/CMakeLists.txt@@ -62,7 +62,6 @@ if(NOT (X86 OR X86_64))list(APPEND EXCLUDED_SOURCE_PATHS${CMAKE_CURRENT_SOURCE_DIR}/custom/single_layer_tests/instances/x64${CMAKE_CURRENT_SOURCE_DIR}/custom/subgraph_tests/src/x64- ${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances/snippets/x64${CMAKE_CURRENT_SOURCE_DIR}/utils/x64)endif()@@ -70,7 +69,6 @@ if(NOT (ARM OR AARCH64))list(APPEND EXCLUDED_SOURCE_PATHS${CMAKE_CURRENT_SOURCE_DIR}/custom/single_layer_tests/instances/arm${CMAKE_CURRENT_SOURCE_DIR}/custom/subgraph_tests/src/arm- ${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances/snippets/arm${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances/low_precision_transformations/aarch64${CMAKE_CURRENT_SOURCE_DIR}/utils/arm)else()diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/arm/convert.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/convert.cppsimilarity index 60%rename from src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/arm/convert.cpprename to src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/convert.cppindex 4d1877f5d23..c1cf4cd0c99 100644--- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/arm/convert.cpp+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/convert.cpp@@ -1,18 +1,18 @@-// Copyright (C) 2024 Intel Corporation+// Copyright (C) 2018-2025 Intel Corporation// SPDX-License-Identifier: Apache-2.0//#include "snippets/convert.hpp"#include "common_test_utils/test_constants.hpp"+#include "utils.hpp"namespace ov {namespace test {namespace snippets {--namespace {-const std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::element::Type>>> types_Convert = {+static std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::element::Type>>> getTypesConvert() {+ std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::element::Type>>> types = {{ { ov::element::f32 }, { ov::element::f16 } },{ { ov::element::f32 }, { ov::element::i8 } },{ { ov::element::f32 }, { ov::element::u8 } },@@ -28,25 +28,46 @@ const std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::elem{ { ov::element::u8 }, { ov::element::f32 } },{ { ov::element::u8 }, { ov::element::f16 } },{ { ov::element::u8 }, { ov::element::i8 } },-};--const std::vector<std::vector<ov::test::InputShape>> inputShapes_Convert = {+ };++ types.push_back({{ ov::element::f32 }, { ov::element::bf16 }});+ types.push_back({{ ov::element::f16 }, { ov::element::bf16 }});+ types.push_back({{ ov::element::bf16 }, { ov::element::f32 }});+ types.push_back({{ ov::element::bf16 }, { ov::element::i8 }});+ types.push_back({{ ov::element::bf16 }, { ov::element::u8 }});+ types.push_back({{ ov::element::bf16 }, { ov::element::f16 }});+ types.push_back({{ ov::element::i8 }, { ov::element::bf16 }});+ types.push_back({{ ov::element::u8 }, { ov::element::bf16 }});++ return types;+}++static std::vector<std::vector<ov::test::InputShape>> getInputShapesConvert() {+ std::vector<std::vector<ov::test::InputShape>> shapes = {{ {{}, {{2, 16}}} },{ {{}, {{5, 7}}} },{ {{}, {{2, 12, 1}}} },{ {{{1, 6}, 6}, {{6, 6}, {1, 6}, {6, 6}}} },-};+ };++ shapes.push_back({ {{-1, -1}, {{2, 16}, {2, 8}, {2, 16}}} });+ shapes.push_back({ {{{1, 5}, 5}, {{5, 5}, {1, 5}, {5, 5}}} });+ shapes.push_back({ {{{1, 10}, {4, 12}, {1, 2}}, {{2, 12, 1}, {4, 4, 2}, {2, 12, 1}}} });++ return shapes;+}INSTANTIATE_TEST_SUITE_P(smoke_Snippets_Convert, Convert,::testing::Combine(- ::testing::ValuesIn(inputShapes_Convert),- ::testing::ValuesIn(types_Convert),+ ::testing::ValuesIn(getInputShapesConvert()),+ ::testing::ValuesIn(getTypesConvert()),::testing::Values(1),::testing::Values(1),::testing::Values(ov::test::utils::DEVICE_CPU)),Convert::getTestCaseName);-const std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::element::Type>>> types_ConvertInput = {+static std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::element::Type>>> getTypesConvertInput() {+ std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::element::Type>>> types = {{ { ov::element::f32 }, { ov::element::f16 } },{ { ov::element::f16 }, { ov::element::f32 } },@@ -56,27 +77,35 @@ const std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::elem{ { ov::element::u8 }, { ov::element::f32 } },{ { ov::element::u8 }, { ov::element::f16 } },-};+ };-const std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::element::Type>>> types_ConvertStub = {- { { ov::element::i8 }, { ov::element::f32 } },- { { ov::element::i8 }, { ov::element::f16 } },+ types.push_back({{ ov::element::f32 }, { ov::element::bf16 }});+ types.push_back({{ ov::element::bf16 }, { ov::element::f32 }});+ types.push_back({{ ov::element::i8 }, { ov::element::bf16 }});+ types.push_back({{ ov::element::u8 }, { ov::element::bf16 }});- { { ov::element::u8 }, { ov::element::f32 } },- { { ov::element::u8 }, { ov::element::f16 } },-};+ return types;+}-const std::vector<std::vector<ov::test::InputShape>> inputShapes_ConvertInput = {+static std::vector<std::vector<ov::test::InputShape>> getInputShapesConvertInput() {+ std::vector<std::vector<ov::test::InputShape>> shapes = {{ {{}, {{2, 16}}}, {{}, {{1, 16}}} },{ {{}, {{5, 18}}}, {{}, {{5, 1}}} },{ {{}, {{3, 1}}}, {{}, {{3, 21}}} },{ {{{1, 6}, 6}, {{6, 6}, {1, 6}, {6, 6}}}, {{{1, 6}, 6}, {{1, 6}, {6, 6}, {1, 6}}} },-};+ };++ shapes.push_back({ {{-1, -1}, {{2, 16}, {1, 16}, {2, 16}}}, {{-1, -1}, {{1, 16}, {2, 16}, {1, 16}}} });+ shapes.push_back({ {{5, -1}, {{5, 18}, {5, 1}, {5, 18}}}, {{-1, 1}, {{5, 1}, {1, 1}, {5, 1}}} });+ shapes.push_back({ {{{1, 4}, {1, 8}}, {{3, 1}, {4, 8}, {3, 1}}}, {{{1, 4}, {8, 21}}, {{3, 21}, {1, 8}, {3, 21}}} });++ return shapes;+}INSTANTIATE_TEST_SUITE_P(smoke_Snippets_ConvertInput, ConvertInput,::testing::Combine(- ::testing::ValuesIn(inputShapes_ConvertInput),- ::testing::ValuesIn(types_ConvertInput),+ ::testing::ValuesIn(getInputShapesConvertInput()),+ ::testing::ValuesIn(getTypesConvertInput()),::testing::Values(1),::testing::Values(1),::testing::Values(ov::test::utils::DEVICE_CPU)),@@ -84,17 +113,32 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_ConvertInput, ConvertInput,INSTANTIATE_TEST_SUITE_P(smoke_Snippets_ConvertOutput, ConvertOutput,::testing::Combine(- ::testing::ValuesIn(inputShapes_ConvertInput),- ::testing::ValuesIn(types_ConvertInput),+ ::testing::ValuesIn(getInputShapesConvertInput()),+ ::testing::ValuesIn(getTypesConvertInput()),::testing::Values(1),::testing::Values(1),::testing::Values(ov::test::utils::DEVICE_CPU)),Convert::getTestCaseName);+static std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::element::Type>>> getTypesConvertStub() {+ std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::element::Type>>> types = {+ { { ov::element::i8 }, { ov::element::f32 } },+ { { ov::element::i8 }, { ov::element::f16 } },++ { { ov::element::u8 }, { ov::element::f32 } },+ { { ov::element::u8 }, { ov::element::f16 } },+ };++ types.push_back({{ ov::element::i8 }, { ov::element::bf16 }});+ types.push_back({{ ov::element::u8 }, { ov::element::bf16 }});++ return types;+}+INSTANTIATE_TEST_SUITE_P(smoke_Snippets_ConvertStub, ConvertStub,::testing::Combine(- ::testing::ValuesIn(inputShapes_ConvertInput),- ::testing::ValuesIn(types_ConvertStub),+ ::testing::ValuesIn(getInputShapesConvertInput()),+ ::testing::ValuesIn(getTypesConvertStub()),::testing::Values(1),::testing::Values(1),::testing::Values(ov::test::utils::DEVICE_CPU)),@@ -104,16 +148,22 @@ const std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::elem{ { ov::element::i8, ov::element::i8, ov::element::f32 }, { ov::element::f32, ov::element::i8 } },};-const std::vector<std::vector<ov::test::InputShape>> inputShapes_ConvertPartialInputsAndResults = {+static std::vector<std::vector<ov::test::InputShape>> getInputShapesConvertPartialInputsAndResults() {+ std::vector<std::vector<ov::test::InputShape>> shapes = {{ {{}, {{2, 16}}}, {{}, {{1, 16}}}, {{}, {{1, 1}}} },{ {{}, {{5, 18}}}, {{}, {{5, 1}}}, {{}, {{1, 18}}} },{ {{}, {{3, 1}}}, {{}, {{3, 21}}}, {{}, {{3, 1}}} },{ {{{1, 3}, 4}, {{1, 4}, {2, 4}, {3, 4}}}, {{{1, 3}, 4}, {{3, 4}, {2, 4}, {3, 4}}}, {{{1, 3}, 4}, {{1, 4}, {1, 4}, {3, 4}}} },-};+ };++ shapes.push_back({ {{-1, -1}, {{3, 1}, {2, 4}, {3, 1}}}, {{{1, 3}, -1}, {{3, 21}, {2, 1}, {3, 21}}}, {{{1, 3}, {1, 2}}, {{3, 1}, {1, 1}, {3, 1}}} });++ return shapes;+}INSTANTIATE_TEST_SUITE_P(smoke_Snippets_ConvertPartialInputsAndResults, ConvertPartialInputsAndResults,::testing::Combine(- ::testing::ValuesIn(inputShapes_ConvertPartialInputsAndResults),+ ::testing::ValuesIn(getInputShapesConvertPartialInputsAndResults()),::testing::ValuesIn(types_ConvertPartialInputsAndResults),::testing::Values(2), // subgraph & roll after subgraph::testing::Values(1),@@ -126,14 +176,21 @@ const std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::elem{ { ov::element::f32, ov::element::f32, ov::element::i8, ov::element::i8 }, {} },};-const std::vector<std::vector<ov::test::InputShape>> inputShapes_ConvertManyOnInputs = {+static std::vector<std::vector<ov::test::InputShape>> getInputShapesConvertManyOnInputs() {+ std::vector<std::vector<ov::test::InputShape>> shapes = {{ {{}, {{5, 5, 5, 5}}} },{ {{{3, 5}, {3, 5}, {3, 5}, 5}, {{5, 5, 5, 5}, {3, 3, 3, 5}, {5, 5, 5, 5}}} }-};+ };++ // Add dynamic shapes for all platforms+ shapes.push_back({ {{-1, -1, -1, -1}, {{5, 5, 5, 5}, {3, 3, 3, 3}, {5, 5, 5, 5}}} });++ return shapes;+}INSTANTIATE_TEST_SUITE_P(smoke_Snippets_ConvertManyOnInputs, ConvertManyOnInputs,::testing::Combine(- ::testing::ValuesIn(inputShapes_ConvertManyOnInputs),+ ::testing::ValuesIn(getInputShapesConvertManyOnInputs()),::testing::ValuesIn(types_ConvertMany),::testing::Values(1),::testing::Values(1),@@ -142,7 +199,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_ConvertManyOnInputs, ConvertManyOnInputsINSTANTIATE_TEST_SUITE_P(smoke_Snippets_ConvertManyOnOutputs, ConvertManyOnOutputs,::testing::Combine(- ::testing::ValuesIn(inputShapes_ConvertManyOnInputs),+ ::testing::ValuesIn(getInputShapesConvertManyOnInputs()),::testing::ValuesIn(types_ConvertMany),::testing::Values(1),::testing::Values(1),@@ -156,7 +213,7 @@ const std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::elemINSTANTIATE_TEST_SUITE_P(smoke_Snippets_ConvertManyOnInputOutput, ConvertManyOnInputOutput,::testing::Combine(- ::testing::ValuesIn(inputShapes_ConvertManyOnInputs),+ ::testing::ValuesIn(getInputShapesConvertManyOnInputs()),::testing::ValuesIn(types_ConvertManyIO),::testing::Values(1),::testing::Values(1),diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/x64/convert.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/x64/convert.cppdeleted file mode 100644index 590135c1575..00000000000--- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/x64/convert.cpp+++ /dev/null@@ -1,180 +0,0 @@-// Copyright (C) 2022 Intel Corporation-// SPDX-License-Identifier: Apache-2.0-//--#include "snippets/convert.hpp"-#include "common_test_utils/test_constants.hpp"--namespace ov {-namespace test {-namespace snippets {---namespace {--const std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::element::Type>>> types_Convert = {- { { ov::element::f32 }, { ov::element::bf16 } },- { { ov::element::f32 }, { ov::element::u8 } },- { { ov::element::f32 }, { ov::element::i8 } },- { { ov::element::f32 }, { ov::element::f16 } },-- { { ov::element::f16 }, { ov::element::f32 } },- { { ov::element::f16 }, { ov::element::bf16 } },- { { ov::element::f16 }, { ov::element::i8 } },- { { ov::element::f16 }, { ov::element::u8 } },-- { { ov::element::bf16 }, { ov::element::f32 } },- { { ov::element::bf16 }, { ov::element::i8 } },- { { ov::element::bf16 }, { ov::element::u8 } },- { { ov::element::bf16 }, { ov::element::f16 } },-- { { ov::element::i8 }, { ov::element::f32 } },- { { ov::element::i8 }, { ov::element::bf16 } },- { { ov::element::i8 }, { ov::element::u8 } },- { { ov::element::i8 }, { ov::element::f16 } },-- { { ov::element::u8 }, { ov::element::f32 } },- { { ov::element::u8 }, { ov::element::bf16 } },- { { ov::element::u8 }, { ov::element::i8 } },- { { ov::element::u8 }, { ov::element::f16 } },-};--const std::vector<std::vector<ov::test::InputShape>> inputShapes_Convert = {- { {{}, {{2, 16}}} },- { {{}, {{5, 5}}} },- { {{}, {{2, 12, 1}}} },- // DS(dynamic shape)- { {{-1, -1}, {{2, 16}, {2, 8}, {2, 16}}} },- { {{{1, 5}, 5}, {{5, 5}, {1, 5}, {5, 5}}} },- { {{{1, 10}, {4, 12}, {1, 2}}, {{2, 12, 1}, {4, 4, 2}, {2, 12, 1}}} }-};--INSTANTIATE_TEST_SUITE_P(smoke_Snippets_Convert, Convert,- ::testing::Combine(- ::testing::ValuesIn(inputShapes_Convert),- ::testing::ValuesIn(types_Convert),- ::testing::Values(1),- ::testing::Values(1),- ::testing::Values(ov::test::utils::DEVICE_CPU)),- Convert::getTestCaseName);--const std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::element::Type>>> types_ConvertInput = {- { { ov::element::f32 }, { ov::element::bf16 } },-- { { ov::element::bf16 }, { ov::element::f32 } },-- { { ov::element::i8 }, { ov::element::f32 } },- { { ov::element::i8 }, { ov::element::bf16 } },- { { ov::element::i8 }, { ov::element::f16 } },-- { { ov::element::u8 }, { ov::element::f32 } },- { { ov::element::u8 }, { ov::element::bf16 } },- { { ov::element::u8 }, { ov::element::f16 } },-};--const std::vector<std::vector<ov::test::InputShape>> inputShapes_ConvertInput = {- { {{}, {{2, 16}}}, {{}, {{1, 16}}} },- { {{}, {{5, 18}}}, {{}, {{5, 1}}} },- { {{}, {{3, 1}}}, {{}, {{3, 21}}} },- // DS- { {{-1, -1}, {{2, 16}, {1, 16}, {2, 16}}}, {{-1, -1}, {{1, 16}, {2, 16}, {1, 16}}} },- { {{5, -1}, {{5, 18}, {5, 1}, {5, 18}}}, {{-1, 1}, {{5, 1}, {1, 1}, {5, 1}}} },- { {{{1, 4}, {1, 8}}, {{3, 1}, {4, 8}, {3, 1}}}, {{{1, 4}, {8, 21}}, {{3, 21}, {1, 8}, {3, 21}}} }-};--INSTANTIATE_TEST_SUITE_P(smoke_Snippets_ConvertInput, ConvertInput,- ::testing::Combine(- ::testing::ValuesIn(inputShapes_ConvertInput),- ::testing::ValuesIn(types_ConvertInput),- ::testing::Values(1),- ::testing::Values(1),- ::testing::Values(ov::test::utils::DEVICE_CPU)),- Convert::getTestCaseName);--INSTANTIATE_TEST_SUITE_P(smoke_Snippets_ConvertOutput, ConvertOutput,- ::testing::Combine(- ::testing::ValuesIn(inputShapes_ConvertInput),- ::testing::ValuesIn(types_ConvertInput),- ::testing::Values(1),- ::testing::Values(1),- ::testing::Values(ov::test::utils::DEVICE_CPU)),- Convert::getTestCaseName);--INSTANTIATE_TEST_SUITE_P(smoke_Snippets_ConvertStub, ConvertStub,- ::testing::Combine(- ::testing::ValuesIn(inputShapes_ConvertInput),- ::testing::ValuesIn(types_ConvertInput),- ::testing::Values(1),- ::testing::Values(1),- ::testing::Values(ov::test::utils::DEVICE_CPU)),- Convert::getTestCaseName);--const std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::element::Type>>> types_ConvertPartialInputsAndResults = {- { { ov::element::i8, ov::element::i8, ov::element::f32 }, { ov::element::f32, ov::element::i8 } },-};--const std::vector<std::vector<ov::test::InputShape>> inputShapes_ConvertPartialInputsAndResults = {- { {{}, {{2, 16}}}, {{}, {{1, 16}}}, {{}, {{1, 1}}} },- { {{}, {{5, 18}}}, {{}, {{5, 1}}}, {{}, {{1, 18}}} },- { {{}, {{3, 1}}}, {{}, {{3, 21}}}, {{}, {{3, 1}}} },- // DS- { {{-1, -1}, {{3, 1}, {2, 4}, {3, 1}}}, {{{1, 3}, -1}, {{3, 21}, {2, 1}, {3, 21}}}, {{{1, 3}, {1, 2}}, {{3, 1}, {1, 1}, {3, 1}}} },-};--INSTANTIATE_TEST_SUITE_P(smoke_Snippets_ConvertPartialInputsAndResults, ConvertPartialInputsAndResults,- ::testing::Combine(- ::testing::ValuesIn(inputShapes_ConvertPartialInputsAndResults),- ::testing::ValuesIn(types_ConvertPartialInputsAndResults),- ::testing::Values(2), // subgraph & roll after subgraph- ::testing::Values(1),- ::testing::Values(ov::test::utils::DEVICE_CPU)),- Convert::getTestCaseName);--const std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::element::Type>>> types_ConvertMany = {- { { ov::element::f32, ov::element::u8}, {} },- { { ov::element::f32, ov::element::u8, ov::element::i8 }, {} },- { { ov::element::f32, ov::element::f32, ov::element::i8, ov::element::i8 }, {} },-};--const std::vector<std::vector<ov::test::InputShape>> inputShapes_ConvertManyOnInputs = {- { {{}, {{5, 5, 5, 5}}} },- // DS- { {{-1, -1, -1, -1}, {{5, 5, 5, 5}, {3, 3, 3, 3}, {5, 5, 5, 5}}} }-};--INSTANTIATE_TEST_SUITE_P(smoke_Snippets_ConvertManyOnInputs, ConvertManyOnInputs,- ::testing::Combine(- ::testing::ValuesIn(inputShapes_ConvertManyOnInputs),- ::testing::ValuesIn(types_ConvertMany),- ::testing::Values(1),- ::testing::Values(1),- ::testing::Values(ov::test::utils::DEVICE_CPU)),- Convert::getTestCaseName);--INSTANTIATE_TEST_SUITE_P(smoke_Snippets_ConvertManyOnOutputs, ConvertManyOnOutputs,- ::testing::Combine(- ::testing::ValuesIn(inputShapes_ConvertManyOnInputs),- ::testing::ValuesIn(types_ConvertMany),- ::testing::Values(1),- ::testing::Values(1),- ::testing::Values(ov::test::utils::DEVICE_CPU)),- Convert::getTestCaseName);--const std::vector<std::pair<std::vector<ov::element::Type>, std::vector<ov::element::Type>>> types_ConvertManyIO = {- { { ov::element::f32, ov::element::u8}, {ov::element::i8} },- { { ov::element::f32, ov::element::u8, ov::element::i8 }, { ov::element::u8, ov::element::i8, ov::element::f32, ov::element::f32 } },-};--INSTANTIATE_TEST_SUITE_P(smoke_Snippets_ConvertManyOnInputOutput, ConvertManyOnInputOutput,- ::testing::Combine(- ::testing::ValuesIn(inputShapes_ConvertManyOnInputs),- ::testing::ValuesIn(types_ConvertManyIO),- ::testing::Values(1),- ::testing::Values(1),- ::testing::Values(ov::test::utils::DEVICE_CPU)),- Convert::getTestCaseName);--} // namespace-} // namespace snippets-} // namespace test-} // namespace ov\ No newline at end of file