reduce_l1.hpp
1 //*****************************************************************************
2 // Copyright 2017-2020 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //*****************************************************************************
16 
17 #pragma once
18 
19 #include "ngraph/op/util/arithmetic_reductions_keep_dims.hpp"
20 
21 namespace ngraph
22 {
23  namespace op
24  {
25  namespace v4
26  {
27  /// \brief Reduction operation using L1 norm: L1(x) = sum(abs(x)) if all dimensions are
28  /// specified for the normalisation.
29  ///
30  /// Reduces the tensor, eliminating the specified reduction axes by taking the L1-norm.
31  class NGRAPH_API ReduceL1 : public util::ArithmeticReductionKeepDims
32  {
33  public:
34  static constexpr NodeTypeInfo type_info{"ReduceL1", 4};
35  const NodeTypeInfo& get_type_info() const override { return type_info; }
36  /// \brief Constructs a reducet L1-norm operation.
37  ReduceL1() = default;
38  /// \brief Constructs a reduce L1-norm operation.
39  ///
40  /// \param arg The tensor to be reduced.
41  /// \param reduction_axes The axis positions (0-based) to be eliminated.
42  /// \param keep_dims If set to true it holds axes that are used for reduction.
43  ReduceL1(const Output<Node>& arg,
44  const Output<Node>& reduction_axes,
45  bool keep_dims = false);
46 
47  size_t get_version() const override { return 4; }
48  /// \return The default value for Reduce.
49  virtual std::shared_ptr<Node> get_default_value() const override;
50 
51  virtual std::shared_ptr<Node>
52  clone_with_new_inputs(const OutputVector& new_args) const override;
53 
54  bool evaluate(const HostTensorVector& outputs,
55  const HostTensorVector& inputs) const override;
56  };
57  }
58  }
59 }
ngraph::op::v4::ReduceL1::ReduceL1
ReduceL1()=default
Constructs a reducet L1-norm operation.
ngraph::op::v4::ReduceL1::get_version
size_t get_version() const override
Definition: reduce_l1.hpp:47
ngraph::op::util::ArithmeticReductionKeepDims
Definition: arithmetic_reductions_keep_dims.hpp:29
ngraph::op::v4::ReduceL1::get_type_info
const NodeTypeInfo & get_type_info() const override
Definition: reduce_l1.hpp:35
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
ngraph::op::v4::ReduceL1
Reduction operation using L1 norm: L1(x) = sum(abs(x)) if all dimensions are specified for the normal...
Definition: reduce_l1.hpp:32
ngraph::op::v4::ReduceL1::get_default_value
virtual std::shared_ptr< Node > get_default_value() const override
ngraph::op::v4::ReduceL1::ReduceL1
ReduceL1(const Output< Node > &arg, const Output< Node > &reduction_axes, bool keep_dims=false)
Constructs a reduce L1-norm operation.