dgl.sparse.bspmm

dgl.sparse.bspmm(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 by batches, equivalent to A @ X.

Parameters
  • A (SparseMatrix or DiagMatrix) – Sparse matrix of shape (L, M) with vector values of length K

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

Returns

Dense matrix of shape (L, N, K)

Return type

torch.Tensor

Examples

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