Template Function sequant::eval::combine_forest_roots¶
Defined in File forest_combine.hpp
Function Documentation¶
-
template<Trace EvalTrace, meta::can_evaluate node_t, typename N, bool FHC>
ResultPtr sequant::eval::combine_forest_roots(container::svector<node_t const*> const &roots, container::svector<ResultPtr> &pre_results, auto const &layout, CacheManager<N, FHC> &cache)¶ The shared per-root combine step every whole-forest executor ends with: permute each root’s own (already-built) result to
layout, then sum across roots — the identical Term Begin/End boundary, Permute EvalStat, and cross-rootadd_inplace+ SumInplace EvalStat trace/hwmark bookkeepingsequant::evaluate(Nodes const&, layout, ...)(eval.hpp) emits.Factored into its own header so every whole-forest executor entry —
evaluate_ordered_scheduleandevaluate_ordered_multiroot(ordered_executor.hpp) — reuses the identical bookkeeping rather than hand-syncing a second copy that would silently drift as later work extends either entry point.- Parameters:
roots – pointers to the forest’s own top-level trees, in forest order — pointers, not nodes, because
FullBinaryNode'scopy constructor deep-copies the whole subtree, and a caller assembling a node vector here would clone the entire forest (thousands of nodes for a residual) once per call just to name its roots. The pointees are the caller’s forest, which outlives this call.pre_results – Each root’s own unpermuted, already-built result, aligned index-for-index with
roots. Moved out of on use (each entry is consumed), so the caller’s own copy is left empty after this call returns.layout – The layout each root’s result is permuted to before being summed; same meaning as
sequant::evaluate(Node const&, layout,
...)'s
layout.cache – The cache consulted for the trace/hwmark bookkeeping only (byte counts, chain residency) — no value is built or stored by this function.
- Returns:
The summed, per-root-permuted result.