Repository navigation
Pair up map arguments in memory order, like Base - #885
Merged
Merged
Conversation
`map` and `map!` on GPU arrays with differently shaped arguments broadcast them and kept the first results. That only agrees with Base when broadcasting happens to pair the same elements: `map(+, a_1x4, b_4)` added `a[1,1]` to every element of `b`, `map(min, a_2x2, b_2x1)` returned two elements where Base throws a `DimensionMismatch`, and mapping over a matrix and a range of the same length, or into a destination of another shape, threw. `map!` now indexes every container by its n-th linear index, stopping at the shortest one, and `map` uses `zip`'s shape rules to decide between Base's `DimensionMismatch` and a vector of the shortest length. Arguments of equal size still go through `broadcast`. Fixes #882
maleadt
force-pushed
the
tb/map-linear
branch
from
December 2, 2026 19:30
1c242c0 to
971fea6
Compare
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.
map/map!with differently shaped arguments broadcast them and truncated the result, which only agrees with Base when broadcasting happens to pair the same elements.map(+, a_1x4, b_4)addeda[1,1]to all ofb.map(min, a_2x2, b_2x1)returned two elements where Base throwsDimensionMismatch. Mapping a matrix with a range of the same length, or into a destination of another shape, threw.map!now pairs the n-th element of every container, up to the shortest one, so indices that don't start at 1 work too.mapuseszip's shape rules to choose between Base'sDimensionMismatchand a vector of the shortest length. Arguments of equal size still go throughbroadcast.Fixes #882