Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DynamicPPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export AbstractVarInfo,
SampleFromUniform,
# Contexts
SamplingContext,
DefaultContext,
EvaluationContext,
LikelihoodContext,
PriorContext,
MiniBatchContext,
Expand Down
8 changes: 8 additions & 0 deletions src/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,15 @@ function build_output(modelinfo, linenumbernode)
evaluatordef[:kwargs] = []

# Replace the user-provided function body with the version created by DynamicPPL.
@gensym leafctx
evaluatordef[:body] = quote
# in case someone accessed these
$leafctx = DynamicPPL.unwrap(__context__)
if $leafctx isa $(DynamicPPL.SamplingContext)
__rng__ = $leafctx.rng
__sampler__ = $leafctx.sampler
end

$(modelinfo[:body])
end

Expand Down
Loading