Skip to content
This repository was archived by the owner on Mar 12, 2021. It is now read-only.

Commit 50c1a3d

Browse files
authored
Merge pull request #522 from baggepinnen/type_cu
Allow cu to operate on Array types
2 parents 60b1d8e + 6410a82 commit 50c1a3d

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/array.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ end
283283
## utilities
284284

285285
cu(xs) = adapt(CuArray{Float32}, xs)
286+
cu(::Type{Array{T,N}}) where {T,N} = CuArray{T,N,Nothing}
287+
cu(::Type{Array{T}}) where {T} = CuArray{T}
286288
Base.getindex(::typeof(cu), xs...) = CuArray([xs...])
287289

288290
zeros(T::Type, dims...) = fill!(CuArray{T}(undef, dims...), 0)

test/base.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ end
3939
@test cu(1:3) === 1:3
4040
@test Base.elsize(xs) == sizeof(Int)
4141
@test CuArray{Int, 2}(xs) === xs
42+
@test cu(Array{Float64,1}) == CuArray{Float64,1, Nothing}
43+
@test cu(Array{Float64,4}) == CuArray{Float64,4, Nothing}
44+
@test cu(Array{Float64}) == CuArray{Float64}
4245

4346
@test_throws ArgumentError Base.unsafe_convert(Ptr{Int}, xs)
4447
@test_throws ArgumentError Base.unsafe_convert(Ptr{Float32}, xs)

0 commit comments

Comments
 (0)