From 18643ff29a946c4d21b67d288e6da98bb0c1b169 Mon Sep 17 00:00:00 2001 From: Yih-Dar <2521628+ydshieh@users.noreply.github.com> Date: Tue, 20 Sep 2022 21:52:18 +0200 Subject: [PATCH] Skip `test_export_to_onnx` for `LongT5` if `torch` < 1.11 (#19122) * Skip if torch < 1.11 * fix quality * fix import * fix typo * fix condition * fix condition * fix condition * fix quality * fix condition Co-authored-by: ydshieh --- tests/models/longt5/test_modeling_longt5.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/models/longt5/test_modeling_longt5.py b/tests/models/longt5/test_modeling_longt5.py index 61ad68921d..bde8505640 100644 --- a/tests/models/longt5/test_modeling_longt5.py +++ b/tests/models/longt5/test_modeling_longt5.py @@ -39,6 +39,7 @@ if is_torch_available(): LongT5Model, ) from transformers.models.longt5.modeling_longt5 import LONGT5_PRETRAINED_MODEL_ARCHIVE_LIST + from transformers.pytorch_utils import is_torch_less_than_1_11 class LongT5ModelTester: @@ -584,6 +585,10 @@ class LongT5ModelTest(ModelTesterMixin, GenerationTesterMixin, unittest.TestCase model = LongT5Model.from_pretrained(model_name) self.assertIsNotNone(model) + @unittest.skipIf( + not is_torch_available() or is_torch_less_than_1_11, + "Test failed with torch < 1.11 with an exception in a C++ file.", + ) @slow def test_export_to_onnx(self): config_and_inputs = self.model_tester.prepare_config_and_inputs()