array-api: Boolean array indexing is not compatible with static memory allocation

JAX is built on top of XLA which (currently) requires static memory allocation for operations. This means it is not possible to express operations like x[y] where y is a boolean, because the resulting array has value dependent size: https://data-apis.github.io/array-api/latest/API_specification/indexing.html#boolean-array-indexing

It’s definitely possible that the static memory allocation requirement could be relaxed in the future, but dynamic memory allocation is always going to be harder to implement in a performant way. For example, I would guess Numba also struggles with this sort of operation. I don’t think we should require it for array libraries implementing our standard, since it isn’t needed for the majority of array operations.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (18 by maintainers)

Commits related to this issue

Most upvoted comments

The summary of a discussion we had a few days ago:

  • boolean indexing is fairly fundamental to how people use NumPy; leaving it out completely may cause people to simply ignore the standard.
  • given that this type of data-dependent shape can be produced by several other functions, we need a way to clearly mark that as a property of those functions and of boolean indexing. I.e. with color-coding or a custom admonition in the API standard document.