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 mo.front.extractor import FrontExtractorOp
20 from mo.front.mxnet.extractors.utils import get_mxnet_layer_attrs
21 from mo.ops.pooling import Pooling
24 class PoolingFrontExtractor(FrontExtractorOp):
30 attrs = get_mxnet_layer_attrs(node.symbol_dict)
32 kernel = attrs.tuple("kernel", int, None)
33 stride = attrs.tuple("stride", int, tuple(np.ones(len(kernel), dtype=np.int64)))
34 padding = attrs.tuple("pad", int, tuple(np.zeros(len(kernel), dtype=np.int64)))
35 method = attrs.str("pool_type", None)
39 'window': np.array([1, 1, *[k for k in kernel]], dtype=np.int64),
40 'stride': np.array([1, 1, *[s for s in stride]], dtype=np.int64),
41 'pad': np.array([[0, 0], [0, 0], *[[pad, pad] for pad in padding]], dtype=np.int64),
42 'pad_spatial_shape': np.array([[pad, pad] for pad in padding], dtype=np.int64),
43 'pool_method': method,
44 'exclude_pad': 'false',
45 'output_spatial_shape': None,
47 'channel_dims': np.array([1], dtype=np.int64),
48 'batch_dims': np.array([0], dtype=np.int64),
53 pooling_conv = attrs.str("pooling_convention", 'valid')
55 data["pooling_convention"] = pooling_conv
56 if pooling_conv == 'full':
57 data["rounding_type"] = 'ceil'
59 global_pool = attrs.bool("global_pool", False)
61 data["global_pool"] = global_pool
63 # update the attributes of the node
64 Pooling.update_node_stat(node, data)
65 return __class__.enabled