gru_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 GRUSequence : public util::RNNCellBase
33  {
34  public:
35  NGRAPH_RTTI_DECLARATION;
36  GRUSequence();
37 
38  GRUSequence(const Output<Node>& X,
39  const Output<Node>& H_t,
40  const Output<Node>& sequence_lengths,
41  const Output<Node>& W,
42  const Output<Node>& R,
43  const Output<Node>& B,
44  size_t hidden_size,
46  const std::vector<std::string>& activations =
47  std::vector<std::string>{"sigmoid", "tanh"},
48  const std::vector<float>& activations_alpha = {},
49  const std::vector<float>& activations_beta = {},
50  float clip = 0.f,
51  bool linear_before_reset = false);
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  bool get_linear_before_reset() const { return m_linear_before_reset; }
60  op::RecurrentSequenceDirection get_direction() const { return m_direction; }
61  protected:
63  bool m_linear_before_reset;
64  };
65  }
66  } // namespace op
67 } // 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::AttributeVisitor
Visits the attributes of a node, primarily for serialization-like tasks.
Definition: attribute_visitor.hpp:70
ngraph::op::v5::GRUSequence::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::v5::GRUSequence
Definition: gru_sequence.hpp:33