352352fast_ldf_accs (:: typeof (getlogprior)) = AccumulatorTuple ((LogPriorAccumulator (),))
353353fast_ldf_accs (:: typeof (getloglikelihood)) = AccumulatorTuple ((LogLikelihoodAccumulator (),))
354354
355- struct FastLogDensityAt{M<: Model ,F<: Function ,N<: NamedTuple }
356- _model:: M
357- _getlogdensity:: F
358- _iden_varname_ranges:: N
359- _varname_ranges:: Dict{VarName,RangeAndLinked}
360- end
361- function (f:: FastLogDensityAt )(params:: AbstractVector{<:Real} )
362- ctx = FastEvalVectorContext (f. _iden_varname_ranges, f. _varname_ranges, params)
363- model = DynamicPPL. setleafcontext (f. _model, ctx)
364- accs = fast_ldf_accs (f. _getlogdensity)
355+ function fast_evaluate!! (model:: Model , ctx:: FastEvalVectorContext , accs:: AccumulatorTuple )
356+ model = DynamicPPL. setleafcontext (model, ctx)
357+ vi = OnlyAccsVarInfo (accs)
365358 # Calling `evaluate!!` would be fine, but would lead to an extra call to resetaccs!!,
366359 # which is unnecessary. So we shortcircuit this by simply calling `_evaluate!!`
367360 # directly. To preserve thread-safety we need to reproduce the ThreadSafeVarInfo logic
@@ -378,7 +371,18 @@ function (f::FastLogDensityAt)(params::AbstractVector{<:Real})
378371 else
379372 OnlyAccsVarInfo (accs)
380373 end
381- _, vi = DynamicPPL. _evaluate!! (model, vi)
374+ return DynamicPPL. _evaluate!! (model, vi)
375+ end
376+
377+ struct FastLogDensityAt{M<: Model ,F<: Function ,N<: NamedTuple }
378+ _model:: M
379+ _getlogdensity:: F
380+ _iden_varname_ranges:: N
381+ _varname_ranges:: Dict{VarName,RangeAndLinked}
382+ end
383+ function (f:: FastLogDensityAt )(params:: AbstractVector{<:Real} )
384+ ctx = FastEvalVectorContext (f. _iden_varname_ranges, f. _varname_ranges, params)
385+ _, vi = fast_evaluate!! (f. _model, ctx, fast_ldf_accs (f. _getlogdensity))
382386 return f. _getlogdensity (vi)
383387end
384388
0 commit comments