Skip to content

Commit

Permalink
TransformationContext is removed from moveDequantizationBefore/After
Browse files Browse the repository at this point in the history
  • Loading branch information
v-Golubev committed Jan 17, 2025
1 parent 2ce9c4d commit 1725469
Show file tree
Hide file tree
Showing 23 changed files with 21 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,12 @@ class LP_TRANSFORMATIONS_API LayerTransformation : public ov::pass::MatcherPass

protected:
std::shared_ptr<ov::Node> moveDequantizationAfter(
TransformationContext &context,
const std::shared_ptr<ov::Node>& operation,
const FakeQuantizeDequantization& dequantization,
const bool updateOutputPrecision = true,
const bool moveSubtract = true) const;

std::shared_ptr<ov::Node> moveDequantizationBefore(
TransformationContext& context,
const std::shared_ptr<ov::Node>& operation,
const FakeQuantizeDequantization& dequantization,
const bool moveSubtract = true) const;
Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/avg_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ bool AvgPoolTransformation::transform(TransformationContext& context, ov::pass::

const std::shared_ptr<Node> pooling = NetworkHelper::separateInStandaloneBranch(m.get_match_root(), defaultPrecisions);
const bool updatePrecision = isPrecisionPreserved(pooling);
const auto newOperation = moveDequantizationAfter(context, pooling, NetworkHelper::getDequantization(pooling, defaultPrecisions), updatePrecision);
const auto newOperation = moveDequantizationAfter(pooling, NetworkHelper::getDequantization(pooling, defaultPrecisions), updatePrecision);

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bool BatchToSpaceTransformation::transform(TransformationContext& context, ov::p
}

const std::shared_ptr<Node> op = NetworkHelper::separateInStandaloneBranch(m.get_match_root(), defaultPrecisions);
const auto newOperation = moveDequantizationAfter(context, op, NetworkHelper::getDequantization(op, defaultPrecisions));
const auto newOperation = moveDequantizationAfter(op, NetworkHelper::getDequantization(op, defaultPrecisions));

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/clamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool ClampTransformation::transform(TransformationContext& context, ov::pass::pa
return false;
}

const auto newClamp = ov::as_type_ptr<ov::opset1::Clamp>(moveDequantizationAfter(context, clamp, dequantization, false, moveSubtract));
const auto newClamp = ov::as_type_ptr<ov::opset1::Clamp>(moveDequantizationAfter(clamp, dequantization, false, moveSubtract));

std::shared_ptr<ov::opset1::Clamp> replacement;
{
Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/gather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ bool GatherTransformation::transform(TransformationContext& context, ov::pass::p
replace_node(dequantization.subtractConstant, newConstant);
}

const auto newOperation = moveDequantizationAfter(context, gather, NetworkHelper::getDequantization(gather, defaultPrecisions));
const auto newOperation = moveDequantizationAfter(gather, NetworkHelper::getDequantization(gather, defaultPrecisions));

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool InterpolateTransformation::transform(TransformationContext &context, ov::pa
return false;
}
interpolate = NetworkHelper::separateInStandaloneBranch(interpolate, defaultPrecisions);
const auto newOperation = moveDequantizationAfter(context, interpolate, NetworkHelper::getDequantization(interpolate, defaultPrecisions));
const auto newOperation = moveDequantizationAfter(interpolate, NetworkHelper::getDequantization(interpolate, defaultPrecisions));

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ DataPrecision LayerTransformation::getDataPrecision(
}

std::shared_ptr<ov::Node> LayerTransformation::moveDequantizationAfter(
TransformationContext &context,
const std::shared_ptr<ov::Node>& operation,
const FakeQuantizeDequantization& dequantization,
const bool updateOutputPrecision,
Expand All @@ -409,7 +408,6 @@ std::shared_ptr<ov::Node> LayerTransformation::moveDequantizationAfter(
}

std::shared_ptr<ov::Node> LayerTransformation::moveDequantizationBefore(
TransformationContext& context,
const std::shared_ptr<ov::Node>& operation,
const FakeQuantizeDequantization& dequantization,
const bool moveSubtract) const {
Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/max_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool MaxPoolTransformation::transform(TransformationContext& context, ov::pass::
}

const std::shared_ptr<Node> pooling = NetworkHelper::separateInStandaloneBranch(m.get_match_root(), defaultPrecisions);
const auto newOperation = moveDequantizationAfter(context, pooling, NetworkHelper::getDequantization(pooling, defaultPrecisions));
const auto newOperation = moveDequantizationAfter(pooling, NetworkHelper::getDequantization(pooling, defaultPrecisions));

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ bool MoveFakeQuantize::transform(TransformationContext& context, ov::pass::patte
newConcat->set_friendly_name(concat->get_friendly_name());
NetworkHelper::copyInfo(concat, newConcat);
if (!dequantization.empty()) {
moveDequantizationBefore(context, newConcat, dequantization);
moveDequantizationBefore(newConcat, dequantization);
return true;
}
replace_node(fq, newConcat);
Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/pad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ bool PadTransformation::transform(TransformationContext& context, ov::pass::patt
const auto convertedZero = ov::opset1::Constant::create(dequantization.data.get_element_type(), Shape{}, { padConstantValue });
pad->set_argument(3, convertedZero);

const auto newOperation = moveDequantizationAfter(context, pad, dequantization);
const auto newOperation = moveDequantizationAfter(pad, dequantization);

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/prelu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bool PReluTransformation::transform(TransformationContext& context, ov::pass::pa

prelu = NetworkHelper::separateInStandaloneBranch(prelu, defaultPrecisions);
const FakeQuantizeDequantization dequantization = NetworkHelper::getDequantization(prelu, defaultPrecisions, 0);
const auto newOperation = moveDequantizationAfter(context, prelu, dequantization, false, false);
const auto newOperation = moveDequantizationAfter(prelu, dequantization, false, false);

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void RecurrentCellTransformation::propagate(TransformationContext& context, cons
if (dequantization.empty()) {
return;
}
const auto& new_node = moveDequantizationAfter(context, normalized_node, dequantization);
const auto& new_node = moveDequantizationAfter(normalized_node, dequantization);

const auto& new_dequantization = NetworkHelper::getDequantizationBelow(new_node);
if (new_dequantization.empty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bool ReduceBaseTransformation::transform(TransformationContext& context, ov::pas

// updatePrecision depends on type and parameters of the reduce
const bool updatePrecision = getUpdatePrecision(reduce);
const auto newOperation = moveDequantizationAfter(context, reduce, dequantization, updatePrecision);
const auto newOperation = moveDequantizationAfter(reduce, dequantization, updatePrecision);

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/relu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bool ReluTransformation::transform(TransformationContext& context, ov::pass::pat

relu = NetworkHelper::separateInStandaloneBranch(relu, defaultPrecisions);
const FakeQuantizeDequantization dequantization = NetworkHelper::getDequantization(relu, defaultPrecisions, 0);
const auto newOperation = moveDequantizationAfter(context, relu, dequantization);
const auto newOperation = moveDequantizationAfter(relu, dequantization);

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/reshape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ bool ReshapeTransformation::transform(TransformationContext& context, ov::pass::

reshape = ov::as_type_ptr<ov::opset1::Reshape>(NetworkHelper::separateInStandaloneBranch(reshape, defaultPrecisions));
reshapeDequantizationConstant(reshape, defaultPrecisions);
const auto newOperation = moveDequantizationAfter(context, reshape, NetworkHelper::getDequantization(reshape, defaultPrecisions, 0));
const auto newOperation = moveDequantizationAfter(reshape, NetworkHelper::getDequantization(reshape, defaultPrecisions, 0));

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ bool ShuffleChannelsTransformation::transform(TransformationContext& context, ov
replace_node(dequantization.multiplyConstant, shuffledMulConst);
dequantization.multiplyConstant = shuffledMulConst;

const auto newOperation = moveDequantizationAfter(context, shuffleChannels, dequantization);
const auto newOperation = moveDequantizationAfter(shuffleChannels, dequantization);

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/slice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bool SliceTransformation::transform(TransformationContext& context, ov::pass::pa
}

const auto strided_slice = NetworkHelper::separateInStandaloneBranch(m.get_match_root(), defaultPrecisions);
const auto newOperation = moveDequantizationAfter(context, strided_slice, NetworkHelper::getDequantization(strided_slice, defaultPrecisions));
const auto newOperation = moveDequantizationAfter(strided_slice, NetworkHelper::getDequantization(strided_slice, defaultPrecisions));

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bool SpaceToBatchTransformation::transform(TransformationContext& context, ov::p
}

const std::shared_ptr<Node> op = NetworkHelper::separateInStandaloneBranch(m.get_match_root(), defaultPrecisions);
const auto newOperation = moveDequantizationAfter(context, op, NetworkHelper::getDequantization(op, defaultPrecisions));
const auto newOperation = moveDequantizationAfter(op, NetworkHelper::getDequantization(op, defaultPrecisions));

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/squeeze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ bool SqueezeTransformation::transform(TransformationContext& context, ov::pass::
replace_node(dequantization.subtractConstant, newConstant);
}

const auto newOperation = moveDequantizationAfter(context, squeeze, NetworkHelper::getDequantization(squeeze, defaultPrecisions));
const auto newOperation = moveDequantizationAfter(squeeze, NetworkHelper::getDequantization(squeeze, defaultPrecisions));

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ bool StridedSliceTransformation::transform(TransformationContext& context, ov::p
replace_node(dequantization.multiplyConstant, new_mul_const);
dequantization.multiplyConstant = new_mul_const;

const auto newOperation = moveDequantizationAfter(context, strided_slice, NetworkHelper::getDequantization(strided_slice, defaultPrecisions));
const auto newOperation = moveDequantizationAfter(strided_slice, NetworkHelper::getDequantization(strided_slice, defaultPrecisions));

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bool TransparentBaseTransformation::transform(TransformationContext& context, ov
}

op = NetworkHelper::separateInStandaloneBranch(op, defaultPrecisions);
const auto newOperation = moveDequantizationAfter(context, op, NetworkHelper::getDequantization(op, defaultPrecisions));
const auto newOperation = moveDequantizationAfter(op, NetworkHelper::getDequantization(op, defaultPrecisions));

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/transpose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ bool TransposeTransformation::transform(TransformationContext& context, ov::pass

transpose = NetworkHelper::separateInStandaloneBranch(transpose, defaultPrecisions);
transposeDequantizationConstant(transpose, defaultPrecisions);
const auto newOperation = moveDequantizationAfter(context, transpose, NetworkHelper::getDequantization(transpose, defaultPrecisions, 0));
const auto newOperation = moveDequantizationAfter(transpose, NetworkHelper::getDequantization(transpose, defaultPrecisions, 0));

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/common/low_precision_transformations/src/unsqueeze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ bool UnsqueezeTransformation::transform(TransformationContext& context, ov::pass
replace_node(dequantization.subtractConstant, newConstant);
}

const auto newOperation = moveDequantizationAfter(context, unsqueeze, NetworkHelper::getDequantization(unsqueeze, defaultPrecisions));
const auto newOperation = moveDequantizationAfter(unsqueeze, NetworkHelper::getDequantization(unsqueeze, defaultPrecisions));

OPENVINO_DEBUG("LPT: done: ", newOperation);
return true;
Expand Down

0 comments on commit 1725469

Please sign in to comment.