Convert a tensor to compressed row storage format (CSR). Except for strided tensors, only works with 2D tensors. If the self
is strided, then the number of dense dimensions could be specified, and a hybrid CSR tensor will be created, with dense_dim dense dimensions and self.dim() - 2 - dense_dim batch dimension.
dense_dim (int, optional) – Number of dense dimensions of the resulting CSR tensor. This argument should be used only if self
is a strided tensor, and must be a value between 0 and dimension of self
tensor minus two.
Example:
>>> dense = torch.randn(5, 5) >>> sparse = dense.to_sparse_csr() >>> sparse._nnz() 25 >>> dense = torch.zeros(3, 3, 1, 1) >>> dense[0, 0] = dense[1, 2] = dense[2, 1] = 1 >>> dense.to_sparse_csr(dense_dim=2) tensor(crow_indices=tensor([0, 1, 2, 3]), col_indices=tensor([0, 2, 1]), values=tensor([[[1.]], [[1.]], [[1.]]]), size=(3, 3, 1, 1), nnz=3, layout=torch.sparse_csr)
Access comprehensive developer documentation for PyTorch
View Docs TutorialsGet in-depth tutorials for beginners and advanced developers
View Tutorials ResourcesFind development resources and get your questions answered
View ResourcesRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4