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.
20 from argparse import Namespace
22 from mo.graph.graph import Node
23 from extensions.front.mxnet.add_input_data_to_prior_boxes import AddInputDataToPriorBoxes
24 from mo.utils.unittest.graph import build_graph
27 class TestMxnetPipeline(unittest.TestCase):
28 def test_mxnet_pipeline_1(self):
30 {'data': {'type': 'Identity', 'value': None, 'kind': 'op', 'op': 'Placeholder'},
31 'node_2': {'type': 'Identity', 'value': None, 'kind': 'op'},
32 'node_multi_box': {'type': '_contrib_MultiBoxPrior', 'kind': 'op', 'op': '_contrib_MultiBoxPrior'},
35 ('node_2', 'node_multi_box')],
37 'data': {'shape': np.array([1, 3, 227, 227])},
38 'node_2': {'shape': np.array([1, 3, 10, 10])},
41 graph.graph['cmd_params'] = Namespace(input=None)
42 AddInputDataToPriorBoxes().find_and_replace_pattern(graph)
43 node_multi_box = Node(graph, 'node_multi_box')
45 node_input1 = node_multi_box.in_node(0)
46 node_input2 = node_multi_box.in_node(1)
47 self.assertEqual(node_input1.name, 'node_2')
48 self.assertEqual(node_input2.name, 'data')
50 def test_mxnet_pipeline_2(self):
52 {'node_1': {'type': 'Identity', 'value': None, 'kind': 'op', 'op': 'Placeholder'},
53 'node_2': {'type': 'Identity', 'value': None, 'kind': 'op'},
54 'node_multi_box': {'type': '_contrib_MultiBoxPrior', 'kind': 'op', 'op': '_contrib_MultiBoxPrior'},
56 [('node_1', 'node_2'),
57 ('node_2', 'node_multi_box')],
59 'node_1': {'shape': np.array([1, 3, 227, 227])},
60 'node_2': {'shape': np.array([1, 3, 10, 10])},
63 graph.graph['cmd_params'] = Namespace(input='node_1')
64 AddInputDataToPriorBoxes().find_and_replace_pattern(graph)
65 node_multi_box = Node(graph, 'node_multi_box')
67 node_input1 = node_multi_box.in_node(0)
68 node_input2 = node_multi_box.in_node(1)
69 self.assertEqual(node_input1.name, 'node_2')
70 self.assertEqual(node_input2.name, 'node_1')