Skip to content

Commit 94c2e43

Browse files
jClugstorChrisRackauckas
authored andcommitted
account for Thunks, non tangent types
1 parent e414e7c commit 94c2e43

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/BracketingNonlinearSolve/ext/BracketingNonlinearSolveChainRulesCoreExt.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ function ChainRulesCore.rrule(
1212
prob::IntervalNonlinearProblem,
1313
sensealg, p, alg, args...; kwargs...
1414
)
15-
out = solve(prob)
15+
out = solve(prob, alg)
1616
u = out.u
1717
f = SciMLBase.unwrapped_f(prob.f)
1818
function ∇bracketingnonlinear_solve_up(Δ)
19+
Δ = Δ isa AbstractThunk ? unthunk(Δ) : Δ
1920
# Δ = dg/du
20-
λ = only(ForwardDiff.derivative(u -> f(u, p), only(u)) \ Δ.u)
21+
Δ isa Tangent ? delu = Δ.u : delu = Δ
22+
λ = only(ForwardDiff.derivative(u -> f(u, p), only(u)) \ delu)
2123
if p isa Number
2224
dgdp = -λ * ForwardDiff.derivative(p -> f(u, p), p)
2325
else

0 commit comments

Comments
 (0)