gather.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/util/gather_base.hpp"
8 
9 namespace ngraph
10 {
11  namespace op
12  {
13  namespace v1
14  {
15  /// \brief Gather slices from axis of params according to indices
16  class NGRAPH_API Gather : public op::util::GatherBase
17  {
18  public:
19  NGRAPH_RTTI_DECLARATION;
20  static const int64_t AXIS_NOT_SET_VALUE = std::numeric_limits<int64_t>::max();
21  Gather() = default;
22  /// \param params The tensor from which slices are gathered
23  /// \param indices Tensor with indexes to gather
24  /// \param axis The tensor is a dimension index to gather data from
25  Gather(const Output<Node>& params,
26  const Output<Node>& indices,
27  const Output<Node>& axis);
28 
29  bool visit_attributes(AttributeVisitor& visitor) override;
30  int64_t get_axis() const override;
31 
32  std::shared_ptr<Node>
33  clone_with_new_inputs(const OutputVector& new_args) const override;
34  };
35  } // namespace v1
36 
37  namespace v7
38  {
39  /// \brief Gather slices from axis of params according to indices
40  class NGRAPH_API Gather : public op::util::GatherBase
41  {
42  public:
43  NGRAPH_RTTI_DECLARATION;
44  Gather() = default;
45 
46  /// \param data The tensor from which slices are gathered
47  /// \param indices Tensor with indexes to gather
48  /// \param axis The tensor is a dimension index to gather data from
49  /// \param batch_dims The number of batch dimension in data and indices tensors.
50  /// If batch_dims = 0 Gather v7 is identical to Gather v1.
51  Gather(const Output<Node>& data,
52  const Output<Node>& indices,
53  const Output<Node>& axis,
54  const int64_t batch_dims = 0);
55 
56  bool visit_attributes(AttributeVisitor& visitor) override;
57  void validate_and_infer_types() override;
58  int64_t get_batch_dims() const;
59 
60  std::shared_ptr<Node>
61  clone_with_new_inputs(const OutputVector& new_args) const override;
62  };
63  } // namespace v7
64  } // namespace op
65 } // 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
GatherBase basic class for Gather v1 and v7.
Definition: gather_base.hpp:17
Gather slices from axis of params according to indices.
Definition: gather.hpp:17
Gather(const Output< Node > &params, const Output< Node > &indices, const Output< Node > &axis)
Gather slices from axis of params according to indices.
Definition: gather.hpp:41
Gather(const Output< Node > &data, const Output< Node > &indices, const Output< Node > &axis, const int64_t batch_dims=0)
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16