Spaces:
Sleeping
Sleeping
Update model_handler.py
Browse files- model_handler.py +13 -8
model_handler.py
CHANGED
|
@@ -22,19 +22,24 @@ import torch
|
|
| 22 |
if not hasattr(torch, "xpu"):
|
| 23 |
class _DummyXPU:
|
| 24 |
@staticmethod
|
| 25 |
-
def empty_cache()
|
| 26 |
-
# No‑op: nothing to clear on CPU‑only builds.
|
| 27 |
return None
|
| 28 |
@staticmethod
|
| 29 |
-
def
|
| 30 |
-
|
|
|
|
|
|
|
| 31 |
return False
|
| 32 |
@staticmethod
|
| 33 |
-
def device_count()
|
| 34 |
-
|
|
|
|
|
|
|
| 35 |
return 0
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
import time
|
| 39 |
from typing import Optional, Tuple, Any
|
| 40 |
from transformers import UMT5EncoderModel
|
|
|
|
| 22 |
if not hasattr(torch, "xpu"):
|
| 23 |
class _DummyXPU:
|
| 24 |
@staticmethod
|
| 25 |
+
def empty_cache():
|
|
|
|
| 26 |
return None
|
| 27 |
@staticmethod
|
| 28 |
+
def manual_seed(_seed: int):
|
| 29 |
+
return None
|
| 30 |
+
@staticmethod
|
| 31 |
+
def is_available():
|
| 32 |
return False
|
| 33 |
@staticmethod
|
| 34 |
+
def device_count():
|
| 35 |
+
return 0
|
| 36 |
+
@staticmethod
|
| 37 |
+
def current_device():
|
| 38 |
return 0
|
| 39 |
+
@staticmethod
|
| 40 |
+
def set_device(_idx: int):
|
| 41 |
+
return None
|
| 42 |
+
torch.xpu = _DummyXPU() # type: ignore
|
| 43 |
import time
|
| 44 |
from typing import Optional, Tuple, Any
|
| 45 |
from transformers import UMT5EncoderModel
|