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.
17 from mo.graph.graph import Graph
18 from mo.middle.passes.eliminate import remove_op_node_with_data_node
19 from mo.middle.replacement import MiddleReplacementPattern
22 class RemoveIdentity(MiddleReplacementPattern):
26 from extensions.middle.InputCut import MiddleInputCut
27 return [MiddleInputCut]
30 from extensions.middle.pass_separator import MiddleStart
35 nodes=[('op', dict(kind='op', identity=True))],
39 def replace_pattern(self, graph: Graph, match: dict):
40 remove_op_node_with_data_node(graph, match['op'])
43 class RemoveDropout(MiddleReplacementPattern):
47 from extensions.middle.pass_separator import PreMiddleStart
48 return [PreMiddleStart]
51 from extensions.middle.pass_separator import MiddleStart
56 nodes=[('op', dict(op='Dropout'))],
60 def replace_pattern(self, graph: Graph, match: dict):
61 remove_op_node_with_data_node(graph, match['op'])
64 class RemoveNodesWithZeroPhase(MiddleReplacementPattern):
69 from extensions.middle.pass_separator import PreMiddleStart
70 return [PreMiddleStart]
73 from extensions.middle.pass_separator import MiddleStart
78 nodes=[('op', dict(kind='op', phase=0))],
82 def replace_pattern(self, graph: Graph, match: dict):
83 remove_op_node_with_data_node(graph, match['op'])