OpenVinoSharp 0.0.4

dotnet add package OpenVinoSharp --version 0.0.4
                    
NuGet\Install-Package OpenVinoSharp -Version 0.0.4
                    
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="OpenVinoSharp" Version="0.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenVinoSharp" Version="0.0.4" />
                    
Directory.Packages.props
<PackageReference Include="OpenVinoSharp" />
                    
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 OpenVinoSharp --version 0.0.4
                    
#r "nuget: OpenVinoSharp, 0.0.4"
                    
#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 OpenVinoSharp@0.0.4
                    
#: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=OpenVinoSharp&version=0.0.4
                    
Install as a Cake Addin
#tool nuget:?package=OpenVinoSharp&version=0.0.4
                    
Install as a Cake Tool

OpenVinoSharp

.NET C# Build Status Super-Linter codecov CodeQL Nuget Release downloads Size License Blog GitHub Repo stars

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

⭐ Please star this project if you like it. ⭐

Example | Example Catalogue | Public API Reference

Example

var modelPath = Path.Combine(AppContext.BaseDirectory, "mnist-8.onnx");
using var core = new OvCore();
using var model = core.ReadModel(modelPath);
using var compiledModel = model.Compile();
using var inferRequest = compiledModel.CreateInferRequest();
using var inputTensor = inferRequest.GetInputTensor();
inputTensor.GetData<float>().Clear();
inferRequest.Infer();
using var outputTensor = inferRequest.GetOutputTensor();
_ = outputTensor.GetData<float>();

For more examples see Example Catalogue.

Benchmarks

Benchmarks.

Detailed Benchmarks

Comparison Benchmarks

Example Catalogue

The following examples are available in ReadMeTest.cs.

Example - MNIST inference

var modelPath = Path.Combine(AppContext.BaseDirectory, "mnist-8.onnx");
using var core = new OvCore();
using var model = core.ReadModel(modelPath);
using var compiledModel = model.Compile();
using var inferRequest = compiledModel.CreateInferRequest();
using var inputTensor = inferRequest.GetInputTensor();
inputTensor.GetData<float>().Clear();
inferRequest.Infer();
using var outputTensor = inferRequest.GetOutputTensor();
_ = outputTensor.GetData<float>();

Public API Reference

