Skip to main content

Crate handwired_rs_gpu

Crate handwired_rs_gpu 

Source
Expand description

Run handwired circuits as WebGPU compute shaders.

A program becomes WGSL compute shaders that evaluate one record per invocation, so a batch of records, e.g. 100,000 documents to score, runs in parallel. A long program is split into stages that run one after another (see wgsl). The shaders reproduce the CPU reference evaluator’s values bit for bit, within the limits in wgsl’s documentation.

let gpu = handwired_rs_gpu::Gpu::new().unwrap();
let batch = handwired_rs_gpu::GpuBatch::new(&gpu, &pick_circuit()).unwrap();
let results = batch.run(&gpu, &[(1,), (5,), (200,)]).unwrap();
assert_eq!(results, vec![12, 10, 10]);

Modules§

wgsl
WGSL for a compiled tensor program: one compute invocation per record, one let per operation, in the executor’s order.

Structs§

Gpu
A GPU device and its queue.
GpuBatch
A #[handwired] function’s circuit on the GPU, run on typed arguments.
GpuProgram
A compiled program on the GPU: a pipeline per shader stage and the constant tables.

Enums§

GpuError