RFC: add `logsumexp`
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- python
- Domain
- backend-api-design
Research direction
Start with the referenced logaddexp entry in src/array_api_stubs/_2022_12/elementwise_functions.py and compare the proposed signature with the linked SciPy, CuPy, PyTorch, TensorFlow, and JAX APIs. Determine the specification changes and decisions needed for logsumexp; done means the RFC has an agreed proposal and the relevant array API specification is updated.
Written by the indexing model from the issue text.
Description
This RFC seeks to include a new API in the array API specification for the purpose of computing the log of summed exponentials.
Overview
The Array API specification currently includes logaddexp which performs an element-wise operation on two input arrays, but does not include the reduction logsumexp. This API is commonly implemented in accelerator libraries for better numerical stability in deep learning applications.
This can be implemented using log(sum(exp)); however, such an implementation is not likely to be numerically stable.
Prior art
- NumPy: (not currently implemented)
- NumPy does, however, implement
logaddexp.reduce.
- NumPy does, however, implement
- Dask: (not currently implemented)
- SciPy: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.logsumexp.html
- CuPy: https://docs.cupy.dev/en/stable/reference/generated/cupyx.scipy.special.logsumexp.html
- In
scipy.specialnamespace.
- In
- PyTorch: https://pytorch.org/docs/stable/generated/torch.logsumexp.html (also an alias in
torch.special: https://pytorch.org/docs/stable/special.html#torch.special.logsumexp) - TensorFlow: https://www.tensorflow.org/api_docs/python/tf/math/reduce_logsumexp
- JAX: jax.nn.logsumexp and jax.scipy.special.logsumexp (same function, exposed in two places)
Proposal:
def logsumexp(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, dtype: Optional[dtype] = None, keepdims: bool = False) -> array
dtypekwarg is for consistency withsumet al
Related
cc @kgryte
- Dominant language
- Python
- Stars
- 281
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from data-apis/array-api
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Maintenance
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in data-apis/array-api
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100