Skip to content

Commit 2d3abf7

Browse files
docs: clarify input arrays in device placement
PR-URL: #919 Ref: data-apis/array-api-compat#293 Ref: #918 Reviewed-by: Athan Reines <[email protected]> Reviewed-by: Ralf Gommers <[email protected]> Reviewed-by: Lucy Liu <[email protected]> Co-authored-by: Lucy Liu <[email protected]>
1 parent 4ddeaca commit 2d3abf7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

spec/draft/design_topics/device_support.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ 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+
- 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`.
8081
- Use a default for ``device=None`` which is consistent between functions within the same library.
81-
- If a library has multiple ways of controlling device placement, the most explicit method should have the highest priority. For example:
82+
- If a library has multiple ways of controlling device placement, the most explicit method should have the highest priority:
8283

83-
1. If ``device=`` keyword is specified, that always takes precedence
84-
85-
2. If ``device=None``, then use the setting from a context manager, if set.
86-
87-
3. If no context manager was used, then use the global default device/strategy
84+
1. If the ``device=`` keyword is specified, that always takes precedence;
85+
2. If ``device=None`` or the function does not accept a ``device`` parameter, then use the device of the input array(s), if any;
86+
3. If there are no input arrays, then use the setting from a context manager, if any;
87+
4. If no context manager was used, then use the global default device/strategy.
8888

8989
.. _device-out-of-scope:
9090

0 commit comments

Comments
 (0)