Repository navigation
Fixes for 12.0.2 - #808
Merged
Merged
Fixes for 12.0.2#808
Conversation
On 1.10, Base passes a single index to the three-argument to_indices with one linear range as the indices, so _check_mask never checked a mask against a multidimensional array. A mask of the wrong shape whose true entries all fell within the array then returned values instead of throwing a BoundsError. Define the two-argument method on every version, as 1.11 already did, and keep the three-argument override only for the trailing host mask that 1.10 would make a LogicalIndex. The test now uses masks that select only in-bounds elements, so it fails deterministically instead of in about a quarter of the runs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found by Metal.jl's CI on Julia 1.10 (JuliaGPU/Metal.jl#1013), for 12.0.2:
On Julia 1.10, indexing a multidimensional GPU array with a single logical mask of a different shape didn't throw a
BoundsErrorwhen every true entry of the mask fell within the array; it returned those elements instead. Base 1.10 hands a single index to the three-argumentto_indiceswith one linear range as the indices, so the shape check, which only ran when there was one index per dimension, never ran. The two-argument method that 1.11 and later already used is now defined on every version, and the three-argument override remains only for the trailing host mask that 1.10 would otherwise turn into aLogicalIndex.The testsuite caught this only in about a quarter of runs (any back-end, JLArrays included), because the mask was random; it now uses masks that select only in-bounds elements. Without the fix,
indexing logicalfails on 1.10 every time; with it, it passes on 1.10 and 1.13 with JLArrays, and Metal's logical indexing andfindalltests pass on 1.10.