Common APIs across array libraries
See original GitHub issueOverview
To help further the discussion of what array APIs should be included in the standard, I’ve compiled a (WIP) list of common APIs across various array libraries.
This list should provide some indication as to API importance from the library development perspective based on API curation and need and should summarize current existing practice.
Goal
To standardize a common set of core APIs and minimal signatures (i.e., argument order and keyword arguments) that every array API should implement in order to be array specification compliant.
Method
I compiled the list by doing the following:
- Generating a list of APIs based on publicly documented array APIs (e.g., by scraping website documentation).
- Computing the intersection across the individual datasets.
The following libraries were analyzed:
- numpy
- cupy
- dask.array
- jax
- mxnet
- pytorch
- tensorflow
APIs
The following APIs were found to be common across the above libraries (using NumPy’s naming conventions):
angle
arange
arccos
arcsin
arctan
arctan2
argmax
argmin
array
ceil
concatenate
conj
cos
cosh
cumprod
cumsum
einsum
exp
expm1
eye
flip
floor
full
imag
linalg.cholesky
linalg.inv
linalg.norm
linalg.qr
linalg.solve
linalg.svd
linspace
log
log1p
logaddexp
matmul
maximum
mean
meshgrid
minimum
ones
ones_like
prod
real
reshape
roll
sign
sin
sinh
sqrt
square
squeeze
stack
std
sum
tan
tanh
tensordot
trace
transpose
trunc
var
where
zeros
zeros_like
We can split these APIs into various categories as follows…
Array Creation
arange
array
eye
full
linspace
meshgrid
ones
ones_like
zeros
zeros_like
Array Manipulation
concatenate
flip
reshape
roll
squeeze
stack
Special Functions
ceil
exp
expm1
floor
log
log1p
logaddexp
maximum
minimum
sign
square
sqrt
trunc
Trigonometry
arccos
arcsin
arctan
arctan2
cos
cosh
sin
sinh
tan
tanh
Complex Numbers
angle
conj
imag
real
Reductions
cumprod
cumsum
mean
prod
std
sum
var
Linear Algebra
einsum
linalg.cholesky
linalg.inv
linalg.norm
linalg.qr
linalg.solve
linalg.svd
matmul
tensordot
trace
transpose
Indexing
argmax
argmin
where
Next Steps
- Provide the intersection of keyword arguments for each of the above APIs.
Questions
- While the above uses NumPy naming conventions, some of the above libraries have chosen to deviate from NumPy conventions (
absolute
vsabs
). Are there APIs which should be aliased differently? - How to handle/encode missing data in element-wise functions (
ufuncs
) and reductions? - Can we standardize a core subset of the above APIs in terms of method names and a limited set of keyword arguments?
- To allow for API extensibility, can we specify a common API for arbitrary element-wise and/or axis-wise operations (e.g.,
apply
,reduce
)?
Feedback is welcome. 😃
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6 (5 by maintainers)
Top GitHub Comments
For 1) so this listing excludes these functions, right? Should we manually alias them to get a more complete list?
Also, shouldn’t we also look at the complement, i.e. all the other functions that are not in each library and list in which libraries they are?
This is all done, and https://github.com/data-apis/array-api-comparison holds the up-to-date data and tooling. So I’ll close this.