评价此页

torch.Tensor.col_indices#

Tensor.col_indices() IntTensor#

返回 self 张量在 sparse_csr 布局的稀疏 CSR 张量时的列索引张量。 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)