Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

olilarkin/ort-builder

Open more actions menu

Repository files navigation

ONNX Runtime static library builder

Converts an ONNX model to ORT format and serializes it to C++ source code, generate custom slimmed ONNX Runtime static libs & xcframework for apple platforms.

The goal here is to create a flexible but tiny inference engine for a specific model e.g. iPlug2 example.

NOTE: due to risk of ODR violations, global/static variable conflicts, and dependency symbol clashes with DAW Hosts that use ORT themselves - think hard before you use this in an audio plugin!

The scripts here are configured to create a minimal ORT binary using only the CPU provider. If you want to experiment with GPU inference, Core ML etc, you will have to modify.

Requirements:

CMake v2.6+

Instructions:

  1. Checkout ONNX Runtime submodule $ git submodule update --init

  2. Create a virtual environment and activate it

windows

$ py -3 -m venv venv
$ source ./venv/Scripts/activate`

mac/linux

$ python3 -m venv venv
$ source ./venv/bin/activate`
  1. Install dependencies $ pip install -r requirements.txt

  2. Run $ ./convert-model-to-ort.sh model.onnx This converts the .onnx file to .ort and produces a .config file which slims the onnxruntime library build in the next step. It also serializes the .ort format model to C++ source code, which can be used to bake the model into your app binary. If the model is large this might not be a great solution, and it might be better to locate the .ort file at runtime.

  3. Build customized onnx runtime static libraries

$ ./build-mac.sh
$ ./build-ios.sh
$ ./build-ios-simulator.sh
$ ./build-xcframework.sh

Note: windows static lib builds can get very large due to the LTO/LTCG settings in onnxruntime. You can turn that off by applying the change in ltcg_patch_for_windows.patch to the onnxruntime repo. Due to different MSVC runtimes for Debug and Release builds, we need to build two binaries for windows.

$ ./build-win.sh

About

ONNX Runtime static library builder

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  
Morty Proxy This is a proxified and sanitized view of the page, visit original site.