Commit 07fcc56b authored by Tomasz Dołbniak's avatar Tomasz Dołbniak Committed by Scott Cyphers

Use v1 ops in ONNX shrink (#4089)

Co-authored-by: 's avatarScott Cyphers <diyessi@users.noreply.github.com>
parent 972dd2f5
......@@ -18,10 +18,6 @@
#include "default_opset.hpp"
#include "exceptions.hpp"
#include "ngraph/op/add.hpp"
#include "ngraph/op/multiply.hpp"
#include "ngraph/op/subtract.hpp"
#include "ngraph/opsets/opset0.hpp"
#include "shrink.hpp"
namespace ngraph
......@@ -66,7 +62,7 @@ namespace ngraph
// by adding and subtracting bias
// All other values indicated by 'false' in the masks need to be zeroed out
std::shared_ptr<ngraph::Node> values_below_neg_lambd =
std::make_shared<ngraph::opset0::Less>(input, negative_lambd);
std::make_shared<default_opset::Less>(input, negative_lambd);
std::shared_ptr<ngraph::Node> values_above_pos_lambd =
std::make_shared<default_opset::Greater>(input, positive_lambd);
......@@ -77,15 +73,21 @@ namespace ngraph
values_above_pos_lambd = std::make_shared<default_opset::Convert>(
values_above_pos_lambd, input_element_type);
std::shared_ptr<ngraph::Node> input_minus_bias = input - bias_tensor;
std::shared_ptr<ngraph::Node> input_plus_bias = input + bias_tensor;
std::shared_ptr<ngraph::Node> input_minus_bias =
std::make_shared<default_opset::Subtract>(input, bias_tensor);
std::shared_ptr<ngraph::Node> input_plus_bias =
std::make_shared<default_opset::Add>(input, bias_tensor);
// multiply by the corresponding mask to zero-out the values within
// the <-lambd;lambd> range and keep the bias-adjusted values from outside of it
input_minus_bias = values_above_pos_lambd * input_minus_bias;
input_plus_bias = values_below_neg_lambd * input_plus_bias;
input_minus_bias = std::make_shared<default_opset::Multiply>(
values_above_pos_lambd, input_minus_bias);
return {input_plus_bias + input_minus_bias};
input_plus_bias = std::make_shared<default_opset::Multiply>(
values_below_neg_lambd, input_plus_bias);
return {
std::make_shared<default_opset::Add>(input_plus_bias, input_minus_bias)};
}
} // namespace set_1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment