Template Function sequant::detail::make_batched_scratch¶
Defined in File eval.hpp
Function Documentation¶
-
template<typename TreeNode, bool FHC, typename Members>
BatchedScratch<TreeNode, FHC> sequant::detail::make_batched_scratch(Members const &members, CacheManager<TreeNode, FHC> const &real)¶ Builds the scratch CacheManager for one batched replay pass over
members(each a subtree root paired with its batch mode).Walks every member subtree with the same pruned counting walk as cache_manager() (descend on first visit of a canonical-equal node, so counts match access counts under caching — and also on a re-encounter whose slicing signature differs from the first visit’s, so that descendants’ signatures under an inconsistently-sliced occurrence are recorded rather than hidden by the prune) and registers every internal subnode that repeats AND has a consistent slicing signature — the position of the containing member’s batch mode in the subnode’s canon_indices(), or its absence — across all occurrences. Signature consistency is what makes a scratch hit exact across members: canonical equality maps the index at canonical position p to the index at position p, so equal signatures plus equal realized element ranges (guaranteed by the caller’s grouping) imply identical slices. Inconsistently-sliced subnodes are not registered and so are evaluated per occurrence, unshared. Count inexactness arising from the pruned walk is benign: an undercount makes evaluate() recompute a drained entry, an overcount keeps an entry until the per-batch reset().
Subnodes whose signature is consistently ‘absent’ (no leaf below carries the mode — the mode is contracted at the member’s root, so a subtree containing a mode-carrying leaf carries the mode free in its canon_indices()) have batch-invariant full values; those that are alive persistent entries of
realare returned as seeds and the caller copies their values into the scratch before the batch loop.Note
The ordered (table-driven) executor does not come through here: it resolves every operand read from the cell table’s own storage, so the seeding discipline below is the forest-descent one and the only one.