Skip to content

Commit

Permalink
Add recommendation on what to do with DLPack read-only flag
Browse files Browse the repository at this point in the history
This is a follow-up to the discussion in data-apisgh-191. It's a recommendation
rather than a hard requirement to allow implementers some choice.
That said, this is how things worked in practice before DLPack 1.0
as well, since there was no flag to represent read-only. Experience
with JAX showed that exposing shared memory was preferred by users
over raising or always making a copy of the data on the producer side.
  • Loading branch information
rgommers committed Feb 15, 2024
1 parent cc11aa3 commit 11cbc07
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/array_api_stubs/_draft/array_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,12 @@ def __dlpack__(
This logic is also applicable to handling of the new ``dl_device`` and ``copy``
keywords.
DLPack 1.0 added a flag to indicate that the array is read-only
(``DLPACK_FLAG_BITMASK_READ_ONLY``). A consumer that does not support
read-only arrays should ignore this flag (this is preferred over
raising an exception; the user is then responsible for ensuring the
memory isn't modified).
.. versionchanged:: 2022.12
Added BufferError.
Expand Down

0 comments on commit 11cbc07

Please sign in to comment.