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.mxnet.custom import CustomFrontExtractorOp
20 from mo.utils.unittest.graph import build_graph
21 from mo.front.extractor import FrontExtractorOp, MXNetCustomFrontExtractorOp
22 from mo.graph.graph import Node
24 attrs = {'test_attr': 1}
27 class FakeExtractor(MXNetCustomFrontExtractorOp):
29 def extract(node: Node):
33 class TestCustomFrontExtractorOp(unittest.TestCase):
36 FrontExtractorOp.registered_ops['Custom'] = CustomFrontExtractorOp
38 def test_extract_custom_layer(self):
40 {'node_1': {'type': 'Identity', 'value': None, 'kind': 'op', 'op': 'Placeholder'},
41 'node_2': {'type': 'Identity', 'value': None, 'kind': 'op'},
42 'node_custom': {'type': 'Custom', 'value': None, 'kind': 'op', 'op': 'Custom', },
43 'node_3': {'type': 'Identity', 'value': None, 'kind': 'op'},
45 [('node_1', 'node_2'),
46 ('node_2', 'node_custom'),
47 ('node_custom', 'node_3'),
50 'node_custom': {'symbol_dict': {'attrs': {'op_type': 'test_type'}}},
53 custom_node = Node(graph, 'node_custom')
54 custom_op = FakeExtractor()
55 supported, op_attrs = custom_op.extract(custom_node)
56 self.assertTrue(supported)
57 self.assertEquals(op_attrs, attrs)