Define
Tensor calls describe shapes and operations. TypeNN records them as graph nodes.
tensor.matmul(weight).relu()A TypeScript neural network framework
TypeNN gives Tensor and Module code a deferred graph. TypeShade compiles its kernels and executes them on CPU and supported GPU backends.
Pre-release · source and examples are the current usage reference.
import * as nn from "typenn";
const device = await nn.device();
const input = device.tensor([1, 2, 3, 4], { shape: [2, 2] });
const weight = device.tensor([5, 6, 7, 8], { shape: [2, 2] });
const output = input.matmul(weight).relu();
console.log(await output.data());
// Float32Array [19, 22, 43, 50]
await output.disposeGraph();
await device.dispose();[19, 22, 43, 50]Example outputFrom TypeScript to execution
Tensor calls describe shapes and operations. TypeNN records them as graph nodes.
tensor.matmul(weight).relu()Each node holds a TypeShade kernel function that TypeNN calls on resident arrays.
Tensor graph → kernel functionsOne fuse scope runs the reachable kernels on the selected execution tier.
CPU · WebGPU · WebGL2** WebGL2 and the CPU tier run the same kernel functions apart. Only WebGPU fuses an elementwise chain into one dispatch.
Explore TypeNN
Try matrix operations in the browser, then follow the guide into graph execution, automatic differentiation, and model training.
Current implementation
Each data() runs as one TypeShade fuse scope, and device.lastReport shows its plan. Optimizers still update host arrays, so Adam is not a device kernel and tiled MatMul remains future work.