Closed gao462 closed 2 years ago
It is best to use the SparseTensor
class directly for this:
from torch_sparse import SparseTensor
spmat = SparseTensor(row=torch.from_numpy(rows),
col=torch.from_numpy(cols),
value=torch.from_numpy(vals),
sparse_sizes=(3, 4))
print(spmat @ spmat.t())
The spspmm
interface is pretty old and not well maintained. You can fix your initial error by running
(indices, values) = spspmm(indices, values, indices[[1, 0]], values, num_srcs,
num_dsts, num_srcs, coalesced=True)
The sparse-sparse multiplication (
spspmm
) gives wrong output which is different from SciPy sparse matrix multiplication.Get results:
torch_sparse
version is0.6.14
.