From a3cd2343555fad214553eaa96732c99012ffe89e Mon Sep 17 00:00:00 2001 From: Brian Groenke <brian.groenke@awi.de> Date: Tue, 7 Jan 2025 19:41:54 +0100 Subject: [PATCH] Fix bug with AD caches This reverts a previous change which broke parameter AD support. However, this change breaks compat with integrator AD (unless chunk sizes align). Trade off is worth it since integrator AD is not generally that useful. --- src/Numerics/caches.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Numerics/caches.jl b/src/Numerics/caches.jl index 39c72fb3..b0cfe0de 100644 --- a/src/Numerics/caches.jl +++ b/src/Numerics/caches.jl @@ -23,12 +23,12 @@ Base.show(io::IO, mime::MIME{Symbol("text/plain")}, cache::DiffCache) = show(io, _retrieve(cache_var::AbstractArray{T}, ::AbstractArray{T}) where {T} = cache_var _retrieve(cache_var::AbstractArray{T}, u::AbstractArray{U}) where {T,U} = copyto!(similar(u, length(cache_var)), cache_var) retrieve(dc::DiffCache) = dc.cache.du -retrieve(dc::DiffCache, u::AbstractArray{T}) where {T<:ForwardDiff.Dual} = copyto!(Prealloc.get_tmp(dc.cache, u), dc.cache.du) +retrieve(dc::DiffCache, u::AbstractArray{T}) where {T<:ForwardDiff.Dual} = Prealloc.get_tmp(dc.cache, u) retrieve(dc::DiffCache, u::AbstractArray{T}) where {T} = _retrieve(dc.cache.du, u) retrieve(dc::DiffCache, u::AbstractArray{T}, t) where {T} = retrieve(dc, u) # these cover cases for Rosenbrock solvers where only t has differentiable type -retrieve(dc::DiffCache, u::AbstractArray, t::T) where {T<:ForwardDiff.Dual} = copyto!(Prealloc.get_tmp(dc.cache, t), dc.cache.du) -retrieve(dc::DiffCache, u::AbstractArray{T}, t::T) where {T<:ForwardDiff.Dual} = copyto!(Prealloc.get_tmp(dc.cache, u), dc.cache.du) +retrieve(dc::DiffCache, u::AbstractArray, t::T) where {T<:ForwardDiff.Dual} = Prealloc.get_tmp(dc.cache, t) +retrieve(dc::DiffCache, u::AbstractArray{T}, t::T) where {T<:ForwardDiff.Dual} = Prealloc.get_tmp(dc.cache, u) """ ArrayCache{T,TA} <: StateVarCache -- GitLab