Skip to content

Commit

Permalink
Update adjoint_common.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek-1Bhatt committed Jul 11, 2022
1 parent 1dba742 commit 6158ba9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/adjoint_common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,15 @@ function (f::ReverseLossCallback)(integrator)
if ArrayInterfaceCore.ismutable(u)
# Warning: alias here! Be careful with λ
gᵤ = isq ? λ : @view(λ[1:idx])
dgdu(gᵤ, y, p, t[cur_time[]], cur_time[])
if dgdu !== nothing
dgdu(gᵤ, y, p, t[cur_time[]], cur_time[])
# add discrete dgdp contribution
if dgdp !== nothing && !isq
gp = @view(λ[(idx + 1):end])
dgdp(gp, y, p, t[cur_time[]], cur_time[])
u[(idx + 1):length(λ)] .+= gp
end
end
else
@assert sensealg isa QuadratureAdjoint
outtype = DiffEqBase.parameterless_type(λ)
Expand Down

0 comments on commit 6158ba9

Please sign in to comment.