21
21
22
22
`FixedSizeDiffCache(u::AbstractArray, N = Val{default_cache_size(length(u))})`
23
23
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`
25
25
and for the `Dual` version of `u`, allowing use of pre-cached vectors with
26
26
forward-mode automatic differentiation.
27
27
"""
@@ -100,7 +100,7 @@ DiffCache(u::AbstractArray, N::AbstractArray{<:Int}) = DiffCache(u, size(u), N)
100
100
function DiffCache (u:: AbstractArray , :: Type{Val{N}} ; levels:: Int = 1 ) where {N}
101
101
DiffCache (u, N; levels)
102
102
end
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)
104
104
105
105
# Legacy deprecate later
106
106
const dualcache = DiffCache
@@ -115,15 +115,15 @@ Returns the `Dual` or normal cache array stored in `dc` based on the type of `u`
115
115
function get_tmp (dc:: DiffCache , u:: T ) where {T <: ForwardDiff.Dual }
116
116
nelem = div (sizeof (T), sizeof (eltype (dc. dual_du))) * length (dc. du)
117
117
if nelem > length (dc. dual_du)
118
- enlargedualcache ! (dc, nelem)
118
+ enlargediffcache ! (dc, nelem)
119
119
end
120
120
_restructure (dc. du, reinterpret (T, view (dc. dual_du, 1 : nelem)))
121
121
end
122
122
123
123
function get_tmp (dc:: DiffCache , u:: AbstractArray{T} ) where {T <: ForwardDiff.Dual }
124
124
nelem = div (sizeof (T), sizeof (eltype (dc. dual_du))) * length (dc. du)
125
125
if nelem > length (dc. dual_du)
126
- enlargedualcache ! (dc, nelem)
126
+ enlargediffcache ! (dc, nelem)
127
127
end
128
128
_restructure (dc. du, reinterpret (T, view (dc. dual_du, 1 : nelem)))
129
129
end
@@ -150,11 +150,11 @@ function _restructure(normal_cache::AbstractArray, duals)
150
150
ArrayInterfaceCore. restructure (normal_cache, duals)
151
151
end
152
152
153
- function enlargedualcache ! (dc, nelem) # warning comes only once per dualcache .
153
+ function enlargediffcache ! (dc, nelem) # warning comes only once per DiffCache .
154
154
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
156
156
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 ."
158
158
resize! (dc. dual_du, nelem)
159
159
end
160
160
@@ -183,7 +183,7 @@ function Base.getindex(b::LazyBufferCache, u::T) where {T <: AbstractArray}
183
183
return buf
184
184
end
185
185
186
- export FixedSizeDiffCache, DiffCache, LazyBufferCache
186
+ export FixedSizeDiffCache, DiffCache, LazyBufferCache, dualcache
187
187
export get_tmp
188
188
189
189
end
0 commit comments