Skip to main content

Module relations

Module relations 

Source
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§

CustomRelationCtx
Context passed to a Custom relation’s run function. 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.
RelationResult
Outcome of running a relation against the solver’s current type nodes. The solver’s worklist treats each variant differently: Refined requeues dependents, Satisfied removes the relation, Defer parks it for later, Failed aborts the solve.
TypeRelation
One type relation declared on an op. The TypeSolver instantiates each as a constraint node linked to its participating type variables via back-edges.