reverse_sequence.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 v0
26  {
27  class NGRAPH_API ReverseSequence : public Op
28  {
29  public:
30  static constexpr NodeTypeInfo type_info{"ReverseSequence", 0};
31  const NodeTypeInfo& get_type_info() const override { return type_info; }
32  ReverseSequence() = default;
33  /// \brief Constructs a ReverseSequence operation.
34  ///
35  /// \param arg tensor with input data to reverse
36  /// \param seq_lengths 1D tensor of integers with sequence lengths in the input
37  /// tensor.
38  /// \param batch_axis index of the batch dimension.
39  /// \param seq_axis index of the sequence dimension.
40  ReverseSequence(const Output<Node>& arg,
41  const Output<Node>& seq_lengths,
42  int64_t batch_axis,
43  int64_t seq_axis);
44 
45  bool visit_attributes(AttributeVisitor& visitor) override;
46  void validate_and_infer_types() override;
47 
48  virtual std::shared_ptr<Node>
49  clone_with_new_inputs(const OutputVector& new_args) const override;
50 
51  size_t get_batch_axis() const { return m_normalized_batch_axis; }
52  int64_t get_origin_batch_axis() const { return m_batch_axis; }
53  void set_batch_axis(int64_t batch_axis) { m_batch_axis = batch_axis; }
54  size_t get_sequence_axis() const { return m_normalized_seq_axis; }
55  int64_t get_origin_sequence_axis() const { return m_seq_axis; }
56  void set_sequence_axis(int64_t sequence_axis) { m_seq_axis = sequence_axis; }
57  private:
58  int64_t m_batch_axis;
59  int64_t m_seq_axis;
60  size_t m_normalized_batch_axis;
61  size_t m_normalized_seq_axis;
62  };
63  }
64  using v0::ReverseSequence;
65  }
66 }
ngraph::op::v0::ReverseSequence::ReverseSequence
ReverseSequence(const Output< Node > &arg, const Output< Node > &seq_lengths, int64_t batch_axis, int64_t seq_axis)
Constructs a ReverseSequence operation.
ngraph::op::v0::ReverseSequence
Definition: reverse_sequence.hpp:28
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::v0::ReverseSequence::get_type_info
const NodeTypeInfo & get_type_info() const override
Definition: reverse_sequence.hpp:31
ngraph::op::v0::ReverseSequence::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::Op
Root of all actual ops.
Definition: op.hpp:29