Skip to content

Conversation

@N5N3
Copy link
Contributor

@N5N3 N5N3 commented Feb 20, 2022

Style-based dispatch would be easier to extend by external array wrapper package. (Reusing more code)
JuliaArrays/StructArrays.jl#215
OffsetArrays should be simiar, but IIRC @cartesianidx(dest, i) doesn't support 1d offset axes.

This PR also wants to move backend to Adapt.jl JuliaGPU/Adapt.jl#50 to keep dependence lightweight.

@maleadt
Copy link
Member

maleadt commented Feb 21, 2022

So this is a rebase of #295? cc @vchuravy


@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))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base won't create a Broadcasted{<:AbstractGPUArrayStyle}, bc's stype is kept there.
So we need to create Broadcasted{<:AbstractGPUArrayStyle} ourself.

@N5N3
Copy link
Contributor Author

N5N3 commented Feb 25, 2022

The error should be unrelated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants