Skip to content
Merged
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
9 changes: 9 additions & 0 deletions ext/SciMLBaseChainRulesCoreExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ function ChainRulesCore.rrule(::Type{ODEProblem}, args...; kwargs...)
ODEProblem(args...; kwargs...), ODEProblemAdjoint
end

function ChainRulesCore.rrule(::Type{
<:ODEProblem{iip, T}}, args...; kwargs...) where {iip, T}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usually only IIP is set, is this hit there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only IIP is set it actually goes through the existing rrule, e.g.

y, back = Zygote._pullback(p -> ODEProblem{true}(dudt!, u0, (0.0, 20.0), p), [1.0])

back(1.0)

ends up going through

function ChainRulesCore.rrule(::Type{ODEProblem}, args...; kwargs...)
function ODEProblemAdjoint(ȳ)
(NoTangent(), ȳ.f, ȳ.u0, ȳ.tspan, ȳ.p, ȳ.kwargs, ȳ.problem_type)
end
ODEProblem(args...; kwargs...), ODEProblemAdjoint
end

function ODEProblemAdjoint(ȳ)
(NoTangent(), ȳ.f, ȳ.u0, ȳ.tspan, ȳ.p, ȳ.kwargs, ȳ.problem_type)
end

ODEProblem(args...; kwargs...), ODEProblemAdjoint
end

function ChainRulesCore.rrule(::Type{SDEProblem}, args...; kwargs...)
function SDEProblemAdjoint(ȳ)
(NoTangent(), ȳ.f, ȳ.g, ȳ.u0, ȳ.tspan, ȳ.p, ȳ.kwargs, ȳ.problem_type)
Expand Down
Loading