torch.Tensor.crow_indices#
- Tensor.crow_indices() IntTensor#
Returns the tensor containing the compressed row indices of the
selftensor whenselfis a sparse CSR tensor of layoutsparse_csr. Thecrow_indicestensor is strictly of shape (self.size(0) + 1) and of typeint32orint64. When using MKL routines such as sparse matrix multiplication, it is necessary to useint32indexing in order to avoid downcasting and potentially losing information.Example:
>>> csr = torch.eye(5,5).to_sparse_csr() >>> csr.crow_indices() tensor([0, 1, 2, 3, 4, 5], dtype=torch.int32)