Skip to content

Commit

Permalink
fix when length = 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellipse0934 authored and Ellipse0934 committed Jul 15, 2020
1 parent e366b86 commit 1ecf150
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/host/construction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function Base.fill(X::Type{<: AbstractGPUArray{T}}, val, dims::NTuple{N, Integer
fill!(res, convert(T, val))
end
function Base.fill!(A::AbstractGPUArray{T}, x) where T
length(A) == 0 && return A
gpu_call(A, convert(T, x)) do ctx, a, val
idx = @linearidx(a, ctx)
@inbounds a[idx] = val
Expand Down
8 changes: 8 additions & 0 deletions test/testsuite/construction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ end
@test all(x-> x == 2f0, Array(x1))
@test all(x-> x == Int32(77), Array(x2))

x = fill(zero(T), (0, 2))
x1 = fill(AT{T}, T(0), (0, 2))
x2 = fill(AT{T}, T(0), (0, 2))
x3 = fill(AT{T, 2}, T(0), (0, 2))
@test Array(x1) x
@test Array(x2) x
@test Array(x3) x

x = Matrix{T}(I, 4, 2)

x1 = AT{T, 2}(I, 4, 2)
Expand Down

0 comments on commit 1ecf150

Please sign in to comment.