Repository navigation
Conversation
Julia 1.12 added `map!(f, A)`, which maps an array in place by forwarding to `map!(f, A, A)`. Our `map!(f, dest::AnyGPUArray, xs::AbstractArray...)` is more specific and also matched the zero-source call, building an empty broadcast that invoked `f()`. Requiring at least one source lets Base handle that call: on 1.12+ it forwards back to us with `dest` as the source, and on older versions Base throws its "map! requires at least one source argument" error instead of a confusing compilation failure.
This branch has not been deployed
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.
Julia 1.12 added
map!(f, A), which maps an array in place by forwarding tomap!(f, A, A). Ourmap!(f, dest::AnyGPUArray, xs::AbstractArray...)is more specific, so it also caught the zero-source call and broadcastf():On a real GPU this surfaces as an
InvalidIRError. Before 1.12 the same interception hid Base'sArgumentError: map! requires at least one "source" argument, which is what #482 originally reported.This requires at least one source argument in our method, so the zero-source call falls through to Base: on 1.12+ Base forwards it back to us with
destas the source, and on older versions users get Base's error. Adding an explicitmap!(f, dest::AnyGPUArray) = map!(f, dest, dest)instead would also enable in-placemap!for GPU arrays on 1.10/1.11, where it doesn't exist forArray.Tested with JLArrays on 1.10, 1.11, 1.12 and 1.13 (no new
map!ambiguities); the added test fails on 1.12 without the change.Fixes #482