Sparse tensor multiplication throws a run-time error



I am trying to use torch.mul() for a sparse tensor, but unfortunately the code below throws a run-time error:

a = torch.tensor([0.92], requires_grad=True)

i = torch.LongTensor([[0,0,0,0], [0,0,1,1], [0,0,2,2], [0,0,3,3]])
v = torch.FloatTensor([1, 2, 1, 1])

# A 4D sparse tensor
t = torch.sparse.FloatTensor(i.t(), v, torch.Size([2,2,5,5]))

# multiplication
y = torch.mul(a,t)


Traceback (most recent call last):
  File "", line 59, in <module>
    y = torch.mul(a,t)
RuntimeError: sparse tensors do not have strides

Is sparse matrix multiplication not supported at the moment?



According to #8853, mul/mul_ for (Sparse, Sparse) -> Sparse and (Sparse, Scalar) -> Sparse exist, but (Sparse, Dense) is still on todo list.