@@ -13,6 +13,7 @@ An accumulator type `T <: AbstractAccumulator` must implement the following meth
1313- `accumulator_name(acc::T)` or `accumulator_name(::Type{T})`
1414- `accumulate_observe!!(acc::T, dist, val, vn)`
1515- `accumulate_assume!!(acc::T, val, logjac, vn, dist)`
16+ - `reset(acc::T)`
1617- `Base.copy(acc::T)`
1718
1819In these functions:
@@ -50,9 +51,7 @@ accumulator_name(acc::AbstractAccumulator) = accumulator_name(typeof(acc))
5051
5152Update `acc` in a `tilde_observe!!` call. Returns the updated `acc`.
5253
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.
5655
5756`accumulate_observe!!` may mutate `acc`, but not any of the other arguments.
5857
@@ -65,26 +64,45 @@ function accumulate_observe!! end
6564
6665Update `acc` in a `tilde_assume!!` call. Returns the updated `acc`.
6766
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.
7368
7469`accumulate_assume!!` may mutate `acc`, but not any of the other arguments.
7570
7671See also: [`accumulate_observe!!`](@ref)
7772"""
7873function accumulate_assume!! end
7974
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+
8095"""
8196 split(acc::AbstractAccumulator)
8297
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.
84103
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.
88106
89107See also: [`combine`](@ref)
90108"""
0 commit comments