Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[Snippets] Remove thread count parameter from MHA and MLP SEQ tests (#34309)

Arseniy Obolenskiy4773bdf3aa1a
diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha.cpp
index a19cc2f2ba9..5294740eb1d 100644
--- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha.cpp
+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha.cpp
@@ -96,7 +96,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MHA_4D,
::testing::ValuesIn(precision_f32(4)),
::testing::Values(ov::element::f32),
::testing::Values(false),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(expected_nodes_mha_4d_f32),
::testing::Values(2), // decomposed Transpose + MHA
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -111,7 +110,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MHA_4D_MatMul1_Const_B_Are_Wei_Blocked,
::testing::Values(false),
::testing::Values(false),
::testing::Values(true),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(expected_nodes_mha_4d_f32),
::testing::Values(2), // decomposed Transpose + MHA
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -124,7 +122,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MHA_4D_WithScalarMul,
::testing::ValuesIn(precision_f32(4)),
::testing::Values(ov::element::f32),
::testing::Values(true),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(expected_nodes_mha_4d_f32),
::testing::Values(2), // decomposed Transpose, Mul + MHA
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -137,7 +134,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MHA_3D,
::testing::ValuesIn(precision_f32(4)),
::testing::Values(ov::element::f32),
::testing::Values(false),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(5), // [122706]: Subgraph + 4 Transpose
::testing::Values(2), // decomposed Transpose + MHA
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -150,7 +146,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MHA_2D,
::testing::ValuesIn(precision_f32(4)),
::testing::Values(ov::element::f32),
::testing::Values(false),
- ::testing::Values(MHA2D::default_thread_count),
::testing::Values(1), // Subgraph
::testing::Values(1), // MHA
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -163,7 +158,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MHA_3D_WithScalarMul,
::testing::ValuesIn(precision_f32(4)),
::testing::Values(ov::element::f32),
::testing::Values(true),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(5), // [122706]: Subgraph + 4 Transpose
::testing::Values(2), // decomposed Transpose + MHA
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -176,7 +170,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MHABF16_4D,
::testing::ValuesIn(precision_bf16_if_supported(4)),
::testing::Values(ov::element::bf16),
::testing::Values(false),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(3), // decomposed Transpose + MHA + 1 Transpose on output
::testing::Values(2), // decomposed Transpose + MHA
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -190,7 +183,6 @@ INSTANTIATE_TEST_SUITE_P(
::testing::ValuesIn(precision_f32(4)),
::testing::Values(ov::element::bf16),
::testing::ValuesIn({false}),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(8), // decomposed Transpose + MHA + 5 Converts + 1 Transpose on output
::testing::Values(6), // MHA + 5 Reorders on inputs and output
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -203,7 +195,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MHAEnforceBF16_f32_in_prc,
::testing::ValuesIn(precision_f32(4)),
::testing::Values(ov::element::f32),
::testing::ValuesIn({false}),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(4), // decomposed Transpose + MHA + Reorder (bf16->fp32)
// + 1 Transpose on output
::testing::Values(2), // decomposed Transpose + MHA
@@ -217,7 +208,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MHA_FP16_4D_Without_Multiply,
::testing::ValuesIn(precision_fp16_if_supported(4)),
::testing::Values(ov::element::f16),
::testing::ValuesIn({false}),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(expected_nodes_mha_fp16_static),
::testing::Values(2),
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -229,7 +219,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MHA_FP16_4D_With_Multiply_Static,
::testing::ValuesIn(precision_fp16_if_supported(4)),
::testing::Values(ov::element::f16),
::testing::ValuesIn({true}),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(expected_nodes_mha_fp16_static),
::testing::Values(2),
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -242,7 +231,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MHA_FP16_4D_With_Multiply_Dynamic,
::testing::ValuesIn(precision_fp16_if_supported(4)),
::testing::Values(ov::element::f16),
::testing::ValuesIn({true}),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(expected_nodes_mha_fp16_dynamic),
::testing::Values(2),
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -255,7 +243,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MHAEnforceFP16_Without_Multiply,
::testing::ValuesIn(precision_f32(4)),
::testing::Values(ov::element::f16),
::testing::ValuesIn({false}),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(expected_nodes_mha_fp16_static),
::testing::Values(2),
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -267,7 +254,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MHAEnforceFP16_With_Multiply_Static,
::testing::ValuesIn(precision_f32(4)),
::testing::Values(ov::element::f16),
::testing::ValuesIn({true}),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(expected_nodes_mha_fp16_static),
::testing::Values(2),
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -279,7 +265,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MHAEnforceFP16_With_Multiply_Dynamic,
::testing::ValuesIn(precision_f32(4)),
::testing::Values(ov::element::f16),
::testing::ValuesIn({true}),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(expected_nodes_mha_fp16_dynamic),
::testing::Values(2),
::testing::Values(ov::test::utils::DEVICE_CPU),
diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_extracted_reshape.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_extracted_reshape.cpp
index 5dfaafab009..fd8f75e9b44 100644
--- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_extracted_reshape.cpp
+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_extracted_reshape.cpp
@@ -27,7 +27,6 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Values(std::vector<element::Type>{}),
::testing::Values(ov::element::f32),
::testing::ValuesIn({true}), // False is not supported for graph builder in tests
- ::testing::Values(MHA::default_thread_count),
::testing::Values(3), // Extracted Add + Extracted Reshape + MHA
::testing::Values(2), // Extracted Add + MHA
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -44,7 +43,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MHARankUpgradeToReductionReshape,
::testing::Values(std::vector<element::Type>{}),
::testing::Values(ov::element::f32),
::testing::Values(false),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(2), // MHA + reshape
::testing::Values(1), // MHA subgraph
::testing::Values(ov::test::utils::DEVICE_CPU),
diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_fma.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_fma.cpp
index 9b880e0cace..ee958fa71e3 100644
--- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_fma.cpp
+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_fma.cpp
@@ -22,7 +22,6 @@ INSTANTIATE_TEST_SUITE_P(
::testing::ValuesIn(precision_f32(3)),
::testing::Values(ov::element::f32),
::testing::ValuesIn({false}), // Need to support True for graph builder in tests
- ::testing::Values(MHA::default_thread_count),
::testing::Values(expected_nodes_mha_mul_add),
::testing::Values(2), // Subgraph with MHA + Subgraph with Transpose1
::testing::Values(ov::test::utils::DEVICE_CPU),
diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_quantized.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_quantized.cpp
index dfe48d4785d..049675da9cd 100644
--- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_quantized.cpp
+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_quantized.cpp
@@ -47,7 +47,6 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Values(std::vector<element::Type>{}),
::testing::Values(ov::element::f32),
::testing::Values(false), // The graph doesn't contain Multiply
- ::testing::Values(MHA::default_thread_count),
::testing::Values(7), // FQx3, Transpose1 on inputs + MHA + Transpose on output + Deq Mul
::testing::Values(5), // FQx3 on inputs + MHA + Deq Mul
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -62,7 +61,6 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Values(std::vector<element::Type>{}),
::testing::Values(ov::element::f32),
::testing::Values(false), // The graph doesn't contain Multiply
- ::testing::Values(MHA::default_thread_count),
::testing::Values(6), // FQx2, Transpose1 on inputs + MHA + Transpose on output + Deq Mul
::testing::Values(4), // FQx2 on inputs + MHA + Deq Mul
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -76,7 +74,6 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Values(std::vector<element::Type>{}),
::testing::Values(ov::element::f32),
::testing::Values(false), // The graph doesn't contain Multiply
- ::testing::Values(MHA::default_thread_count),
::testing::Values(4), // Transpose1 + MHA + Transpose on output + Deq Mul
::testing::Values(3), // Transpose1 + MHA + Deq Mul
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -90,7 +87,6 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Values(std::vector<element::Type>{}),
::testing::Values(ov::element::f32),
::testing::Values(false), // The graph doesn't contain Multiply
- ::testing::Values(MHA::default_thread_count),
::testing::Values(8), // Transposex3 + Subgraphsx5
::testing::Values(5), // MHA + Deq Mul on output + Deqs on inputs + 2 xFQ on inputs
::testing::Values(ov::test::utils::DEVICE_CPU),
diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_select.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_select.cpp
index 3057d761c0e..325efa0bf7e 100644
--- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_select.cpp
+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_select.cpp
@@ -30,7 +30,6 @@ INSTANTIATE_TEST_SUITE_P(
::testing::ValuesIn(precision_f32(6)),
::testing::Values(ov::element::f32),
::testing::Values(false), // Need to support True for graph builder in tests
- ::testing::Values(MHA::default_thread_count),
::testing::Values(expected_nodes_mha_select),
::testing::Values(3), // Transpose1 + Less + MHA
::testing::Values(ov::test::utils::DEVICE_CPU),
diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_split_dim_m.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_split_dim_m.cpp
index 23a888034af..f26644548cb 100644
--- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_split_dim_m.cpp
+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_split_dim_m.cpp
@@ -12,38 +12,40 @@ namespace snippets {
namespace {
-static ov::AnyMap enable_callback() {
- return ov::AnyMap({ov::intel_cpu::snippets_mode(ov::intel_cpu::SnippetsMode::ENABLE)});
+static ov::AnyMap enable_callback(size_t num_threads) {
+ return ov::AnyMap({ov::intel_cpu::snippets_mode(ov::intel_cpu::SnippetsMode::ENABLE),
+ ov::inference_num_threads(num_threads)});
+}
+
+static ov::AnyMap set_num_threads(size_t num_threads) {
+ return ov::AnyMap({ov::inference_num_threads(num_threads)});
}
INSTANTIATE_TEST_SUITE_P(
smoke_Snippets_MHA_4D_SplitDimensionM_static,
- MHA,
+ MHAWithThreadCount,
::testing::Combine(::testing::ValuesIn(SNIPPETS_TESTS_STATIC_SHAPES({{1, 128, 2, 64}, {1, 128, 2, 64}, {1, 1, 1, 1}, {1, 128, 2, 64}})),
::testing::ValuesIn(precision_f32(4)),
::testing::Values(ov::element::f32),
::testing::Values(true),
- ::testing::Values(4), // 4 Threads
::testing::Values(7), // Subgraph + 4 Reshapes, Transpose1 on inputs and 1 Reshape on output
::testing::Values(2),
::testing::Values(ov::test::utils::DEVICE_CPU),
- ::testing::Values(enable_callback())),
- MHA::getTestCaseName);
+ ::testing::Values(enable_callback(4))), // 4 Threads
+ MHAWithThreadCount::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(
smoke_Snippets_MHA_3D_SplitDimensionM_static,
- MHA,
- ::testing::Combine(
- ::testing::ValuesIn(SNIPPETS_TESTS_STATIC_SHAPES({{384, 2, 64}, {384, 2, 64}, {1, 384, 384}, {384, 2, 64}})),
- ::testing::ValuesIn(precision_f32(4)),
- ::testing::Values(ov::element::f32),
- ::testing::Values(true),
- ::testing::Values(4), // 4 Threads
- ::testing::Values(10), // Subgraph + 4 Reshapes on inputs and 1 Reshape on output + 4 Transposes
- ::testing::Values(1), // MHA
- ::testing::Values(ov::test::utils::DEVICE_CPU),
- ::testing::Values(enable_callback())),
- MHA::getTestCaseName);
+ MHAWithThreadCount,
+ ::testing::Combine(::testing::ValuesIn(SNIPPETS_TESTS_STATIC_SHAPES({{384, 2, 64}, {384, 2, 64}, {1, 384, 384}, {384, 2, 64}})),
+ ::testing::ValuesIn(precision_f32(4)),
+ ::testing::Values(ov::element::f32),
+ ::testing::Values(true),
+ ::testing::Values(10), // Subgraph + 4 Reshapes on inputs and 1 Reshape on output + 4 Transposes
+ ::testing::Values(1), // MHA
+ ::testing::Values(ov::test::utils::DEVICE_CPU),
+ ::testing::Values(enable_callback(4))), // 4 Threads
+ MHAWithThreadCount::getTestCaseName);
std::vector<std::vector<ov::test::InputShape>> splitm_dynamic_shapes_4d = {
{
@@ -76,17 +78,16 @@ static constexpr size_t expected_nodes_mha_splitm_4d_dyn = 2;
INSTANTIATE_TEST_SUITE_P(
smoke_Snippets_MHA_4D_SplitDimensionM_dynamic,
- MHA,
+ MHAWithThreadCount,
::testing::Combine(::testing::ValuesIn(splitm_dynamic_shapes_4d),
::testing::ValuesIn(precision_f32(4)),
::testing::Values(ov::element::f32),
::testing::Values(false),
- ::testing::Values(4), // 4 Threads
::testing::Values(expected_nodes_mha_splitm_4d_dyn),
- ::testing::Values(2), // Transpose1 + MHA
+ ::testing::Values(2), // Transpose1 + MHA
::testing::Values(ov::test::utils::DEVICE_CPU),
- ::testing::Values(CPUTestUtils::empty_plugin_config)),
- MHA::getTestCaseName);
+ ::testing::Values(set_num_threads(4))), // 4 Threads
+ MHAWithThreadCount::getTestCaseName);
std::vector<std::vector<ov::test::InputShape>> splitm_dynamic_shapes_3d = {
{
@@ -105,17 +106,16 @@ std::vector<std::vector<ov::test::InputShape>> splitm_dynamic_shapes_3d = {
INSTANTIATE_TEST_SUITE_P(
smoke_Snippets_MHA_3D_SplitDimensionM_dynamic,
- MHA,
+ MHAWithThreadCount,
::testing::Combine(::testing::ValuesIn(splitm_dynamic_shapes_3d),
::testing::ValuesIn(precision_f32(4)),
::testing::Values(ov::element::f32),
::testing::Values(false),
- ::testing::Values(4), // 4 Threads
::testing::Values(5), // Subgraph + 4 Transpose
::testing::Values(2), // MHA + one of the transposes is executed via Subgraph (because callback is disabled)
::testing::Values(ov::test::utils::DEVICE_CPU),
- ::testing::Values(CPUTestUtils::empty_plugin_config)),
- MHA::getTestCaseName);
+ ::testing::Values(set_num_threads(4))), // 4 Threads
+ MHAWithThreadCount::getTestCaseName);
} // namespace
} // namespace snippets
diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_transposed_b.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_transposed_b.cpp
index ab2b81dd3d6..8cc3c015868 100644
--- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_transposed_b.cpp
+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_transposed_b.cpp
@@ -43,7 +43,6 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Values(std::vector<element::Type>{}),
::testing::Values(ov::element::f32),
::testing::ValuesIn({true}), // Need to support False for graph builder in tests
- ::testing::Values(MHA::default_thread_count),
::testing::Values(expected_num_nodes),
::testing::Values(1),
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -61,7 +60,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MHA_SharedKV,
::testing::ValuesIn(precision_f32(2)),
::testing::Values(ov::element::f32),
::testing::Values(false),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(expected_num_nodes),
::testing::Values(1),
::testing::Values(ov::test::utils::DEVICE_CPU),
diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_with_dyn_mul.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_with_dyn_mul.cpp
index 00814071c13..c3189147168 100644
--- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_with_dyn_mul.cpp
+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_with_dyn_mul.cpp
@@ -44,7 +44,6 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Combine(::testing::ValuesIn(transposedShape_4D_WithMul),
::testing::ValuesIn(precision_f32(5)),
::testing::Values(ov::element::f32),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(expected_nodes_mha_with_dyn_mul),
::testing::Values(2), // Transpose1 + MHA
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -57,7 +56,6 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Combine(::testing::ValuesIn(transposedShape_4D_WithMul),
::testing::ValuesIn(precision_f32(5)),
::testing::Values(ov::element::bf16),
- ::testing::Values(MHA::default_thread_count),
::testing::Values(9), // Transpose1 + MHA + 1 Transpose on output + 6 Converts around
::testing::Values(7), // MHA + 6 Converts around
::testing::Values(ov::test::utils::DEVICE_CPU),
diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_wo_transpose.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_wo_transpose.cpp
index f94fc5f3f12..a9d1356ea62 100644
--- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_wo_transpose.cpp
+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mha_wo_transpose.cpp
@@ -59,7 +59,6 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Values(std::vector<ov::element::Type>{}),
::testing::Values(ov::element::f32),
::testing::Values(true), // Need to support False for graph builder in tests
- ::testing::Values(MHA::default_thread_count),
::testing::Values(1),
::testing::Values(1),
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -73,7 +72,6 @@ INSTANTIATE_TEST_SUITE_P(
::testing::ValuesIn(precision_f32(3)),
::testing::Values(ov::element::f32),
::testing::Values(true), // Need to support False for graph builder in tests
- ::testing::Values(MHA::default_thread_count),
::testing::Values(1),
::testing::Values(1),
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -87,7 +85,6 @@ INSTANTIATE_TEST_SUITE_P(
::testing::ValuesIn(precision_bf16_if_supported(3)),
::testing::Values(ov::element::f32),
::testing::Values(true), // Need to support False for graph builder in tests
- ::testing::Values(MHA::default_thread_count),
::testing::Values(5), // MHA + 4 extra Converts on inputs and output
::testing::Values(5), // MHA + 4 extra Converts on inputs and output
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -102,7 +99,6 @@ INSTANTIATE_TEST_SUITE_P(
::testing::ValuesIn(precision_f32(3)),
::testing::Values(ov::element::bf16),
::testing::Values(true), // Need to support False for graph builder in tests
- ::testing::Values(MHA::default_thread_count),
::testing::Values(5), // MHA + 4 extra Converts on inputs and output
::testing::Values(5), // MHA + 4 extra Converts on inputs and output
::testing::Values(ov::test::utils::DEVICE_CPU),
@@ -117,7 +113,6 @@ INSTANTIATE_TEST_SUITE_P(
::testing::ValuesIn(precision_f32(3)),
::testing::Values(ov::element::f16),
::testing::Values(true), // Need to support False for graph builder in tests
- ::testing::Values(MHA::default_thread_count),
::testing::Values(1),
::testing::Values(1),
::testing::Values(ov::test::utils::DEVICE_CPU),
diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mlp_seq.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mlp_seq.cpp
index 829e10fc039..109a6166289 100644
--- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mlp_seq.cpp
+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/mlp_seq.cpp
@@ -74,7 +74,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MLP_SEQ_2D_f32,
::testing::Combine(::testing::ValuesIn(inputShape_2D()),
::testing::ValuesIn(precision_f32(1)),
::testing::Values(ov::element::f32),
- ::testing::Values(MLPSeq::default_thread_count),
::testing::Values(ov::test::utils::DEVICE_CPU),
::testing::Values(CPUTestUtils::empty_plugin_config),
::testing::ValuesIn(numHiddenLayersWithExpectations()),
@@ -86,7 +85,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MLP_SEQ_2D_f32_prc_bf16,
::testing::Combine(::testing::ValuesIn(inputShape_2D()),
::testing::ValuesIn(precision_f32(1)),
::testing::Values(ov::element::bf16),
- ::testing::Values(MLPSeq::default_thread_count),
::testing::Values(ov::test::utils::DEVICE_CPU),
::testing::Values(CPUTestUtils::empty_plugin_config),
::testing::ValuesIn(numHiddenLayersWithExpectationsBf16()),
@@ -98,7 +96,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MLP_SEQ_Quantized_2D_f32,
::testing::Combine(::testing::ValuesIn(inputShape_2D()),
::testing::ValuesIn(precision_f32(1)),
::testing::Values(ov::element::f32),
- ::testing::Values(MLPSeqQuantized::default_thread_count),
::testing::Values(ov::test::utils::DEVICE_CPU),
::testing::Values(CPUTestUtils::empty_plugin_config),
::testing::ValuesIn(numHiddenLayersWithExpectationsQuantized()),
diff --git a/src/tests/functional/plugin/shared/include/snippets/mha.hpp b/src/tests/functional/plugin/shared/include/snippets/mha.hpp
index d8cb49d16fc..af485329041 100644
--- a/src/tests/functional/plugin/shared/include/snippets/mha.hpp
+++ b/src/tests/functional/plugin/shared/include/snippets/mha.hpp
@@ -15,7 +15,6 @@ typedef std::tuple<std::vector<InputShape>, // Input shapes
std::vector<ov::element::Type>, // Input Element types
ov::element::Type, // Inference precision
bool, // With Multiply
- size_t, // Thread count
size_t, // Expected num nodes
size_t, // Expected num subgraphs
std::string, // Target Device
@@ -29,7 +28,6 @@ typedef std::tuple<std::vector<InputShape>, // Input shapes
bool, // With Multiply
bool, // MatMul0 with const B
bool, // MatMul1 with const B
- size_t, // Thread count
size_t, // Expected num nodes
size_t, // Expected num subgraphs
std::string, // Target Device
@@ -40,55 +38,44 @@ typedef std::tuple<std::vector<InputShape>, // Input shapes
typedef std::tuple<std::vector<InputShape>, // Input shapes
std::vector<ov::element::Type>, // Input Element types
ov::element::Type, // Inference precision
- size_t, // Thread count
size_t, // Expected num nodes
size_t, // Expected num subgraphs
std::string, // Target Device
ov::AnyMap // Config
>
- MHAWithDynamicMulParams;
-
-class MHABase : virtual public SnippetsTestsCommon {
-public:
- constexpr static size_t default_thread_count = 0;
+MHAWithDynamicMulParams;
+class MHABase : virtual public SnippetsTestsCommon {
protected:
void SetUp() override;
- void compile_model() override;
void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override;
void init_thresholds() override;
virtual std::shared_ptr<SnippetsFunctionBase> get_subgraph() const = 0;
- virtual void init_params(std::vector<InputShape>& input_shapes,
- ov::element::Type& prc,
- ov::AnyMap& additional_config) = 0;
+ virtual void init_params(std::vector<InputShape>& input_shapes, ov::element::Type& prc, ov::AnyMap& additional_config) = 0;
- size_t m_thread_count;
std::vector<ov::element::Type> m_input_types;
};
-class MHA : public testing::WithParamInterface<ov::test::snippets::MHAParams>, virtual public MHABase {
+class MHA : public testing::WithParamInterface<ov::test::snippets::MHAParams>,
+ virtual public MHABase {
public:
static std::string getTestCaseName(const testing::TestParamInfo<ov::test::snippets::MHAParams>& obj);
protected:
std::shared_ptr<SnippetsFunctionBase> get_subgraph() const override;
- void init_params(std::vector<InputShape>& input_shapes,
- ov::element::Type& prc,
- ov::AnyMap& additional_config) override;
- void init_thresholds() override;
+ void init_params(std::vector<InputShape>& input_shapes, ov::element::Type& prc, ov::AnyMap& additional_config) override;
- bool m_with_mul = false;
+ void init_thresholds() override;
};
-class MHAConstB : public testing::WithParamInterface<ov::test::snippets::MHAConstBParams>, virtual public MHABase {
+class MHAConstB : public testing::WithParamInterface<ov::test::snippets::MHAConstBParams>,
+ virtual public MHABase {
public:
static std::string getTestCaseName(const testing::TestParamInfo<ov::test::snippets::MHAConstBParams>& obj);
protected:
std::shared_ptr<SnippetsFunctionBase> get_subgraph() const override;
- void init_params(std::vector<InputShape>& input_shapes,
- ov::element::Type& prc,
- ov::AnyMap& additional_config) override;
+ void init_params(std::vector<InputShape>& input_shapes, ov::element::Type& prc, ov::AnyMap& additional_config) override;
void init_thresholds() override;
bool m_with_mul = false;
@@ -164,9 +151,16 @@ public:
protected:
std::shared_ptr<SnippetsFunctionBase> get_subgraph() const override;
- void init_params(std::vector<InputShape>& input_shapes,
- ov::element::Type& prc,
- ov::AnyMap& additional_config) override;
+ void init_params(std::vector<InputShape>& input_shapes, ov::element::Type& prc, ov::AnyMap& additional_config) override;
+};
+
+class MHAWithThreadCount : public MHA {
+public:
+ constexpr static size_t default_thread_count = 0;
+ static std::string getTestCaseName(const testing::TestParamInfo<ov::test::snippets::MHAParams>& obj);
+
+protected:
+ void compile_model() override;
};
class MHASharedKV : public MHA {
diff --git a/src/tests/functional/plugin/shared/include/snippets/mlp_seq.hpp b/src/tests/functional/plugin/shared/include/snippets/mlp_seq.hpp
index b2eb66e19c0..c4da1a53b66 100644
--- a/src/tests/functional/plugin/shared/include/snippets/mlp_seq.hpp
+++ b/src/tests/functional/plugin/shared/include/snippets/mlp_seq.hpp
@@ -14,7 +14,6 @@ namespace snippets {
typedef std::tuple<std::vector<InputShape>, // Input shapes
std::vector<ov::element::Type>, // Input Element types
ov::element::Type, // Inference precision
- size_t, // Thread count
std::string, // Target Device
ov::AnyMap, // Config
std::pair<size_t, std::pair<size_t, size_t>>, // {number of hidden layers, {expected number of
@@ -24,16 +23,11 @@ typedef std::tuple<std::vector<InputShape>, // Input shape
MLPSeqParams;
class MLPSeqBase : virtual public SnippetsTestsCommon {
-public:
- constexpr static size_t default_thread_count = 0;
-
protected:
void SetUp() override;
- void compile_model() override;
virtual std::shared_ptr<SnippetsFunctionBase> get_subgraph(size_t num_hidden_layers, size_t hidden_matmul_size) const = 0;
virtual void init_params(std::vector<InputShape>& input_shapes, ov::element::Type& prc, ov::AnyMap& additional_config) = 0;
- size_t m_thread_count;
std::vector<ov::element::Type> m_input_types;
size_t m_num_hidden_layers, m_hidden_matmul_size;
};
diff --git a/src/tests/functional/plugin/shared/src/snippets/mha.cpp b/src/tests/functional/plugin/shared/src/snippets/mha.cpp
index 70e6941d9c5..2bfd330bfe4 100644
--- a/src/tests/functional/plugin/shared/src/snippets/mha.cpp
+++ b/src/tests/functional/plugin/shared/src/snippets/mha.cpp
@@ -14,11 +14,19 @@ namespace ov {
namespace test {
namespace snippets {
-void MHABase::compile_model() {
- if (m_thread_count != default_thread_count)
- core->set_property(targetDevice, ov::inference_num_threads(m_thread_count));
- SubgraphBaseTest::compile_model();
+namespace {
+size_t get_inference_thread_count(const ov::AnyMap& config, size_t default_value = 0) {
+ const auto thread_count = config.find(ov::inference_num_threads.name());
+ if (thread_count == config.end())
+ return default_value;
+
+ try {
+ return thread_count->second.as<size_t>();
+ } catch (const ov::Exception&) {
+ return default_value;
+ }
}
+} // namespace
void MHABase::generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) {
inputs.clear();
@@ -35,9 +43,8 @@ void MHABase::generate_inputs(const std::vector<ov::Shape>& targetInputStaticSha
in_data.start_from = bf16_precision ? 0 : -1;
in_data.range = 2;
in_data.resolution = 256;
- tensor = ov::test::utils::create_and_fill_tensor(model_input.get_element_type(),
- targetInputStaticShapes[i],
- in_data);
+ tensor =
+ ov::test::utils::create_and_fill_tensor(model_input.get_element_type(), targetInputStaticShapes[i], in_data);
inputs.insert({model_input.get_node_shared_ptr(), tensor});
}
}
@@ -76,7 +83,6 @@ std::string MHA::getTestCaseName(const testing::TestParamInfo<ov::test::snippets
elem_types,
prc,
with_mul,
- thread_count,
num_nodes,
num_subgraphs,
target_device,
@@ -88,7 +94,6 @@ std::string MHA::getTestCaseName(const testing::TestParamInfo<ov::test::snippets
for (size_t i = 0; i < elem_types.size(); i++)
result << "T[" << i << "]=" << elem_types[i] << "_";
result << "Mul=" << with_mul << "_";
- result << "ThreadNum=" << thread_count << "_";
result << "PRC=" << prc << "_";
result << "#N=" << num_nodes << "_";
result << "#S=" << num_subgraphs << "_";
@@ -110,7 +115,6 @@ std::string MHAConstB::getTestCaseName(const testing::TestParamInfo<ov::test::sn
with_mul,
const_b_matmul0,
const_b_matmul1,
- thread_count,
num_nodes,
num_subgraphs,
target_device,
@@ -124,7 +128,6 @@ std::string MHAConstB::getTestCaseName(const testing::TestParamInfo<ov::test::sn
result << "Mul=" << with_mul << "_";
result << "ConstBMatMul0=" << const_b_matmul0 << "_";
result << "ConstBMatMul1=" << const_b_matmul1 << "_";
- result << "ThreadNum=" << thread_count << "_";
result << "PRC=" << prc << "_";
result << "#N=" << num_nodes << "_";
result << "#S=" << num_subgraphs << "_";
@@ -139,12 +142,10 @@ std::string MHAConstB::getTestCaseName(const testing::TestParamInfo<ov::test::sn
return result.str();
}
-std::string MHAWithDynamicMul::getTestCaseName(
- const testing::TestParamInfo<ov::test::snippets::MHAWithDynamicMulParams>& obj) {
+std::string MHAWithDynamicMul::getTestCaseName(const testing::TestParamInfo<ov::test::snippets::MHAWithDynamicMulParams>& obj) {
const auto& [input_shapes,
elem_types,
prc,
- thread_count,
num_nodes,
num_subgraphs,
target_device,
@@ -155,7 +156,6 @@ std::string MHAWithDynamicMul::getTestCaseName(
result << "IS[" << i << "]=" << input_shapes[i] << "_";
for (size_t i = 0; i < elem_types.size(); i++)
result << "T[" << i << "]=" << elem_types[i] << "_";
- result << "ThreadNum=" << thread_count << "_";
result << "PRC=" << prc << "_";
result << "#N=" << num_nodes << "_";
result << "#S=" << num_subgraphs << "_";
@@ -170,63 +170,56 @@ std::string MHAWithDynamicMul::getTestCaseName(
return result.str();
}
+std::string MHAWithThreadCount::getTestCaseName(const testing::TestParamInfo<ov::test::snippets::MHAParams>& obj) {
+ auto params_without_thread_count = obj.param;
+ auto& additional_config = std::get<7>(params_without_thread_count);
+ const auto thread_count = get_inference_thread_count(additional_config, MHAWithThreadCount::default_thread_count);
+ additional_config.erase(ov::inference_num_threads.name());
+
+ const testing::TestParamInfo<ov::test::snippets::MHAParams> test_info{params_without_thread_count, obj.index};
+ return MHA::getTestCaseName(test_info) + "_ThreadNum=" + std::to_string(thread_count);
+}
+
void MHA::init_params(std::vector<InputShape>& input_shapes, ov::element::Type& prc, ov::AnyMap& additional_config) {
- std::tie(input_shapes,
- m_input_types,
- prc,
- m_with_mul,
- m_thread_count,
- ref_num_nodes,
- ref_num_subgraphs,
- targetDevice,
- additional_config) = this->GetParam();
+ std::tie(input_shapes, m_input_types, prc, std::ignore, ref_num_nodes, ref_num_subgraphs, targetDevice, additional_config) =
+ this->GetParam();
+}
+
+void MHAWithDynamicMul::init_params(std::vector<InputShape>& input_shapes, ov::element::Type& prc, ov::AnyMap& additional_config) {
+ std::tie(input_shapes, m_input_types, prc, ref_num_nodes, ref_num_subgraphs, targetDevice, additional_config) = this->GetParam();
}
-void MHAConstB::init_params(std::vector<InputShape>& input_shapes,
- ov::element::Type& prc,
- ov::AnyMap& additional_config) {
+void MHAConstB::init_params(std::vector<InputShape>& input_shapes, ov::element::Type& prc, ov::AnyMap& additional_config) {
std::tie(input_shapes,
m_input_types,
prc,
m_with_mul,
m_const_b_matmul0,
m_const_b_matmul1,
- m_thread_count,
ref_num_nodes,
ref_num_subgraphs,
targetDevice,
additional_config) = this->GetParam();
}
-void MHAWithDynamicMul::init_params(std::vector<InputShape>& input_shapes,
- ov::element::Type& prc,
- ov::AnyMap& additional_config) {
- std::tie(input_shapes,
- m_input_types,
- prc,
- m_thread_count,
- ref_num_nodes,
- ref_num_subgraphs,
- targetDevice,
- additional_config) = this->GetParam();
+void MHAWithThreadCount::compile_model() {
+ const auto thread_count = get_inference_thread_count(configuration, default_thread_count);
+ if (thread_count != default_thread_count)
+ core->set_property(targetDevice, ov::inference_num_threads(thread_count));
+ configuration.erase(ov::inference_num_threads.name());
+ SubgraphBaseTest::compile_model();
}
std::shared_ptr<SnippetsFunctionBase> MHA::get_subgraph() const {
- bool is_with_reshape =
- std::all_of(inputDynamicShapes.begin(), inputDynamicShapes.end(), [](const PartialShape& ps) {
- return ps.is_static();
- });
- return std::make_shared<ov::test::snippets::MHAFunction>(inputDynamicShapes,
- m_input_types,
- m_with_mul,
- is_with_reshape);
+ const auto with_mul = std::get<3>(this->GetParam());
+ const bool is_with_reshape =
+ std::all_of(inputDynamicShapes.begin(), inputDynamicShapes.end(), [](const ov::PartialShape& ps) { return ps.is_static(); });
+ return std::make_shared<ov::test::snippets::MHAFunction>(inputDynamicShapes, m_input_types, with_mul, is_with_reshape);
}
std::shared_ptr<SnippetsFunctionBase> MHAConstB::get_subgraph() const {
const bool is_with_reshape =
- std::all_of(inputDynamicShapes.begin(), inputDynamicShapes.end(), [](const PartialShape& ps) {
- return ps.is_static();
- });
+ std::all_of(inputDynamicShapes.begin(), inputDynamicShapes.end(), [](const PartialShape& ps) { return ps.is_static(); });
return std::make_shared<ov::test::snippets::MHAConstBFunction>(inputDynamicShapes,
m_input_types,
m_with_mul,
@@ -235,10 +228,6 @@ std::shared_ptr<SnippetsFunctionBase> MHAConstB::get_subgraph() const {
m_const_b_matmul1);
}
-std::shared_ptr<SnippetsFunctionBase> MHA2D::get_subgraph() const {
- return std::make_shared<ov::test::snippets::MHA2DFunction>(inputDynamicShapes, m_input_types);
-}
-
void MHA::init_thresholds() {
MHABase::init_thresholds();
auto precision_hint = configuration.count(ov::hint::inference_precision.name())
@@ -261,6 +250,10 @@ void MHAConstB::init_thresholds() {
}
}
+std::shared_ptr<SnippetsFunctionBase> MHA2D::get_subgraph() const {
+ return std::make_shared<ov::test::snippets::MHA2DFunction>(inputDynamicShapes, m_input_types);
+}
+
void MHASelect::generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) {
inputs.clear();
auto model_inputs = function->inputs();
@@ -366,6 +359,12 @@ TEST_P(MHAConstB, CompareWithRefImpl) {
validateNumSubgraphs();
}
+TEST_P(MHAWithThreadCount, CompareWithRefImpl) {
+ SKIP_IF_CURRENT_TEST_IS_DISABLED()
+ run();
+ validateNumSubgraphs();
+}
+
TEST_P(MHA2D, CompareWithRefImpl) {
SKIP_IF_CURRENT_TEST_IS_DISABLED()
run();
diff --git a/src/tests/functional/plugin/shared/src/snippets/mlp_seq.cpp b/src/tests/functional/plugin/shared/src/snippets/mlp_seq.cpp
index d9778e8cc54..fef534d0248 100644
--- a/src/tests/functional/plugin/shared/src/snippets/mlp_seq.cpp
+++ b/src/tests/functional/plugin/shared/src/snippets/mlp_seq.cpp
@@ -14,12 +14,6 @@ namespace ov {
namespace test {
namespace snippets {
-void MLPSeqBase::compile_model() {
- if (m_thread_count != default_thread_count)
- core->set_property(targetDevice, ov::inference_num_threads(m_thread_count));
- SubgraphBaseTest::compile_model();
-}
-
void MLPSeqBase::SetUp() {
std::vector<InputShape> input_shapes;
ov::element::Type prc;
@@ -41,7 +35,6 @@ std::string MLPSeq::getTestCaseName(const testing::TestParamInfo<ov::test::snipp
const auto& [input_shapes,
elem_types,
prc,
- thread_count,
target_device,
additional_config,
num_hidden_layers_with_expectations,
@@ -55,7 +48,6 @@ std::string MLPSeq::getTestCaseName(const testing::TestParamInfo<ov::test::snipp
result << "IS[" << i << "]=" << input_shapes[i] << "_";
for (size_t i = 0; i < elem_types.size(); i++)
result << "T[" << i << "]=" << elem_types[i] << "_";
- result << "ThreadNum=" << thread_count << "_";
result << "PRC=" << prc << "_";
result << "#N=" << num_nodes << "_";
result << "#S=" << num_subgraphs << "_";
@@ -76,7 +68,6 @@ void MLPSeq::init_params(std::vector<InputShape>& input_shapes, ov::element::Typ
const auto& [_input_shapes,
_m_input_types,
_prc,
- _m_thread_count,
_targetDevice,
_additional_config,
num_hidden_layers_with_expectations,
@@ -84,7 +75,6 @@ void MLPSeq::init_params(std::vector<InputShape>& input_shapes, ov::element::Typ
input_shapes = _input_shapes;
m_input_types = _m_input_types;
prc = _prc;
- m_thread_count = _m_thread_count;
targetDevice = _targetDevice;
additional_config = _additional_config;
m_hidden_matmul_size = _m_hidden_matmul_size;