Use style dispatch in broadcast(!)#393
Merged
maleadt merged 3 commits intoJuliaGPU:masterfrom Mar 15, 2022
Merged
Conversation
5 tasks
maleadt
reviewed
Feb 21, 2022
maleadt
reviewed
Feb 21, 2022
Member
maleadt
reviewed
Feb 21, 2022
|
|
||
| @inline function Base.copyto!(dest::BroadcastGPUArray, bc::Broadcasted{Nothing}) | ||
| @inline function Base.materialize!(::Style, dest, bc::Broadcasted) where {Style<:AbstractGPUArrayStyle} | ||
| return _copyto!(dest, instantiate(Broadcasted{Style}(bc.f, bc.args, axes(dest)))) |
Member
There was a problem hiding this comment.
If this, and the original Base implementation at https://github.com/JuliaLang/julia/blob/17775537232de5b12a38b257e402756b6df55386/base/broadcast.jl#L871, creates a Broadcasted{<:AbstractGPUArrayStyle}, why doesn't the copyto!(::AbstractArray, Broadcasted{<:AbstractGPUArrayStyle}) implementation below suffice?
Contributor
Author
There was a problem hiding this comment.
Base won't create a Broadcasted{<:AbstractGPUArrayStyle}, bc's stype is kept there.
So we need to create Broadcasted{<:AbstractGPUArrayStyle} ourself.
Contributor
Author
|
The error should be unrelated? |
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.
Style-based dispatch would be easier to extend by external array wrapper package. (Reusing more code)
JuliaArrays/StructArrays.jl#215
OffsetArraysshould be simiar, but IIRC@cartesianidx(dest, i)doesn't support 1d offset axes.This PR also wants to move
backendtoAdapt.jlJuliaGPU/Adapt.jl#50 to keep dependence lightweight.