pub struct PatternMatch {
pub bindings: Vec<(usize, NodeId)>,
pub params: FusedOpParams,
}Expand description
Result of a successful pattern match. Carries the bindings — the
concrete NodeIds that the pattern’s variables matched against in
the host graph — plus the FusedOpParams payload the fusion rule
should stamp onto the emitted Op::Fused(id, params) node.
bindings is index-keyed: bindings sorted by index become the
fused-op node’s input list (inputs[0] ← index 0, inputs[1] ←
index 1, …). SoftmaxLastDim’s match has one binding (0, x_id)
and so emits a single-input node; FusedLinear (3 inputs:
[a, b, bias]) emits three bindings indexed 0–2.
params is the matcher’s authority on the resulting fused-op’s
per-instance parameters. The matcher knows what variant of
FusedOpParams it’s recognizing; carrying that decision in the
match result keeps crate::opt::FusionRule::rewrite generic
across all registered fused ops.
Fields§
§bindings: Vec<(usize, NodeId)>Variable-id → resolved NodeId. The fusion rule sorts by index and uses the resolved ids in order as the emitted node’s inputs.
params: FusedOpParamsPer-instance parameters the matcher stamps onto the fused-op node it produces. Parameterless ops (SoftmaxLastDim, FusedLinear) stamp their unit variant; parameterized ops (RmsNormLastDim, FlashAttn) recover their payload from the matched subgraph.