2 Copyright (c) 2019 Intel Corporation
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
8 http://www.apache.org/licenses/LICENSE-2.0
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.
16 from extensions.ops.RNN import rnn_infer
17 from mo.graph.graph import Node, Graph
18 from mo.ops.op import Op
25 def __init__(self, graph: Graph, attrs: dict):
27 'type': 'RNNSequence', # should be never emitted to IR; for debugging purposes
30 'has_num_directions': False,
31 'direction': 'forward',
32 'infer': __class__.infer,
35 'gate_order': np.array([0, 1, 2]), # TODO: change it later
38 'activation_alpha': None,
39 'activation_beta': None,
42 'linear_before_reset': None,
46 super().__init__(graph, mandatory_props, attrs)
49 def supported_attrs():
51 'hidden_size', # number of the elements in hidden cell size
52 'direction', # one of 'forward', 'reverse', or 'bidirectional'
59 'linear_before_reset',
62 def backend_attrs(self):
64 'hidden_size', # number of the elements in hidden cell size
65 'direction', # one of 'forward', 'reverse', or 'bidirectional'
70 ('activations', lambda node: ','.join(node.activations) if node.activations is not None else None),
72 'linear_before_reset',
76 def infer(node: Node):
77 assert len(node.in_nodes()) >= 3 # X, W and R
78 assert len(node.in_nodes()) <= 5
79 assert len(node.out_nodes()) <= 2