XT_Li
(Xt Li)
1
I tired to use torch.mm for a sparse matrix and a dense matrix, but got following error:
TypeError: Type torch.cuda.sparse.FloatTensor doesn't implement stateless method addmm
Is it possible to multiply a sparse matrix with a dense matrix on GPU ? Thanks!
tom
(Thomas V)
2
I think you need the functions from the torch.sparse module.
Best regards
Thomas
richard
3
Seems to work for me:
import torch
from torch.autograd import Variable
i = torch.LongTensor([[0, 1, 1],
[2, 0, 2]])
v = torch.FloatTensor([3, 4, 5])
x = torch.sparse.FloatTensor(i, v, torch.Size([2,3])).cuda()
y = x.to_dense().t()
torch.mm(x, y)
What version of pytorch are you using?
XT_Li
(Xt Li)
4
Sorry, I wasn’t being clear, my matrices are all variables.
richard
5
XT_Li
(Xt Li)
6
Hoops, I guess I have to manually do back propagation then.