dgl.sparse.SparseMatrix.csrΒΆ
-
SparseMatrix.
csr
() → Tuple[torch.Tensor, torch.Tensor, torch.Tensor][source]ΒΆ Returns the compressed sparse row (CSR) representation of the sparse matrix.
See CSR in Wikipedia.
This function also returns value indices as an index tensor, indicating the order of the values of non-zero elements in the CSR representation. A
None
value indices array indicates the order of the values stays the same as the values of the SparseMatrix.- Returns
torch.Tensor β Row indptr
torch.Tensor β Column indices
torch.Tensor β Value indices
Examples
>>> indices = torch.tensor([[1, 2, 1], [2, 4, 3]]) >>> A = dglsp.spmatrix(indices) >>> A.csr() (tensor([0, 0, 2, 3]), tensor([2, 3, 4]), tensor([0, 2, 1]))