Kernels:
Trusted publisher
File size: 430 Bytes
b0b387a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import platform
import pytest
import torch
@pytest.fixture(scope="session")
def device() -> torch.device:
if platform.system() == "Darwin":
return torch.device("mps")
elif hasattr(torch, "xpu") and torch.xpu.is_available():
return torch.device("xpu")
elif torch.version.cuda is not None and torch.cuda.is_available():
return torch.device("cuda")
else:
return torch.device("cpu")
|