Skip to main content

TiGrIS - Tiled Graph Inference Scheduler for edge ML deployment

Project description

TiGrIS

License PyPI Docs

Tiled Graph Inference Scheduler. An ahead-of-time compiler that tiles ML models to fit embedded devices with hard memory budgets.

Give it an ONNX model and a memory budget. It partitions the compute graph into stages, tiles spatial operations, and emits a flat binary plan that the tigris-runtime executes with zero dynamic allocation.

The problem

On an embedded device with a few hundred KB of SRAM, most interesting models simply don't fit. The usual answer is to shrink the model: quantize harder, prune, pick a smaller architecture, and hope the accuracy hit is acceptable.

TiGrIS takes the other approach. It keeps the model you trained and rearranges the computation so that only a small working set lives in SRAM at any moment. Weights and intermediate spills go to flash or PSRAM. What comes out is a binary plan that the runtime executes as a flat sequence of kernel calls, with no interpreter, no tensor allocator, and no dynamic memory at all.

Quick start

pip install tigris-ml

# Will this model fit in 256KB SRAM + 16MB flash?
tigris analyze mobilenetv2.onnx -m 256K -f 16M
╭──────────────────────── TiGrIS - mobilenetv2 ────────────────────────╮
│ Operators            65                                              │
│ Peak memory (naive)  4.59 MiB                                        │
│ Largest tensor       1x96x112x112 (4.59 MiB)                         │
╰──────────────────────────────────────────────────────────────────────╯
╭──────────────────────────────── SRAM ────────────────────────────────╮
│ Budget              256.00 KiB                                       │
│ Scheduled peak      254.62 KiB (5.4% of naive peak)                  │
│ Stages              42                                               │
│ Need tiling         31 of 42 stages                                  │
╰────────────────  PASS - tiling resolves all stages  ─────────────────╯

The naive peak is 4.59 MiB. TiGrIS schedules it into 256 KiB through temporal partitioning and spatial tiling. analyze runs on your laptop; no hardware required.

From ONNX to embedded

Three steps take a model from ONNX to a C file you can drop into your firmware project:

# 1. Analyze feasibility against a memory budget
tigris analyze model.onnx -m 256K -f 16M

# 2. Compile to a binary plan (weights read-in-place from flash)
tigris compile model.onnx -m 256K -f 16M --xip -o model.tgrs

# 3. Generate a backend-specific C harness for your target
tigris codegen model.tgrs --backend esp-nn -o model.c

The .tgrs plan is target-agnostic: it is the same file whether you run it on an ESP32, a Cortex-M, or a POSIX host for testing. The choice of kernel backend happens at codegen time and decides which kernel library the generated C calls into.

Several kernel backends are available (portable C99, ESP32 family, Cortex-M family); see tigris-runtime for the current list. Switching between them is a --backend flag, not a rewrite.

What you get

tigris compile writes a single .tgrs file that contains the operator schedule, tile parameters, quantization tables, and the weights. This file goes on flash at deployment time.

tigris codegen produces a small C harness that locates the plan on flash at runtime and hands it to the runtime:

  • declarations for the input/output buffers and the arena
  • a target entry point (app_main() for ESP-IDF, main() for POSIX/Cortex-M examples) that sets up memory and calls the runtime
  • backend-specific glue for finding the plan: partition mmap on ESP-IDF, an extern flash symbol on Cortex-M, a file path on POSIX

Link the harness against tigris-runtime and your chosen kernel library, flash the .tgrs alongside the firmware, and you have a working inference binary.

Further reading

Development

git clone https://github.com/raws-labs/tigris
cd tigris
pip install -e ".[dev]"
pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tigris_ml-0.3.1.tar.gz (80.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tigris_ml-0.3.1-py3-none-any.whl (66.1 kB view details)

Uploaded Python 3

File details

Details for the file tigris_ml-0.3.1.tar.gz.

File metadata

  • Download URL: tigris_ml-0.3.1.tar.gz
  • Upload date:
  • Size: 80.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tigris_ml-0.3.1.tar.gz
Algorithm Hash digest
SHA256 9b5ac4c2d20915ae60a19ce3f37564da97652b44a41d1bba470707886953a6da
MD5 b7eec4b85dce5bf06ba27b6493c5fb3f
BLAKE2b-256 d8d3a0225faa29adc118557d49ad7b72a24670f15be406e3c1a2b3eeb0d9a301

See more details on using hashes here.

Provenance

The following attestation bundles were made for tigris_ml-0.3.1.tar.gz:

Publisher: publish.yml on raws-labs/tigris

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tigris_ml-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: tigris_ml-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 66.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tigris_ml-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3fdc5564f42d9f358d981cd8d9ece424062ee5c597d5164f7d9808862083802d
MD5 ea0d0837914b6e47d9a6605230b13384
BLAKE2b-256 1b81bcb37f1ca6f54ad43c1c390af8ae42d231d92c28a4cbc2f9c51562c96994

See more details on using hashes here.

Provenance

The following attestation bundles were made for tigris_ml-0.3.1-py3-none-any.whl:

Publisher: publish.yml on raws-labs/tigris

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page