Skip to content

Commit d88bf58

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 73e8b14 commit d88bf58

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
@@ -143,8 +143,13 @@ This constructor does not store/modify `y` or `x`.
143143
x::X;
144144
tag::Union{Symbol,Nothing} = :default) where {F,X<:Real,Y<:Real}
145145
# @inline ensures that, e.g., DerivativeConfig(...; tag = :small) will be well-inferred
146-
T = @inline maketag(tag, f, X)
147-
return @noinline DerivativeConfig(f,y,x,T)
146+
@static if VERSION v"1.8"
147+
T = @inline maketag(tag, f, X)
148+
return @noinline DerivativeConfig(f,y,x,T)
149+
else
150+
T = maketag(tag, f, X)
151+
return DerivativeConfig(f,y,x,T)
152+
end
148153
end
149154

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

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

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

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

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

375405
function HessianConfig(f::F,

0 commit comments

Comments
 (0)