Skip to main content

Crate svod_codegen

Crate svod_codegen 

Source
Expand description

Code generation for svod tensor operations.

This crate provides backend-agnostic code generation infrastructure for converting optimized UOp graphs into executable code.

§Architecture

  • Traits: Backend-agnostic interfaces (Renderer)
  • LLVM: LLVM IR code generation for CPU execution
  • Future: CUDA, Metal, OpenCL renderers

§Usage

use svod_codegen::{llvm, program_pipeline};

let linear = svod_ir::UOp::linear(svod_schedule::linearize_with_cfg(optimized_uop_graph).into());
let kernel = llvm::text::render(&linear, Some("kernel"))?;
// Canonical staged flow: PROGRAM -> LINEAR -> SOURCE -> BINARY.
// See `program_pipeline` for the strict staged entrypoints.

§Pre-render invariants

Direct callers of Renderer::render (and the per-backend render free functions) must pass a LINEAR-stage UOp produced by svod_schedule::linearize::line_rewrite_cleanups. The cleanup pass lowers gated LOADs into IF/STORE/ENDIF and provides the alt value that per-backend op handlers rely on; backends report Error::InvalidGraph if these invariants are violated. The staged entrypoints in program_pipeline run the cleanup pass automatically.

Re-exports§

pub use common::collect_buffers_and_vars;
pub use error::*;
pub use traits::*;
pub use types::*;

Modules§

c
C source code generation backend.
common
Common utilities shared between codegen backends.
error
Error types for code generation.
llvm
LLVM IR code generation.
program_pipeline
traits
Core traits for code generation.
types
Types for code generation.