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

[Frontend][Pytorch]Add Pytorch advanced indexing #6318

Merged
merged 3 commits into from
Aug 22, 2020

Conversation

kevinthesun
Copy link
Contributor

This PR adds support for Pytorch advanced indexing aten::index and also fixes an issue in Pytorch slice mapping.

@masahi @yongwww @zhiics

data = inputs[0]
indices = []
max_indices_len = -1
for index in inputs[1]:
Copy link
Member

Choose a reason for hiding this comment

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

seems these two for loops are able to be merged

Copy link
Contributor Author

Choose a reason for hiding this comment

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

max_indices_len needs to be fetched first.

if index_key in slice_map:
tmp = slice_map[index_key]
else:
tmp = _op.take(tmp, _expr.const(index[i]), axis=0)
Copy link
Member

Choose a reason for hiding this comment

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

out of curiosity, would this introduce many take and tile ops?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In most cases it should be fine, but we can definitely improve it by adding a new topi implementation.

Copy link
Member

Choose a reason for hiding this comment

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

I am okay with this for now. We can implement a topi op if when perf is not good.

@masahi masahi merged commit 88f6f79 into apache:master Aug 22, 2020
@masahi
Copy link
Member

masahi commented Aug 22, 2020

Thanks @kevinthesun @zhiics @yongwww

trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Aug 26, 2020
* Add Pytorch advanced indexing

* Minor fix for test

* Fix for cuda
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Aug 26, 2020
* Add Pytorch advanced indexing

* Minor fix for test

* Fix for cuda
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Aug 26, 2020
* Add Pytorch advanced indexing

* Minor fix for test

* Fix for cuda
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Sep 2, 2020
* Add Pytorch advanced indexing

* Minor fix for test

* Fix for cuda
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Sep 3, 2020
* Add Pytorch advanced indexing

* Minor fix for test

* Fix for cuda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants