2121
2222`FixedSizeDiffCache(u::AbstractArray, N = Val{default_cache_size(length(u))})`
2323
24- Builds a `DualCache ` object that stores both a version of the cache for `u`
24+ Builds a `FixedSizeDiffCache ` object that stores both a version of the cache for `u`
2525and for the `Dual` version of `u`, allowing use of pre-cached vectors with
2626forward-mode automatic differentiation.
2727"""
@@ -100,7 +100,7 @@ DiffCache(u::AbstractArray, N::AbstractArray{<:Int}) = DiffCache(u, size(u), N)
100100function DiffCache (u:: AbstractArray , :: Type{Val{N}} ; levels:: Int = 1 ) where {N}
101101 DiffCache (u, N; levels)
102102end
103- DiffCache (u:: AbstractArray , :: Val{N} ; levels:: Int = 1 ) where {N} = dualcache (u, N; levels)
103+ DiffCache (u:: AbstractArray , :: Val{N} ; levels:: Int = 1 ) where {N} = DiffCache (u, N; levels)
104104
105105# Legacy deprecate later
106106const dualcache = DiffCache
@@ -115,15 +115,15 @@ Returns the `Dual` or normal cache array stored in `dc` based on the type of `u`
115115function get_tmp (dc:: DiffCache , u:: T ) where {T <: ForwardDiff.Dual }
116116 nelem = div (sizeof (T), sizeof (eltype (dc. dual_du))) * length (dc. du)
117117 if nelem > length (dc. dual_du)
118- enlargedualcache ! (dc, nelem)
118+ enlargediffcache ! (dc, nelem)
119119 end
120120 _restructure (dc. du, reinterpret (T, view (dc. dual_du, 1 : nelem)))
121121end
122122
123123function get_tmp (dc:: DiffCache , u:: AbstractArray{T} ) where {T <: ForwardDiff.Dual }
124124 nelem = div (sizeof (T), sizeof (eltype (dc. dual_du))) * length (dc. du)
125125 if nelem > length (dc. dual_du)
126- enlargedualcache ! (dc, nelem)
126+ enlargediffcache ! (dc, nelem)
127127 end
128128 _restructure (dc. du, reinterpret (T, view (dc. dual_du, 1 : nelem)))
129129end
@@ -150,11 +150,11 @@ function _restructure(normal_cache::AbstractArray, duals)
150150 ArrayInterfaceCore. restructure (normal_cache, duals)
151151end
152152
153- function enlargedualcache ! (dc, nelem) # warning comes only once per dualcache .
153+ function enlargediffcache ! (dc, nelem) # warning comes only once per DiffCache .
154154 chunksize = div (nelem, length (dc. du)) - 1
155- @warn " The supplied dualcache was too small and was enlarged. This incurs allocations
155+ @warn " The supplied DiffCache was too small and was enlarged. This incurs allocations
156156 on the first call to `get_tmp`. If few calls to `get_tmp` occur and optimal performance is essential,
157- consider changing 'N'/chunk size of this dualcache to $chunksize ."
157+ consider changing 'N'/chunk size of this DiffCache to $chunksize ."
158158 resize! (dc. dual_du, nelem)
159159end
160160
@@ -183,7 +183,7 @@ function Base.getindex(b::LazyBufferCache, u::T) where {T <: AbstractArray}
183183 return buf
184184end
185185
186- export FixedSizeDiffCache, DiffCache, LazyBufferCache
186+ export FixedSizeDiffCache, DiffCache, LazyBufferCache, dualcache
187187export get_tmp
188188
189189end
0 commit comments