Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/array_partition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ end
@inline function unpack_args(i, args::Tuple)
return (unpack(args[1], i), unpack_args(i, Base.tail(args))...)
end
unpack_args(i, args::Tuple{Any}) = (unpack(args[1], i),)
@inline unpack_args(i, args::Tuple{Any}) = (unpack(args[1], i),)
unpack_args(::Any, args::Tuple{}) = ()

## utils
Expand Down
11 changes: 11 additions & 0 deletions test/Core/partitions_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,14 @@ end
struct TestIsnanFunctor end
(::TestIsnanFunctor)(x) = isnan(x)
@test all(TestIsnanFunctor(), AP[[NaN], [NaN]])

@testset "Mixed-eltype in-place broadcast does not allocate" begin
# unpack_args(i, ::Tuple{Any}) was missing @inline, forcing a runtime
# dispatch at the tuple-recursion base case whenever the partitions
# have different element types.
f!(a, b, c, d) = (@. a = b + c * d; nothing)
mk() = ArrayPartition(rand(10), rand(Float32, 20), rand(5))
a, b, c, d = mk(), mk(), mk(), mk()
f!(a, b, c, d)
@test (@allocated f!(a, b, c, d)) == 0
end
Loading