Skip to content
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

Avoid copy when returning python numpy / array #139

Closed
axsaucedo opened this issue Feb 9, 2021 · 1 comment
Closed

Avoid copy when returning python numpy / array #139

axsaucedo opened this issue Feb 9, 2021 · 1 comment
Labels

Comments

@axsaucedo
Copy link
Member

PyBind11 allows for efficient data passing between C++ and python, particularly in cases where the memory is owned by the C++ program, and the data is passed upstream to Python. This can be implemented in a simple way via either the def_buffer definition, or alternatively by casting the data into a py::capsule which seems to be a non-owning memory container. References:

This issue would depend on whether part 4 of #136 is carried out, as removing the std::vector completely, would result in having just a std::span which is a non-owning "memory-view" to the host-visible GPU memory, and there may be hidden nuances when passing this non-owning view to python as a buffer (including non-explicit performance nuances that may be better to make explicit, such as by recommending to minimise copies to/from tensors).

@axsaucedo axsaucedo added enhancement New feature or request performance python labels Feb 9, 2021
@axsaucedo
Copy link
Member Author

This was done via #164

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant