Template Function sequant::eval::evaluate_ordered_multiroot¶
Defined in File ordered_executor.hpp
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>
container::svector<ResultPtr> sequant::eval::evaluate_ordered_multiroot(Nodes const &roots, OrderedSchedule const &ordered, RichSchedule const &rich, container::svector<std::string> const &layouts, 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 multi-root ordered entry point. Identical inputs to
evaluate_ordered_schedule(sameroots/ alreadyhave been built from the same concatenatedroots, e.g. viacompute_dag_boulevard(roots, ...)build_ordered_schedule, exactly as anyevaluate_ordered_schedulecaller already does for its own forest), exceptlayoutwidens tolayouts, one entry per root: unlike a single summed forest, independent roots need not share a layout (e.g. distinct CC residual annotations R1{a;i}vs R2{ab;ij}). Returns a map instead of a sum: each root’s own (permuted to its ownlayoutsentry, but not cross-root-accumulated) result, aligned index-for-index withroots.Runs the identical schedule walk
evaluate_ordered_scheduleruns (via the samedetail::run_ordered_schedule_pre_resultsthis function andevaluate_ordered_scheduleboth delegate to —thecell table derivation and the run-completeness assert are unchanged, exercised over the combined schedule exactly as they already are for a multi-summand forest), so a value shared across two independent roots is built exactly once for the identical reason a value shared across two summands of one root’s own forest already is:compute_dag_boulevardbuckets by structural hash into oneValueCellregardless of which root(s) reference it, andwell_formed'sstatic single-producer invariant (plus this walk’s own run-completeness assert) guarantees the schedule realizes exactly oneBuildStepfor it. The only change fromevaluate_ordered_scheduleis the tail: instead of one forest-widecombine_forest_rootscall (which sums every root into a singleResultPtr), this callscombine_forest_rootsonce per root, each with a singleton{roots[i]}/{pre_results[i]} pair — reusing the identical per-root Term/Permute trace bookkeepingcombine_forest_rootsalready emits for each root of a summed forest, but never reaching its cross-rootadd_inplace(a singleton call never has a second root to sum against), so no roots are summed together. For a single-rootrootsinput this reduces to a singletoncombine_forest_rootscall byte- identical to whatevaluate_ordered_schedulewould run for that same one-root forest — the regression anchor:evaluate_ordered_multiroot( {r}, …) == { evaluate_ordered_schedule({r}, …) }.
- Returns:
One
ResultPtrper element ofroots, inroots'own order, each permuted to its ownlayoutsentry — not summed together.