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

RFC: add API to return a list of all devices #636

Closed
kgryte opened this issue Jun 1, 2023 · 1 comment
Closed

RFC: add API to return a list of all devices #636

kgryte opened this issue Jun 1, 2023 · 1 comment
Labels
API extension Adds new functions or objects to the API.

Comments

@kgryte
Copy link
Contributor

kgryte commented Jun 1, 2023

This RFC proposes to add an API to the standard for returning the list of devices. Currently, the only standardized means for an array API consumer to access a device object is by creating an array and accessing the .device attribute.

>>> x = xp.zeros((2, 2))
>>> d = x.device

More generally, the standard currently lacks APIs for device inspection, and device objects are unspecified, apart from required support for equality comparison. To aid in introspection and scripting/REPL envs, having a means for getting the list of devices would be useful, especially when probing the capabilities of an unknown platform.

Prior art

JAX

jax.devices(backend=None) -> List[Device]

Returns the list of devices from the default backend (e.g., gpu, tpu, or cpu).

jax.local_devices(process_index=None, backend=None, host_id=None)

Returns a list of devices local to a given process.

Proposal

devices() -> List[device]

The proposed API would be a nullary function which returns a list of device objects.

Notes

  • Currently, when not provided a backend kwarg, JAX returns the list of devices for the default backend. I am not sure whether this is preferred compared to returning a list of devices across all backends.

Related

@kgryte kgryte added the API extension Adds new functions or objects to the API. label Jun 1, 2023
@kgryte
Copy link
Contributor Author

kgryte commented Jun 29, 2023

This RFC has been superseded by #640.

@kgryte kgryte closed this as completed Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API extension Adds new functions or objects to the API.
Projects
None yet
Development

No branches or pull requests

1 participant