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.
OnnxEngine
API.Onnx as an Engine: a model run in-process. A thin wrapper over Session, which is the whole reason the generic run came first -- without onnx_run there was nothing for an Engine to call, and the eight per-family entry points could not supply one. Use it when calling code should not choose a backend at every call site. Session itself is the better choice when the code is ONNX-specific anyway: GetModelInfo has no equivalent on a remote engine, so it is not on the interface, and this class exposes the Session for that reason.
Example
engine := OnnxEngine->New("model.onnx");
if(<>engine->IsOpen()) {
EndPoint->GetLastError()->PrintLine();
return;
};
outputs := engine->Run(inputs);
engine->Close();Operations
GetSession #
The underlying session, for what the Engine interface deliberately does not carry -- GetModelInfo above all, which has no remote equivalent.
method : public : GetSession() ~ SessionReturn
| Type | Description |
|---|---|
| Session | the session |
IsOpen #
Whether the model loaded.
method : public : IsOpen() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true when a run can proceed |