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 extensions.front.kaldi.fuse_repeated_reshape import FuseRepeatedReshapes
20 from mo.front.common.replacement import FrontReplacementPattern
21 from mo.graph.graph import Graph
22 from mo.middle.passes.eliminate import remove_op_node_with_data_node
25 class EliminateRedundantReshape(FrontReplacementPattern):
37 ('reshape', dict(kind='op', op='Reshape'))
43 def replace_pattern(graph: Graph, match: dict):
44 reshape_node = match['reshape']
45 in_node = reshape_node.in_node()
46 out_node = reshape_node.out_node()
47 if not np.array_equal(in_node.shape, out_node.shape):
49 remove_op_node_with_data_node(graph, reshape_node)