binary_elementwise_logical.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 binary logical operations, i.e.,
29  /// operations where the same scalar binary logical operation is applied to
30  /// each corresponding pair of elements in two boolean input tensors. Implicit
31  /// broadcast of input tensors is supported through one of the AutoBroadcast
32  /// modes.
33  ///
34  /// For example, if the underlying operation (determined by the subclass) is
35  /// \f$\mathit{op}(x,y)\f$, the input tensors \f$[[x_0,y_0],[z_0,w_0]]\f$ and
36  /// \f$[[x_1,y_1],[z_1,w_1]]\f$ will be mapped to
37  /// \f$[[\mathit{op}(x_0,x_1),\mathit{op}(y_0,y_1)],[\mathit{op}(z_0,z_1),\mathit{op}(w_0,w_1)]]\f$.
38  ///
39  /// ## Inputs
40  ///
41  /// | | Type | Description |
42  /// | ------ | --------------------------------------------- | ------------------------------------------------------ |
43  /// | `arg0` | \f$\texttt{bool}[d_1,\dots,d_n]~(n \geq 0)\f$ | A tensor of any shape, with element type `bool`. |
44  /// | `arg1` | \f$\texttt{bool}[d_1,\dots,d_n]~(n \geq 0)\f$ | A tensor of the same shape and element type as `arg0`. |
45  /// | `autob`| AutoBroadcastSpec | Auto broadcast specification. |
46  ///
47  /// ## Output
48  ///
49  /// | Type | Description |
50  /// | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
51  /// | \f$\texttt{bool}[d_1,\dots,d_n]\f$ | The tensor \f$T\f$, where \f$T[i_1,\dots,i_n] = \mathit{op}(\texttt{arg0}[i_1,\dots,i_n],\texttt{arg1}[i_1,\dots,i_n])\f$. This will always have the same shape as the input tensors, and the element type `bool`. |
52  // clang-format on
53  class NGRAPH_API BinaryElementwiseLogical : public Op
54  {
55  protected:
56  NGRAPH_RTTI_DECLARATION;
57 
59 
60  /// \brief Constructs a binary elementwise logical operation.
61  ///
62  /// \param arg0 Output that produces the first input tensor.
63  /// \param arg1 Output that produces the second input tensor.
64  BinaryElementwiseLogical(const Output<Node>& arg0,
65  const Output<Node>& arg1,
66  const AutoBroadcastSpec& autob = AutoBroadcastSpec());
67 
68  public:
69  void validate_and_infer_types() override;
70 
71  const AutoBroadcastSpec& get_autob() const override { return m_autob; }
72  void set_autob(const AutoBroadcastSpec& autob) { m_autob = autob; }
73  bool visit_attributes(AttributeVisitor& visitor) override;
74 
75  private:
76  void validate_and_infer_elementwise_logical(const op::AutoBroadcastSpec& autob);
77  AutoBroadcastSpec m_autob;
78  };
79  }
80  }
81 }
ngraph::op::AutoBroadcastSpec
Implicit broadcast specification.
Definition: attr_types.hpp:321
ngraph::op::util::BinaryElementwiseLogical
Abstract base class for elementwise binary logical operations, i.e., operations where the same scalar...
Definition: binary_elementwise_logical.hpp:54
ngraph::op::util::BinaryElementwiseLogical::BinaryElementwiseLogical
BinaryElementwiseLogical(const Output< Node > &arg0, const Output< Node > &arg1, const AutoBroadcastSpec &autob=AutoBroadcastSpec())
Constructs a binary elementwise logical operation.
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
ngraph::op::util::BinaryElementwiseLogical::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::BinaryElementwiseLogical::get_autob
const AutoBroadcastSpec & get_autob() const override
Definition: binary_elementwise_logical.hpp:71
ngraph::op::Op
Root of all actual ops.
Definition: op.hpp:29