Initialise empty sparse tensor

I recently switched to pytorch nightly from stable version and initialising an empty sparse tensor, which worked fine previously, now throws an error:

a = torch.sparse.FloatTensor(torch.empty((0), dtype=torch.long), torch.empty((0), dtype=torch.float), torch.Size([1, 5, 30, 20]))

Error:

RuntimeError: indices must be sparse_dim x nnz, but got: [0]

Try

import torch

x = torch.empty([1, 5, 30, 20], layout=torch.sparse_coo)
1 Like