Create a pytorch type list for tensors of different sizes?

Hey guys, so I am trying to create a PyTorch type of list for a few tensors of different sizes but same dimensions; e.g.,

A = torch.randn(3,3)
B = torch.randn(5,5)

So I need to create a PyTorch type object like [A, B], for the purpose of vectorized calculation (matrix multiplication, matrix inverse, …) happened later on (to each element in the list; i.e., A,B,...). How should I do this?

Further to this, is it possible to do this for a list of tensors of different dimensions?

Hi,

What you would want here is a NestedTensor. This is work in progress at the moment. You can follow the current status on this issue: https://github.com/pytorch/pytorch/issues/25032

So nestedtensor is a separate package than torch? Interesting why torch doesn’t include it.

It’s a feature, which is currently being implemented. :wink:

1 Like

I just hope it can be implemented soon so that I don’t have to use nightly lol

1 Like

Speak of nestedtensor, just to confirm, it will be able to run on GPU right?

Yes it will.
The current experimental repo here should already support it.