()
| 286 | |
| 287 | @functools.lru_cache |
| 288 | def get_device(): |
| 289 | if torch.cuda.is_available(): |
| 290 | return "cuda" |
| 291 | elif is_torch_npu_available(): |
| 292 | return "npu" |
| 293 | elif hasattr(torch, "xpu") and torch.xpu.is_available(): |
| 294 | return "xpu" |
| 295 | elif torch.backends.mps.is_available(): |
| 296 | return "mps" |
| 297 | elif is_torch_mlu_available(): |
| 298 | return "mlu" |
| 299 | else: |
| 300 | return "cpu" |
| 301 | |
| 302 | |
| 303 | def empty_device_cache(device_type: str | None = None): |
no test coverage detected
searching dependent graphs…