2 Copyright (c) 2018-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.
19 from mo.front.common.partial_infer.utils import mark_input_bins
20 from mo.graph.graph import Node, Graph
21 from mo.ops.op import Op
28 def __init__(self, graph: Graph, attrs: dict):
31 'infer': __class__.infer,
34 super().__init__(graph, mandatory_props, attrs)
37 def infer(node: Node):
39 MO input edges: | Description:
40 -------------------------------------------------
41 0 | x: The sequence input to the LSTM, shape (timelen, batch_size, num_inputs)
42 1 | w: The weight matrix
43 2 | b: The bias vector
44 3 | h_prev: Previous/initial hidden state
45 4 | cs_prev: Value of the initial cell state
47 assert len(node.in_nodes()) == 5
50 MO output edges: | Description:
51 0 | cs: Output data / output hidden states concatenated over the whole time sequence
52 1 | h: Output cell states concatenated over the whole time sequence
55 assert len(node.out_nodes()) in [1, 2]
58 input_shape = node.in_node(0).shape
60 assert len(input_shape) == 3
61 out_shape = input_shape
62 node.out_node(0).shape = out_shape
63 if len(node.out_nodes()) > 1:
64 node.out_node(1).shape = out_shape