normalize_l2.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 <memory>
20 
21 #include "ngraph/node.hpp"
22 #include "ngraph/op/util/attr_types.hpp"
23 #include "ngraph/op/util/fused_op.hpp"
24 
25 NGRAPH_SUPPRESS_DEPRECATED_START
26 
27 namespace ngraph
28 {
29  namespace op
30  {
31  namespace v0
32  {
33  /// \brief Normalization input tensor with L2 norm.
34  ///
35  class NGRAPH_API NormalizeL2 : public ngraph::op::util::FusedOp
36  {
37  public:
38  static constexpr NodeTypeInfo type_info{"NormalizeL2", 0};
39  const NodeTypeInfo& get_type_info() const override { return type_info; }
40  NormalizeL2() = default;
41  ///
42  /// \brief Constructs a Normalize operation.
43  ///
44  /// \param data - Node producing the input tensor
45  /// \param axes - Node indicating axes along which reduction is
46  /// calculated
47  /// \param eps - The epsilon added to L2 norm.
48  /// \param eps_mode - Specifies how eps is combined with L2 value
49  /// calculated
50  /// before division
51  ///
52  NormalizeL2(const Output<Node>& data,
53  const Output<Node>& axes,
54  float eps,
55  EpsMode eps_mode);
56 
57  bool visit_attributes(AttributeVisitor& visitor) override;
58  float get_eps() const { return m_eps; }
59  EpsMode get_eps_mode() const { return m_eps_mode; }
60  virtual OutputVector decompose_op() const override;
61  virtual void pre_validate_and_infer_types() override;
62  AxisSet get_reduction_axes() const;
63 
64  virtual std::shared_ptr<Node>
65  clone_with_new_inputs(const OutputVector& new_args) const override;
66 
67  protected:
68  float m_eps;
69  EpsMode m_eps_mode;
70  };
71  }
72  using v0::NormalizeL2;
73  }
74 }
75 
76 NGRAPH_SUPPRESS_DEPRECATED_END
ngraph::AxisSet
A set of axes.
Definition: axis_set.hpp:31
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
ngraph::op::EpsMode
EpsMode
Specifies how eps is combined with L2 value.
Definition: attr_types.hpp:238
ngraph::AttributeVisitor
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:70
ngraph::op::v0::NormalizeL2
Normalization input tensor with L2 norm.
Definition: normalize_l2.hpp:36
ngraph::op::v0::NormalizeL2::NormalizeL2
NormalizeL2(const Output< Node > &data, const Output< Node > &axes, float eps, EpsMode eps_mode)
Constructs a Normalize operation.