When parsing the model, if we encounter any := statements we could store a flag on the model. This is because, in general, if you need to calculate the value of some := statement, the only reliable way is to re-execute the model. In contrast, if you only need parameters in ~ statements, you could sometimes get away with not evaluating the model (e.g. if the values are already stored in some other format).
In particular, I'm thinking of this case:
|
# Specialisation for when the LDF is known to have all fixed transforms |
|
function ParamsWithStats( |
|
param_vector::AbstractVector, |
|
ldf::LogDensityFunction{M,A,L,F,V,D,X,C,true}, |
|
stats::NamedTuple=NamedTuple(); |
|
include_colon_eq::Bool=true, |
|
include_log_probs::Bool=true, |
|
) where {M,A,L,F,V,D,X,C} |
|
if include_log_probs || include_colon_eq |
|
return pws_with_eval(param_vector, ldf, stats; include_colon_eq, include_log_probs) |
|
end |
|
# Fast path: extract raw values directly from the parameter vector using the fixed |
If include_colon_eq is true, then we conservatively rerun the model. However, if the model has no := statements, then we technically don't need to.
This is a bit of a minor optimisation though and probably not very urgent.
When parsing the model, if we encounter any
:=statements we could store a flag on the model. This is because, in general, if you need to calculate the value of some:=statement, the only reliable way is to re-execute the model. In contrast, if you only need parameters in~statements, you could sometimes get away with not evaluating the model (e.g. if the values are already stored in some other format).In particular, I'm thinking of this case:
DynamicPPL.jl/src/chains.jl
Lines 175 to 186 in 157e5f6
If
include_colon_eqis true, then we conservatively rerun the model. However, if the model has no:=statements, then we technically don't need to.This is a bit of a minor optimisation though and probably not very urgent.