divide.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_arithmetic.hpp"
20 
21 namespace ngraph
22 {
23  namespace op
24  {
25  namespace v0
26  {
27  /// \brief Elementwise division operation.
28  class NGRAPH_DEPRECATED(
29  "This operation is deprecated and will be removed soon. "
30  "Use v1::Divide instead of it.") NGRAPH_API Divide
31  : public util::BinaryElementwiseArithmetic
32  {
33  NGRAPH_SUPPRESS_DEPRECATED_START
34  public:
35  static constexpr NodeTypeInfo type_info{"Divide", 0};
36  const NodeTypeInfo& get_type_info() const override { return type_info; }
37  /// \brief Constructs a division operation.
38  Divide()
39  : util::BinaryElementwiseArithmetic(AutoBroadcastSpec::NONE)
40  {
41  }
42  /// \brief Constructs a division operation.
43  ///
44  /// \param arg0 Node that produces the first input tensor.
45  /// \param arg1 Node that produces the second input tensor.
46  /// \param pythondiv Use Python style rounding for integral type
47  /// \param auto_broadcast Auto broadcast specification
48  Divide(const Output<Node>& arg0,
49  const Output<Node>& arg1,
50  bool pythondiv,
51  const AutoBroadcastSpec& auto_broadcast = AutoBroadcastSpec());
52 
53  /// \brief Constructs a division 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  Divide(const Output<Node>& arg0,
59  const Output<Node>& arg1,
60  const AutoBroadcastSpec& auto_broadcast = AutoBroadcastSpec());
61  bool visit_attributes(AttributeVisitor& visitor) override;
62  bool is_pythondiv() const { return m_pythondiv; }
63  void set_is_pythondiv(bool pythondiv) { m_pythondiv = pythondiv; }
64  virtual std::shared_ptr<Node>
65  clone_with_new_inputs(const OutputVector& new_args) const override;
66 
67  bool evaluate(const HostTensorVector& outputs,
68  const HostTensorVector& inputs) const override;
69 
70  protected:
71  bool m_pythondiv{true};
72  NGRAPH_SUPPRESS_DEPRECATED_END
73  };
74  } // namespace v0
75 
76  namespace v1
77  {
78  /// \brief Elementwise division operation.
79  class NGRAPH_API Divide : public util::BinaryElementwiseArithmetic
80  {
81  public:
82  NGRAPH_RTTI_DECLARATION;
83  /// \brief Constructs a division operation.
85  : util::BinaryElementwiseArithmetic(AutoBroadcastSpec::NUMPY)
86  {
87  }
88 
89  /// \brief Constructs a division operation.
90  ///
91  /// \param arg0 Node that produces the first input tensor.
92  /// \param arg1 Node that produces the second input tensor.
93  /// \param pythondiv Use Python style rounding for integral type
94  /// \param auto_broadcast Auto broadcast specification
95  Divide(const Output<Node>& arg0,
96  const Output<Node>& arg1,
97  bool pythondiv,
98  const AutoBroadcastSpec& auto_broadcast =
99  AutoBroadcastSpec(AutoBroadcastType::NUMPY));
100 
101  /// \brief Constructs a division operation.
102  ///
103  /// \param arg0 Node that produces the first input tensor.
104  /// \param arg1 Node that produces the second input tensor.
105  /// \param auto_broadcast Auto broadcast specification
106  Divide(const Output<Node>& arg0,
107  const Output<Node>& arg1,
108  const AutoBroadcastSpec& auto_broadcast =
109  AutoBroadcastSpec(AutoBroadcastType::NUMPY));
110  bool visit_attributes(AttributeVisitor& visitor) override;
111  bool is_pythondiv() const { return m_pythondiv; }
112  void set_is_pythondiv(bool pythondiv) { m_pythondiv = pythondiv; }
113  virtual std::shared_ptr<Node>
114  clone_with_new_inputs(const OutputVector& new_args) const override;
115 
116  size_t get_version() const override { return 1; }
117  bool evaluate(const HostTensorVector& outputs,
118  const HostTensorVector& inputs) const override;
119 
120  protected:
121  bool m_pythondiv{true};
122  };
123  } // namespace v1
124 
125  NGRAPH_SUPPRESS_DEPRECATED_START
126  using v0::Divide;
127  NGRAPH_SUPPRESS_DEPRECATED_END
128  } // namespace op
129 
130  NGRAPH_DEPRECATED("This operator was deprecated and will be removed with v0 operation.")
131  NGRAPH_API
132  std::shared_ptr<Node> operator/(const Output<Node>& arg0, const Output<Node>& arg1);
133 } // namespace ngraph
ngraph::op::v1::Divide::get_version
size_t get_version() const override
Definition: divide.hpp:116
ngraph::op::v1::Divide::Divide
Divide()
Constructs a division operation.
Definition: divide.hpp:84
ngraph::op::v1::Divide
Elementwise division operation.
Definition: divide.hpp:80
ngraph::op::v1::Divide::Divide
Divide(const Output< Node > &arg0, const Output< Node > &arg1, bool pythondiv, const AutoBroadcastSpec &auto_broadcast=AutoBroadcastSpec(AutoBroadcastType::NUMPY))
Constructs a division operation.
ngraph::op::AutoBroadcastSpec
Implicit broadcast specification.
Definition: attr_types.hpp:321
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
ngraph::AttributeVisitor
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:70
ngraph::op::util::BinaryElementwiseArithmetic
Abstract base class for elementwise binary arithmetic operations, i.e., operations where the same sca...
Definition: binary_elementwise_arithmetic.hpp:55
ngraph::op::v1::Divide::Divide
Divide(const Output< Node > &arg0, const Output< Node > &arg1, const AutoBroadcastSpec &auto_broadcast=AutoBroadcastSpec(AutoBroadcastType::NUMPY))
Constructs a division operation.