Module Tolk_uop
Hash-consed DAG IR for the tolk compiler.
This module aggregates the uop layer: a single hash-consed node type (Uop.t) that flows through every stage of the pipeline — tensor graph, kernel AST, and linearized program — together with its operation tags, pattern DSL, stage specifications, and symbolic simplifier.
Structurally equal nodes are physically identical. Stage membership is not encoded in the type system; it is enforced by Spec validators at pass boundaries.
Usage
Open this module to bring every submodule into scope:
open Tolk_uop
let x = Uop.const_int 5
let sum = Uop.alu_binary ~op:Ops.Add ~lhs:x ~rhs:(Uop.const_int 7)
let pat =
Upat.op ~src:[Upat.var "x"; Upat.const_int 0] Ops.AddModules
Core
Uop— the hash-consed node type, its smart constructors, view accessors, traversal, and rewrite engine.Ops— the flat enumeration of operation tags. Declaration order is part of the public contract (drives commutative canonicalisation and toposort stability).Render— tinygrad-shaped graph listings for debugging and golden tests.
Primitives
Dtype— value and pointer data types, promotion lattice, and float/integer truncation.Const— typed compile-time constants.Axis_type— classification of kernel loop axes (global, local, reduce, unroll, …) used during scheduling.
Patterns and rewriting
Upat— pattern DSL and matcher for writing rewrite rules overUop.t.Validate— deterministic memory-access validation used bySpec.Spec— stage specifications used to validate that a DAG is well-formed at a given pipeline stage.Symbolic— algebraic simplification rules wired intoUop.simplify.
module Ops : sig ... endUOp operation tags.
module Axis_type : sig ... endKernel loop axis classification.
module Dtype : sig ... endData types for tensor computations.
module Const : sig ... endTyped compile-time constants.
module Uop : sig ... endUnified hash-consed DAG IR.
module Render : sig ... endTinygrad-shaped UOp graph rendering.
module Validate : sig ... endMemory access validation for UOp specs.
module Divandmod : sig ... endInteger division and modulo simplification.