Expand description
Fuel’s independent typed shape-expression AST + §6.19 canonical wire codec +
evaluator (KISS-Ops §6.20). Byte-matches the KISS reference
(conformance/src/shape_expr.rs), verified against the vendored golden vectors —
the shape-side companion to the value oracle. EXPRESSION kind only (SameAs +
DimExpr); the role/index-woven kind (reduce/gather/matmul) is a separate variant
(Convergence-C C-2). Every malformed input is a typed decline, never a panic.
MOVED (Increment C slice 1, T1): the implementation now lives in
fuel_kernel_seam_types::shape_expr — its permanent, dependency-free home, so
fuel-graph can carry Dim/ShapeExpr in OpAttrs without depending on this
crate. This module is a re-export shim: every existing
crate::fkc::shape_expr::… path keeps compiling unchanged. The codec goldens
moved with it (see the seam-types test module). The text-surface parser
(shape_expr_parse) stays here — contract-import machinery, not grammar.
Enums§
- Dim
- A single-dimension expression (
DimExpr). - DimValue
- Evaluating a
DimExpr: a concrete dim, or a surfaced gap (§6.20-0004). - Shape
Expr - A whole-shape expression (
ShapeExpr). The closed core isSameAs;WithDimandDimsare the experimental-range extension constructors registered via the KISS umbrella §6.4 registry (Ops §6.20-0009/-0010, issue #80), activating the §6.20-0005 tags0x0A/0x0B.Reduce(0x09) stays reserved (no consumer). - Shape
Expr Error - A typed decline. A reader MUST refuse malformed input with one of these, never a panic (§6.20-0003/0006).
- Shape
Value - Evaluating a
ShapeExpr: a concrete shape, or a surfaced gap.
Constants§
- LAST
- Reserved
axissentinel = the trailing axis, resolved torank-1at eval (§6.20-0002/-0003). Concrete axes are0..MAX_RANK-1(MAX_RANK=8), so0xFFis unambiguouslylast. DISTINCT from §6.19-0020’s0xFFFE(u16 axis-set mask) — a different field, different width. - SYMBOLIC
- Sentinel extent for a symbolic / data-dependent axis length → surfaced Gap (§6.20-0004).
- TAG_ADD
- TAG_
CONST - TAG_
DIMS - TAG_DIV
- TAG_
EXTENT - TAG_MUL
- TAG_
PARAM - TAG_
REDUCE - TAG_
SAME_ AS - TAG_SUB
- TAG_
WITH_ DIM
Functions§
- decode_
dim - Decode one
DimExprblob, rejecting a malformed one with a typed decline. Round-trips:decode_dim(&d.encode()) == Ok(d). - decode_
shape - Decode one whole-shape
ShapeExprblob, rejecting a malformed one with a typed decline (§6.20-0006). ReadsSameAs(core) plus the registered experimental extension constructorsWithDim/Dims(§6.20-0009/-0010); the still-reservedReduce(0x09) and theDimExpr-only tags decline typed. A well-formed blob round-trips:decode_shape(&s.encode()) == Ok(s). Distinct fromdecode_dim, which reads the single-dimension grammar (aDimis never a whole shape, so a whole-shape tag declines there, and vice-versa). - eval_
dim - Evaluate a
DimExpragainst operand shapes + param values. - eval_
shape - Evaluate a
ShapeExprto a concrete shape (or a surfaced gap). - gather_
shape - §6.20-0008
gather/index_select/embeddingshape rule: the data shape with the gatheredaxisreplaced by the index shape (data[..axis] ++ index ++ data[axis+1..]). In general the output equals NO operand’s shape — which is why advertisingsame_as(data)for a gather is a bug the shape oracle catches. - matmul_
shape - §6.20-0008
matmul(contraction) shape rule: role-vector-derived (KISS-Classify §6.6-0016 M/N/K axis roles, carried as roles not a ShapeExpr). For the canonical same-rank ≥ 2 celllhs[..batch, M, K] · rhs[..batch, K, N] -> [..batch, M, N]; the output equals neither operand (§6.20-0008). - reduce_
shape - §6.20-0007
reduce-family shape rule: the input shape withreduce_axesremoved (keepdim=false) or set to1(keepdim=true) — derived from op semantics. - resolve_
axis - Resolve a non-negative
axis(orLAST) againstrank(§6.20-0003).pubsince Increment C slice 1 (T2): the recipe-interioraxis_lastresolver (fuel_graph::runtime_fused::resolve_rel_attrs) reuses this as the single LAST→rank−1evaluator instead of growing a second one. - shape_
consistent - KISS-CONTRACT-6.4-0011: the Interface
declaredoutput shape is consistent iff it equals the op’s shape rulecomputedover the operand shapes. A surfacedGap(symbolic/data-dependent output) is never a hard inconsistency — a consumer cannot assert a mismatch it cannot compute. The shape-side companion to the §6.4-0006 value oracle.