From 869f52a5ff171a38864ea25f6649c5daa5ce7f2e Mon Sep 17 00:00:00 2001 From: Korbinian Poeppel Date: Sat, 21 Dec 2024 00:38:28 +0000 Subject: [PATCH] Fix: Skip tests, if xlstm library is not installed. --- tests/models/xlstm/test_modeling_xlstm.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/models/xlstm/test_modeling_xlstm.py b/tests/models/xlstm/test_modeling_xlstm.py index 5bdb1c6f96b8a2..de71a8f6df6237 100644 --- a/tests/models/xlstm/test_modeling_xlstm.py +++ b/tests/models/xlstm/test_modeling_xlstm.py @@ -21,6 +21,7 @@ from transformers import AutoTokenizer, is_torch_available, xLSTMConfig from transformers.testing_utils import require_read_token, require_torch, require_torch_gpu, slow, torch_device +from transformers.utils import is_xlstm_available from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester @@ -163,6 +164,7 @@ def prepare_config_and_inputs_for_common(self): @unittest.skipIf( not is_torch_greater_or_equal_than_2_2, reason="See https://github.com/huggingface/transformers/pull/24204" ) +@unittest.skipIf(not is_xlstm_available(), reason="xlstm needs to be installed for tests to work") @require_torch class xLSTMModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin, unittest.TestCase): all_model_classes = (xLSTMModel, xLSTMForCausalLM) if is_torch_available() else () @@ -279,6 +281,7 @@ def recursive_check(tuple_object, dict_object): check_equivalence(model, tuple_inputs, dict_inputs, {"output_hidden_states": True}) +@unittest.skipIf(not is_xlstm_available(), reason="xlstm needs to be installed for tests to work") @require_torch @slow @require_read_token