Skip to content

Commit 728d9e0

Browse files
authored
Merge pull request #31 from christiangnrd/accumbug
Fix `accumulate!` default argument bug
2 parents 62b6311 + 5b33c80 commit 728d9e0

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/accumulate/accumulate.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ end
139139

140140

141141
function accumulate!(
142-
op, dst::AbstractArray, src::AbstractArray, backend::Backend=get_backend(v);
142+
op, dst::AbstractArray, src::AbstractArray, backend::Backend=get_backend(dst);
143143
init,
144144
neutral=GPUArrays.neutral_element(op, eltype(dst)),
145145
dims::Union{Nothing, Int}=nothing,

test/runtests.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,9 +1307,9 @@ end
13071307
for _ in 1:100
13081308
num_elems = rand(1:100_000)
13091309
x = array_from_host(rand(1:1000, num_elems), Int32)
1310-
y = copy(x)
1310+
y = similar(x)
13111311
init = rand(-1000:1000)
1312-
AK.accumulate!(+, y; init=Int32(init))
1312+
AK.accumulate!(+, y, x; init=Int32(init))
13131313
@test all(Array(y) .== accumulate(+, Array(x), init=init))
13141314
end
13151315

@@ -1395,7 +1395,7 @@ end
13951395
n3 = rand(1:100)
13961396
vh = rand(Float32, n1, n2, n3)
13971397
v = array_from_host(vh)
1398-
1398+
13991399
s = AK.accumulate(+, v; init=Float32(0), dims=dims)
14001400
sh = Array(s)
14011401
@test all(sh .≈ accumulate(+, vh, init=Float32(0), dims=dims))
@@ -1530,7 +1530,7 @@ end
15301530
AK.searchsortedfirst(v, x, by=abs, lt=(>), rev=true, block_size=64)
15311531
AK.searchsortedlast!(ix, v, x, by=abs, lt=(>), rev=true, block_size=64)
15321532
AK.searchsortedlast(v, x, by=abs, lt=(>), rev=true, block_size=64)
1533-
1533+
15341534
vh = Array(v)
15351535
xh = Array(x)
15361536
ixh = similar(xh, Int32)
@@ -1809,7 +1809,7 @@ end
18091809

18101810

18111811
@testset "cumsum" begin
1812-
1812+
18131813
Random.seed!(0)
18141814

18151815
# Simple correctness tests
@@ -1858,7 +1858,7 @@ end
18581858

18591859

18601860
@testset "cumprod" begin
1861-
1861+
18621862
Random.seed!(0)
18631863

18641864
# Simple correctness tests

0 commit comments

Comments
 (0)