Skip to content

Commit 1b2a7bc

Browse files
committed
add rrule for nonlinearsolution constructor
1 parent 4638d8b commit 1b2a7bc

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ext/SciMLBaseChainRulesCoreExt.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,15 @@ function ChainRulesCore.rrule(::SciMLBase.EnsembleSolution, sim, time, converged
116116
out, EnsembleSolution_adjoint
117117
end
118118

119+
function ChainRulesCore.rrule(
120+
::Type{<:SciMLBase.NonlinearSolution{
121+
T, N, uType, R, P, A, O, uType2, S, Tr}}, u,
122+
args...) where {T, N, uType, R, P, A, O, uType2, S, Tr}
123+
function NonlinearSolutionAdjoint(ȳ)
124+
(NoTangent(), ȳ.u, ntuple(_ -> NoTangent(), length(args))...)
125+
end
126+
SciMLBase.NonlinearSolution{T, N, uType, R, P, A, O, uType2, S, Tr}(u, args...),
127+
NonlinearSolutionAdjoint
128+
end
129+
119130
end

0 commit comments

Comments
 (0)