Skip to content

Commit 8a67a86

Browse files
Remove option
1 parent 9f82dfa commit 8a67a86

File tree

1 file changed

+29
-81
lines changed

1 file changed

+29
-81
lines changed

src/config.jl

Lines changed: 29 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,13 @@ Base.eltype(cfg::AbstractConfig) = eltype(typeof(cfg))
104104
@inline (chunksize(::AbstractConfig{N})::Int) where {N} = N
105105

106106
function maketag(tagstyle::Union{Symbol,Nothing}, f, X)
107-
if tagstyle === :default
108-
@static if VERSION v"1.11"
109-
return HashTag(f, X)
110-
else
111-
# On ≤1.10, the hash of a type cannot be computed at compile-time,
112-
# making `HashTag(...)` type-unstable, so `Tag(...)` is left as
113-
# as the default.
114-
return Tag(f, X)
115-
end
116-
elseif tagstyle === :type
117-
return Tag(f, X)
118-
elseif tagstyle === :hash
107+
@static if VERSION v"1.11"
119108
return HashTag(f, X)
120-
elseif tagstyle === nothing
121-
return nothing
122109
else
123-
throw(ArgumentError("tag may be :default, :type, :hash, or nothing"))
110+
# On ≤1.10, the hash of a type cannot be computed at compile-time,
111+
# making `HashTag(...)` type-unstable, so `Tag(...)` is left as
112+
# as the default.
113+
return Tag(f, X)
124114
end
125115
end
126116

@@ -133,7 +123,7 @@ struct DerivativeConfig{T,D} <: AbstractConfig{1}
133123
end
134124

135125
"""
136-
ForwardDiff.DerivativeConfig(f!, y::AbstractArray, x::Real; tagstyle::Union{Symbol,Nothing} = :default)
126+
ForwardDiff.DerivativeConfig(f!, y::AbstractArray, x::Real)
137127
138128
Return a `DerivativeConfig` instance based on the type of `f!`, and the types/shapes of the
139129
output vector `y` and the input value `x`.
@@ -153,16 +143,9 @@ This constructor does not store/modify `y` or `x`.
153143
"""
154144
@inline function DerivativeConfig(f::F,
155145
y::AbstractArray{Y},
156-
x::X;
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
159-
@static if VERSION v"1.8"
160-
T = @inline maketag(tagstyle, f, X)
161-
return @noinline DerivativeConfig(f,y,x,T)
162-
else
163-
T = maketag(tagstyle, f, X)
164-
return DerivativeConfig(f,y,x,T)
165-
end
146+
x::X) where {F,X<:Real,Y<:Real}
147+
T = maketag(f, X)
148+
return DerivativeConfig(f,y,x,T)
166149
end
167150

168151
function DerivativeConfig(f::F,
@@ -186,7 +169,7 @@ struct GradientConfig{T,V,N,D} <: AbstractConfig{N}
186169
end
187170

188171
"""
189-
ForwardDiff.GradientConfig(f, x::AbstractArray, chunk::Chunk = Chunk(x); tagstyle::Union{Symbol,Nothing} = :default)
172+
ForwardDiff.GradientConfig(f, x::AbstractArray, chunk::Chunk = Chunk(x))
190173
191174
Return a `GradientConfig` instance based on the type of `f` and type/shape of the input
192175
vector `x`.
@@ -205,16 +188,9 @@ This constructor does not store/modify `x`.
205188
"""
206189
@inline function GradientConfig(f::F,
207190
x::AbstractArray{V},
208-
c::Chunk{N} = Chunk(x);
209-
tagstyle::Union{Symbol,Nothing} = :default) where {F,V,N}
210-
# @inline ensures that, e.g., GradientConfig(...; tagstyle = :small) will be well-inferred
211-
@static if VERSION v"1.8"
212-
T = @inline maketag(tagstyle, f, V)
213-
return @noinline GradientConfig(f,x,c,T)
214-
else
215-
T = maketag(tagstyle, f, V)
216-
return GradientConfig(f,x,c,T)
217-
end
191+
c::Chunk{N} = Chunk(x)) where {F,V,N}
192+
T = maketag(f, V)
193+
return GradientConfig(f,x,c,T)
218194
end
219195

220196
function GradientConfig(f::F,
@@ -239,7 +215,7 @@ struct JacobianConfig{T,V,N,D} <: AbstractConfig{N}
239215
end
240216

241217
"""
242-
ForwardDiff.JacobianConfig(f, x::AbstractArray, chunk::Chunk = Chunk(x); tagstyle::Union{Symbol,Nothing} = :default)
218+
ForwardDiff.JacobianConfig(f, x::AbstractArray, chunk::Chunk = Chunk(x))
243219
244220
Return a `JacobianConfig` instance based on the type of `f` and type/shape of the input
245221
vector `x`.
@@ -259,16 +235,9 @@ This constructor does not store/modify `x`.
259235
"""
260236
@inline function JacobianConfig(f::F,
261237
x::AbstractArray{V},
262-
c::Chunk{N} = Chunk(x);
263-
tagstyle::Union{Symbol,Nothing} = :default) where {F,V,N}
264-
# @inline ensures that, e.g., JacobianConfig(...; tagstyle = :small) will be well-inferred
265-
@static if VERSION v"1.8"
266-
T = @inline maketag(tagstyle, f, V)
267-
return @noinline JacobianConfig(f,x,c,T)
268-
else
269-
T = maketag(tagstyle, f, V)
270-
return JacobianConfig(f,x,c,T)
271-
end
238+
c::Chunk{N} = Chunk(x)) where {F,V,N}
239+
T = maketag(f, V)
240+
return JacobianConfig(f,x,c,T)
272241
end
273242

