[ 
https://issues.apache.org/jira/browse/ARROW-4452?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17661474#comment-17661474
 ] 

Rok Mihevc commented on ARROW-4452:
-----------------------------------

This issue has been migrated to [issue 
#21010|https://github.com/apache/arrow/issues/21010] on GitHub. Please see the 
[migration documentation|https://github.com/apache/arrow/issues/14542] for 
further details.

> [Python] Serializing sparse torch tensors
> -----------------------------------------
>
>                 Key: ARROW-4452
>                 URL: https://issues.apache.org/jira/browse/ARROW-4452
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: Python
>            Reporter: Philipp Moritz
>            Assignee: Philipp Moritz
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 0.14.0
>
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> Using the pytorch serialization handler on sparse Tensors:
> {code:java}
> import torch
> i = torch.LongTensor([[0, 2], [1, 0], [1, 2]])
> v = torch.FloatTensor([3,      4,      5    ])
> tensor = torch.sparse.FloatTensor(i.t(), v, torch.Size([2,3]))
> pyarrow.serialization.register_torch_serialization_handlers(pyarrow.serialization._default_serialization_context)
> s = pyarrow.serialize(tensor, 
> context=pyarrow.serialization._default_serialization_context) {code}
> Produces this result:
> {code:java}
> TypeError: can't convert sparse tensor to numpy. Use Tensor.to_dense() to 
> convert to a dense tensor first.{code}
> We should provide a way to serialize sparse torch tensors, especially now 
> that we are getting support for sparse Tensors.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to