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