@@ -60,7 +60,7 @@ function JacobianCache(prob, alg, f::F, fu_, u, p; stats, autodiff = nothing,
60
60
61
61
if ! has_analytic_jac && needs_jac
62
62
autodiff = get_concrete_forward_ad (autodiff, prob; check_forward_mode = false )
63
- sd = __sparsity_detection_alg (f, autodiff)
63
+ sd = sparsity_detection_alg (f, autodiff)
64
64
sparse_jac = ! (sd isa NoSparsityDetection)
65
65
# Eventually we want to do everything via DI. But for now, we just do the dense via DI
66
66
if sparse_jac
@@ -174,9 +174,13 @@ function (cache::JacobianCache{iip})(
174
174
end
175
175
end
176
176
177
- # Sparsity Detection Choices
178
- @inline __sparsity_detection_alg (_, _) = NoSparsityDetection ()
179
- @inline function __sparsity_detection_alg (f:: NonlinearFunction , ad:: AutoSparse )
177
+ function sparsity_detection_alg (f:: NonlinearFunction , ad:: AbstractADType )
178
+ # TODO : Also handle case where colorvec is provided
179
+ f. sparsity === nothing && return NoSparsityDetection ()
180
+ return sparsity_detection_alg (f, AutoSparse (ad; sparsity_detector = f. sparsity))
181
+ end
182
+
183
+ function sparsity_detection_alg (f:: NonlinearFunction , ad:: AutoSparse )
180
184
if f. sparsity === nothing
181
185
if f. jac_prototype === nothing
182
186
is_extension_loaded (Val (:Symbolics )) && return SymbolicsSparsityDetection ()
200
204
end
201
205
202
206
if SciMLBase. has_colorvec (f)
203
- return PrecomputedJacobianColorvec (; jac_prototype,
204
- f. colorvec,
207
+ return PrecomputedJacobianColorvec (; jac_prototype, f. colorvec,
205
208
partition_by_rows = ADTypes. mode (ad) isa ADTypes. ReverseMode)
206
209
else
207
210
return JacPrototypeSparsityDetection (; jac_prototype)
0 commit comments