Torch.stack cannot be useful for tensors with different dimensions

I would like to convert type(tmp) to tensor.

tmp = [torch.tensor([1]),torch.tensor([2,3])]
type(tmp) -> <class 'list'>
type(tmp[0]) -> <class 'torch.Tensor'>
type(tmp[0][0]) -> <class 'torch.Tensor'>

How can I realize it?

Hi,

I’m afraid this is not possible with regular Tensors.

You can check the experimental nested tensor here though as it seems it will fit your need.