Configure GPU tuning modes and precision in OcrEngineConfig
nextWhen using GPU backends (OpenCL or Vulkan), you can control the trade-off between startup latency and steady-state throughput using GpuTuningMode and precision settings via OcrEngineConfig.
Tuning Modes
GpuTuningMode::Auto: The default. SelectsFASTfor OpenCL andNONEfor Vulkan. This reduces tuning work during cold or dynamic inference but may trade off some throughput for lower startup latency.GpuTuningMode::WideandGpuTuningMode::Heavy: Explicit options for fixed-shape, long-running workloads where maximum throughput is required.
Precision and Backends
- OpenCL: Retains
Buffermemory support. - Vulkan: Does not support OpenCL-only
Fast/Normaltuning modes. - Precision Mapping: For Vulkan,
OcrEngineConfigmapsNormalprecision toHighprecision. This is because MNN 3.6.1's Vulkan buffer backend defaults tofp16unlessHighis requested.Highprecision is recommended for long recognition sequences to mitigate numerical issues.Lowprecision is also explicitly supported.
// Example of configuring tuning and precision
let config = OcrEngineConfig::new()
.with_gpu_tuning(GpuTuningMode::Wide)
.with_precision(Precision::High);