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 DefineGlobal 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 DefineGlobal argument 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>,
) -> ProgramSpec
pub fn new( name: String, src: String, device: DeviceSpec, ast: Arc<UOp>, ) -> ProgramSpec
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 moreAuto Trait Implementations§
impl Freeze for ProgramSpec
impl !RefUnwindSafe for ProgramSpec
impl Send for ProgramSpec
impl Sync for ProgramSpec
impl Unpin for ProgramSpec
impl UnsafeUnpin for ProgramSpec
impl !UnwindSafe for ProgramSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more