relationPrediction icon indicating copy to clipboard operation
relationPrediction copied to clipboard

the intent of SpecialSpmmFunctionFinal and whether it can be done by Pytorch itself ?

Open zhangxin9988 opened this issue 4 years ago • 0 comments

I think SpecialSpmmFunctionFinal 's forward section is intend to compute the row sum of sparse matrix ,and backward return the gradient for the sparse matrix's values,but I find torch.sparse might solve the backward of row sum operation,for example: `i = torch.LongTensor([[0, 1, 1],[2, 0, 2]]) #row, col v = torch.FloatTensor([3, 4, 5]) #data v.requires_grad=True m=torch.sparse_coo_tensor(i, v, torch.Size([2,3])) #torch.Size() m.retain_grad()

m1=torch.sparse.sum(m,dim=1) m1.retain_grad()

m2=torch.sparse.sum(m1) m2.backward() print(v.grad)#v's gradient is tensor([1., 1., 1.])` So why do you write the autograd function or something I understand is wrong?
waitting for your reply,thanks.

zhangxin9988 avatar Dec 11 '21 09:12 zhangxin9988