Documentation
¶
Overview ¶
Package webgpu is a wasi-nn backend that runs ONNX graphs on the browser's GPU through WebGPU (WGSL compute kernels), for the "gpu" execution target. It runs where the engine's WASI host runs in the browser: the playground's engine worker.
The graph is laid out by onnx.Session.Plan (shapes from a CPU dry run, constants folded), then each node is one kernel dispatch. A fallback (software) adapter is refused: GPU work is never claimed from a CPU.
Index ¶
Constants ¶
const MaxRank = 8
MaxRank is the largest tensor rank the kernels index.
const MaxSpatial = 3
MaxSpatial is the largest number of spatial axes of Conv and pooling.
Variables ¶
var Supported = []string{"Add", "AveragePool", "Concat", "Constant", "Conv", "Div", "Dropout", "Flatten",
"Gemm", "Identity", "MatMul", "MaxPool", "Mul", "Relu", "Reshape", "Softmax", "Sub", "Transpose"}
Supported lists the operators with a GPU kernel (or a copy-free rewrite); it equals onnx.Supported, checked by a test.
Functions ¶
Types ¶
type Backend ¶
type Backend struct {
Limits onnx.Limits
// MemoryBytes is each graph's GPU memory quota (default 256 MiB).
MemoryBytes int64
// AllowFallback accepts a software adapter; off by default, since its
// work is not GPU work.
AllowFallback bool
}
Backend is the wasi-nn "gpu" backend for ONNX graphs. Its calls block on WebGPU promises, so nn runs them off the host call (Async).