data-apis / array-api

RFC document, tooling and other content related to the array API standard
https://data-apis.github.io/array-api/latest/
MIT License
215 stars 45 forks source link

Minor clarification for conflicting information in `__dlpack__` #831

Open ndgrigorian opened 3 months ago

ndgrigorian commented 3 months ago

The specification page for __dlpack__ requires the following two, conflicting things:

for the dlpack_device argument

The v2023.12 standard only mandates that a compliant library should offer a way for dlpack to return a capsule referencing an array whose underlying memory is accessible to the Python interpreter (represented by the kDLCPU enumerator in DLPack). If a copy must be made to enable this support but copy is set to False, the function must raise ValueError.

for the copy argument

If False, the function must never copy, and raise a BufferError in case a copy is deemed necessary (e.g. if a cross-device data movement is requested, and it is not possible without a copy).

These appear to be mutually exclusive and in direct conflict. It would be nice to clarify the correct intention

leofang commented 1 month ago

Thanks for catching this. It seems raising ValueError is a mistake.