Skip to content

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

[Snippets][CPU][RV64] Enable quantized MHA tests (#39381)

Arseniy Obolenskiy3214bbd4ed56
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 37212562f82..bc3418a7b0f 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
@@ -481,11 +481,8 @@ const std::vector<std::regex>& disabled_test_patterns() {
std::regex(R"(.*CPU/CoreThreadingTest.smoke_QueryModel.*)"),
// Target Static Shape is empty
std::regex(R"(.*proposal_params/.*)"),
- // Quantized models unsupported
- std::regex(R"(.*Quantized.*)"),
std::regex(R"(.*smoke_Snippets_ExplicitTransposeMatMul.*)"),
std::regex(R"(.*smoke_Snippets_FullyConnected.*)"),
- std::regex(R"(.*smoke_Snippets_MHA(INT8|Quant|FQ).*)"),
std::regex(R"(.*smoke_Snippets_MLP.*)"),
std::regex(R"(.*smoke_Snippets_GatedMLP.*)"),
std::regex(R"(.*smoke_Snippets_GroupNormalization.*)"),
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 049675da9cd..6ba2c422554 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
@@ -40,6 +40,29 @@ std::vector<std::vector<InputShape>> inputShapesQuantized {
}
};
+// RISC-V keeps FakeQuantize in f32 with low-precision transformations disabled.
+#if defined(OPENVINO_ARCH_RISCV64)
+static constexpr size_t expected_nodes_mha_int8 = 6; // FQx3, Transpose1 on inputs + MHA + Transpose on output
+static constexpr size_t expected_subgraphs_mha_int8 = 4; // FQx3 on inputs + MHA
+static constexpr size_t expected_nodes_mha_quant_matmul0 = 5; // FQx2, Transpose1 on inputs + MHA + Transpose on output
+static constexpr size_t expected_subgraphs_mha_quant_matmul0 = 3; // FQx2 on inputs + MHA
+static constexpr size_t expected_nodes_mha_fq_after_matmul = 3; // Transpose1 + MHA + Transpose on output
+static constexpr size_t expected_subgraphs_mha_fq_after_matmul = 2; // Transpose1 + MHA
+static constexpr size_t expected_nodes_mha_fq = 5; // Transposex2 + Subgraphsx3
+static constexpr size_t expected_subgraphs_mha_fq = 3; // MHA + 2 x FQ on inputs
+#else
+static constexpr size_t expected_nodes_mha_int8 =
+ 7; // FQx3, Transpose1 on inputs + MHA + Transpose on output + Deq Mul
+static constexpr size_t expected_subgraphs_mha_int8 = 5; // FQx3 on inputs + MHA + Deq Mul
+static constexpr size_t expected_nodes_mha_quant_matmul0 =
+ 6; // FQx2, Transpose1 on inputs + MHA + Transpose on output + Deq Mul
+static constexpr size_t expected_subgraphs_mha_quant_matmul0 = 4; // FQx2 on inputs + MHA + Deq Mul
+static constexpr size_t expected_nodes_mha_fq_after_matmul = 4; // Transpose1 + MHA + Transpose on output + Deq Mul
+static constexpr size_t expected_subgraphs_mha_fq_after_matmul = 3; // Transpose1 + MHA + Deq Mul
+static constexpr size_t expected_nodes_mha_fq = 8; // Transposex3 + Subgraphsx5
+static constexpr size_t expected_subgraphs_mha_fq = 5; // MHA + Deq Mul on output + Deqs on inputs + 2 xFQ on inputs
+#endif
+
INSTANTIATE_TEST_SUITE_P(
smoke_Snippets_MHAINT8MatMul,
MHAINT8MatMul,
@@ -47,8 +70,8 @@ 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(7), // FQx3, Transpose1 on inputs + MHA + Transpose on output + Deq Mul
- ::testing::Values(5), // FQx3 on inputs + MHA + Deq Mul
+ ::testing::Values(expected_nodes_mha_int8),
+ ::testing::Values(expected_subgraphs_mha_int8),
::testing::Values(ov::test::utils::DEVICE_CPU),
::testing::Values(CPUTestUtils::empty_plugin_config)),
MHA::getTestCaseName);
@@ -61,8 +84,8 @@ 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(6), // FQx2, Transpose1 on inputs + MHA + Transpose on output + Deq Mul
- ::testing::Values(4), // FQx2 on inputs + MHA + Deq Mul
+ ::testing::Values(expected_nodes_mha_quant_matmul0),
+ ::testing::Values(expected_subgraphs_mha_quant_matmul0),
::testing::Values(ov::test::utils::DEVICE_CPU),
::testing::Values(CPUTestUtils::empty_plugin_config)),
MHA::getTestCaseName);
@@ -74,8 +97,8 @@ 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(4), // Transpose1 + MHA + Transpose on output + Deq Mul
- ::testing::Values(3), // Transpose1 + MHA + Deq Mul
+ ::testing::Values(expected_nodes_mha_fq_after_matmul),
+ ::testing::Values(expected_subgraphs_mha_fq_after_matmul),
::testing::Values(ov::test::utils::DEVICE_CPU),
::testing::Values(CPUTestUtils::empty_plugin_config)),
MHA::getTestCaseName);
@@ -87,8 +110,8 @@ 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(8), // Transposex3 + Subgraphsx5
- ::testing::Values(5), // MHA + Deq Mul on output + Deqs on inputs + 2 xFQ on inputs
+ ::testing::Values(expected_nodes_mha_fq),
+ ::testing::Values(expected_subgraphs_mha_fq),
::testing::Values(ov::test::utils::DEVICE_CPU),
::testing::Values(CPUTestUtils::empty_plugin_config)),
MHA::getTestCaseName);