274243
function JacobianConfig(f::F,
@@ -281,7 +250,7 @@ function JacobianConfig(f::F,
281250
end
282251

283252
"""
284-
ForwardDiff.JacobianConfig(f!, y::AbstractArray, x::AbstractArray, chunk::Chunk = Chunk(x); tagstyle::Union{Symbol,Nothing} = :default)
253+
ForwardDiff.JacobianConfig(f!, y::AbstractArray, x::AbstractArray, chunk::Chunk = Chunk(x))
285254
286255
Return a `JacobianConfig` instance based on the type of `f!`, and the types/shapes of the
287256
output vector `y` and the input vector `x`.
@@ -302,16 +271,9 @@ This constructor does not store/modify `y` or `x`.
302271
@inline function JacobianConfig(f::F,
303272
y::AbstractArray{Y},
304273
x::AbstractArray{X},
305-
c::Chunk{N} = Chunk(x);
306-
tagstyle::Union{Symbol,Nothing} = :default) where {F,Y,X,N}
307-
# @inline ensures that, e.g., JacobianConfig(...; tagstyle = :small) will be well-inferred
308-
@static if VERSION v"1.8"
309-
T = @inline maketag(tagstyle, f, X)
310-
return @noinline JacobianConfig(f,y,x,c,T)
311-
else
312-
T = maketag(tagstyle, f, X)
313-
return JacobianConfig(f,y,x,c,T)
314-
end
274+
c::Chunk{N} = Chunk(x)) where {F,Y,X,N}
275+
T = maketag(f, X)
276+
return JacobianConfig(f,y,x,c,T)
315277
end
316278

317279
function JacobianConfig(f::F,
@@ -339,7 +301,7 @@ struct HessianConfig{T,V,N,DG,DJ} <: AbstractConfig{N}
339301
end
340302

341303
"""
342-
ForwardDiff.HessianConfig(f, x::AbstractArray, chunk::Chunk = Chunk(x); tagstyle::Union{Symbol,Nothing} = :default)
304+
ForwardDiff.HessianConfig(f, x::AbstractArray, chunk::Chunk = Chunk(x))
343305
344306
Return a `HessianConfig` instance based on the type of `f` and type/shape of the input
345307
vector `x`.
@@ -361,16 +323,9 @@ This constructor does not store/modify `x`.
361323
"""
362324
@inline function HessianConfig(f::F,
363325
x::AbstractArray{V},
364-
chunk::Chunk = Chunk(x);
365-
tagstyle::Union{Symbol,Nothing} = :default) where {F,V}
366-
# @inline ensures that, e.g., HessianConfig(...; tagstyle = :small) will be well-inferred
367-
@static if VERSION v"1.8"
368-
T = @inline maketag(tagstyle, f, V)
369-
return @noinline HessianConfig(f, x, chunk, T)
370-
else
371-
T = maketag(tagstyle, f, V)
372-
return HessianConfig(f, x, chunk, T)
373-
end
326+
chunk::Chunk = Chunk(x)) where {F,V}
327+
T = maketag(f, V)
328+
return HessianConfig(f, x, chunk, T)
374329
end
375330

376331
function HessianConfig(f::F,
@@ -383,7 +338,7 @@ function HessianConfig(f::F,
383338
end
384339

385340
"""
386-
ForwardDiff.HessianConfig(f, result::DiffResult, x::AbstractArray, chunk::Chunk = Chunk(x); tagstyle::Union{Symbol,Nothing} = :default)
341+
ForwardDiff.HessianConfig(f, result::DiffResult, x::AbstractArray, chunk::Chunk = Chunk(x))
387342
388343
Return a `HessianConfig` instance based on the type of `f`, types/storage in `result`, and
389344
type/shape of the input vector `x`.
@@ -403,16 +358,9 @@ This constructor does not store/modify `x`.
403358
@inline function HessianConfig(f::F,
404359
result::DiffResult,
405360
x::AbstractArray{V},
406-
chunk::Chunk = Chunk(x);
407-
tagstyle::Union{Symbol,Nothing} = :default) where {F,V}
408-
# @inline ensures that, e.g., HessianConfig(...; tagstyle = :small) will be well-inferred
409-
@static if VERSION v"1.8"
410-
T = @inline maketag(tagstyle, f, V)
411-
return @noinline HessianConfig(f, result, x, chunk, T)
412-
else
413-
T = maketag(tagstyle, f, V)
414-
return HessianConfig(f, result, x, chunk, T)
415-
end
361+
chunk::Chunk = Chunk(x)) where {F,V}
362+
T = maketag(f, V)
363+
return HessianConfig(f, result, x, chunk, T)
416364
end
417365

418366
function HessianConfig(f::F,

0 commit comments

Comments
 (0)