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

Update DLPack content to address unsupported use cases #709

Merged
merged 2 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion spec/draft/design_topics/data_interchange.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ include:

There may be other reasons why it is not possible or desirable for an
implementation to materialize the array as strided data in memory. In such
cases, the implementation may raise a `BufferError` in the `__dlpack__` method.
cases, the implementation may raise a `BufferError` in the `__dlpack__` or
`__dlpack_device__` method. In case an implementation is never able to export
its array data via DLPack, it may omit `__dlpack__` and `__dlpack_device__`
completely, and hence `from_dlpack` may raise an `AttributeError`.
15 changes: 10 additions & 5 deletions src/array_api_stubs/_draft/creation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,16 @@ def from_dlpack(x: object, /) -> array:
Raises
------
BufferError
The ``__dlpack__`` method on the input array may raise ``BufferError``
when the data cannot be exported as DLPack (e.g., incompatible dtype or
strides). It may also raise other errors when export fails for other
reasons (e.g., not enough memory available to materialize the data).
``from_dlpack`` must propagate such exceptions.
The ``__dlpack__`` and ``__dlpack_device__`` methods on the input array
may raise ``BufferError`` when the data cannot be exported as DLPack
(e.g., incompatible dtype or strides). It may also raise other errors
when export fails for other reasons (e.g., not enough memory available
to materialize the data). ``from_dlpack`` must propagate such
exceptions.
AttributeError
If the ``__dlpack__`` and ``__dlpack_device__`` methods are not present
on the input array. This may happen for libraries that are never able
to export their data with DLPack.
"""


Expand Down