OnnxRuntimeSharp 0.1.0-preview.2
dotnet add package OnnxRuntimeSharp --version 0.1.0-preview.2
NuGet\Install-Package OnnxRuntimeSharp -Version 0.1.0-preview.2
<PackageReference Include="OnnxRuntimeSharp" Version="0.1.0-preview.2" />
<PackageVersion Include="OnnxRuntimeSharp" Version="0.1.0-preview.2" />
<PackageReference Include="OnnxRuntimeSharp" />
paket add OnnxRuntimeSharp --version 0.1.0-preview.2
#r "nuget: OnnxRuntimeSharp, 0.1.0-preview.2"
#:package OnnxRuntimeSharp@0.1.0-preview.2
#addin nuget:?package=OnnxRuntimeSharp&version=0.1.0-preview.2&prerelease
#tool nuget:?package=OnnxRuntimeSharp&version=0.1.0-preview.2&prerelease
OnnxRuntimeSharp
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 | Versions 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. |
-
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 |