@@ -8,8 +8,7 @@ struct Prior <: InferenceAlgorithm end
88function AbstractMCMC. step (
99 rng:: Random.AbstractRNG ,
1010 model:: DynamicPPL.Model ,
11- sampler:: DynamicPPL.Sampler{<:Prior} ,
12- state= nothing ;
11+ sampler:: DynamicPPL.Sampler{<:Prior} ;
1312 kwargs... ,
1413)
1514 # TODO (DPPL0.38/penelopeysm): replace with init!!
@@ -26,5 +25,27 @@ function AbstractMCMC.step(
2625 ),
2726 )
2827 _, 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
3051end
0 commit comments