MCPcopy Create free account
hub / github.com/apache/singa / _create_max_avg_pool

Method _create_max_avg_pool

python/singa/sonnx.py:1678–1708  ·  view source on GitHub ↗

get the clip operator from onnx node Args: onnx_node (OnnxNode): a given onnx node operator (Operator Class): a singa operator class opset_version (int): the opset version Returns: singa operator instance

(cls,
                             onnx_node,
                             operator,
                             opset_version=_opset_version)

Source from the content-addressed store, hash-verified

1676
1677 @classmethod
1678 def _create_max_avg_pool(cls,
1679 onnx_node,
1680 operator,
1681 opset_version=_opset_version):
1682 """
1683 get the clip operator from onnx node
1684 Args:
1685 onnx_node (OnnxNode): a given onnx node
1686 operator (Operator Class): a singa operator class
1687 opset_version (int): the opset version
1688 Returns:
1689 singa operator instance
1690 """
1691 kernel_size = tuple(onnx_node.getattr('kernel_shape'))
1692 padding = tuple(onnx_node.getattr('pads', (0, 0)))
1693 stride = tuple(onnx_node.getattr('strides', (1, 1)))
1694 auto_pad = utils.force_unicode(onnx_node.getattr('auto_pad', 'NOTSET'))
1695
1696 # not support count_include_pad and auto_pad
1697 ceil_mode = onnx_node.getattr('ceil_mode', 0)
1698 count_include_pad = onnx_node.getattr('count_include_pad', 0)
1699 if ceil_mode != 0 or count_include_pad != 0:
1700 raise ValueError(
1701 "Not implemented yet for count_include_pad or ceil_mode")
1702
1703 # only support 1d or 2d
1704 if len(kernel_size) > 2:
1705 raise ValueError("Only implemented for 1d or 2d")
1706
1707 is_max = onnx_node.op_type == 'MaxPool'
1708 return operator(kernel_size, stride, padding, is_max, auto_pad)
1709
1710 @classmethod
1711 def _create_scatter_elements(cls,

Callers

nothing calls this directly

Calls 2

getattrMethod · 0.80
tupleFunction · 0.50

Tested by

no test coverage detected