Skip to content

Commit 12d9b8d

Browse files
committed
0-size array
1 parent 9b14634 commit 12d9b8d

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/mapreduce.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,8 @@ function GPUArrays.mapreducedim!(f::F, op::OP, R::AnyCuArray{T},
255255
# we can cover the dimensions to reduce using a single block
256256
kernel(f, op, init, Rreduce, Rother, Val(shuffle), R, A; threads, blocks, shmem)
257257
else
258-
# we need multiple steps to cover all values to reduce
259-
partial = similar(R, (size(R)..., reduce_blocks))
258+
# Temporary empty array of the same type for kernel definition
259+
partial = similar(R, ntuple(_ -> 0, Val(ndims(R)+1)))
260260

261261
# NOTE: we can't use the previously-compiled kernel, since the type of `partial`
262262
# might not match the original output container (e.g. if that was a view).
@@ -278,9 +278,7 @@ function GPUArrays.mapreducedim!(f::F, op::OP, R::AnyCuArray{T},
278278
partial_shmem = partial_reduce_shmem
279279
partial_blocks = partial_reduce_blocks*other_blocks
280280

281-
if reduce_blocks != partial_blocks
282-
partial = similar(R, (size(R)..., partial_blocks))
283-
end
281+
partial = similar(R, (size(R)..., partial_blocks))
284282

285283
if init === nothing
286284
# without an explicit initializer we need to copy from the output container

0 commit comments

Comments
 (0)