Skip to content

Commit

Permalink
TransformationContext is removed from canBeTransformed
Browse files Browse the repository at this point in the history
  • Loading branch information
v-Golubev committed Jan 17, 2025
1 parent 1725469 commit bdae6c0
Show file tree
Hide file tree
Showing 99 changed files with 173 additions and 178 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LP_TRANSFORMATIONS_API AddTransformation : public EltwiseBaseTransformatio
OPENVINO_RTTI("AddTransformation", "0", EltwiseBaseTransformation);
AddTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
};

} // namespace low_precision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class LP_TRANSFORMATIONS_API AssignAndReadValueTransformation : public LayerTran
OPENVINO_RTTI("AssignAndReadValueTransformation", "0", LayerTransformation);
AssignAndReadValueTransformation(const std::shared_ptr<ov::Model> model, const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher& m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> op) const override;
bool canBeTransformed(const std::shared_ptr<Node>& op) const override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
private:
std::shared_ptr<ov::Model> model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LP_TRANSFORMATIONS_API AvgPoolTransformation : public LayerTransformation
AvgPoolTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
};

} // namespace low_precision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LP_TRANSFORMATIONS_API BatchToSpaceTransformation : public LayerTransforma
public:
OPENVINO_RTTI("BatchToSpaceTransformation", "0", LayerTransformation);
BatchToSpaceTransformation(const Params& params = Params());
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> op) const override;
bool canBeTransformed(const std::shared_ptr<Node>& op) const override;
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LP_TRANSFORMATIONS_API BroadcastTransformation : public TransparentBaseTra
public:
OPENVINO_RTTI("BroadcastTransformation", "0", TransparentBaseTransformation);
BroadcastTransformation(const Params& params = Params());
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<ov::Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<ov::Node>& layer) const override;
};

} // namespace low_precision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LP_TRANSFORMATIONS_API ClampTransformation : public LayerTransformation {
OPENVINO_RTTI("ClampTransformation", "0", LayerTransformation);
ClampTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher& m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> op) const override;
bool canBeTransformed(const std::shared_ptr<Node>& op) const override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class LP_TRANSFORMATIONS_API CleanupTransformation : public LayerTransformation
CleanupTransformation(const Params& params);
virtual ~CleanupTransformation() = default;

bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
static bool canBeTransformedStatic(
const std::shared_ptr<Node>& layer,
const std::vector<ov::element::Type>& defaultPrecisions = precision_set::get_int8_support());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class LP_TRANSFORMATIONS_API ConcatTransformation : public LayerTransformation {
ConcatTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
static bool isQuantizedStatic(const std::shared_ptr<const Node>& layer);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LP_TRANSFORMATIONS_API ConvolutionBackpropDataTransformation : public Weig
public:
ConvolutionBackpropDataTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> op) const override;
bool canBeTransformed(const std::shared_ptr<Node>& op) const override;
bool isQuantized(const std::shared_ptr<const Node>& layer,
const std::vector<ov::element::Type>&defaultPrecisions) const override;
static bool isQuantizedStatic(const std::shared_ptr<const Node>& layer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LP_TRANSFORMATIONS_API DepthToSpaceTransformation : public TransparentBase
public:
OPENVINO_RTTI("DepthToSpaceTransformation", "0", TransparentBaseTransformation);
DepthToSpaceTransformation(const Params& params = Params());
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<ov::Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<ov::Node>& layer) const override;
};

} // namespace low_precision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LP_TRANSFORMATIONS_API EliminateFakeQuantizeTransformation : public Cleanu
OPENVINO_RTTI("EliminateFakeQuantizeTransformation", "0", CleanupTransformation);
EliminateFakeQuantizeTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace low_precision {
class LP_TRANSFORMATIONS_API EltwiseBaseTransformation : public LayerTransformation {
public:
EltwiseBaseTransformation(const Params& params) : LayerTransformation(params) {}
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;

static bool isBroadcasted(const PartialShape& shape);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class LP_TRANSFORMATIONS_API FoldConvertTransformation : public CleanupTransform
OPENVINO_RTTI("FoldConvertTransformation", "0", CleanupTransformation);
FoldConvertTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LP_TRANSFORMATIONS_API FoldFakeQuantizeTransformation : public LayerTransf
OPENVINO_RTTI("FoldFakeQuantizeTransformation", "0", LayerTransformation);
FoldFakeQuantizeTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
bool isConstantOutput(std::shared_ptr<ov::Node> op) const;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LP_TRANSFORMATIONS_API FuseConvertTransformation : public CleanupTransform
OPENVINO_RTTI("FuseConvertTransformation", "0", CleanupTransformation);
FuseConvertTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class LP_TRANSFORMATIONS_API FuseElementwiseToFakeQuantizeTransformation : publi
FuseElementwiseToFakeQuantizeTransformation(const Params& params);
virtual ~FuseElementwiseToFakeQuantizeTransformation() = default;

bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
};

} // namespace low_precision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LP_TRANSFORMATIONS_API GatherTransformation : public LayerTransformation {
GatherTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
};

} // namespace low_precision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LP_TRANSFORMATIONS_API InterpolateTransformation : public LayerTransformat
InterpolateTransformation(const Params& params = Params());
bool transform(TransformationContext &context, ov::pass::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
};

} // namespace low_precision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class LP_TRANSFORMATIONS_API LayerTransformation : public ov::pass::MatcherPass

void setDefaultPrecisions(const std::vector<ov::element::Type>& defaultPrecisions);

virtual bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const;
virtual bool canBeTransformed(const std::shared_ptr<Node>& layer) const;
static bool canBeTransformedStatic(const std::shared_ptr<Node>& layer,
const std::vector<ov::element::Type>& defaultPrecisions = precision_set::get_int8_support());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LP_TRANSFORMATIONS_API MatMulTransformation : public LayerTransformation {
MatMulTransformation(const Params& params = Params());
bool transform(TransformationContext &context, ov::pass::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
};

} // namespace low_precision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LP_TRANSFORMATIONS_API MaxPoolTransformation : public LayerTransformation
public:
OPENVINO_RTTI("MaxPoolTransformation", "0", LayerTransformation);
MaxPoolTransformation(const Params& params = Params());
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> op) const override;
bool canBeTransformed(const std::shared_ptr<Node>& op) const override;
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LP_TRANSFORMATIONS_API MoveFakeQuantize : public LayerTransformation {
OPENVINO_RTTI("MoveFakeQuantize", "0", LayerTransformation);
MoveFakeQuantize(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LP_TRANSFORMATIONS_API MultiplyPartialTransformation : public EltwiseBaseT
OPENVINO_RTTI("MultiplyPartialTransformation", "0", EltwiseBaseTransformation);
MultiplyPartialTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
};

} // namespace low_precision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class LP_TRANSFORMATIONS_API MultiplyToGroupConvolutionTransformation : public C
const PrecisionsRestriction::PrecisionsByPorts& restrictions = {});
~MultiplyToGroupConvolutionTransformation() override {}
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
bool isQuantized(const std::shared_ptr<const Node>& layer,
const std::vector<ov::element::Type>& defaultPrecisions) const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LP_TRANSFORMATIONS_API MVNTransformation : public LayerTransformation {
OPENVINO_RTTI("MVNTransformation", "0", LayerTransformation);
MVNTransformation(const Params& params = Params());
bool transform(TransformationContext &context, ov::pass::pattern::Matcher &m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LP_TRANSFORMATIONS_API NormalizeL2Transformation : public LayerTransformat
OPENVINO_RTTI("NormalizeL2Transformation", "0", LayerTransformation);
NormalizeL2Transformation(const Params& params = Params());
bool transform(TransformationContext &context, ov::pass::pattern::Matcher &m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LP_TRANSFORMATIONS_API PadTransformation : public LayerTransformation {
OPENVINO_RTTI("PadTransformation", "0", LayerTransformation);
PadTransformation(const Params& params = Params());
bool transform(TransformationContext& context, pattern::Matcher& m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> op) const override;
bool canBeTransformed(const std::shared_ptr<Node>& op) const override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class LP_TRANSFORMATIONS_API PReluTransformation : public LayerTransformation {
PReluTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> op) const override;
bool canBeTransformed(const std::shared_ptr<Node>& op) const override;
};

} // namespace low_precision
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LP_TRANSFORMATIONS_API RecurrentCellTransformation : public LayerTransform
OPENVINO_RTTI("RecurrentCellTransformation", "0", LayerTransformation);
RecurrentCellTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
void propagateSkipCleanupAttribute(std::shared_ptr<Node> dequantization_multiply);
static std::shared_ptr<ov::Node> wrap_fake_quantize(const std::shared_ptr<ov::Node> parameter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LP_TRANSFORMATIONS_API ReduceBaseTransformation : public LayerTransformati
public:
ReduceBaseTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher& m) override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> reduce) const override;
bool canBeTransformed(const std::shared_ptr<Node>& reduce) const override;

protected:
virtual void changeDequantizationValues(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class LP_TRANSFORMATIONS_API ReduceMaxTransformation : public ReduceBaseTransfor
OPENVINO_RTTI("ReduceMaxTransformation", "0", ReduceBaseTransformation);
ReduceMaxTransformation(const Params& params = Params());
bool isPrecisionPreserved(std::shared_ptr<Node> reduce) const noexcept override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> reduce) const override;
bool canBeTransformed(const std::shared_ptr<Node>& reduce) const override;

protected:
bool getUpdatePrecision(const std::shared_ptr<Node>& reduce) const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class LP_TRANSFORMATIONS_API ReduceMeanTransformation : public ReduceBaseTransfo
OPENVINO_RTTI("ReduceMeanTransformation", "0", ReduceBaseTransformation);
ReduceMeanTransformation(const Params& params = Params());
bool isPrecisionPreserved(std::shared_ptr<Node> reduce) const noexcept override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> reduce) const override;
bool canBeTransformed(const std::shared_ptr<Node>& reduce) const override;

protected:
bool getUpdatePrecision(const std::shared_ptr<Node>& reduce) const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class LP_TRANSFORMATIONS_API ReduceMinTransformation : public ReduceBaseTransfor
OPENVINO_RTTI("ReduceMinTransformation", "0", ReduceBaseTransformation);
ReduceMinTransformation(const Params& params = Params());
bool isPrecisionPreserved(std::shared_ptr<Node> reduce) const noexcept override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> reduce) const override;
bool canBeTransformed(const std::shared_ptr<Node>& reduce) const override;

protected:
bool getUpdatePrecision(const std::shared_ptr<Node>& reduce) const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class LP_TRANSFORMATIONS_API ReduceSumTransformation : public ReduceBaseTransfor
OPENVINO_RTTI("ReduceSumTransformation", "0", ReduceBaseTransformation);
ReduceSumTransformation(const Params& params = Params());
bool isPrecisionPreserved(std::shared_ptr<Node> reduce) const noexcept override;
bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> reduce) const override;
bool canBeTransformed(const std::shared_ptr<Node>& reduce) const override;

protected:
void changeDequantizationValues(
Expand Down
Loading

0 comments on commit bdae6c0

Please sign in to comment.