Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fill!(::ArrayPartition) #419

Merged
merged 5 commits into from
Jan 29, 2025
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 Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ SafeTestsets = "0.1"
SparseArrays = "1.10"
StaticArrays = "1.6"
StaticArraysCore = "1.4"
Statistics = "1.10"
Statistics = "1.10, 1.11"
StructArrays = "0.6.11, 0.7"
SymbolicIndexingInterface = "0.3.25"
Tables = "1.11"
Expand Down
8 changes: 7 additions & 1 deletion src/array_partition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,19 @@ function Base.copyto!(A::ArrayPartition, src::ArrayPartition)
A
end

function Base.fill!(A::ArrayPartition, x)
unrolled_foreach!(A.x) do x_
fill!(x_, x)
end
A
end

function recursivefill!(b::ArrayPartition, a::T2) where {T2 <: Union{Number, Bool}}
unrolled_foreach!(b.x) do x
fill!(x, a)
end
end


## indexing

# Interface for the linear indexing. This is just a view of the underlying nested structure
Expand Down
4 changes: 4 additions & 0 deletions test/gpu/arraypartition_gpu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ mask = pA .> 0
# Test recursive filling is done using GPU kernels and not scalar indexing
RecursiveArrayTools.recursivefill!(pA, true)
@test all(pA .== true)

# Test that regular filling is done using GPU kernels and not scalar indexing
fill!(pA, false)
@test all(pA .== false)
Loading