Skip to content

Commit 2bf5b18

Browse files
committed
Add comments
1 parent fa32c88 commit 2bf5b18

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/fasteval.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,18 @@ using Random: Random
3939
4040
Evaluate a model using parameters obtained via `strategy`, and only computing the results in
4141
the provided accumulators.
42+
43+
It is assumed that the accumulators passed in have been initialised to appropriate values,
44+
as this function will not reset them. The default constructors for each accumulator will do
45+
this for you correctly.
46+
47+
Returns a tuple of the model's return value, plus an `OnlyAccsVarInfo`. Note that the `accs`
48+
argument may be mutated (depending on how the accumulators are implemented); hence the `!!`
49+
in the function name.
4250
"""
4351
@inline function fast_evaluate!!(
52+
# Note that this `@inline` is mandatory for performance. If it's not inlined, it leads
53+
# to extra allocations (even for trivial models) and much slower runtime.
4454
rng::Random.AbstractRNG,
4555
model::Model,
4656
strategy::AbstractInitStrategy,
@@ -69,6 +79,7 @@ end
6979
@inline function fast_evaluate!!(
7080
model::Model, strategy::AbstractInitStrategy, accs::AccumulatorTuple
7181
)
82+
# This `@inline` is also mandatory for performance
7283
return fast_evaluate!!(Random.default_rng(), model, strategy, accs)
7384
end
7485

0 commit comments

Comments
 (0)