question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adopt Python Array API standard

See original GitHub issue

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

  • allocate numpy arrays backed by pinned memory (kDLCPUPinned) (related: #3625)

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
leofangcommented, Aug 24, 2021

Update: NumPy has done its first pass! https://github.com/numpy/numpy/pull/18585

1reaction
kmaehashicommented, Jun 21, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Purpose and scope — Python array API standard 2021.12 ...
This array API standard aims to address that issue, by specifying an API for the ... necessary to make sure all existing array...
Read more >
NEP 47 — Adopting the array API standard - NumPy
We propose to adopt the Python array API standard, developed by the Consortium for Python Data API Standards.
Read more >
array — Efficient arrays of numeric values — Python 3.11.1 ...
This module defines an object type which can compactly represent an array of basic values: characters, integers, floating point numbers. Arrays are sequence ......
Read more >
Python Array API Support — CuPy 11.4.0 documentation
The Python array API standard aims to provide a coherent set of APIs for array and tensor libraries developed by the community to...
Read more >
Standardization — Ivy 1.0 documentation
While Ivy does adhere to the Python Array API Standard, Ivy does not mandate adoption of the standard. Ivy is entirely complimentary to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found