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
- MXNet: (Not currently implemented)
- TensorFlow: https://www.tensorflow.org/api_docs/python/tf/experimental/numpy/exp2
- C99: https://en.cppreference.com/w/c/numeric/math/exp2
Proposal:
def exp2(x: array, /) -> array
cc @kgryte