torch.Tensor.crow_indices#
- Tensor.crow_indices() IntTensor#
返回包含
self張量在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)