---
title: "Get started with TypeNN"
description: "Create a device, build a Tensor graph, run an operation, and read the result."
url: https://nn.typeshade.dev/guide/
language: en
---

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.

[Open the TypeNN repository ↗](https://github.com/typeshade/typenn)

## 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.

MatMul followed by ReLU first-operation.ts

```ts
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.

## Continue with a guide

[**Execution model** See which kernels run for a Tensor when you call `data()`. **→**](https://nn.typeshade.dev/guide/execution/) [**Train a model** Define a Module and update its parameters with an optimizer. **→**](https://nn.typeshade.dev/guide/training/) [**Try the Playground** Run operations without setting up a project. **→**](https://nn.typeshade.dev/playground/)
