Function sequant::eval::detail::assert_global_level_axis_uniqueness

Function Documentation

inline void sequant::eval::detail::assert_global_level_axis_uniqueness(ScopeBlock const &block, std::map<std::tuple<std::size_t, std::wstring, int, int>, Index> &seen)

Debug safety net: compute_sliced_mode_assignment's canonical level enumeration (enumerate_realized_levels, which folds every realized ScopeBlock's DagScopeLevel into one LoopId per distinct level) leans on (level.depth, level.space, level.ordinal) being unique globally across the whole realized tree &#8212; i.e. any two blocks sharing that triple must also share the same representative axis, or the enumeration could fold two structurally-different loops onto one LoopId. well_formed only checks ordinal uniqueness among a block’s own same-axis direct children (sibling-local, see ordered_schedule_block_well_formed above) &#8212; it says nothing about two blocks at the same (depth, space, ordinal) that are not siblings (say, nested under different parents). Walk every block in the tree and assert the stronger, global invariant loudly: a violation means the scheduler emitted two structurally-distinct loops the level-to-LoopId mapping cannot tell apart. Debug-only insurance; expected to never fire on any fixture.