ONNX Runtime inference library for running pre-trained models. Supports object detection (YOLO), image classification (ResNet), segmentation (DeepLab), pose estimation (OpenPose), face recognition, and Phi-3 text generation. Compile with -lib onnx.
OnnxRuntime
ONNX runtime utilities for querying execution providers.
The execution provider is chosen per session: pass "ep" in the session's config map -- "cpu", "cuda", "dml", "qnn", "vitisai" or "coreml". Without "ep" a session gets the provider the library was built for (GetDefaultProvider). A provider the loaded ONNX Runtime does not carry is refused, with the list of those it does, and the session does not open; it never silently runs on the CPU instead.
Example
providers := OnnxRuntime->GetProviders();
each(p in providers) {
p->PrintLine();
};
config := Map->New()<String, String>;
if(OnnxRuntime->HasProvider("cuda")) {
config->Insert("ep", "cuda");
config->Insert("device_id", "0");
};
session := YoloSession->New("yolo11n.onnx", config);Operations
GetDefaultProvider # function
Gets the provider a session uses when its config names no "ep" (the provider the native library was built for)
function : GetDefaultProvider() ~ StringReturn
| Type | Description |
|---|---|
| String | short name: "cpu", "cuda", "dml", "qnn", "vitisai" or "coreml" |
GetProviders # function
Gets available ONNX execution providers (e.g., "DML", "CUDA", "CPU")
function : GetProviders() ~ String[]Return
| Type | Description |
|---|---|
| String | array of provider name strings |
HasProvider # function
Whether the loaded ONNX Runtime carries an execution provider, so a program can pick "ep" before creating a session. Takes the names "ep" takes (case-insensitive); an unknown name is false. Present in the runtime does not guarantee it can start: CUDA also needs the NVIDIA driver, CUDA and cuDNN.
function : HasProvider(name:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| name | String | short provider name, e.g. "cuda", "dml", "cpu" |
Return
| Type | Description |
|---|---|
| Bool | true if the runtime was built with the provider |