Guides

Execution model

TypeNN owns the Tensor graph and its meaning. TypeShade owns kernel compilation and program execution.

Tensor calls build a deferred graph

Operations such as matmul(), add(), and relu() create graph nodes with shape and operation metadata. This graph is separate from TypeShade Shader IR.

A small Tensor graphmodel.ts
const input = device.tensor(values, { shape: [batch, features] });
const logits = input.matmul(weights).add(bias);
const output = logits.relu();

// This is the materialization boundary.
const result = await output.data();

Materialization executes reachable work

When data() is requested, TypeNN traverses the dependency graph. The CPU tier evaluates compiled TypeShade programs. GPU execution prepares resident inputs, records program dispatches in a TypeShade Frame, submits the work, and reads back only the requested output.

TypeNN

Shape checks · graph nodes · autograd · execution order

TypeShade

Shader IR · backend programs · dispatch · runtime resources

Backends and limits

TierSelectionCurrent note
CPUAuto fallback or explicitTypeShade CPU tier; suitable for correctness and fallback.
WebGPUAuto or explicitNative GPU compute when the browser exposes an adapter.
WebGL2ExplicitConstrained compute lowering; performance depends on passes and device.

One active TypeNN Device is supported per JavaScript context because TypeShade call-layer configuration is process-global.

A Frame is not fusion

A Frame can collect multiple dispatches and submit them in order. The current Tensor executor still dispatches a kernel per graph node. It does not remove intermediate storage through general elementwise kernel fusion.

See graph optimization status ↗