Skip to content

Commit

Permalink
[LPT] FQ decomposition in common pass manager - exporation #3
Browse files Browse the repository at this point in the history
  • Loading branch information
eshoguli committed Jun 24, 2021
1 parent b2f569b commit e218c13
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,14 @@ std::shared_ptr<opset1::FakeQuantize> FakeQuantizeTransformation::fuseElementwis
const auto data = fq::getData(eltwise);
const size_t outputIdx = NetworkHelper::getParentOutputIndex(data, eltwise);

std::shared_ptr<opset1::FakeQuantize> newFakeQuantize = matcherPass.register_new_node<opset1::FakeQuantize>(
std::shared_ptr<opset1::FakeQuantize> newFakeQuantize = as_type_ptr<opset1::FakeQuantize>(fakeQuantize->clone_with_new_inputs({
data->output(outputIdx),
inputLowConst_f32,
inputHighConst_f32,
foldConvert(fakeQuantize->input_value(3), deqPrecision),
foldConvert(fakeQuantize->input_value(4), deqPrecision),
fakeQuantize->get_levels(),
fakeQuantize->get_auto_broadcast());
foldConvert(fakeQuantize->input_value(4), deqPrecision) }));

matcherPass.register_new_node(newFakeQuantize);

replace_node(fakeQuantize, newFakeQuantize);
ngraph::copy_runtime_info({ fakeQuantize, eltwise }, newFakeQuantize);
Expand Down
7 changes: 7 additions & 0 deletions ngraph/core/include/ngraph/pass/graph_rewrite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ namespace ngraph
return node;
}

template <typename T>
std::shared_ptr<T> register_new_node(const std::shared_ptr<T>& node)
{
m_new_nodes.push_back(node);
return node;
}

const std::vector<std::shared_ptr<ngraph::Node>>& get_new_nodes()
{
return m_new_nodes;
Expand Down

0 comments on commit e218c13

Please sign in to comment.