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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency between index_select and __get_item__ #83702

Open
smorad opened this issue Aug 18, 2022 · 1 comment
Open

Inconsistency between index_select and __get_item__ #83702

smorad opened this issue Aug 18, 2022 · 1 comment
Labels
module: advanced indexing Related to x[i] = y, index functions triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@smorad
Copy link
Contributor

smorad commented Aug 18, 2022

馃悰 Describe the bug

We should be able to index using torch.int32 using the bracket notation. It is possible using index_select:

>>> idx = torch.tensor([0]).int()
>>> a = torch.rand(3)
>>> a[idx]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: tensors used as indices must be long, byte or bool tensors
>>> a.index_select(0, idx)
tensor([0.6999])

When dealing with large sets of indices (e.g. graph edge lists), this means we have to use more memory.

Versions

master

@mikaylagawarecki mikaylagawarecki added module: advanced indexing Related to x[i] = y, index functions triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Aug 18, 2022
@vadimkantorov
Copy link
Contributor

vadimkantorov commented Aug 18, 2022

Related: #61819, pyg-team/pytorch_geometric#5087

It would be nice to support other integer dtypes, and without upcasts using more memory (maybe via jiterator or some jit/codegen?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: advanced indexing Related to x[i] = y, index functions triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

3 participants