Skip to content

Commit

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class LP_TRANSFORMATIONS_API AssignAndReadValueTransformation : public LayerTran
public:
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 transform(ov::pass::pattern::Matcher& m) override;
bool canBeTransformed(const std::shared_ptr<Node>& op) const override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LP_TRANSFORMATIONS_API AvgPoolTransformation : public LayerTransformation
public:
OPENVINO_RTTI("AvgPoolTransformation", "0", LayerTransformation);
AvgPoolTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LP_TRANSFORMATIONS_API BatchToSpaceTransformation : public LayerTransforma
OPENVINO_RTTI("BatchToSpaceTransformation", "0", LayerTransformation);
BatchToSpaceTransformation(const Params& params = Params());
bool canBeTransformed(const std::shared_ptr<Node>& op) const override;
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(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 @@ -24,7 +24,7 @@ class LP_TRANSFORMATIONS_API ClampTransformation : public LayerTransformation {
public:
OPENVINO_RTTI("ClampTransformation", "0", LayerTransformation);
ClampTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher& m) override;
bool transform(ov::pass::pattern::Matcher& m) 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 @@ -31,7 +31,7 @@ class LP_TRANSFORMATIONS_API ConcatTransformation : public LayerTransformation {
public:
OPENVINO_RTTI("ConcatTransformation", "0", LayerTransformation);
ConcatTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept 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 @@ -15,7 +15,7 @@ class LP_TRANSFORMATIONS_API ConvertTransformation : public LayerTransformation
public:
OPENVINO_RTTI("ConvertTransformation", "0", LayerTransformation);
ConvertTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(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 ConvolutionTransformation : public WeightableLayerT
public:
OPENVINO_RTTI("ConvolutionTransformation", "0", WeightableLayerTransformation);
ConvolutionTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) 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 @@ -21,7 +21,7 @@ namespace low_precision {
class LP_TRANSFORMATIONS_API ConvolutionBackpropDataTransformation : public WeightableLayerTransformation {
public:
ConvolutionBackpropDataTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class LP_TRANSFORMATIONS_API EliminateFakeQuantizeTransformation : public Cleanu
public:
OPENVINO_RTTI("EliminateFakeQuantizeTransformation", "0", CleanupTransformation);
EliminateFakeQuantizeTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) 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,16 +23,15 @@ class LP_TRANSFORMATIONS_API FakeQuantizeTransformation : public LayerTransforma
public:
OPENVINO_RTTI("FakeQuantizeTransformation", "0", LayerTransformation);
FakeQuantizeTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;

static bool checkElementwise(const std::shared_ptr<Node>& eltwise);

static std::shared_ptr<ov::opset1::FakeQuantize> fuseElementwise(
TransformationContext& context,
MatcherPass* matcherPass,
const std::shared_ptr<ov::opset1::FakeQuantize>& fakeQuantize,
const bool updatePrecisions);
MatcherPass* matcherPass,
const std::shared_ptr<ov::opset1::FakeQuantize>& fakeQuantize,
const bool updatePrecisions);
};

} // 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 FakeQuantizeDecompositionTransformation : public La
public:
OPENVINO_RTTI("FakeQuantizeDecompositionTransformation", "0", LayerTransformation);
FakeQuantizeDecompositionTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(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 @@ -25,7 +25,7 @@ class LP_TRANSFORMATIONS_API FoldConvertTransformation : public CleanupTransform
public:
OPENVINO_RTTI("FoldConvertTransformation", "0", CleanupTransformation);
FoldConvertTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) 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 FoldFakeQuantizeTransformation : public LayerTransf
public:
OPENVINO_RTTI("FoldFakeQuantizeTransformation", "0", LayerTransformation);
FoldFakeQuantizeTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) 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 @@ -22,7 +22,7 @@ class LP_TRANSFORMATIONS_API FuseConvertTransformation : public CleanupTransform
public:
OPENVINO_RTTI("FuseConvertTransformation", "0", CleanupTransformation);
FuseConvertTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) 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 FuseMultiplyToFakeQuantizeTransformation : public F
public:
OPENVINO_RTTI("FuseMultiplyToFakeQuantizeTransformation", "0", FuseElementwiseToFakeQuantizeTransformation);
FuseMultiplyToFakeQuantizeTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(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 @@ -24,7 +24,7 @@ class LP_TRANSFORMATIONS_API FuseSubtractToFakeQuantizeTransformation : public F
public:
OPENVINO_RTTI("FuseSubtractToFakeQuantizeTransformation", "0", FuseElementwiseToFakeQuantizeTransformation);
FuseSubtractToFakeQuantizeTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(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 @@ -15,7 +15,7 @@ class LP_TRANSFORMATIONS_API GatherTransformation : public LayerTransformation {
public:
OPENVINO_RTTI("GatherTransformation", "0", LayerTransformation);
GatherTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LP_TRANSFORMATIONS_API GroupConvolutionTransformation : public Convolution
public:
OPENVINO_RTTI("GroupConvolutionTransformation", "0", ConvolutionTransformation);
GroupConvolutionTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) 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 InterpolateTransformation : public LayerTransformat
public:
OPENVINO_RTTI("InterpolateTransformation", "0", LayerTransformation);
InterpolateTransformation(const Params& params = Params());
bool transform(TransformationContext &context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class LP_TRANSFORMATIONS_API LayerTransformation : public ov::pass::MatcherPass

LayerTransformation(const Params& params);
virtual ~LayerTransformation() = default;
virtual bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) = 0;
virtual bool transform(ov::pass::pattern::Matcher &m) = 0;

void setUpdatePrecisions(const bool updatePrecisions);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LP_TRANSFORMATIONS_API MatMulTransformation : public LayerTransformation {
public:
OPENVINO_RTTI("MatMulTransformation", "0", LayerTransformation);
MatMulTransformation(const Params& params = Params());
bool transform(TransformationContext &context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
bool canBeTransformed(const std::shared_ptr<Node>& layer) const override;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LP_TRANSFORMATIONS_API MaxPoolTransformation : public LayerTransformation
OPENVINO_RTTI("MaxPoolTransformation", "0", LayerTransformation);
MaxPoolTransformation(const Params& params = Params());
bool canBeTransformed(const std::shared_ptr<Node>& op) const override;
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(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 @@ -16,7 +16,7 @@ class LP_TRANSFORMATIONS_API MoveFakeQuantize : public LayerTransformation {
public:
OPENVINO_RTTI("MoveFakeQuantize", "0", LayerTransformation);
MoveFakeQuantize(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) 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 MultiplyTransformation : public WeightableLayerTran
public:
OPENVINO_RTTI("MultiplyTransformation", "0", WeightableLayerTransformation);
MultiplyTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) override;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class LP_TRANSFORMATIONS_API MultiplyToGroupConvolutionTransformation : public C
const Params& params = Params(),
const PrecisionsRestriction::PrecisionsByPorts& restrictions = {});
~MultiplyToGroupConvolutionTransformation() override {}
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LP_TRANSFORMATIONS_API MVNTransformation : public LayerTransformation {
public:
OPENVINO_RTTI("MVNTransformation", "0", LayerTransformation);
MVNTransformation(const Params& params = Params());
bool transform(TransformationContext &context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) 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 @@ -22,7 +22,7 @@ class LP_TRANSFORMATIONS_API NormalizeL2Transformation : public LayerTransformat
public:
OPENVINO_RTTI("NormalizeL2Transformation", "0", LayerTransformation);
NormalizeL2Transformation(const Params& params = Params());
bool transform(TransformationContext &context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) 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 PadTransformation : public LayerTransformation {
public:
OPENVINO_RTTI("PadTransformation", "0", LayerTransformation);
PadTransformation(const Params& params = Params());
bool transform(TransformationContext& context, pattern::Matcher& m) override;
bool transform(pattern::Matcher& m) 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 @@ -24,7 +24,7 @@ class LP_TRANSFORMATIONS_API PReluTransformation : public LayerTransformation {
public:
OPENVINO_RTTI("PReluTransformation", "0", LayerTransformation);
PReluTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) override;
bool isPrecisionPreserved(std::shared_ptr<Node> layer) const noexcept override;
bool canBeTransformed(const std::shared_ptr<Node>& op) const override;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class LP_TRANSFORMATIONS_API RecurrentCellTransformation : public LayerTransform
public:
OPENVINO_RTTI("RecurrentCellTransformation", "0", LayerTransformation);
RecurrentCellTransformation(const Params& params = Params());
bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) override;
bool transform(ov::pass::pattern::Matcher &m) 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);
Expand All @@ -25,7 +25,7 @@ class LP_TRANSFORMATIONS_API RecurrentCellTransformation : public LayerTransform
static std::shared_ptr<ov::Node> wrap_dequantization(const std::shared_ptr<ov::Node> parameter, const bool with_subtract);

private:
void propagate(TransformationContext& context, const std::shared_ptr<ov::Node> node);
void propagate(const std::shared_ptr<ov::Node> node);
};

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

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

0 comments on commit 7d88209

Please sign in to comment.