equal.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/util/binary_elementwise_comparison.hpp"
20 
21 namespace ngraph
22 {
23  namespace op
24  {
25  namespace v0
26  {
27  // clang-format off
28  /// \brief Elementwise is-equal operation.
29  ///
30  /// ## Inputs
31  ///
32  /// | | Type | Description |
33  /// | ------ | --------------------------------- | ------------------------------------------------------ |
34  /// | `arg0` | \f$E[d_1,\dots,d_n]~(n \geq 0)\f$ | A tensor of any shape and element type. |
35  /// | `arg1` | \f$E[d_1,\dots,d_n]~(n \geq 0)\f$ | A tensor of the same shape and element type as `arg0`. |
36  /// | `autob`| AutoBroadcastSpec | Auto broadcast specification. |
37  ///
38  /// ## Output
39  ///
40  /// | Type | Description |
41  /// | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
42  /// | \f$\texttt{bool}[d_1,\dots,d_n]\f$ | The tensor \f$T\f$, where \f$T[i_1,\dots,i_n] = 1\text{ if }\texttt{arg0}[i_1,\dots,i_n] = \texttt{arg1}[i_1,\dots,i_n]\text{, else } 0\f$ |
43  // clang-format on
44  class NGRAPH_DEPRECATED(
45  "This operation is deprecated and will be removed soon. "
46  "Use v1::Equal instead of it.") NGRAPH_API Equal
47  : public util::BinaryElementwiseComparison
48  {
49  NGRAPH_SUPPRESS_DEPRECATED_START
50  public:
51  static constexpr NodeTypeInfo type_info{"Equal", 0};
52  const NodeTypeInfo& get_type_info() const override { return type_info; }
53  /// \brief Constructs an equal operation.
54  Equal()
55  : util::BinaryElementwiseComparison(AutoBroadcastSpec::NONE)
56  {
57  }
58  /// \brief Constructs an equal operation.
59  ///
60  /// \param arg0 Node that produces the first input tensor.
61  /// \param arg1 Node that produces the second input tensor.
62  /// \param auto_broadcast Auto broadcast specification
63  Equal(const Output<Node>& arg0,
64  const Output<Node>& arg1,
65  const AutoBroadcastSpec& auto_broadcast = AutoBroadcastSpec());
66 
67  virtual std::shared_ptr<Node>
68  clone_with_new_inputs(const OutputVector& new_args) const override;
69 
70  bool evaluate(const HostTensorVector& outputs,
71  const HostTensorVector& inputs) const override;
72  NGRAPH_SUPPRESS_DEPRECATED_END
73  };
74  } // namespace v0
75 
76  namespace v1
77  {
78  // clang-format off
79  /// \brief Elementwise is-equal operation.
80  ///
81  /// ## Inputs
82  ///
83  /// | | Type | Description |
84  /// | ------ | --------------------------------- | ------------------------------------------------------ |
85  /// | `arg0` | \f$E[d_1,\dots,d_n]~(n \geq 0)\f$ | A tensor of any shape and element type. |
86  /// | `arg1` | \f$E[d_1,\dots,d_n]~(n \geq 0)\f$ | A tensor of the same shape and element type as `arg0`. |
87  /// | `autob`| AutoBroadcastSpec | Auto broadcast specification. |
88  ///
89  /// ## Output
90  ///
91  /// | Type | Description |
92  /// | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
93  /// | \f$\texttt{bool}[d_1,\dots,d_n]\f$ | The tensor \f$T\f$, where \f$T[i_1,\dots,i_n] = 1\text{ if }\texttt{arg0}[i_1,\dots,i_n] = \texttt{arg1}[i_1,\dots,i_n]\text{, else } 0\f$ |
94  // clang-format on
95  class NGRAPH_API Equal : public util::BinaryElementwiseComparison
96  {
97  public:
98  NGRAPH_RTTI_DECLARATION;
99  /// \brief Constructs an equal operation.
101  : util::BinaryElementwiseComparison(AutoBroadcastSpec::NUMPY)
102  {
103  }
104  /// \brief Constructs an equal operation.
105  ///
106  /// \param arg0 Node that produces the first input tensor.
107  /// \param arg1 Node that produces the second input tensor.
108  /// \param auto_broadcast Auto broadcast specification
109  Equal(const Output<Node>& arg0,
110  const Output<Node>& arg1,
111  const AutoBroadcastSpec& auto_broadcast =
112  AutoBroadcastSpec(AutoBroadcastType::NUMPY));
113 
114  virtual std::shared_ptr<Node>
115  clone_with_new_inputs(const OutputVector& new_args) const override;
116 
117  bool evaluate(const HostTensorVector& outputs,
118  const HostTensorVector& inputs) const override;
119  };
120  } // namespace v1
121 
122  NGRAPH_SUPPRESS_DEPRECATED_START
123  using v0::Equal;
124  NGRAPH_SUPPRESS_DEPRECATED_END
125  }
126 }
ngraph::op::util::BinaryElementwiseComparison
Abstract base class for elementwise binary comparison operations, i.e., operations where the same sca...
Definition: binary_elementwise_comparison.hpp:55
ngraph::op::v1::Equal::Equal
Equal()
Constructs an equal operation.
Definition: equal.hpp:100
ngraph::op::AutoBroadcastSpec
Implicit broadcast specification.
Definition: attr_types.hpp:321
ngraph::op::v1::Equal
Elementwise is-equal operation.
Definition: equal.hpp:96
ngraph::op::v1::Equal::Equal
Equal(const Output< Node > &arg0, const Output< Node > &arg1, const AutoBroadcastSpec &auto_broadcast=AutoBroadcastSpec(AutoBroadcastType::NUMPY))
Constructs an equal operation.
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28