Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

Added first tests checking cpu / gpu

Carlos Bf464e18ec60e
diff --git a/conftest.py b/conftest.py
new file mode 100644
index 000000000..bd0e0ad29
--- /dev/null
+++ b/conftest.py
@@ -0,0 +1,5 @@
+import pytest
+
+
+def pytest_addoption(parser):
+ parser.addoption('--typetest', action="store", default="cpu")
diff --git a/test/common.py b/test/common.py
index 1ed369413..0051a8848 100644
--- a/test/common.py
+++ b/test/common.py
@@ -1,4 +1,5 @@
import torch
+import pytest
def get_test_devices():
@@ -17,3 +18,9 @@ def get_test_devices():
# setup the devices to test the source code
TEST_DEVICES = get_test_devices()
+
+
+def device_type(request):
+ typ = request.config.getoption('--typetest')
+ return typ
diff --git a/test/test_losses.py b/test/test_losses.py
index f4decd958..23ae5cf88 100644
--- a/test/test_losses.py
+++ b/test/test_losses.py
@@ -5,7 +5,7 @@ import torchgeometry as tgm
from torch.autograd import gradcheck
import utils
-from common import TEST_DEVICES
+from common import device_type
class TestFocalLoss:
@@ -200,7 +200,6 @@ class TestDepthSmoothnessLoss:
assert gradcheck(tgm.losses.depth_smoothness_loss,
(depth, image,), raise_exception=True)
- @pytest.mark.parametrize("device_type", TEST_DEVICES)
@pytest.mark.parametrize("batch_shape",
[(1, 1, 10, 16), (2, 4, 8, 15), ])
def test_run_all(self, batch_shape, device_type):
@@ -213,7 +212,6 @@ class TestDepthSmoothnessLoss:
@pytest.mark.parametrize("window_size", [5, 11])
@pytest.mark.parametrize("reduction_type", ['none', 'mean', 'sum'])
[email protected]("device_type", TEST_DEVICES)
@pytest.mark.parametrize("batch_shape",
[(1, 1, 10, 16), (2, 4, 8, 15), ])
def test_ssim(batch_shape, device_type, window_size, reduction_type):