Skip to content

Commit ba787e3

Browse files
authored
Add recommendation on what to do with DLPack read-only flag (#749)
This is a follow-up to the discussion in gh-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.
1 parent cc11aa3 commit ba787e3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: src/array_api_stubs/_draft/array_object.py

+6
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,12 @@ def __dlpack__(
444444
This logic is also applicable to handling of the new ``dl_device`` and ``copy``
445445
keywords.
446446
447+
DLPack 1.0 added a flag to indicate that the array is read-only
448+
(``DLPACK_FLAG_BITMASK_READ_ONLY``). A consumer that does not support
449+
read-only arrays should ignore this flag (this is preferred over
450+
raising an exception; the user is then responsible for ensuring the
451+
memory isn't modified).
452+
447453
.. versionchanged:: 2022.12
448454
Added BufferError.
449455

0 commit comments

Comments
 (0)