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

[Feature Request] Default creation of LazyStackedTensorDict vs TensorDict when calling torch.stack? #5

Closed
vmoens opened this issue Feb 10, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@vmoens
Copy link
Contributor

vmoens commented Feb 10, 2022

By default, torch.stack(list_of_tds, dim) will return a LazyStackedTensorDict object.
Keeping the discussion about the usefulness of this class apart, it may be more desirable to have a LazyStackedTensorDict created only when it is explicitely asked by the user, e.g.

stacked_td = torch.stack(list_of_tds, dim)
assert isinstance(stacked_td, TensorDict) # passes

stacked_td = torch.stack(list_of_tds, dim, contiguous=False)
assert isinstance(stacked_td, LazyStackedTensorDict) # passes

The main advantage is that working with LazyStackedTensorDict can be computationally expensive and users may not be aware of this bottleneck.
Also, when called on lists of torch.Tensor objects, torch.stack does not return a non-contiguous object. Aligning TensorDict behaviour to this might be beneficial for consistency purposes.

@vmoens vmoens added the enhancement New feature or request label Feb 10, 2022
@vmoens vmoens self-assigned this Feb 10, 2022
@Benjamin-eecs Benjamin-eecs changed the title Default creation of LazyStackedTensorDict vs TensorDict when calling torch.stack? [Feature Request] Default creation of LazyStackedTensorDict vs TensorDict when calling torch.stack? Jul 21, 2022
@vmoens
Copy link
Contributor Author

vmoens commented Aug 29, 2022

Closing as #352 made it clear that this is needed. Happy to re open if needed

@vmoens vmoens closed this as not planned Won't fix, can't repro, duplicate, stale Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant