Skip to content

Commit c084e17

Browse files
committed
Prefer to use Val(unroll) over passing previous Val
1 parent 1664691 commit c084e17

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Utils.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,19 @@ end
7575

7676
# Fastest way to check for NaN in an array.
7777
# Thanks @mikmore https://discourse.julialang.org/t/fastest-way-to-check-for-inf-or-nan-in-an-array/76954/33?u=milescranmer
78-
is_bad_array(x, V::Val{unroll}=Val(16)) where {unroll} = !is_good_array(x, V)
79-
function is_good_array(x::AbstractArray{T}, V::Val{unroll}=Val(16)) where {unroll,T}
78+
is_bad_array(x, ::Val{unroll}=Val(16)) where {unroll} = !is_good_array(x, Val(unroll))
79+
function is_good_array(x::AbstractArray{T}, ::Val{unroll}=Val(16)) where {unroll,T}
8080
isempty(x) && return true
8181
_zero = zero(T)
8282

8383
# Vectorized segment
8484
vectorized_segment = eachindex(x)[begin:unroll:(end - unroll + 1)]
8585
empty_vectorized_segment = isempty(vectorized_segment)
8686
if !empty_vectorized_segment
87-
mask = ntuple(i -> _zero, V)
87+
mask = ntuple(i -> _zero, Val(unroll))
8888
cumulator = mask
8989
for i in vectorized_segment
90-
batch = ntuple(j -> @inbounds(x[i + (j - 1)]), V)
90+
batch = ntuple(j -> @inbounds(x[i + (j - 1)]), Val(unroll))
9191
cumulator = muladd.(mask, batch, cumulator)
9292
end
9393
cumulator == mask || return false

0 commit comments

Comments
 (0)