Skip to content

Commit c13f48f

Browse files
Merge pull request #147 from JuliaDiff/chunks
use ForwardDiff chunk heuristic
2 parents b72948a + c9d1335 commit c13f48f

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

src/differentiation/compute_jacobian_ad.jl

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ struct ForwardColorJacCache{T,T2,T3,T4,T5,T6}
88
chunksize::Int
99
end
1010

11-
function default_chunk_size(maxcolor)
12-
if maxcolor < DEFAULT_CHUNK_THRESHOLD
13-
Val(maxcolor)
14-
else
15-
Val(DEFAULT_CHUNK_THRESHOLD)
16-
end
17-
end
18-
1911
getsize(::Val{N}) where N = N
2012
getsize(N::Integer) = N
2113
void_setindex!(args...) = (setindex!(args...); return)
@@ -26,7 +18,7 @@ function ForwardColorJacCache(f,x,_chunksize = nothing;
2618
sparsity::Union{AbstractArray,Nothing}=nothing)
2719

2820
if _chunksize isa Nothing
29-
chunksize = default_chunk_size(maximum(colorvec))
21+
chunksize = ForwardDiff.pickchunksize(maximum(colorvec))
3022
else
3123
chunksize = _chunksize
3224
end
@@ -264,7 +256,7 @@ function forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number},
264256
chunksize = jac_cache.chunksize
265257
color_i = 1
266258
maxcolor = maximum(colorvec)
267-
259+
268260
fill!(J, zero(eltype(J)))
269261

270262
if FiniteDiff._use_findstructralnz(sparsity)
@@ -325,6 +317,3 @@ function forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number},
325317
end
326318
return J
327319
end
328-
329-
330-

0 commit comments

Comments
 (0)