Struct NodeBatchAnnotation

Struct Documentation

struct NodeBatchAnnotation

Per-contraction-node batch annotation emitted by the order-aware batched cost model (PeakBatchedModel::reconstruct_batched_modes) and threaded to the eval tree via BinarizationOptions::node_batch_axes.

One instance per contraction node, in the optimizer’s left-first post-order. Beyond axes, this is the annotation bridge to a runtime batched evaluator that hoists loop-invariant intermediates: order_aware (the gate) feeds per-level placement together with the runtime residency EvalExpr::sliced_modes (the all-batched-modes cross-occurrence meet, which carries the enclosing-contracted residency directly); effective_count is the node’s effective use count — how many times its value is (re)referenced across the enclosing batch loops it does not carry, the product of per-mode batch counts over its escaped-outer set.

The defaults (order_aware == false, effective_count == 1) are the order-blind values, so a node annotated by a non-batched objective (or not annotated at all) rides along inert.

Public Members

container::svector<std::pair<Index, BatchModeType>> axes = {}

Batchable indices sliced at this node, each tagged with its BatchModeType (see EvalExpr::node_slice_mask).

container::svector<std::pair<Index, BatchModeType>> opened_here = {}

Subset of axes for which this node is the loop-open site (the outermost node at which the physical batch loop over the index is introduced), as opposed to a deeper node that merely carries the sliced mode. An external batch loop opens once, at the term root (an external mode is on the final result, so the root is its outermost carrier); a contracted batch loop opens at its (unique) contraction node. Distinguished from axes so a consumer that needs the loop nest (peak_profile's ectx) counts each physical loop once instead of once-per-carrying-node. Default empty (off path and every non-open node). See EvalExpr::batch_loops_opened_here.

std::size_t effective_count = 1

Effective use count; see the class doc.

bool order_aware = false

True iff the order-aware cost model emitted this node (set for every node on the order-aware path, including a whole-nest invariant whose residency union is empty). The per-level placement order-aware gate: a positive signal an empty union cannot provide, distinguishing an off-path all-full node (do not hoist) from an order-aware whole-nest invariant (hoist to the run/term-scope root). Default false leaves the off path unhoisted. See EvalExpr::batch_order_aware.