Skip to content

Commit

Permalink
add pad operator to sonnx
Browse files Browse the repository at this point in the history
  • Loading branch information
joddiy committed Jun 14, 2020
1 parent 978f91e commit e3d31aa
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions python/singa/sonnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,7 @@ class SingaBackend(Backend):
'Reshape': 'Reshape',
'Slice': 'Slice',
'Clip': 'Clip',
'Pad': 'Pad',
'Gemm': 'layer.Gemm', # layer
'BatchNormalization': 'layer.BatchNorm2d', # layer
'Conv': 'layer.Conv2d', # layer
Expand Down Expand Up @@ -1148,8 +1149,25 @@ class SingaBackend(Backend):
'Conv': '_create_conv',
'MaxPool': '_create_max_avg_pool',
'AveragePool': '_create_max_avg_pool',
'Pad': '_create_pad',
}

@classmethod
def _create_pad(cls, onnx_node, operator, opset_version=_opset_version):
"""
get the Pad 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
"""
mode = onnx_node.getattr("mode", "constant")
onnx_node.set_attr_inputs(onnx_node.inputs[2], 'pads')
onnx_node.set_attr_inputs(onnx_node.inputs[2], 'constant')
return operator(mode, None, )

@classmethod
def _create_cast(cls, onnx_node, operator, opset_version=_opset_version):
"""
Expand Down

0 comments on commit e3d31aa

Please sign in to comment.