Function sequant::eval::detail::mode_is_external

Function Documentation

inline bool sequant::eval::detail::mode_is_external(RichSchedule const &rich, Index const &mode)

True iff mode's index type (IndexSpace::base_key()) ever survives, un-summed, into a forest-root value’s own carried slots.

RichSchedule does not carry BatchModeType directly: the cross-occurrence meet in stamp_lifetime_masks folds every kind (External or Contracted) into one Index set (see stamp_residency_impl's doc comment — “any BatchModeType”), so a mode’s kind is not a field anywhere on ValueCell. It is still recoverable from rich alone: a batch mode realized in the forest is either Contracted (summed away below every root — an accumulate loop, so it never appears on a root’s own result) or External (a free/spectator index of some final output — a scatter loop, one output slice per block, so it does appear on a root’s own result). A forest-root occurrence is identified by OccurrenceRec::point == consumer_point: compute_dag_boulevard's post-order walk only ever overwrites a child’s consumer_point (to its parent’s point, always later in the walk), so a node that is never anyone’s child — a top-level tree of the forest — keeps its default-seeded consumer_point == its own point.

Matches by type (base_key()) — not by exact Index identity (Index::operator== compares space and ordinal). More than one physical Index label of the same type can appear across rich's cells (e.g. one occurrence’s K_1 vs another’s K_2), so an exact-Index match could miss a root occurrence that uses a different physical label of the very type being classified, silently misclassifying an External mode as Contracted.