Skip to content

Commit

Permalink
[LPT] code style fix
Browse files Browse the repository at this point in the history
  • Loading branch information
v-Golubev committed Jul 17, 2020
1 parent ba8832c commit 188102e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void ClampTransformation::registerMatcherIn(GraphRewrite& pass, TransformationCo
}

void ClampTransformation::transform(TransformationContext& context, ngraph::pattern::Matcher& m) const {
if(!canBeTransformed(context, m.get_match_root())) {
if (!canBeTransformed(context, m.get_match_root())) {
return;
}
const std::shared_ptr<Node> clamp = separateInStandaloneBranch(m.get_match_root());
Expand Down Expand Up @@ -47,7 +47,9 @@ void ClampTransformation::transform(TransformationContext& context, ngraph::patt
auto replacement = std::make_shared<ngraph::opset1::Clamp>(newClamp->get_input_node_shared_ptr(0), min, max);
replace_node(newClamp, replacement);

element::Type outputClampType = dequantization.multiply ? dequantization.multiply->get_output_element_type(0) : dequantization.subtract->get_output_element_type(0);
element::Type outputClampType = dequantization.multiply ?
dequantization.multiply->get_output_element_type(0) :
dequantization.subtract->get_output_element_type(0);
ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(replacement, outputClampType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
#include "simple_low_precision_transformer.hpp"
#include "ngraph_functions/low_precision_transformations/clamp_function.hpp"

//TODO: remove after debugging
#include <ngraph/pass/visualize_tree.hpp>


using namespace testing;
using namespace ngraph::pass;
Expand Down Expand Up @@ -54,18 +51,15 @@ class ClampTransformation : public LayerTransformation, public testing::WithPara

SimpleLowPrecisionTransformer transform;
transform.add<ngraph::pass::low_precision::ClampTransformation, ngraph::opset1::Clamp>(testValues.params);
// ngraph::pass::VisualizeTree("C:\\models\\clamp2\\clamp.original").run_on_module(std::vector<std::shared_ptr<ngraph::Function>>{ actualFunction });
transform.transform(actualFunction); // <-- it's my function
// ngraph::pass::VisualizeTree("C:\\models\\clamp2\\clamp.transformed").run_on_module(std::vector<std::shared_ptr<ngraph::Function>>{ actualFunction });

transform.transform(actualFunction);

referenceFunction = ngraph::builder::subgraph::ClampFunction::getReference(precision,
shape,
{
testValues.params.updatePrecisions ? testValues.params.precisionsOnActivations[0] : precision,
testValues.subtractValues,
testValues.multiplyValues
});
// ngraph::pass::VisualizeTree("C:\\models\\clamp2\\clamp.reference").run_on_module(std::vector<std::shared_ptr<ngraph::Function>>{ referenceFunction });
}

static std::string getTestCaseName(testing::TestParamInfo<ClampTransformationParams> obj) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ namespace subgraph {
parent = convert;

if (!values.subtractValues.empty()) {
auto constant = std::make_shared<ngraph::opset1::Constant>(originalFunctionPrecision, Shape({ values.subtractValues.size() }), values.subtractValues);
auto constant = std::make_shared<ngraph::opset1::Constant>(originalFunctionPrecision,
Shape({ values.subtractValues.size() }), values.subtractValues);
const std::shared_ptr<ngraph::Node> subtract = std::make_shared<ngraph::opset1::Subtract>(
parent,
constant);
Expand Down Expand Up @@ -53,7 +54,6 @@ namespace subgraph {

parent = clamp;


if (!values.subtractValues.empty()) {
const std::shared_ptr<ngraph::Node> subtract = std::make_shared<op::TypeRelaxed<ngraph::opset1::Subtract>>(
parent,
Expand All @@ -71,7 +71,6 @@ namespace subgraph {
input = as_type_ptr<ngraph::opset1::Parameter>(replace_node(
input,
std::make_shared<ngraph::opset1::Parameter>(values.activationPrecision, ngraph::Shape(inputShape))));

}

ngraph::ResultVector results{ std::make_shared<ngraph::opset1::Result>(multiply) };
Expand Down

0 comments on commit 188102e

Please sign in to comment.