You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: HISTORY.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,23 @@
2
2
3
3
## 0.39.0
4
4
5
+
### Breaking changes
6
+
7
+
#### Parent and leaf contexts
8
+
9
+
The `DynamicPPL.NodeTrait` function has been removed.
10
+
Instead of implementing this, parent contexts should subtype `DynamicPPL.AbstractParentContext`.
11
+
This is an abstract type which requires you to overload two functions, `DynamicPPL.childcontext` and `DynamicPPL.setchildcontext`.
12
+
13
+
There should generally be few reasons to define your own parent contexts (the only one we are aware of, outside of DynamicPPL itself, is `Turing.Inference.GibbsContext`), so this change should not really affect users.
14
+
15
+
Leaf contexts require no changes, apart from a removal of the `NodeTrait` function.
16
+
17
+
`ConditionContext` and `PrefixContext` are no longer exported.
18
+
You should not need to use these directly, please use `AbstractPPL.condition` and `DynamicPPL.prefix` instead.
19
+
20
+
#### Miscellaneous
21
+
5
22
Removed the method `returned(::Model, values, keys)`; please use `returned(::Model, ::AbstractDict{<:VarName})` instead.
Copy file name to clipboardExpand all lines: docs/src/api.md
+36-10Lines changed: 36 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -352,13 +352,6 @@ Base.empty!
352
352
SimpleVarInfo
353
353
```
354
354
355
-
### Tilde-pipeline
356
-
357
-
```@docs
358
-
tilde_assume!!
359
-
tilde_observe!!
360
-
```
361
-
362
355
### Accumulators
363
356
364
357
The subtypes of [`AbstractVarInfo`](@ref) store the cumulative log prior and log likelihood, and sometimes other variables that change during executing, in what are called accumulators.
@@ -463,15 +456,48 @@ By default, it does not perform any actual sampling: it only evaluates the model
463
456
If you wish to sample new values, see the section on [VarInfo initialisation](#VarInfo-initialisation) just below this.
464
457
465
458
The behaviour of a model execution can be changed with evaluation contexts, which are a field of the model.
466
-
Contexts are subtypes of `AbstractPPL.AbstractContext`.
459
+
460
+
All contexts are subtypes of `AbstractPPL.AbstractContext`.
461
+
462
+
Contexts are split into two kinds:
463
+
464
+
**Leaf contexts**: These are the most important contexts as they ultimately decide how model evaluation proceeds.
465
+
For example, `DefaultContext` evaluates the model using values stored inside a VarInfo's metadata, whereas `InitContext` obtains new values either by sampling or from a known set of parameters.
466
+
DynamicPPL has more leaf contexts which are used for internal purposes, but these are the two that are exported.
467
467
468
468
```@docs
469
469
DefaultContext
470
-
PrefixContext
471
-
ConditionContext
472
470
InitContext
473
471
```
474
472
473
+
To implement a leaf context, you need to subtype `AbstractPPL.AbstractContext` and implement the `tilde_assume!!` and `tilde_observe!!` methods for your context.
474
+
475
+
```@docs
476
+
tilde_assume!!
477
+
tilde_observe!!
478
+
```
479
+
480
+
**Parent contexts**: These essentially act as 'modifiers' for leaf contexts.
481
+
For example, `PrefixContext` adds a prefix to all variable names during evaluation, while `ConditionContext` marks certain variables as observed.
482
+
483
+
To implement a parent context, you have to subtype `DynamicPPL.AbstractParentContext`, and implement the `childcontext` and `setchildcontext` methods.
484
+
If needed, you can also implement `tilde_assume!!` and `tilde_observe!!` for your context.
485
+
This is optional; the default implementation is to simply delegate to the child context.
486
+
487
+
```@docs
488
+
AbstractParentContext
489
+
childcontext
490
+
setchildcontext
491
+
```
492
+
493
+
Since contexts form a tree structure, these functions are automatically defined for manipulating context stacks.
494
+
They are mainly useful for modifying the fundamental behaviour (i.e. the leaf context), without affecting any of the modifiers (i.e. parent contexts).
495
+
496
+
```@docs
497
+
leafcontext
498
+
setleafcontext
499
+
```
500
+
475
501
### VarInfo initialisation
476
502
477
503
The function `init!!` is used to initialise, or overwrite, values in a VarInfo.
0 commit comments