IOnnxModel<T>
Interfaces · AiDotNet.Interfaces
Defines the contract for ONNX model wrappers that provide cross-platform model inference.
Implements: IDisposable
Known implementations: OnnxModel<T>
For Beginners
ONNX (Open Neural Network Exchange) is a universal format for neural network models. This interface allows you to:
- Load models trained in PyTorch, TensorFlow, or other frameworks
- Run inference using CPU, GPU (CUDA), TensorRT, or DirectML
- Convert between AiDotNet tensors and ONNX tensors automatically
How It Works
This interface provides a unified way to work with ONNX models in AiDotNet. It supports loading models from files, byte arrays, or URLs, and provides methods for running inference with AiDotNet Tensor types.
Properties
| Property | Summary |
|---|---|
IOnnxModelMetadata Metadata { get; } |
Gets the metadata about the loaded ONNX model. |
bool IsLoaded { get; } |
Gets whether the model has been successfully loaded and is ready for inference. |
string ExecutionProvider { get; } |
Gets the execution provider currently being used (CPU, CUDA, TensorRT, DirectML). |
Methods
| Method | Summary |
|---|---|
IReadOnlyDictionary<string, Tensor<T>> Run(IReadOnlyDictionary<string, Tensor<T>> inputs) |
Runs inference with named inputs. |
Task WarmUpAsync(CancellationToken cancellationToken) |
Warms up the model asynchronously. |
Task<IReadOnlyDictionary<string, Tensor<T>>> RunAsync(IReadOnlyDictionary<string, Tensor<T>> inputs, CancellationToken cancellationToken) |
Runs inference asynchronously with named inputs. |
Task<Tensor<T>> RunAsync(Tensor<T> input, CancellationToken cancellationToken) |
Runs inference asynchronously with named inputs. |
Tensor<T> Run(Tensor<T> input) |
Runs inference with named inputs. |
void WarmUp() |
Warms up the model by running a single inference with dummy data. |