@@ -22,23 +22,24 @@ using DynamicPPL: LogDensityFunction
22
22
vns = DynamicPPL. TestUtils. varnames (m)
23
23
varinfos = DynamicPPL. TestUtils. setup_varinfos (m, rand_param_values, vns)
24
24
25
- @testset " $(short_varinfo_name (varinfo)) " for varinfo in varinfos
26
- # TODO : This runs unlinked. Should we test linked as well?
27
- f = LogDensityFunction (m, varinfo )
25
+ @testset " $(short_varinfo_name (varinfo)) " for linked_varinfo in varinfos
26
+ linked_varinfo = DynamicPPL . link (varinfo, m)
27
+ f = LogDensityFunction (m, linked_varinfo )
28
28
x = DynamicPPL. getparams (f)
29
29
# Calculate reference logp + gradient of logp using ForwardDiff
30
- ref_ldf = LogDensityFunction (m, varinfo ; adtype= ref_adtype)
30
+ ref_ldf = LogDensityFunction (m, linked_varinfo ; adtype= ref_adtype)
31
31
ref_logp, ref_grad = LogDensityProblems. logdensity_and_gradient (ref_ldf, x)
32
32
33
33
@testset " $adtype " for adtype in test_adtypes
34
- @info " Testing AD on: $(m. f) - $(short_varinfo_name (varinfo )) - $adtype "
34
+ @info " Testing AD on: $(m. f) - $(short_varinfo_name (linked_varinfo )) - $adtype "
35
35
36
36
# Put predicates here to avoid long lines
37
37
is_mooncake = adtype isa AutoMooncake
38
38
is_1_10 = v " 1.10" <= VERSION < v " 1.11"
39
39
is_1_11 = v " 1.11" <= VERSION < v " 1.12"
40
- is_svi_vnv = varinfo isa SimpleVarInfo{<: DynamicPPL.VarNamedVector }
41
- is_svi_od = varinfo isa SimpleVarInfo{<: OrderedDict }
40
+ is_svi_vnv =
41
+ linked_varinfo isa SimpleVarInfo{<: DynamicPPL.VarNamedVector }
42
+ is_svi_od = linked_varinfo isa SimpleVarInfo{<: OrderedDict }
42
43
43
44
# Mooncake doesn't work with several combinations of SimpleVarInfo.
44
45
if is_mooncake && is_1_11 && is_svi_vnv
@@ -57,11 +58,10 @@ using DynamicPPL: LogDensityFunction
57
58
ref_ldf, adtype
58
59
)
59
60
else
60
- # TODO : Should we test linked as well?
61
61
@test DynamicPPL. TestUtils. AD. run_ad (
62
62
m,
63
63
adtype;
64
- varinfo= varinfo ,
64
+ varinfo= linked_varinfo ,
65
65
expected_value_and_grad= (ref_logp, ref_grad),
66
66
) isa Any
67
67
end
0 commit comments