Publishing 2019 R1 content
[platform/upstream/dldt.git] / model-optimizer / mo / front / common / find_unsupported_ops.py
1 """
2  Copyright (c) 2018-2019 Intel Corporation
3
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
7
8       http://www.apache.org/licenses/LICENSE-2.0
9
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.
15 """
16
17 import logging as log
18
19 import numpy as np
20
21 from mo.graph.graph import Node, Graph
22
23
24 def find_unsupported_ops(graph: Graph):
25     """
26     The function returns list of node name those are not supported. Currently nodes that product non FP32 data tensors
27     or has undefined 'type' attribute are considered unsupported.
28     :param graph: current graph with operations. Data nodes are not yet added.
29     :return: the list of node names which are not supported
30     """
31     unsupported = list()
32     for node_name in graph.nodes():
33         node = Node(graph, node_name)
34         # op node that produce non FP32 data or has no type are considered unsupported
35         if node.kind == 'op':
36             if node.has_valid('type') or (node.has_valid('op') and node.op == 'OpOutput'):
37                 for out_data_node in node.out_nodes().values():
38                     if out_data_node.has_valid('data_type') and out_data_node.data_type != np.float32:
39                         log.info('Node "{}" produces output as non FP32. Consider it unsupported'.format(node_name))
40                         unsupported.append(node.id)
41             else:
42                 log.info('Node "{}" does not have type. Consider it unsupported'.format(node_name))
43                 unsupported.append(node.id)
44     return unsupported
45