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.
18 from unittest.mock import patch
20 from mo.front.caffe.extractors.crop import CropFrontExtractor
21 from mo.front.common.partial_infer.crop import crop_infer
22 from mo.ops.crop import Crop
23 from mo.ops.op import Op
24 from mo.utils.unittest.extractors import FakeMultiParam
25 from mo.utils.unittest.graph import FakeNode
28 class FakeCropProtoLayer:
29 def __init__(self, val):
33 class TestCropExt(unittest.TestCase):
36 Op.registered_ops['Crop'] = Crop
38 def test_da_no_pb_no_ml(self):
39 self.assertRaises(AttributeError, CropFrontExtractor.extract, None)
41 @patch('mo.front.caffe.collect_attributes')
42 def test_crop_ext(self, collect_attributes_mock):
47 collect_attributes_mock.return_value = {
52 fake_pl = FakeCropProtoLayer(FakeMultiParam(params))
53 fake_node = FakeNode(fake_pl, None)
55 CropFrontExtractor.extract(fake_node)
61 'dim': None, # set in infer
65 for key in exp_res.keys():
66 self.assertEqual(exp_res[key], fake_node[key])