π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
Add mps to testing init and fixing test cases (#2428)
Nripesh Niketand2dc9e8a3a3c
diff --git a/kornia/testing/__init__.py b/kornia/testing/__init__.pyindex 3c32607b2..cb70f3af7 100644--- a/kornia/testing/__init__.py+++ b/kornia/testing/__init__.py@@ -237,7 +237,7 @@ def _get_precision(device: torch.device, dtype: torch.dtype) -> float:def _get_precision_by_name(device: torch.device, device_target: str, tol_val: float, tol_val_default: float = 1e-4) -> float:- if device_target not in ['cpu', 'cuda', 'xla']:+ if device_target not in ['cpu', 'cuda', 'xla', 'mps']:raise ValueError(f"Invalid device name: {device_target}.")if device_target in device.type:diff --git a/test/geometry/test_homography.py b/test/geometry/test_homography.pyindex bdc4b42f3..b8fa815de 100644--- a/test/geometry/test_homography.py+++ b/test/geometry/test_homography.py@@ -1,3 +1,5 @@+import sys+import pytestimport torchfrom torch.autograd import gradcheck@@ -15,6 +17,7 @@ from kornia.geometry.homography import (symmetric_transfer_error,)from kornia.testing import assert_close+from kornia.utils._compat import torch_version_leclass TestSampleValidation:@@ -391,6 +394,9 @@ class TestFindHomographyDLTIter:assert H.shape == (1, 3, 3)@pytest.mark.parametrize("batch_size, num_points", [(1, 4), (2, 5), (3, 6)])+ @pytest.mark.skipif(+ sys.platform == "darwin" and torch_version_le(1, 9, 1), reason="Known bug in torch 1.9.1 on macos"+ )def test_shape(self, batch_size, num_points, device, dtype):B, N = batch_size, num_pointspoints1 = torch.rand(B, N, 2, device=device, dtype=dtype)