array-api icon indicating copy to clipboard operation
array-api copied to clipboard

RFC: add support for computing the cumulative product to the standard

Open steff456 opened this issue 2 years ago • 2 comments

This RFC requests to include a new API in the array API specification for the purpose of computing the cumulative product.

Overview

Based on array comparison data, the API is available in the majority of the libraries in the PyData ecosystem.

Prior art

Proposal:

def cumprod(x: array, /, *, axis: Optional[int] = None, dtype: Optional[dtype] = None) -> array
  • dtype kwarg is for consistency with sum et al

cc @oleksandr-pavlyk

steff456 avatar Feb 14 '23 23:02 steff456

@steff456 for the axis kwarg, this should be limited to just an int and not a Tuple. Based on the various docs, libraries seem to only support an int.

kgryte avatar Feb 14 '23 23:02 kgryte

One thing to note is that PyTorch, e.g., requires an axis argument and does not support NumPy's default behavior of computing the cumulative sum over the flattened array.

kgryte avatar Feb 14 '23 23:02 kgryte