Skip to content

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

[CPU][LPT] Simplify LPT pass pipeline description (#30392)

Arseniy Obolenskiy16da0649d14d
diff --git a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
index 945fb799a3b..b05924a11be 100644
--- a/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
+++ b/src/plugins/intel_cpu/src/transformations/transformation_pipeline.cpp
@@ -799,54 +799,12 @@ void Transformations::PreLpt(const std::vector<ov::element::Type>& defaultPrecis
void Transformations::runLptPasses(const std::vector<ov::element::Type>& defaultPrecisions) {
using namespace ov::pass::low_precision;
ov::pass::Manager lptManager("CPU:LPT");
+
#if defined(OPENVINO_ARCH_ARM) || defined(OPENVINO_ARCH_ARM64)
+ auto quantizationRestrictions = std::vector<QuantizationGranularityRestriction>();
auto supportedPrecisions = std::vector<PrecisionsRestriction>({
PrecisionsRestriction::create<ov::opset1::MatMul>({{{0, 1}, {ov::element::i8}}}),
});
-
- auto quantizationRestrictions = std::vector<QuantizationGranularityRestriction>();
-
- CPU_REGISTER_PASS_COMMON(lptManager,
- LowPrecision,
- supportedPrecisions,
- quantizationRestrictions,
- LayerTransformation::Params(true, ov::element::f32, defaultPrecisions));
- CPU_DISABLE_PASS_COMMON(lptManager, AvgPoolTransformation);
- CPU_DISABLE_PASS_COMMON(lptManager, ConvolutionTransformation);
- CPU_DISABLE_PASS_COMMON(lptManager, ConvolutionBackpropDataTransformation);
- CPU_DISABLE_PASS_COMMON(lptManager, InterpolateTransformation);
- CPU_DISABLE_PASS_COMMON(lptManager, GroupConvolutionTransformation);
- CPU_DISABLE_PASS_COMMON(lptManager, MaxPoolTransformation);
- CPU_DISABLE_PASS_COMMON(lptManager, MVNTransformation);
- CPU_DISABLE_PASS_COMMON(lptManager, NormalizeL2Transformation);
- CPU_DISABLE_PASS_COMMON(lptManager, RecurrentCellTransformation);
- CPU_DISABLE_PASS_COMMON(lptManager, ReduceMaxTransformation);
- CPU_DISABLE_PASS_COMMON(lptManager, ReduceMeanTransformation);
- CPU_DISABLE_PASS_COMMON(lptManager, ReduceMinTransformation);
- CPU_DISABLE_PASS_COMMON(lptManager, ReduceSumTransformation);
- CPU_DISABLE_PASS_COMMON(lptManager, MultiplyToGroupConvolutionTransformation);
-
- CPU_SET_CALLBACK_COMMON(
- lptManager,
- [](const_node_ptr& node) -> bool {
- return ov::marked_as_bias(node);
- },
- AddTransformation);
-
- // Enable MatMulTransformation against FC nodes only
- // int8 MatMul is disabled because acl_lowp_matmul_t supports 2D case only
- // most models have 3D/4D cases, so fallback to jit_gemm_i8 gives worse perf than gemm_acl_f16
- // oneDNN ticket #2696
- CPU_SET_CALLBACK_COMMON(
- lptManager,
- [&](const_node_ptr& node) -> bool {
- if (NetworkHelper::isConstantPath(node->get_input_node_shared_ptr(1)) &&
- one_of(node->input_value(1).get_partial_shape().rank().get_length(), 2, 3)) {
- return false;
- }
- return true;
- },
- MatMulTransformation);
#else
// Only enable conv/group conv signed input on AMX and avx2_vnni_2 platform.
std::vector<ov::element::Type> input0LowPrecisionList;
@@ -857,6 +815,9 @@ void Transformations::runLptPasses(const std::vector<ov::element::Type>& default
input0LowPrecisionList = {ov::element::u8};
}
+ auto quantizationRestrictions = std::vector<QuantizationGranularityRestriction>(
+ {QuantizationGranularityRestriction::create<ov::opset1::Convolution>({0}),
+ QuantizationGranularityRestriction::create<ov::opset1::ConvolutionBackpropData>({0})});
auto supportedPrecisions = std::vector<PrecisionsRestriction>({
PrecisionsRestriction::create<ov::opset1::Convolution>({
{{0}, input0LowPrecisionList},
@@ -880,30 +841,53 @@ void Transformations::runLptPasses(const std::vector<ov::element::Type>& default
PrecisionsRestriction::create<ov::opset5::LSTMSequence>({{{0, 1}, {ov::element::u8}}}),
PrecisionsRestriction::create<ov::opset6::GRUSequence>({{{0, 1}, {ov::element::u8}}}),
});
-
- auto quantizationRestrictions = std::vector<QuantizationGranularityRestriction>(
- {QuantizationGranularityRestriction::create<ov::opset1::Convolution>({0}),
- QuantizationGranularityRestriction::create<ov::opset1::ConvolutionBackpropData>({0})});
-
+#endif
CPU_REGISTER_PASS_COMMON(lptManager,
LowPrecision,
supportedPrecisions,
quantizationRestrictions,
LayerTransformation::Params(true, ov::element::f32, defaultPrecisions));
-
CPU_SET_CALLBACK_COMMON(
+ lptManager,
+ [](const_node_ptr& node) -> bool {
+ return ov::marked_as_bias(node);
+ },
+ AddTransformation);
+ CPU_DISABLE_PASS_COMMON(lptManager, MultiplyToGroupConvolutionTransformation);
+
+ CPU_DISABLE_PASS_ARM(lptManager, AvgPoolTransformation);
+ CPU_DISABLE_PASS_ARM(lptManager, ConvolutionTransformation);
+ CPU_DISABLE_PASS_ARM(lptManager, ConvolutionBackpropDataTransformation);
+ CPU_DISABLE_PASS_ARM(lptManager, InterpolateTransformation);
+ CPU_DISABLE_PASS_ARM(lptManager, GroupConvolutionTransformation);
+ CPU_DISABLE_PASS_ARM(lptManager, MaxPoolTransformation);
+ CPU_DISABLE_PASS_ARM(lptManager, MVNTransformation);
+ CPU_DISABLE_PASS_ARM(lptManager, NormalizeL2Transformation);
+ CPU_DISABLE_PASS_ARM(lptManager, RecurrentCellTransformation);
+ CPU_DISABLE_PASS_ARM(lptManager, ReduceMaxTransformation);
+ CPU_DISABLE_PASS_ARM(lptManager, ReduceMeanTransformation);
+ CPU_DISABLE_PASS_ARM(lptManager, ReduceMinTransformation);
+ CPU_DISABLE_PASS_ARM(lptManager, ReduceSumTransformation);
+
+ // Enable MatMulTransformation against FC nodes only
+ // int8 MatMul is disabled because acl_lowp_matmul_t supports 2D case only
+ // most models have 3D/4D cases, so fallback to jit_gemm_i8 gives worse perf than gemm_acl_f16
+ // oneDNN ticket #2696
+ CPU_SET_CALLBACK_ARM(
+ lptManager,
+ [&](const_node_ptr& node) -> bool {
+ return !(NetworkHelper::isConstantPath(node->get_input_node_shared_ptr(1)) &&
+ one_of(node->input_value(1).get_partial_shape().rank().get_length(), 2, 3));
+ },
+ MatMulTransformation);
+
+ CPU_SET_CALLBACK_X64(
lptManager,
[&defaultPrecisions](const_node_ptr& node) -> bool {
return LayerTransformation::isAsymmetricQuantization(node, defaultPrecisions) ||
WeightableLayerTransformation::isAsymmetricOnWeights(node, defaultPrecisions);
},
ConvolutionBackpropDataTransformation);
- CPU_SET_CALLBACK_COMMON(
- lptManager,
- [](const_node_ptr& node) -> bool {
- return ov::marked_as_bias(node);
- },
- AddTransformation);
CPU_SET_CALLBACK_X64(
lptManager,
@@ -934,8 +918,6 @@ void Transformations::runLptPasses(const std::vector<ov::element::Type>& default
},
FuseConvertTransformation);
- CPU_DISABLE_PASS_COMMON(lptManager, MultiplyToGroupConvolutionTransformation);
-#endif
lptManager.run_passes(model);
}
diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/x64/concat_with_neighbors_transformation.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/x64/concat_with_neighbors_transformation.cpp
index 048886d1fa1..403833888a3 100644
--- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/x64/concat_with_neighbors_transformation.cpp
+++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/low_precision_transformations/x64/concat_with_neighbors_transformation.cpp
@@ -31,6 +31,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithNeighborsGraphTransformation,
::testing::ValuesIn(precisions),
::testing::ValuesIn(shapes),
::testing::Values(ov::test::utils::DEVICE_CPU),
- ::testing::ValuesIn(trasformationParamValues)),
+ ::testing::ValuesIn(trasformationParamValues),
+ ::testing::Values("convolution_addition_original"),
+ ::testing::Values("u8")),
ConcatWithNeighborsGraphTransformation::getTestCaseName);
} // namespace
diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp
index 43c85782d0e..bd5d6e6b4c2 100644
--- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp
+++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp
@@ -27,6 +27,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_LPT, ConcatWithNeighborsGraphTransformation,
::testing::ValuesIn(precisions),
::testing::Values(ov::PartialShape({ 1, 3, 16, 16 })),
::testing::Values(ov::test::utils::DEVICE_GPU),
- ::testing::ValuesIn(trasformationParamValues)),
+ ::testing::ValuesIn(trasformationParamValues),
+ ::testing::Values("convolution_addition_original"),
+ ::testing::Values("u8")),
ConcatWithNeighborsGraphTransformation::getTestCaseName);
} // namespace
diff --git a/src/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_neighbors_graph_transformation.hpp b/src/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_neighbors_graph_transformation.hpp
index 24809fc6312..264c4d56eef 100644
--- a/src/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_neighbors_graph_transformation.hpp
+++ b/src/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_neighbors_graph_transformation.hpp
@@ -15,7 +15,9 @@ typedef std::tuple<
ov::element::Type,
ov::PartialShape,
std::string,
- ov::pass::low_precision::LayerTransformation::Params> ConcatNeighboringGraphTransformationParams;
+ ov::pass::low_precision::LayerTransformation::Params,
+ std::string,
+ std::string> ConcatNeighboringGraphTransformationParams;
class ConcatWithNeighborsGraphTransformation :
public testing::WithParamInterface<ConcatNeighboringGraphTransformationParams>,
@@ -25,6 +27,8 @@ public:
protected:
void SetUp() override;
+ void run() override;
+ std::string expectedKernelName, expectedRuntimePrecision;
};
} // namespace LayerTestsDefinitions
diff --git a/src/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp b/src/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp
index 112712822db..c1cd933ec16 100644
--- a/src/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp
+++ b/src/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp
@@ -19,17 +19,21 @@ std::string ConcatWithNeighborsGraphTransformation::getTestCaseName(const testin
ov::PartialShape inputShapes;
std::string targetDevice;
ov::pass::low_precision::LayerTransformation::Params params;
- std::tie(precision, inputShapes, targetDevice, params) = obj.param;
+ std::string expectedKernelName, expectedRuntimePrecision;
+ std::tie(precision, inputShapes, targetDevice, params, expectedKernelName, expectedRuntimePrecision) = obj.param;
return get_test_case_name_by_params(precision, inputShapes, targetDevice, params);
}
void ConcatWithNeighborsGraphTransformation::SetUp() {
+ SKIP_IF_CURRENT_TEST_IS_DISABLED()
+
ov::element::Type ngPrecision;
ov::PartialShape inputShape;
ov::pass::low_precision::LayerTransformation::Params params;
- std::tie(ngPrecision, inputShape, targetDevice, params) = this->GetParam();
+ std::string expectedKernelName, expectedRuntimePrecision;
+ std::tie(ngPrecision, inputShape, targetDevice, params, expectedKernelName, expectedRuntimePrecision) = this->GetParam();
init_input_shapes({ inputShape, inputShape, inputShape });
@@ -40,7 +44,18 @@ void ConcatWithNeighborsGraphTransformation::SetUp() {
{ 256ul, ov::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f / 2.f} },
{ 256ul, ov::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f / 3.f} },
"concat",
- "");
+ "convolution");
+}
+
+void ConcatWithNeighborsGraphTransformation::run() {
+ LayerTransformation::run();
+
+ const auto params = std::get<3>(GetParam());
+ const auto expectedKernelName = std::get<4>(GetParam());
+ const auto expectedRuntimePrecision = std::get<5>(GetParam());
+ const auto actualType = get_runtime_precision(expectedKernelName);
+
+ EXPECT_EQ(actualType, expectedRuntimePrecision);
}
TEST_P(ConcatWithNeighborsGraphTransformation, CompareWithRefImpl) {
diff --git a/src/tests/ov_helpers/ov_lpt_models/src/concat.cpp b/src/tests/ov_helpers/ov_lpt_models/src/concat.cpp
index 04b515e258f..5277946feec 100644
--- a/src/tests/ov_helpers/ov_lpt_models/src/concat.cpp
+++ b/src/tests/ov_helpers/ov_lpt_models/src/concat.cpp
@@ -235,8 +235,8 @@ std::shared_ptr<ov::Model> ConcatFunction::getOriginalWithNeighbors(
concat1,
std::make_shared<ov::opset1::Multiply>(
std::make_shared<ov::opset1::Convert>(ov::opset1::Constant::create(ov::element::i8, convShape, {1}),
- ov::element::f32),
- ov::opset1::Constant::create(ov::element::f32, Shape{}, {1})),
+ precision),
+ ov::opset1::Constant::create(precision, Shape{}, {1})),
ov::Strides{1, 1},
ov::CoordinateDiff{0, 0},
ov::CoordinateDiff{0, 0},