pytorch / nestedtensor

[Prototype] Tools for the concurrent manipulation of variably sized Tensors.
BSD 3-Clause "New" or "Revised" License
252 stars 28 forks source link

Cannot index into a NestedTensor with grad ie nt[0] #472

Open erichan1 opened 2 years ago

erichan1 commented 2 years ago

🐛 Bug

Can index into a NestedTensor without grad, but cannot index into a NestedTensor with grad

To Reproduce

Steps to reproduce the behavior:

import torch
c = torch.Tensor([1,2])
d = torch.nested_tensor([c,c])
print(d[0]) # works
d.requires_grad=True
print(d[0]) # fails
Traceback (most recent call last):
  File "/fsx/users/erichan1/work/erichan1_test/random/nt_index_test.py", line 6, in <module>
    print(d[0]) # fails
RuntimeError: Internal error: NestedTensorImpl doesn't support sizes. Please file an issue on https://github.com/pytorch/nestedtensor

Expected behavior

The second print should print tensor([1., 2.]), but fails instead.

Environment

Additional context

n/a