Skip to content

Commit b2b4852

Browse files
committed
Support GPU-like array types with map.
1 parent d6e37de commit b2b4852

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/host/broadcast.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ end
8989
allequal(x) = true
9090
allequal(x, y, z...) = x == y && allequal(y, z...)
9191

92-
function Base.map!(f, y::AbstractGPUArray, xs::AbstractArray...)
92+
function Base.map!(f, y::GPUDestArray, xs::AbstractArray...)
9393
@assert allequal(size.((y, xs...))...)
9494
return y .= f.(xs...)
9595
end
9696

97-
function Base.map(f, y::AbstractGPUArray, xs::AbstractArray...)
97+
function Base.map(f, y::GPUDestArray, xs::AbstractArray...)
9898
@assert allequal(size.((y, xs...))...)
9999
return f.(y, xs...)
100100
end

src/reference.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ JLArrayStyle{M}(::Val{N}) where {N,M} = JLArrayStyle{N}()
212212

213213
BroadcastStyle(::Type{JLArray{T,N}}) where {T,N} = JLArrayStyle{N}()
214214

215+
# Allocating the output container
215216
Base.similar(bc::Broadcasted{JLArrayStyle{N}}, ::Type{T}) where {N,T} =
216217
similar(JLArray{T}, axes(bc))
217-
218218
Base.similar(bc::Broadcasted{JLArrayStyle{N}}, ::Type{T}, dims...) where {N,T} =
219219
JLArray{T}(undef, dims...)
220220

0 commit comments

Comments
 (0)