RFC: add `logsumexp`

Open
#596 2 comments 2 reactions 0 assignees View on GitHub

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

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

API extension RFC

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

Proposal:

def logsumexp(x: array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None, dtype: Optional[dtype] = None, keepdims: bool = False) -> array
  • dtype kwarg is for consistency with sum et al

Related

cc @kgryte

Dominant language
Python
Stars
281
Forks
52
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from data-apis/array-api

All issues in data-apis/array-api

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.