Add torch >=1.12 requirement for Tapas (#24251)
* fix * fix * fix * Update src/transformers/models/tapas/modeling_tapas.py Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com> * fix --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com> Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
This commit is contained in:
@@ -60,6 +60,9 @@ if is_torch_available():
|
||||
reduce_mean,
|
||||
reduce_sum,
|
||||
)
|
||||
from transformers.pytorch_utils import is_torch_greater_or_equal_than_1_12
|
||||
else:
|
||||
is_torch_greater_or_equal_than_1_12 = False
|
||||
|
||||
|
||||
class TapasModelTester:
|
||||
@@ -408,6 +411,7 @@ class TapasModelTester:
|
||||
return config, inputs_dict
|
||||
|
||||
|
||||
@unittest.skipIf(not is_torch_greater_or_equal_than_1_12, reason="Tapas is only available in torch v1.12+")
|
||||
@require_torch
|
||||
class TapasModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (
|
||||
@@ -562,6 +566,7 @@ def prepare_tapas_batch_inputs_for_training():
|
||||
return table, queries, answer_coordinates, answer_text, float_answer
|
||||
|
||||
|
||||
@unittest.skipIf(not is_torch_greater_or_equal_than_1_12, reason="Tapas is only available in torch v1.12+")
|
||||
@require_torch
|
||||
class TapasModelIntegrationTest(unittest.TestCase):
|
||||
@cached_property
|
||||
@@ -916,6 +921,7 @@ class TapasModelIntegrationTest(unittest.TestCase):
|
||||
# Below: tests for Tapas utilities which are defined in modeling_tapas.py.
|
||||
# These are based on segmented_tensor_test.py of the original implementation.
|
||||
# URL: https://github.com/google-research/tapas/blob/master/tapas/models/segmented_tensor_test.py
|
||||
@unittest.skipIf(not is_torch_greater_or_equal_than_1_12, reason="Tapas is only available in torch v1.12+")
|
||||
@require_torch
|
||||
class TapasUtilitiesTest(unittest.TestCase):
|
||||
def _prepare_tables(self):
|
||||
|
||||
Reference in New Issue
Block a user