Start here
Get started
Create a device, describe work with Tensor operations, then materialize the value you need.
Project status
TypeNN is pre-release. The npm package metadata still describes a placeholder package. Check the repository source and examples for current usage until the package is ready for release.
Run your first operation
device() selects WebGPU when available and falls back to the TypeShade CPU tier. You can request "cpu", "webgpu", or "webgl2" explicitly. With WebGL2, TypeNN uses the CPU tier for calls it cannot run.
import * as nn from "typenn";
const device = await nn.device({ device: "auto" });
const a = device.tensor([1, 2, 3, 4], { shape: [2, 2] });
const b = device.tensor([5, 6, 7, 8], { shape: [2, 2] });
const y = a.matmul(b).relu();
const values = await y.data();
console.log(values);
await y.disposeGraph();
await device.dispose();Understand when work runs
Tensor methods construct a deferred graph. They do not immediately read values back to JavaScript. Calling data() executes the reachable graph and returns a Float32Array to the host.
Keep the graph alive until execution finishes.After you consume the result, call
disposeGraph() to release intermediate tensors. Dispose the Device when its work is finished.