onnx-rs

Library Listed

Zero-dependency ONNX model parser in Rust

Checked · Sources

Downloads
453
Dependents
5
Stars
6
Forks
0
Contributors
1
Commits
14
Latest release
0.1.3 ·

About

From the project README ·

Zero-dependency ONNX model parser and encoder in Rust. Parses .onnx files (protobuf wire format) directly into typed Rust structs without relying on prost, protobuf, or any other crate.

Usage

use onnx_rs::ast::*;

// Parse
let bytes = std::fs::read("model.onnx").unwrap();
let model = onnx_rs::parse(&bytes).unwrap();

let graph = model.graph.as_ref().unwrap();
for node in &graph.node {
    match &node.op_type {
        OpType::Conv => println!("found conv: {}", node.name),
        OpType::Relu => println!("found relu: {}", node.name),
        op => println!("{}: {}", op, node.name),
    }
}

// Encode back to protobuf
let bytes = onnx_rs::encode(&model);
std::fs::write("output.onnx", &bytes).unwrap();

Features

  • Zero dependencies — hand-rolled protobuf wire format decoder
  • Typed AST — OpType enum with 170+ standard ONNX operators, Custom(String) fallback for vendor ops
  • Full ONNX IR — Model, Graph, Node, TensorProto, TypeProto (Tensor/Sequence/Map/Optional/SparseTensor), Attribute, Function, TrainingInfo
  • All 23 data types — including Float8 (e4m3fn, e5m2, etc.), Int4, Uint4, BFloat16
  • Roundtrip encode/decode — parse() and encode() are fully symmetric
Read the full README

Benchmarks

Measured on Apple Silicon. onnx-rs vs the official C++ protobuf implementation (via Python onnx package). Parse only — file I/O excluded.

ModelSizeonnx-rsC++ protobufSpeedup
NLLB Decoder1.7 GB0.4ms55.3ms138x
NLLB Encoder1.5 GB0.2ms29.8ms149x
BGE Large1.2 GB0.3ms55.7ms186x
VGG-19548 MB8.2ms8.5ms1.0x
GPT-2523 MB0.3ms8.3ms28x
Swin Transformer422 MB2.6ms8.2ms3.1x
BERT-SQuAD415 MB0.1ms12.6ms126x
Donut Encoder297 MB2.2ms6.1ms2.8x
YOLOv4245 MB0.1ms4.0ms40x
ResNet-152230 MB3.9ms4.0ms1.0x
Mask R-CNN169 MB0.9ms3.7ms4.1x
Faster R-CNN168 MB0.7ms3.5ms5.0x
MiniLM-L686 MB0.1ms1.5ms15x
EfficientNet49 MB0.1ms0.9ms9x
Inception v242 MB0.1ms0.9ms9x

Models using raw_data (the default for modern exporters like PyTorch) are parsed near-instantly via zero-copy borrows. Models using float_data (legacy packed floats) use bulk memcpy on little-endian platforms.

All 15 models roundtrip cleanly: onnx_rs::parse -> onnx_rs::encode -> validated by onnx.checker.check_model() in the official C++ implementation.

Run benchmarks locally:

cargo bench

License

MIT

Runs on
GPU support unknown
What shows it
  • no dependency or feature matches a backend row
Native code
None found
  • No native code found
Python bindings
No Python binding crate found
License
MIT

Compare with similar projects

Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.

onnx-rs beside the projects that share a topic with it
ProjectDownloadsDependentsStarsLatest releaseRuns on (GPU)Native codeLicense
onnx-rs This page Listed

Zero-dependency ONNX model parser in Rust

453 downloads over 30 days 5 6 0.1.3 GPU support unknown No native code found MIT
safetensors Featured

Provides functions to read and write safetensors which aim to be safer than their PyTorch counterpart.

5,486,837 downloads over 30 days 531 3,943 0.8.0 GPU support unknown No native code found Apache-2.0

Minimal ONNX model loader for extracting weights, tensors, operations, and graph structure

3,975 downloads over 30 days 4 6 0.5.2 GPU support unknown No native code found MIT
gguf Listed

GGUF file parser

2,472 downloads over 30 days 4 25 0.1.8 GPU support unknown No native code found MIT
cmf App Listed

One backbone, many specialists. CMF is a self-describing, memory-mappable single-file format and a dependency-free runtime for quantized LLMs — zero-copy execution on CPU or GPU (Vulkan · Metal · DX12) that overlays task-specialized skills onto one shared model, with no per-model duplication.

24 binary downloads per release Not applicable 52 Not measured Not measured Apache-2.0
compressr App New

Model conversion and quantization with no Python: reads SafeTensors, GGUF, TCF and PyTorch state dicts, writes SafeTensors, GGUF and TCF, and quantizes to Q2_K through Q8_0 and IQ4 formats, including Q4_K_M mixes. GPTQ, AWQ, NF4, FP8, EXL2 and ONNX input are not implemented.

