Skip to main content

Module backend

Module backend 

Source
Expand description

Backend trait — abstraction over CPU/GPU/CUDA execution.

Each backend implements Backend::compile(graph, &CompileOptions) and returns an ExecutableGraph. New compile knobs go in CompileOptions rather than as new trait methods.

Modules§

cpu_backend
wgpu_backend

Traits§

Backend
Backend implementation trait.
ExecutableGraph
A compiled, ready-to-execute graph on a specific backend.

Functions§

compile
Compile at default options (F32, no policy).
compile_hir
Compile HIR through the fusion-first pipeline.
compile_module
Compile a GraphModule through the fusion-first pipeline.
compile_with_precision
Compile at a specific precision (default policy = none).
narrow_f32_to_bytes
Narrow a &[f32] buffer down to the declared output dtype, returning the corresponding little-endian byte stream. Mirrors the bytes a backend that stores the native dtype would emit. Used by run_typed to keep the byte-level output contract identical across backends.
widen_bytes_to_f32
Widen (or, for F64, narrow) a typed byte buffer to Vec<f32>. Used by set_param_typed / run_typed overrides on backends whose internal arena is f32-uniform (Vulkan / wgpu / CUDA / ROCm / oneAPI / TPU) so callers can hand in F16/BF16/F64 without doing the host-side cast themselves. F64 is narrowed to f32 to match the f32-uniform arena slot (SPD-manifold ops re-widen to f64 inside their CPU host-fallback, so the eigendecomposition itself stays f64). Panics on dtypes the f32 arena can’t carry.