torch.Tensor.col_indices

Tensor.col_indices() IntTensor

self是布局为sparse_csr的稀疏CSR张量时,此函数返回包含self张量列索引的张量。该col_indices 张量具有形状 (self.nnz()) 并且类型为 int32int64。在使用 MKL 路由(如稀疏矩阵乘法)时,为了防止信息丢失,必须使用 int32 索引。

示例:
>>> csr = torch.eye(5,5).to_sparse_csr()
>>> csr.col_indices()
tensor([0, 1, 2, 3, 4], dtype=torch.int32)
本页目录