-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read-only array exchange via the buffer protocol
This PR adapts nanobind so that it can both receive and return arrays representing read-only memory. This is communicated via the standard ``const`` type modifier, e.g. by replacing ``nb::ndarray<float, ...>`` with ``nb::ndarray<const float, ...>``. The PR also adapts accessors (``data()``, ``operator()``) so that they only return constant references/pointers in that case. The change is for now specific to the buffer protocol used to exchange data with NumPy. The DLPack interface (with PyTorch, Tensorflow, etc.) ignores the read-only annotation. This may change at some point in the future when an upcoming DLPack version with a read-only bit is more widely deployed.
- Loading branch information
Showing
8 changed files
with
148 additions
and
48 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Oops, something went wrong.