[assembly: System.CLSCompliant(false)]
[assembly: System.Reflection.AssemblyMetadata("IsAotCompatible", "True")]
[assembly: System.Reflection.AssemblyMetadata("IsTrimmable", "True")]
[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/nietras/OpenVinoSharp/")]
[assembly: System.Resources.NeutralResourcesLanguage("en")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("OpenVinoSharp.Benchmarks")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("OpenVinoSharp.ComparisonBenchmarks")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("OpenVinoSharp.Test")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("OpenVinoSharp.XyzTest")]
[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v10.0", FrameworkDisplayName=".NET 10.0")]
namespace OpenVinoSharp
{
    public static class Ov
    {
        [System.Runtime.CompilerServices.SkipLocalsInit]
        [System.Runtime.InteropServices.LibraryImport("openvino_c")]
        public static OpenVinoSharp.Ov.Status ov_compiled_model_create_infer_request(OpenVinoSharp.Ov.CompiledModelHandle compiledModel, out OpenVinoSharp.Ov.InferRequestHandle inferRequest) { }
        [System.Runtime.InteropServices.LibraryImport("openvino_c")]
        public static void ov_compiled_model_free(OpenVinoSharp.Ov.CompiledModelHandle compiledModel) { }
        [System.Runtime.CompilerServices.SkipLocalsInit]
        [System.Runtime.InteropServices.LibraryImport("openvino_c", StringMarshalling=System.Runtime.InteropServices.StringMarshalling.Utf8)]
        public static OpenVinoSharp.Ov.Status ov_core_compile_model(OpenVinoSharp.Ov.CoreHandle core, OpenVinoSharp.Ov.ModelHandle model, string deviceName, nuint propertyArgsSize, out OpenVinoSharp.Ov.CompiledModelHandle compiledModel) { }
        [System.Runtime.CompilerServices.SkipLocalsInit]
        [System.Runtime.InteropServices.LibraryImport("openvino_c", StringMarshalling=System.Runtime.InteropServices.StringMarshalling.Utf8)]
        public static OpenVinoSharp.Ov.Status ov_core_compile_model_from_file(OpenVinoSharp.Ov.CoreHandle core, string modelPath, string deviceName, nuint propertyArgsSize, out OpenVinoSharp.Ov.CompiledModelHandle compiledModel) { }
        [System.Runtime.CompilerServices.SkipLocalsInit]
        [System.Runtime.InteropServices.LibraryImport("openvino_c")]
        public static OpenVinoSharp.Ov.Status ov_core_create(out OpenVinoSharp.Ov.CoreHandle core) { }
        [System.Runtime.InteropServices.LibraryImport("openvino_c")]
        public static void ov_core_free(OpenVinoSharp.Ov.CoreHandle core) { }
        [System.Runtime.CompilerServices.SkipLocalsInit]
        [System.Runtime.InteropServices.LibraryImport("openvino_c", StringMarshalling=System.Runtime.InteropServices.StringMarshalling.Utf8)]
        public static OpenVinoSharp.Ov.Status ov_core_read_model(OpenVinoSharp.Ov.CoreHandle core, string modelPath, string? binPath, out OpenVinoSharp.Ov.ModelHandle model) { }
        [System.Runtime.CompilerServices.SkipLocalsInit]
        [System.Runtime.InteropServices.LibraryImport("openvino_c", StringMarshalling=System.Runtime.InteropServices.StringMarshalling.Utf8)]
        public static OpenVinoSharp.Ov.Status ov_core_set_property(OpenVinoSharp.Ov.CoreHandle core, string deviceName, string propertyKey, string propertyValue) { }
        [System.Runtime.InteropServices.LibraryImport("openvino_c")]
        public static nint ov_get_error_info(OpenVinoSharp.Ov.Status status) { }
        [System.Runtime.InteropServices.LibraryImport("openvino_c")]
        public static nint ov_get_last_err_msg() { }
        [System.Runtime.InteropServices.LibraryImport("openvino_c")]
        public static void ov_infer_request_free(OpenVinoSharp.Ov.InferRequestHandle inferRequest) { }
        [System.Runtime.CompilerServices.SkipLocalsInit]
        [System.Runtime.InteropServices.LibraryImport("openvino_c")]
        public static OpenVinoSharp.Ov.Status ov_infer_request_get_input_tensor(OpenVinoSharp.Ov.InferRequestHandle inferRequest, out OpenVinoSharp.Ov.TensorHandle tensor) { }
        [System.Runtime.CompilerServices.SkipLocalsInit]
        [System.Runtime.InteropServices.LibraryImport("openvino_c")]
        public static OpenVinoSharp.Ov.Status ov_infer_request_get_output_tensor(OpenVinoSharp.Ov.InferRequestHandle inferRequest, out OpenVinoSharp.Ov.TensorHandle tensor) { }
        [System.Runtime.InteropServices.LibraryImport("openvino_c")]
        public static OpenVinoSharp.Ov.Status ov_infer_request_infer(OpenVinoSharp.Ov.InferRequestHandle inferRequest) { }
        [System.Runtime.InteropServices.LibraryImport("openvino_c")]
        public static OpenVinoSharp.Ov.Status ov_infer_request_set_input_tensor(OpenVinoSharp.Ov.InferRequestHandle inferRequest, OpenVinoSharp.Ov.TensorHandle tensor) { }
        [System.Runtime.InteropServices.LibraryImport("openvino_c")]
        public static void ov_model_free(OpenVinoSharp.Ov.ModelHandle model) { }
        [System.Runtime.CompilerServices.SkipLocalsInit]
        [System.Runtime.InteropServices.LibraryImport("openvino_c")]
        public static OpenVinoSharp.Ov.Status ov_shape_free(ref OpenVinoSharp.Ov.Shape shape) { }
        [System.Runtime.CompilerServices.SkipLocalsInit]
        [System.Runtime.InteropServices.LibraryImport("openvino_c")]
        public static OpenVinoSharp.Ov.Status ov_tensor_data(OpenVinoSharp.Ov.TensorHandle tensor, out System.IntPtr data) { }
        [System.Runtime.InteropServices.LibraryImport("openvino_c")]
        public static void ov_tensor_free(OpenVinoSharp.Ov.TensorHandle tensor) { }
        [System.Runtime.CompilerServices.SkipLocalsInit]
        [System.Runtime.InteropServices.LibraryImport("openvino_c")]
        public static OpenVinoSharp.Ov.Status ov_tensor_get_shape(OpenVinoSharp.Ov.TensorHandle tensor, out OpenVinoSharp.Ov.Shape shape) { }
        public readonly struct CompiledModelHandle : System.IEquatable<OpenVinoSharp.Ov.CompiledModelHandle>
        {
            public CompiledModelHandle(nint Value) { }
            public System.IntPtr Value { get; init; }
        }
        public readonly struct CoreHandle : System.IEquatable<OpenVinoSharp.Ov.CoreHandle>
        {
            public CoreHandle(nint Value) { }
            public System.IntPtr Value { get; init; }
        }
        public enum ElementType
        {
            DYNAMIC = 0,
            BOOLEAN = 1,
            BF16 = 2,
            F16 = 3,
            F32 = 4,
            F64 = 5,
            I4 = 6,
            I8 = 7,
            I16 = 8,
            I32 = 9,
            I64 = 10,
            U1 = 11,
            U2 = 12,
            U3 = 13,
            U4 = 14,
            U6 = 15,
            U8 = 16,
            U16 = 17,
            U32 = 18,
            U64 = 19,
            NF4 = 20,
            F8E4M3 = 21,
            F8E5M3 = 22,
            STRING = 23,
            F4E2M1 = 24,
            F8E8M0 = 25,
        }
        public readonly struct InferRequestHandle : System.IEquatable<OpenVinoSharp.Ov.InferRequestHandle>
        {
            public InferRequestHandle(nint Value) { }
            public System.IntPtr Value { get; init; }
        }
        public readonly struct ModelHandle : System.IEquatable<OpenVinoSharp.Ov.ModelHandle>
        {
            public ModelHandle(nint Value) { }
            public System.IntPtr Value { get; init; }
        }
        public struct Shape
        {
            public unsafe long* Dimensions;
            public long Rank;
            public System.ReadOnlySpan<long> Span { get; }
        }
        public enum Status
        {
            OK = 0,
            GENERAL_ERROR = -1,
            NOT_IMPLEMENTED = -2,
            NETWORK_NOT_LOADED = -3,
            PARAMETER_MISMATCH = -4,
            NOT_FOUND = -5,
            OUT_OF_BOUNDS = -6,
            UNEXPECTED = -7,
            REQUEST_BUSY = -8,
            RESULT_NOT_READY = -9,
            NOT_ALLOCATED = -10,
            INFER_NOT_STARTED = -11,
            NETWORK_NOT_READ = -12,
            INFER_CANCELLED = -13,
            INVALID_C_PARAM = -14,
            UNKNOWN_C_ERROR = -15,
            NOT_IMPLEMENT_C_METHOD = -16,
            UNKNOW_EXCEPTION = -17,
        }
        public readonly struct TensorHandle : System.IEquatable<OpenVinoSharp.Ov.TensorHandle>
        {
            public TensorHandle(nint Value) { }
            public System.IntPtr Value { get; init; }
        }
        extension(OpenVinoSharp.Ov.Status result)
        {
            public void Ok() { }
            public bool IsOk() { }
            public bool IsError() { }
            public string ToStringFast() { }
        }
    }
    public sealed class OvCompiledModel : System.Runtime.InteropServices.SafeHandle
    {
        public override bool IsInvalid { get; }
        public OpenVinoSharp.OvInferRequest CreateInferRequest() { }
        protected override bool ReleaseHandle() { }
    }
    public sealed class OvCore : System.Runtime.InteropServices.SafeHandle
    {
        public OvCore() { }
        public override bool IsInvalid { get; }
        public OpenVinoSharp.OvModel ReadModel(string modelPath, string? binPath = null) { }
        protected override bool ReleaseHandle() { }
        public void SetProperty(string deviceName, string propertyKey, string propertyValue) { }
    }
    [System.Serializable]
    public class OvException : System.Exception
    {
        public OvException(string message) { }
    }
    public sealed class OvInferRequest : System.Runtime.InteropServices.SafeHandle
    {
        public override bool IsInvalid { get; }
        public OpenVinoSharp.OvTensor GetInputTensor() { }
        public OpenVinoSharp.OvTensor GetOutputTensor() { }
        public System.Collections.Generic.IReadOnlyList<OpenVinoSharp.OvProfilingInfo> GetProfilingInfo() { }
        public void Infer() { }
        protected override bool ReleaseHandle() { }
    }
    public sealed class OvModel : System.Runtime.InteropServices.SafeHandle
    {
        public override bool IsInvalid { get; }
        public OpenVinoSharp.OvCompiledModel Compile(string deviceName = "CPU") { }
        protected override bool ReleaseHandle() { }
    }
    public sealed class OvProfilingInfo : System.IEquatable<OpenVinoSharp.OvProfilingInfo>
    {
        public OvProfilingInfo(OpenVinoSharp.OvProfilingStatus Status, long RealTimeMicroseconds, long CpuTimeMicroseconds, string NodeName, string ExecutionType, string NodeType) { }
        public long CpuTimeMicroseconds { get; init; }
        public string ExecutionType { get; init; }
        public string NodeName { get; init; }
        public string NodeType { get; init; }
        public long RealTimeMicroseconds { get; init; }
        public OpenVinoSharp.OvProfilingStatus Status { get; init; }
    }
    public enum OvProfilingStatus
    {
        NotRun = 0,
        OptimizedOut = 1,
        Executed = 2,
    }
    public sealed class OvShape : System.Runtime.InteropServices.SafeHandle
    {
        public override bool IsInvalid { get; }
        public long Rank { get; }
        public System.ReadOnlySpan<long> Span { get; }
        protected override bool ReleaseHandle() { }
    }
    [System.Serializable]
    public sealed class OvStatusException : OpenVinoSharp.OvException
    {
        public OvStatusException(OpenVinoSharp.Ov.Status status, string message) { }
        public OpenVinoSharp.Ov.Status Status { get; }
    }
    public sealed class OvTensor : System.Runtime.InteropServices.SafeHandle
    {
        public System.IntPtr Data { get; }
        public override bool IsInvalid { get; }
        public System.Span<T> GetData<T>()
            where T :  unmanaged { }
        public OpenVinoSharp.OvShape GetShape() { }
        protected override bool ReleaseHandle() { }
    }
}
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.0.4 0 8/27/2026
0.0.3 64 7/30/2026
0.0.2 58 7/29/2026
0.0.1 53 7/29/2026