array-api
array-api copied to clipboard
RFC: add `exp2` function to the standard
This RFC requests to include a new API in the array API specification for the purpose of computing the base-2 exponential.
Overview
Based on array comparison data, the API is available in the majority of libraries in the PyData ecosystem.
The Array API specification currently includes log2, exp, and pow, but does not include the IEEE 754 function exp2. Would be nice to add for completeness.
While this can currently be achieved now by using pow, exp2 is commonly implemented as a slightly more ergonomic perf path.
Prior art
- NumPy: https://numpy.org/doc/stable/reference/generated/numpy.exp2.html
- PyTorch: https://pytorch.org/docs/stable/generated/torch.exp2.html
- TensorFlow: https://www.tensorflow.org/api_docs/python/tf/experimental/numpy/exp2
- JAX: https://docs.jax.dev/en/latest/_autosummary/jax.numpy.exp2.html#jax.numpy.exp2
- CuPy: https://docs.cupy.dev/en/stable/reference/generated/cupy.exp2.html
- Dask: https://docs.dask.org/en/stable/generated/dask.array.exp2.html
- ndonnx: (Not currently implemented)
- C99: https://en.cppreference.com/w/c/numeric/math/exp2
Proposal:
def exp2(x: array, /) -> array
cc @kgryte
Looks like, of the libraries consulted, only ndonnx does not support.