In order to auto tune a tensorflow pb model(layout NHWC), I convert to a onnx model(layout NCHW).
I found the auto tune log message is a little confused, the conv op input tensor shape is different with the onnxruntime
then i check the tvm_code/tvm/python/tvm/relay/frontend/onnx.pyonnx.py
class Conv(OnnxOpConverter):
""" Operator converter for Conv.
"""
@classmethod
def _impl_v1(cls, inputs, attr, params):
out = AttrCvt(op_name=dimension_picker('conv'),
transforms={
'kernel_shape': 'kernel_size',
'dilations': ('dilation', (0, 0)),
'pads': ('padding', (0, 0), revert_caffe2_pad),
'group': ('groups', 1)},
ignores=['auto_pad'],
custom_check=dimension_constraint())(inputs[:2], attr, params)
use_bias = len(inputs) == 3
if use_bias:
out = _op.nn.bias_add(out, inputs[2])
return out
find use revert_caffe2_pad to convert onnx attr pads to padding
def revert_caffe2_pad(pads):
"""Caffe2 requires two times the normal padding."""
if len(pads) == 4:
pads = pads[:2]
elif len(pads) == 2:
pass
else:
raise tvm.error.OpAttributeInvalid(
'Number of pads must be either 2 or 4.')
return pads
so the new padding convert form (0 ,0 ,1 , 1) to (0, 0) , is this ok for onnx model?