Skip to content

Update DLPack content to address unsupported use cases #709

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

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
16 changes: 16 additions & 0 deletions spec/draft/design_topics/data_interchange.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,19 @@ page gives a high-level specification for data exchange in Python using DLPack.
are recommended to do so using the same syntax and semantics as outlined
below. They are not required to return an array object from ``from_dlpack``
which conforms to this standard.

Non-supported use cases
-----------------------

Use of DLPack requires that the data can be represented by a strided, in-memory
layout on a single device. This covers usage by a large range of, but not all,
known and possible array libraries. Use cases that are not supported by DLPack
include:

- Distributed arrays, i.e., the data residing on multiple nodes or devices,
- Sparse arrays, i.e., sparse representations where a data value (typically
zero) is implicit.

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.
9 changes: 9 additions & 0 deletions src/array_api_stubs/_draft/creation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,15 @@ def from_dlpack(x: object, /) -> array:
:class: note

The returned array may be either a copy or a view. See :ref:`data-interchange` for details.

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.
"""


Expand Down