Template Function sequant::eval::evaluate_ordered_schedule

Function Documentation

template<Trace EvalTrace = Trace::Default, meta::can_evaluate_range Nodes, typename F, typename N, bool FHC, typename ScopeGuardFactory = ::sequant::make_no_scope_guard>
ResultPtr sequant::eval::evaluate_ordered_schedule(Nodes const &forest, OrderedSchedule const &ordered, RichSchedule const &rich, auto const &layout, F const &leaf_evaluator, CacheManager<N, FHC> &cache, std::function<std::size_t(Index const&)> const &target, ScopeGuardFactory const &make_scope_guard = {}, std::function<bool(std::ranges::range_value_t<Nodes> const&)> const &is_volatile = {})

The ordered executor (as-built design section 8, doc/dev/specs/2026-09-12-batched-array-dag-eval-as-built.md). Walks ordered.root.steps in sequence, building one value per root-level BuildStep via detail::compute_cell (which reads every operand through the cell table, so a value an earlier step already produced is read from its cell rather than re-descended into &#8212; see compute_cell's doc comment) and one value per root-level ScopeBlock (Contracted or External alike) via detail::run_ordered_contracted_block (a realized batch loop, its own BuildStep's/nested child blocks run per batch on a scratch cache, its AccumulateSum outputs summed across batches; its AccumulateScatter outputs written into a disjoint slice of a pre-sized destination each batch &#8212; both kinds stored at the level the block itself sits in on close, including a nest’s own pass-ordered sibling blocks (one per pass, latitude = pass), run in schedule order like any other set of sibling steps), then combines the forest roots’ results into the final ResultPtr via the shared root-combine loop combine_forest_roots (permute-to-layout + cross-root add_inplace, with the Term/Permute/SumInplace trace bookkeeping).

Parameters:
  • forest – The forest whose per-root results are evaluated and summed.

  • ordered – The OrderedSchedule (build_ordered_schedule) for forest, built from rich / a LegalitySchedule over it.

  • rich – The RichSchedule that produced ordered (compute_dag_boulevard) &#8212; used to resolve a BuildStep's value_id back to a forest node via its ValueCell::hash and build_value_node_map, and to resolve each forest root’s own value_id for the final combine.

  • layout – The layout each root’s result is permuted to before being summed.

  • leaf_evaluator – The leaf evaluator, as in sequant::evaluate.

  • cache – The cache handle this run hangs its hooks off (backend array-ops, the peak monitor, the persistent value store); the table, not this cache, is where a value repeated across BuildStep's operand needs is deduped.

  • target – Per-index batch partition size (elements): the source of each realized loop block’s batch partition (detail::run_ordered_contracted_block's mode_batches call).

  • make_scope_guard – Backend scope-guard factory; unused here (no backend screening relaxation is threaded into the loop-block walk), threaded for interface symmetry with the forest-descent driver.

  • is_volatile – node-level volatility predicate (empty means “never volatile”), the lift of BatchPolicy::is_volatile_leaf exactly as make_evaluator's own is_volatile_node lift (eval.hpp) computes it &#8212; threaded down through detail::run_ordered_contracted_block's recursion but not consulted here: classifying a home value volatile-vs-persistent via subtree_any at the homing sites is left to the caller.

Returns:

The summed, per-root-permuted result, as forest descent itself would produce for the same (unbatched) forest.