Function sequant::eval::well_formed

Function Documentation

inline bool sequant::eval::well_formed(OrderedSchedule const &sched)

Structural sanity check on sched (no sequencer logic):

  • every BuildStep::value_id is < sched.num_values;

  • ordinals are unique among same-axis (IndexSpace::base_key()) sibling blocks within a parent;

  • every ScopeBlock::outputs value_id is < sched.num_values;

  • single-producer (SSA-like), with the multi-level escape chain allowed: no value_id is built (BuildStep) more than once; a built value_id may also escape only through its own chain &#8212; every block listing it in outputs either holds its BuildStep or is an ancestor of the block that does (a member materialized across a forced loop split is built at its production site for its in-nest readers and escapes from that same site outward; see build_ordered_schedule's mixed-pass rule) &#8212; and any other combination of build and escape sites is duplicate production; and a value_id may escape (outputs) at more than one block only when those blocks lie on a single root-to-node nesting path (distinct depths, each shallower one an ancestor of the deepest) &#8212; the inner-sum / outer-scatter escape chain of build_ordered_schedule. Escapes in unrelated (sibling) blocks, or two escapes at one depth, are rejected as duplicate production.

Note

This checks single-producer (no duplicate production) but not completeness (no value_id gaps &#8212; that every id in [0, num_values) is produced somewhere). Completeness holds by construction of build_ordered_schedule and is covered by its own test, so a caller cannot read well_formed as a guarantee that every value_id is present.