Skip to content

Commit 84c9983

Browse files
committed
docs: allow per-device dtype subsets
1 parent 8884c40 commit 84c9983

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

spec/draft/API_specification/creation_functions.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ Objects in API
3434
triu
3535
zeros
3636
zeros_like
37+
38+
39+
.. note::
40+
Creation functions which accept ``device`` and ``dtype`` arguments should raise an
41+
exception if the explicitly provided ``dtype`` is not supported by the ``device``.

spec/draft/API_specification/data_types.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Data Types
55

66
Array API specification for supported data types.
77

8-
A conforming implementation of the array API standard must provide and support
8+
A conforming implementation of the array API standard should provide and support
99
the following data types ("dtypes") in its array object, and as data type
1010
objects in its main namespace under the specified names:
1111

@@ -39,6 +39,9 @@ objects in its main namespace under the specified names:
3939
| complex128 | Double-precision (128-bit) complex floating-point number whose real and imaginary components must be IEEE 754 double-precision (64-bit) binary floating-point numbers (see IEEE 754-2019). |
4040
+--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
4141

42+
If a library only supports a subset of data types, it must support at least one data type
43+
from each :ref:`category <data-type-categories>`.
44+
4245
Data type objects must have the following methods (no attributes are required):
4346

4447
..

spec/draft/design_topics/device_support.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ rather than hard requirements:
7777
- Respect explicit device assignment (i.e. if the input to the ``device=`` keyword is not ``None``, guarantee that the array is created on the given device, and raise an exception otherwise).
7878
- Preserve device assignment as much as possible (e.g. output arrays from a function are expected to be on the same device as input arrays to the function).
7979
- Raise an exception if an operation involves arrays on different devices (i.e. avoid implicit data transfer between devices).
80+
- Raise an exception if the user explicitly requests an unsupported combination of a ``device=`` and ``dtype=`` arguments
81+
(e.g. when a user attempts to create an array of a data type which is not supported by the device, we recommend
82+
raising an error instead of silently returning an array of a dtype supported by the device).
8083
- When a function accepts a mix of arrays and Python scalars, the scalars should inherit the device of the arrays, much like what happens with :ref:`type-promotion`.
8184
- Use a default for ``device=None`` which is consistent between functions within the same library.
8285
- If a library has multiple ways of controlling device placement, the most explicit method should have the highest priority:

0 commit comments

Comments
 (0)