@@ -146,6 +146,26 @@ function _pointwise_tilde_observe(
146
146
end
147
147
end
148
148
149
+ # Note on submodels (penelopeysm)
150
+ #
151
+ # We don't need to overload tilde_observe!! for Sampleables (yet), because it
152
+ # is currently not possible to evaluate a model with a Sampleable on the RHS
153
+ # of an observe statement.
154
+ #
155
+ # Note that calling tilde_assume!! on a Sampleable does not necessarily imply
156
+ # that there are no observe statements inside the Sampleable. There could well
157
+ # be likelihood terms in there, which must be included in the returned logp.
158
+ # See e.g. the `demo_dot_assume_observe_submodel` demo model.
159
+ #
160
+ # This is handled by passing the same context to rand_like!!, which figures out
161
+ # which terms to include using the context, and also mutates the context and vi
162
+ # appropriately. Thus, we don't need to check against _include_prior(context)
163
+ # here.
164
+ function tilde_assume!! (context:: PointwiseLogdensityContext , right:: Sampleable , vn, vi)
165
+ value, vi = DynamicPPL. rand_like!! (right, context, vi)
166
+ return value, vi
167
+ end
168
+
149
169
function tilde_assume!! (context:: PointwiseLogdensityContext , right, vn, vi)
150
170
! _include_prior (context) && return (tilde_assume!! (context. context, right, vn, vi))
151
171
value, logp, vi = tilde_assume (context. context, right, vn, vi)
0 commit comments