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.
17 from mo.front.kaldi.extractors.common_ext_test import KaldiFrontExtractorTest
19 from mo.front.kaldi.extractors.max_pooling_ext import MaxPoolingComponentFrontExtractor
20 from mo.front.kaldi.loader.utils_test import TestKaldiUtilsLoading
21 from mo.ops.op import Op
22 from mo.ops.pooling import Pooling
25 class MaxPoolingComponentFrontExtractorTest(KaldiFrontExtractorTest):
28 Op.registered_ops['Pooling'] = Pooling
31 def create_pb_for_test_node(cls):
32 pb = KaldiFrontExtractorTest.write_tag_with_value('<PoolSize>', 2)
33 pb += KaldiFrontExtractorTest.write_tag_with_value('<PoolStep>', 2)
34 pb += KaldiFrontExtractorTest.write_tag_with_value('<PoolStride>', 4)
35 cls.test_node['parameters'] = TestKaldiUtilsLoading.bytesio_from(pb)
36 MaxPoolingComponentFrontExtractor.extract(cls.test_node)
38 def test_assertion(self):
39 self.assertRaises(AttributeError, MaxPoolingComponentFrontExtractor.extract, None)
43 'window': [1, 1, 1, 2],
44 'stride': [1, 1, 2, 2],
46 'pad': [[[0, 0], [0, 0], [0, 0], [0, 0]]]
48 for attr in val_attrs:
49 if isinstance(val_attrs[attr], list):
50 self.assertTrue((self.test_node[attr] == val_attrs[attr]).all())
52 self.assertEqual(self.test_node[attr], val_attrs[attr])