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.
21 from generator import generator, generate
23 from extensions.front.onnx.slice_ext import SliceFrontExtractor
24 from mo.ops.op import Op
25 from mo.ops.slice import Slice
26 from mo.utils.unittest.extractors import PB
30 class TestSliceONNXExt(unittest.TestCase):
32 def _create_slice_node(axes, starts, ends):
34 pb = onnx.helper.make_node(
42 pb = onnx.helper.make_node(
56 Op.registered_ops['Slice'] = Slice
58 @generate(*[([0, 1], [0, 0], [28, 28]), (None, [0, 0], [28, 28])])
59 def test_slice_ext(self, axes, starts, ends):
60 node = self._create_slice_node(axes, starts, ends)
61 SliceFrontExtractor.extract(node)
71 for key in exp_res.keys():
72 if type(node[key]) in [list, np.ndarray]:
73 self.assertTrue(np.array_equal(np.array(node[key]), np.array(exp_res[key])))
75 self.assertEqual(node[key], exp_res[key])