8000 docs: clarify input arrays in device placement by crusaderky · Pull Request #919 · data-apis/array-api · GitHub
[go: up one dir, main page]

Skip to content

docs: clarify input arrays in device placement #919

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 6 commits into from
Jun 23, 2025
Merged
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
Prev Previous commit
Next Next commit
rework
  • Loading branch information
crusaderky committed Apr 18, 2025
commit 0b9225854f58d5795a0d545635b2cb059e775ab9
12 changes: 6 additions & 6 deletions spec/draft/design_topics/device_support.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ rather than hard requirements:

- 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).
- 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).
- When a function accepts a mix of arrays and Python scalars, the scalars should inherit the device of the arrays, much like it happens with :ref:`type-promotion`.
- Raise an exception if an operation involves arrays on different devices (i.e. avoid implicit data transfer between devices).
- When a function accepts a mix of arrays and Python scalars, the scalars should inherit the device of the arrays, much like it happens with :ref:`type-promotion`.
- Use a default for ``device=None`` which is consistent between functions within the same library.
- If a library has multiple ways of controlling device placement, the most explicit method has the highest priority:
- If a library has multiple ways of controlling device placement, the most explicit method should have the highest priority:

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

.. _device-out-of-scope:

Expand Down
0