rnn_sequence.hpp
1 //*****************************************************************************
2 // Copyright 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 <memory>
20 #include <string>
21 #include <vector>
22 
23 #include "ngraph/op/op.hpp"
24 #include "ngraph/op/util/rnn_cell_base.hpp"
25 
26 namespace ngraph
27 {
28  namespace op
29  {
30  namespace v5
31  {
32  class NGRAPH_API RNNSequence : public util::RNNCellBase
33  {
34  public:
35  NGRAPH_RTTI_DECLARATION;
36 
37  RNNSequence();
38 
40  const Output<Node>& X,
41  const Output<Node>& H_t,
42  const Output<Node>& sequence_lengths,
43  const Output<Node>& W,
44  const Output<Node>& R,
45  const Output<Node>& B,
46  size_t hidden_size,
48  const std::vector<std::string>& activations = std::vector<std::string>{"tanh"},
49  const std::vector<float>& activations_alpha = {},
50  const std::vector<float>& activations_beta = {},
51  float clip = 0.f);
52 
53  std::shared_ptr<Node>
54  clone_with_new_inputs(const OutputVector& new_args) const override;
55 
56  void validate_and_infer_types() override;
57 
58  bool visit_attributes(AttributeVisitor& visitor) override;
59 
60  op::RecurrentSequenceDirection get_direction() const { return m_direction; }
61  protected:
63  };
64  }
65  } // namespace op
66 } // namespace ngraph
ngraph::op::util::RNNCellBase
Base class for all recurrent network cells.
Definition: rnn_cell_base.hpp:66
ngraph::op::RecurrentSequenceDirection
RecurrentSequenceDirection
This class defines possible recurrent sequence directions.
Definition: attr_types.hpp:430
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
ngraph::op::v5::RNNSequence::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::AttributeVisitor
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:70
ngraph::op::v5::RNNSequence
Definition: rnn_sequence.hpp:33