OnnxRuntimeSharp 0.1.0-preview.2

This is a prerelease version of OnnxRuntimeSharp.
dotnet add package OnnxRuntimeSharp --version 0.1.0-preview.2
                    
NuGet\Install-Package OnnxRuntimeSharp -Version 0.1.0-preview.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OnnxRuntimeSharp" Version="0.1.0-preview.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OnnxRuntimeSharp" Version="0.1.0-preview.2" />
                    
Directory.Packages.props
<PackageReference Include="OnnxRuntimeSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OnnxRuntimeSharp --version 0.1.0-preview.2
                    
#r "nuget: OnnxRuntimeSharp, 0.1.0-preview.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OnnxRuntimeSharp@0.1.0-preview.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OnnxRuntimeSharp&version=0.1.0-preview.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=OnnxRuntimeSharp&version=0.1.0-preview.2&prerelease
                    
Install as a Cake Tool

OnnxRuntimeSharp

.NET C# Build Status Super-Linter NuGet Release License

Low-level ONNX Runtime C API interop in modern C#. Cross-platform, trimmable, and AOT/NativeAOT compatible.

Example

The application supplies the native ONNX Runtime runtime package and owns the managed input and output buffers. Tensors pin those buffers once, so steady state inference does not allocate managed memory.

using OnnxRuntimeSharp;

using var environment = new OrtEnvironment();
using var session = new OrtSession(environment, File.ReadAllBytes("mnist-8.onnx"));
using var input = new OrtTensor<float>(new float[28 * 28], [1, 1, 28, 28]);
using var output = new OrtTensor<float>(new float[10], [1, 10]);

session.Run(input, output);

Profiling

Enable profiling before creating the session, run inference, and finish the profile to retrieve the trace file path.

using var options = new OrtSessionOptions();
options.EnableProfiling("mnist-profile");
using var session = new OrtSession(environment, model, options);
// Run inference.
var profilePath = session.EndProfiling();

The OnnxRuntimeSharp.Profiler project runs the bundled mnist-8.onnx model and emits an ONNX Runtime JSON trace.

Building

dotnet test
dotnet run --project src\OnnxRuntimeSharp.Profiler

License

This project is licensed under the MIT license.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-preview.2 69 8/29/2026
0.1.0-preview.1 278 7/8/2022