From 10392644e30e24754eeee1cefb018add3d31a3fa Mon Sep 17 00:00:00 2001 From: Maxim Vafin Date: Wed, 26 Apr 2023 18:24:38 +0200 Subject: [PATCH] [PT FE] Enable stable sort layer tests (#17229) * [PT FE] Enable stable sort layer tests * Remove unused code --- tests/layer_tests/pytorch_tests/test_sort.py | 52 +++++++++----------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/tests/layer_tests/pytorch_tests/test_sort.py b/tests/layer_tests/pytorch_tests/test_sort.py index f68ce270743..c2f6243bb81 100644 --- a/tests/layer_tests/pytorch_tests/test_sort.py +++ b/tests/layer_tests/pytorch_tests/test_sort.py @@ -7,13 +7,6 @@ import pytest from pytorch_layer_test_class import PytorchLayerTest -def not_yet_supported(value): - return pytest.param( - value, - marks = pytest.mark.xfail( - reason="Failed due to aten::sort not yet supporting stable sorting. Ticket 105242" - ), - ) class TestSortConstants(PytorchLayerTest): def _prepare_input(self): @@ -29,16 +22,16 @@ class TestSortConstants(PytorchLayerTest): def forward(self, input_tensor): if self.stable is not None: - return torch.sort(input_tensor, - stable = self.stable, - dim = self.dim, - descending = self.descending - )[0] + return torch.sort(input_tensor, + stable=self.stable, + dim=self.dim, + descending=self.descending + )[0] else: - return torch.sort(input_tensor, - dim = self.dim, - descending = self.descending - )[0] + return torch.sort(input_tensor, + dim=self.dim, + descending=self.descending + )[0] ref_net = None return aten_sort(dim, descending, stable), ref_net, "aten::sort" @@ -57,31 +50,31 @@ class TestSortConstants(PytorchLayerTest): np.array([[9, 8, 8], [8, 7, 7], [7, 5, 6], [8, 8, 9], [7, 7, 8], [6, 5, 7], [8, 9, 8], [7, 8, 7], [5, 6, 7]]), - np.array([[[1, 2, 3], [4, 5, 6], [7, 8, 9]], - [[5, 2, 4], [4, 9, 0], [7, 7, 9]], + np.array([[[1, 2, 3], [4, 5, 6], [7, 8, 9]], + [[5, 2, 4], [4, 9, 0], [7, 7, 9]], [[5, 2, 4], [4, 9, 0], [7, 7, 9]]]), - np.array([[[3, 2, 2], [1, 2, 1], [3, 2, 2]], - [[1, 2, 1], [4, 3, 4], [3, 2, 2]], + np.array([[[3, 2, 2], [1, 2, 1], [3, 2, 2]], + [[1, 2, 1], [4, 3, 4], [3, 2, 2]], [[3, 2, 2], [1, 2, 1], [7, 9, 9]]]), - np.array([[[2, 1, 3], [3, 2, 1], [1, 2, 3]], - [[2, 0, 2], [1, 2, 1], [3, 2, 8]], + np.array([[[2, 1, 3], [3, 2, 1], [1, 2, 3]], + [[2, 0, 2], [1, 2, 1], [3, 2, 8]], [[3, 2, 2], [3, 2, 1], [1, 2, 3]], - [[2, 1, 3], [3, 2, 1], [1, 2, 3]], - [[2, 0, 2], [1, 2, 1], [3, 2, 8]], + [[2, 1, 3], [3, 2, 1], [1, 2, 3]], + [[2, 0, 2], [1, 2, 1], [3, 2, 8]], [[3, 2, 2], [3, 2, 1], [1, 2, 3]], - [[2, 1, 3], [3, 2, 1], [1, 2, 3]], - [[2, 0, 2], [1, 2, 1], [3, 2, 8]], + [[2, 1, 3], [3, 2, 1], [1, 2, 3]], + [[2, 0, 2], [1, 2, 1], [3, 2, 8]], [[3, 2, 2], [3, 2, 1], [1, 2, 3]]]) ]) @pytest.mark.parametrize("descending", [ True, - False + False ]) @pytest.mark.parametrize("stable", [ False, None, - not_yet_supported(True) + True ]) @pytest.mark.nightly @pytest.mark.precommit @@ -89,4 +82,5 @@ class TestSortConstants(PytorchLayerTest): self.input_tensor = input_tensor dims = len(input_tensor.shape) for dim in range(-dims, dims): - self._test(*self.create_model(dim, descending, stable), ie_device, precision, ir_version) + self._test(*self.create_model(dim, descending, stable), + ie_device, precision, ir_version)