1

In pytorch, I can achieve two sparse matrixes multiplication by first turning them into a dense form

adjdense = torch.sparse.FloatTensor(indextmp, valuetmp, torch.Size([num_nodes,num_nodes])).to_dense()
mask_dense = torch.sparse.FloatTensor(edge_index, edge_mask_list[k], torch.Size([num_nodes,num_nodes])).to_dense()
gdcdense = adjdense * mask_dense

but when the graph is large, this method requires a lot of memory. Thus, How to multiply a sparse matrix by a sparse matrix element-wise in pytorch? Thanks a lot.

Unicion
  • 11
  • 2

1 Answers1

0

Thanks for sim. I have known how to do it.

adjsparse = torch.sparse.FloatTensor(indextmp, valuetmp, torch.Size([num_nodes,num_nodes])) masksparse = torch.sparse.FloatTensor(edge_index, edge_mask_list[k],torch.Size([num_nodes,num_nodes]))

result = adjsparse.mul(masksparse)

Unicion
  • 11
  • 2