You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/04/20 09:01:50 UTC

[GitHub] [tvm] ah-cheng opened a new pull request, #11076: [frontend][ONNX]support ConvTranspose explicitly specified output_shape

ah-cheng opened a new pull request, #11076:
URL: https://github.com/apache/tvm/pull/11076

   When I import the onnx model efficientdet_lite.onnx. There are some ConvTranspose operator just provide `output_shape` attributes. no `pads`. As shown in the picture below:
   ![image](https://user-images.githubusercontent.com/50271153/164190563-340e13a6-9623-4ac3-85be-3591a8d6fd67.png)
   Then i get a error is the
    ```
   AssertionError: Output shapes (1, 256, 256, 16) and (1, 270, 270, 16) don't match
   ```
   According the doc
   ```
   https://github.com/onnx/onnx/blob/main/docs/Operators.md#ConvTranspose
   total_padding[i] = stride[i] * (input_size[i] - 1) + output_padding[i] + ((kernel_shape[i] - 1) * dilations[i] + 1) - output_shape[i]
   ```
   I updated how `total_padding` is calculated. And support  explicitly specified the ```output_shape```.
   
   cc: @MatthewARM  @jwfromm  @AndrewZhaoLuo  
   
   
   


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] AndrewZhaoLuo commented on pull request #11076: [frontend][ONNX]support ConvTranspose explicitly specified output_shape

Posted by GitBox <gi...@apache.org>.
AndrewZhaoLuo commented on PR #11076:
URL: https://github.com/apache/tvm/pull/11076#issuecomment-1127891963

   Thanks! Was out on vacation last week so apologies for not merging sooner


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] ah-cheng commented on pull request #11076: [frontend][ONNX]support ConvTranspose explicitly specified output_shape

Posted by GitBox <gi...@apache.org>.
ah-cheng commented on PR #11076:
URL: https://github.com/apache/tvm/pull/11076#issuecomment-1107177346

   I am confused. Why did the test pass before. And I can also test it pass locally.
   Maybe I will check it again today.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] ah-cheng commented on pull request #11076: [frontend][ONNX]support ConvTranspose explicitly specified output_shape

Posted by GitBox <gi...@apache.org>.
ah-cheng commented on PR #11076:
URL: https://github.com/apache/tvm/pull/11076#issuecomment-1107706463

   Looks like it's an onnx official issue.  According to the codeļ¼š
   ```
   https://github.com/onnx/onnx/blob/8ab1efa4fc979e1748ebd378a71a59a22deabe88/onnx/defs/nn/defs.cc
   ```
   the function `convTransposeShapeInference` we can know. 
   It did not perform additional processing on the value of pad after explicitly specifying output_shape.
   So according to the test
   https://github.com/onnx/onnx/blob/main/onnx/backend/test/case/node/convtranspose.py
   The default pads is [0,0,0,0]
   So the last result is [1, 2, 9, 7]
   
   So about this PR. I should close it now until the onnx office fix it?  Or I still add the `test_convtranspose_output_shape` in `unsupported_onnx_tests`?  So you can review this PR?


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] AndrewZhaoLuo commented on pull request #11076: [frontend][ONNX]support ConvTranspose explicitly specified output_shape

Posted by GitBox <gi...@apache.org>.
AndrewZhaoLuo commented on PR #11076:
URL: https://github.com/apache/tvm/pull/11076#issuecomment-1108893123

   We should match behavior in the official onnx test. Don't have time to take a look deeply at this, but if you can figure it out it will be cool B)
   
   To run the failing test you can do
   
   `pytest tests/python/frontend/onnx/test_forward.py::test_onnx_nodes[test_convtranspose_output_shape-llvm]` 
   
   (You can get the failing test names from the Jenkins "test" tab)


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] ah-cheng commented on pull request #11076: [frontend][ONNX]support ConvTranspose explicitly specified output_shape

Posted by GitBox <gi...@apache.org>.
ah-cheng commented on PR #11076:
URL: https://github.com/apache/tvm/pull/11076#issuecomment-1107333359

   Looks like it because of   remove "test_convtranspose_output_shape". Right?


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] AndrewZhaoLuo commented on a diff in pull request #11076: [frontend][ONNX]support ConvTranspose explicitly specified output_shape

Posted by GitBox <gi...@apache.org>.
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] AndrewZhaoLuo commented on pull request #11076: [frontend][ONNX]support ConvTranspose explicitly specified output_shape

Posted by GitBox <gi...@apache.org>.
AndrewZhaoLuo commented on PR #11076:
URL: https://github.com/apache/tvm/pull/11076#issuecomment-1106881080

   Looks like we don't match onnx behavior based on official tests.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] AndrewZhaoLuo merged pull request #11076: [frontend][ONNX]support ConvTranspose explicitly specified output_shape

Posted by GitBox <gi...@apache.org>.
AndrewZhaoLuo merged PR #11076:
URL: https://github.com/apache/tvm/pull/11076


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] ah-cheng commented on pull request #11076: [frontend][ONNX]support ConvTranspose explicitly specified output_shape

Posted by GitBox <gi...@apache.org>.
ah-cheng commented on PR #11076:
URL: https://github.com/apache/tvm/pull/11076#issuecomment-1109203997

   OK, thank you very much for your reply. @AndrewZhaoLuo .  I will continue to follow up on this issue.
   BTW, I have raised an issue on the official onnx to discuss this issue. When necessary, I will also raise PR to fix this problem, and then we will follow up with this PR.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] AndrewZhaoLuo commented on pull request #11076: [frontend][ONNX]support ConvTranspose explicitly specified output_shape

Posted by GitBox <gi...@apache.org>.
AndrewZhaoLuo commented on PR #11076:
URL: https://github.com/apache/tvm/pull/11076#issuecomment-1104741855

   I'll look at this tomorrow


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [tvm] ah-cheng commented on pull request #11076: [frontend][ONNX]support ConvTranspose explicitly specified output_shape

Posted by GitBox <gi...@apache.org>.
ah-cheng commented on PR #11076:
URL: https://github.com/apache/tvm/pull/11076#issuecomment-1120531159

   It seems not auto merge, Please help to review again. Thanks. 
   I found the version of official onnx test `test_convtranspose_output_shape`  is `version 9`, It is the reason why test fail at begin. now, I fix it and it test success.


-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org