Skip to content

Commit

Permalink
[LPT] FQ decomposition in common pass manager - exporation #5
Browse files Browse the repository at this point in the history
  • Loading branch information
eshoguli committed Jun 24, 2021
1 parent 6bb43a7 commit c73b161
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LP_TRANSFORMATIONS_API FakeQuantizeTransformation : public LayerTransforma
private:
std::shared_ptr<opset1::FakeQuantize> fuseElementwise(
TransformationContext& context,
MatcherPass& matcherPass,
MatcherPass* matcherPass,
const std::shared_ptr<opset1::FakeQuantize>& fakeQuantize) const;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ bool FakeQuantizeTransformation::transform(TransformationContext& context, ngrap
bool wasHandled = false;
std::shared_ptr<opset1::FakeQuantize> fakeQuantize = layer;
do {
fakeQuantize = fuseElementwise(context, *this, fakeQuantize);
fakeQuantize = fuseElementwise(context, this, fakeQuantize);
wasHandled = wasHandled || (fakeQuantize != nullptr);
} while (fakeQuantize != nullptr);

Expand Down Expand Up @@ -127,7 +127,7 @@ bool FakeQuantizeTransformation::checkElementwise(const std::shared_ptr<Node>& e

std::shared_ptr<opset1::FakeQuantize> FakeQuantizeTransformation::fuseElementwise(
TransformationContext& context,
MatcherPass& matcherPass,
MatcherPass* matcherPass,
const std::shared_ptr<opset1::FakeQuantize>& fakeQuantize) const {
const std::shared_ptr<Node> eltwise = fakeQuantize->get_input_node_shared_ptr(0);

Expand Down Expand Up @@ -198,7 +198,7 @@ std::shared_ptr<opset1::FakeQuantize> FakeQuantizeTransformation::fuseElementwis
foldConvert(fakeQuantize->input_value(3), deqPrecision),
foldConvert(fakeQuantize->input_value(4), deqPrecision) }));

matcherPass.register_new_node(newFakeQuantize);
matcherPass->register_new_node(newFakeQuantize);

replace_node(fakeQuantize, newFakeQuantize);
ngraph::copy_runtime_info({ fakeQuantize, eltwise }, newFakeQuantize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ DataPrecision getDataPrecisionByOutputPort(std::shared_ptr<opset1::FakeQuantize>

// TODO: LPT: refactor: use one way to decompose FakeQuantize
std::shared_ptr<ngraph::Node> decomposeFakeQuantize(
MatcherPass* matcherPass,
std::shared_ptr<opset1::FakeQuantize>& layer,
const std::shared_ptr<IntervalsAlignmentAttribute>& intervalsAlignment,
const DataPrecision& dataPrecision,
Expand Down Expand Up @@ -196,6 +197,7 @@ std::shared_ptr<ngraph::Node> decomposeFakeQuantize(
roundf(updatedOutputLowValue),
roundf(updatedOutputHighValue),
false);
matcherPass->register_new_node(newFakeQuantizeLayer);
newFakeQuantizeLayer->set_levels(levels);

auto dequantization = ngraph::pass::low_precision::NetworkHelper::makeDequantization(
Expand Down Expand Up @@ -232,6 +234,7 @@ std::shared_ptr<ngraph::Node> decomposeFakeQuantize(
dataPrecision.hasZeroPoint,
updatePrecisions);

matcherPass->register_new_node(std::get<0>(QDQ));
dequantize = std::get<1>(QDQ);
}

Expand Down Expand Up @@ -375,6 +378,7 @@ bool FakeQuantizeDecompositionTransformation::transform(TransformationContext& c
}

std::shared_ptr<ngraph::Node> dequantize = fq_decomposition::decomposeFakeQuantize(
this,
layer,
intervalsAlignment,
dataPrecision,
Expand Down

0 comments on commit c73b161

Please sign in to comment.