divide.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  /// \brief Elementwise division operation.
28  class NGRAPH_API Divide : public util::BinaryElementwiseArithmetic
29  {
30  public:
31  NGRAPH_RTTI_DECLARATION;
32  /// \brief Constructs a division operation.
34  : util::BinaryElementwiseArithmetic(AutoBroadcastSpec::NUMPY)
35  {
36  }
37 
38  /// \brief Constructs a division operation.
39  ///
40  /// \param arg0 Node that produces the first input tensor.
41  /// \param arg1 Node that produces the second input tensor.
42  /// \param pythondiv Use Python style rounding for integral type
43  /// \param auto_broadcast Auto broadcast specification
44  Divide(const Output<Node>& arg0,
45  const Output<Node>& arg1,
46  bool pythondiv,
47  const AutoBroadcastSpec& auto_broadcast =
48  AutoBroadcastSpec(AutoBroadcastType::NUMPY));
49 
50  /// \brief Constructs a division operation.
51  ///
52  /// \param arg0 Node that produces the first input tensor.
53  /// \param arg1 Node that produces the second input tensor.
54  /// \param auto_broadcast Auto broadcast specification
55  Divide(const Output<Node>& arg0,
56  const Output<Node>& arg1,
57  const AutoBroadcastSpec& auto_broadcast =
58  AutoBroadcastSpec(AutoBroadcastType::NUMPY));
59  bool visit_attributes(AttributeVisitor& visitor) override;
60  bool is_pythondiv() const { return m_pythondiv; }
61  void set_is_pythondiv(bool pythondiv) { m_pythondiv = pythondiv; }
62  virtual std::shared_ptr<Node>
63  clone_with_new_inputs(const OutputVector& new_args) const override;
64 
65  size_t get_version() const override { return 1; }
66  bool evaluate(const HostTensorVector& outputs,
67  const HostTensorVector& inputs) const override;
68 
69  protected:
70  bool m_pythondiv{true};
71  };
72  } // namespace v1
73  } // namespace op
74 } // namespace ngraph
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:71
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 division operation.
Definition: divide.hpp:29
Divide(const Output< Node > &arg0, const Output< Node > &arg1, const AutoBroadcastSpec &auto_broadcast=AutoBroadcastSpec(AutoBroadcastType::NUMPY))
Constructs a division operation.
Divide(const Output< Node > &arg0, const Output< Node > &arg1, bool pythondiv, const AutoBroadcastSpec &auto_broadcast=AutoBroadcastSpec(AutoBroadcastType::NUMPY))
Constructs a division operation.
Divide()
Constructs a division operation.
Definition: divide.hpp:33
size_t get_version() const override
Definition: divide.hpp:65
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
Implicit broadcast specification.
Definition: attr_types.hpp:323