gather_tree.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 v1
14  {
15  /// \brief Generates the complete beams from the ids per each step and the parent beam
16  /// ids.
17  class NGRAPH_API GatherTree : public Op
18  {
19  public:
20  static constexpr NodeTypeInfo type_info{"GatherTree", 1};
21  const NodeTypeInfo& get_type_info() const override { return type_info; }
22  GatherTree() = default;
23  /// \param step_ids Tensor of shape [MAX_TIME, BATCH_SIZE, BEAM_WIDTH] with
24  /// indices from per each step
25  /// \param parent_idx Tensor of shape [MAX_TIME, BATCH_SIZE, BEAM_WIDTH] with
26  /// parent beam indices
27  /// \param max_seq_len Tensor of shape [BATCH_SIZE] with maximum lengths for each
28  /// sequence in the batch
29  /// \param end_token Tensor of shape [MAX_TIME, BATCH_SIZE, BEAM_WIDTH]
30  GatherTree(const Output<Node>& step_ids,
31  const Output<Node>& parent_idx,
32  const Output<Node>& max_seq_len,
33  const Output<Node>& end_token);
34 
35  bool visit_attributes(AttributeVisitor& visitor) override;
36  void validate_and_infer_types() override;
37 
38  virtual std::shared_ptr<Node>
39  clone_with_new_inputs(const OutputVector& new_args) const override;
40  };
41  } // namespace v1
42  } // namespace op
43 } // 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
Root of all actual ops.
Definition: op.hpp:17
Generates the complete beams from the ids per each step and the parent beam ids.
Definition: gather_tree.hpp:18
GatherTree(const Output< Node > &step_ids, const Output< Node > &parent_idx, const Output< Node > &max_seq_len, const Output< Node > &end_token)
void validate_and_infer_types() override
Verifies that attributes and inputs are consistent and computes output shapes and element types....
const NodeTypeInfo & get_type_info() const override
Definition: gather_tree.hpp:21
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16
Definition: type.hpp:27