NumPy for the browser GPU — zero shaders, zero dependencies.
WebGPU · WebGL2 · CPU fallbacknpm install accel-gpu
const gpu = await init();
const gpu = await init({ forceCPU: true }); // Force CPU for testing
const gpu = await init({ forceWebGL: true }); // WebGL2
const gpu = await init({ profiling: true }); // Enable profiling
import { init, matmul, softmax } from "accel-gpu";
const gpu = await init();
const a = gpu.array([1, 2, 3, 4]);
const b = gpu.array([5, 6, 7, 8]);
await a.add(b);
console.log(await a.toArray()); // [6, 8, 10, 12]
No M, N, K — inferred from array shapes
add, mul return Promises for chaining
softmax, layerNorm, batchNorm, attentionScores
fft, ifft, spectrogram
conv2d, maxPool2d, avgPool2d
Safari, Firefox, Node, headless
const A = gpu.array(new Float32Array([1,2,3,4,5,6]), [2, 3]);
const B = gpu.array(new Float32Array([1,2,3,4,5,6]), [3, 2]);
const C = await matmul(gpu, A, B);
Await each step — add/mul return Promises.
const x = gpu.array([1, 2, 3, 4]);
await (await x.add(1)).mul(2);
console.log(await x.toArray()); // [4, 6, 8, 10]
const probs = await softmax(gpu, logits);
const normed = await layerNorm(gpu, x, gamma, beta);
const scores = await attentionScores(gpu, Q, K);
const spec = await spectrogram(gpu, signal, 256, 128);
const invA = await inv(gpu, A);
const d = await det(gpu, A);
const x = await solve(gpu, A, b);