bucketize.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include "ngraph/op/op.hpp"
8 
9 namespace ngraph
10 {
11  namespace op
12  {
13  namespace v3
14  {
15  /// \brief Operation that bucketizes the input based on boundaries
16  class NGRAPH_API Bucketize : public Op
17  {
18  public:
19  static constexpr NodeTypeInfo type_info{"Bucketize", 3};
20  const NodeTypeInfo& get_type_info() const override { return type_info; }
21  Bucketize() = default;
22  /// \brief Constructs a Bucketize node
23 
24  /// \param data Input data to bucketize
25  /// \param buckets 1-D of sorted unique boundaries for buckets
26  /// \param output_type Output tensor type, "i64" or "i32", defaults to i64
27  /// \param with_right_bound indicates whether bucket includes the right or left
28  /// edge of interval. default true = includes right edge
29  Bucketize(const Output<Node>& data,
30  const Output<Node>& buckets,
31  const element::Type output_type = element::i64,
32  const bool with_right_bound = true);
33 
34  virtual void validate_and_infer_types() override;
35  virtual bool visit_attributes(AttributeVisitor& visitor) override;
36 
37  virtual std::shared_ptr<Node>
38  clone_with_new_inputs(const OutputVector& inputs) const override;
39 
40  element::Type get_output_type() const { return m_output_type; }
41  void set_output_type(element::Type output_type) { m_output_type = output_type; }
42  // Overload collision with method on Node
43  using Node::set_output_type;
44 
45  bool get_with_right_bound() const { return m_with_right_bound; }
46  void set_with_right_bound(bool with_right_bound)
47  {
48  m_with_right_bound = with_right_bound;
49  }
50 
51  private:
52  element::Type m_output_type;
53  bool m_with_right_bound;
54  };
55  } // namespace v3
56  using v3::Bucketize;
57  } // namespace op
58 } // namespace ngraph
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:59
A handle for one of a node's outputs.
Definition: node_output.hpp:33
Definition: element_type.hpp:51
Root of all actual ops.
Definition: op.hpp:17
Operation that bucketizes the input based on boundaries.
Definition: bucketize.hpp:17
virtual void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
Bucketize(const Output< Node > &data, const Output< Node > &buckets, const element::Type output_type=element::i64, const bool with_right_bound=true)
Constructs a Bucketize node.
const NodeTypeInfo & get_type_info() const override
Definition: bucketize.hpp:20
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16
Definition: type.hpp:27