@@ -25,43 +25,43 @@ Tag(::Nothing, ::Type{V}) where {V} = nothing
2525end
2626
2727"""
28- SmallTag {Hash}
28+ HashTag {Hash}
2929
30- SmallTag is similar to a Tag, but carries just a small UInt64 hash,
30+ HashTag is similar to a Tag, but carries just a small UInt64 hash,
3131instead of the full type, which makes stacktraces / types easier to
3232read while still providing good resilience to perturbation confusion.
3333"""
34- struct SmallTag {H}
34+ struct HashTag {H}
3535end
3636
37- @generated function tagcount (:: Type{SmallTag {H}} ) where {H}
37+ @generated function tagcount (:: Type{HashTag {H}} ) where {H}
3838 :($ (Threads. atomic_add! (TAGCOUNT, UInt (1 ))))
3939end
4040
41- function SmallTag (f:: F , :: Type{V} ) where {F,V}
41+ function HashTag (f:: F , :: Type{V} ) where {F,V}
4242 H = if F <: Tuple
4343 # no easy way to check Jacobian tag used with Hessians as multiple functions may be used
4444 # see checktag(::Type{Tag{FT,VT}}, f::F, x::AbstractArray{V}) where {FT<:Tuple,VT,F,V}
4545 nothing
4646 else
4747 hash (F) ⊻ hash (V)
4848 end
49- tagcount (SmallTag {H}) # trigger generated function
50- SmallTag {H} ()
49+ tagcount (HashTag {H}) # trigger generated function
50+ HashTag {H} ()
5151end
5252
53- SmallTag (:: Nothing , :: Type{V} ) where {V} = nothing
53+ HashTag (:: Nothing , :: Type{V} ) where {V} = nothing
5454
55- @inline function ≺ (:: Type{SmallTag {H1}} , :: Type{Tag{F2,V2}} ) where {H1,F2,V2}
56- tagcount (SmallTag {H1}) < tagcount (Tag{F2,V2})
55+ @inline function ≺ (:: Type{HashTag {H1}} , :: Type{Tag{F2,V2}} ) where {H1,F2,V2}
56+ tagcount (HashTag {H1}) < tagcount (Tag{F2,V2})
5757end
5858
59- @inline function ≺ (:: Type{Tag{F1,V1}} , :: Type{SmallTag {H2}} ) where {F1,V1,H2}
60- tagcount (Tag{F1,V1}) < tagcount (SmallTag {H2})
59+ @inline function ≺ (:: Type{Tag{F1,V1}} , :: Type{HashTag {H2}} ) where {F1,V1,H2}
60+ tagcount (Tag{F1,V1}) < tagcount (HashTag {H2})
6161end
6262
63- @inline function ≺ (:: Type{SmallTag {H1}} , :: Type{SmallTag {H2}} ) where {H1,H2}
64- tagcount (SmallTag {H1}) < tagcount (SmallTag {H2})
63+ @inline function ≺ (:: Type{HashTag {H1}} , :: Type{HashTag {H2}} ) where {H1,H2}
64+ tagcount (HashTag {H1}) < tagcount (HashTag {H2})
6565end
6666
6767struct InvalidTagException{E,O} <: Exception
@@ -75,13 +75,13 @@ checktag(::Type{Tag{FT,VT}}, f::F, x::AbstractArray{V}) where {FT,VT,F,V} =
7575
7676checktag (:: Type{Tag{F,V}} , f:: F , x:: AbstractArray{V} ) where {F,V} = true
7777
78- # SmallTag is a smaller tag, that only confirms the hash
79- function checktag (:: Type{SmallTag {HT}} , f:: F , x:: AbstractArray{V} ) where {HT,F,V}
78+ # HashTag is a smaller tag, that only confirms the hash
79+ function checktag (:: Type{HashTag {HT}} , f:: F , x:: AbstractArray{V} ) where {HT,F,V}
8080 H = hash (F) ⊻ hash (V)
8181 if HT == H || HT === nothing
8282 true
8383 else
84- throw (InvalidTagException {SmallTag {H},SmallTag {HT}} ())
84+ throw (InvalidTagException {HashTag {H},HashTag {HT}} ())
8585 end
8686end
8787
@@ -103,21 +103,21 @@ Base.eltype(cfg::AbstractConfig) = eltype(typeof(cfg))
103103
104104@inline (chunksize (:: AbstractConfig{N} ):: Int ) where {N} = N
105105
106- function maketag (kind :: Union{Symbol,Nothing} , f, X)
107- if kind === :default
106+ function maketag (tagstyle :: Union{Symbol,Nothing} , f, X)
107+ if tagstyle === :default
108108 @static if VERSION ≥ v " 1.11"
109- return SmallTag (f, X)
109+ return HashTag (f, X)
110110 else
111111 # On ≤1.10, the hash of a type cannot be computed at compile-time,
112- # making `SmallTag (...)` type-unstable, so `Tag(...)` is left as
112+ # making `HashTag (...)` type-unstable, so `Tag(...)` is left as
113113 # as the default.
114114 return Tag (f, X)
115115 end
116- elseif kind === :type
116+ elseif tagstyle === :type
117117 return Tag (f, X)
118- elseif kind === :hash
119- return SmallTag (f, X)
120- elseif kind === nothing
118+ elseif tagstyle === :hash
119+ return HashTag (f, X)
120+ elseif tagstyle === nothing
121121 return nothing
122122 else
123123 throw (ArgumentError (" tag may be :default, :type, :hash, or nothing" ))
@@ -133,7 +133,7 @@ struct DerivativeConfig{T,D} <: AbstractConfig{1}
133133end
134134
135135"""
136- ForwardDiff.DerivativeConfig(f!, y::AbstractArray, x::Real; tag ::Union{Symbol,Nothing} = :default)
136+ ForwardDiff.DerivativeConfig(f!, y::AbstractArray, x::Real; tagstyle ::Union{Symbol,Nothing} = :default)
137137
138138Return a `DerivativeConfig` instance based on the type of `f!`, and the types/shapes of the
139139output vector `y` and the input value `x`.
@@ -154,13 +154,13 @@ This constructor does not store/modify `y` or `x`.
154154@inline function DerivativeConfig (f:: F ,
155155 y:: AbstractArray{Y} ,
156156 x:: X ;
157- tag :: Union{Symbol,Nothing} = :default ) where {F,X<: Real ,Y<: Real }
158- # @inline ensures that, e.g., DerivativeConfig(...; tag = :small) will be well-inferred
157+ tagstyle :: Union{Symbol,Nothing} = :default ) where {F,X<: Real ,Y<: Real }
158+ # @inline ensures that, e.g., DerivativeConfig(...; tagstyle = :small) will be well-inferred
159159 @static if VERSION ≥ v " 1.8"
160- T = @inline maketag (tag , f, X)
160+ T = @inline maketag (tagstyle , f, X)
161161 return @noinline DerivativeConfig (f,y,x,T)
162162 else
163- T = maketag (tag , f, X)
163+ T = maketag (tagstyle , f, X)
164164 return DerivativeConfig (f,y,x,T)
165165 end
166166end
@@ -186,7 +186,7 @@ struct GradientConfig{T,V,N,D} <: AbstractConfig{N}
186186end
187187
188188"""
189- ForwardDiff.GradientConfig(f, x::AbstractArray, chunk::Chunk = Chunk(x); tag ::Union{Symbol,Nothing} = :default)
189+ ForwardDiff.GradientConfig(f, x::AbstractArray, chunk::Chunk = Chunk(x); tagstyle ::Union{Symbol,Nothing} = :default)
190190
191191Return a `GradientConfig` instance based on the type of `f` and type/shape of the input
192192vector `x`.
@@ -206,13 +206,13 @@ This constructor does not store/modify `x`.
206206@inline function GradientConfig (f:: F ,
207207 x:: AbstractArray{V} ,
208208 c:: Chunk{N} = Chunk (x);
209- tag :: Union{Symbol,Nothing} = :default ) where {F,V,N}
210- # @inline ensures that, e.g., GradientConfig(...; tag = :small) will be well-inferred
209+ tagstyle :: Union{Symbol,Nothing} = :default ) where {F,V,N}
210+ # @inline ensures that, e.g., GradientConfig(...; tagstyle = :small) will be well-inferred
211211 @static if VERSION ≥ v " 1.8"
212- T = @inline maketag (tag , f, V)
212+ T = @inline maketag (tagstyle , f, V)
213213 return @noinline GradientConfig (f,x,c,T)
214214 else
215- T = maketag (tag , f, V)
215+ T = maketag (tagstyle , f, V)
216216 return GradientConfig (f,x,c,T)
217217 end
218218end
@@ -239,7 +239,7 @@ struct JacobianConfig{T,V,N,D} <: AbstractConfig{N}
239239end
240240
241241"""
242- ForwardDiff.JacobianConfig(f, x::AbstractArray, chunk::Chunk = Chunk(x); tag ::Union{Symbol,Nothing} = :default)
242+ ForwardDiff.JacobianConfig(f, x::AbstractArray, chunk::Chunk = Chunk(x); tagstyle ::Union{Symbol,Nothing} = :default)
243243
244244Return a `JacobianConfig` instance based on the type of `f` and type/shape of the input
245245vector `x`.
@@ -260,13 +260,13 @@ This constructor does not store/modify `x`.
260260@inline function JacobianConfig (f:: F ,
261261 x:: AbstractArray{V} ,
262262 c:: Chunk{N} = Chunk (x);
263- tag :: Union{Symbol,Nothing} = :default ) where {F,V,N}
264- # @inline ensures that, e.g., JacobianConfig(...; tag = :small) will be well-inferred
263+ tagstyle :: Union{Symbol,Nothing} = :default ) where {F,V,N}
264+ # @inline ensures that, e.g., JacobianConfig(...; tagstyle = :small) will be well-inferred
265265 @static if VERSION ≥ v " 1.8"
266- T = @inline maketag (tag , f, V)
266+ T = @inline maketag (tagstyle , f, V)
267267 return @noinline JacobianConfig (f,x,c,T)
268268 else
269- T = maketag (tag , f, V)
269+ T = maketag (tagstyle , f, V)
270270 return JacobianConfig (f,x,c,T)
271271 end
272272end
@@ -281,7 +281,7 @@ function JacobianConfig(f::F,
281281end
282282
283283"""
284- ForwardDiff.JacobianConfig(f!, y::AbstractArray, x::AbstractArray, chunk::Chunk = Chunk(x); tag ::Union{Symbol,Nothing} = :default)
284+ ForwardDiff.JacobianConfig(f!, y::AbstractArray, x::AbstractArray, chunk::Chunk = Chunk(x); tagstyle ::Union{Symbol,Nothing} = :default)
285285
286286Return a `JacobianConfig` instance based on the type of `f!`, and the types/shapes of the
287287output vector `y` and the input vector `x`.
@@ -303,13 +303,13 @@ This constructor does not store/modify `y` or `x`.
303303 y:: AbstractArray{Y} ,
304304 x:: AbstractArray{X} ,
305305 c:: Chunk{N} = Chunk (x);
306- tag :: Union{Symbol,Nothing} = :default ) where {F,Y,X,N}
307- # @inline ensures that, e.g., JacobianConfig(...; tag = :small) will be well-inferred
306+ tagstyle :: Union{Symbol,Nothing} = :default ) where {F,Y,X,N}
307+ # @inline ensures that, e.g., JacobianConfig(...; tagstyle = :small) will be well-inferred
308308 @static if VERSION ≥ v " 1.8"
309- T = @inline maketag (tag , f, X)
309+ T = @inline maketag (tagstyle , f, X)
310310 return @noinline JacobianConfig (f,y,x,c,T)
311311 else
312- T = maketag (tag , f, X)
312+ T = maketag (tagstyle , f, X)
313313 return JacobianConfig (f,y,x,c,T)
314314 end
315315end
@@ -339,7 +339,7 @@ struct HessianConfig{T,V,N,DG,DJ} <: AbstractConfig{N}
339339end
340340
341341"""
342- ForwardDiff.HessianConfig(f, x::AbstractArray, chunk::Chunk = Chunk(x); tag ::Union{Symbol,Nothing} = :default)
342+ ForwardDiff.HessianConfig(f, x::AbstractArray, chunk::Chunk = Chunk(x); tagstyle ::Union{Symbol,Nothing} = :default)
343343
344344Return a `HessianConfig` instance based on the type of `f` and type/shape of the input
345345vector `x`.
@@ -362,13 +362,13 @@ This constructor does not store/modify `x`.
362362@inline function HessianConfig (f:: F ,
363363 x:: AbstractArray{V} ,
364364 chunk:: Chunk = Chunk (x);
365- tag :: Union{Symbol,Nothing} = :default ) where {F,V}
366- # @inline ensures that, e.g., HessianConfig(...; tag = :small) will be well-inferred
365+ tagstyle :: Union{Symbol,Nothing} = :default ) where {F,V}
366+ # @inline ensures that, e.g., HessianConfig(...; tagstyle = :small) will be well-inferred
367367 @static if VERSION ≥ v " 1.8"
368- T = @inline maketag (tag , f, V)
368+ T = @inline maketag (tagstyle , f, V)
369369 return @noinline HessianConfig (f, x, chunk, T)
370370 else
371- T = maketag (tag , f, V)
371+ T = maketag (tagstyle , f, V)
372372 return HessianConfig (f, x, chunk, T)
373373 end
374374end
@@ -383,7 +383,7 @@ function HessianConfig(f::F,
383383end
384384
385385"""
386- ForwardDiff.HessianConfig(f, result::DiffResult, x::AbstractArray, chunk::Chunk = Chunk(x); tag ::Union{Symbol,Nothing} = :default)
386+ ForwardDiff.HessianConfig(f, result::DiffResult, x::AbstractArray, chunk::Chunk = Chunk(x); tagstyle ::Union{Symbol,Nothing} = :default)
387387
388388Return a `HessianConfig` instance based on the type of `f`, types/storage in `result`, and
389389type/shape of the input vector `x`.
@@ -404,13 +404,13 @@ This constructor does not store/modify `x`.
404404 result:: DiffResult ,
405405 x:: AbstractArray{V} ,
406406 chunk:: Chunk = Chunk (x);
407- tag :: Union{Symbol,Nothing} = :default ) where {F,V}
408- # @inline ensures that, e.g., HessianConfig(...; tag = :small) will be well-inferred
407+ tagstyle :: Union{Symbol,Nothing} = :default ) where {F,V}
408+ # @inline ensures that, e.g., HessianConfig(...; tagstyle = :small) will be well-inferred
409409 @static if VERSION ≥ v " 1.8"
410- T = @inline maketag (tag , f, V)
410+ T = @inline maketag (tagstyle , f, V)
411411 return @noinline HessianConfig (f, result, x, chunk, T)
412412 else
413- T = maketag (tag , f, V)
413+ T = maketag (tagstyle , f, V)
414414 return HessianConfig (f, result, x, chunk, T)
415415 end
416416end
0 commit comments