torch.Tensor.crow_indices¶
- Tensor.crow_indices() IntTensor¶
返回包含
self张量压缩行索引的 tensor,当self是一个布局为sparse_csr的稀疏 CSR 张量时。crow_indices张量的形状严格为(self.size(0) + 1),类型为int32或int64。在使用如稀疏矩阵乘法等 MKL 例程时,必须使用int32索引以避免降级并可能丢失信息。- 示例::
>>> csr = torch.eye(5,5).to_sparse_csr() >>> csr.crow_indices() tensor([0, 1, 2, 3, 4, 5], dtype=torch.int32)