Can鈥檛 save SparseTensor for custom device #121797
Labels
module: sparse
Related to torch.sparse
triaged
This issue has been looked at a team member, and triaged and prioritized into an appropriate module
馃悰 Describe the bug
Our backend has support to create SparseTensor, but we find that SparseTensor in PrivateUse1 can not be saved directly, like:
It will raise error
TypeError: can't convert Sparse layout tensor to numpy. Use Tensor.dense() first.
I found that the following code was causing the problem:
pytorch/torch/_tensor.py
Lines 262 to 273 in e99fa00
SparseTensor doesn't have storage, so above code will be running. And
self.cpu().numpy()
will failed inpytorch/torch/csrc/utils/tensor_numpy.cpp
Lines 133 to 138 in e99fa00
I think here are two ways to solve this problem, maybe you have other advice?
pytorch/torch/_tensor.py
Lines 263 to 264 in e99fa00
numpy()
cannot handle these tensorsVersions
torch/main
cc @alexsamardzic @nikitaved @pearu @cpuhrsch @amjames @bhosmer @jcaip
The text was updated successfully, but these errors were encountered: