Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Relay] Convert negative axes to positive when importing ONNX Unsqueeze #13846

Merged

Conversation

balaram-cadence
Copy link
Contributor

Currently, ONNX frontend imports Unsqueeze as a sequence of expand_dims in Relay. This works fine when the axes are positive.

However, for negative axes we need to compute the output rank and add the negative axis value to get its equivalent positive axis value.

This commit computes the output rank as the sum of the input rank of data and the number of axis in the axes array and convert negative axes to positive.

This commit also adds testcases for unsqueeze with negative axes and verifies the result with onnx runtime.

@tvm-bot
Copy link
Collaborator

tvm-bot commented Jan 26, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

  • No users to tag found in teams: relay See #10317 for details

Generated by tvm-bot

@balaram-cadence
Copy link
Contributor Author

@AndrewZhaoLuo : This is my first pull request. Can you please take a look?

@masahi masahi merged commit 2bfdcbe into apache:main Jan 27, 2023
@balaram-cadence balaram-cadence deleted the cadence/balaram/unsqueeze_neg_axes branch January 27, 2023 11:55
fzi-peccia pushed a commit to fzi-peccia/tvm that referenced this pull request Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants