Skip to content

Commit 22569ee

Browse files
committed
Disable Mooncake on prerelease
1 parent 1a70627 commit 22569ee

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

test/ad.jl

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,22 @@ using Random: Random
88
using StableRNGs: StableRNG
99
using Test
1010
using ..Models: gdemo_default
11-
import ForwardDiff, ReverseDiff, Mooncake
11+
import ForwardDiff, ReverseDiff
12+
13+
# Detect if prerelease version, if so, we skip some tests
14+
const IS_PRERELEASE = !isempty(VERSION.prerelease)
15+
const INCLUDE_MOONCAKE = !IS_PRERELEASE
16+
17+
if INCLUDE_MOONCAKE
18+
Pkg.add("Mooncake")
19+
using Mooncake: Mooncake
20+
end
1221

1322
"""Element types that are always valid for a VarInfo regardless of ADType."""
1423
const always_valid_eltypes = (AbstractFloat, AbstractIrrational, Integer, Rational)
1524

1625
"""A dictionary mapping ADTypes to the element types they use."""
17-
const eltypes_by_adtype = Dict(
26+
eltypes_by_adtype = Dict(
1827
Turing.AutoForwardDiff => (ForwardDiff.Dual,),
1928
Turing.AutoReverseDiff => (
2029
ReverseDiff.TrackedArray,
@@ -25,8 +34,10 @@ const eltypes_by_adtype = Dict(
2534
ReverseDiff.TrackedVecOrMat,
2635
ReverseDiff.TrackedVector,
2736
),
28-
Turing.AutoMooncake => (Mooncake.CoDual,),
2937
)
38+
if INCLUDE_MOONCAKE
39+
eltypes_by_adtype[Turing.AutoMooncake] = (Mooncake.CoDual,)
40+
end
3041

3142
"""
3243
AbstractWrongADBackendError
@@ -177,11 +188,10 @@ end
177188
"""
178189
All the ADTypes on which we want to run the tests.
179190
"""
180-
ADTYPES = [
181-
Turing.AutoForwardDiff(),
182-
Turing.AutoReverseDiff(; compile=false),
183-
Turing.AutoMooncake(; config=nothing),
184-
]
191+
ADTYPES = [Turing.AutoForwardDiff(), Turing.AutoReverseDiff(; compile=false)]
192+
if INCLUDE_MOONCAKE
193+
push!(ADTYPES, Turing.AutoMooncake(; config=nothing))
194+
end
185195

186196
# Check that ADTypeCheckContext itself works as expected.
187197
@testset "ADTypeCheckContext" begin

0 commit comments

Comments
 (0)