add.hpp
1 //*****************************************************************************
2 // Copyright 2017-2021 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 v1
28  {
29  /// \brief Elementwise addition operation.
30  ///
31  class NGRAPH_API Add : public util::BinaryElementwiseArithmetic
32  {
33  public:
34  NGRAPH_RTTI_DECLARATION;
35 
36  /// \brief Constructs an uninitialized addition operation
37  Add()
38  : util::BinaryElementwiseArithmetic(AutoBroadcastSpec::NUMPY)
39  {
40  }
41 
42  /// \brief Constructs an addition operation.
43  ///
44  /// \param arg0 Output that produces the first input tensor.<br>
45  /// `[d0, ...]`
46  /// \param arg1 Output that produces the second input tensor.<br>
47  /// `[d0, ...]`
48  /// \param auto_broadcast Auto broadcast specification. Default is Numpy-style
49  /// implicit broadcasting.
50  ///
51  /// Output `[d0, ...]`
52  ///
53  Add(const Output<Node>& arg0,
54  const Output<Node>& arg1,
55  const AutoBroadcastSpec& auto_broadcast =
56  AutoBroadcastSpec(AutoBroadcastType::NUMPY));
57 
58  std::shared_ptr<Node>
59  clone_with_new_inputs(const OutputVector& new_args) const override;
60 
61  bool visit_attributes(AttributeVisitor& visitor) override;
62 
63  size_t get_version() const override { return 1; }
64  bool evaluate(const HostTensorVector& outputs,
65  const HostTensorVector& inputs) const override;
66  };
67  } // namespace v1
68  } // namespace op
69 } // namespace ngraph
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:71
A handle for one of a node's outputs.
Definition: node_output.hpp:42
Abstract base class for elementwise binary arithmetic operations, i.e., operations where the same sca...
Definition: binary_elementwise_arithmetic.hpp:55
Elementwise addition operation.
Definition: add.hpp:32
Add(const Output< Node > &arg0, const Output< Node > &arg1, const AutoBroadcastSpec &auto_broadcast=AutoBroadcastSpec(AutoBroadcastType::NUMPY))
Constructs an addition operation.
Add()
Constructs an uninitialized addition operation.
Definition: add.hpp:37
size_t get_version() const override
Definition: add.hpp:63
bool evaluate(const HostTensorVector &outputs, const HostTensorVector &inputs) const override
Evaluates the op on input_values putting results in output_values.
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
Implicit broadcast specification.
Definition: attr_types.hpp:323