hotfix: fix xpu crash brought by code refine. torch.xpu rely on import ipex

Signed-off-by: Wang, Yi A <yi.a.wang@intel.com>
This commit is contained in:
Wang, Yi A 2024-07-30 19:28:59 -07:00
parent 0b95693fb8
commit 4d28e29236

View File

@ -56,6 +56,8 @@ elif torch.version.cuda is not None and torch.cuda.is_available():
get_free_memory = get_cuda_free_memory get_free_memory = get_cuda_free_memory
elif is_ipex_available(): elif is_ipex_available():
SYSTEM = "ipex" SYSTEM = "ipex"
import intel_extension_for_pytorch # noqa: F401
if hasattr(torch, "xpu") and torch.xpu.is_available(): if hasattr(torch, "xpu") and torch.xpu.is_available():
empty_cache = torch.xpu.empty_cache empty_cache = torch.xpu.empty_cache
synchronize = torch.xpu.synchronize synchronize = torch.xpu.synchronize