pub struct ProgramSpec {
pub name: String,
pub src: String,
pub device: DeviceSpec,
pub ast: Arc<UOp>,
pub global_size: Option<[usize; 3]>,
pub local_size: Option<[usize; 3]>,
pub vars: Vec<Variable>,
pub var_names: Vec<String>,
pub globals: Vec<usize>,
pub outs: Vec<usize>,
pub ins: Vec<usize>,
pub buf_count: usize,
}Expand description
Program specification containing source code and metadata.
This is returned by Renderer::render() and consumed by Compiler::compile(). It bridges the gap between UOp graphs and compiled executables.
§Tinygrad Alignment
Buffer metadata (globals, outs, ins) matches Tinygrad’s Program class:
globals: Buffer indices from PARAM opsouts: Output buffer indices (written by STORE ops)ins: Input buffer indices (read by LOAD ops)
Fields§
§name: StringKernel name (for debugging/profiling)
src: StringGenerated source code (LLVM IR, CUDA C, Metal, WGSL, etc.)
device: DeviceSpecDevice specification
ast: Arc<UOp>Original AST (for cache key construction via hash consing)
global_size: Option<[usize; 3]>Global work size (for GPU backends, None for CPU)
local_size: Option<[usize; 3]>Local work size (for GPU backends, None for CPU)
vars: Vec<Variable>Variable list (for symbolic shapes/strides)
var_names: Vec<String>Variable names in order for populating vars array at runtime. Includes thread_id at the end if threading is enabled.
globals: Vec<usize>Global buffer indices (from PARAM slot values).
Matches Tinygrad’s globals field.
outs: Vec<usize>Output buffer indices (written by STORE ops).
Matches Tinygrad’s outs field.
ins: Vec<usize>Input buffer indices (read by LOAD ops, excluding outputs).
Matches Tinygrad’s ins field.
buf_count: usizeNumber of buffer arguments (for CIF construction at compile time).
Implementations§
Source§impl ProgramSpec
impl ProgramSpec
Sourcepub fn new(name: String, src: String, device: DeviceSpec, ast: Arc<UOp>) -> Self
pub fn new(name: String, src: String, device: DeviceSpec, ast: Arc<UOp>) -> Self
Create a new program specification.
Sourcepub fn set_work_sizes(&mut self, global: [usize; 3], local: [usize; 3])
pub fn set_work_sizes(&mut self, global: [usize; 3], local: [usize; 3])
Set work sizes for GPU execution.
Sourcepub fn set_var_names(&mut self, var_names: Vec<String>)
pub fn set_var_names(&mut self, var_names: Vec<String>)
Set variable names for populating vars array at runtime.
Trait Implementations§
Source§impl Clone for ProgramSpec
impl Clone for ProgramSpec
Source§fn clone(&self) -> ProgramSpec
fn clone(&self) -> ProgramSpec
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more