Overview
TheRettoOrtWorker provides an ONNX Runtime backend for running PaddleOCR models with support for CPU, CUDA, and DirectML execution providers.
RettoOrtWorker
The main worker struct that manages ONNX Runtime sessions for detection, classification, and recognition.Type Definition
retto-core/src/worker/ort_worker.rs:113
Methods
new()
Creates a new ONNX Runtime worker with the specified configuration.
cfg: Configuration including device settings and model providers
RettoResult<Self>: The initialized worker or an error
init()
Initializes the worker (currently a no-op for ORT backend).
RettoOrtWorkerConfig
Configuration struct for the ONNX Runtime worker.Type Definition
retto-core/src/worker/ort_worker.rs:53
Fields
The execution device to use (CPU, CUDA, or DirectML)
Model provider specifying sources for det, cls, and rec models
Example
RettoOrtWorkerDevice
Enum specifying which execution provider to use for inference.Type Definition
retto-core/src/worker/ort_worker.rs:21
Variants
Use CPU execution provider only (default)
Use NVIDIA CUDA execution provider with specified device IDRequires
backend-ort-cuda feature flagUse DirectML execution provider with specified device IDRequires
backend-ort-directml feature flagExamples
Backend Configuration
The ORT worker configures execution providers based on the selected device:CPU Backend
Always available as a fallback. UsesCPUExecutionProvider.
CUDA Backend
Available when compiled withbackend-ort-cuda feature. Configures:
- Arena extend strategy:
NextPowerOfTwo - CuDNN conv algorithm search:
Exhaustive - Device ID selection
DirectML Backend
Available when compiled withbackend-ort-directml feature. Supports Windows DirectX acceleration.
The CPU execution provider is always added as a fallback, even when GPU acceleration is enabled.
Complete Example
For WASM targets, the worker automatically initializes the ORT environment with a global thread pool.
