Co-authored-by: leland17 <lileliao@foxmail.com> Co-authored-by: OmX <omx@oh-my-codex.dev> Co-authored-by: ronnie_zheng <zl19940307@163.com>
18 lines
540 B
Python
18 lines
540 B
Python
from collections.abc import Sequence
|
|
from typing import Any
|
|
|
|
|
|
def apply_torch_npu_patches(torch_npu: Any, patches: Sequence[Sequence[Any]]) -> None:
|
|
"""Apply torch_npu patches across old and new torch_npu patch APIs."""
|
|
if hasattr(torch_npu, "_apply_patches"):
|
|
torch_npu._apply_patches(patches)
|
|
return
|
|
|
|
if hasattr(torch_npu, "_apply_all_patches"):
|
|
torch_npu._apply_all_patches()
|
|
return
|
|
|
|
raise AttributeError(
|
|
"torch_npu must provide either _apply_patches or _apply_all_patches"
|
|
)
|