Skip to content

Commit a2b9990

Browse files
committed
fix nontorch failure
Signed-off-by: yisheng <[email protected]>
1 parent 635f6ab commit a2b9990

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

accelerator/real_accelerator.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,22 @@ def get_accelerator():
131131
if accelerator_name is None:
132132
try:
133133
import intel_extension_for_pytorch as ipex
134+
134135
if ipex._C._has_xpu():
135136
accelerator_name = "xpu"
136137
except ImportError as e:
138+
pass
139+
if accelerator_name is None:
140+
try:
137141
import torch
142+
138143
if hasattr(torch, 'xpu'):
139144
if torch.xpu.is_available():
140145
accelerator_name = "xpu"
141146
else:
142147
pass
143-
else:
144-
pass
148+
except ImportError as e:
149+
pass
145150
if accelerator_name is None:
146151
try:
147152
import torch_npu # noqa: F401,F811 # type: ignore

0 commit comments

Comments
 (0)