Skip to content

Commit 925d6f1

Browse files
committed
add rrule for nonlinearsolution constructor
1 parent b77a55a commit 925d6f1

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
@@ -114,4 +114,15 @@ function ChainRulesCore.rrule(::SciMLBase.EnsembleSolution, sim, time, converged
114114
out, EnsembleSolution_adjoint
115115
end
116116

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

0 commit comments

Comments
 (0)