[PT FE] Enable stable sort layer tests (#17229)

* [PT FE] Enable stable sort layer tests

* Remove unused code
This commit is contained in:
Maxim Vafin authored and GitHub committed 2023-04-26 18:24:38 +02:00
1 parent 80519162ae
commit 10392644e3
1 file changed
+23 -29
+23 -29
View File
@@ -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)