Skip to content

gluschenko/onnxify

Repository files navigation

Onnxify

Onnxify is an experimental .NET library for reading, inspecting, and writing ONNX models.

Paper

Machine learning workflows are often difficult not because models are impossible to run, but because they are difficult to understand, inspect, adapt, and carry from one environment to another. A lot of useful work happens in that space between research and production, where people need clarity, control, and confidence rather than another opaque black box. Onnxify exists for that middle ground.

The idea behind this repository is simple: models should be easier to work with, easier to reason about, and easier to integrate into real development workflows. If ONNX is meant to be a common language for models, then the tools around it should help people move faster, make smaller changes safely, and build their own workflows without unnecessary friction. That is the direction Onnxify is trying to push.

New models created with OnnxModel.Create() default to standard ONNX opset 25 and IR version 11. The opset default tracks the current bundled standard-domain operator schemas, while IR 11 remains compatible with the ONNX Runtime version used by the repository tests. Override OnnxModelCreationOptions.Opset and IrVersion when targeting an older runtime or a specific deployment profile.

GitHub CI

NuGet Packages

The repository currently implements the following NuGet packages. Package-specific instructions live in .docs/nuget.

Labrary NuGet Package
Onnxify NuGet Version
Onnxify.TorchSharp NuGet Version
Onnxify.Safetensors NuGet Version
Onnxify.ProjectGenerator NuGet Version
Onnxify.ModelGenerator NuGet Version
Onnxify.ML NuGet Version
Onnxify.ML.TorchSharp NuGet Version
Onnxify.HuggingFace NuGet Version
Onnxify.CLI NuGet Version

Onnxify.ModelGenerator can generate typed Microsoft.ML.OnnxRuntime inference wrappers for .onnx files included in a consuming project. Generated OnnxRuntimeInference wrappers now include both synchronous Run(...) overloads and async RunAsync(...) overloads with CancellationToken support. The async path uses ONNX Runtime's real InferenceSession.RunAsync(...) OrtValue buffer API rather than wrapping synchronous inference in Task.Run(...).

See TORCH_OPERATOR_COVERAGE.md for the current TorchSharp operator support matrix across ONNX import and export features.

Requirements

  • .NET 8 SDK + .NET 10 SDK
  • Windows 11 or Linux-based system
  • NuGet packages are cross-platform for consumer projects

Getting Started

Clone the repository and build the solution.

Windows:

git clone --recurse-submodules https://github.com/gluschenko/onnxify.git
cd onnxify
dotnet build src\Onnxify.slnx

Linux:

git clone --recurse-submodules https://github.com/gluschenko/onnxify.git
cd onnxify
dotnet build src/Onnxify.slnx

To pack and install the local Onnxify.CLI tool from this repository:

Windows:

.\install-onnxify-cli.ps1

Linux:

chmod +x ./install-onnxify-cli.sh
./install-onnxify-cli.sh

To install or refresh the bundled Codex skills from this repository:

Windows:

.\install-onnxify-skills.ps1

Linux:

chmod +x ./install-onnxify-skills.sh
./install-onnxify-skills.sh

Both install scripts support help output:

Windows:

.\install-onnxify-cli.ps1 -Help
.\install-onnxify-skills.ps1 -Help

Linux:

./install-onnxify-cli.sh --help
./install-onnxify-skills.sh --help

Install the Codex Skill

This section is optional. If you only want to consume the NuGet packages in your own .NET project, you do not need the Codex skill.

If you use Codex and want repository-specific help for Onnxify, Onnxify.TorchSharp, and the related package family, you can install the bundled onnxify skill directly from GitHub without cloning the repository.

Windows:

$codexHome = if ($env:CODEX_HOME) { $env:CODEX_HOME } else { Join-Path $HOME ".codex" }

py -3 "$codexHome\skills\.system\skill-installer\scripts\install-skill-from-github.py" `
  --repo gluschenko/onnxify `
  --path .agents/skills/onnxify

Linux:

codex_home="${CODEX_HOME:-$HOME/.codex}"

python3 "$codex_home/skills/.system/skill-installer/scripts/install-skill-from-github.py" \
  --repo gluschenko/onnxify \
  --path .agents/skills/onnxify

You can also install it by URL instead of --repo and --path.

Windows:

$codexHome = if ($env:CODEX_HOME) { $env:CODEX_HOME } else { Join-Path $HOME ".codex" }

py -3 "$codexHome\skills\.system\skill-installer\scripts\install-skill-from-github.py" `
  --url "https://github.com/gluschenko/onnxify/tree/main/.agents/skills/onnxify"

Linux:

codex_home="${CODEX_HOME:-$HOME/.codex}"

python3 "$codex_home/skills/.system/skill-installer/scripts/install-skill-from-github.py" \
  --url "https://github.com/gluschenko/onnxify/tree/main/.agents/skills/onnxify"

If you already cloned this repository and want to install both bundled skills from the local checkout, use the install-onnxify-skills.ps1 or install-onnxify-skills.sh scripts shown in Getting Started.

Restart Codex after installation so it picks up the new or refreshed skill files.

License

This repository is licensed under the terms of the LICENSE file.

About

Deeper integration between TorchSharp and Microsoft.ML.OnnxRuntime for .NET

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages