Skip to content

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

[Snippets][CPU] Enable Matmul with transposed B matrix tests (#31706)

Arseniy Obolenskiy73d64a87ec1a
diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
index 277c3cffa52..ba084f242a1 100644
--- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
+++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
@@ -277,6 +277,10 @@
# include "openvino/op/softmax.hpp"
#endif
+#if !defined(OPENVINO_ARCH_X86_64) && !defined(OPENVINO_ARCH_ARM64)
+# include "openvino/core/except.hpp"
+#endif
+
#if defined(OPENVINO_ARCH_ARM64)
# include "transformations/op_conversions/hard_sigmoid_decomposition.hpp"
# include "transformations/op_conversions/hsigmoid_decomposition.hpp"
@@ -1511,7 +1515,7 @@ void Transformations::MainSnippets() {
},
snippets::pass::TokenizeSnippets);
- auto mm_supports_transpose_b = [this]([[maybe_unused]] const std::shared_ptr<const ov::Node>& n) {
+ auto mm_supports_transpose_b = [this]([[maybe_unused]] const std::shared_ptr<const ov::Node>& n) -> bool {
[[maybe_unused]] const auto& inferencePrecision = config.inferencePrecision;
// Note: BrgemmTPP doesn't support transposed KN natively
// so we should extract transposes for the corresponding matmul nodes
@@ -1541,12 +1545,20 @@ void Transformations::MainSnippets() {
return !ov::intel_cpu::tpp::pass::BrgemmToBrgemmTPP::is_supported_brgemm_configuration(layouts, precisions);
}
#endif
+#if defined(OPENVINO_ARCH_ARM64)
+ // KleidiAI matmul primitives do not support transposed B input
+ return false;
+#elif defined(OPENVINO_ARCH_X86_64)
return true;
+#else
+ OPENVINO_THROW("ExplicitTransposeMatMulInputs callback is not supported on this architecture");
+ return false;
+#endif
};
CPU_SET_CALLBACK_COMMON(
snippetsManager,
- [&mm_supports_transpose_b](const std::shared_ptr<const ov::Node>& n) {
+ [&mm_supports_transpose_b](const std::shared_ptr<const ov::Node>& n) -> bool {
return mm_supports_transpose_b(n);
},
snippets::pass::ExplicitTransposeMatMulInputs);
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 320aa590e55..4c5481ea964 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
@@ -511,12 +511,10 @@ std::vector<std::string> disabledTestPatterns() {
#if defined(OPENVINO_ARCH_ARM64)
// Tests to be enabled on ARM64
retVector.emplace_back(R"(smoke_Snippets_ConvAdd/ConvEltwise.CompareWithRefImpl.*)");
- retVector.emplace_back(R"(smoke_Snippets_FullyConnectedTransposeB/MatMulTransposeB.*)");
retVector.emplace_back(R"(smoke_Snippets_GatedMLP.*)");
retVector.emplace_back(R"(smoke_Snippets_GroupNormalization.*)");
retVector.emplace_back(R"(smoke_Snippets_MHA.*)");
retVector.emplace_back(R"(smoke_Snippets_MLP_SEQ.*)");
- retVector.emplace_back(R"(smoke_Snippets_MatMulTransposeB.*)");
retVector.emplace_back(R"(smoke_Snippets_PrecisionPropagation_Convertion.*)");
#endif
#if defined(_WIN32)
diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/matmul.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/matmul.cpp
index c9d8ada7544..14a88f680bc 100644
--- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/matmul.cpp
+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/matmul.cpp
@@ -106,12 +106,18 @@ std::vector<std::vector<ov::test::InputShape>> transpose_b_shapes{
}
};
+#ifdef OPENVINO_ARCH_ARM64
+static constexpr size_t expected_num_subgraphs = 2; // MatMul + Transpose
+#else
+static constexpr size_t expected_num_subgraphs = 1; // MatMul
+#endif
+
INSTANTIATE_TEST_SUITE_P(smoke_Snippets_MatMulTransposeB, MatMulTransposeB,
::testing::Combine(
::testing::ValuesIn(transpose_b_shapes),
::testing::ValuesIn(precisions()),
::testing::Values(MatMulType::MatMul),
- ::testing::Values(1), // MatMul
+ ::testing::Values(expected_num_subgraphs),
::testing::Values(1), // Tokenized MatMul
::testing::Values(ov::test::utils::DEVICE_CPU),
::testing::Values(CPUTestUtils::empty_plugin_config)),