Simplify conditional code (#39781)
* Use != Signed-off-by: cyy <cyyever@outlook.com> * Use get Signed-off-by: cyy <cyyever@outlook.com> * Format * Simplify bool operations Signed-off-by: cyy <cyyever@outlook.com> --------- Signed-off-by: cyy <cyyever@outlook.com>
This commit is contained in:
@@ -147,7 +147,7 @@ class DepthAnythingModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Tes
|
||||
test_resize_embeddings = False
|
||||
test_head_masking = False
|
||||
test_torch_exportable = True
|
||||
test_torch_exportable_strictly = not get_torch_major_and_minor_version() == "2.7"
|
||||
test_torch_exportable_strictly = get_torch_major_and_minor_version() != "2.7"
|
||||
|
||||
def setUp(self):
|
||||
self.model_tester = DepthAnythingModelTester(self)
|
||||
|
||||
@@ -141,7 +141,7 @@ class DPTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
test_resize_embeddings = False
|
||||
test_head_masking = False
|
||||
test_torch_exportable = True
|
||||
test_torch_exportable_strictly = not get_torch_major_and_minor_version() == "2.7"
|
||||
test_torch_exportable_strictly = get_torch_major_and_minor_version() != "2.7"
|
||||
|
||||
def setUp(self):
|
||||
self.model_tester = DPTModelTester(self)
|
||||
|
||||
@@ -371,7 +371,7 @@ class HieraModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
[num_patches, self.model_tester.embed_dim],
|
||||
)
|
||||
|
||||
if not model_class.__name__ == "HieraBackbone":
|
||||
if model_class.__name__ != "HieraBackbone":
|
||||
reshaped_hidden_states = outputs.reshaped_hidden_states
|
||||
self.assertEqual(len(reshaped_hidden_states), expected_num_layers)
|
||||
|
||||
|
||||
@@ -382,7 +382,7 @@ class SwinModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
[num_patches, self.model_tester.embed_dim],
|
||||
)
|
||||
|
||||
if not model_class.__name__ == "SwinBackbone":
|
||||
if model_class.__name__ != "SwinBackbone":
|
||||
reshaped_hidden_states = outputs.reshaped_hidden_states
|
||||
self.assertEqual(len(reshaped_hidden_states), expected_num_layers)
|
||||
|
||||
|
||||
@@ -365,7 +365,7 @@ class Swinv2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
[num_patches, self.model_tester.embed_dim],
|
||||
)
|
||||
|
||||
if not model_class.__name__ == "Swinv2Backbone":
|
||||
if model_class.__name__ != "Swinv2Backbone":
|
||||
reshaped_hidden_states = outputs.reshaped_hidden_states
|
||||
self.assertEqual(len(reshaped_hidden_states), expected_num_layers)
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ class UperNetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase)
|
||||
test_torchscript = False
|
||||
has_attentions = False
|
||||
test_torch_exportable = True
|
||||
test_torch_exportable_strictly = not get_torch_major_and_minor_version() == "2.7"
|
||||
test_torch_exportable_strictly = get_torch_major_and_minor_version() != "2.7"
|
||||
|
||||
def setUp(self):
|
||||
self.model_tester = UperNetModelTester(self)
|
||||
|
||||
@@ -144,7 +144,7 @@ class VitMatteModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase
|
||||
test_resize_embeddings = False
|
||||
test_head_masking = False
|
||||
test_torch_exportable = True
|
||||
test_torch_exportable_strictly = not get_torch_major_and_minor_version() == "2.7"
|
||||
test_torch_exportable_strictly = get_torch_major_and_minor_version() != "2.7"
|
||||
|
||||
def setUp(self):
|
||||
self.model_tester = VitMatteModelTester(self)
|
||||
|
||||
@@ -155,7 +155,7 @@ class VitPoseModelTest(ModelTesterMixin, unittest.TestCase):
|
||||
test_resize_embeddings = False
|
||||
test_head_masking = False
|
||||
test_torch_exportable = True
|
||||
test_torch_exportable_strictly = not get_torch_major_and_minor_version() == "2.7"
|
||||
test_torch_exportable_strictly = get_torch_major_and_minor_version() != "2.7"
|
||||
|
||||
def setUp(self):
|
||||
self.model_tester = VitPoseModelTester(self)
|
||||
|
||||
@@ -148,7 +148,7 @@ class ZoeDepthModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase
|
||||
test_resize_embeddings = False
|
||||
test_head_masking = False
|
||||
# `strict=True/False` are both failing with torch 2.7, see #38677
|
||||
test_torch_exportable = not get_torch_major_and_minor_version() == "2.7"
|
||||
test_torch_exportable = get_torch_major_and_minor_version() != "2.7"
|
||||
|
||||
def setUp(self):
|
||||
self.model_tester = ZoeDepthModelTester(self)
|
||||
|
||||
Reference in New Issue
Block a user