From b139531bf7ccc53c369f2a5a9412449e5b8c17d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81kos=20Hadnagy?= Date: Sun, 20 Jul 2025 14:34:33 -0500 Subject: [PATCH 1/4] Add AMD test expectations to DETR model --- tests/models/detr/test_modeling_detr.py | 175 +++++++++++++++++++----- 1 file changed, 140 insertions(+), 35 deletions(-) diff --git a/tests/models/detr/test_modeling_detr.py b/tests/models/detr/test_modeling_detr.py index 2af2ca92115f..2ad9a9efccb7 100644 --- a/tests/models/detr/test_modeling_detr.py +++ b/tests/models/detr/test_modeling_detr.py @@ -18,7 +18,7 @@ import unittest from transformers import DetrConfig, ResNetConfig, is_torch_available, is_vision_available -from transformers.testing_utils import require_timm, require_torch, require_vision, slow, torch_device +from transformers.testing_utils import Expectations, require_timm, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property from ...test_configuration_common import ConfigTester @@ -585,13 +585,35 @@ def test_inference_no_head(self): expected_shape = torch.Size((1, 100, 256)) assert outputs.last_hidden_state.shape == expected_shape - expected_slice = torch.tensor( - [ - [0.0622, -0.5142, -0.4034], - [-0.7628, -0.4935, -1.7153], - [-0.4751, -0.6386, -0.7818], - ] - ).to(torch_device) + expected_slices = Expectations( + { + ("xpu", 3): torch.tensor( + [ + [0.0622, -0.5142, -0.4034], + [-0.7628, -0.4935, -1.7153], + [-0.4751, -0.6386, -0.7818], + ], device=torch_device), + ("cuda", 7): torch.tensor( + [ + [0.0622, -0.5142, -0.4034], + [-0.7628, -0.4935, -1.7153], + [-0.4751, -0.6386, -0.7818], + ], device=torch_device), + ("cuda", 8): torch.tensor( + [ + [0.0622, -0.5142, -0.4034], + [-0.7628, -0.4935, -1.7153], + [-0.4751, -0.6386, -0.7818], + ], device=torch_device), + ("rocm", (9, 5)): torch.tensor( + [ + [ 0.0616, -0.5146, -0.4032], + [-0.7629, -0.4934, -1.7153], + [-0.4768, -0.6403, -0.7826] + ], device=torch_device), + } + ) # fmt: skip + expected_slice = expected_slices.get_expectation() torch.testing.assert_close(outputs.last_hidden_state[0, :3, :3], expected_slice, rtol=2e-4, atol=2e-4) def test_inference_object_detection_head(self): @@ -609,13 +631,36 @@ def test_inference_object_detection_head(self): # verify outputs expected_shape_logits = torch.Size((1, model.config.num_queries, model.config.num_labels + 1)) self.assertEqual(outputs.logits.shape, expected_shape_logits) - expected_slice_logits = torch.tensor( - [ - [-19.1211, -0.0881, -11.0188], - [-17.3641, -1.8045, -14.0229], - [-20.0415, -0.5833, -11.1005], - ] - ).to(torch_device) + expected_slices = Expectations( + { + ("xpu", 3): torch.tensor( + [ + [-19.1211, -0.0881, -11.0188], + [-17.3641, -1.8045, -14.0229], + [-20.0415, -0.5833, -11.1005], + ], device=torch_device), + ("cuda", 7): torch.tensor( + [ + [-19.1211, -0.0881, -11.0188], + [-17.3641, -1.8045, -14.0229], + [-20.0415, -0.5833, -11.1005], + ], device=torch_device), + ("cuda", 8): torch.tensor( + [ + [-19.1211, -0.0881, -11.0188], + [-17.3641, -1.8045, -14.0229], + [-20.0415, -0.5833, -11.1005], + ], device=torch_device), + ("rocm", (9, 5)): torch.tensor( + [ + [-19.1194, -0.0893, -11.0154], + [-17.3640, -1.8035, -14.0219], + [-20.0461, -0.5837, -11.1060] + ], device=torch_device), + } + ) # fmt: skip + expected_slice_logits = expected_slices.get_expectation() + print(f"Generated: {outputs.logits[0, :3, :3]}") torch.testing.assert_close(outputs.logits[0, :3, :3], expected_slice_logits, rtol=2e-4, atol=2e-4) expected_shape_boxes = torch.Size((1, model.config.num_queries, 4)) @@ -657,27 +702,65 @@ def test_inference_panoptic_segmentation_head(self): # verify outputs expected_shape_logits = torch.Size((1, model.config.num_queries, model.config.num_labels + 1)) self.assertEqual(outputs.logits.shape, expected_shape_logits) - expected_slice_logits = torch.tensor( - [ - [-18.1523, -1.7592, -13.5019], - [-16.8866, -1.4139, -14.1025], - [-17.5735, -2.5090, -11.8666], - ] - ).to(torch_device) + expected_slices = Expectations( + { + ("xpu", 3): torch.tensor( + [ + [0.0622, -0.5142, -0.4034], + [-0.7628, -0.4935, -1.7153], + [-0.4751, -0.6386, -0.7818], + ], device=torch_device), + ("cuda", 7): torch.tensor( + [ + [0.0622, -0.5142, -0.4034], + [-0.7628, -0.4935, -1.7153], + [-0.4751, -0.6386, -0.7818], + ], device=torch_device), + ("cuda", 8): torch.tensor( + [ + [0.0622, -0.5142, -0.4034], + [-0.7628, -0.4935, -1.7153], + [-0.4751, -0.6386, -0.7818], + ], device=torch_device), + ("rocm", (9, 5)): torch.tensor( + [ + [-18.1565, -1.7568, -13.5029], + [-16.8888, -1.4138, -14.1028], + [-17.5709, -2.5080, -11.8654] + ], device=torch_device), + } + ) # fmt: skip + expected_slice_logits = expected_slices.get_expectation() + print(f"Generated: {outputs.logits[0, :3, :3]}") torch.testing.assert_close(outputs.logits[0, :3, :3], expected_slice_logits, rtol=2e-4, atol=2e-4) expected_shape_boxes = torch.Size((1, model.config.num_queries, 4)) self.assertEqual(outputs.pred_boxes.shape, expected_shape_boxes) - expected_slice_boxes = torch.tensor( - [[0.5344, 0.1790, 0.9284], [0.4421, 0.0571, 0.0875], [0.6632, 0.6886, 0.1015]] - ).to(torch_device) + expected_slices = Expectations( + { + ("xpu", 3): torch.tensor([[0.5344, 0.1790, 0.9284], [0.4421, 0.0571, 0.0875], [0.6632, 0.6886, 0.1015]], device=torch_device), + ("cuda", 7): torch.tensor([[0.5344, 0.1790, 0.9284], [0.4421, 0.0571, 0.0875], [0.6632, 0.6886, 0.1015]], device=torch_device), + ("cuda", 8): torch.tensor([[0.5344, 0.1790, 0.9284], [0.4421, 0.0571, 0.0875], [0.6632, 0.6886, 0.1015]], device=torch_device), + ("rocm", (9, 5)): torch.tensor([[0.5344, 0.1789, 0.9285], [0.4420, 0.0572, 0.0875], [0.6630, 0.6887, 0.1017]], device=torch_device), + } + ) # fmt: skip + expected_slice_boxes = expected_slices.get_expectation() + print(f"Generated boxes: {outputs.pred_boxes[0, :3, :3]}") torch.testing.assert_close(outputs.pred_boxes[0, :3, :3], expected_slice_boxes, rtol=2e-4, atol=2e-4) expected_shape_masks = torch.Size((1, model.config.num_queries, 200, 267)) self.assertEqual(outputs.pred_masks.shape, expected_shape_masks) - expected_slice_masks = torch.tensor( - [[-7.8408, -11.0104, -12.1279], [-12.0299, -16.6498, -17.9806], [-14.8995, -19.9940, -20.5646]] - ).to(torch_device) + expected_slices = Expectations( + { + ("xpu", 3): torch.tensor([[-7.8408, -11.0104, -12.1279], [-12.0299, -16.6498, -17.9806], [-14.8995, -19.9940, -20.5646]], device=torch_device), + ("cuda", 7): torch.tensor([[-7.8408, -11.0104, -12.1279], [-12.0299, -16.6498, -17.9806], [-14.8995, -19.9940, -20.5646]], device=torch_device), + ("cuda", 8): torch.tensor([[-7.8408, -11.0104, -12.1279], [-12.0299, -16.6498, -17.9806], [-14.8995, -19.9940, -20.5646]], device=torch_device), + ("rocm", (9, 5)): torch.tensor([[ -7.7558, -10.8789, -11.9798], [-11.8882, -16.4330, -17.7452], [-14.7317, -19.7384, -20.3005]], device=torch_device), + } + ) # fmt: skip + expected_slice_masks = expected_slices.get_expectation() + + print(f"Generated masks: {outputs.pred_masks[0, 0, :3, :3]}") torch.testing.assert_close(outputs.pred_masks[0, 0, :3, :3], expected_slice_masks, rtol=2e-3, atol=2e-3) # verify postprocessing @@ -731,11 +814,33 @@ def test_inference_no_head(self): expected_shape = torch.Size((1, 100, 256)) assert outputs.last_hidden_state.shape == expected_shape - expected_slice = torch.tensor( - [ - [0.0622, -0.5142, -0.4034], - [-0.7628, -0.4935, -1.7153], - [-0.4751, -0.6386, -0.7818], - ] - ).to(torch_device) + expected_slices = Expectations( + { + ("xpu", 3): torch.tensor( + [ + [0.0622, -0.5142, -0.4034], + [-0.7628, -0.4935, -1.7153], + [-0.4751, -0.6386, -0.7818], + ], device=torch_device), + ("cuda", 7): torch.tensor( + [ + [0.0622, -0.5142, -0.4034], + [-0.7628, -0.4935, -1.7153], + [-0.4751, -0.6386, -0.7818], + ], device=torch_device), + ("cuda", 8): torch.tensor( + [ + [0.0622, -0.5142, -0.4034], + [-0.7628, -0.4935, -1.7153], + [-0.4751, -0.6386, -0.7818], + ], device=torch_device), + ("rocm", (9, 5)): torch.tensor( + [ + [ 0.0616, -0.5146, -0.4032], + [-0.7629, -0.4934, -1.7153], + [-0.4768, -0.6403, -0.7826] + ], device=torch_device), + } + ) # fmt: skip + expected_slice = expected_slices.get_expectation() torch.testing.assert_close(outputs.last_hidden_state[0, :3, :3], expected_slice, rtol=1e-4, atol=1e-4) From d845be71bf3b046dbaa33f78cea6f7b607f3c6ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81kos=20Hadnagy?= Date: Sun, 20 Jul 2025 14:36:40 -0500 Subject: [PATCH 2/4] Fix baseline expectation --- tests/models/detr/test_modeling_detr.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/models/detr/test_modeling_detr.py b/tests/models/detr/test_modeling_detr.py index 2ad9a9efccb7..e097c7bf9a59 100644 --- a/tests/models/detr/test_modeling_detr.py +++ b/tests/models/detr/test_modeling_detr.py @@ -706,21 +706,21 @@ def test_inference_panoptic_segmentation_head(self): { ("xpu", 3): torch.tensor( [ - [0.0622, -0.5142, -0.4034], - [-0.7628, -0.4935, -1.7153], - [-0.4751, -0.6386, -0.7818], + [-18.1523, -1.7592, -13.5019], + [-16.8866, -1.4139, -14.1025], + [-17.5735, -2.5090, -11.8666], ], device=torch_device), ("cuda", 7): torch.tensor( [ - [0.0622, -0.5142, -0.4034], - [-0.7628, -0.4935, -1.7153], - [-0.4751, -0.6386, -0.7818], + [-18.1523, -1.7592, -13.5019], + [-16.8866, -1.4139, -14.1025], + [-17.5735, -2.5090, -11.8666], ], device=torch_device), ("cuda", 8): torch.tensor( [ - [0.0622, -0.5142, -0.4034], - [-0.7628, -0.4935, -1.7153], - [-0.4751, -0.6386, -0.7818], + [-18.1523, -1.7592, -13.5019], + [-16.8866, -1.4139, -14.1025], + [-17.5735, -2.5090, -11.8666], ], device=torch_device), ("rocm", (9, 5)): torch.tensor( [ From 8aca6fbc520b77a942bbf4ba1eaae8adaf1561ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81kos=20Hadnagy?= Date: Mon, 21 Jul 2025 15:21:49 -0500 Subject: [PATCH 3/4] Address review comments --- tests/models/detr/test_modeling_detr.py | 109 ++++++------------------ 1 file changed, 26 insertions(+), 83 deletions(-) diff --git a/tests/models/detr/test_modeling_detr.py b/tests/models/detr/test_modeling_detr.py index e097c7bf9a59..a68e854efc30 100644 --- a/tests/models/detr/test_modeling_detr.py +++ b/tests/models/detr/test_modeling_detr.py @@ -587,33 +587,21 @@ def test_inference_no_head(self): assert outputs.last_hidden_state.shape == expected_shape expected_slices = Expectations( { - ("xpu", 3): torch.tensor( + (None, None): [ [0.0622, -0.5142, -0.4034], [-0.7628, -0.4935, -1.7153], [-0.4751, -0.6386, -0.7818], - ], device=torch_device), - ("cuda", 7): torch.tensor( - [ - [0.0622, -0.5142, -0.4034], - [-0.7628, -0.4935, -1.7153], - [-0.4751, -0.6386, -0.7818], - ], device=torch_device), - ("cuda", 8): torch.tensor( - [ - [0.0622, -0.5142, -0.4034], - [-0.7628, -0.4935, -1.7153], - [-0.4751, -0.6386, -0.7818], - ], device=torch_device), - ("rocm", (9, 5)): torch.tensor( + ], + ("rocm", (9, 5)): [ [ 0.0616, -0.5146, -0.4032], [-0.7629, -0.4934, -1.7153], [-0.4768, -0.6403, -0.7826] - ], device=torch_device), + ], } ) # fmt: skip - expected_slice = expected_slices.get_expectation() + expected_slice = torch.tensor(expected_slices.get_expectation(), device=torch_device) torch.testing.assert_close(outputs.last_hidden_state[0, :3, :3], expected_slice, rtol=2e-4, atol=2e-4) def test_inference_object_detection_head(self): @@ -633,34 +621,21 @@ def test_inference_object_detection_head(self): self.assertEqual(outputs.logits.shape, expected_shape_logits) expected_slices = Expectations( { - ("xpu", 3): torch.tensor( + (None, None): [ [-19.1211, -0.0881, -11.0188], [-17.3641, -1.8045, -14.0229], [-20.0415, -0.5833, -11.1005], - ], device=torch_device), - ("cuda", 7): torch.tensor( - [ - [-19.1211, -0.0881, -11.0188], - [-17.3641, -1.8045, -14.0229], - [-20.0415, -0.5833, -11.1005], - ], device=torch_device), - ("cuda", 8): torch.tensor( - [ - [-19.1211, -0.0881, -11.0188], - [-17.3641, -1.8045, -14.0229], - [-20.0415, -0.5833, -11.1005], - ], device=torch_device), - ("rocm", (9, 5)): torch.tensor( + ], + ("rocm", (9, 5)): [ [-19.1194, -0.0893, -11.0154], [-17.3640, -1.8035, -14.0219], [-20.0461, -0.5837, -11.1060] - ], device=torch_device), + ], } ) # fmt: skip - expected_slice_logits = expected_slices.get_expectation() - print(f"Generated: {outputs.logits[0, :3, :3]}") + expected_slice_logits = torch.tensor(expected_slices.get_expectation(), device=torch_device) torch.testing.assert_close(outputs.logits[0, :3, :3], expected_slice_logits, rtol=2e-4, atol=2e-4) expected_shape_boxes = torch.Size((1, model.config.num_queries, 4)) @@ -704,63 +679,43 @@ def test_inference_panoptic_segmentation_head(self): self.assertEqual(outputs.logits.shape, expected_shape_logits) expected_slices = Expectations( { - ("xpu", 3): torch.tensor( + (None, None): [ [-18.1523, -1.7592, -13.5019], [-16.8866, -1.4139, -14.1025], [-17.5735, -2.5090, -11.8666], - ], device=torch_device), - ("cuda", 7): torch.tensor( - [ - [-18.1523, -1.7592, -13.5019], - [-16.8866, -1.4139, -14.1025], - [-17.5735, -2.5090, -11.8666], - ], device=torch_device), - ("cuda", 8): torch.tensor( - [ - [-18.1523, -1.7592, -13.5019], - [-16.8866, -1.4139, -14.1025], - [-17.5735, -2.5090, -11.8666], - ], device=torch_device), - ("rocm", (9, 5)): torch.tensor( + ], + ("rocm", (9, 5)): [ [-18.1565, -1.7568, -13.5029], [-16.8888, -1.4138, -14.1028], [-17.5709, -2.5080, -11.8654] - ], device=torch_device), + ], } ) # fmt: skip - expected_slice_logits = expected_slices.get_expectation() - print(f"Generated: {outputs.logits[0, :3, :3]}") + expected_slice_logits = torch.tensor(expected_slices.get_expectation(), device=torch_device) torch.testing.assert_close(outputs.logits[0, :3, :3], expected_slice_logits, rtol=2e-4, atol=2e-4) expected_shape_boxes = torch.Size((1, model.config.num_queries, 4)) self.assertEqual(outputs.pred_boxes.shape, expected_shape_boxes) expected_slices = Expectations( { - ("xpu", 3): torch.tensor([[0.5344, 0.1790, 0.9284], [0.4421, 0.0571, 0.0875], [0.6632, 0.6886, 0.1015]], device=torch_device), - ("cuda", 7): torch.tensor([[0.5344, 0.1790, 0.9284], [0.4421, 0.0571, 0.0875], [0.6632, 0.6886, 0.1015]], device=torch_device), - ("cuda", 8): torch.tensor([[0.5344, 0.1790, 0.9284], [0.4421, 0.0571, 0.0875], [0.6632, 0.6886, 0.1015]], device=torch_device), - ("rocm", (9, 5)): torch.tensor([[0.5344, 0.1789, 0.9285], [0.4420, 0.0572, 0.0875], [0.6630, 0.6887, 0.1017]], device=torch_device), + (None, None): [[0.5344, 0.1790, 0.9284], [0.4421, 0.0571, 0.0875], [0.6632, 0.6886, 0.1015]], + ("rocm", (9, 5)): [[0.5344, 0.1789, 0.9285], [0.4420, 0.0572, 0.0875], [0.6630, 0.6887, 0.1017]], } ) # fmt: skip - expected_slice_boxes = expected_slices.get_expectation() - print(f"Generated boxes: {outputs.pred_boxes[0, :3, :3]}") + expected_slice_boxes = torch.tensor(expected_slices.get_expectation(), device=torch_device) torch.testing.assert_close(outputs.pred_boxes[0, :3, :3], expected_slice_boxes, rtol=2e-4, atol=2e-4) expected_shape_masks = torch.Size((1, model.config.num_queries, 200, 267)) self.assertEqual(outputs.pred_masks.shape, expected_shape_masks) expected_slices = Expectations( { - ("xpu", 3): torch.tensor([[-7.8408, -11.0104, -12.1279], [-12.0299, -16.6498, -17.9806], [-14.8995, -19.9940, -20.5646]], device=torch_device), - ("cuda", 7): torch.tensor([[-7.8408, -11.0104, -12.1279], [-12.0299, -16.6498, -17.9806], [-14.8995, -19.9940, -20.5646]], device=torch_device), - ("cuda", 8): torch.tensor([[-7.8408, -11.0104, -12.1279], [-12.0299, -16.6498, -17.9806], [-14.8995, -19.9940, -20.5646]], device=torch_device), - ("rocm", (9, 5)): torch.tensor([[ -7.7558, -10.8789, -11.9798], [-11.8882, -16.4330, -17.7452], [-14.7317, -19.7384, -20.3005]], device=torch_device), + (None, None): [[-7.8408, -11.0104, -12.1279], [-12.0299, -16.6498, -17.9806], [-14.8995, -19.9940, -20.5646]], + ("rocm", (9, 5)): [[ -7.7558, -10.8789, -11.9798], [-11.8882, -16.4330, -17.7452], [-14.7317, -19.7384, -20.3005]], } ) # fmt: skip - expected_slice_masks = expected_slices.get_expectation() - - print(f"Generated masks: {outputs.pred_masks[0, 0, :3, :3]}") + expected_slice_masks = torch.tensor(expected_slices.get_expectation(), device=torch_device) torch.testing.assert_close(outputs.pred_masks[0, 0, :3, :3], expected_slice_masks, rtol=2e-3, atol=2e-3) # verify postprocessing @@ -816,31 +771,19 @@ def test_inference_no_head(self): assert outputs.last_hidden_state.shape == expected_shape expected_slices = Expectations( { - ("xpu", 3): torch.tensor( + (None, None): [ [0.0622, -0.5142, -0.4034], [-0.7628, -0.4935, -1.7153], [-0.4751, -0.6386, -0.7818], - ], device=torch_device), - ("cuda", 7): torch.tensor( - [ - [0.0622, -0.5142, -0.4034], - [-0.7628, -0.4935, -1.7153], - [-0.4751, -0.6386, -0.7818], - ], device=torch_device), - ("cuda", 8): torch.tensor( - [ - [0.0622, -0.5142, -0.4034], - [-0.7628, -0.4935, -1.7153], - [-0.4751, -0.6386, -0.7818], - ], device=torch_device), - ("rocm", (9, 5)): torch.tensor( + ], + ("rocm", (9, 5)): [ [ 0.0616, -0.5146, -0.4032], [-0.7629, -0.4934, -1.7153], [-0.4768, -0.6403, -0.7826] - ], device=torch_device), + ], } ) # fmt: skip - expected_slice = expected_slices.get_expectation() + expected_slice = torch.tensor(expected_slices.get_expectation(), device=torch_device) torch.testing.assert_close(outputs.last_hidden_state[0, :3, :3], expected_slice, rtol=1e-4, atol=1e-4) From e74c37d25979e915f4d1d268b798895e866f9e1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81kos=20Hadnagy?= Date: Tue, 22 Jul 2025 06:54:17 -0500 Subject: [PATCH 4/4] Make formatting a bit more consistent --- tests/models/detr/test_modeling_detr.py | 36 +++++++++++++++++++------ 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/tests/models/detr/test_modeling_detr.py b/tests/models/detr/test_modeling_detr.py index a68e854efc30..38bc54b3017b 100644 --- a/tests/models/detr/test_modeling_detr.py +++ b/tests/models/detr/test_modeling_detr.py @@ -597,7 +597,7 @@ def test_inference_no_head(self): [ [ 0.0616, -0.5146, -0.4032], [-0.7629, -0.4934, -1.7153], - [-0.4768, -0.6403, -0.7826] + [-0.4768, -0.6403, -0.7826], ], } ) # fmt: skip @@ -631,7 +631,7 @@ def test_inference_object_detection_head(self): [ [-19.1194, -0.0893, -11.0154], [-17.3640, -1.8035, -14.0219], - [-20.0461, -0.5837, -11.1060] + [-20.0461, -0.5837, -11.1060], ], } ) # fmt: skip @@ -689,7 +689,7 @@ def test_inference_panoptic_segmentation_head(self): [ [-18.1565, -1.7568, -13.5029], [-16.8888, -1.4138, -14.1028], - [-17.5709, -2.5080, -11.8654] + [-17.5709, -2.5080, -11.8654], ], } ) # fmt: skip @@ -700,8 +700,18 @@ def test_inference_panoptic_segmentation_head(self): self.assertEqual(outputs.pred_boxes.shape, expected_shape_boxes) expected_slices = Expectations( { - (None, None): [[0.5344, 0.1790, 0.9284], [0.4421, 0.0571, 0.0875], [0.6632, 0.6886, 0.1015]], - ("rocm", (9, 5)): [[0.5344, 0.1789, 0.9285], [0.4420, 0.0572, 0.0875], [0.6630, 0.6887, 0.1017]], + (None, None): + [ + [0.5344, 0.1790, 0.9284], + [0.4421, 0.0571, 0.0875], + [0.6632, 0.6886, 0.1015] + ], + ("rocm", (9, 5)): + [ + [0.5344, 0.1789, 0.9285], + [0.4420, 0.0572, 0.0875], + [0.6630, 0.6887, 0.1017], + ], } ) # fmt: skip expected_slice_boxes = torch.tensor(expected_slices.get_expectation(), device=torch_device) @@ -711,8 +721,18 @@ def test_inference_panoptic_segmentation_head(self): self.assertEqual(outputs.pred_masks.shape, expected_shape_masks) expected_slices = Expectations( { - (None, None): [[-7.8408, -11.0104, -12.1279], [-12.0299, -16.6498, -17.9806], [-14.8995, -19.9940, -20.5646]], - ("rocm", (9, 5)): [[ -7.7558, -10.8789, -11.9798], [-11.8882, -16.4330, -17.7452], [-14.7317, -19.7384, -20.3005]], + (None, None): + [ + [-7.8408, -11.0104, -12.1279], + [-12.0299, -16.6498, -17.9806], + [-14.8995, -19.9940, -20.5646], + ], + ("rocm", (9, 5)): + [ + [ -7.7558, -10.8789, -11.9798], + [-11.8882, -16.4330, -17.7452], + [-14.7317, -19.7384, -20.3005], + ], } ) # fmt: skip expected_slice_masks = torch.tensor(expected_slices.get_expectation(), device=torch_device) @@ -771,7 +791,7 @@ def test_inference_no_head(self): assert outputs.last_hidden_state.shape == expected_shape expected_slices = Expectations( { - (None, None): + (None, None): [ [0.0622, -0.5142, -0.4034], [-0.7628, -0.4935, -1.7153],