ML_RUNNER
A small library that aims to provide a fast and device agnostic way of running python ML models in embedded platforms using rust
Features
- A python library to parse ML models into an exported json format. Exports from :
- ONNX models
- A rust library to run the exported models on any platforms, with optimized functions depending on the platforms toolset
The library supports complex models with multiple inputs and outputs, and with multiple paths inside the model.
Supported layers in python library
| layer | ONNX support |
|---|---|
| Linear | ✅ |
| Conv2D | ✅ |
| Flatten | ✅ |
| MaxPool | ✅ |
| RNN | ✅ |
| GRU | ✅ |
| LSTM | ✅ |
| Add | ✅ |
| Concat | ✅ |
| Expand | ✅ |
| Gather | ✅ |
| Identity | ✅ |
| Shape | ✅ |
| Squeeze | ✅ |
| Transpose | ✅ |
| Unsqueeze | ✅ |
Supported activation functions
| function | ONNX support |
|---|---|
| ReLU | ✅ |
| Sigmoid | ✅ |
| Tanh | ✅ |
| Softmax | ✅ |
| Linear | ✅ |
Supported layers in Rust library
| layer | simple forward | BLAS | simd | comment |
|---|---|---|---|---|
| Linear | ✅ | ✅ | ✅ | |
| Conv2D | ✅ | ✅ | ✅ | |
| Flatten | ✅ | ✅ | ✖ | |
| MaxPool | ✅ | ✅ | ✖ | |
| RNN | ✅ | ✅ | ✅ | |
| GRU | ✅ | ✅ | ✅ | |
| LSTM | ✅ | ✅ | ✅ | |
| Add | ✅ | ✅ | ✅ | |
| Concat | ✅ | ✅ | ✖ | |
| Expand | ✅ | ✅ | ✖ | |
| Gather | ✅ | ✅ | ✖ | |
| Identity | ✅ | ✅ | ✖ | |
| Shape | ✅ | ✅ | ✖ | |
| Squeeze | ✅ | ✅ | ✖ | |
| Transpose | ✅ | ✅ | ✖ | |
| Unsqueeze | ✅ | ✅ | ✖ |
Supported activation functions
| function | simple application | BLAS | simd |
|---|---|---|---|
| ReLU | ✅ | ✅ | ✖ |
| Sigmoid | ✅ | ✅ | ✖ |
| Tanh | ✅ | ✅ | ✖ |
| Softmax | ✅ | ✅ | ✖ |
| Linear | ✅ | ✅ | ✖ |
Usage
Python library
To export a simple example onnx model, you can run the following :
poetry run python main.py --model-path simple_linear_model.onnx --output-path export.json
or from your own code
from ml_runner_exporter.onnx_exporter import export_onnx
output_model = export_onnx(model_path)
You can then save the exported model as a json file
Rust library
To run a model using the rust library, first export it to json using the python library as described in the python library section.
You can then import it and run it using :
let model = match Model::from_json(&model_json) {
Ok(m) => m,
Err(e) => {
eprintln!("Error parsing model JSON: {}", e);
return;
}
};
// Shape the input to what the model requires
let input = vec![...];
println!("Input: {:?}", input);
// Run forward pass
match model.forward(&input) {
Ok(output) => println!("Output: {:?}", output),
Err(e) => eprintln!("Error during forward pass: {}", e),
}
See the main.rs file for a concrete example.
To run the library, you can use one of the following targets :
cargo runto run the default target (no optimization)cargo run --features simdto run with SIMD optimizations (requireswidecrate)cargo run --features blasto run with BLAS optimizations (requires specific software depending on your OS)- To compile in release mode, use
cargo run -r(add the feature you want after)
Testing
To run the tests, you can use cargo test --all-features to run all tests
Benchmarks
See benchmark.md
Roadmap
These are the next features that I would like to implement, in no specific order
- Add activation functions support in simd
- Add support for more layer types
- Add support to other optimization backends (cuda, ...)
- Export both the python library and rust library to pip/crates.io for easier usage
- Add support for non float models (right now only float is supported, we should allow export and run of models in int)
- Implement parser for pytorch and tensorflow models
- I will focus mainly on tensorflow support at first, since pytorch has a good onnx exporter
Metadata
Release files for ml-runner-exporter 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ml_runner_exporter-1.0.0.tar.gz | 25.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ml_runner_exporter-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 60.4 kB
Release files / ml_runner_exporter-1.0.0.tar.gz
| Download URL | ml_runner_exporter-1.0.0.tar.gz |
|---|---|
| Size | 25.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d6adcdf288a4922073f302277eaedbd3aa47de6f52824f3f3d29f93faae5ca8
|
|
BLAKE2b-256 checksum How to use checksums |
1fc6621566aabc1eb53fa7158ad8e4c144b38ae93c1774ffc6208086be1bab63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency logRelease files / ml_runner_exporter-1.0.0-py3-none-any.whl
| Download URL | ml_runner_exporter-1.0.0-py3-none-any.whl |
|---|---|
| Size | 35.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f906efb3df1d1d68025a9434d50ca816119c8cc73930443f3096a68dcc936fd4
|
|
BLAKE2b-256 checksum How to use checksums |
3d6a6f8cb25a50ad99b899c353d3614269251451f6b780dcb8ea7527421f0358
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency log