On this page
torch.Tensor.to_sparse_csr
Tensor.to_sparse_csr() → Tensor
-
Convert a tensor to compressed row storage format (CSR). Only works with 2D tensors.
Example:
>>> dense = torch.randn(5, 5) >>> sparse = dense.to_sparse_csr() >>> sparse._nnz() 25
© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/1.13/generated/torch.Tensor.to_sparse_csr.html