API Overview
Complete API reference for Tiny-DL-Inference.
Core Modules
| Module | Description |
|---|---|
| GPUContext | WebGPU device and resource management |
| Tensor | GPU tensor with shape and layout |
| Operators | Neural network operators |
| Engine | High-level inference engine |
| Utilities | Helper functions and benchmark tools |
Quick Reference
Import
typescript
import {
GPUContext,
Tensor,
InferenceEngine,
ModelLoader,
Conv2dOperator,
MaxPoolOperator,
ReLUOperator,
SoftmaxOperator,
DenseOperator,
FlattenOperator,
Conv2dBiasReLUOperator,
Benchmark
} from 'tiny-dl-inference';1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
Basic Usage
typescript
// Initialize engine
const engine = new InferenceEngine();
await engine.initialize();
// Create input
const input = engine.tensorFromArray(data, [1, 3, 224, 224]);
// Load and run
await engine.loadModel(modelDef);
const output = await engine.infer(input);
const result = await output.download();
// Cleanup
engine.destroy();1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
Type Definitions
Core Types
typescript
type TensorShape = number[];
type DataLayout = 'NCHW' | 'NHWC';
interface OperatorParams {
[key: string]: number | number[] | boolean | string | undefined;
}1
2
3
4
5
6
2
3
4
5
6
Error Types
| Error | When to Use |
|---|---|
WebGPUNotSupportedError | Browser lacks WebGPU |
DeviceInitializationError | GPU init failure |
InvalidShapeError | Tensor shape mismatch |
BufferSizeError | Buffer/data size mismatch |
Version
Current Version: 2.0.1
See Changelog for version history.