Skip to main content

Module jit

Module jit 

Source
Expand description

Kernel-seam JIT — the Fuel-side projection + structural matcher (kernel-seam-interop §5; fkc-fusion-patterns §3/§3a). The frozen grammar types (OpTag, OpAttrs, PatternNode) live in fuel_kernel_seam_types and are re-exported here; this module holds the two parts that need the graph: the Op -> OpTag projection op_to_tag and the structural matcher match_region (the declarative-fusion engine behind PatternKind::Declarative).

One PatternNode serves the JIT region (Fuel -> synthesizer, “build a kernel for this subgraph”), a contract’s pattern: re-fuse rule, and a synthesized op’s decompose (the region re-emitted).

Structs§

OpAttrs
Non-tensor attributes a PatternNode::Op carries (fkc-fusion-patterns §3a.4; Baracuda reconcile §2). For scalar-param ops the value is not baked — it identifies the slot the emitted extract: path points at, and the matcher re-reads the live value from the matched graph node at match time. Carries the load-bearing attributes the general vocabulary needs.

Enums§

OpTag
The §4.1 graph-Op vocabulary, functional ops only — the stable op identifier a PatternNode carries. Excludes in-place variants (a region is the functional subgraph; in-place is a Fuel-side scheduling rewrite) and structural / bookkeeping ops (Const, Release, Alloc, views, …). The Op -> OpTag projection (op_to_tag) lives Fuel-side (it needs the graph Op); the inverse — which params an emitted op carries — rides OpAttrs + the extract: path.
PatternNode
A node of the §3 declarative subgraph grammar. One type, two directions: a region (Fuel -> synthesizer) populates Op { op, operands, attrs } + Bind; an emitted pattern: (synthesizer -> Fuel) additionally carries the consumer/extract routing the matcher compiler reads. SeeThrough/Any are matcher-only and never appear in a concrete region.

Functions§

match_region
Match a declarative region PatternNode against the graph rooted at root (the subgraph sink, §3a.1). Returns the region’s external inputs in bind-index order on a match, or None. This is the structural core of the declarative matcher (PatternKind::Declarative); the §5 guard:/extract: layers and the see_through-set wrappers compose on top.
match_region_extract
match_region plus the extract: layer (FKC §5.3): alongside the bound inputs, return the matched region’s live scalar values — one entry per scalar a slot pattern node left open (a scalar-carrying op whose pattern attrs.scalars is empty/wildcard), read from the matched graph node, in pattern pre-order (the canonical slot order the recipe’s re-emit and a synthesized kernel’s trailing p{i} launch args both use). A pattern node with baked scalars is a constant of the pattern (the attr guard enforced equality), not a slot, and extracts nothing. A slotless region extracts [].
op_to_tag
Project a graph Op to its functional OpTag. Returns None for in-place variants, structural/bookkeeping ops, and Op::Fused (a fused op isn’t a region node — its decomposition is). Same for Op::Scan / Op::ScanPlaceholder: a scan isn’t a region node either — its body (referenced via inputs, not a PatternNode) is what a region walk would see. A None op in a region is an honest “outside the vocabulary” miss, never a crash.