Function sequant::eval::classify_axis¶
Defined in File legality.hpp
Function Documentation¶
-
inline LoopRole sequant::eval::classify_axis(container::svector_base<Index> const &carried, container::svector_base<Index> const &contracted_below, Index const &axis, container::svector_base<OccurrenceRec> const &occurrences, std::function<container::svector<LoopInstance>(OccurrenceRec const&)> const &enclosing_instances, container::svector<OccurrenceAxisRole> *per_occurrence = nullptr)¶
Classify one batch-loop axis
axisagainst one value, given the value’s own result indicescarried, the axes it contracts at its own nodecontracted_below(seecontracted_indicesin eval_expr.hpp), and every use-siteoccurrencesof the value in the forest.Two questions, the second answered per occurrence:
Q1: is
axisone ofcarried(byIndexidentity)?no -> does
contracted_belowhold it (the value reduces the axis at its own node)? ->Reduction; otherwise the axis merely encloses the value without touching it ->LoopInvariant.yes -> Q2: for every occurrence, is the loop instance that slices
axis'scarried position (the occurrence’s ownloop_slotat that position) among the instances enclosing the occurrence (enclosing_instances)? Enclosed -> the occurrence reads the value inside its own loop, per batch (OccurrenceRole::Lockstep); not enclosed -> the occurrence reads it where that loop is not running: the value opens the loop itself, or the reader sits after it, or in a sibling nest – in every case the reader needs the assembled value (OccurrenceRole::Assembled). The value’s role isLoopLocalif any occurrence is enclosed andLoopCarriedotherwise (also with no occurrences at all). The per-occurrence verdicts are appended toper_occurrencewhen given; aLoopLocalvalue withAssembledoccurrences is built inside its loop for the former and additionally escapes assembled for the latter (build_ordered_schedule).
Positions, not labels, align the occurrences: every occurrence’s
carriedlist is positionally aligned withcarried(each occurrence’s frame relabels the same slots), soaxis'sposition incarriedis the one read at every occurrence. Loop identity is the recorded one (OccurrenceRec::loop_slotand the openers’ stamps). An occurrence that is not aligned, or a batched position with no stamp, is a defect of the record and throws.