Python bindings

23 downloads over 30 days Not applicable 0 0.2.1 GPU support unknown No native code found Apache-2.0
Why ListedNo archive, New or Featured rule places it, so it is Listed.

What it lacks for Featured

  • It has 4 active dependents and 4 new dependents in 365 days. Featured needs 11 active dependents or 9 new dependents in 365 days. The repository route reads 6 stars, 0 forks and 1 contributor. It needs 4,539 stars, 434 forks and 79 contributors together.

What else the check found

  • The last activity is on 9 Oct 2026, 31 days ago. The rules expect an update within 365 days. Dormancy rule

Exact rules: Listed, Featured library. The check on applied thresholds version 9.

Every rule outcome, as the check records it
  • expected-interval: version 0.1.3 base 300, capped at 4 releases = 200, raised to the 365-day floor: E = 365 days
  • dormancy: last activity 2026-10-09, 31 days ago, E = 365: active
  • featured: not featured: active_users 4 < 11 and new_adopters 4 < 9 and repository route stars 6 (needs 4539), forks 0 (needs 434), contributors 1 (needs 79)
  • listed: listed: no archive, new or featured rule applies

Measurements and sources

Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.

Sources6 sources
Adoption4 active dependents, 4 new dependents in 365 days1 not measured
Adoption measurements
SignalValueSourceFetchedCounts
Active dependents4crates.io database dumpYes
New dependents (365 days)4crates.io database dumpYes
Peak active dependents4crates.io database dumpYes
Active dependents as a share of the peak1crates.io database dumpYes
Binary downloads per releaseNot measuredYes
MaintenanceLatest human commit: 31 days ago3 not measured
Maintenance measurements
SignalValueSourceFetchedCounts
Latest human commit2026-10-09GitHub repositoryYes
Latest release2026-10-09crates.io database dumpYes
First release2026-04-02crates.io database dumpYes
Latest version0.1.3crates.io database dumpYes
Days the oldest outside issue waits for a reply0GitHub repositoryYes
Maintainer replies over 365 days2GitHub repositoryYes
Repository archivedfalseGitHub repositoryYes
Repository gonefalseGitHub repositoryYes
Release commit or manifest in the repotruecrates.io packageYes
Published docstruecrates.io database dumpYes
Latest release fails cargo checkNot measuredYes
Build check dateNot measuredYes
Build check toolchainNot measuredYes
SecurityUnpatched vulnerabilities: none
Security measurements
SignalValueSourceFetchedCounts
Unpatched vulnerabilities past the grace windownoneRustSec advisory databaseYes
RustSec unmaintained advisorynoneRustSec advisory databaseYes
Deprecation noticenonecrates.io database dumpYes
Deprecated requirementnonecrates.io database dumpYes
Distribution4 releases, 453 downloads over 30 days5 not measured
Distribution measurements
SignalValueSourceFetchedCounts
Releases4crates.io database dumpYes
Downloads over 30 days453crates.io database dumpYes
Binary downloads over the last 3 releasesNot measuredYes
Homebrew installs on request over 365 daysNot measuredYes
Repology repository familiesNot measuredYes
Docker pull growth over 90 daysNot measuredYes
Docker pulls at the growth baselineNot measuredYes
Every version a prereleasefalsecrates.io database dumpYes
Every version 0.0.xfalsecrates.io database dumpYes
Every version yankedfalsecrates.io database dumpYes
Crate deleted from crates.iofalsecrates.io database dumpYes
Repository6 stars, 0 forks, 1 contributors, 14 commits. Stars alone never qualify a project.
Repository measurements
SignalValueSourceFetchedCounts
GitHub stars6GitHub repositoryYes — one part of the repository route
GitHub forks0GitHub repositoryYes — one part of the repository route
Contributors with a GitHub account1GitHub contributorsYes — one part of the repository route
Commits on the default branch14GitHub repositoryNo
Repository's main crate left out of the entrynonecrates.io database dumpYes
Facts that never count
Facts that never count measurements
SignalValueSourceFetchedCounts
LicenseMITcrates.io database dumpNo
Runs on, from listed crates and their direct dependenciesGPU support unknowncrates.io database dumpNo
What shows each backendno dependency or feature matches a backend rowcrates.io database dumpNo
Native code, from listed crates and their dependenciesNo native code foundcrates.io database dumpNo
Python bindings, from direct dependencies of listed cratesNo Python binding crate foundcrates.io database dumpNo
Crates that depend on a listed crate directly5crates.io database dumpNo

Corrections and review history

Report a correction

No correction applies to this entry.

Judgments

A judgment enters only through an approved issue and a merged pull request.

No judgment applies to this entry.