jiangjiajun commented on a change in pull request #9295:
URL: https://github.com/apache/tvm/pull/9295#discussion_r734305439
##########
File path: python/tvm/relay/frontend/paddlepaddle.py
##########
@@ -248,24 +287,13 @@ def convert_conv2d(g, op, block):
if padding_algorithm == "VALID":
paddings = [0, 0]
elif padding_algorithm == "SAME":
- if strides[0] == 1 and strides[1] == 1:
- pad_h = _get_pad_size(0, (k_h - 1) * dilations[0] + 1, strides[0])
- pad_w = _get_pad_size(0, (k_w - 1) * dilations[1] + 1, strides[1])
- else:
- input_shape = shape_of(input_x)
- h_w = _op.strided_slice(input_shape, [2], [4])
- try:
- in_h, in_w = infer_value(h_w, g.get_params()).numpy().tolist()
- except Exception as e:
- msg = "Dynamic shape is not supported in SAME padding
algorithm while stride!=1"
- raise tvm.error.OpAttributeInvalid(msg) from e
- pad_h = _get_pad_size(in_h, (k_h - 1) * dilations[0] + 1,
strides[0])
- pad_w = _get_pad_size(in_w, (k_w - 1) * dilations[1] + 1,
strides[1])
- paddings = [pad_h[0], pad_w[0], pad_h[1], pad_w[1]]
+ dilations = [1, 1]
Review comment:
> do we mean to override the dilations?
Yes, after `autopad` on input tensor, dilation is not need for the next step
##########
File path: python/tvm/relay/frontend/paddlepaddle.py
##########
@@ -248,24 +287,13 @@ def convert_conv2d(g, op, block):
if padding_algorithm == "VALID":
paddings = [0, 0]
elif padding_algorithm == "SAME":
- if strides[0] == 1 and strides[1] == 1:
- pad_h = _get_pad_size(0, (k_h - 1) * dilations[0] + 1, strides[0])
- pad_w = _get_pad_size(0, (k_w - 1) * dilations[1] + 1, strides[1])
- else:
- input_shape = shape_of(input_x)
- h_w = _op.strided_slice(input_shape, [2], [4])
- try:
- in_h, in_w = infer_value(h_w, g.get_params()).numpy().tolist()
- except Exception as e:
- msg = "Dynamic shape is not supported in SAME padding
algorithm while stride!=1"
- raise tvm.error.OpAttributeInvalid(msg) from e
- pad_h = _get_pad_size(in_h, (k_h - 1) * dilations[0] + 1,
strides[0])
- pad_w = _get_pad_size(in_w, (k_w - 1) * dilations[1] + 1,
strides[1])
- paddings = [pad_h[0], pad_w[0], pad_h[1], pad_w[1]]
+ dilations = [1, 1]
Review comment:
This is a little difference with ONNX, here is the API reference
https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/Conv2D_cn.html#conv2d
while `padding == SAME`, dilation is no need any more

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]