Skip to content

use ForwardDiff chunk heuristic #147

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

Merged
merged 1 commit into from
Jul 30, 2021
Merged
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
15 changes: 2 additions & 13 deletions src/differentiation/compute_jacobian_ad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ struct ForwardColorJacCache{T,T2,T3,T4,T5,T6}
chunksize::Int
end

function default_chunk_size(maxcolor)
if maxcolor < DEFAULT_CHUNK_THRESHOLD
Val(maxcolor)
else
Val(DEFAULT_CHUNK_THRESHOLD)
end
end

getsize(::Val{N}) where N = N
getsize(N::Integer) = N
void_setindex!(args...) = (setindex!(args...); return)
Expand All @@ -26,7 +18,7 @@ function ForwardColorJacCache(f,x,_chunksize = nothing;
sparsity::Union{AbstractArray,Nothing}=nothing)

if _chunksize isa Nothing
chunksize = default_chunk_size(maximum(colorvec))
chunksize = ForwardDiff.pickchunksize(maximum(colorvec))
else
chunksize = _chunksize
end
Expand Down Expand Up @@ -264,7 +256,7 @@ function forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number},
chunksize = jac_cache.chunksize
color_i = 1
maxcolor = maximum(colorvec)

fill!(J, zero(eltype(J)))

if FiniteDiff._use_findstructralnz(sparsity)
Expand Down Expand Up @@ -325,6 +317,3 @@ function forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number},
end
return J
end