01
TypeNN Tensor API
Owns Shape and operation semantics, modules, loss functions, and Tensor graph gradient rules.
A neural network framework built on TypeShade
TypeNN builds deferred Tensor graphs from neural network operations. TypeShade compiles the operation kernels and runs them on CPU and GPU backends.
TypeScript · Tensor Graph · TypeShade Runtime
import * as nn from "typenn";
const device = await nn.device();
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();
console.log(await y.data());
// Float32Array [19, 22, 43, 50]Real TypeNN examples and kernel source
Execution model
Operation methods build a dependency graph. Requesting a result executes the graph needed for that value. On GPU, TypeNN records kernel dispatches in a TypeShade Frame and submits the frame.
Tensor API and execution notes01
Owns Shape and operation semantics, modules, loss functions, and Tensor graph gradient rules.
02
TypeNN kernel sources compile to TypeShade programs and are dispatched to the selected device.
03
Automatic selection tries WebGPU, then falls back to CPU. WebGL2 is a constrained compute-lowering path.
A Frame can submit several dispatches together. That is distinct from kernel fusion. Graph-wide fusion is outside the current implementation.
Model training
The README's MNIST example shows a user-defined Module, Adam, CrossEntropyLoss, and Tensor-graph backward path. The repository example includes the MNIST data loader and evaluation loop.
MNIST example sourceCurrent scope
Includes rank-2 MatMul, elementwise arithmetic, activations, reductions, softmax, and logits-based cross entropy.
Operation and shape TODOTensor graph gradient rules cover selected operations. TypeShade shadeGrad is a separate API for pure TypeShade functions.
Autograd implementationIntermediate Tensors stay resident until disposed or the Device is disposed. disposeGraph() releases an operation graph while preserving parameters.
Runtime implementationThis page does not publish performance figures or GPU measurements. Any future measurements should include the execution environment and reproduction steps.