Add a section of how to link IE with CMake project (#99)
[platform/upstream/dldt.git] / model-optimizer / mo / front / onnx / extractors / dropout.py
1 """
2  Copyright (c) 2018 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 from mo.front.onnx.extractors.utils import onnx_attr
18 from mo.utils.error import Error
19
20 def dropout_ext(node):
21     # some Dropout flavors doesn't have is_test attribute; when it is missing, interpret it as 1
22     is_test = onnx_attr(node, 'is_test', 'i', 1)
23     if len(node.out_nodes()) > 1:
24         raise Error('Dropout node {} has more than one consumer. Unsupported.', node.name)
25     if not is_test:
26         raise Error('Dropout node {} has is_test: 0. This means training mode which is not supported.', node.name)
27
28     return {
29         # redefine op to automatically remove a node in the next tranformations
30         'op': 'Identity',
31     }
32