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.back.replacement import BackReplacementPattern
20 from mo.graph.graph import Node, Graph
21 from mo.utils.error import Error
24 class DisableUnsupportedNDOperations(BackReplacementPattern):
26 This pass disables ND Convolutions/Deconvolutions/Poolings
30 unsupported_operations = ['Convolution', 'Deconvolution', 'Pooling']
32 def find_and_replace_pattern(self, graph: Graph):
33 unsupported_nodes = []
34 for node in graph.nodes():
35 node = Node(graph, node)
36 if node.kind == 'op' and node.soft_get('type') in self.unsupported_operations:
37 input_shape = node.in_node(0).shape
38 if len(input_shape) > 4:
39 unsupported_nodes.append((node.id, node.type))
41 if len(unsupported_nodes) == 0:
44 error_message = "\nOperations below were marked as unsupported due to they expect more than two spatial dims" \
45 " (input shape length more than 4)\n"
46 error_message += "List of unsupported operations ({})\n".format(len(unsupported_nodes))
47 for node, type in unsupported_nodes:
48 error_message += " {} {}\n".format(type, node)
50 raise Error(error_message)