pytorch / 1 / generated / torch.tensor.to_sparse_csc.html

torch.Tensor.to_sparse_csc

Tensor.to_sparse_csc() → Tensor

Convert a tensor to compressed column storage (CSC) format. Only works with 2D tensors.

Example:

>>> dense = torch.randn(5, 5)
>>> sparse = dense.to_sparse_csc()
>>> 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_csc.html