dgl.sparse.spspmm

dgl.sparse.spspmm(A: dgl.sparse.sparse_matrix.SparseMatrix, B: dgl.sparse.sparse_matrix.SparseMatrix)dgl.sparse.sparse_matrix.SparseMatrix[source]

Multiplies a sparse matrix by a sparse matrix, equivalent to A @ B.

The non-zero values of the two sparse matrices must be 1D.

Parameters
Returns

Sparse matrix of shape (L, N).

Return type

SparseMatrix

Examples

>>> indices1 = torch.tensor([[0, 1, 1], [1, 0, 1]])
>>> val1 = torch.ones(len(row1))
>>> A = dglsp.spmatrix(indices1, val1)
>>> indices2 = torch.tensor([[0, 1, 1], [0, 2, 1]])
>>> val2 = torch.ones(len(row2))
>>> B = dglsp.spmatrix(indices2, val2)
>>> dglsp.spspmm(A, B)
SparseMatrix(indices=tensor([[0, 0, 1, 1, 1],
                             [1, 2, 0, 1, 2]]),
             values=tensor([1., 1., 1., 1., 1.]),
             shape=(2, 3), nnz=5)