add.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/op/util/binary_elementwise_arithmetic.hpp"
22 
23 namespace ngraph
24 {
25  namespace op
26  {
27  namespace v0
28  {
29  /// \brief Elementwise addition operation.
30  ///
31  class NGRAPH_DEPRECATED(
32  "This operation is deprecated and will be removed soon. Use v1::Add instead of it.")
33  NGRAPH_API Add : public util::BinaryElementwiseArithmetic
34  {
35  NGRAPH_SUPPRESS_DEPRECATED_START
36  public:
37  static constexpr NodeTypeInfo type_info{"Add", 0};
38  const NodeTypeInfo& get_type_info() const override { return type_info; }
39  /// \brief Constructs an uninitialized addition operation
40  Add()
41  : util::BinaryElementwiseArithmetic(AutoBroadcastSpec::NONE)
42  {
43  }
44 
45  /// \brief Constructs an addition operation.
46  ///
47  /// \param arg0 Output that produces the first input tensor.<br>
48  /// `[d0, ...]`
49  /// \param arg1 Output that produces the second input tensor.<br>
50  /// `[d0, ...]`
51  /// \param auto_broadcast Auto broadcast specification
52  ///
53  /// Output `[d0, ...]`
54  ///
55  Add(const Output<Node>& arg0,
56  const Output<Node>& arg1,
57  const AutoBroadcastSpec& auto_broadcast = AutoBroadcastSpec());
58 
59  std::shared_ptr<Node>
60  clone_with_new_inputs(const OutputVector& new_args) const override;
61 
62  bool visit_attributes(AttributeVisitor& visitor) override;
63  bool evaluate(const HostTensorVector& outputs,
64  const HostTensorVector& inputs) const override;
65  NGRAPH_SUPPRESS_DEPRECATED_END
66  };
67  } // namespace v0
68 
69  namespace v1
70  {
71  /// \brief Elementwise addition operation.
72  ///
73  class NGRAPH_API Add : public util::BinaryElementwiseArithmetic
74  {
75  public:
76  NGRAPH_RTTI_DECLARATION;
77 
78  /// \brief Constructs an uninitialized addition operation
79  Add()
80  : util::BinaryElementwiseArithmetic(AutoBroadcastSpec::NUMPY)
81  {
82  }
83 
84  /// \brief Constructs an addition operation.
85  ///
86  /// \param arg0 Output that produces the first input tensor.<br>
87  /// `[d0, ...]`
88  /// \param arg1 Output that produces the second input tensor.<br>
89  /// `[d0, ...]`
90  /// \param auto_broadcast Auto broadcast specification. Default is Numpy-style
91  /// implicit broadcasting.
92  ///
93  /// Output `[d0, ...]`
94  ///
95  Add(const Output<Node>& arg0,
96  const Output<Node>& arg1,
97  const AutoBroadcastSpec& auto_broadcast =
98  AutoBroadcastSpec(AutoBroadcastType::NUMPY));
99 
100  std::shared_ptr<Node>
101  clone_with_new_inputs(const OutputVector& new_args) const override;
102  bool visit_attributes(AttributeVisitor& visitor) override;
103  size_t get_version() const override { return 1; }
104  bool evaluate(const HostTensorVector& outputs,
105  const HostTensorVector& inputs) const override;
106  };
107 
108  } // namespace v1
109  NGRAPH_SUPPRESS_DEPRECATED_START
110  using v0::Add;
111  NGRAPH_SUPPRESS_DEPRECATED_END
112  } // namespace op
113 
114  NGRAPH_DEPRECATED("This operator was deprecated and will be removed with v0 operation.")
115  NGRAPH_API
116  std::shared_ptr<Node> operator+(const Output<Node>& arg0, const Output<Node>& arg1);
117 } // namespace ngraph
ngraph::op::v1::Add
Elementwise addition operation.
Definition: add.hpp:74
ngraph::op::AutoBroadcastSpec
Implicit broadcast specification.
Definition: attr_types.hpp:321
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
ngraph::op::v1::Add::Add
Add()
Constructs an uninitialized addition operation.
Definition: add.hpp:79
ngraph::AttributeVisitor
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:70
ngraph::op::util::BinaryElementwiseArithmetic
Abstract base class for elementwise binary arithmetic operations, i.e., operations where the same sca...
Definition: binary_elementwise_arithmetic.hpp:55
ngraph::op::v1::Add::Add
Add(const Output< Node > &arg0, const Output< Node > &arg1, const AutoBroadcastSpec &auto_broadcast=AutoBroadcastSpec(AutoBroadcastType::NUMPY))
Constructs an addition operation.
ngraph::op::v1::Add::get_version
size_t get_version() const override
Definition: add.hpp:103