[Frontend][ONNX]support Pool2D layout is CHW#11034
Merged
AndrewZhaoLuo merged 3 commits intoapache:mainfrom Apr 20, 2022
chengven027:ven.dev
Merged
[Frontend][ONNX]support Pool2D layout is CHW#11034AndrewZhaoLuo merged 3 commits intoapache:mainfrom chengven027:ven.dev
AndrewZhaoLuo merged 3 commits intoapache:mainfrom
chengven027:ven.dev
Conversation
added 2 commits
April 18, 2022 19:35
Contributor
There was a problem hiding this comment.
The central issue is that onnx expects a batch dimension: https://github.com/onnx/onnx/blob/main/docs/Operators.md#maxpool
So technically your onnx model is malformed (probably pytorch onnx converter is non spec compliant) since it does not have a batch dimension input to the pooling op. We have seen this before so I'm fine with the change in general. Just address comments and also document this fact.
python/tvm/relay/frontend/onnx.py
Outdated
| return attr_cvt([data], attr, params) | ||
| out = attr_cvt([data], attr, params) | ||
|
|
||
| if ndim == 3 and len(attr["kernel_shape"]) == 2: |
Contributor
There was a problem hiding this comment.
Can you make this so if kernel_shape rank and ndim differ by 1 we assume it's missing a batch dimension and runs below code? (same thing for _run_calculation)
Contributor
Author
|
ok, thanks @AndrewZhaoLuo |
AndrewZhaoLuo
approved these changes
Apr 20, 2022
shtinsa
pushed a commit
to Deelvin/tvm
that referenced
this pull request
May 17, 2022
* support Pool layout is CHW * fix lint test * change the if condition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, my onnx model is superpoint. it's converted from a pytorch model.
When I import the model. I get the relay as follow:
The model layer in Netron is:

Then we can see the %39 reshape is a 3 dimensions. It is legal in pytorch model. But in ONNX, I will get a error.
Then I will add a
expand_dimsbefore pool2D and a squeeze after pool2D like the code I commited.But i don`t know how to add a unit test case. because there will be error in onnxruntime if the pool2D shape is 3D.

cc: @MatthewARM @jwfromm @AndrewZhaoLuo