AndrewZhaoLuo commented on code in PR #11076:
URL: https://github.com/apache/tvm/pull/11076#discussion_r855717296


##########
tests/python/frontend/onnx/test_forward.py:
##########
@@ -2815,6 +2815,48 @@ def repeat(N, D):
 
 @tvm.testing.parametrize_targets
 def test_convtranspose(target, dev):
+    def verify_convtranspose_with_output_shape(

Review Comment:
   Can you remove "test_convtranspose_output_shape", from 
`unsupported_onnx_tests`?



##########
python/tvm/relay/frontend/onnx.py:
##########
@@ -688,13 +691,28 @@ def _impl_v11(cls, inputs, attr, params):
                 output_padding = attr.get("output_padding", [0] * kndim)
                 strides = attr["strides"]
                 total_pad = [0] * kndim
-                for i in range(kndim):
-                    total_pad[i] = (
-                        output_padding[i] + ((kernel_shape[i] - 1) * 
dilations[i] + 1) - strides[i]
-                    )
+                if "output_shape" in attr:
+                    for i in range(kndim):
+                        total_pad[i] = (
+                            strides[i] * (input_shape[ndim - kndim + i] - 1)
+                            + output_padding[i]
+                            + ((kernel_shape[i] - 1) * dilations[i] + 1)
+                            - attr["output_shape"][i]
+                        )
+                else:
+                    for i in range(kndim):
+                        total_pad[i] = (
+                            output_padding[i]
+                            + ((kernel_shape[i] - 1) * dilations[i] + 1)
+                            - strides[i]
+                        )
                 left = [p // 2 for p in total_pad]
                 right = [total_pad[i] - left[i] for i in range(kndim)]
-                if "LOWER" in attr["auto_pad"]:
+                if "output_shape" in attr and "auto_pad" not in attr:
+                    # assert left[0] == right[0] and left[1] == right[1],\

Review Comment:
   remove comment if it's not needed



##########
python/tvm/relay/frontend/onnx.py:
##########
@@ -688,13 +691,28 @@ def _impl_v11(cls, inputs, attr, params):
                 output_padding = attr.get("output_padding", [0] * kndim)
                 strides = attr["strides"]
                 total_pad = [0] * kndim
-                for i in range(kndim):
-                    total_pad[i] = (
-                        output_padding[i] + ((kernel_shape[i] - 1) * 
dilations[i] + 1) - strides[i]
-                    )
+                if "output_shape" in attr:

Review Comment:
   Can you post a reference back to the docs on how these are calculated? 
https://github.com/onnx/onnx/blob/main/docs/Operators.md#ConvTranspose



-- 
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]

Reply via email to