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

Method _create_conv

python/singa/sonnx.py:1638–1675  ·  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

1636
1637 @classmethod
1638 def _create_conv(cls, onnx_node, operator, opset_version=_opset_version):
1639 """
1640 get the clip operator from onnx node
1641 Args:
1642 onnx_node (OnnxNode): a given onnx node
1643 operator (Operator Class): a singa operator class
1644 opset_version (int): the opset version
1645 Returns:
1646 singa operator instance
1647 """
1648 kernel_size = tuple(onnx_node.getattr('kernel_shape'))
1649 padding = tuple(onnx_node.getattr('pads', (0, 0)))
1650 stride = tuple(onnx_node.getattr('strides', (1, 1)))
1651 auto_pad = utils.force_unicode(onnx_node.getattr('auto_pad', 'NOTSET'))
1652
1653 # not support dilation
1654 dilation = onnx_node.getattr('dilations', 1)
1655 if dilation != 1 and list(dilation) != [1, 1]:
1656 raise ValueError("Not implemented yet for dilation")
1657 group = onnx_node.getattr('group', 1)
1658
1659 # only support 1d or 2d
1660 if len(kernel_size) > 2:
1661 raise ValueError("Only implemented for 1d or 2d")
1662
1663 onnx_node.set_weight_inputs(onnx_node.inputs[1], 'W')
1664 bias = False
1665 if len(onnx_node.inputs) == 3:
1666 onnx_node.set_weight_inputs(onnx_node.inputs[2], 'b')
1667 bias = True
1668 return operator(None,
1669 kernel_size,
1670 stride=stride,
1671 padding=padding,
1672 dilation=dilation,
1673 group=group,
1674 bias=bias,
1675 pad_mode=auto_pad)
1676
1677 @classmethod
1678 def _create_max_avg_pool(cls,

Callers

nothing calls this directly

Calls 3

getattrMethod · 0.80
set_weight_inputsMethod · 0.80
tupleFunction · 0.50

Tested by

no test coverage detected