diff --git a/src/common/low_precision_transformations/include/low_precision/eliminate_fake_quantize.hpp b/src/common/low_precision_transformations/include/low_precision/eliminate_fake_quantize.hpp index 2741d6b15cc026..9b3d1f9e0fe0b7 100644 --- a/src/common/low_precision_transformations/include/low_precision/eliminate_fake_quantize.hpp +++ b/src/common/low_precision_transformations/include/low_precision/eliminate_fake_quantize.hpp @@ -6,7 +6,7 @@ #include -#include "low_precision/layer_transformation.hpp" +#include "low_precision/cleanup_transformation.hpp" namespace ov { namespace pass { @@ -20,7 +20,7 @@ namespace low_precision { * [EliminateFakeQuantizeTransformation](@ref openvino_docs_OV_UG_lpt_EliminateFakeQuantizeTransformation) page * in the Inference Engine Developer Guide. */ -class LP_TRANSFORMATIONS_API EliminateFakeQuantizeTransformation : public LayerTransformation { +class LP_TRANSFORMATIONS_API EliminateFakeQuantizeTransformation : public CleanupTransformation { public: OPENVINO_RTTI("EliminateFakeQuantizeTransformation", "0"); EliminateFakeQuantizeTransformation(const Params& params = Params()); diff --git a/src/common/low_precision_transformations/include/low_precision/fold_convert.hpp b/src/common/low_precision_transformations/include/low_precision/fold_convert.hpp index e5fcfd639f7dee..640cdda59e6947 100644 --- a/src/common/low_precision_transformations/include/low_precision/fold_convert.hpp +++ b/src/common/low_precision_transformations/include/low_precision/fold_convert.hpp @@ -6,7 +6,7 @@ #include -#include "low_precision/layer_transformation.hpp" +#include "low_precision/cleanup_transformation.hpp" namespace ov { namespace pass { @@ -20,7 +20,7 @@ namespace low_precision { * [FoldConvertTransformation](@ref openvino_docs_OV_UG_lpt_FoldConvertTransformation) page * in the Inference Engine Developer Guide. */ -class LP_TRANSFORMATIONS_API FoldConvertTransformation : public LayerTransformation { +class LP_TRANSFORMATIONS_API FoldConvertTransformation : public CleanupTransformation { public: OPENVINO_RTTI("FoldConvertTransformation", "0"); FoldConvertTransformation(const Params& params = Params()); diff --git a/src/common/low_precision_transformations/include/low_precision/fuse_convert.hpp b/src/common/low_precision_transformations/include/low_precision/fuse_convert.hpp index 76e5a8e419558f..09c4692198d4ae 100644 --- a/src/common/low_precision_transformations/include/low_precision/fuse_convert.hpp +++ b/src/common/low_precision_transformations/include/low_precision/fuse_convert.hpp @@ -4,9 +4,7 @@ #pragma once - -#include "low_precision/layer_transformation.hpp" -#include "low_precision/eltwise_base_transformation.hpp" +#include "low_precision/cleanup_transformation.hpp" namespace ov { namespace pass { @@ -20,7 +18,7 @@ namespace low_precision { * [FuseConvertTransformation](@ref openvino_docs_OV_UG_lpt_FuseConvertTransformation) page * in the Inference Engine Developer Guide. */ -class LP_TRANSFORMATIONS_API FuseConvertTransformation : public LayerTransformation { +class LP_TRANSFORMATIONS_API FuseConvertTransformation : public CleanupTransformation { public: OPENVINO_RTTI("FuseConvertTransformation", "0"); FuseConvertTransformation(const Params& params = Params()); diff --git a/src/common/low_precision_transformations/include/low_precision/multiply_to_group_convolution.hpp b/src/common/low_precision_transformations/include/low_precision/multiply_to_group_convolution.hpp index b107b7de0418f9..d76f2ef108853d 100644 --- a/src/common/low_precision_transformations/include/low_precision/multiply_to_group_convolution.hpp +++ b/src/common/low_precision_transformations/include/low_precision/multiply_to_group_convolution.hpp @@ -5,7 +5,7 @@ #pragma once #include -#include "low_precision/layer_transformation.hpp" +#include "low_precision/cleanup_transformation.hpp" #include "common/precisions_restriction.hpp" namespace ov { @@ -20,7 +20,7 @@ namespace low_precision { * [MultiplyToGroupConvolutionTransformation](@ref openvino_docs_OV_UG_lpt_MultiplyToGroupConvolutionTransformation) page * in the Inference Engine Developer Guide. */ -class LP_TRANSFORMATIONS_API MultiplyToGroupConvolutionTransformation : public LayerTransformation { +class LP_TRANSFORMATIONS_API MultiplyToGroupConvolutionTransformation : public CleanupTransformation { public: OPENVINO_RTTI("MultiplyToGroupConvolutionTransformation", "0"); MultiplyToGroupConvolutionTransformation( diff --git a/src/common/low_precision_transformations/src/eliminate_fake_quantize.cpp b/src/common/low_precision_transformations/src/eliminate_fake_quantize.cpp index bfa83bb0f44b5b..3010ea213d04f2 100644 --- a/src/common/low_precision_transformations/src/eliminate_fake_quantize.cpp +++ b/src/common/low_precision_transformations/src/eliminate_fake_quantize.cpp @@ -15,7 +15,7 @@ namespace ov { namespace pass { namespace low_precision { -EliminateFakeQuantizeTransformation::EliminateFakeQuantizeTransformation(const Params& params) : LayerTransformation(params) { +EliminateFakeQuantizeTransformation::EliminateFakeQuantizeTransformation(const Params& params) : CleanupTransformation(params) { MATCHER_SCOPE(FuseMultiplyToFakeQuantizeTransformation); const auto matcher = pattern::wrap_type({ pattern::any_input(), @@ -112,6 +112,10 @@ bool check_intervals(const std::shared_ptr& fakeQuanti } // namespace bool EliminateFakeQuantizeTransformation::canBeTransformed(const TransformationContext& context, std::shared_ptr operation) const { + if (!CleanupTransformation::canBeTransformed(context, operation)) { + return false; + } + const auto fakeQuantize = ov::as_type_ptr(operation); OPENVINO_ASSERT(fakeQuantize != nullptr, "unexpected operation type"); diff --git a/src/common/low_precision_transformations/src/fold_convert.cpp b/src/common/low_precision_transformations/src/fold_convert.cpp index 35b3385e2ebf4e..7f8de487a19ead 100644 --- a/src/common/low_precision_transformations/src/fold_convert.cpp +++ b/src/common/low_precision_transformations/src/fold_convert.cpp @@ -14,7 +14,7 @@ namespace ov { namespace pass { namespace low_precision { -FoldConvertTransformation::FoldConvertTransformation(const Params& params) : LayerTransformation(params) { +FoldConvertTransformation::FoldConvertTransformation(const Params& params) : CleanupTransformation(params) { MATCHER_SCOPE(FoldConvertTransformation); auto subtract = pattern::wrap_type(); auto matcher = std::make_shared(subtract, matcher_name); @@ -57,6 +57,7 @@ bool FoldConvertTransformation::transform(TransformationContext& context, ov::pa bool FoldConvertTransformation::canBeTransformed(const TransformationContext& context, std::shared_ptr operation) const { return + (CleanupTransformation::canBeTransformed(context, operation)) && (ov::is_type(operation->get_input_node_ptr(1)) && ov::is_type(operation->get_input_node_ptr(1)->get_input_node_ptr(0))) || (ov::is_type(operation->get_input_node_ptr(0)) && diff --git a/src/common/low_precision_transformations/src/fuse_convert.cpp b/src/common/low_precision_transformations/src/fuse_convert.cpp index 68a7b500374a5a..372476aeabe737 100644 --- a/src/common/low_precision_transformations/src/fuse_convert.cpp +++ b/src/common/low_precision_transformations/src/fuse_convert.cpp @@ -20,7 +20,7 @@ namespace ov { namespace pass { namespace low_precision { -FuseConvertTransformation::FuseConvertTransformation(const Params& params) : LayerTransformation(params) { +FuseConvertTransformation::FuseConvertTransformation(const Params& params) : CleanupTransformation(params) { MATCHER_SCOPE(FuseConvertTransformation); auto multiply = pattern::wrap_type({ pattern::wrap_type(), pattern::wrap_type() }); auto subtract = pattern::wrap_type({ pattern::wrap_type(), pattern::wrap_type() }); @@ -115,7 +115,7 @@ bool FuseConvertTransformation::transform(TransformationContext& context, ov::pa } bool FuseConvertTransformation::canBeTransformed(const TransformationContext& context, std::shared_ptr op) const { - if (!getAttribute(op).empty()) { + if (!CleanupTransformation::canBeTransformed(context, op)) { return false; } diff --git a/src/common/low_precision_transformations/src/multiply_to_group_convolution.cpp b/src/common/low_precision_transformations/src/multiply_to_group_convolution.cpp index 62a51ef6193d56..a8999aeff8eec6 100644 --- a/src/common/low_precision_transformations/src/multiply_to_group_convolution.cpp +++ b/src/common/low_precision_transformations/src/multiply_to_group_convolution.cpp @@ -15,7 +15,7 @@ namespace low_precision { MultiplyToGroupConvolutionTransformation::MultiplyToGroupConvolutionTransformation( const Params& params, - const PrecisionsRestriction::PrecisionsByPorts& restrictions) : LayerTransformation(params), restrictions(restrictions), groupSize(1ul) { + const PrecisionsRestriction::PrecisionsByPorts& restrictions) : CleanupTransformation(params), restrictions(restrictions), groupSize(1ul) { MATCHER_SCOPE(MultiplyToGroupConvolutionTransformation); auto matcher = pattern::wrap_type(); @@ -143,6 +143,10 @@ bool MultiplyToGroupConvolutionTransformation::transform(TransformationContext& } bool MultiplyToGroupConvolutionTransformation::canBeTransformed(const TransformationContext& context, std::shared_ptr operation) const { + if (!CleanupTransformation::canBeTransformed(context, operation)) { + return false; + } + const PartialShape outPShape = operation->get_output_partial_shape(0); const auto rank = outPShape.rank(); if (rank.is_dynamic()) {