Shortcuts

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

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources