Describe the bug
Not sure if I am missing something but I am trying to load a batch of lazy_stacked TensorDicts that have variable size tensors.
The DataLoader throws an error however that it cannot stack the tensors.
To Reproduce
import tensordict
import torch
tensors = [{"x": torch.rand((i,))} for i in range(10)]
tensordicts_stacked = tensordict.lazy_stack(
[tensordict.TensorDict.from_dict(x) for x in tensors]
)
dl = DataLoader(tensordicts_stacked, batch_size=4, collate_fn=lambda x: x)
next(iter(dl))
Expected behavior
Not sure if this is supposed to work but I would have expected it to return a batch of LazyStackedTensorDicts.
Reason and Possible fixes
I think it's because __getitems__ actually points to <bound method TensorDictBase.__getitem__ of LazyStackedTensorDict.
If I add __getitems__ = __getitem__ after the __getitem__ in LazyStackedTensorDict (the same as in the Base) it returns a LazyStackedTensorDict without an error.
Checklist
Describe the bug
Not sure if I am missing something but I am trying to load a batch of
lazy_stackedTensorDictsthat have variable size tensors.The
DataLoaderthrows an error however that it cannot stack the tensors.To Reproduce
Expected behavior
Not sure if this is supposed to work but I would have expected it to return a batch of
LazyStackedTensorDicts.Reason and Possible fixes
I think it's because
__getitems__actually points to<bound method TensorDictBase.__getitem__ of LazyStackedTensorDict.If I add
__getitems__ = __getitem__after the__getitem__inLazyStackedTensorDict(the same as in the Base) it returns aLazyStackedTensorDictwithout an error.Checklist