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

Adopt Python Array API standard #4789

Closed
3 of 4 tasks
leofang opened this issue Mar 2, 2021 · 5 comments · Fixed by #5698
Closed
3 of 4 tasks

Adopt Python Array API standard #4789

leofang opened this issue Mar 2, 2021 · 5 comments · Fixed by #5698
Labels
array-api Topic: Array API Standard cat:feature New features/APIs prio:medium

Comments

@leofang
Copy link
Member

leofang commented Mar 2, 2021

This is a meta-issue tracking the adoption of Python Array API standard:

In the Data API weekly meetings, it was decided that a reference implementation will be provided to NumPy (see NEP-47), which other implementations can follow and test against. Given that CuPy is IMHO by far the most compliant library with the API standard (probably more compliant than NumPy is, given many design deviations), I think it is much easier if we just wait until the ref implementation is out, and try taking it as is.

A new array object will be added in a separate namespace, delegating real work to cupy.ndarray whenever appropriate. Following NEP-47 I suggest the namespace to be cupy.array_api, but I suppose cupyx.array_api is also a fine choice.
The array object will only have "dunder" methods (names with double underscores), and all APIs for manipulating this object live under the new namespace.

But in addition to the new array object and APIs added to the new namespace, similar to numpy/numpy.ndarray there are some work to be done in the cupy namespace as well as in cupy.ndarray. A list of such examples are copied from NEP-47 for convenience:

  • ndarray.__dlpack__
  • ndarray.__dlpack_device__
  • ndarray.device

In addition, since DLPack is the main data exchange mechanism, we better support

There are still some issues in the standard to be ironed out (ex: linalg related APIs), but I think it's getting close to be completed.

@leofang
Copy link
Member Author

leofang commented Mar 10, 2021

it was decided that a reference implementation will be provided to NumPy

See numpy/numpy#18585.

@leofang
Copy link
Member Author

leofang commented Jun 21, 2021

it was decided that a reference implementation will be provided to NumPy

See numpy/numpy#18585.

@kmaehashi Would CuPy follow exactly what NumPy does and creates a new _array_api namespace, or would you rather follow PyTorch and turn cupy.ndarray directly into an Array API compliant array object? I took the former as granted, but I think I better double check with you guys 😅

@kmaehashi
Copy link
Member

We will follow NumPy's design as our goal is to be a drop-in replacement for NumPy 😄

@kmaehashi kmaehashi added the array-api Topic: Array API Standard label Jun 21, 2021
@leofang
Copy link
Member Author

leofang commented Jun 22, 2021

Thanks for confirming @kmaehashi!

@leofang
Copy link
Member Author

leofang commented Aug 24, 2021

Update: NumPy has done its first pass! numpy/numpy#18585

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
array-api Topic: Array API Standard cat:feature New features/APIs prio:medium
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants