Skip to content

Commit 98b57bb

Browse files
committed
Fix pre-compilation on Julia 1.6
This old version of Julia doesn't have call-site `@inline` / `@noinline` so version-guard against this trick for now.
1 parent e9652db commit 98b57bb

File tree

1 file changed

+42
-12
lines changed

1 file changed

+42
-12
lines changed

src/config.jl

+42-12
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,13 @@ This constructor does not store/modify `y` or `x`.
142142
x::X;
143143
tag::Union{Symbol,Nothing} = :default) where {F,X<:Real,Y<:Real}
144144
# @inline ensures that, e.g., DerivativeConfig(...; tag = :small) will be well-inferred
145-
T = @inline maketag(tag, f, X)
146-
return @noinline DerivativeConfig(f,y,x,T)
145+
@static if VERSION v"1.8"
146+
T = @inline maketag(tag, f, X)
147+
return @noinline DerivativeConfig(f,y,x,T)
148+
else
149+
T = maketag(tag, f, X)
150+
return DerivativeConfig(f,y,x,T)
151+
end
147152
end
148153

149154
function DerivativeConfig(f::F,
@@ -189,8 +194,13 @@ This constructor does not store/modify `x`.
189194
c::Chunk{N} = Chunk(x);
190195
tag::Union{Symbol,Nothing} = :default) where {F,V,N}
191196
# @inline ensures that, e.g., GradientConfig(...; tag = :small) will be well-inferred
192-
T = @inline maketag(tag, f, V)
193-
return @noinline GradientConfig(f,x,c,T)
197+
@static if VERSION v"1.8"
198+
T = @inline maketag(tag, f, V)
199+
return @noinline GradientConfig(f,x,c,T)
200+
else
201+
T = maketag(tag, f, V)
202+
return GradientConfig(f,x,c,T)
203+
end
194204
end
195205

196206
function GradientConfig(f::F,
@@ -238,8 +248,13 @@ This constructor does not store/modify `x`.
238248
c::Chunk{N} = Chunk(x);
239249
tag::Union{Symbol,Nothing} = :default) where {F,V,N}
240250
# @inline ensures that, e.g., JacobianConfig(...; tag = :small) will be well-inferred
241-
T = @inline maketag(tag, f, V)
242-
return @noinline JacobianConfig(f,x,c,T)
251+
@static if VERSION v"1.8"
252+
T = @inline maketag(tag, f, V)
253+
return @noinline JacobianConfig(f,x,c,T)
254+
else
255+
T = maketag(tag, f, V)
256+
return JacobianConfig(f,x,c,T)
257+
end
243258
end
244259

245260
function JacobianConfig(f::F,
@@ -276,8 +291,13 @@ This constructor does not store/modify `y` or `x`.
276291
c::Chunk{N} = Chunk(x);
277292
tag::Union{Symbol,Nothing} = :default) where {F,Y,X,N}
278293
# @inline ensures that, e.g., JacobianConfig(...; tag = :small) will be well-inferred
279-
T = @inline maketag(tag, f, X)
280-
return @noinline JacobianConfig(f,y,x,c,T)
294+
@static if VERSION v"1.8"
295+
T = @inline maketag(tag, f, X)
296+
return @noinline JacobianConfig(f,y,x,c,T)
297+
else
298+
T = maketag(tag, f, X)
299+
return JacobianConfig(f,y,x,c,T)
300+
end
281301
end
282302

283303
function JacobianConfig(f::F,
@@ -330,8 +350,13 @@ This constructor does not store/modify `x`.
330350
chunk::Chunk = Chunk(x);
331351
tag::Union{Symbol,Nothing} = :default) where {F,V}
332352
# @inline ensures that, e.g., HessianConfig(...; tag = :small) will be well-inferred
333-
T = @inline maketag(tag, f, V)
334-
return @noinline HessianConfig(f, x, chunk, T)
353+
@static if VERSION v"1.8"
354+
T = @inline maketag(tag, f, V)
355+
return @noinline HessianConfig(f, x, chunk, T)
356+
else
357+
T = maketag(tag, f, V)
358+
return HessianConfig(f, x, chunk, T)
359+
end
335360
end
336361

337362
function HessianConfig(f::F,
@@ -367,8 +392,13 @@ This constructor does not store/modify `x`.
367392
chunk::Chunk = Chunk(x);
368393
tag::Union{Symbol,Nothing} = :default) where {F,V}
369394
# @inline ensures that, e.g., HessianConfig(...; tag = :small) will be well-inferred
370-
T = @inline maketag(tag, f, V)
371-
return @noinline HessianConfig(f, result, x, chunk, T)
395+
@static if VERSION v"1.8"
396+
T = @inline maketag(tag, f, V)
397+
return @noinline HessianConfig(f, result, x, chunk, T)
398+
else
399+
T = maketag(tag, f, V)
400+
return HessianConfig(f, result, x, chunk, T)
401+
end
372402
end
373403

374404
function HessianConfig(f::F,

0 commit comments

Comments
 (0)