@@ -8,8 +8,7 @@ struct Prior <: InferenceAlgorithm end
8
8
function AbstractMCMC. step (
9
9
rng:: Random.AbstractRNG ,
10
10
model:: DynamicPPL.Model ,
11
- sampler:: DynamicPPL.Sampler{<:Prior} ,
12
- state= nothing ;
11
+ sampler:: DynamicPPL.Sampler{<:Prior} ;
13
12
kwargs... ,
14
13
)
15
14
# TODO (DPPL0.38/penelopeysm): replace with init!!
@@ -26,5 +25,27 @@ function AbstractMCMC.step(
26
25
),
27
26
)
28
27
_, vi = DynamicPPL. evaluate!! (sampling_model, vi)
29
- return Transition (model, vi, nothing ; reevaluate= false ), nothing
28
+ vi = DynamicPPL. typed_varinfo (vi)
29
+ return Transition (model, vi, nothing ; reevaluate= false ), vi
30
+ end
31
+
32
+ function AbstractMCMC. step (
33
+ rng:: Random.AbstractRNG ,
34
+ model:: DynamicPPL.Model ,
35
+ sampler:: DynamicPPL.Sampler{<:Prior} ,
36
+ vi:: AbstractVarInfo ;
37
+ kwargs... ,
38
+ )
39
+ # TODO (DPPL0.38/penelopeysm): replace the entire thing with init!!
40
+ # `vi` is a VarInfo from the previous step so already has all the
41
+ # right accumulators and stuff. The only thing we need to change is
42
+ # to make sure that the old values are overwritten...
43
+ for vn in keys (vi)
44
+ DynamicPPL. set_flag! (vi, vn, " del" )
45
+ end
46
+ sampling_model = DynamicPPL. contextualize (
47
+ model, DynamicPPL. SamplingContext (rng, DynamicPPL. SampleFromPrior (), model. context)
48
+ )
49
+ _, vi = DynamicPPL. evaluate!! (sampling_model, vi)
50
+ return Transition (model, vi, nothing ; reevaluate= false ), vi
30
51
end
0 commit comments