dgl.sparse is a library for sparse operators that are commonly used in GNN models.
dgl.sparse
A SparseMatrix can be created from Coordinate format indices using the spmatrix
constructor:
>>> indices = torch.tensor([[1, 1, 2], >>> [2, 4, 3]]) >>> A = dglsp.spmatrix(indices) SparseMatrix(indices=tensor([[1, 1, 2], [2, 4, 3]]), values=tensor([1., 1., 1.]), shape=(3, 5), nnz=3)
Creation Ops
spmatrix val_like from_coo from_csr from_csc diag identity
SparseMatrix.shape SparseMatrix.nnz SparseMatrix.dtype SparseMatrix.device SparseMatrix.val SparseMatrix.row SparseMatrix.col SparseMatrix.indices SparseMatrix.coo SparseMatrix.csr SparseMatrix.csc SparseMatrix.coalesce SparseMatrix.has_duplicate SparseMatrix.to_dense SparseMatrix.to SparseMatrix.cuda SparseMatrix.cpu SparseMatrix.float SparseMatrix.double SparseMatrix.int SparseMatrix.long SparseMatrix.transpose SparseMatrix.t SparseMatrix.T SparseMatrix.neg SparseMatrix.reduce SparseMatrix.sum SparseMatrix.smax SparseMatrix.smin SparseMatrix.smean SparseMatrix.softmax
dgl.sparse
Elementwise Operators
add sub mul div power
Matrix Multiplication
matmul spmm bspmm spspmm sddmm bsddmm
Non-linear activation functions
softmax
Broadcast operators
sp_broadcast_v sp_add_v sp_sub_v sp_mul_v sp_div_v