2 Copyright (c) 2018 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.common.extractors.utils import layout_attrs
20 from mo.front.extractor import FrontExtractorOp
21 from mo.front.mxnet.extractors.utils import get_mxnet_layer_attrs
22 from mo.ops.pooling import Pooling
25 class PoolingFrontExtractor(FrontExtractorOp):
31 attrs = get_mxnet_layer_attrs(node.symbol_dict)
33 kernel = attrs.tuple("kernel", int, None)
34 stride = attrs.tuple("stride", int, (1, 1))
35 padding = attrs.tuple("pad", int, (0, 0))
36 method = attrs.str("pool_type", None)
40 'window': np.array([1, 1, kernel[0], kernel[1]], dtype=np.int64),
41 'stride': np.array([1, 1, stride[0], stride[1]], dtype=np.int64),
42 'pad': np.array([[0, 0], [0, 0], [padding[0], padding[0]], [padding[1], padding[1]]], dtype=np.int64),
43 'pad_spatial_shape': np.array([[padding[0], padding[0]], [padding[1], padding[1]]], dtype=np.int64),
44 'pool_method': method,
45 'exclude_pad': 'false',
46 'output_spatial_shape': None,
50 data.update(layout_attrs())
52 pooling_conv = attrs.str("pooling_convention", 'valid')
54 data["pooling_convention"] = pooling_conv
55 if pooling_conv == 'full':
56 data["rounding_type"] = 'ceil'
58 global_pool = attrs.bool("global_pool", False)
60 data["global_pool"] = global_pool
62 # update the attributes of the node
63 Pooling.update_node_stat(node, data)
64 return __class__.enabled