Module Tolk.Program_spec
Compile-time kernel descriptions extracted from a linearized uop program.
A t is the runtime-facing description of a lowered kernel before device-specific preparation. It captures the lowered program, kernel name, launch metadata, scalar variables, buffer reads and writes, and cost estimates.
Types
type program = Tolk_uop.Uop.t listThe linearized uop program produced by the linearizer.
type var = {name : string;(*Variable name matching the IR definition.
*)lo : int;(*Inclusive lower bound.
*)hi : int;(*Inclusive upper bound.
*)dtype : Tolk_uop.Dtype.t;(*Scalar data type.
*)
}Bounded scalar Tolk_uop.Uop.Param_arg kernel parameter.
Runtime-managed "core_id" variable for multi-core dispatch.
val thread_count : core_id -> intthread_count cid is cid.hi - cid.lo + 1.
Cost estimates
module Estimates : sig ... endKernel specifications
val of_program :
name:string ->
src:string ->
device:string ->
?lib:bytes ->
?applied_opts:Tolk_uop.Uop.Opt.t list ->
?estimates:Estimates.t ->
?aux:string list ->
program ->
tof_program ~name ~src ~device ?lib ?applied_opts ?estimates ?aux program extracts a kernel description from program. If estimates is omitted, estimates are computed from program. aux is copied to Tolk_uop.Uop.program_info.
val with_estimates : Estimates.t -> t -> twith_estimates e spec is spec with estimates replaced by e.
with_global_dims dims spec is spec with the global launch dimensions replaced by constant values dims.
val name : t -> stringval src : t -> stringval device : t -> stringval lib : t -> bytes optionval applied_opts : t -> Tolk_uop.Uop.Opt.t listval outs : t -> int listval ins : t -> int listval globals : t -> int listval launch_kind : t -> launch_kindval estimates : t -> Estimates.tval global_size : t -> Tolk_uop.Uop.t arrayval local_size : t -> Tolk_uop.Uop.t array optionval program_info : t -> Tolk_uop.Uop.program_infoprogram_info spec is the tinygrad-shaped program metadata carried by spec. Symbolic global dimensions are preserved as launch expressions; local dimensions are present only when all local dimensions are fixed integers, and backend auxiliary metadata is preserved.
val launch_dims : t -> (string * int) list -> int array * int array optionlaunch_dims spec var_vals evaluates launch dimensions by replacing symbolic variables with the values in var_vals.