Skip to content

Conversation

@masahi
Copy link
Member

@masahi masahi commented Nov 7, 2022

Fixes #12292
Fixes #13296

PyTorch uses the same op, aten::index, to represent indexing by both integer indices and a boolean mask. In our PT converter, Relay adv_index op is used to convert aten::index, but it doesn't correctly recognize indexing by mask - it will treat True / False as indices 0 / 1. So our converter generates an invalid model if the PT model uses such indexing, see #12292 and #13296.

I fixed this issue by explicitly tuning the mask into integer indices using argwhere, which will also take care of the inherent dynamism in indexing by mask.

cc @comaniac @junrushao @shingjan @yelite

@tvm-bot
Copy link
Collaborator

tvm-bot commented Nov 7, 2022

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.

Generated by tvm-bot

Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@comaniac comaniac merged commit e398d16 into apache:main Nov 7, 2022
@comaniac
Copy link
Contributor

comaniac commented Nov 7, 2022

Thanks @masahi

xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 10, 2022
* [Torch] Fix advanced indexing with boolean mask

* add comment
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
* [Torch] Fix advanced indexing with boolean mask

* add comment
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.

[Bug] TVM generates wrong results for ssd300_vgg16 [Bug] Tensor advanced indexing with boolean mask not working

3 participants