dgl.sparse.spmm

dgl.sparse.spmm(A: dgl.sparse.sparse_matrix.SparseMatrix, X: torch.Tensor)torch.Tensor[source]

Multiplies a sparse matrix by a dense matrix, equivalent to A @ X.

Parameters
  • A (SparseMatrix) – Sparse matrix of shape (L, M) with scalar values

  • X (torch.Tensor) – Dense matrix of shape (M, N) or (M)

Returns

The dense matrix of shape (L, N) or (L)

Return type

torch.Tensor

Examples

>>> indices = torch.tensor([[0, 1, 1], [1, 0, 1]])
>>> val = torch.randn(indices.shape[1])
>>> A = dglsp.spmatrix(indices, val)
>>> X = torch.randn(2, 3)
>>> result = dglsp.spmm(A, X)
>>> type(result)
<class 'torch.Tensor'>
>>> result.shape
torch.Size([2, 3])