Skip to content

Commit 84aa53c

Browse files
committed
Invlink if linked=false
1 parent 93e9bd4 commit 84aa53c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/test_utils/ad.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using ADTypes: AbstractADType, AutoForwardDiff
44
using Chairmarks: @be
55
import DifferentiationInterface as DI
66
using DocStringExtensions
7-
using DynamicPPL: Model, LogDensityFunction, VarInfo, AbstractVarInfo, link
7+
using DynamicPPL: Model, LogDensityFunction, VarInfo, AbstractVarInfo, link, invlink
88
using LogDensityProblems: logdensity, logdensity_and_gradient
99
using Random: Random, Xoshiro
1010
using Statistics: median
@@ -184,6 +184,8 @@ function run_ad(
184184
)::ADResult
185185
if linked
186186
varinfo = link(varinfo, model)
187+
else
188+
varinfo = invlink(varinfo, model)
187189
end
188190
if isnothing(params)
189191
params = varinfo[:]

test/ad.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ using DynamicPPL: LogDensityFunction
2323
varinfos = DynamicPPL.TestUtils.setup_varinfos(m, rand_param_values, vns)
2424

2525
@testset "$(short_varinfo_name(varinfo))" for varinfo in varinfos
26-
# TODO: This runs unlinked. Should we test linked as well?
2726
f = LogDensityFunction(m, varinfo)
2827
x = DynamicPPL.getparams(f)
2928
# Calculate reference logp + gradient of logp using ForwardDiff
@@ -57,14 +56,14 @@ using DynamicPPL: LogDensityFunction
5756
ref_ldf, adtype
5857
)
5958
else
60-
# TODO: Should we test linked as well?
61-
DynamicPPL.TestUtils.AD.run_ad(
59+
# TODO: test linked as well
60+
@test DynamicPPL.TestUtils.AD.run_ad(
6261
m,
6362
adtype;
6463
linked=false,
6564
varinfo=varinfo,
6665
expected_value_and_grad=(ref_logp, ref_grad),
67-
)
66+
) isa Any
6867
end
6968
end
7069
end

0 commit comments

Comments
 (0)