-
Notifications
You must be signed in to change notification settings - Fork 219
/
runtests.jl
112 lines (96 loc) · 3.3 KB
/
runtests.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using AbstractMCMC
using AdvancedMH
using Clustering
using Distributions
using Distributions.FillArrays
using DistributionsAD
using FiniteDifferences
using ForwardDiff
using MCMCChains
using NamedArrays
using Optim
using Optimization
using OptimizationOptimJL
using PDMats
using ReverseDiff
using SpecialFunctions
using StatsBase
using StatsFuns
using Tracker
using Turing
using Turing.Inference
using Turing.RandomMeasures
using Zygote
using LinearAlgebra
using Pkg
using Random
using Test
using StableRNGs
using AdvancedPS: ResampleWithESSThreshold, resample_systematic, resample_multinomial
using AdvancedVI: TruncatedADAGrad, DecayedADAGrad, apply!
using Distributions: Binomial, logpdf
using DynamicPPL: getval, getlogp
using ForwardDiff: Dual
using MCMCChains: Chains
using StatsFuns: binomlogpdf, logistic, logsumexp
using TimerOutputs: TimerOutputs, @timeit
using Turing: BinomialLogit, ForwardDiffAD, Sampler, SampleFromPrior, NUTS, TrackerAD,
Variational, ZygoteAD, getspace
using Turing.Essential: TuringDenseMvNormal, TuringDiagMvNormal
using Turing.Variational: TruncatedADAGrad, DecayedADAGrad, AdvancedVI
import LogDensityProblems
import LogDensityProblemsAD
setprogress!(false)
include(pkgdir(Turing)*"/test/test_utils/AllUtils.jl")
# Collect timing and allocations information to show in a clear way.
const TIMEROUTPUT = TimerOutputs.TimerOutput()
macro timeit_include(path::AbstractString) :(@timeit TIMEROUTPUT $path include($path)) end
@testset "Turing" begin
@testset "essential" begin
@timeit_include("essential/ad.jl")
end
@testset "samplers (without AD)" begin
@timeit_include("mcmc/particle_mcmc.jl")
@timeit_include("mcmc/emcee.jl")
@timeit_include("mcmc/ess.jl")
@timeit_include("mcmc/is.jl")
end
Turing.setrdcache(false)
for adbackend in (:forwarddiff, :reversediff)
@timeit TIMEROUTPUT "inference: $adbackend" begin
Turing.setadbackend(adbackend)
@info "Testing $(adbackend)"
@testset "inference: $adbackend" begin
@testset "samplers" begin
@timeit_include("mcmc/gibbs.jl")
@timeit_include("mcmc/gibbs_conditional.jl")
@timeit_include("mcmc/hmc.jl")
@timeit_include("mcmc/Inference.jl")
@timeit_include("mcmc/sghmc.jl")
@timeit_include("mcmc/abstractmcmc.jl")
@timeit_include("mcmc/mh.jl")
@timeit_include("ext/dynamichmc.jl")
end
end
@testset "variational algorithms : $adbackend" begin
@timeit_include("variational/advi.jl")
end
@testset "mode estimation : $adbackend" begin
@timeit_include("optimisation/OptimInterface.jl")
@timeit_include("ext/Optimisation.jl")
end
end
end
@testset "variational optimisers" begin
@timeit_include("variational/optimisers.jl")
end
Turing.setadbackend(:forwarddiff)
@testset "stdlib" begin
@timeit_include("stdlib/distributions.jl")
@timeit_include("stdlib/RandomMeasures.jl")
end
@testset "utilities" begin
@timeit_include("mcmc/utilities.jl")
end
end
show(TIMEROUTPUT; compact=true, sortby=:firstexec)