Skip to main content

optimize_kernel

Function optimize_kernel 

Source
pub fn optimize_kernel(ast: Arc<UOp>, renderer: &Renderer) -> Arc<UOp>
Expand description

Apply optimizations to a kernel AST.

This is the main entry point for optimization in the tensor pipeline. Uses environment variables for configuration (see OptimizerConfig::from_env).

§Pipeline

  1. Symbolic simplification - Constant folding, identities, DCE
  2. Loop→Global conversion - Enable GPU parallelization
  3. Hand-coded heuristics - Vectorization, unrolling, tiling

§Arguments

  • ast - The kernel AST (inner AST from KERNEL op)
  • renderer - Backend capabilities descriptor

§Returns

Optimized AST with transformations applied.

§Environment Variables

  • MOROK_NOOPT=1 - Disable all optimizations (for debugging)
  • MOROK_BEAM=N - Use beam search with width N (future)