Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ext/SciMLBaseChainRulesCoreExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,15 @@ function ChainRulesCore.rrule(::SciMLBase.EnsembleSolution, sim, time, converged
out, EnsembleSolution_adjoint
end

function ChainRulesCore.rrule(
::Type{<:SciMLBase.NonlinearSolution{
T, N, uType, R, P, A, O, uType2, S, Tr}}, u, resid, prob,
args...) where {T, N, uType, R, P, A, O, uType2, S, Tr}
function NonlinearSolutionAdjoint(ȳ)
(NoTangent(), ȳ.u, NoTangent(), ȳ.prob, ntuple(_ -> NoTangent(), length(args))...)
end
SciMLBase.NonlinearSolution{T, N, uType, R, P, A, O, uType2, S, Tr}(u, resid, prob, args...),
NonlinearSolutionAdjoint
end

end
2 changes: 1 addition & 1 deletion ext/SciMLBaseZygoteExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ end
uType2
}
function NonlinearSolutionAdjoint(ȳ)
(ȳ, ntuple(_ -> nothing, length(args))...)
(ȳ.u, ntuple(_ -> nothing, length(args))...)
end
NonlinearSolution{T, N, uType, R, P, A, O, uType2}(u, args...), NonlinearSolutionAdjoint
end
Expand Down
Loading