Skip to content

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

[Snippets][CPU][RV64] Fuse transpose with MatMul (#38581)

Arseniy Obolenskiy0a3cef6638eb
diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
index 7ae7d707852..621429ec839 100644
--- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
+++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
@@ -1269,12 +1269,9 @@ void Transformations::MainSnippets() {
concurrency = parallel_get_max_threads();
}
CommonOptimizations::Config common_optimizations_config(concurrency);
-#if defined(OPENVINO_ARCH_X86_64) || defined(OPENVINO_ARCH_ARM64)
+#if defined(OPENVINO_ARCH_X86_64) || defined(OPENVINO_ARCH_ARM64) || defined(OPENVINO_ARCH_RISCV64)
common_optimizations_config.set_transpose_support_callback(
ov::snippets::utils::make_transpose_support_callback(true));
-#elif defined(OPENVINO_ARCH_RISCV64)
- common_optimizations_config.set_transpose_support_callback(
- ov::snippets::utils::make_transpose_support_callback(false));
#else
common_optimizations_config.set_transpose_support_callback([](const std::shared_ptr<const ov::Node>&) -> bool {
return false;
diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp
index 8134e38851d..ea57abf4860 100644
--- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp
+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp
@@ -483,9 +483,8 @@ const std::vector<std::regex>& disabled_test_patterns() {
std::regex(R"(.*proposal_params/.*)"),
// Quantized models unsupported
std::regex(R"(.*Quantized.*)"),
- std::regex(R"(.*smoke_Snippets_MatMult.*)"),
std::regex(R"(.*smoke_Snippets_ExplicitTransposeMatMul.*)"),
- std::regex(R"(.*smoke_Snippets_Dyn.*Mat.*)"),
+ std::regex(R"(.*smoke_Snippets_Dyn(?!MatMult).*Mat.*)"),
std::regex(R"(.*smoke_Snippets_FullyConnected.*)"),
std::regex(R"(.*smoke_Snippets_MHA(INT8|Quant|FQ).*)"),
std::regex(R"(.*smoke_Snippets_MLP.*)"),
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 8116cd7c19b..68ac4d1dc4b 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
@@ -101,15 +101,9 @@ std::vector<std::vector<InputShape>> transposedShape_2D(bool with_dynamic = true
return shapes;
}
-#if defined(OPENVINO_ARCH_RISCV64)
-static constexpr size_t expected_nodes_mha_4d_f32 = 4; // 2 Subgraphs + 2 Reorders
-static constexpr size_t expected_nodes_mha_4d_const_b = 3; // 2 Subgraphs + 1 Reorder
-static constexpr size_t expected_nodes_mha_4d_two_const_b = 6; // 4 Subgraphs + 2 Reorders
-#else
static constexpr size_t expected_nodes_mha_4d_f32 = 2;
static constexpr size_t expected_nodes_mha_4d_const_b = expected_nodes_mha_4d_f32;
static constexpr size_t expected_nodes_mha_4d_two_const_b = 4;
-#endif
static constexpr size_t expected_nodes_mha_fp16_static = 3;
static constexpr size_t expected_nodes_mha_fp16_dynamic = 4;
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 5beb2f44fcd..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
@@ -12,11 +12,7 @@ namespace snippets {
namespace {
-#if defined(OPENVINO_ARCH_RISCV64)
-static constexpr size_t expected_nodes_mha_mul_add = 4;
-#else
static constexpr size_t expected_nodes_mha_mul_add = 2;
-#endif
INSTANTIATE_TEST_SUITE_P(
smoke_Snippets_MHAMulAdd,
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 9b85392f9f4..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
@@ -21,11 +21,7 @@ const auto& inputShapeSelect = SNIPPETS_TESTS_STATIC_SHAPES(
{{2, 52, 6, 102}, {2, 52, 6, 102}, {1, 6, 52, 52}, {1, 6, 1, 1}, {1, 6, 1, 1}, {2, 52, 6, 102}}
);
-#if defined(OPENVINO_ARCH_RISCV64)
-static constexpr size_t expected_nodes_mha_select = 5;
-#else
static constexpr size_t expected_nodes_mha_select = 3;
-#endif
INSTANTIATE_TEST_SUITE_P(
smoke_Snippets_MHA,
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 c379066c174..77da1cac706 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
@@ -48,11 +48,7 @@ std::vector<std::vector<ov::test::InputShape>> splitm_shapes_4d = {
},
};
-#if defined(OPENVINO_ARCH_RISCV64)
-static constexpr size_t expected_nodes_mha_splitm_4d_dyn = 4;
-#else
static constexpr size_t expected_nodes_mha_splitm_4d_dyn = 2;
-#endif
INSTANTIATE_TEST_SUITE_P(
smoke_Snippets_MHA_4D_MHAParallelWAOptimizer,
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 126037c84b4..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
@@ -36,11 +36,7 @@ std::vector<std::vector<ov::test::InputShape>> transposedShape_4D_WithMul {
}
};
-#if defined(OPENVINO_ARCH_RISCV64)
-static constexpr size_t expected_nodes_mha_with_dyn_mul = 4;
-#else
static constexpr size_t expected_nodes_mha_with_dyn_mul = 2;
-#endif
INSTANTIATE_TEST_SUITE_P(
smoke_Snippets_MHA_4D_WithDynamicMul,