question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Boolean array indexing is not compatible with static memory allocation

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
rgommerscommented, Dec 7, 2020

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.
0reactions
kgrytecommented, Nov 10, 2021

As this issue should be addressed (boolean indexing is optional and admonitions have been added to the specification), will close this out.

If additional discussion is necessary, we can either reopen this issue or open a new one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Memory overflow in numpy boolean array - python
Save this question. Show activity on this post. I am trying to create a large Boolean array (for a prime number sieve). I...
Read more >
GPU Pro Tip: Fast Dynamic Indexing of Private Arrays in CUDA
This post covers best practices in dynamic indexing of per-thread private arrays in CUDA C++ programs, including explanation of the benefits ...
Read more >
Indexing on ndarrays — NumPy v1.24 Manual
If there is only one Boolean array and no integer indexing array present, this is straightforward. Care must only be taken to make...
Read more >
BooleanArrays (fastutil 8.5.9) - Unimi
A class providing static methods and objects that do useful things with type-specific arrays. In particular, the forceCapacity() , ensureCapacity() , grow() ...
Read more >
Array (GNU Classpath 0.94-pre Documentation)
These are not to be confused with the classes java.lang.Boolean, java.lang. ... static boolean, getBoolean(Object array, int index).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found