feat: 完成 issue #59 ⑥ 昇腾 NPU 后端适配(CANN 对接)
This commit is contained in:
@@ -40,14 +40,18 @@ def build_backend(config: dict) -> InferenceBackend:
|
||||
)
|
||||
cls = BACKEND_REGISTRY[name]
|
||||
inf = config.get("inference", {}) or {}
|
||||
return cls(
|
||||
kwargs = dict(
|
||||
endpoint=inf.get("endpoint", ""),
|
||||
model=inf.get("model", "iaop-default"),
|
||||
timeout_seconds=float(inf.get("timeout_seconds", 10)),
|
||||
runtime=inf.get("runtime", ""),
|
||||
device=inf.get("device", ""),
|
||||
cann_version=inf.get("cann_version", ""),
|
||||
)
|
||||
# 空值/缺省不覆盖后端类默认(如昇腾 npu 默认 mindie / ascend-910b / CANN 8.0),
|
||||
# 保证「切换后端仅改 backend 字段」时硬件相关参数落到正确的默认值。
|
||||
for key in ("runtime", "device", "cann_version"):
|
||||
value = inf.get(key)
|
||||
if value:
|
||||
kwargs[key] = value
|
||||
return cls(**kwargs)
|
||||
|
||||
|
||||
def load_backend_config(path: str) -> dict:
|
||||
|
||||
Reference in New Issue
Block a user