-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Tensor to PyObject conversion using torch_python #457
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Would be very interested in this as well, as this would be a nice path forward for writing fast dataloader in rust. |
@LaurentMazare, would love to see this PR considered; it would make integrating python and rust pytorch code more ergonomic. |
Any updates on this one? |
Closing this as these functionalities should now be available from the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These changes add a few additional bindings to torch_python library.
Mainly:
THPVariable_Unpack
for unpacking PyObject into a Tensor pointerTHPVariable_Check
for checking whether PyObject is a valid Tensor objectTHPVariable_Wrap
for creating PyObject from a Tensor pointer (and transferring ownership)Additionally pyo3 type conversion traits are implemented for Torch struct to convert between PyObject and Tensor seamlessly when defining pyo3 functions.
An example project is included creating a simple counter/metric class which accumulates tensor objects and computes a metric as output while exposing the counter tensor.
The changes are split over torch-sys (
python
feature) and tch (torch_python
feature) modules.The relevant issue to this PR would be: #174
Thanks in advance. Let me know if some changes are needed.