Skip to content

Commit c5574ae

Browse files
committed
Link VarInfo by default
1 parent 5ba3530 commit c5574ae

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
**Breaking changes**
66

7+
### AD testing utilities
8+
9+
`DynamicPPL.TestUtils.AD.run_ad` now links the VarInfo by default.
10+
711
### VarInfo constructors
812

913
`VarInfo(vi::VarInfo, values)` has been removed. You can replace this directly with `unflatten(vi, values)` instead.

src/test_utils/ad.jl

Lines changed: 7 additions & 4 deletions
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
7+
using DynamicPPL: Model, LogDensityFunction, VarInfo, AbstractVarInfo, link
88
using LogDensityProblems: logdensity, logdensity_and_gradient
99
using Random: Random, Xoshiro
1010
using Statistics: median
@@ -64,7 +64,7 @@ end
6464
benchmark=false,
6565
value_atol=1e-6,
6666
grad_atol=1e-6,
67-
varinfo::AbstractVarInfo=VarInfo(model),
67+
varinfo::AbstractVarInfo=link(VarInfo(model), model),
6868
params::Vector{<:Real}=varinfo[:],
6969
reference_adtype::ADTypes.AbstractADType=REFERENCE_ADTYPE,
7070
expected_value_and_grad::Union{Nothing,Tuple{Real,Vector{<:Real}}}=nothing,
@@ -96,7 +96,10 @@ Everything else is optional, and can be categorised into several groups:
9696
DynamicPPL contains several different types of VarInfo objects which change
9797
the way model evaluation occurs. If you want to use a specific type of
9898
VarInfo, pass it as the `varinfo` argument. Otherwise, it will default to
99-
using a `TypedVarInfo` generated from the model.
99+
using a `TypedVarInfo` generated from the model. It will also perform
100+
_linking_, that is, the parameters in the VarInfo will be transformed to
101+
unconstrained Euclidean space if they aren't already in that space. Note
102+
that the act of linking may change the length of the parameters.
100103
101104
2. _How to specify the parameters._
102105
@@ -148,7 +151,7 @@ function run_ad(
148151
benchmark=false,
149152
value_atol=1e-6,
150153
grad_atol=1e-6,
151-
varinfo::AbstractVarInfo=VarInfo(model),
154+
varinfo::AbstractVarInfo=link(VarInfo(model), model),
152155
params::Vector{<:Real}=varinfo[:],
153156
reference_adtype::AbstractADType=REFERENCE_ADTYPE,
154157
expected_value_and_grad::Union{Nothing,Tuple{Real,Vector{<:Real}}}=nothing,

0 commit comments

Comments
 (0)