std1.0.0-beta-7 SafeC docs

std :: ml::device_webgpu

Struct std::WebGpuBackend

#include <std/ml/device_webgpu.h> source

struct WebGpuBackend { }

Handles are byte offsets into the backend's one device heap (never 0), with device.h's element-type tag in the top bits.

Methods

§static int available()source · definition
§static unsigned long alloc(unsigned long bytes)source · definition
§static void release(unsigned long handle)source · definition

No wait: the queue runs in order, so work that still reads the block runs before anything a new owner queues.

§static int upload(unsigned long dst, const &float src, unsigned long n)source · definition
§static int download(&float dst, unsigned long src, unsigned long n)source · definition
§static int copy(unsigned long dst, unsigned long src, unsigned long n)source · definition

n 32-bit words, bit-exact (wk_copy: WebGPU copies within one buffer only through a kernel)

§static int sync()source · definition
§static int gemm( int ta, int tb, unsigned long m, unsigned long n, unsigned long k, float alpha, unsigned long a, unsigned long lda, unsigned long b, unsigned long ldb, float beta, unsigned long c, unsigned long ldc, )source · definition
§static int gemm_batched(const &DevGemm g)source · definition
§static int conv(const &DevConv c)source · definition

Convolutions as implicit GEMMs (device_kernels.wgsl's wk_conv): the forward pass, the input gradient as a gather over the windows (no atomics), the weight gradient split over batch x pixels and added atomically into zeroed weights (fp32 only: a 16-bit one declines and device.sc runs it in fp32). A transposed convolution is the plain one with input and output swapped, so its forward pass is the input-gradient kernel and its input gradient the forward one; the input gradient runs a grid slice per stride phase, as Metal's does. The tile, by the product's rows (output channels, or input channels for the input gradient): 64 x 64 from 48, 32 x 128 from 17, 16 x 256 below.

§static int storage16()source · definition
§static int launch(int kernel, unsigned long n, const &DevArgs args)source · definition
§static unsigned long offset(unsigned long handle, unsigned long bytes)source · definition
§static int map( int op, unsigned long a, unsigned long b, unsigned long out, unsigned long n, )source · definition

gpu_webgpu.h's elementwise ops without a DK_* kernel (device_kernels.wgsl's wk_map): out = a / b (op 0), pow(a, b) (1), sqrt(a) (2) over n elements