Rate this Page

torch.Tensor.col_indices#

Tensor.col_indices()IntTensor#

Returns the tensor containing the column indices of theselftensor whenself is a sparse CSR tensor of layoutsparse_csr.Thecol_indices tensor is strictly of shape (self.nnz())and of typeint32 orint64. When using MKL routines such as sparsematrix multiplication, it is necessary to useint32 indexing in orderto avoid downcasting and potentially losing information.

Example:

>>>csr=torch.eye(5,5).to_sparse_csr()>>>csr.col_indices()tensor([0, 1, 2, 3, 4], dtype=torch.int32)