Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Morok

⚠️ Pre-alpha software. APIs are unstable and may change without notice. Not recommended for production use. 🚧💀

Morok is a Rust-based ML compiler inspired by Tinygrad. It features lazy tensor evaluation with UOp-based IR, pattern-driven optimization, and multi-backend code generation.

Highlights

FeatureDescription
Declarative Optimizationpatterns! DSL for graph rewrites with Z3-verified correctness
Lazy EvaluationTensors build computation graphs, compiled only at realize()
CUDA SupportUnified memory, D2D copy, LRU buffer caching
Provenance Tracking#[track_caller] traces every UOp to source location
80+ IR OperationsArithmetic, memory, control flow, WMMA tensor cores
20+ OptimizationsConstant folding, tensor cores, vectorization, loop unrolling

Quick Example

#![allow(unused)]
fn main() {
use morok_tensor::Tensor;

// Build lazy computation graph
let a = Tensor::from_slice(&[1.0, 2.0, 3.0], &[3])?;
let b = Tensor::from_slice(&[4.0, 5.0, 6.0], &[3])?;
let c = (a + b).sum();

// Compile and execute
let result = c.realize()?;
}

License

MIT