Skip to content

Commit

Permalink
using ReduceL1 and ReduceL2 ops in onnx importer, fix comment in Redu…
Browse files Browse the repository at this point in the history
…ceL1 definition
  • Loading branch information
blesniewski committed Aug 19, 2020
1 parent 6ab61c1 commit f51b3f8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
1 change: 0 additions & 1 deletion ngraph/core/include/ngraph/op/reduce_l1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ namespace ngraph
///
/// \param arg The tensor to be reduced.
/// \param reduction_axes The axis positions (0-based) to be eliminated.
/// \param p The scalar defining the order of normalization.
/// \param keep_dims If set to true it holds axes that are used for reduction.
ReduceL1(const Output<Node>& arg,
const Output<Node>& reduction_axes,
Expand Down
28 changes: 12 additions & 16 deletions ngraph/frontend/onnx_import/src/op/reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,24 @@ namespace ngraph

OutputVector reduce_l1(const Node& node)
{
auto l1_norm_reduction = [](const Output<ngraph::Node>& node,
const ngraph::AxisSet& axis_set) {
const auto axis_set_const = default_opset::Constant::create(
element::i64, {axis_set.size()}, axis_set.to_vector());
return ngraph::builder::opset1::l1_norm(node, axis_set_const, 0.f);
};

return {reduction::make_ng_reduction_op(
node, node.get_ng_inputs().at(0), l1_norm_reduction)};
node,
node.get_ng_inputs().at(0),
std::make_shared<default_opset::ReduceL1,
const Output<ngraph::Node>&,
const Output<ngraph::Node>&,
bool>)};
}

OutputVector reduce_l2(const Node& node)
{
auto l2_norm_reduction = [](const Output<ngraph::Node>& node,
const ngraph::AxisSet& axis_set) {
const auto axis_set_const = default_opset::Constant::create(
element::i64, {axis_set.size()}, axis_set.to_vector());
return ngraph::builder::opset1::l2_norm(
node, axis_set_const, 0.f, ngraph::builder::BiasMode::ADD, false);
};
return {reduction::make_ng_reduction_op(
node, node.get_ng_inputs().at(0), l2_norm_reduction)};
node,
node.get_ng_inputs().at(0),
std::make_shared<default_opset::ReduceL2,
const Output<ngraph::Node>&,
const Output<ngraph::Node>&,
bool>)};
}

OutputVector reduce_max(const Node& node)
Expand Down

0 comments on commit f51b3f8

Please sign in to comment.