onnx_graph
A minimal ONNX graph parser and inference engine written in Rust. Takes an .onnx file, builds an internal linked list of nodes, and runs forward inference by executing each node in order and writing results into a contiguous tensor map.
Currently supports the subset of ONNX operators required for YOLOv8 inference.
How it works
- Parses the
.onnxfile and builds a linked list where each node corresponds to an ONNX operator - Initializes a
TensorMap— aHashMap<String, TypedArray>wrapper that ensures all arrays are contiguous in memory - Runs inference by walking the linked list, each node reads its inputs from the
TensorMapand writes its output back into it
Usage
[]
= "0.1.0"
use ;
// Load model and initialize tensor map
let =
from_onnx_file?;
// Run inference
graph.pass;
The TensorMap automatically ensures contiguous memory layout on every insert:
Tensors are stored as TypedArray, a typed enum over ndarray's ArrayD:
License
MIT