unary_elementwise_arithmetic.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/op.hpp"
20 
21 namespace ngraph
22 {
23  namespace op
24  {
25  namespace util
26  {
27  // clang-format off
28  /// \brief Abstract base class for elementwise unary arithmetic operations, i.e.,
29  /// operations where the same scalar arithmetic operation is applied to each
30  /// element.
31  ///
32  /// For example, if the underlying operation (determined by the subclass) is
33  /// \f$\mathit{op}(x)\f$, the input tensor \f$[[x,y],[z,w]]\f$ will be mapped to
34  /// \f$[[\mathit{op}(x),\mathit{op}(y)],[\mathit{op}(z),\mathit{op}(w)]]\f$.
35  ///
36  /// ## Inputs
37  ///
38  /// | | Type | Description |
39  /// | ----- | --------------------------------- | ------------------------------------------------------------------------ |
40  /// | `arg` | \f$N[d_1,\dots,d_n]~(n \geq 0)\f$ | A tensor of any shape. The element type \f$N\f$ may be any numeric type. |
41  ///
42  /// ## Output
43  ///
44  /// | Type | Description |
45  /// | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
46  /// | \f$N[d_1,\dots,d_n]\f$ | The tensor \f$T\f$, where \f$T[i_1,\dots,i_n] = \mathit{op}(\texttt{arg}[i_1,\dots,i_n])\f$. This will always have the same shape and element type as the input tensor. |
47  // clang-format on
48  class NGRAPH_API UnaryElementwiseArithmetic : public Op
49  {
50  protected:
51  /// \brief Constructs a unary elementwise arithmetic operation.
53  /// \brief Constructs a unary elementwise arithmetic operation.
54  ///
55  /// \param arg Output that produces the input tensor.
56  UnaryElementwiseArithmetic(const Output<Node>& arg);
57 
58  public:
59  void validate_and_infer_types() override;
60  bool visit_attributes(AttributeVisitor& visitor) override;
61 
62  private:
63  void validate_and_infer_elementwise_arithmetic();
64  };
65  }
66  }
67 }
ngraph::op::util::UnaryElementwiseArithmetic
Abstract base class for elementwise unary arithmetic operations, i.e., operations where the same scal...
Definition: unary_elementwise_arithmetic.hpp:49
ngraph::op::util::UnaryElementwiseArithmetic::UnaryElementwiseArithmetic
UnaryElementwiseArithmetic()
Constructs a unary elementwise arithmetic operation.
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
ngraph::op::util::UnaryElementwiseArithmetic::validate_and_infer_types
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
ngraph::AttributeVisitor
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:70
ngraph::op::util::UnaryElementwiseArithmetic::UnaryElementwiseArithmetic
UnaryElementwiseArithmetic(const Output< Node > &arg)
Constructs a unary elementwise arithmetic operation.
ngraph::op::Op
Root of all actual ops.
Definition: op.hpp:29