Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fully zero all memory in QuadratureAdjoint #1053

Merged
merged 2 commits into from
May 15, 2024
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
4 changes: 4 additions & 0 deletions src/quadrature_adjoint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ function AdjointSensitivityIntegrand(sol, adj_sol, sensealg, dgdp = nothing)
else
pf = DiffEqBase.ParamJacobianWrapper(unwrappedf, tspan[1], y)
pJ = similar(u0, length(u0), numparams)
pJ .= false
paramjac_config = build_param_jac_config(sensealg, pf, y, p)
end
AdjointSensitivityIntegrand(sol, adj_sol, p, y, λ, pf, f_cache, pJ, paramjac_config,
Expand Down Expand Up @@ -316,6 +317,7 @@ end

function (S::AdjointSensitivityIntegrand)(t)
out = similar(S.p)
out .= false
S(out, t)
end

Expand Down Expand Up @@ -408,6 +410,7 @@ function _adjoint_sensitivities(sol, sensealg::QuadratureAdjoint, alg; t = nothi
iλ = zero(rcb.λ)
out = zero(res')
yy = similar(rcb.y)
yy .= false
for (Δλa, tt) in rcb.Δλas
@unpack algevar_idxs = rcb.diffcache
iλ[algevar_idxs] .= Δλa
Expand Down Expand Up @@ -467,6 +470,7 @@ function _update_integrand_and_dgrad(res, sensealg::QuadratureAdjoint, cb, integ
end

_p = similar(integrand.p, size(integrand.p))
_p .= false
wp(_p, integrand.p, integrand.y, t)

if _p != integrand.p
Expand Down
Loading