power.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 "ngraph/op/util/binary_elementwise_arithmetic.hpp"
20 
21 namespace ngraph
22 {
23  namespace op
24  {
25  namespace v1
26  {
27  // clang-format off
28  /// \brief Elementwise exponentiation operation.
29  ///
30  /// ## Inputs
31  ///
32  /// | | Type | Description |
33  /// | ------ | --------------------------------- | ------------------------------------------------------ |
34  /// | `arg0` | \f$N[d_1,\dots,d_n]~(n \geq 0)\f$ | A tensor of any shape and numeric element type. |
35  /// | `arg1` | \f$N[d_1,\dots,d_n]~(n \geq 0)\f$ | A tensor of the same shape and element type as `arg0`. |
36  ///
37  /// ## Output
38  ///
39  /// | Type | Description |
40  /// | ---------------------- | -------------------------------------------------------------------------------------------------------------- |
41  /// | \f$N[d_1,\dots,d_n]\f$ | The tensor \f$T\f$, where \f$T[i_1,\dots,i_n] = \texttt{arg0}[i_1,\dots,i_n]^{\texttt{arg1}[i_1,\dots,i_n]}\f$ |
42  // clang-format on
43  class NGRAPH_API Power : public util::BinaryElementwiseArithmetic
44  {
45  public:
46  static constexpr NodeTypeInfo type_info{"Power", 1};
47  const NodeTypeInfo& get_type_info() const override { return type_info; }
48  Power()
49  : util::BinaryElementwiseArithmetic(AutoBroadcastSpec::NUMPY)
50  {
51  }
52 
53  /// \brief Constructs an exponentiation operation.
54  ///
55  /// \param arg0 Node that produces the first input tensor.
56  /// \param arg1 Node that produces the second input tensor.
57  /// \param auto_broadcast Auto broadcast specification
58  Power(const Output<Node>& arg0,
59  const Output<Node>& arg1,
60  const AutoBroadcastSpec& auto_broadcast =
61  AutoBroadcastSpec(AutoBroadcastType::NUMPY));
62 
63  virtual std::shared_ptr<Node>
64  clone_with_new_inputs(const OutputVector& new_args) const override;
65  bool evaluate(const HostTensorVector& outputs,
66  const HostTensorVector& inputs) const override;
67  };
68  } // namespace v1
69  }
70 }
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 exponentiation operation.
Definition: power.hpp:44
const NodeTypeInfo & get_type_info() const override
Definition: power.hpp:47
Power(const Output< Node > &arg0, const Output< Node > &arg1, const AutoBroadcastSpec &auto_broadcast=AutoBroadcastSpec(AutoBroadcastType::NUMPY))
Constructs an exponentiation operation.
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
Definition: type.hpp:39
Implicit broadcast specification.
Definition: attr_types.hpp:323