Skip to main content

Module shader

Module shader 

Source
Expand description

WGSL shader source generation for common compute kernels.

Each function returns a complete, self-contained WGSL source string suitable for passing to device.create_shader_module().

Functionsยง

attention_wgsl
Generate a WGSL compute shader for scaled dot-product attention.
batched_gemm_wgsl
Generate WGSL source for a batched (strided) GEMM kernel.
binary_wgsl
Generate WGSL source for an element-wise binary operation.
conv2d_wgsl
Generate a WGSL compute shader for 2D convolution in NCHW format.
elementwise_wgsl
Generate WGSL source for an element-wise unary operation.
gemm_wgsl
Generate WGSL source for a tiled GEMM kernel: C = alpha * A * B + beta * C.
gemm_wgsl_f16
Generate WGSL source for a tiled GEMM kernel using FP16 storage.
reduction_final_wgsl
Generate WGSL for the final scalar reduction of partial sums.
reduction_wgsl
Generate WGSL source for a parallel workgroup-level reduction.