yongqiang
commited on
Commit
·
83c76bb
1
Parent(s):
ba96580
launcher_axmodel 移除对编译上下文的依赖
Browse files
VideoX-Fun/examples/z_image_fun/launcher_axmodel.py
CHANGED
|
@@ -298,6 +298,7 @@ class AxSplitTransformer:
|
|
| 298 |
if spec.label not in self._session_cache:
|
| 299 |
path = self._expected_path(spec)
|
| 300 |
self._session_cache[spec.label] = AxInferenceSession(path.as_posix())
|
|
|
|
| 301 |
return self._session_cache[spec.label]
|
| 302 |
|
| 303 |
def close(self) -> None:
|
|
@@ -333,33 +334,14 @@ class AxSplitTransformer:
|
|
| 333 |
def _load_auto_specs(self) -> List[SubGraphSpec]:
|
| 334 |
specs: List[SubGraphSpec] = []
|
| 335 |
for path in sorted(self.model_dir.glob("auto_*.axmodel")):
|
| 336 |
-
# Ax compiler有两种输出目录命名:compiled_{stem} 或 compiled_auto_XX
|
| 337 |
-
candidates = [path.parent / f"compiled_{path.stem}"]
|
| 338 |
-
# 兼容实际产物 compiled_auto_00 这类名称
|
| 339 |
-
parts = path.stem.split("_", 3)
|
| 340 |
-
if len(parts) >= 2:
|
| 341 |
-
candidates.append(path.parent / f"compiled_{parts[0]}_{parts[1]}")
|
| 342 |
-
|
| 343 |
-
ctx_path = None
|
| 344 |
-
for cand in candidates:
|
| 345 |
-
candidate_ctx = cand / "build_context.json"
|
| 346 |
-
if candidate_ctx.exists():
|
| 347 |
-
ctx_path = candidate_ctx
|
| 348 |
-
break
|
| 349 |
-
|
| 350 |
-
if ctx_path is None:
|
| 351 |
-
logger.warning(f"跳过 {path.name},缺少 build_context.json (尝试: {[c.as_posix() for c in candidates]})")
|
| 352 |
-
continue
|
| 353 |
-
if not ctx_path.exists():
|
| 354 |
-
logger.warning(f"跳过 {path.name},缺少 build_context.json")
|
| 355 |
-
continue
|
| 356 |
try:
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
|
|
|
| 361 |
except Exception as exc: # pragma: no cover - defensive
|
| 362 |
-
logger.warning(f"
|
| 363 |
continue
|
| 364 |
|
| 365 |
if not inputs or not outputs:
|
|
|
|
| 298 |
if spec.label not in self._session_cache:
|
| 299 |
path = self._expected_path(spec)
|
| 300 |
self._session_cache[spec.label] = AxInferenceSession(path.as_posix())
|
| 301 |
+
logger.info(f"加载子图 session: {spec.label} from {path.name}")
|
| 302 |
return self._session_cache[spec.label]
|
| 303 |
|
| 304 |
def close(self) -> None:
|
|
|
|
| 334 |
def _load_auto_specs(self) -> List[SubGraphSpec]:
|
| 335 |
specs: List[SubGraphSpec] = []
|
| 336 |
for path in sorted(self.model_dir.glob("auto_*.axmodel")):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
try:
|
| 338 |
+
session = AxInferenceSession(path.as_posix())
|
| 339 |
+
inputs = [info.name for info in session.get_inputs() if getattr(info, "name", None)]
|
| 340 |
+
outputs = [info.name for info in session.get_outputs() if getattr(info, "name", None)]
|
| 341 |
+
# 缓存 session,避免重复打开
|
| 342 |
+
self._session_cache[path.stem] = session
|
| 343 |
except Exception as exc: # pragma: no cover - defensive
|
| 344 |
+
logger.warning(f"跳过 {path.name},加载/解析 IO 失败: {exc}")
|
| 345 |
continue
|
| 346 |
|
| 347 |
if not inputs or not outputs:
|