Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

return devices for testing

edgarribaaa15428ead39
diff --git a/test/common.py b/test/common.py
index 0051a8848..4e10fcfc7 100644
--- a/test/common.py
+++ b/test/common.py
@@ -1,26 +1,29 @@
+from typing import Dict
+
import torch
import pytest
-def get_test_devices():
- """Creates a string list with the devices type to test the source code.
+def get_test_devices() -> Dict[str, torch.device]:
+ """Creates a dictionary with the devices to test the source code.
CUDA devices will be test only in case the current hardware supports it.
Return:
- list(str): list with devices names.
+ dict(str, torch.device): list with devices names.
"""
- devices = ["cpu"]
- # if torch.cuda.is_available():
- # devices.append("cuda")
+ devices: Dict[str, torch.device] = {}
+ devices["cpu"] = torch.device("cpu")
+ if torch.cuda.is_available():
+ devices["cuda"] = torch.device("cuda:0")
return devices
# setup the devices to test the source code
-TEST_DEVICES = get_test_devices()
+TEST_DEVICES: Dict[str, torch.device] = get_test_devices()
@pytest.fixture()
-def device_type(request):
- typ = request.config.getoption('--typetest')
- return typ
+def device(request) -> torch.device:
+ _device_type: str = request.config.getoption('--typetest')
+ return TEST_DEVICES[_device_type]