Skip to content

Commit 6d2b026

Browse files
committed
fix: unwrap sparse AD for derivative call
1 parent 3134e5d commit 6d2b026

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/internal/jacobian.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function JacobianCache(prob, alg, f::F, ::Number, u::Number, p; stats,
122122
return JacobianCache{false}(u, f, fu, u, p, stats, autodiff, nothing)
123123
end
124124
autodiff = get_concrete_forward_ad(autodiff, prob; check_forward_mode = false)
125-
di_extras = DI.prepare_derivative(f, autodiff, u, Constant(prob.p))
125+
di_extras = DI.prepare_derivative(f, get_dense_ad(autodiff), u, Constant(prob.p))
126126
return JacobianCache{false}(u, f, fu, u, p, stats, autodiff, di_extras, nothing)
127127
end
128128

@@ -217,3 +217,6 @@ function sparsity_detection_alg(f::NonlinearFunction, ad::AutoSparse)
217217
return JacPrototypeSparsityDetection(; jac_prototype)
218218
end
219219
end
220+
221+
get_dense_ad(ad) = ad
222+
get_dense_ad(ad::AutoSparse) = ADTypes.dense_ad(ad)

0 commit comments

Comments
 (0)