dgl.sparse.spmm

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

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

Parameters
  • A (SparseMatrix or DiagMatrix) – 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(len(row))
>>> 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])