🐍 Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
bump pytorch version to 2.1.0 (#2605)
João Gustavo A. Amorim29a7066d7fcf
diff --git a/.github/actions/env/action.yml b/.github/actions/env/action.ymlindex c7067c2d5..8aaca7218 100644--- a/.github/actions/env/action.yml+++ b/.github/actions/env/action.yml@@ -12,7 +12,7 @@ on:pytorch-version:description: "The pytorch version desired."required: true- default: '2.0.1'+ default: '2.1.0'type: stringruns:diff --git a/.github/actions_info.md b/.github/actions_info.mdindex 51ad5e385..aa200cd86 100644--- a/.github/actions_info.md+++ b/.github/actions_info.md@@ -13,7 +13,7 @@ Use the actions:Has the inputs:- `python-version`: (string, default: `'3.10'`) the python version desired.- The version should be supported by `setup-python@v4` action.-- `pytorch-version`: (string, default: `'2.0.1`') the pytorch version desired.+- `pytorch-version`: (string, default: `'2.1.0`') the pytorch version desired.- This value will be used to install pytorch using conda from pytorchchannel.- If the value passed is `nightly` the nightly version of pytorch with dynamo@@ -35,7 +35,7 @@ Has the inputs:- `os`: (string, default: `ubuntu-latest`) the OS name same as supported by [gha](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners).- `python-version`: (json list of strings, default: `'["3.10"]'`) a string withformat of a json list within strings for each python version desired.-- `pytorch-version`: (json list of strings, default: `'["2.0.1"]'`) a string+- `pytorch-version`: (json list of strings, default: `'["2.1.0"]'`) a stringwith format of a json list within strings for each pytorch version desired.- `pytorch-dtype`: (string, default: `float32`) the dtype used to generatethe tests with pytest.@@ -60,7 +60,7 @@ Has the inputs:- `os`: (string, default: `ubuntu-latest`) the OS name same as supported by [gha](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners).- `python-version`: (json list of strings, default: `'["3.10"]'`) a string withformat of a json list within strings for each python version desired.-- `pytorch-version`: (json list of strings, default: `'["2.0.1"]'`) a string+- `pytorch-version`: (json list of strings, default: `'["2.1.0"]'`) a stringwith format of a json list within strings for each pytorch version desired.- `fail-fast`: (boolean, default: `false`) to set the `fail-fast` behavior onthe matrix strategy.@@ -80,7 +80,7 @@ Has the inputs:- `os`: (string, default: `ubuntu-latest`) the OS name same as supported by [gha](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners).- `python-version`: (json list of strings, default: `'["3.10"]'`) a string withformat of a json list within strings for each python version desired.-- `pytorch-version`: (json list of strings, default: `'["2.0.1"]'`) a string+- `pytorch-version`: (json list of strings, default: `'["2.1.0"]'`) a stringwith format of a json list within strings for each pytorch version desired.- `fail-fast`: (boolean, default: `false`) to set the `fail-fast` behavior onthe matrix strategy.diff --git a/.github/workflows/pr_test_cpu.yml b/.github/workflows/pr_test_cpu.ymlindex f71461ac6..988e0551a 100644--- a/.github/workflows/pr_test_cpu.yml+++ b/.github/workflows/pr_test_cpu.yml@@ -30,15 +30,16 @@ jobs:with:os: ${{ matrix.os }}python-version: '["3.8", "3.10"]'- pytorch-version: '["1.9.1", "2.0.1"]'+ pytorch-version: '["1.9.1", "2.1.0"]'pytorch-dtype: ${{ matrix.pytorch-dtype }}+tests-coverage:# This job run all test suiteuses: ./.github/workflows/tests.ymlwith:python-version: '["3.10"]'- pytorch-version: '["2.0.1"]'+ pytorch-version: '["2.1.0"]'pytorch-dtype: 'float32,float64'coverage: truepytest-extra: '--runslow'diff --git a/.github/workflows/scheduled_test_cpu.yml b/.github/workflows/scheduled_test_cpu.ymlindex 3dc384aec..8780ea24f 100644--- a/.github/workflows/scheduled_test_cpu.yml+++ b/.github/workflows/scheduled_test_cpu.yml@@ -22,7 +22,7 @@ jobs:with:os: 'Ubuntu-latest'python-version: '["3.8", "3.9", "3.10"]'- pytorch-version: '["1.9.1", "1.10.2", "1.11.0", "1.12.1", "1.13.1", "2.0.1"]'+ pytorch-version: '["1.9.1", "1.10.2", "1.11.0", "1.12.1", "1.13.1", "2.0.1", "2.1.0"]'pytorch-dtype: ${{ matrix.pytorch-dtype }}pytest-extra: '--runslow'@@ -38,7 +38,7 @@ jobs:with:os: 'Windows-latest'python-version: '["3.10"]'- pytorch-version: '["1.9.1", "2.0.1"]'+ pytorch-version: '["1.9.1", "2.1.0"]'pytorch-dtype: ${{ matrix.pytorch-dtype }}tests-cpu-mac:@@ -62,7 +62,7 @@ jobs:uses: ./.github/workflows/tests.ymlwith:python-version: '["3.10"]'- pytorch-version: '["2.0.1"]'+ pytorch-version: '["2.1.0"]'pytorch-dtype: 'float32,float64'coverage: truecontinue-on-error: truediff --git a/.github/workflows/scheduled_test_cpu_half.yml b/.github/workflows/scheduled_test_cpu_half.ymlindex 47b3ff8b8..99ad92a55 100644--- a/.github/workflows/scheduled_test_cpu_half.yml+++ b/.github/workflows/scheduled_test_cpu_half.yml@@ -21,5 +21,5 @@ jobs:with:os: ${{ matrix.os }}python-version: '["3.8", , "3.10"]' # "3.9"- pytorch-version: '["2.0.1"]' # '["1.9.1", "1.10.2", "1.11.0", "1.12.1", "1.13.1"]'+ pytorch-version: '["2.1.0"]' # '["1.9.1", "1.10.2", "1.11.0", "1.12.1", "1.13.1"]'pytorch-dtype: 'float16'diff --git a/.github/workflows/test_tutorials.yml b/.github/workflows/test_tutorials.ymlindex 7cc598e99..ec27731a7 100644--- a/.github/workflows/test_tutorials.yml+++ b/.github/workflows/test_tutorials.yml@@ -8,7 +8,7 @@ on:pytorch-version:required: falsetype: string- default: '["2.0.1"]'+ default: '["2.1.0"]'os:required: falsetype: stringdiff --git a/.github/workflows/test_typing.yml b/.github/workflows/test_typing.ymlindex c450fab94..3b36452a4 100644--- a/.github/workflows/test_typing.yml+++ b/.github/workflows/test_typing.yml@@ -8,7 +8,7 @@ on:pytorch-version:required: falsetype: string- default: '["2.0.1"]'+ default: '["2.1.0"]'os:required: falsetype: stringdiff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex b5c13e4cf..1d6097b85 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -8,7 +8,7 @@ on:pytorch-version:required: falsetype: string- default: '["2.0.1"]'+ default: '["2.1.0"]'os:required: falsetype: stringdiff --git a/kornia/augmentation/auto/operations/base.py b/kornia/augmentation/auto/operations/base.pyindex a1299f15e..29ea4d061 100644--- a/kornia/augmentation/auto/operations/base.py+++ b/kornia/augmentation/auto/operations/base.py@@ -159,7 +159,7 @@ class OperationBase(Module):@propertydef transform_matrix(self) -> Optional[Tensor]:if hasattr(self.op, "transform_matrix"):- return self.op.transform_matrix # type:ignore+ return self.op.transform_matrixreturn None@propertydiff --git a/kornia/augmentation/auto/operations/policy.py b/kornia/augmentation/auto/operations/policy.pyindex 20b00f47a..475cf38a3 100644--- a/kornia/augmentation/auto/operations/policy.py+++ b/kornia/augmentation/auto/operations/policy.py@@ -25,7 +25,7 @@ class PolicySequential(TransformMatrixMinIn, ImageSequentialBase):self._valid_ops_for_transform_computation: Tuple[Any, ...] = (OperationBase,)def _update_transform_matrix_for_valid_op(self, module: Module) -> None:- self._transform_matrices.append(module.transform_matrix) # type: ignore+ self._transform_matrices.append(module.transform_matrix)def clear_state(self) -> None:self._reset_transform_matrix_state()diff --git a/kornia/augmentation/container/augment.py b/kornia/augmentation/container/augment.pyindex 3dcf1c6b5..164a52105 100644--- a/kornia/augmentation/container/augment.py+++ b/kornia/augmentation/container/augment.py@@ -208,7 +208,7 @@ class AugmentationSequential(TransformMatrixMinIn, ImageSequential):return super().clear_state()def _update_transform_matrix_for_valid_op(self, module: Module) -> None:- self._transform_matrices.append(module.transform_matrix) # type: ignore+ self._transform_matrices.append(module.transform_matrix)def identity_matrix(self, input: Tensor) -> Tensor:"""Return identity matrix."""diff --git a/kornia/feature/lightglue.py b/kornia/feature/lightglue.pyindex 68c5f499b..12626321f 100644--- a/kornia/feature/lightglue.py+++ b/kornia/feature/lightglue.py@@ -97,12 +97,12 @@ class Attention(Module):m = self.flash_(q.half(), stack([k, v], 2).half())return m.transpose(-2, -3).to(q.dtype)else: # use torch 2.0 scaled_dot_product_attention with flash- args = [x.half().contiguous() for x in [q, k, v]]with torch.backends.cuda.sdp_kernel(enable_flash=True):- return F.scaled_dot_product_attention(*args).to(q.dtype)+ return F.scaled_dot_product_attention(+ q.half().contiguous(), k.half().contiguous(), v.half().contiguous()+ ).to(q.dtype)elif hasattr(F, 'scaled_dot_product_attention'):- args = [x.contiguous() for x in [q, k, v]]- return F.scaled_dot_product_attention(*args).to(q.dtype)+ return F.scaled_dot_product_attention(q.contiguous(), k.contiguous(), v.contiguous()).to(q.dtype)else:s = q.shape[-1] ** -0.5attn = softmax(einsum('...id,...jd->...ij', q, k) * s, -1)diff --git a/test/augmentation/test_container.py b/test/augmentation/test_container.pyindex 7e853bbb4..5dfa2f6be 100644--- a/test/augmentation/test_container.py+++ b/test/augmentation/test_container.py@@ -514,6 +514,7 @@ class TestAugmentationSequential:_, out_labels = aug(img, labels)assert labels is out_labels+ @pytest.mark.slow@pytest.mark.parametrize('random_apply', [1, (2, 2), (1, 2), (2,), 10, True, False])def test_forward_and_inverse(self, random_apply, device, dtype):inp = torch.randn(1, 3, 1000, 500, device=device, dtype=dtype)@@ -628,6 +629,7 @@ class TestAugmentationSequential:assert out_inv[2].shape == bbox.shapeassert out_inv[3].shape == keypoints.shape+ @pytest.mark.slow@pytest.mark.parametrize('random_apply', [1, (2, 2), (1, 2), (2,), 10, True, False])def test_inverse_and_forward_return_transform(self, random_apply, device, dtype):inp = torch.randn(1, 3, 1000, 500, device=device, dtype=dtype)diff --git a/test/contrib/models/test_tiny_vit.py b/test/contrib/models/test_tiny_vit.pyindex 113f4cfbe..38dd18f35 100644--- a/test/contrib/models/test_tiny_vit.py+++ b/test/contrib/models/test_tiny_vit.py@@ -15,6 +15,7 @@ class TestTinyViT(BaseTester):out = model(inpt)assert isinstance(out, Tensor)+ @pytest.mark.slow@pytest.mark.parametrize('num_classes', [10, 100])@pytest.mark.parametrize('batch_size', [1, 3])def test_cardinality(self, device, dtype, batch_size, num_classes):diff --git a/test/filters/test_guided.py b/test/filters/test_guided.pyindex b202aee3e..32e2625b3 100644--- a/test/filters/test_guided.py+++ b/test/filters/test_guided.py@@ -3,6 +3,7 @@ import torchfrom kornia.filters import GuidedBlur, guided_blurfrom kornia.testing import BaseTester, tensor_to_gradcheck_var+from kornia.utils._compat import torch_versionclass TestGuidedBlur(BaseTester):@@ -88,6 +89,13 @@ class TestGuidedBlur(BaseTester):op_module = GuidedBlur(kernel_size, eps, subsample=subsample)self.assert_close(op_module(guide, img), op(guide, img, kernel_size, eps, subsample=subsample))+ @pytest.mark.skipif(+ torch_version() == '2.1.0',+ reason=(+ "https://github.com/pytorch/pytorch/issues/110696 "+ "- Failing with: Argument of Integer should be of numeric type, got s3 + 3."+ ),+ )@pytest.mark.parametrize('kernel_size', [5, (5, 7)])@pytest.mark.parametrize("subsample", [1, 2])def test_dynamo(self, kernel_size, subsample, device, dtype, torch_optimizer):diff --git a/test/geometry/transform/test_crop3d.py b/test/geometry/transform/test_crop3d.pyindex eb764c202..1ede77f45 100644--- a/test/geometry/transform/test_crop3d.py+++ b/test/geometry/transform/test_crop3d.py@@ -5,6 +5,7 @@ from torch.autograd import gradcheckimport korniaimport kornia.testing as utils # test utilsfrom kornia.testing import assert_close+from kornia.utils._compat import torch_versionclass TestCropAndResize3D:@@ -131,6 +132,13 @@ class TestCenterCrop3D:kornia.geometry.transform.center_crop3d, (img, (3, 5, 7)), raise_exception=True, fast_mode=True)+ @pytest.mark.skipif(+ torch_version() == '2.1.0',+ reason=(+ "https://github.com/pytorch/pytorch/issues/110680"+ " - unsupported operand type(s) for @: 'FakeTensor' and 'FakeTensor' on `normalize_homography3d`"+ ),+ )def test_dynamo(self, device, dtype, torch_optimizer):# Define scriptop = kornia.geometry.transform.center_crop3ddiff --git a/test/integration/test_focal.py b/test/integration/test_focal.pyindex 426125673..98b51d58c 100644--- a/test/integration/test_focal.py+++ b/test/integration/test_focal.py@@ -31,6 +31,7 @@ class TestIntegrationFocalLoss:if isinstance(m, nn.Conv2d):torch.nn.init.xavier_uniform_(m.weight)+ @pytest.mark.slowdef test_conv2d_relu(self, device):# we generate base sampletarget = torch.LongTensor(1, 6, 5).fill_(0).to(device)