Define
Tensor calls define shapes and operations. TypeNN records each call as a graph node.
tensor.matmul(weight).relu()A TypeScript neural network framework
Use Tensor operations and Module classes to define models. TypeNN records those operations in a deferred graph; TypeShade compiles and runs their kernels 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 outputExecution
Tensor calls define shapes and operations. TypeNN records each call as a graph node.
tensor.matmul(weight).relu()Each node holds a TypeShade kernel function. When you call data(), TypeNN runs the function with that node's input and output arrays.
TypeShade kernelWhen needed, data() runs the kernels for the requested result on the selected tier.
CPU · WebGPU · WebGL2** WebGL2 and the CPU tier run the same kernel functions apart. Only WebGPU fuses an elementwise chain into one dispatch.
Try TypeNN
Run matrix operations in the browser, then read the guides to learn about graph execution, automatic differentiation, and model training.