Skip to content

Commit a7f86fb

Browse files
authored
export dualcache again + naming consistency
This exports dualcache again, because I had packages breaking due to renaming it and not exporting it. Just avoiding the same for others until we consciously remove the name.
1 parent ef66f21 commit a7f86fb

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/PreallocationTools.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ end
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`
2525
and for the `Dual` version of `u`, allowing use of pre-cached vectors with
2626
forward-mode automatic differentiation.
2727
"""
@@ -100,7 +100,7 @@ DiffCache(u::AbstractArray, N::AbstractArray{<:Int}) = DiffCache(u, size(u), N)
100100
function DiffCache(u::AbstractArray, ::Type{Val{N}}; levels::Int = 1) where {N}
101101
DiffCache(u, N; levels)
102102
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)
104104

105105
# Legacy deprecate later
106106
const dualcache = DiffCache
@@ -115,15 +115,15 @@ Returns the `Dual` or normal cache array stored in `dc` based on the type of `u`
115115
function 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)))
121121
end
122122

123123
function 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)))
129129
end
@@ -150,11 +150,11 @@ function _restructure(normal_cache::AbstractArray, duals)
150150
ArrayInterfaceCore.restructure(normal_cache, duals)
151151
end
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)
159159
end
160160

@@ -183,7 +183,7 @@ function Base.getindex(b::LazyBufferCache, u::T) where {T <: AbstractArray}
183183
return buf
184184
end
185185

186-
export FixedSizeDiffCache, DiffCache, LazyBufferCache
186+
export FixedSizeDiffCache, DiffCache, LazyBufferCache, dualcache
187187
export get_tmp
188188

189189
end

0 commit comments

Comments
 (0)