Expand description
Type relations on ops.
Every op declares its type contract via composable
TypeRelations — a small set of high-coverage predicates
(SameElementType, Elementwise, BroadcastShape,
ReduceOver) plus a Custom escape hatch. The compiler’s
TypeSolver walks the graph, instantiates each relation as a
constraint node, and resolves every value’s TypeNode via a
bipartite worklist (TVM Relay shape).
Coverage strategy: a library of trait predicates (MLIR pattern)
handles ~90% of ops. The remaining ~10% (Reshape, Gather, Concat,
anything with structural type effects) use Custom. Adding a
new op = declaring its type_relations in atomic_opset().
Structs§
- Custom
Relation Ctx - Context passed to a
Customrelation’srunfunction. Borrows from the solver; exposes a read-only view of each participating port’s current type resolution. Concrete shape lands when the TypeSolver (T4) materializes.
Enums§
- PortRef
- Reference to a port position on an op’s input/output list.
Indices into
AtomicOpDecl.inputs/outputs. - Relation
Result - Outcome of running a relation against the solver’s current type
nodes. The solver’s worklist treats each variant differently:
Refinedrequeues dependents,Satisfiedremoves the relation,Deferparks it for later,Failedaborts the solve. - Type
Relation - One type relation declared on an op. The TypeSolver instantiates each as a constraint node linked to its participating type variables via back-edges.