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

Commit 6410a82

Browse files
committed
Make cu return concrete type if possible
1 parent fea9d56 commit 6410a82

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/array.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ end
286286
## utilities
287287

288288
cu(xs) = adapt(CuArray{Float32}, xs)
289-
cu(::Type{Array{T,N}}) where {T,N} = CuArray{T,N}
289+
cu(::Type{Array{T,N}}) where {T,N} = CuArray{T,N,Nothing}
290+
cu(::Type{Array{T}}) where {T} = CuArray{T}
290291
Base.getindex(::typeof(cu), xs...) = CuArray([xs...])
291292

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

test/base.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ 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}
43-
@test cu(Array{Float64,4}) == CuArray{Float64,4}
42+
@test cu(Array{Float64,1}) == CuArray{Float64,1, Nothing}
43+
@test cu(Array{Float64,4}) == CuArray{Float64,4, Nothing}
4444
@test cu(Array{Float64}) == CuArray{Float64}
4545

4646
@test_throws ArgumentError Base.unsafe_convert(Ptr{Int}, xs)

0 commit comments

Comments
 (0)