Skip to content

Latest commit

History

64 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Mars Logo

Mars: Open-Source Neural Network Runtime for Ingenic T41

Hardware-accelerated inference on IP cameras using the MXUv3 SIMD unit and ORAM.

License: GPL v3

🚀 Performance

MetricBefore (Scalar)After (Mars)Speedup
Inference Time35 seconds1.75 seconds20x
Memory Read41 MB/s (DDR)314 MB/s (ORAM)7.6x
Memory Write77 MB/s (DDR)1578 MB/s (ORAM)20.6x

Overview

Mars is an open-source neural network runtime for the Ingenic T41 SoC, reverse-engineered from Ingenic's proprietary Venus SDK. It enables hardware-accelerated inference on IP cameras running Thingino firmware.

Why Mars?

  • 🔓 Open Source: No proprietary SDKs or closed toolchains
  • 🐧 musl Compatible: Works with Thingino's musl libc (Venus requires glibc)
  • Hardware Accelerated: Uses MXUv3 SIMD (512-bit) and on-chip ORAM
  • 🎯 Purpose-Built: Custom TinyDet model for security camera use cases

Features

  • ✅ MXUv3 SIMD acceleration (16 floats per instruction)
  • ✅ ORAM weight staging (640KB on-chip, 7.6x faster than DDR)
  • ✅ Conv2D, ReLU, MaxPool, Add, Concat operations
  • ✅ NHWC tensor format (optimized for T41 memory access)
  • ✅ Custom .mars model format
  • ✅ ONNX → Mars compiler (Python + Rust)

Quick Start

Building

# Set cross-compiler (adjust path to your toolchain)export CROSS_COMPILE=/path/to/mipsel-linux-
# Build runtime library and tools
make
# Output:# build/lib/libmars.so - Runtime library# build/bin/mars_detect - Detection CLI tool

Running on Device

# Copy to camera
scp build/bin/mars_detect build/lib/libmars.so root@camera:/opt/
# Run detection
ssh root@camera
cd /opt
LD_LIBRARY_PATH=/opt ./mars_detect model.mars input.jpg output.jpg

Compiling Models

cd mars-compiler
# Stage 1: ONNX → JSON + weights
python3 onnx2mars.py model.onnx -o model
# Stage 2: JSON → .mars binary
cargo run -- -i model.json -o model.mars --float32

Architecture

thingino-accel/
├── src/mars/ # Mars runtime (C)
│ ├── mars_runtime.c # Model loader and executor
│ ├── mxu_conv.c # MXUv3 convolution kernels
│ └── mars_nn_hw.c # Hardware initialization (ORAM, MXU)
├── mars-compiler/ # ONNX → Mars compiler
│ ├── onnx2mars.py # Python: ONNX → JSON extraction
│ └── src/ # Rust: JSON → .mars binary
├── training/ # TinyDet model training
│ ├── tinydet.py # Model architecture
│ └── train_*.py # Training scripts
├── include/ # Public headers
└── docs/ # Documentation
└── MARS_PROJECT_WRITEUP.md # Full research paper

TinyDet: Custom Detection Model

We trained a purpose-built 4-class detector optimized for security cameras:

ClassDescription
PersonHuman detection
VehicleCars, trucks
CatFeline pets
DogCanine pets

Model specs:

  • Input: 320×192 RGB (NHWC)
  • Parameters: ~202K
  • Architecture: Anchor-free, single-stage
  • Training: COCO + Oxford Pets datasets

Hardware Details

Ingenic T41 SoC

  • CPU: Dual XBurst2 @ 1.5GHz (MIPS)
  • MXUv3: 512-bit SIMD, 32 VPR registers
  • ORAM: 640KB @ 0x12640000 (on-chip SRAM)
  • NNA: Neural Network Accelerator with NNDMA

Memory Performance

RegionBandwidthLatency
DDR41 MB/s readHigh
ORAM314 MB/s readLow

Weights are staged to ORAM before convolution for maximum throughput.

Documentation

Comparison with Venus SDK

FeatureVenus (OEM)Mars
LicenseProprietaryGPLv3
C Libraryglibc onlymusl/glibc
Model Format.mgk (closed).mars (open)
Source CodeNoYes
CompilerClosedPython + Rust

Contributing

Contributions welcome! See the project writeup for technical background.

License

GPLv3 - See LICENSE for details.

Acknowledgments

About

Open-Source Neural Network Runtime (Ingenic MIPs)

Topics

Resources

Stars

14 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages