@@ -13,6 +13,7 @@ An accumulator type `T <: AbstractAccumulator` must implement the following meth
13
13
- `accumulator_name(acc::T)` or `accumulator_name(::Type{T})`
14
14
- `accumulate_observe!!(acc::T, dist, val, vn)`
15
15
- `accumulate_assume!!(acc::T, val, logjac, vn, dist)`
16
+ - `reset(acc::T)`
16
17
- `Base.copy(acc::T)`
17
18
18
19
In these functions:
@@ -50,9 +51,7 @@ accumulator_name(acc::AbstractAccumulator) = accumulator_name(typeof(acc))
50
51
51
52
Update `acc` in a `tilde_observe!!` call. Returns the updated `acc`.
52
53
53
- `vn` is the name of the variable being observed, `left` is the value of the variable, and
54
- `right` is the distribution on the RHS of the tilde statement. `vn` is `nothing` in the case
55
- of literal observations like `0.0 ~ Normal()`.
54
+ See [`AbstractAccumulator`](@ref) for the meaning of the arguments.
56
55
57
56
`accumulate_observe!!` may mutate `acc`, but not any of the other arguments.
58
57
@@ -65,26 +64,45 @@ function accumulate_observe!! end
65
64
66
65
Update `acc` in a `tilde_assume!!` call. Returns the updated `acc`.
67
66
68
- `vn` is the name of the variable being assumed, `val` is the value of the variable (in the
69
- original, unlinked space), and `right` is the distribution on the RHS of the tilde
70
- statement. `logjac` is the log determinant of the Jacobian of the transformation that was
71
- done to convert the value of `vn` as it was given to `val`: for example, if the sampler is
72
- operating in linked (Euclidean) space, then logjac will be nonzero.
67
+ See [`AbstractAccumulator`](@ref) for the meaning of the arguments.
73
68
74
69
`accumulate_assume!!` may mutate `acc`, but not any of the other arguments.
75
70
76
71
See also: [`accumulate_observe!!`](@ref)
77
72
"""
78
73
function accumulate_assume!! end
79
74
75
+ """
76
+ reset(acc::AbstractAccumulator)
77
+
78
+ Return a new accumulator like `acc`, but with its contents reset to the state that they
79
+ should be at the beginning of model evaluation.
80
+
81
+ Note that this may in general have very similar behaviour to [`split`](@ref), and may share
82
+ the same implementation, but the difference is that `split` may in principle happen at any
83
+ stage during model evaluation, whereas `reset` is only called at the beginning of model
84
+ evaluation.
85
+ """
86
+ function reset end
87
+
88
+ @doc """
89
+ Base.copy(acc::AbstractAccumulator)
90
+
91
+ Create a new accumulator that is a copy of `acc`, without aliasing (i.e., this should
92
+ behave conceptually like a `deepcopy`).
93
+ """ Base. copy
94
+
80
95
"""
81
96
split(acc::AbstractAccumulator)
82
97
83
- Return a new accumulator like `acc` but empty.
98
+ Return a new accumulator like `acc` suitable for use in a forked thread.
99
+
100
+ The returned value should be such that `combine(acc, split(acc))` is equal to `acc`. This is
101
+ used in the context of multi-threading where different threads may accumulate independently
102
+ and the results are then combined.
84
103
85
- The precise meaning of "empty" is that that the returned value should be such that
86
- `combine(acc, split(acc))` is equal to `acc`. This is used in the context of multi-threading
87
- where different threads may accumulate independently and the results are then combined.
104
+ Note that this may in general have very similar behaviour to [`reset`](@ref), but is
105
+ semantically different. See [`reset`](@ref) for more details.
88
106
89
107
See also: [`combine`](@ref)
90
108
"""
0 commit comments