Replies: 1 comment 8 replies
|
You could copy the data to a new Tensor instead. You could also transfer the ownership of the Pointer to the new Tensor by providing a deallocator to from_blob().
|
8 replies
Answer selected by
guangster
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi, I would like to persist a Tensor object outside a PoinsterScope. Following your example here
gives me access to Tensor but the underlying data seems to get cleaned. The only solution I found is to call
retainReference()on the original Pointer I passed totorch.from_blob(Pointer,...). This is not ideal as I have to track each Pointer I used to create the Tensor. Neither callingretainReference()on Tensor, nor on the output ofTensor.data_ptr_float()worked (corrupted data after) even thoughTensor.data_ptr_float()returned a pointer with the same address as the original Pointer. Is there a way for us to get the original Pointer from the tensor, or some better ways to retain the tensor?I attached my example below along with the output I observed. Any help is greatly appreciated!
All reactions