配置
可设项都挂在 ModelConfig 上,一律 Open() 前设好。取用 model.config(),也能直接在 model 上链式写。
可设项一览
| 项 | 类型 | 默认 | 说明 |
|---|---|---|---|
| provider | std::string | 空串 | 点名后端。空 = 自动选;非空 = 不降级,不可用直接报错 |
| gpu_id | int32_t | 0 | 卡号。0 = 第一块卡 |
| timeout | int32_t | 0 | 单次推理等待预算(毫秒)。0 = 不限 |
| default_thresholds | std::vector<double> | 空 | 按类别分数下限。空 = 不卡分 |
| threads | int32_t | 0 | 推理线程数。0 = 自动 |
| workers | int32_t | 1 | 并发会话数。1 = 单会话,2..32 = 开池(硬顶 32) |
| queue | int32_t | 0 | 池队列容量。0 = 64,合法 1..4096;满了按失败返回 |
| weight | int32_t | 0 | 同卡槽份额相对数。0 视同 100 |
连着写
Darra::AI::Model model("model.darmodel");
model.config().provider("onnx-cuda").gpu_id(0).timeout(5000);