Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[PT FE] Enable layer tests on Windows (#26332)

Maxim Vafind74a39240a55
diff --git a/.github/workflows/windows_vs2019_release.yml b/.github/workflows/windows_vs2019_release.yml
index 4abf546be80..a1ff614672c 100644
--- a/.github/workflows/windows_vs2019_release.yml
+++ b/.github/workflows/windows_vs2019_release.yml
@@ -315,14 +315,15 @@ jobs:
# layer test requirements
python3 -m pip install -r ${{ env.LAYER_TESTS_INSTALL_DIR }}/requirements.txt
- # Ticket - 115085
- name: PyTorch Layer Tests
- if: ${{ 'false' }}
+ if: fromJSON(needs.smart_ci.outputs.affected_components).PyTorch_FE.test
shell: cmd
run: |
- python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/pytorch_tests -n logical -m precommit --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-pytorch.xml
+ # parallelizing with xdict leads to segfaults
+ python3 -m pytest ${{ env.LAYER_TESTS_INSTALL_DIR }}/pytorch_tests -m precommit --junitxml=${{ env.INSTALL_TEST_DIR }}/TEST-pytorch.xml
env:
TEST_DEVICE: CPU
+ TEST_PRECISION: FP32
- name: ONNX Layer Tests
if: fromJSON(needs.smart_ci.outputs.affected_components).ONNX_FE.test
diff --git a/tests/layer_tests/pytorch_tests/test_gather.py b/tests/layer_tests/pytorch_tests/test_gather.py
index 4693ddaa90a..bc861af2b77 100644
--- a/tests/layer_tests/pytorch_tests/test_gather.py
+++ b/tests/layer_tests/pytorch_tests/test_gather.py
@@ -6,10 +6,10 @@ import pytest
from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
-class TestGelu(PytorchLayerTest):
+class TestGather(PytorchLayerTest):
def _prepare_input(self, m, n, max_val, out=False):
import numpy as np
- index = np.random.randint(0, max_val, (m, n))
+ index = np.random.randint(0, max_val, (m, n)).astype(np.int64)
inp = np.random.randn(m, n).astype(np.float32)
if out:
axis = int(max_val == n)
diff --git a/tests/layer_tests/pytorch_tests/test_take_along_dim.py b/tests/layer_tests/pytorch_tests/test_take_along_dim.py
index 57e02ec9f09..93e80df002b 100644
--- a/tests/layer_tests/pytorch_tests/test_take_along_dim.py
+++ b/tests/layer_tests/pytorch_tests/test_take_along_dim.py
@@ -5,12 +5,13 @@ from pytorch_layer_test_class import PytorchLayerTest
class TestTakeAlongDim(PytorchLayerTest):
def _prepare_input(self, m, n, max_val, out=False, flattenize=False):
import numpy as np
- index = np.random.randint(0, max_val, (m, n) if not flattenize else (m*n, ))
+ shape = (m, n) if not flattenize else (m * n,)
+ index = np.random.randint(0, max_val, shape).astype(np.int64)
inp = np.random.randn(m, n).astype(np.float32)
if out:
axis = int(max_val == n)
if flattenize:
- out = np.zeros_like(np.take(inp, index))
+ out = np.zeros_like(np.take(inp, index))
else:
out = np.zeros_like(np.take(inp, index, axis))
return (inp, index, out)
@@ -40,9 +41,7 @@ class TestTakeAlongDim(PytorchLayerTest):
def forward_no_dim_out(self, x, index, out):
return torch.take_along_dim(x, index, out=out)
- ref_net = None
-
- return aten_take_along_dim(axis, out), ref_net, "aten::take_along_dim"
+ return aten_take_along_dim(axis, out), None, "aten::take_along_dim"
@pytest.mark.nightly
@pytest.mark.precommit
diff --git a/tests/layer_tests/pytorch_tests/test_topk.py b/tests/layer_tests/pytorch_tests/test_topk.py
index cee8c103ab7..f6d1d85b086 100644
--- a/tests/layer_tests/pytorch_tests/test_topk.py
+++ b/tests/layer_tests/pytorch_tests/test_topk.py
@@ -62,7 +62,6 @@ class TestTopK(PytorchLayerTest):
@pytest.mark.nightly
@pytest.mark.precommit
@pytest.mark.precommit_fx_backend
- @pytest.mark.skipif(os.getenv("GITHUB_ACTIONS") == 'true', reason="Ticket - 115085")
def test_topK(self, input_shape, k, dim, largest, sort, ie_device, precision, ir_version):
self.input_tensor = np.random.randn(*input_shape).astype(np.float32)
self._test(*self.create_model(k, dim, largest, sort), ie_device, precision, ir_version)
diff --git a/tests/layer_tests/pytorch_tests/test_unique.py b/tests/layer_tests/pytorch_tests/test_unique.py
index bd4f852ea95..0665ee5e83a 100644
--- a/tests/layer_tests/pytorch_tests/test_unique.py
+++ b/tests/layer_tests/pytorch_tests/test_unique.py
@@ -3,8 +3,11 @@
import pytest
import numpy as np
+from packaging.version import parse as parse_version
+import torch
+import sys
-from pytorch_layer_test_class import PytorchLayerTest, skip_if_export
+from pytorch_layer_test_class import PytorchLayerTest
class TestUnique2(PytorchLayerTest):
@@ -54,7 +57,6 @@ class TestUnique2(PytorchLayerTest):
result, _, _ = self.op(x, self.sorted, False, False)
return result
- ref_net = None
if return_inverse and return_counts:
model_class, op = (aten_unique2_return_both, "aten::_unique2")
elif return_inverse:
@@ -64,7 +66,7 @@ class TestUnique2(PytorchLayerTest):
else:
model_class, op = (aten_unique2_return_neither, "aten::_unique2")
- return model_class(sorted), ref_net, op
+ return model_class(sorted), None, op
@pytest.mark.parametrize("input_shape", [
[115], [24, 30], [5, 4, 6], [3, 7, 1, 4], [16, 3, 32, 32]
@@ -75,5 +77,7 @@ class TestUnique2(PytorchLayerTest):
@pytest.mark.nightly
@pytest.mark.precommit
def test_unique2(self, input_shape, sorted, return_inverse, return_counts, ie_device, precision, ir_version):
+ if sys.platform == "win32" and input_shape == [16, 3, 32, 32] and parse_version(torch.__version__).release == (2, 4, 0):
+ pytest.skip(reason="torch==2.4.0 fails on windows, but is fixed in nightly.")
self.input_tensor = np.random.randint(0, 10, size=input_shape).astype(np.int32)
self._test(*self.create_model(sorted, return_inverse, return_counts), ie_device, precision, ir_version)