dgl.sparse.bspmm

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

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

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