diff --git a/.github/workflows/self-scheduled.yml b/.github/workflows/self-scheduled.yml index 7d270611c2..509650ab0f 100644 --- a/.github/workflows/self-scheduled.yml +++ b/.github/workflows/self-scheduled.yml @@ -16,6 +16,8 @@ env: MKL_NUM_THREADS: 16 PYTEST_TIMEOUT: 600 SIGOPT_API_TOKEN: ${{ secrets.SIGOPT_API_TOKEN }} + TF_FORCE_GPU_ALLOW_GROWTH: true + RUN_PT_TF_CROSS_TESTS: 1 jobs: run_all_tests_torch_gpu: diff --git a/tests/conftest.py b/conftest.py similarity index 97% rename from tests/conftest.py rename to conftest.py index 5dc776e222..1443342fc0 100644 --- a/tests/conftest.py +++ b/conftest.py @@ -22,7 +22,7 @@ from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switching between checkouts and running tests. -git_repo_path = abspath(join(dirname(dirname(__file__)), "src")) +git_repo_path = abspath(join(dirname(__file__), "src")) sys.path.insert(1, git_repo_path) # silence FutureWarning warnings in tests since often we can't act on them until diff --git a/examples/flax/test_examples.py b/examples/flax/test_flax_examples.py similarity index 100% rename from examples/flax/test_examples.py rename to examples/flax/test_flax_examples.py diff --git a/examples/pytorch/test_examples.py b/examples/pytorch/test_pytorch_examples.py similarity index 100% rename from examples/pytorch/test_examples.py rename to examples/pytorch/test_pytorch_examples.py diff --git a/src/transformers/commands/add_new_model.py b/src/transformers/commands/add_new_model.py index 4cbdf7a0ef..558ef6dd48 100644 --- a/src/transformers/commands/add_new_model.py +++ b/src/transformers/commands/add_new_model.py @@ -131,7 +131,7 @@ class AddNewModelCommand(BaseTransformersCLICommand): shutil.move( f"{directory}/test_modeling_{lowercase_model_name}.py", - f"{path_to_transformer_root}/tests/test_modeling_{lowercase_model_name}.py", + f"{path_to_transformer_root}/tests/{lowercase_model_name}/test_modeling_{lowercase_model_name}.py", ) else: os.remove(f"{directory}/modeling_{lowercase_model_name}.py") @@ -148,7 +148,7 @@ class AddNewModelCommand(BaseTransformersCLICommand): shutil.move( f"{directory}/test_modeling_tf_{lowercase_model_name}.py", - f"{path_to_transformer_root}/tests/test_modeling_tf_{lowercase_model_name}.py", + f"{path_to_transformer_root}/tests/{lowercase_model_name}/test_modeling_tf_{lowercase_model_name}.py", ) else: os.remove(f"{directory}/modeling_tf_{lowercase_model_name}.py") @@ -165,7 +165,7 @@ class AddNewModelCommand(BaseTransformersCLICommand): shutil.move( f"{directory}/test_modeling_flax_{lowercase_model_name}.py", - f"{path_to_transformer_root}/tests/test_modeling_flax_{lowercase_model_name}.py", + f"{path_to_transformer_root}/tests/{lowercase_model_name}/test_modeling_flax_{lowercase_model_name}.py", ) else: os.remove(f"{directory}/modeling_flax_{lowercase_model_name}.py") diff --git a/src/transformers/commands/add_new_model_like.py b/src/transformers/commands/add_new_model_like.py index 17a958664c..f69fd93ea6 100644 --- a/src/transformers/commands/add_new_model_like.py +++ b/src/transformers/commands/add_new_model_like.py @@ -554,7 +554,7 @@ def get_model_files(model_type: str, frameworks: Optional[List[str]] = None) -> ] test_files = filter_framework_files(test_files, frameworks=frameworks) # Add the test directory - test_files = [REPO_PATH / "tests" / f for f in test_files] + test_files = [REPO_PATH / "tests" / module_name / f for f in test_files] # Filter by existing files test_files = [f for f in test_files if f.exists()] diff --git a/src/transformers/testing_utils.py b/src/transformers/testing_utils.py index ca2d1403f3..aa71a7ee02 100644 --- a/src/transformers/testing_utils.py +++ b/src/transformers/testing_utils.py @@ -689,6 +689,10 @@ def get_tests_dir(append_path=None): # this function caller's __file__ caller__file__ = inspect.stack()[1][1] tests_dir = os.path.abspath(os.path.dirname(caller__file__)) + + while not tests_dir.endswith("tests"): + tests_dir = os.path.dirname(tests_dir) + if append_path: return os.path.join(tests_dir, append_path) else: @@ -1270,10 +1274,10 @@ def pytest_terminal_summary_main(tr, id): orig_tbstyle = config.option.tbstyle orig_reportchars = tr.reportchars - dir = "reports" + dir = f"reports/{id}" Path(dir).mkdir(parents=True, exist_ok=True) report_files = { - k: f"{dir}/{id}_{k}.txt" + k: f"{dir}/{k}.txt" for k in [ "durations", "errors", diff --git a/templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/test_modeling_flax_{{cookiecutter.lowercase_modelname}}.py b/templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/test_modeling_flax_{{cookiecutter.lowercase_modelname}}.py index 02748f13a7..69b0a7fae2 100644 --- a/templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/test_modeling_flax_{{cookiecutter.lowercase_modelname}}.py +++ b/templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/test_modeling_flax_{{cookiecutter.lowercase_modelname}}.py @@ -20,8 +20,8 @@ import unittest from transformers import is_flax_available, {{cookiecutter.camelcase_modelname}}Config from transformers.testing_utils import require_flax, slow -from .test_configuration_common import ConfigTester -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): import numpy as np @@ -345,8 +345,8 @@ from transformers import ( ) from transformers.testing_utils import require_sentencepiece, require_flax, require_tokenizers, slow -from .test_configuration_common import ConfigTester -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): diff --git a/templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/test_modeling_tf_{{cookiecutter.lowercase_modelname}}.py b/templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/test_modeling_tf_{{cookiecutter.lowercase_modelname}}.py index 4e3a619a7c..390298a115 100644 --- a/templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/test_modeling_tf_{{cookiecutter.lowercase_modelname}}.py +++ b/templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/test_modeling_tf_{{cookiecutter.lowercase_modelname}}.py @@ -20,8 +20,8 @@ import unittest from transformers import is_tf_available, {{cookiecutter.camelcase_modelname}}Config from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor if is_tf_available(): @@ -360,8 +360,8 @@ from transformers import ( ) from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/test_modeling_{{cookiecutter.lowercase_modelname}}.py b/templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/test_modeling_{{cookiecutter.lowercase_modelname}}.py index 83f02056db..700e380610 100644 --- a/templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/test_modeling_{{cookiecutter.lowercase_modelname}}.py +++ b/templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/test_modeling_{{cookiecutter.lowercase_modelname}}.py @@ -18,13 +18,13 @@ {% if cookiecutter.is_encoder_decoder_model == "False" -%} import unittest -from tests.test_modeling_common import floats_tensor +from ..test_modeling_common import floats_tensor from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from transformers import {{cookiecutter.camelcase_modelname}}Config -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask if is_torch_available(): @@ -489,9 +489,9 @@ from transformers import is_torch_available from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_generation_utils import GenerationTesterMixin +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/albert/__init__.py b/tests/albert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_albert.py b/tests/albert/test_modeling_albert.py similarity index 98% rename from tests/test_modeling_albert.py rename to tests/albert/test_modeling_albert.py index ab5595f4b6..125ba314dd 100644 --- a/tests/test_modeling_albert.py +++ b/tests/albert/test_modeling_albert.py @@ -20,8 +20,8 @@ from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_modeling_flax_albert.py b/tests/albert/test_modeling_flax_albert.py similarity index 98% rename from tests/test_modeling_flax_albert.py rename to tests/albert/test_modeling_flax_albert.py index ca8cfeafdd..11e971684e 100644 --- a/tests/test_modeling_flax_albert.py +++ b/tests/albert/test_modeling_flax_albert.py @@ -19,7 +19,7 @@ import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): diff --git a/tests/test_modeling_tf_albert.py b/tests/albert/test_modeling_tf_albert.py similarity index 99% rename from tests/test_modeling_tf_albert.py rename to tests/albert/test_modeling_tf_albert.py index ab6b32ab84..59815561c0 100644 --- a/tests/test_modeling_tf_albert.py +++ b/tests/albert/test_modeling_tf_albert.py @@ -20,8 +20,8 @@ from transformers import AlbertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_albert.py b/tests/albert/test_tokenization_albert.py similarity index 97% rename from tests/test_tokenization_albert.py rename to tests/albert/test_tokenization_albert.py index e965f52de2..2421da4927 100644 --- a/tests/test_tokenization_albert.py +++ b/tests/albert/test_tokenization_albert.py @@ -15,14 +15,15 @@ import os import unittest +from os.path import dirname from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import require_sentencepiece, require_tokenizers, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/spiece.model") +SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/spiece.model") @require_sentencepiece diff --git a/tests/auto/__init__.py b/tests/auto/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_configuration_auto.py b/tests/auto/test_configuration_auto.py similarity index 97% rename from tests/test_configuration_auto.py rename to tests/auto/test_configuration_auto.py index d6a99c2cf6..f07bb42834 100644 --- a/tests/test_configuration_auto.py +++ b/tests/auto/test_configuration_auto.py @@ -27,12 +27,12 @@ from transformers.models.roberta.configuration_roberta import RobertaConfig from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER -sys.path.append(str(Path(__file__).parent.parent / "utils")) +sys.path.append(str(Path(__file__).parent.parent.parent / "utils")) from test_module.custom_configuration import CustomConfig # noqa E402 -SAMPLE_ROBERTA_CONFIG = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/dummy-config.json") +SAMPLE_ROBERTA_CONFIG = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../fixtures/dummy-config.json") class AutoConfigTest(unittest.TestCase): diff --git a/tests/test_feature_extraction_auto.py b/tests/auto/test_feature_extraction_auto.py similarity index 95% rename from tests/test_feature_extraction_auto.py rename to tests/auto/test_feature_extraction_auto.py index c8a785d291..b0c11c517a 100644 --- a/tests/test_feature_extraction_auto.py +++ b/tests/auto/test_feature_extraction_auto.py @@ -31,17 +31,17 @@ from transformers import ( from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER -sys.path.append(str(Path(__file__).parent.parent / "utils")) +sys.path.append(str(Path(__file__).parent.parent.parent / "utils")) from test_module.custom_configuration import CustomConfig # noqa E402 from test_module.custom_feature_extraction import CustomFeatureExtractor # noqa E402 -SAMPLE_FEATURE_EXTRACTION_CONFIG_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures") +SAMPLE_FEATURE_EXTRACTION_CONFIG_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../fixtures") SAMPLE_FEATURE_EXTRACTION_CONFIG = os.path.join( - os.path.dirname(os.path.abspath(__file__)), "fixtures/dummy_feature_extractor_config.json" + os.path.dirname(os.path.abspath(__file__)), "../fixtures/dummy_feature_extractor_config.json" ) -SAMPLE_CONFIG = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/dummy-config.json") +SAMPLE_CONFIG = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../fixtures/dummy-config.json") class AutoFeatureExtractorTest(unittest.TestCase): diff --git a/tests/test_modeling_auto.py b/tests/auto/test_modeling_auto.py similarity index 99% rename from tests/test_modeling_auto.py rename to tests/auto/test_modeling_auto.py index 959be8d821..ae04501ea2 100644 --- a/tests/test_modeling_auto.py +++ b/tests/auto/test_modeling_auto.py @@ -29,10 +29,10 @@ from transformers.testing_utils import ( slow, ) -from .test_modeling_bert import BertModelTester +from ..bert.test_modeling_bert import BertModelTester -sys.path.append(str(Path(__file__).parent.parent / "utils")) +sys.path.append(str(Path(__file__).parent.parent.parent / "utils")) from test_module.custom_configuration import CustomConfig # noqa E402 diff --git a/tests/test_modeling_flax_auto.py b/tests/auto/test_modeling_flax_auto.py similarity index 100% rename from tests/test_modeling_flax_auto.py rename to tests/auto/test_modeling_flax_auto.py diff --git a/tests/test_modeling_tf_auto.py b/tests/auto/test_modeling_tf_auto.py similarity index 99% rename from tests/test_modeling_tf_auto.py rename to tests/auto/test_modeling_tf_auto.py index 6987ba4779..04f2b4862c 100644 --- a/tests/test_modeling_tf_auto.py +++ b/tests/auto/test_modeling_tf_auto.py @@ -26,7 +26,7 @@ from transformers.testing_utils import ( slow, ) -from .test_modeling_bert import BertModelTester +from ..bert.test_modeling_bert import BertModelTester if is_tf_available(): diff --git a/tests/test_modeling_tf_pytorch.py b/tests/auto/test_modeling_tf_pytorch.py similarity index 100% rename from tests/test_modeling_tf_pytorch.py rename to tests/auto/test_modeling_tf_pytorch.py diff --git a/tests/test_processor_auto.py b/tests/auto/test_processor_auto.py similarity index 98% rename from tests/test_processor_auto.py rename to tests/auto/test_processor_auto.py index d4a543ee5c..3aa3409ee3 100644 --- a/tests/test_processor_auto.py +++ b/tests/auto/test_processor_auto.py @@ -41,7 +41,7 @@ from transformers.testing_utils import PASS, USER, is_staging_test from transformers.tokenization_utils import TOKENIZER_CONFIG_FILE -sys.path.append(str(Path(__file__).parent.parent / "utils")) +sys.path.append(str(Path(__file__).parent.parent.parent / "utils")) from test_module.custom_configuration import CustomConfig # noqa E402 from test_module.custom_feature_extraction import CustomFeatureExtractor # noqa E402 @@ -50,11 +50,11 @@ from test_module.custom_tokenization import CustomTokenizer # noqa E402 SAMPLE_PROCESSOR_CONFIG = os.path.join( - os.path.dirname(os.path.abspath(__file__)), "fixtures/dummy_feature_extractor_config.json" + os.path.dirname(os.path.abspath(__file__)), "../fixtures/dummy_feature_extractor_config.json" ) -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/vocab.json") +SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../fixtures/vocab.json") -SAMPLE_PROCESSOR_CONFIG_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures") +SAMPLE_PROCESSOR_CONFIG_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../fixtures") class AutoFeatureExtractorTest(unittest.TestCase): diff --git a/tests/test_tokenization_auto.py b/tests/auto/test_tokenization_auto.py similarity index 100% rename from tests/test_tokenization_auto.py rename to tests/auto/test_tokenization_auto.py diff --git a/tests/bart/__init__.py b/tests/bart/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_bart.py b/tests/bart/test_modeling_bart.py similarity index 99% rename from tests/test_modeling_bart.py rename to tests/bart/test_modeling_bart.py index 957350b824..1cee64c790 100644 --- a/tests/test_modeling_bart.py +++ b/tests/bart/test_modeling_bart.py @@ -25,9 +25,9 @@ from transformers import BartConfig, is_torch_available from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor if is_torch_available(): diff --git a/tests/test_modeling_flax_bart.py b/tests/bart/test_modeling_flax_bart.py similarity index 99% rename from tests/test_modeling_flax_bart.py rename to tests/bart/test_modeling_flax_bart.py index d1a51e3612..dce757e884 100644 --- a/tests/test_modeling_flax_bart.py +++ b/tests/bart/test_modeling_flax_bart.py @@ -20,8 +20,8 @@ import timeout_decorator # noqa from transformers import BartConfig, is_flax_available from transformers.testing_utils import require_flax, slow -from .test_generation_flax_utils import FlaxGenerationTesterMixin -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor +from ..generation.test_generation_flax_utils import FlaxGenerationTesterMixin +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): diff --git a/tests/test_modeling_tf_bart.py b/tests/bart/test_modeling_tf_bart.py similarity index 99% rename from tests/test_modeling_tf_bart.py rename to tests/bart/test_modeling_tf_bart.py index 951f42d1eb..c231e14188 100644 --- a/tests/test_modeling_tf_bart.py +++ b/tests/bart/test_modeling_tf_bart.py @@ -21,9 +21,9 @@ from transformers import BartConfig, BartTokenizer, is_tf_available from transformers.file_utils import cached_property from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor -from .test_modeling_tf_core import TFCoreModelTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..utils.test_modeling_tf_core import TFCoreModelTesterMixin if is_tf_available(): diff --git a/tests/test_tokenization_bart.py b/tests/bart/test_tokenization_bart.py similarity index 98% rename from tests/test_tokenization_bart.py rename to tests/bart/test_tokenization_bart.py index 2a28957268..a4cdff3119 100644 --- a/tests/test_tokenization_bart.py +++ b/tests/bart/test_tokenization_bart.py @@ -20,7 +20,7 @@ from transformers.file_utils import cached_property from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch -from .test_tokenization_common import TokenizerTesterMixin, filter_roberta_detectors +from ..test_tokenization_common import TokenizerTesterMixin, filter_roberta_detectors @require_tokenizers diff --git a/tests/barthez/__init__.py b/tests/barthez/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_tokenization_barthez.py b/tests/barthez/test_tokenization_barthez.py similarity index 98% rename from tests/test_tokenization_barthez.py rename to tests/barthez/test_tokenization_barthez.py index c8ba5b1582..2738ec6e30 100644 --- a/tests/test_tokenization_barthez.py +++ b/tests/barthez/test_tokenization_barthez.py @@ -18,7 +18,7 @@ import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin @require_tokenizers diff --git a/tests/bartpho/__init__.py b/tests/bartpho/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_tokenization_bartpho.py b/tests/bartpho/test_tokenization_bartpho.py similarity index 92% rename from tests/test_tokenization_bartpho.py rename to tests/bartpho/test_tokenization_bartpho.py index f0aa2a9592..3e35ad15c1 100644 --- a/tests/test_tokenization_bartpho.py +++ b/tests/bartpho/test_tokenization_bartpho.py @@ -15,13 +15,14 @@ import os import unittest +from os.path import dirname from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece_bpe.model") +SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece_bpe.model") class BartphoTokenizerTest(TokenizerTesterMixin, unittest.TestCase): diff --git a/tests/beit/__init__.py b/tests/beit/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_feature_extraction_beit.py b/tests/beit/test_feature_extraction_beit.py similarity index 99% rename from tests/test_feature_extraction_beit.py rename to tests/beit/test_feature_extraction_beit.py index 0ca58a802d..aef4de9fbf 100644 --- a/tests/test_feature_extraction_beit.py +++ b/tests/beit/test_feature_extraction_beit.py @@ -22,7 +22,7 @@ from datasets import load_dataset from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision -from .test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs +from ..test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs if is_torch_available(): diff --git a/tests/test_modeling_beit.py b/tests/beit/test_modeling_beit.py similarity index 99% rename from tests/test_modeling_beit.py rename to tests/beit/test_modeling_beit.py index 2304678e79..3d929a2999 100644 --- a/tests/test_modeling_beit.py +++ b/tests/beit/test_modeling_beit.py @@ -25,8 +25,8 @@ from transformers.file_utils import cached_property, is_torch_available, is_visi from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor if is_torch_available(): diff --git a/tests/test_modeling_flax_beit.py b/tests/beit/test_modeling_flax_beit.py similarity index 99% rename from tests/test_modeling_flax_beit.py rename to tests/beit/test_modeling_flax_beit.py index 88c2d8e33e..12ff97ecab 100644 --- a/tests/test_modeling_flax_beit.py +++ b/tests/beit/test_modeling_flax_beit.py @@ -21,8 +21,8 @@ from transformers import BeitConfig from transformers.file_utils import cached_property, is_flax_available, is_vision_available from transformers.testing_utils import require_flax, require_vision, slow -from .test_configuration_common import ConfigTester -from .test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor if is_flax_available(): diff --git a/tests/benchmark/__init__.py b/tests/benchmark/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_benchmark.py b/tests/benchmark/test_benchmark.py similarity index 100% rename from tests/test_benchmark.py rename to tests/benchmark/test_benchmark.py diff --git a/tests/test_benchmark_tf.py b/tests/benchmark/test_benchmark_tf.py similarity index 100% rename from tests/test_benchmark_tf.py rename to tests/benchmark/test_benchmark_tf.py diff --git a/tests/bert/__init__.py b/tests/bert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_bert.py b/tests/bert/test_modeling_bert.py similarity index 99% rename from tests/test_modeling_bert.py rename to tests/bert/test_modeling_bert.py index 7b8738fd60..efef037627 100755 --- a/tests/test_modeling_bert.py +++ b/tests/bert/test_modeling_bert.py @@ -20,9 +20,9 @@ from transformers import BertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_modeling_flax_bert.py b/tests/bert/test_modeling_flax_bert.py similarity index 98% rename from tests/test_modeling_flax_bert.py rename to tests/bert/test_modeling_flax_bert.py index 6b2be334c7..0214e37901 100644 --- a/tests/test_modeling_flax_bert.py +++ b/tests/bert/test_modeling_flax_bert.py @@ -19,7 +19,7 @@ import numpy as np from transformers import BertConfig, is_flax_available from transformers.testing_utils import require_flax, slow -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): diff --git a/tests/test_modeling_tf_bert.py b/tests/bert/test_modeling_tf_bert.py similarity index 98% rename from tests/test_modeling_tf_bert.py rename to tests/bert/test_modeling_tf_bert.py index cb566f7e49..518870ceb8 100644 --- a/tests/test_modeling_tf_bert.py +++ b/tests/bert/test_modeling_tf_bert.py @@ -20,9 +20,9 @@ from transformers import BertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor -from .test_modeling_tf_core import TFCoreModelTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor +from ..utils.test_modeling_tf_core import TFCoreModelTesterMixin if is_tf_available(): diff --git a/tests/test_tokenization_bert.py b/tests/bert/test_tokenization_bert.py similarity index 99% rename from tests/test_tokenization_bert.py rename to tests/bert/test_tokenization_bert.py index 53f8ef6eb0..f53482eef7 100644 --- a/tests/test_tokenization_bert.py +++ b/tests/bert/test_tokenization_bert.py @@ -29,7 +29,7 @@ from transformers.models.bert.tokenization_bert import ( ) from transformers.testing_utils import require_tokenizers, slow -from .test_tokenization_common import TokenizerTesterMixin, filter_non_english +from ..test_tokenization_common import TokenizerTesterMixin, filter_non_english @require_tokenizers diff --git a/tests/bert_generation/__init__.py b/tests/bert_generation/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_bert_generation.py b/tests/bert_generation/test_modeling_bert_generation.py similarity index 98% rename from tests/test_modeling_bert_generation.py rename to tests/bert_generation/test_modeling_bert_generation.py index ea184af03b..73cd77ac0f 100755 --- a/tests/test_modeling_bert_generation.py +++ b/tests/bert_generation/test_modeling_bert_generation.py @@ -19,9 +19,9 @@ import unittest from transformers import BertGenerationConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_tokenization_bert_generation.py b/tests/bert_generation/test_tokenization_bert_generation.py similarity index 97% rename from tests/test_tokenization_bert_generation.py rename to tests/bert_generation/test_tokenization_bert_generation.py index 40d3f1bae8..20db7c01ca 100644 --- a/tests/test_tokenization_bert_generation.py +++ b/tests/bert_generation/test_tokenization_bert_generation.py @@ -15,17 +15,18 @@ import os import unittest +from os.path import dirname from transformers import BertGenerationTokenizer from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_torch, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin SPIECE_UNDERLINE = "▁" -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") +SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model") @require_sentencepiece diff --git a/tests/bert_japanese/__init__.py b/tests/bert_japanese/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_tokenization_bert_japanese.py b/tests/bert_japanese/test_tokenization_bert_japanese.py similarity index 99% rename from tests/test_tokenization_bert_japanese.py rename to tests/bert_japanese/test_tokenization_bert_japanese.py index 5994225858..ed3e6716c9 100644 --- a/tests/test_tokenization_bert_japanese.py +++ b/tests/bert_japanese/test_tokenization_bert_japanese.py @@ -29,7 +29,7 @@ from transformers.models.bert_japanese.tokenization_bert_japanese import ( ) from transformers.testing_utils import custom_tokenizers -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin @custom_tokenizers diff --git a/tests/bertweet/__init__.py b/tests/bertweet/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_tokenization_bertweet.py b/tests/bertweet/test_tokenization_bertweet.py similarity index 97% rename from tests/test_tokenization_bertweet.py rename to tests/bertweet/test_tokenization_bertweet.py index bf7d5c7798..edeb8ae81a 100644 --- a/tests/test_tokenization_bertweet.py +++ b/tests/bertweet/test_tokenization_bertweet.py @@ -18,7 +18,7 @@ import unittest from transformers.models.bertweet.tokenization_bertweet import VOCAB_FILES_NAMES, BertweetTokenizer -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin class BertweetTokenizationTest(TokenizerTesterMixin, unittest.TestCase): diff --git a/tests/big_bird/__init__.py b/tests/big_bird/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_big_bird.py b/tests/big_bird/test_modeling_big_bird.py similarity index 99% rename from tests/test_modeling_big_bird.py rename to tests/big_bird/test_modeling_big_bird.py index 401fade117..711708ac2c 100644 --- a/tests/test_modeling_big_bird.py +++ b/tests/big_bird/test_modeling_big_bird.py @@ -17,14 +17,13 @@ import unittest -from tests.test_modeling_common import floats_tensor from transformers import BigBirdConfig, is_torch_available from transformers.models.auto import get_values from transformers.models.big_bird.tokenization_big_bird import BigBirdTokenizer from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_modeling_flax_big_bird.py b/tests/big_bird/test_modeling_flax_big_bird.py similarity index 98% rename from tests/test_modeling_flax_big_bird.py rename to tests/big_bird/test_modeling_flax_big_bird.py index 8af5949a1a..834b71b30b 100644 --- a/tests/test_modeling_flax_big_bird.py +++ b/tests/big_bird/test_modeling_flax_big_bird.py @@ -19,7 +19,7 @@ import numpy as np from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): diff --git a/tests/test_tokenization_big_bird.py b/tests/big_bird/test_tokenization_big_bird.py similarity index 98% rename from tests/test_tokenization_big_bird.py rename to tests/big_bird/test_tokenization_big_bird.py index c4c7e5862a..bbeb009572 100644 --- a/tests/test_tokenization_big_bird.py +++ b/tests/big_bird/test_tokenization_big_bird.py @@ -15,17 +15,18 @@ import os import unittest +from os.path import dirname from transformers import BigBirdTokenizer, BigBirdTokenizerFast from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin SPIECE_UNDERLINE = "▁" -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") +SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model") @require_sentencepiece diff --git a/tests/bigbird_pegasus/__init__.py b/tests/bigbird_pegasus/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_bigbird_pegasus.py b/tests/bigbird_pegasus/test_modeling_bigbird_pegasus.py similarity index 99% rename from tests/test_modeling_bigbird_pegasus.py rename to tests/bigbird_pegasus/test_modeling_bigbird_pegasus.py index 7f50ddd6f5..eebdb0a91c 100644 --- a/tests/test_modeling_bigbird_pegasus.py +++ b/tests/bigbird_pegasus/test_modeling_bigbird_pegasus.py @@ -22,9 +22,9 @@ import unittest from transformers import BigBirdPegasusConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/blenderbot/__init__.py b/tests/blenderbot/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_blenderbot.py b/tests/blenderbot/test_modeling_blenderbot.py similarity index 99% rename from tests/test_modeling_blenderbot.py rename to tests/blenderbot/test_modeling_blenderbot.py index 9e04ec89d9..c0b2ef01f2 100644 --- a/tests/test_modeling_blenderbot.py +++ b/tests/blenderbot/test_modeling_blenderbot.py @@ -21,9 +21,9 @@ from transformers import BlenderbotConfig, is_torch_available from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/test_modeling_flax_blenderbot.py b/tests/blenderbot/test_modeling_flax_blenderbot.py similarity index 99% rename from tests/test_modeling_flax_blenderbot.py rename to tests/blenderbot/test_modeling_flax_blenderbot.py index f871cb89ea..cf6b8b9083 100644 --- a/tests/test_modeling_flax_blenderbot.py +++ b/tests/blenderbot/test_modeling_flax_blenderbot.py @@ -20,8 +20,8 @@ import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow -from .test_generation_flax_utils import FlaxGenerationTesterMixin -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor +from ..generation.test_generation_flax_utils import FlaxGenerationTesterMixin +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): diff --git a/tests/test_modeling_tf_blenderbot.py b/tests/blenderbot/test_modeling_tf_blenderbot.py similarity index 99% rename from tests/test_modeling_tf_blenderbot.py rename to tests/blenderbot/test_modeling_tf_blenderbot.py index 3870f1dff7..e8aebc4462 100644 --- a/tests/test_modeling_tf_blenderbot.py +++ b/tests/blenderbot/test_modeling_tf_blenderbot.py @@ -20,8 +20,8 @@ from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.file_utils import cached_property from transformers.testing_utils import require_tf, require_tokenizers, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_blenderbot.py b/tests/blenderbot/test_tokenization_blenderbot.py similarity index 100% rename from tests/test_tokenization_blenderbot.py rename to tests/blenderbot/test_tokenization_blenderbot.py diff --git a/tests/blenderbot_small/__init__.py b/tests/blenderbot_small/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_blenderbot_small.py b/tests/blenderbot_small/test_modeling_blenderbot_small.py similarity index 99% rename from tests/test_modeling_blenderbot_small.py rename to tests/blenderbot_small/test_modeling_blenderbot_small.py index a7e1818404..fa6207ef54 100644 --- a/tests/test_modeling_blenderbot_small.py +++ b/tests/blenderbot_small/test_modeling_blenderbot_small.py @@ -21,9 +21,9 @@ from transformers import BlenderbotSmallConfig, is_torch_available from transformers.file_utils import cached_property from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/test_modeling_flax_blenderbot_small.py b/tests/blenderbot_small/test_modeling_flax_blenderbot_small.py similarity index 99% rename from tests/test_modeling_flax_blenderbot_small.py rename to tests/blenderbot_small/test_modeling_flax_blenderbot_small.py index de7e8336f2..6f67462426 100644 --- a/tests/test_modeling_flax_blenderbot_small.py +++ b/tests/blenderbot_small/test_modeling_flax_blenderbot_small.py @@ -20,8 +20,8 @@ import timeout_decorator # noqa from transformers import BlenderbotSmallConfig, is_flax_available from transformers.testing_utils import require_flax, slow -from .test_generation_flax_utils import FlaxGenerationTesterMixin -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor +from ..generation.test_generation_flax_utils import FlaxGenerationTesterMixin +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): diff --git a/tests/test_modeling_tf_blenderbot_small.py b/tests/blenderbot_small/test_modeling_tf_blenderbot_small.py similarity index 99% rename from tests/test_modeling_tf_blenderbot_small.py rename to tests/blenderbot_small/test_modeling_tf_blenderbot_small.py index 2d99a76ea2..cb74c799cb 100644 --- a/tests/test_modeling_tf_blenderbot_small.py +++ b/tests/blenderbot_small/test_modeling_tf_blenderbot_small.py @@ -20,8 +20,8 @@ from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_ from transformers.file_utils import cached_property from transformers.testing_utils import require_tf, require_tokenizers, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_small_blenderbot.py b/tests/blenderbot_small/test_tokenization_blenderbot_small.py similarity index 98% rename from tests/test_tokenization_small_blenderbot.py rename to tests/blenderbot_small/test_tokenization_blenderbot_small.py index 9169d21b43..38c3f8391d 100644 --- a/tests/test_tokenization_small_blenderbot.py +++ b/tests/blenderbot_small/test_tokenization_blenderbot_small.py @@ -23,7 +23,7 @@ from transformers.models.blenderbot_small.tokenization_blenderbot_small import ( BlenderbotSmallTokenizer, ) -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin class BlenderbotSmallTokenizerTest(TokenizerTesterMixin, unittest.TestCase): diff --git a/tests/bort/__init__.py b/tests/bort/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_bort.py b/tests/bort/test_modeling_bort.py similarity index 100% rename from tests/test_modeling_bort.py rename to tests/bort/test_modeling_bort.py diff --git a/tests/test_modeling_tf_bort.py b/tests/bort/test_modeling_tf_bort.py similarity index 100% rename from tests/test_modeling_tf_bort.py rename to tests/bort/test_modeling_tf_bort.py diff --git a/tests/byt5/__init__.py b/tests/byt5/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_tokenization_byt5.py b/tests/byt5/test_tokenization_byt5.py similarity index 99% rename from tests/test_tokenization_byt5.py rename to tests/byt5/test_tokenization_byt5.py index f241d07d92..f49912e4c5 100644 --- a/tests/test_tokenization_byt5.py +++ b/tests/byt5/test_tokenization_byt5.py @@ -24,7 +24,7 @@ from typing import Tuple from transformers import AddedToken, BatchEncoding, ByT5Tokenizer from transformers.file_utils import cached_property, is_tf_available, is_torch_available -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin if is_torch_available(): diff --git a/tests/camembert/__init__.py b/tests/camembert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_camembert.py b/tests/camembert/test_modeling_camembert.py similarity index 100% rename from tests/test_modeling_camembert.py rename to tests/camembert/test_modeling_camembert.py diff --git a/tests/test_modeling_tf_camembert.py b/tests/camembert/test_modeling_tf_camembert.py similarity index 100% rename from tests/test_modeling_tf_camembert.py rename to tests/camembert/test_modeling_tf_camembert.py diff --git a/tests/test_tokenization_camembert.py b/tests/camembert/test_tokenization_camembert.py similarity index 94% rename from tests/test_tokenization_camembert.py rename to tests/camembert/test_tokenization_camembert.py index 371a5cc057..1f45b21a20 100644 --- a/tests/test_tokenization_camembert.py +++ b/tests/camembert/test_tokenization_camembert.py @@ -15,16 +15,17 @@ import os import unittest +from os.path import dirname from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.file_utils import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") -SAMPLE_BPE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece_bpe.model") +SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model") +SAMPLE_BPE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece_bpe.model") FRAMEWORK = "pt" if is_torch_available() else "tf" diff --git a/tests/canine/__init__.py b/tests/canine/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_canine.py b/tests/canine/test_modeling_canine.py similarity index 99% rename from tests/test_modeling_canine.py rename to tests/canine/test_modeling_canine.py index 888e1d33e6..dc873c86ac 100644 --- a/tests/test_modeling_canine.py +++ b/tests/canine/test_modeling_canine.py @@ -21,8 +21,8 @@ from typing import List, Tuple from transformers import CanineConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, _config_zero_init, global_rng, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, _config_zero_init, global_rng, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_tokenization_canine.py b/tests/canine/test_tokenization_canine.py similarity index 99% rename from tests/test_tokenization_canine.py rename to tests/canine/test_tokenization_canine.py index d52cf82be7..2171013280 100644 --- a/tests/test_tokenization_canine.py +++ b/tests/canine/test_tokenization_canine.py @@ -24,7 +24,7 @@ from transformers.file_utils import cached_property from transformers.testing_utils import require_tokenizers, require_torch from transformers.tokenization_utils import AddedToken -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin class CanineTokenizationTest(TokenizerTesterMixin, unittest.TestCase): diff --git a/tests/clip/__init__.py b/tests/clip/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_feature_extraction_clip.py b/tests/clip/test_feature_extraction_clip.py similarity index 99% rename from tests/test_feature_extraction_clip.py rename to tests/clip/test_feature_extraction_clip.py index eac10af6f4..915600cb30 100644 --- a/tests/test_feature_extraction_clip.py +++ b/tests/clip/test_feature_extraction_clip.py @@ -21,7 +21,7 @@ import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision -from .test_feature_extraction_common import FeatureExtractionSavingTestMixin +from ..test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_torch_available(): diff --git a/tests/test_modeling_clip.py b/tests/clip/test_modeling_clip.py similarity index 99% rename from tests/test_modeling_clip.py rename to tests/clip/test_modeling_clip.py index 353461bd1b..57d1b69a92 100644 --- a/tests/test_modeling_clip.py +++ b/tests/clip/test_modeling_clip.py @@ -36,8 +36,14 @@ from transformers.testing_utils import ( torch_device, ) -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ( + ModelTesterMixin, + _config_zero_init, + floats_tensor, + ids_tensor, + random_attention_mask, +) if is_torch_available(): diff --git a/tests/test_modeling_flax_clip.py b/tests/clip/test_modeling_flax_clip.py similarity index 99% rename from tests/test_modeling_flax_clip.py rename to tests/clip/test_modeling_flax_clip.py index 00f5c47a09..adad20befa 100644 --- a/tests/test_modeling_flax_clip.py +++ b/tests/clip/test_modeling_flax_clip.py @@ -8,7 +8,7 @@ import transformers from transformers import CLIPConfig, CLIPTextConfig, CLIPVisionConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, slow -from .test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask +from ..test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): diff --git a/tests/test_modeling_tf_clip.py b/tests/clip/test_modeling_tf_clip.py similarity index 99% rename from tests/test_modeling_tf_clip.py rename to tests/clip/test_modeling_tf_clip.py index 36b78f7c00..564543dc67 100644 --- a/tests/test_modeling_tf_clip.py +++ b/tests/clip/test_modeling_tf_clip.py @@ -26,8 +26,8 @@ from transformers import CLIPConfig, CLIPTextConfig, CLIPVisionConfig from transformers.file_utils import is_tf_available, is_vision_available from transformers.testing_utils import is_pt_tf_cross_test, require_tf, require_vision, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_tf_available(): diff --git a/tests/test_processor_clip.py b/tests/clip/test_processor_clip.py similarity index 100% rename from tests/test_processor_clip.py rename to tests/clip/test_processor_clip.py diff --git a/tests/test_tokenization_clip.py b/tests/clip/test_tokenization_clip.py similarity index 99% rename from tests/test_tokenization_clip.py rename to tests/clip/test_tokenization_clip.py index 9b854f8ce3..2ad48ca710 100644 --- a/tests/test_tokenization_clip.py +++ b/tests/clip/test_tokenization_clip.py @@ -22,7 +22,7 @@ from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin @require_tokenizers diff --git a/tests/convbert/__init__.py b/tests/convbert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_convbert.py b/tests/convbert/test_modeling_convbert.py similarity index 99% rename from tests/test_modeling_convbert.py rename to tests/convbert/test_modeling_convbert.py index dccf7662e7..a6b41b02d2 100644 --- a/tests/test_modeling_convbert.py +++ b/tests/convbert/test_modeling_convbert.py @@ -17,13 +17,12 @@ import os import tempfile import unittest -from tests.test_modeling_common import floats_tensor from transformers import ConvBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_modeling_tf_convbert.py b/tests/convbert/test_modeling_tf_convbert.py similarity index 99% rename from tests/test_modeling_tf_convbert.py rename to tests/convbert/test_modeling_tf_convbert.py index e882bc64fd..ff4cbb1aa9 100644 --- a/tests/test_modeling_tf_convbert.py +++ b/tests/convbert/test_modeling_tf_convbert.py @@ -19,8 +19,8 @@ import unittest from transformers import ConvBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/convnext/__init__.py b/tests/convnext/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_feature_extraction_convnext.py b/tests/convnext/test_feature_extraction_convnext.py similarity index 98% rename from tests/test_feature_extraction_convnext.py rename to tests/convnext/test_feature_extraction_convnext.py index 1439f3a28c..47d8298dbb 100644 --- a/tests/test_feature_extraction_convnext.py +++ b/tests/convnext/test_feature_extraction_convnext.py @@ -21,7 +21,7 @@ import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision -from .test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs +from ..test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs if is_torch_available(): diff --git a/tests/test_modeling_convnext.py b/tests/convnext/test_modeling_convnext.py similarity index 99% rename from tests/test_modeling_convnext.py rename to tests/convnext/test_modeling_convnext.py index c351685a41..31aa0aaff7 100644 --- a/tests/test_modeling_convnext.py +++ b/tests/convnext/test_modeling_convnext.py @@ -23,8 +23,8 @@ from transformers import ConvNextConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor if is_torch_available(): diff --git a/tests/cpm/__init__.py b/tests/cpm/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_tokenization_cpm.py b/tests/cpm/test_tokenization_cpm.py similarity index 96% rename from tests/test_tokenization_cpm.py rename to tests/cpm/test_tokenization_cpm.py index c65e8f0752..1d66778b8c 100644 --- a/tests/test_tokenization_cpm.py +++ b/tests/cpm/test_tokenization_cpm.py @@ -16,7 +16,7 @@ from transformers.models.cpm.tokenization_cpm import CpmTokenizer from transformers.testing_utils import custom_tokenizers -from .test_modeling_xlnet import XLNetModelTest +from ..xlnet.test_modeling_xlnet import XLNetModelTest @custom_tokenizers diff --git a/tests/ctrl/__init__.py b/tests/ctrl/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_ctrl.py b/tests/ctrl/test_modeling_ctrl.py similarity index 97% rename from tests/test_modeling_ctrl.py rename to tests/ctrl/test_modeling_ctrl.py index 15736ad8e3..3daf31fd98 100644 --- a/tests/test_modeling_ctrl.py +++ b/tests/ctrl/test_modeling_ctrl.py @@ -18,9 +18,9 @@ import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_modeling_tf_ctrl.py b/tests/ctrl/test_modeling_tf_ctrl.py similarity index 98% rename from tests/test_modeling_tf_ctrl.py rename to tests/ctrl/test_modeling_tf_ctrl.py index 6e4d73cc57..65b984b51c 100644 --- a/tests/test_modeling_tf_ctrl.py +++ b/tests/ctrl/test_modeling_tf_ctrl.py @@ -19,8 +19,8 @@ import unittest from transformers import CTRLConfig, is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_ctrl.py b/tests/ctrl/test_tokenization_ctrl.py similarity index 97% rename from tests/test_tokenization_ctrl.py rename to tests/ctrl/test_tokenization_ctrl.py index f4cd52d601..54eb8d2186 100644 --- a/tests/test_tokenization_ctrl.py +++ b/tests/ctrl/test_tokenization_ctrl.py @@ -19,7 +19,7 @@ import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin class CTRLTokenizationTest(TokenizerTesterMixin, unittest.TestCase): diff --git a/tests/deberta/__init__.py b/tests/deberta/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_deberta.py b/tests/deberta/test_modeling_deberta.py similarity index 98% rename from tests/test_modeling_deberta.py rename to tests/deberta/test_modeling_deberta.py index 0c769eb8e5..1902f9389d 100644 --- a/tests/test_modeling_deberta.py +++ b/tests/deberta/test_modeling_deberta.py @@ -17,8 +17,8 @@ import unittest from transformers import DebertaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/test_modeling_tf_deberta.py b/tests/deberta/test_modeling_tf_deberta.py similarity index 98% rename from tests/test_modeling_tf_deberta.py rename to tests/deberta/test_modeling_tf_deberta.py index 8d490569ee..581f6f02f4 100644 --- a/tests/test_modeling_tf_deberta.py +++ b/tests/deberta/test_modeling_tf_deberta.py @@ -19,8 +19,8 @@ import unittest from transformers import DebertaConfig, is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_deberta.py b/tests/deberta/test_tokenization_deberta.py similarity index 99% rename from tests/test_tokenization_deberta.py rename to tests/deberta/test_tokenization_deberta.py index 33bf5efe1a..229ea22618 100644 --- a/tests/test_tokenization_deberta.py +++ b/tests/deberta/test_tokenization_deberta.py @@ -22,7 +22,7 @@ from transformers import DebertaTokenizer, DebertaTokenizerFast from transformers.models.deberta.tokenization_deberta import VOCAB_FILES_NAMES from transformers.testing_utils import slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin class DebertaTokenizationTest(TokenizerTesterMixin, unittest.TestCase): diff --git a/tests/deberta_v2/__init__.py b/tests/deberta_v2/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_deberta_v2.py b/tests/deberta_v2/test_modeling_deberta_v2.py similarity index 98% rename from tests/test_modeling_deberta_v2.py rename to tests/deberta_v2/test_modeling_deberta_v2.py index 5e022cc5d7..48f3a673b6 100644 --- a/tests/test_modeling_deberta_v2.py +++ b/tests/deberta_v2/test_modeling_deberta_v2.py @@ -17,8 +17,8 @@ import unittest from transformers import DebertaV2Config, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/test_modeling_tf_deberta_v2.py b/tests/deberta_v2/test_modeling_tf_deberta_v2.py similarity index 98% rename from tests/test_modeling_tf_deberta_v2.py rename to tests/deberta_v2/test_modeling_tf_deberta_v2.py index 25d558790c..391afee597 100644 --- a/tests/test_modeling_tf_deberta_v2.py +++ b/tests/deberta_v2/test_modeling_tf_deberta_v2.py @@ -19,8 +19,8 @@ import unittest from transformers import DebertaV2Config, is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_deberta_v2.py b/tests/deberta_v2/test_tokenization_deberta_v2.py similarity index 97% rename from tests/test_tokenization_deberta_v2.py rename to tests/deberta_v2/test_tokenization_deberta_v2.py index 5f79903a3b..be414551f6 100644 --- a/tests/test_tokenization_deberta_v2.py +++ b/tests/deberta_v2/test_tokenization_deberta_v2.py @@ -15,14 +15,15 @@ import os import unittest +from os.path import dirname from transformers import DebertaV2Tokenizer from transformers.testing_utils import require_sentencepiece, require_tokenizers, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/spiece.model") +SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/spiece.model") @require_sentencepiece diff --git a/tests/deepspeed/__init__.py b/tests/deepspeed/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/deepspeed/test_deepspeed.py b/tests/deepspeed/test_deepspeed.py index 5e27b6e698..de7e2819ac 100644 --- a/tests/deepspeed/test_deepspeed.py +++ b/tests/deepspeed/test_deepspeed.py @@ -27,7 +27,6 @@ from transformers.testing_utils import ( CaptureLogger, CaptureStd, CaptureStderr, - ExtendSysPath, LoggingLevel, TestCasePlus, execute_subprocess_async, @@ -40,14 +39,11 @@ from transformers.testing_utils import ( ) from transformers.trainer_utils import get_last_checkpoint, set_seed +from ..trainer.test_trainer import TrainerIntegrationCommon # noqa -tests_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) -root_dir = os.path.dirname(tests_dir) -with ExtendSysPath(tests_dir): - from test_trainer import TrainerIntegrationCommon # noqa - if is_torch_available(): - from test_trainer import RegressionModelConfig, RegressionPreTrainedModel, get_regression_trainer # noqa +if is_torch_available(): + from ..trainer.test_trainer import RegressionModelConfig, RegressionPreTrainedModel, get_regression_trainer # noqa set_seed(42) diff --git a/tests/deepspeed/test_model_zoo.py b/tests/deepspeed/test_model_zoo.py index f2b04abab7..12958b8ec8 100644 --- a/tests/deepspeed/test_model_zoo.py +++ b/tests/deepspeed/test_model_zoo.py @@ -15,11 +15,11 @@ import itertools import os import subprocess +from os.path import dirname from parameterized import parameterized from transformers import is_torch_available from transformers.testing_utils import ( - ExtendSysPath, TestCasePlus, execute_subprocess_async, get_gpu_count, @@ -29,14 +29,11 @@ from transformers.testing_utils import ( ) from transformers.trainer_utils import set_seed +from ..trainer.test_trainer import TrainerIntegrationCommon # noqa -tests_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) -root_dir = os.path.dirname(tests_dir) -with ExtendSysPath(tests_dir): - from test_trainer import TrainerIntegrationCommon # noqa - if is_torch_available(): - from test_trainer import RegressionModelConfig, RegressionPreTrainedModel, get_regression_trainer # noqa +if is_torch_available(): + from ..trainer.test_trainer import RegressionModelConfig, RegressionPreTrainedModel, get_regression_trainer # noqa set_seed(42) @@ -70,6 +67,8 @@ ELECTRA_TINY = "hf-internal-testing/tiny-electra" XLNET_TINY = "sshleifer/tiny-xlnet-base-cased" BERT_TINY = "hf-internal-testing/tiny-bert" +FIXTURE_DIRECTORY = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures") +ROOT_DIRECTORY = os.path.join(dirname(dirname(dirname(os.path.abspath(__file__))))) # TODO: to add: # albert @@ -97,10 +96,9 @@ def get_launcher(distributed=False): def make_task_cmds(): - data_dir_fixtures = f"{tests_dir}/fixtures" - data_dir_samples = f"{data_dir_fixtures}/tests_samples" - data_dir_wmt = f"{data_dir_samples}/wmt_en_ro" - data_dir_xsum = f"{data_dir_samples}/xsum" + data_dir_samples = f"{FIXTURE_DIRECTORY}/tests_samples" + data_dir_wmt = f"{FIXTURE_DIRECTORY}/wmt_en_ro" + data_dir_xsum = f"{FIXTURE_DIRECTORY}/xsum" args_main = """ --do_train --max_train_samples 4 @@ -143,7 +141,7 @@ def make_task_cmds(): ], ) - scripts_dir = f"{root_dir}/examples/pytorch" + scripts_dir = f"{ROOT_DIRECTORY}/examples/pytorch" tasks = dict( trans=f""" @@ -161,12 +159,12 @@ def make_task_cmds(): """, clm=f""" {scripts_dir}/language-modeling/run_clm.py - --train_file {data_dir_fixtures}/sample_text.txt + --train_file {FIXTURE_DIRECTORY}/sample_text.txt --block_size 8 """, mlm=f""" {scripts_dir}/language-modeling/run_mlm.py - --train_file {data_dir_fixtures}/sample_text.txt + --train_file {FIXTURE_DIRECTORY}/sample_text.txt """, qa=f""" {scripts_dir}/question-answering/run_qa.py diff --git a/tests/deit/__init__.py b/tests/deit/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_feature_extraction_deit.py b/tests/deit/test_feature_extraction_deit.py similarity index 98% rename from tests/test_feature_extraction_deit.py rename to tests/deit/test_feature_extraction_deit.py index dc86074dc9..94cf791389 100644 --- a/tests/test_feature_extraction_deit.py +++ b/tests/deit/test_feature_extraction_deit.py @@ -21,7 +21,7 @@ import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision -from .test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs +from ..test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs if is_torch_available(): diff --git a/tests/test_modeling_deit.py b/tests/deit/test_modeling_deit.py similarity index 99% rename from tests/test_modeling_deit.py rename to tests/deit/test_modeling_deit.py index d829e59b8e..92e6d1c14b 100644 --- a/tests/test_modeling_deit.py +++ b/tests/deit/test_modeling_deit.py @@ -23,8 +23,8 @@ from transformers.file_utils import cached_property, is_torch_available, is_visi from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor if is_torch_available(): diff --git a/tests/detr/__init__.py b/tests/detr/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_feature_extraction_detr.py b/tests/detr/test_feature_extraction_detr.py similarity index 99% rename from tests/test_feature_extraction_detr.py rename to tests/detr/test_feature_extraction_detr.py index 4207d88fe0..372ef06a5c 100644 --- a/tests/test_feature_extraction_detr.py +++ b/tests/detr/test_feature_extraction_detr.py @@ -23,7 +23,7 @@ import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow -from .test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs +from ..test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs if is_torch_available(): diff --git a/tests/test_modeling_detr.py b/tests/detr/test_modeling_detr.py similarity index 99% rename from tests/test_modeling_detr.py rename to tests/detr/test_modeling_detr.py index 5fba425f25..5236cbf1b2 100644 --- a/tests/test_modeling_detr.py +++ b/tests/detr/test_modeling_detr.py @@ -23,9 +23,9 @@ from transformers import DetrConfig, is_timm_available, is_vision_available from transformers.file_utils import cached_property from transformers.testing_utils import require_timm, require_vision, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor if is_timm_available(): diff --git a/tests/distilbert/__init__.py b/tests/distilbert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_distilbert.py b/tests/distilbert/test_modeling_distilbert.py similarity index 98% rename from tests/test_modeling_distilbert.py rename to tests/distilbert/test_modeling_distilbert.py index b81e42bcf1..535ce2604d 100644 --- a/tests/test_modeling_distilbert.py +++ b/tests/distilbert/test_modeling_distilbert.py @@ -19,8 +19,8 @@ import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_modeling_flax_distilbert.py b/tests/distilbert/test_modeling_flax_distilbert.py similarity index 98% rename from tests/test_modeling_flax_distilbert.py rename to tests/distilbert/test_modeling_flax_distilbert.py index bcf7211462..2ad10c0785 100644 --- a/tests/test_modeling_flax_distilbert.py +++ b/tests/distilbert/test_modeling_flax_distilbert.py @@ -19,7 +19,7 @@ import numpy as np from transformers import DistilBertConfig, is_flax_available from transformers.testing_utils import require_flax, slow -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): diff --git a/tests/test_modeling_tf_distilbert.py b/tests/distilbert/test_modeling_tf_distilbert.py similarity index 98% rename from tests/test_modeling_tf_distilbert.py rename to tests/distilbert/test_modeling_tf_distilbert.py index 23a8f29d12..7a146e9c3b 100644 --- a/tests/test_modeling_tf_distilbert.py +++ b/tests/distilbert/test_modeling_tf_distilbert.py @@ -19,8 +19,8 @@ import unittest from transformers import DistilBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_distilbert.py b/tests/distilbert/test_tokenization_distilbert.py similarity index 96% rename from tests/test_tokenization_distilbert.py rename to tests/distilbert/test_tokenization_distilbert.py index 3fb3801560..7b2c97d78a 100644 --- a/tests/test_tokenization_distilbert.py +++ b/tests/distilbert/test_tokenization_distilbert.py @@ -17,7 +17,7 @@ from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow -from .test_tokenization_bert import BertTokenizationTest +from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers diff --git a/tests/dpr/__init__.py b/tests/dpr/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_dpr.py b/tests/dpr/test_modeling_dpr.py similarity index 98% rename from tests/test_modeling_dpr.py rename to tests/dpr/test_modeling_dpr.py index 5636c2a802..7aef57f753 100644 --- a/tests/test_modeling_dpr.py +++ b/tests/dpr/test_modeling_dpr.py @@ -20,8 +20,8 @@ import unittest from transformers import DPRConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_modeling_tf_dpr.py b/tests/dpr/test_modeling_tf_dpr.py similarity index 98% rename from tests/test_modeling_tf_dpr.py rename to tests/dpr/test_modeling_tf_dpr.py index 39e82fd3ab..7a48a2254e 100644 --- a/tests/test_modeling_tf_dpr.py +++ b/tests/dpr/test_modeling_tf_dpr.py @@ -18,8 +18,8 @@ import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_dpr.py b/tests/dpr/test_tokenization_dpr.py similarity index 98% rename from tests/test_tokenization_dpr.py rename to tests/dpr/test_tokenization_dpr.py index bc5ccb319e..2870e0bcf3 100644 --- a/tests/test_tokenization_dpr.py +++ b/tests/dpr/test_tokenization_dpr.py @@ -26,7 +26,7 @@ from transformers import ( from transformers.testing_utils import require_tokenizers, slow from transformers.tokenization_utils_base import BatchEncoding -from .test_tokenization_bert import BertTokenizationTest +from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers diff --git a/tests/electra/__init__.py b/tests/electra/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_electra.py b/tests/electra/test_modeling_electra.py similarity index 99% rename from tests/test_modeling_electra.py rename to tests/electra/test_modeling_electra.py index 065d596826..4a6a1b1357 100644 --- a/tests/test_modeling_electra.py +++ b/tests/electra/test_modeling_electra.py @@ -20,8 +20,8 @@ from transformers import ElectraConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_modeling_flax_electra.py b/tests/electra/test_modeling_flax_electra.py similarity index 98% rename from tests/test_modeling_flax_electra.py rename to tests/electra/test_modeling_flax_electra.py index 0232788370..390c8be39e 100644 --- a/tests/test_modeling_flax_electra.py +++ b/tests/electra/test_modeling_flax_electra.py @@ -5,7 +5,7 @@ import numpy as np from transformers import ElectraConfig, is_flax_available from transformers.testing_utils import require_flax, slow -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): diff --git a/tests/test_modeling_tf_electra.py b/tests/electra/test_modeling_tf_electra.py similarity index 98% rename from tests/test_modeling_tf_electra.py rename to tests/electra/test_modeling_tf_electra.py index 0f62720236..9a5e6bf177 100644 --- a/tests/test_modeling_tf_electra.py +++ b/tests/electra/test_modeling_tf_electra.py @@ -19,8 +19,8 @@ import unittest from transformers import ElectraConfig, is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/encoder_decoder/__init__.py b/tests/encoder_decoder/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_encoder_decoder.py b/tests/encoder_decoder/test_modeling_encoder_decoder.py similarity index 98% rename from tests/test_modeling_encoder_decoder.py rename to tests/encoder_decoder/test_modeling_encoder_decoder.py index 2c9de822c6..7e1d3b0c97 100644 --- a/tests/test_modeling_encoder_decoder.py +++ b/tests/encoder_decoder/test_modeling_encoder_decoder.py @@ -20,13 +20,13 @@ import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_modeling_bart import BartStandaloneDecoderModelTester -from .test_modeling_bert import BertModelTester -from .test_modeling_bert_generation import BertGenerationEncoderTester -from .test_modeling_common import ids_tensor -from .test_modeling_gpt2 import GPT2ModelTester -from .test_modeling_prophetnet import ProphetNetStandaloneDecoderModelTester -from .test_modeling_roberta import RobertaModelTester +from ..bart.test_modeling_bart import BartStandaloneDecoderModelTester +from ..bert.test_modeling_bert import BertModelTester +from ..bert_generation.test_modeling_bert_generation import BertGenerationEncoderTester +from ..gpt2.test_modeling_gpt2 import GPT2ModelTester +from ..prophetnet.test_modeling_prophetnet import ProphetNetStandaloneDecoderModelTester +from ..roberta.test_modeling_roberta import RobertaModelTester +from ..test_modeling_common import ids_tensor if is_torch_available(): @@ -840,7 +840,7 @@ class GPT2EncoderDecoderModelTest(EncoderDecoderMixin, unittest.TestCase): } def get_pretrained_model(self): - return EncoderDecoderModel.from_encoder_decoder_pretrained("bert-base-cased", "gpt2") + return EncoderDecoderModel.from_encoder_decoder_pretrained("bert-base-cased", "../gpt2") def test_encoder_decoder_model_shared_weights(self): pass @@ -851,7 +851,7 @@ class GPT2EncoderDecoderModelTest(EncoderDecoderMixin, unittest.TestCase): model.to(torch_device) tokenizer_in = AutoTokenizer.from_pretrained("bert-base-cased") - tokenizer_out = AutoTokenizer.from_pretrained("gpt2") + tokenizer_out = AutoTokenizer.from_pretrained("../gpt2") ARTICLE_STUDENTS = """(CNN)Sigma Alpha Epsilon is under fire for a video showing party-bound fraternity members singing a racist chant. SAE's national chapter suspended the students, but University of Oklahoma President David Boren took it a step further, saying the university's affiliation with the fraternity is permanently done. The news is shocking, but it's not the first time SAE has faced controversy. SAE was founded March 9, 1856, at the University of Alabama, five years before the American Civil War, according to the fraternity website. When the war began, the group had fewer than 400 members, of which "369 went to war for the Confederate States and seven for the Union Army," the website says. The fraternity now boasts more than 200,000 living alumni, along with about 15,000 undergraduates populating 219 chapters and 20 "colonies" seeking full membership at universities. SAE has had to work hard to change recently after a string of member deaths, many blamed on the hazing of new recruits, SAE national President Bradley Cohen wrote in a message on the fraternity's website. The fraternity's website lists more than 130 chapters cited or suspended for "health and safety incidents" since 2010. At least 30 of the incidents involved hazing, and dozens more involved alcohol. However, the list is missing numerous incidents from recent months. Among them, according to various media outlets: Yale University banned the SAEs from campus activities last month after members allegedly tried to interfere with a sexual misconduct investigation connected to an initiation rite. Stanford University in December suspended SAE housing privileges after finding sorority members attending a fraternity function were subjected to graphic sexual content. And Johns Hopkins University in November suspended the fraternity for underage drinking. "The media has labeled us as the 'nation's deadliest fraternity,' " Cohen said. In 2011, for example, a student died while being coerced into excessive alcohol consumption, according to a lawsuit. SAE's previous insurer dumped the fraternity. "As a result, we are paying Lloyd's of London the highest insurance rates in the Greek-letter world," Cohen said. Universities have turned down SAE's attempts to open new chapters, and the fraternity had to close 12 in 18 months over hazing incidents.""" diff --git a/tests/test_modeling_flax_encoder_decoder.py b/tests/encoder_decoder/test_modeling_flax_encoder_decoder.py similarity index 99% rename from tests/test_modeling_flax_encoder_decoder.py rename to tests/encoder_decoder/test_modeling_flax_encoder_decoder.py index 267329f29d..60be9f420c 100644 --- a/tests/test_modeling_flax_encoder_decoder.py +++ b/tests/encoder_decoder/test_modeling_flax_encoder_decoder.py @@ -22,9 +22,9 @@ import numpy as np from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, slow, torch_device -from .test_modeling_flax_bert import FlaxBertModelTester -from .test_modeling_flax_common import ids_tensor -from .test_modeling_flax_gpt2 import FlaxGPT2ModelTester +from ..bert.test_modeling_flax_bert import FlaxBertModelTester +from ..gpt2.test_modeling_flax_gpt2 import FlaxGPT2ModelTester +from ..test_modeling_flax_common import ids_tensor if is_flax_available(): diff --git a/tests/test_modeling_tf_encoder_decoder.py b/tests/encoder_decoder/test_modeling_tf_encoder_decoder.py similarity index 99% rename from tests/test_modeling_tf_encoder_decoder.py rename to tests/encoder_decoder/test_modeling_tf_encoder_decoder.py index 3655348ab5..6479d2b505 100644 --- a/tests/test_modeling_tf_encoder_decoder.py +++ b/tests/encoder_decoder/test_modeling_tf_encoder_decoder.py @@ -24,11 +24,11 @@ import numpy as np from transformers import is_tf_available, is_torch_available from transformers.testing_utils import is_pt_tf_cross_test, require_tf, require_torch, slow, torch_device -from .test_modeling_tf_bert import TFBertModelTester -from .test_modeling_tf_common import ids_tensor -from .test_modeling_tf_gpt2 import TFGPT2ModelTester -from .test_modeling_tf_rembert import TFRemBertModelTester -from .test_modeling_tf_roberta import TFRobertaModelTester +from ..bert.test_modeling_tf_bert import TFBertModelTester +from ..gpt2.test_modeling_tf_gpt2 import TFGPT2ModelTester +from ..rembert.test_modeling_tf_rembert import TFRemBertModelTester +from ..roberta.test_modeling_tf_roberta import TFRobertaModelTester +from ..test_modeling_tf_common import ids_tensor if is_tf_available(): @@ -634,7 +634,7 @@ class TFBertEncoderDecoderModelTest(TFEncoderDecoderMixin, unittest.TestCase): @require_tf class TFGPT2EncoderDecoderModelTest(TFEncoderDecoderMixin, unittest.TestCase): def get_pretrained_model(self): - return TFEncoderDecoderModel.from_encoder_decoder_pretrained("bert-base-cased", "gpt2") + return TFEncoderDecoderModel.from_encoder_decoder_pretrained("bert-base-cased", "../gpt2") def get_encoder_decoder_model(self, config, decoder_config): encoder_model = TFBertModel(config, name="encoder") @@ -694,7 +694,7 @@ class TFGPT2EncoderDecoderModelTest(TFEncoderDecoderMixin, unittest.TestCase): from transformers import EncoderDecoderModel tokenizer_in = AutoTokenizer.from_pretrained("bert-base-cased") - tokenizer_out = AutoTokenizer.from_pretrained("gpt2") + tokenizer_out = AutoTokenizer.from_pretrained("../gpt2") """Not working, because pt checkpoint has `encoder.encoder.layer...` while tf model has `encoder.bert.encoder.layer...`. (For GPT2 decoder, there is no issue) diff --git a/tests/flaubert/__init__.py b/tests/flaubert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_flaubert.py b/tests/flaubert/test_modeling_flaubert.py similarity index 99% rename from tests/test_modeling_flaubert.py rename to tests/flaubert/test_modeling_flaubert.py index cf81970f0a..4c01abd459 100644 --- a/tests/test_modeling_flaubert.py +++ b/tests/flaubert/test_modeling_flaubert.py @@ -19,8 +19,8 @@ import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_modeling_tf_flaubert.py b/tests/flaubert/test_modeling_tf_flaubert.py similarity index 99% rename from tests/test_modeling_tf_flaubert.py rename to tests/flaubert/test_modeling_tf_flaubert.py index cd2f053ca7..62503bac28 100644 --- a/tests/test_modeling_tf_flaubert.py +++ b/tests/flaubert/test_modeling_tf_flaubert.py @@ -18,8 +18,8 @@ import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/fnet/__init__.py b/tests/fnet/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_fnet.py b/tests/fnet/test_modeling_fnet.py similarity index 99% rename from tests/test_modeling_fnet.py rename to tests/fnet/test_modeling_fnet.py index eaa61f779f..5ab5c4a57c 100644 --- a/tests/test_modeling_fnet.py +++ b/tests/fnet/test_modeling_fnet.py @@ -22,8 +22,8 @@ from transformers import FNetConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor if is_torch_available(): diff --git a/tests/test_tokenization_fnet.py b/tests/fnet/test_tokenization_fnet.py similarity index 99% rename from tests/test_tokenization_fnet.py rename to tests/fnet/test_tokenization_fnet.py index d04ebf995b..a620ccf1f3 100644 --- a/tests/test_tokenization_fnet.py +++ b/tests/fnet/test_tokenization_fnet.py @@ -20,10 +20,10 @@ from transformers import FNetTokenizer, FNetTokenizerFast from transformers.testing_utils import require_sentencepiece, require_tokenizers, slow, tooslow from transformers.tokenization_utils import AddedToken -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/spiece.model") +SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../fixtures/spiece.model") @require_sentencepiece diff --git a/tests/fsmt/__init__.py b/tests/fsmt/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_fsmt.py b/tests/fsmt/test_modeling_fsmt.py similarity index 99% rename from tests/test_modeling_fsmt.py rename to tests/fsmt/test_modeling_fsmt.py index 8d8bb77142..3ac2b9e3b2 100644 --- a/tests/test_modeling_fsmt.py +++ b/tests/fsmt/test_modeling_fsmt.py @@ -23,9 +23,9 @@ from transformers import FSMTConfig, is_torch_available from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/test_tokenization_fsmt.py b/tests/fsmt/test_tokenization_fsmt.py similarity index 99% rename from tests/test_tokenization_fsmt.py rename to tests/fsmt/test_tokenization_fsmt.py index 05c80ee3df..b28df8a589 100644 --- a/tests/test_tokenization_fsmt.py +++ b/tests/fsmt/test_tokenization_fsmt.py @@ -22,7 +22,7 @@ from transformers.file_utils import cached_property from transformers.models.fsmt.tokenization_fsmt import VOCAB_FILES_NAMES, FSMTTokenizer from transformers.testing_utils import slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin # using a different tiny model than the one used for default params defined in init to ensure proper testing diff --git a/tests/funnel/__init__.py b/tests/funnel/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_funnel.py b/tests/funnel/test_modeling_funnel.py similarity index 99% rename from tests/test_modeling_funnel.py rename to tests/funnel/test_modeling_funnel.py index 9ed3b0339b..481593ac23 100644 --- a/tests/test_modeling_funnel.py +++ b/tests/funnel/test_modeling_funnel.py @@ -20,8 +20,8 @@ from transformers import FunnelConfig, FunnelTokenizer, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/test_modeling_tf_funnel.py b/tests/funnel/test_modeling_tf_funnel.py similarity index 99% rename from tests/test_modeling_tf_funnel.py rename to tests/funnel/test_modeling_tf_funnel.py index 524becbb00..6105f9ab80 100644 --- a/tests/test_modeling_tf_funnel.py +++ b/tests/funnel/test_modeling_tf_funnel.py @@ -19,8 +19,8 @@ import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_funnel.py b/tests/funnel/test_tokenization_funnel.py similarity index 97% rename from tests/test_tokenization_funnel.py rename to tests/funnel/test_tokenization_funnel.py index 0cb76a7ef0..592f19b411 100644 --- a/tests/test_tokenization_funnel.py +++ b/tests/funnel/test_tokenization_funnel.py @@ -21,7 +21,7 @@ from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin @require_tokenizers diff --git a/tests/generation/__init__.py b/tests/generation/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_generation_beam_search.py b/tests/generation/test_generation_beam_search.py similarity index 99% rename from tests/test_generation_beam_search.py rename to tests/generation/test_generation_beam_search.py index ec6a94e0b3..b50be51e1b 100644 --- a/tests/test_generation_beam_search.py +++ b/tests/generation/test_generation_beam_search.py @@ -19,7 +19,7 @@ import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device -from .test_modeling_common import floats_tensor, ids_tensor +from ..test_modeling_common import floats_tensor, ids_tensor if is_torch_available(): diff --git a/tests/test_generation_flax_logits_process.py b/tests/generation/test_generation_flax_logits_process.py similarity index 99% rename from tests/test_generation_flax_logits_process.py rename to tests/generation/test_generation_flax_logits_process.py index dd74783a80..43ed7923d2 100644 --- a/tests/test_generation_flax_logits_process.py +++ b/tests/generation/test_generation_flax_logits_process.py @@ -21,7 +21,7 @@ import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax -from .test_modeling_flax_common import ids_tensor +from ..test_modeling_flax_common import ids_tensor if is_flax_available(): diff --git a/tests/test_generation_flax_utils.py b/tests/generation/test_generation_flax_utils.py similarity index 100% rename from tests/test_generation_flax_utils.py rename to tests/generation/test_generation_flax_utils.py diff --git a/tests/test_generation_logits_process.py b/tests/generation/test_generation_logits_process.py similarity index 99% rename from tests/test_generation_logits_process.py rename to tests/generation/test_generation_logits_process.py index 7b6c78b286..d8873bc02f 100644 --- a/tests/test_generation_logits_process.py +++ b/tests/generation/test_generation_logits_process.py @@ -19,7 +19,7 @@ import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device -from .test_modeling_common import ids_tensor +from ..test_modeling_common import ids_tensor if is_torch_available(): diff --git a/tests/test_generation_stopping_criteria.py b/tests/generation/test_generation_stopping_criteria.py similarity index 81% rename from tests/test_generation_stopping_criteria.py rename to tests/generation/test_generation_stopping_criteria.py index d3de2c56da..38b2b97bad 100644 --- a/tests/test_generation_stopping_criteria.py +++ b/tests/generation/test_generation_stopping_criteria.py @@ -1,10 +1,25 @@ +# coding=utf-8 +# Copyright 2020 The HuggingFace Team Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a clone of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import time import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device -from .test_modeling_common import ids_tensor +from ..test_modeling_common import ids_tensor if is_torch_available(): diff --git a/tests/test_generation_tf_logits_process.py b/tests/generation/test_generation_tf_logits_process.py similarity index 99% rename from tests/test_generation_tf_logits_process.py rename to tests/generation/test_generation_tf_logits_process.py index fb9eb086e4..3869ddbc40 100644 --- a/tests/test_generation_tf_logits_process.py +++ b/tests/generation/test_generation_tf_logits_process.py @@ -32,7 +32,7 @@ if is_tf_available(): ) from transformers.tf_utils import set_tensor_by_indices_to_value - from .test_modeling_tf_common import ids_tensor + from ..test_modeling_tf_common import ids_tensor @require_tf diff --git a/tests/test_generation_utils.py b/tests/generation/test_generation_utils.py similarity index 99% rename from tests/test_generation_utils.py rename to tests/generation/test_generation_utils.py index dbe7c25397..dd99b9ff2b 100644 --- a/tests/test_generation_utils.py +++ b/tests/generation/test_generation_utils.py @@ -20,7 +20,7 @@ import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_modeling_common import floats_tensor, ids_tensor +from ..test_modeling_common import floats_tensor, ids_tensor if is_torch_available(): @@ -2312,8 +2312,8 @@ class GenerationIntegrationTests(unittest.TestCase): @slow def test_constrained_beam_search(self): - model = GPT2LMHeadModel.from_pretrained("gpt2").to(torch_device) - tokenizer = GPT2Tokenizer.from_pretrained("gpt2") + model = GPT2LMHeadModel.from_pretrained("../gpt2").to(torch_device) + tokenizer = GPT2Tokenizer.from_pretrained("../gpt2") force_tokens = tokenizer.encode(" scared", return_tensors="pt").to(torch_device)[0] force_tokens_2 = tokenizer.encode(" big weapons", return_tensors="pt").to(torch_device)[0] diff --git a/tests/gpt2/__init__.py b/tests/gpt2/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_flax_gpt2.py b/tests/gpt2/test_modeling_flax_gpt2.py similarity index 98% rename from tests/test_modeling_flax_gpt2.py rename to tests/gpt2/test_modeling_flax_gpt2.py index 3eed483a6f..7be52b5a11 100644 --- a/tests/test_modeling_flax_gpt2.py +++ b/tests/gpt2/test_modeling_flax_gpt2.py @@ -22,8 +22,8 @@ import transformers from transformers import GPT2Config, GPT2Tokenizer, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, slow -from .test_generation_flax_utils import FlaxGenerationTesterMixin -from .test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask +from ..generation.test_generation_flax_utils import FlaxGenerationTesterMixin +from ..test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): diff --git a/tests/test_modeling_gpt2.py b/tests/gpt2/test_modeling_gpt2.py similarity index 99% rename from tests/test_modeling_gpt2.py rename to tests/gpt2/test_modeling_gpt2.py index cd13be27bb..e80c924310 100644 --- a/tests/test_modeling_gpt2.py +++ b/tests/gpt2/test_modeling_gpt2.py @@ -21,9 +21,9 @@ import unittest from transformers import GPT2Config, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_modeling_tf_gpt2.py b/tests/gpt2/test_modeling_tf_gpt2.py similarity index 98% rename from tests/test_modeling_tf_gpt2.py rename to tests/gpt2/test_modeling_tf_gpt2.py index 4f66ec89f4..27d30a630a 100644 --- a/tests/test_modeling_tf_gpt2.py +++ b/tests/gpt2/test_modeling_tf_gpt2.py @@ -18,9 +18,9 @@ import unittest from transformers import GPT2Config, is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor -from .test_modeling_tf_core import TFCoreModelTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor +from ..utils.test_modeling_tf_core import TFCoreModelTesterMixin if is_tf_available(): diff --git a/tests/test_tokenization_gpt2.py b/tests/gpt2/test_tokenization_gpt2.py similarity index 99% rename from tests/test_tokenization_gpt2.py rename to tests/gpt2/test_tokenization_gpt2.py index 8d70d8814e..96f18e166c 100644 --- a/tests/test_tokenization_gpt2.py +++ b/tests/gpt2/test_tokenization_gpt2.py @@ -22,7 +22,7 @@ from transformers import GPT2Tokenizer, GPT2TokenizerFast from transformers.models.gpt2.tokenization_gpt2 import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin @require_tokenizers diff --git a/tests/gpt_neo/__init__.py b/tests/gpt_neo/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_flax_gpt_neo.py b/tests/gpt_neo/test_modeling_flax_gpt_neo.py similarity index 98% rename from tests/test_modeling_flax_gpt_neo.py rename to tests/gpt_neo/test_modeling_flax_gpt_neo.py index 7d0d832295..580138a7b3 100644 --- a/tests/test_modeling_flax_gpt_neo.py +++ b/tests/gpt_neo/test_modeling_flax_gpt_neo.py @@ -22,8 +22,8 @@ import transformers from transformers import GPT2Tokenizer, GPTNeoConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, slow -from .test_generation_flax_utils import FlaxGenerationTesterMixin -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask +from ..generation.test_generation_flax_utils import FlaxGenerationTesterMixin +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): diff --git a/tests/test_modeling_gpt_neo.py b/tests/gpt_neo/test_modeling_gpt_neo.py similarity index 98% rename from tests/test_modeling_gpt_neo.py rename to tests/gpt_neo/test_modeling_gpt_neo.py index b8f942ef17..ffb6352baf 100644 --- a/tests/test_modeling_gpt_neo.py +++ b/tests/gpt_neo/test_modeling_gpt_neo.py @@ -21,9 +21,9 @@ from transformers import GPTNeoConfig, is_torch_available from transformers.file_utils import cached_property from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): @@ -95,7 +95,7 @@ class GPTNeoModelTester: self.attention_types = attention_types def get_large_model_config(self): - return GPTNeoConfig.from_pretrained("gpt_neo") + return GPTNeoConfig.from_pretrained("gpt-neo-125M") def prepare_config_and_inputs(self): input_ids = ids_tensor([self.batch_size, self.seq_length], self.vocab_size) diff --git a/tests/gptj/__init__.py b/tests/gptj/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_flax_gptj.py b/tests/gptj/test_modeling_flax_gptj.py similarity index 98% rename from tests/test_modeling_flax_gptj.py rename to tests/gptj/test_modeling_flax_gptj.py index 35cfd2b0a5..3a6d71b7bf 100644 --- a/tests/test_modeling_flax_gptj.py +++ b/tests/gptj/test_modeling_flax_gptj.py @@ -22,8 +22,8 @@ import transformers from transformers import GPT2Tokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow -from .test_generation_flax_utils import FlaxGenerationTesterMixin -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask +from ..generation.test_generation_flax_utils import FlaxGenerationTesterMixin +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): diff --git a/tests/test_modeling_gptj.py b/tests/gptj/test_modeling_gptj.py similarity index 99% rename from tests/test_modeling_gptj.py rename to tests/gptj/test_modeling_gptj.py index d6b9f92926..0cabb2342b 100644 --- a/tests/test_modeling_gptj.py +++ b/tests/gptj/test_modeling_gptj.py @@ -20,9 +20,9 @@ import unittest from transformers import GPTJConfig, is_torch_available from transformers.testing_utils import require_torch, slow, tooslow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/herbert/__init__.py b/tests/herbert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_tokenization_herbert.py b/tests/herbert/test_tokenization_herbert.py similarity index 98% rename from tests/test_tokenization_herbert.py rename to tests/herbert/test_tokenization_herbert.py index e8569406bf..d4a30e241d 100644 --- a/tests/test_tokenization_herbert.py +++ b/tests/herbert/test_tokenization_herbert.py @@ -22,7 +22,7 @@ from transformers import HerbertTokenizer, HerbertTokenizerFast from transformers.models.herbert.tokenization_herbert import VOCAB_FILES_NAMES from transformers.testing_utils import get_tests_dir, require_tokenizers, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin @require_tokenizers diff --git a/tests/hubert/__init__.py b/tests/hubert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_hubert.py b/tests/hubert/test_modeling_hubert.py similarity index 99% rename from tests/test_modeling_hubert.py rename to tests/hubert/test_modeling_hubert.py index da3ff2a794..3177aa3d02 100644 --- a/tests/test_modeling_hubert.py +++ b/tests/hubert/test_modeling_hubert.py @@ -20,12 +20,17 @@ import unittest import pytest -from tests.test_modeling_common import floats_tensor, ids_tensor, random_attention_mask from transformers import HubertConfig, is_torch_available from transformers.testing_utils import require_soundfile, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, _config_zero_init +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ( + ModelTesterMixin, + _config_zero_init, + floats_tensor, + ids_tensor, + random_attention_mask, +) if is_torch_available(): diff --git a/tests/test_modeling_tf_hubert.py b/tests/hubert/test_modeling_tf_hubert.py similarity index 99% rename from tests/test_modeling_tf_hubert.py rename to tests/hubert/test_modeling_tf_hubert.py index fb878f5905..5331395b89 100644 --- a/tests/test_modeling_tf_hubert.py +++ b/tests/hubert/test_modeling_tf_hubert.py @@ -25,8 +25,8 @@ import pytest from transformers import is_tf_available from transformers.testing_utils import require_soundfile, require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/ibert/__init__.py b/tests/ibert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_ibert.py b/tests/ibert/test_modeling_ibert.py similarity index 99% rename from tests/test_modeling_ibert.py rename to tests/ibert/test_modeling_ibert.py index fed2a80d65..41819d973b 100755 --- a/tests/test_modeling_ibert.py +++ b/tests/ibert/test_modeling_ibert.py @@ -20,8 +20,8 @@ import unittest from transformers import IBertConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/imagegpt/__init__.py b/tests/imagegpt/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_feature_extraction_imagegpt.py b/tests/imagegpt/test_feature_extraction_imagegpt.py similarity index 98% rename from tests/test_feature_extraction_imagegpt.py rename to tests/imagegpt/test_feature_extraction_imagegpt.py index f8744cfa32..ea5859ecc9 100644 --- a/tests/test_feature_extraction_imagegpt.py +++ b/tests/imagegpt/test_feature_extraction_imagegpt.py @@ -25,7 +25,7 @@ from datasets import load_dataset from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow -from .test_feature_extraction_common import FeatureExtractionSavingTestMixin +from ..test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_torch_available(): diff --git a/tests/test_modeling_imagegpt.py b/tests/imagegpt/test_modeling_imagegpt.py similarity index 98% rename from tests/test_modeling_imagegpt.py rename to tests/imagegpt/test_modeling_imagegpt.py index 2a59d4c1bd..597ccd4137 100644 --- a/tests/test_modeling_imagegpt.py +++ b/tests/imagegpt/test_modeling_imagegpt.py @@ -24,9 +24,15 @@ from transformers import ImageGPTConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor, random_attention_mask +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ( + ModelTesterMixin, + _config_zero_init, + floats_tensor, + ids_tensor, + random_attention_mask, +) if is_torch_available(): diff --git a/tests/layoutlm/__init__.py b/tests/layoutlm/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_layoutlm.py b/tests/layoutlm/test_modeling_layoutlm.py similarity index 99% rename from tests/test_modeling_layoutlm.py rename to tests/layoutlm/test_modeling_layoutlm.py index 67423fe21f..faf4458cc8 100644 --- a/tests/test_modeling_layoutlm.py +++ b/tests/layoutlm/test_modeling_layoutlm.py @@ -19,8 +19,8 @@ import unittest from transformers import LayoutLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/test_modeling_tf_layoutlm.py b/tests/layoutlm/test_modeling_tf_layoutlm.py similarity index 99% rename from tests/test_modeling_tf_layoutlm.py rename to tests/layoutlm/test_modeling_tf_layoutlm.py index 6ff1368891..89df181a47 100644 --- a/tests/test_modeling_tf_layoutlm.py +++ b/tests/layoutlm/test_modeling_tf_layoutlm.py @@ -20,8 +20,8 @@ import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_layoutlm.py b/tests/layoutlm/test_tokenization_layoutlm.py similarity index 97% rename from tests/test_tokenization_layoutlm.py rename to tests/layoutlm/test_tokenization_layoutlm.py index 79831cd30c..dab5121658 100644 --- a/tests/test_tokenization_layoutlm.py +++ b/tests/layoutlm/test_tokenization_layoutlm.py @@ -21,7 +21,7 @@ from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin @require_tokenizers diff --git a/tests/layoutlmv2/__init__.py b/tests/layoutlmv2/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_feature_extraction_layoutlmv2.py b/tests/layoutlmv2/test_feature_extraction_layoutlmv2.py similarity index 99% rename from tests/test_feature_extraction_layoutlmv2.py rename to tests/layoutlmv2/test_feature_extraction_layoutlmv2.py index 1a01ec6a2a..e849a752a9 100644 --- a/tests/test_feature_extraction_layoutlmv2.py +++ b/tests/layoutlmv2/test_feature_extraction_layoutlmv2.py @@ -21,7 +21,7 @@ import numpy as np from transformers.file_utils import is_pytesseract_available, is_torch_available from transformers.testing_utils import require_pytesseract, require_torch -from .test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs +from ..test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs if is_torch_available(): diff --git a/tests/test_modeling_layoutlmv2.py b/tests/layoutlmv2/test_modeling_layoutlmv2.py similarity index 99% rename from tests/test_modeling_layoutlmv2.py rename to tests/layoutlmv2/test_modeling_layoutlmv2.py index 4e02f985f7..fbf96c2031 100644 --- a/tests/test_modeling_layoutlmv2.py +++ b/tests/layoutlmv2/test_modeling_layoutlmv2.py @@ -23,8 +23,8 @@ import unittest from transformers.file_utils import is_detectron2_available, is_torch_available from transformers.testing_utils import require_detectron2, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, _config_zero_init, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, _config_zero_init, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_processor_layoutlmv2.py b/tests/layoutlmv2/test_processor_layoutlmv2.py similarity index 100% rename from tests/test_processor_layoutlmv2.py rename to tests/layoutlmv2/test_processor_layoutlmv2.py diff --git a/tests/test_tokenization_layoutlmv2.py b/tests/layoutlmv2/test_tokenization_layoutlmv2.py similarity index 99% rename from tests/test_tokenization_layoutlmv2.py rename to tests/layoutlmv2/test_tokenization_layoutlmv2.py index c6b0802038..291b8ca0e7 100644 --- a/tests/test_tokenization_layoutlmv2.py +++ b/tests/layoutlmv2/test_tokenization_layoutlmv2.py @@ -40,7 +40,7 @@ from transformers.testing_utils import ( slow, ) -from .test_tokenization_common import ( +from ..test_tokenization_common import ( SMALL_TRAINING_CORPUS, TokenizerTesterMixin, filter_non_english, diff --git a/tests/layoutxlm/__init__.py b/tests/layoutxlm/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_processor_layoutxlm.py b/tests/layoutxlm/test_processor_layoutxlm.py similarity index 99% rename from tests/test_processor_layoutxlm.py rename to tests/layoutxlm/test_processor_layoutxlm.py index 0ba24d3dac..82f2daa1df 100644 --- a/tests/test_processor_layoutxlm.py +++ b/tests/layoutxlm/test_processor_layoutxlm.py @@ -17,6 +17,7 @@ import os import shutil import tempfile import unittest +from os.path import dirname from typing import List from transformers import PreTrainedTokenizer, PreTrainedTokenizerBase, PreTrainedTokenizerFast @@ -37,7 +38,7 @@ if is_pytesseract_available(): from transformers import LayoutLMv2FeatureExtractor, LayoutXLMProcessor -SAMPLE_SP = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") +SAMPLE_SP = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model") @require_pytesseract diff --git a/tests/test_tokenization_layoutxlm.py b/tests/layoutxlm/test_tokenization_layoutxlm.py similarity index 99% rename from tests/test_tokenization_layoutxlm.py rename to tests/layoutxlm/test_tokenization_layoutxlm.py index b0643cfe68..09ca5061fc 100644 --- a/tests/test_tokenization_layoutxlm.py +++ b/tests/layoutxlm/test_tokenization_layoutxlm.py @@ -32,7 +32,7 @@ from transformers.testing_utils import ( slow, ) -from .test_tokenization_common import ( +from ..test_tokenization_common import ( SMALL_TRAINING_CORPUS, TokenizerTesterMixin, filter_non_english, @@ -40,7 +40,7 @@ from .test_tokenization_common import ( ) -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") +SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../fixtures/test_sentencepiece.model") @require_sentencepiece diff --git a/tests/led/__init__.py b/tests/led/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_led.py b/tests/led/test_modeling_led.py similarity index 99% rename from tests/test_modeling_led.py rename to tests/led/test_modeling_led.py index db38604f00..5312dfc7a4 100644 --- a/tests/test_modeling_led.py +++ b/tests/led/test_modeling_led.py @@ -24,9 +24,9 @@ from transformers.file_utils import cached_property from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/test_modeling_tf_led.py b/tests/led/test_modeling_tf_led.py similarity index 99% rename from tests/test_modeling_tf_led.py rename to tests/led/test_modeling_tf_led.py index a77f17f872..6870c2b08c 100644 --- a/tests/test_modeling_tf_led.py +++ b/tests/led/test_modeling_tf_led.py @@ -19,8 +19,8 @@ import unittest from transformers import LEDConfig, is_tf_available from transformers.testing_utils import is_pt_tf_cross_test, require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/longformer/__init__.py b/tests/longformer/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_longformer.py b/tests/longformer/test_modeling_longformer.py similarity index 99% rename from tests/test_modeling_longformer.py rename to tests/longformer/test_modeling_longformer.py index a291d07678..2da2d2e40b 100644 --- a/tests/test_modeling_longformer.py +++ b/tests/longformer/test_modeling_longformer.py @@ -19,8 +19,8 @@ import unittest from transformers import LongformerConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_modeling_tf_longformer.py b/tests/longformer/test_modeling_tf_longformer.py similarity index 99% rename from tests/test_modeling_tf_longformer.py rename to tests/longformer/test_modeling_tf_longformer.py index 7ba7b1a25d..37c1ce5349 100644 --- a/tests/test_modeling_tf_longformer.py +++ b/tests/longformer/test_modeling_tf_longformer.py @@ -19,8 +19,8 @@ import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/luke/__init__.py b/tests/luke/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_luke.py b/tests/luke/test_modeling_luke.py similarity index 99% rename from tests/test_modeling_luke.py rename to tests/luke/test_modeling_luke.py index 94b9fe7695..99a34cc81c 100644 --- a/tests/test_modeling_luke.py +++ b/tests/luke/test_modeling_luke.py @@ -18,8 +18,8 @@ import unittest from transformers import LukeConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_tokenization_luke.py b/tests/luke/test_tokenization_luke.py similarity index 98% rename from tests/test_tokenization_luke.py rename to tests/luke/test_tokenization_luke.py index 2def172d53..456246384c 100644 --- a/tests/test_tokenization_luke.py +++ b/tests/luke/test_tokenization_luke.py @@ -15,17 +15,18 @@ import os import unittest +from os.path import dirname from typing import Tuple from transformers import AddedToken, LukeTokenizer from transformers.testing_utils import require_torch, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/vocab.json") -SAMPLE_MERGE_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/merges.txt") -SAMPLE_ENTITY_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_entity_vocab.json") +SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/vocab.json") +SAMPLE_MERGE_FILE = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/merges.txt") +SAMPLE_ENTITY_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_entity_vocab.json") class LukeTokenizerTest(TokenizerTesterMixin, unittest.TestCase): diff --git a/tests/lxmert/__init__.py b/tests/lxmert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_lxmert.py b/tests/lxmert/test_modeling_lxmert.py similarity index 99% rename from tests/test_modeling_lxmert.py rename to tests/lxmert/test_modeling_lxmert.py index 652e6473c7..adbfbb2ab1 100644 --- a/tests/test_modeling_lxmert.py +++ b/tests/lxmert/test_modeling_lxmert.py @@ -26,8 +26,8 @@ from transformers import LxmertConfig, is_tf_available, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import is_pt_tf_cross_test, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): @@ -48,8 +48,6 @@ if is_tf_available(): class LxmertModelTester: - """You can also import this e.g from .test_modeling_bart import BartModelTester""" - def __init__( self, parent, diff --git a/tests/test_modeling_tf_lxmert.py b/tests/lxmert/test_modeling_tf_lxmert.py similarity index 99% rename from tests/test_modeling_tf_lxmert.py rename to tests/lxmert/test_modeling_tf_lxmert.py index 81ff51e61d..8d91d249d9 100644 --- a/tests/test_modeling_tf_lxmert.py +++ b/tests/lxmert/test_modeling_tf_lxmert.py @@ -22,8 +22,8 @@ import numpy as np from transformers import LxmertConfig, is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_lxmert.py b/tests/lxmert/test_tokenization_lxmert.py similarity index 98% rename from tests/test_tokenization_lxmert.py rename to tests/lxmert/test_tokenization_lxmert.py index a19ea8095d..38b76074c6 100644 --- a/tests/test_tokenization_lxmert.py +++ b/tests/lxmert/test_tokenization_lxmert.py @@ -21,7 +21,7 @@ from transformers import LxmertTokenizer, LxmertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin @require_tokenizers diff --git a/tests/m2m_100/__init__.py b/tests/m2m_100/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_m2m_100.py b/tests/m2m_100/test_modeling_m2m_100.py similarity index 98% rename from tests/test_modeling_m2m_100.py rename to tests/m2m_100/test_modeling_m2m_100.py index 4625a25a74..3393764429 100644 --- a/tests/test_modeling_m2m_100.py +++ b/tests/m2m_100/test_modeling_m2m_100.py @@ -23,9 +23,9 @@ from transformers import M2M100Config, is_torch_available from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/test_tokenization_m2m_100.py b/tests/m2m_100/test_tokenization_m2m_100.py similarity index 98% rename from tests/test_tokenization_m2m_100.py rename to tests/m2m_100/test_tokenization_m2m_100.py index 5c9e2083af..55c2ec11d8 100644 --- a/tests/test_tokenization_m2m_100.py +++ b/tests/m2m_100/test_tokenization_m2m_100.py @@ -15,6 +15,7 @@ import os import tempfile import unittest +from os.path import dirname from pathlib import Path from shutil import copyfile @@ -26,11 +27,11 @@ from transformers.testing_utils import nested_simplify, require_sentencepiece, r if is_sentencepiece_available(): from transformers.models.m2m_100.tokenization_m2m_100 import save_json, VOCAB_FILES_NAMES -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin if is_sentencepiece_available(): - SAMPLE_SP = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") + SAMPLE_SP = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model") if is_torch_available(): diff --git a/tests/marian/__init__.py b/tests/marian/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_flax_marian.py b/tests/marian/test_modeling_flax_marian.py similarity index 99% rename from tests/test_modeling_flax_marian.py rename to tests/marian/test_modeling_flax_marian.py index c0438819e2..ecd1906f38 100644 --- a/tests/test_modeling_flax_marian.py +++ b/tests/marian/test_modeling_flax_marian.py @@ -21,8 +21,8 @@ from transformers import MarianConfig, is_flax_available from transformers.file_utils import cached_property from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow -from .test_generation_flax_utils import FlaxGenerationTesterMixin -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor +from ..generation.test_generation_flax_utils import FlaxGenerationTesterMixin +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): diff --git a/tests/test_modeling_marian.py b/tests/marian/test_modeling_marian.py similarity index 99% rename from tests/test_modeling_marian.py rename to tests/marian/test_modeling_marian.py index 82d4742509..8ecbb8f244 100644 --- a/tests/test_modeling_marian.py +++ b/tests/marian/test_modeling_marian.py @@ -22,9 +22,9 @@ from transformers import MarianConfig, is_torch_available from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/test_modeling_tf_marian.py b/tests/marian/test_modeling_tf_marian.py similarity index 99% rename from tests/test_modeling_tf_marian.py rename to tests/marian/test_modeling_tf_marian.py index ae0e8d02b7..fb7b8629f9 100644 --- a/tests/test_modeling_tf_marian.py +++ b/tests/marian/test_modeling_tf_marian.py @@ -22,8 +22,8 @@ from transformers import AutoTokenizer, MarianConfig, MarianTokenizer, Translati from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_marian.py b/tests/marian/test_tokenization_marian.py similarity index 97% rename from tests/test_tokenization_marian.py rename to tests/marian/test_tokenization_marian.py index 557b7675b6..7109546a79 100644 --- a/tests/test_tokenization_marian.py +++ b/tests/marian/test_tokenization_marian.py @@ -16,6 +16,7 @@ import os import tempfile import unittest +from os.path import dirname from pathlib import Path from shutil import copyfile @@ -27,10 +28,10 @@ from transformers.testing_utils import require_sentencepiece, slow if is_sentencepiece_available(): from transformers.models.marian.tokenization_marian import VOCAB_FILES_NAMES, save_json -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin -SAMPLE_SP = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") +SAMPLE_SP = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model") mock_tokenizer_config = {"target_lang": "fi", "source_lang": "en"} zh_code = ">>zh<<" diff --git a/tests/mbart/__init__.py b/tests/mbart/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_flax_mbart.py b/tests/mbart/test_modeling_flax_mbart.py similarity index 99% rename from tests/test_modeling_flax_mbart.py rename to tests/mbart/test_modeling_flax_mbart.py index 007df91ab1..64e062784d 100644 --- a/tests/test_modeling_flax_mbart.py +++ b/tests/mbart/test_modeling_flax_mbart.py @@ -21,8 +21,8 @@ from transformers import MBartConfig, is_flax_available from transformers.file_utils import cached_property from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow -from .test_generation_flax_utils import FlaxGenerationTesterMixin -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor +from ..generation.test_generation_flax_utils import FlaxGenerationTesterMixin +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): diff --git a/tests/test_modeling_mbart.py b/tests/mbart/test_modeling_mbart.py similarity index 99% rename from tests/test_modeling_mbart.py rename to tests/mbart/test_modeling_mbart.py index 229eb96e90..fb297457d9 100644 --- a/tests/test_modeling_mbart.py +++ b/tests/mbart/test_modeling_mbart.py @@ -23,9 +23,9 @@ from transformers import MBartConfig, is_torch_available from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/test_modeling_tf_mbart.py b/tests/mbart/test_modeling_tf_mbart.py similarity index 99% rename from tests/test_modeling_tf_mbart.py rename to tests/mbart/test_modeling_tf_mbart.py index e69aee3c07..ae1cfe040d 100644 --- a/tests/test_modeling_tf_mbart.py +++ b/tests/mbart/test_modeling_tf_mbart.py @@ -20,8 +20,8 @@ from transformers import AutoTokenizer, MBartConfig, is_tf_available from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_mbart.py b/tests/mbart/test_tokenization_mbart.py similarity index 99% rename from tests/test_tokenization_mbart.py rename to tests/mbart/test_tokenization_mbart.py index aa4868e858..3b842b60fb 100644 --- a/tests/test_tokenization_mbart.py +++ b/tests/mbart/test_tokenization_mbart.py @@ -20,10 +20,10 @@ import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import nested_simplify, require_sentencepiece, require_tokenizers, require_torch -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") +SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../fixtures/test_sentencepiece.model") if is_torch_available(): diff --git a/tests/mbart50/__init__.py b/tests/mbart50/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_tokenization_mbart50.py b/tests/mbart50/test_tokenization_mbart50.py similarity index 98% rename from tests/test_tokenization_mbart50.py rename to tests/mbart50/test_tokenization_mbart50.py index 4f076e2f09..3e39beb67b 100644 --- a/tests/test_tokenization_mbart50.py +++ b/tests/mbart50/test_tokenization_mbart50.py @@ -16,15 +16,15 @@ import os import shutil import tempfile import unittest +from os.path import dirname from transformers import SPIECE_UNDERLINE, BatchEncoding, MBart50Tokenizer, MBart50TokenizerFast, is_torch_available from transformers.testing_utils import nested_simplify, require_sentencepiece, require_tokenizers, require_torch, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") - +SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model") if is_torch_available(): from transformers.models.mbart.modeling_mbart import shift_tokens_right diff --git a/tests/megatron_bert/__init__.py b/tests/megatron_bert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_megatron_bert.py b/tests/megatron_bert/test_modeling_megatron_bert.py similarity index 99% rename from tests/test_modeling_megatron_bert.py rename to tests/megatron_bert/test_modeling_megatron_bert.py index 7ac507988f..01b93bf13a 100644 --- a/tests/test_modeling_megatron_bert.py +++ b/tests/megatron_bert/test_modeling_megatron_bert.py @@ -23,8 +23,8 @@ from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/megatron_gpt2/__init__.py b/tests/megatron_gpt2/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_megatron_gpt2.py b/tests/megatron_gpt2/test_modeling_megatron_gpt2.py similarity index 100% rename from tests/test_modeling_megatron_gpt2.py rename to tests/megatron_gpt2/test_modeling_megatron_gpt2.py diff --git a/tests/mluke/__init__.py b/tests/mluke/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_tokenization_mluke.py b/tests/mluke/test_tokenization_mluke.py similarity index 98% rename from tests/test_tokenization_mluke.py rename to tests/mluke/test_tokenization_mluke.py index 9652e44aa9..c1d5ef6399 100644 --- a/tests/test_tokenization_mluke.py +++ b/tests/mluke/test_tokenization_mluke.py @@ -16,16 +16,17 @@ import os import unittest +from os.path import dirname from typing import Tuple from transformers.models.mluke.tokenization_mluke import MLukeTokenizer from transformers.testing_utils import require_torch, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") -SAMPLE_ENTITY_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_entity_vocab.json") +SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model") +SAMPLE_ENTITY_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_entity_vocab.json") class MLukeTokenizerTest(TokenizerTesterMixin, unittest.TestCase): diff --git a/tests/mobilebert/__init__.py b/tests/mobilebert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_mobilebert.py b/tests/mobilebert/test_modeling_mobilebert.py similarity index 99% rename from tests/test_modeling_mobilebert.py rename to tests/mobilebert/test_modeling_mobilebert.py index 6ca14526a6..99e8e68323 100644 --- a/tests/test_modeling_mobilebert.py +++ b/tests/mobilebert/test_modeling_mobilebert.py @@ -20,8 +20,8 @@ from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_modeling_tf_mobilebert.py b/tests/mobilebert/test_modeling_tf_mobilebert.py similarity index 99% rename from tests/test_modeling_tf_mobilebert.py rename to tests/mobilebert/test_modeling_tf_mobilebert.py index 4150204a2a..4cbfcefee8 100644 --- a/tests/test_modeling_tf_mobilebert.py +++ b/tests/mobilebert/test_modeling_tf_mobilebert.py @@ -19,8 +19,8 @@ import unittest from transformers import MobileBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/mpnet/__init__.py b/tests/mpnet/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_mpnet.py b/tests/mpnet/test_modeling_mpnet.py similarity index 98% rename from tests/test_modeling_mpnet.py rename to tests/mpnet/test_modeling_mpnet.py index 7ce155226e..6869a91c7a 100644 --- a/tests/test_modeling_mpnet.py +++ b/tests/mpnet/test_modeling_mpnet.py @@ -19,8 +19,8 @@ import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_modeling_tf_mpnet.py b/tests/mpnet/test_modeling_tf_mpnet.py similarity index 98% rename from tests/test_modeling_tf_mpnet.py rename to tests/mpnet/test_modeling_tf_mpnet.py index c0305dede9..23448610cc 100644 --- a/tests/test_modeling_tf_mpnet.py +++ b/tests/mpnet/test_modeling_tf_mpnet.py @@ -19,8 +19,8 @@ import unittest from transformers import MPNetConfig, is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_mpnet.py b/tests/mpnet/test_tokenization_mpnet.py similarity index 97% rename from tests/test_tokenization_mpnet.py rename to tests/mpnet/test_tokenization_mpnet.py index 733b2891f8..4cc677397d 100644 --- a/tests/test_tokenization_mpnet.py +++ b/tests/mpnet/test_tokenization_mpnet.py @@ -21,7 +21,7 @@ from transformers import MPNetTokenizerFast from transformers.models.mpnet.tokenization_mpnet import VOCAB_FILES_NAMES, MPNetTokenizer from transformers.testing_utils import require_tokenizers, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin @require_tokenizers diff --git a/tests/mt5/__init__.py b/tests/mt5/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_flax_mt5.py b/tests/mt5/test_modeling_flax_mt5.py similarity index 100% rename from tests/test_modeling_flax_mt5.py rename to tests/mt5/test_modeling_flax_mt5.py diff --git a/tests/test_modeling_mt5.py b/tests/mt5/test_modeling_mt5.py similarity index 100% rename from tests/test_modeling_mt5.py rename to tests/mt5/test_modeling_mt5.py diff --git a/tests/test_modeling_tf_mt5.py b/tests/mt5/test_modeling_tf_mt5.py similarity index 100% rename from tests/test_modeling_tf_mt5.py rename to tests/mt5/test_modeling_tf_mt5.py diff --git a/tests/nystromformer/__init__.py b/tests/nystromformer/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_nystromformer.py b/tests/nystromformer/test_modeling_nystromformer.py similarity index 98% rename from tests/test_modeling_nystromformer.py rename to tests/nystromformer/test_modeling_nystromformer.py index 6e7d413726..e3e962b310 100644 --- a/tests/test_modeling_nystromformer.py +++ b/tests/nystromformer/test_modeling_nystromformer.py @@ -20,8 +20,8 @@ import unittest from transformers import AutoTokenizer, NystromformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/onnx/__init__.py b/tests/onnx/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_onnx.py b/tests/onnx/test_onnx.py similarity index 100% rename from tests/test_onnx.py rename to tests/onnx/test_onnx.py diff --git a/tests/test_onnx_v2.py b/tests/onnx/test_onnx_v2.py similarity index 100% rename from tests/test_onnx_v2.py rename to tests/onnx/test_onnx_v2.py diff --git a/tests/openai/__init__.py b/tests/openai/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_openai.py b/tests/openai/test_modeling_openai.py similarity index 98% rename from tests/test_modeling_openai.py rename to tests/openai/test_modeling_openai.py index 5ad53ac52c..80babf5b51 100644 --- a/tests/test_modeling_openai.py +++ b/tests/openai/test_modeling_openai.py @@ -19,9 +19,9 @@ import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/test_modeling_tf_openai.py b/tests/openai/test_modeling_tf_openai.py similarity index 98% rename from tests/test_modeling_tf_openai.py rename to tests/openai/test_modeling_tf_openai.py index c6d3a09895..227689df59 100644 --- a/tests/test_modeling_tf_openai.py +++ b/tests/openai/test_modeling_tf_openai.py @@ -19,8 +19,8 @@ import unittest from transformers import OpenAIGPTConfig, is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_openai.py b/tests/openai/test_tokenization_openai.py similarity index 98% rename from tests/test_tokenization_openai.py rename to tests/openai/test_tokenization_openai.py index 6d3730cebc..a9ac22c928 100644 --- a/tests/test_tokenization_openai.py +++ b/tests/openai/test_tokenization_openai.py @@ -22,7 +22,7 @@ from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin @require_tokenizers diff --git a/tests/optimization/__init__.py b/tests/optimization/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_optimization.py b/tests/optimization/test_optimization.py similarity index 100% rename from tests/test_optimization.py rename to tests/optimization/test_optimization.py diff --git a/tests/test_optimization_tf.py b/tests/optimization/test_optimization_tf.py similarity index 100% rename from tests/test_optimization_tf.py rename to tests/optimization/test_optimization_tf.py diff --git a/tests/pegasus/__init__.py b/tests/pegasus/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_flax_pegasus.py b/tests/pegasus/test_modeling_flax_pegasus.py similarity index 99% rename from tests/test_modeling_flax_pegasus.py rename to tests/pegasus/test_modeling_flax_pegasus.py index 3f227cdf83..8f5c010477 100644 --- a/tests/test_modeling_flax_pegasus.py +++ b/tests/pegasus/test_modeling_flax_pegasus.py @@ -19,8 +19,8 @@ import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow -from .test_configuration_common import ConfigTester -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): diff --git a/tests/test_modeling_pegasus.py b/tests/pegasus/test_modeling_pegasus.py similarity index 98% rename from tests/test_modeling_pegasus.py rename to tests/pegasus/test_modeling_pegasus.py index 813a1e3224..3f8cdcca10 100644 --- a/tests/test_modeling_pegasus.py +++ b/tests/pegasus/test_modeling_pegasus.py @@ -21,10 +21,10 @@ from transformers import PegasusConfig, is_torch_available from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor -from .test_modeling_mbart import AbstractSeq2SeqIntegrationTest +from ..generation.test_generation_utils import GenerationTesterMixin +from ..mbart.test_modeling_mbart import AbstractSeq2SeqIntegrationTest +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/test_modeling_tf_pegasus.py b/tests/pegasus/test_modeling_tf_pegasus.py similarity index 99% rename from tests/test_modeling_tf_pegasus.py rename to tests/pegasus/test_modeling_tf_pegasus.py index fafd726d5a..b9e7c45b6d 100644 --- a/tests/test_modeling_tf_pegasus.py +++ b/tests/pegasus/test_modeling_tf_pegasus.py @@ -20,8 +20,8 @@ from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_pegasus.py b/tests/pegasus/test_tokenization_pegasus.py similarity index 99% rename from tests/test_tokenization_pegasus.py rename to tests/pegasus/test_tokenization_pegasus.py index 583eace0f7..c189ffdabb 100644 --- a/tests/test_tokenization_pegasus.py +++ b/tests/pegasus/test_tokenization_pegasus.py @@ -18,7 +18,7 @@ from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.file_utils import cached_property from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin SAMPLE_VOCAB = get_tests_dir("fixtures/test_sentencepiece_no_bos.model") diff --git a/tests/perceiver/__init__.py b/tests/perceiver/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_perceiver.py b/tests/perceiver/test_modeling_perceiver.py similarity index 99% rename from tests/test_modeling_perceiver.py rename to tests/perceiver/test_modeling_perceiver.py index 128be2d371..4d50e41e87 100644 --- a/tests/test_modeling_perceiver.py +++ b/tests/perceiver/test_modeling_perceiver.py @@ -30,8 +30,8 @@ from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_tokenization_perceiver.py b/tests/perceiver/test_tokenization_perceiver.py similarity index 99% rename from tests/test_tokenization_perceiver.py rename to tests/perceiver/test_tokenization_perceiver.py index e9cb690183..f92add4885 100644 --- a/tests/test_tokenization_perceiver.py +++ b/tests/perceiver/test_tokenization_perceiver.py @@ -24,7 +24,7 @@ from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.file_utils import cached_property, is_tf_available, is_torch_available -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin if is_torch_available(): diff --git a/tests/phobert/__init__.py b/tests/phobert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_tokenization_phobert.py b/tests/phobert/test_tokenization_phobert.py similarity index 97% rename from tests/test_tokenization_phobert.py rename to tests/phobert/test_tokenization_phobert.py index b5d42c8a24..87bdb95c52 100644 --- a/tests/test_tokenization_phobert.py +++ b/tests/phobert/test_tokenization_phobert.py @@ -18,7 +18,7 @@ import unittest from transformers.models.phobert.tokenization_phobert import VOCAB_FILES_NAMES, PhobertTokenizer -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin class PhobertTokenizationTest(TokenizerTesterMixin, unittest.TestCase): diff --git a/tests/pipelines/__init__.py b/tests/pipelines/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_pipelines_audio_classification.py b/tests/pipelines/test_pipelines_audio_classification.py similarity index 100% rename from tests/test_pipelines_audio_classification.py rename to tests/pipelines/test_pipelines_audio_classification.py diff --git a/tests/test_pipelines_automatic_speech_recognition.py b/tests/pipelines/test_pipelines_automatic_speech_recognition.py similarity index 100% rename from tests/test_pipelines_automatic_speech_recognition.py rename to tests/pipelines/test_pipelines_automatic_speech_recognition.py diff --git a/tests/test_pipelines_common.py b/tests/pipelines/test_pipelines_common.py similarity index 100% rename from tests/test_pipelines_common.py rename to tests/pipelines/test_pipelines_common.py diff --git a/tests/test_pipelines_conversational.py b/tests/pipelines/test_pipelines_conversational.py similarity index 100% rename from tests/test_pipelines_conversational.py rename to tests/pipelines/test_pipelines_conversational.py diff --git a/tests/test_pipelines_feature_extraction.py b/tests/pipelines/test_pipelines_feature_extraction.py similarity index 100% rename from tests/test_pipelines_feature_extraction.py rename to tests/pipelines/test_pipelines_feature_extraction.py diff --git a/tests/test_pipelines_fill_mask.py b/tests/pipelines/test_pipelines_fill_mask.py similarity index 100% rename from tests/test_pipelines_fill_mask.py rename to tests/pipelines/test_pipelines_fill_mask.py diff --git a/tests/test_pipelines_image_classification.py b/tests/pipelines/test_pipelines_image_classification.py similarity index 100% rename from tests/test_pipelines_image_classification.py rename to tests/pipelines/test_pipelines_image_classification.py diff --git a/tests/test_pipelines_image_segmentation.py b/tests/pipelines/test_pipelines_image_segmentation.py similarity index 100% rename from tests/test_pipelines_image_segmentation.py rename to tests/pipelines/test_pipelines_image_segmentation.py diff --git a/tests/test_pipelines_object_detection.py b/tests/pipelines/test_pipelines_object_detection.py similarity index 100% rename from tests/test_pipelines_object_detection.py rename to tests/pipelines/test_pipelines_object_detection.py diff --git a/tests/test_pipelines_question_answering.py b/tests/pipelines/test_pipelines_question_answering.py similarity index 100% rename from tests/test_pipelines_question_answering.py rename to tests/pipelines/test_pipelines_question_answering.py diff --git a/tests/test_pipelines_summarization.py b/tests/pipelines/test_pipelines_summarization.py similarity index 100% rename from tests/test_pipelines_summarization.py rename to tests/pipelines/test_pipelines_summarization.py diff --git a/tests/test_pipelines_table_question_answering.py b/tests/pipelines/test_pipelines_table_question_answering.py similarity index 100% rename from tests/test_pipelines_table_question_answering.py rename to tests/pipelines/test_pipelines_table_question_answering.py diff --git a/tests/test_pipelines_text2text_generation.py b/tests/pipelines/test_pipelines_text2text_generation.py similarity index 100% rename from tests/test_pipelines_text2text_generation.py rename to tests/pipelines/test_pipelines_text2text_generation.py diff --git a/tests/test_pipelines_text_classification.py b/tests/pipelines/test_pipelines_text_classification.py similarity index 100% rename from tests/test_pipelines_text_classification.py rename to tests/pipelines/test_pipelines_text_classification.py diff --git a/tests/test_pipelines_text_generation.py b/tests/pipelines/test_pipelines_text_generation.py similarity index 100% rename from tests/test_pipelines_text_generation.py rename to tests/pipelines/test_pipelines_text_generation.py diff --git a/tests/test_pipelines_token_classification.py b/tests/pipelines/test_pipelines_token_classification.py similarity index 100% rename from tests/test_pipelines_token_classification.py rename to tests/pipelines/test_pipelines_token_classification.py diff --git a/tests/test_pipelines_translation.py b/tests/pipelines/test_pipelines_translation.py similarity index 100% rename from tests/test_pipelines_translation.py rename to tests/pipelines/test_pipelines_translation.py diff --git a/tests/test_pipelines_zero_shot.py b/tests/pipelines/test_pipelines_zero_shot.py similarity index 100% rename from tests/test_pipelines_zero_shot.py rename to tests/pipelines/test_pipelines_zero_shot.py diff --git a/tests/test_pipelines_zero_shot_image_classification.py b/tests/pipelines/test_pipelines_zero_shot_image_classification.py similarity index 100% rename from tests/test_pipelines_zero_shot_image_classification.py rename to tests/pipelines/test_pipelines_zero_shot_image_classification.py diff --git a/tests/plbart/__init__.py b/tests/plbart/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_plbart.py b/tests/plbart/test_modeling_plbart.py similarity index 99% rename from tests/test_modeling_plbart.py rename to tests/plbart/test_modeling_plbart.py index df652a48e2..3353b09b5a 100644 --- a/tests/test_modeling_plbart.py +++ b/tests/plbart/test_modeling_plbart.py @@ -23,9 +23,9 @@ from transformers import PLBartConfig, is_torch_available from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/test_tokenization_plbart.py b/tests/plbart/test_tokenization_plbart.py similarity index 99% rename from tests/test_tokenization_plbart.py rename to tests/plbart/test_tokenization_plbart.py index cc16770ecd..d83964e86d 100644 --- a/tests/test_tokenization_plbart.py +++ b/tests/plbart/test_tokenization_plbart.py @@ -19,10 +19,10 @@ import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, PLBartTokenizer, is_torch_available from transformers.testing_utils import nested_simplify, require_sentencepiece, require_tokenizers, require_torch -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") +SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../fixtures/test_sentencepiece.model") if is_torch_available(): diff --git a/tests/poolformer/__init__.py b/tests/poolformer/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_feature_extraction_poolformer.py b/tests/poolformer/test_feature_extraction_poolformer.py similarity index 98% rename from tests/test_feature_extraction_poolformer.py rename to tests/poolformer/test_feature_extraction_poolformer.py index cec912846c..5c61642830 100644 --- a/tests/test_feature_extraction_poolformer.py +++ b/tests/poolformer/test_feature_extraction_poolformer.py @@ -20,7 +20,7 @@ import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision -from .test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs +from ..test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs if is_torch_available(): diff --git a/tests/test_modeling_poolformer.py b/tests/poolformer/test_modeling_poolformer.py similarity index 98% rename from tests/test_modeling_poolformer.py rename to tests/poolformer/test_modeling_poolformer.py index afbb5e1a6f..87ce66ddbc 100644 --- a/tests/test_modeling_poolformer.py +++ b/tests/poolformer/test_modeling_poolformer.py @@ -23,8 +23,8 @@ from transformers import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor if is_torch_available(): diff --git a/tests/prophetnet/__init__.py b/tests/prophetnet/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_prophetnet.py b/tests/prophetnet/test_modeling_prophetnet.py similarity index 99% rename from tests/test_modeling_prophetnet.py rename to tests/prophetnet/test_modeling_prophetnet.py index 6bde319f8c..b8c5a8d8ec 100644 --- a/tests/test_modeling_prophetnet.py +++ b/tests/prophetnet/test_modeling_prophetnet.py @@ -20,9 +20,9 @@ import unittest from transformers import ProphetNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor if is_torch_available(): diff --git a/tests/test_tokenization_prophetnet.py b/tests/prophetnet/test_tokenization_prophetnet.py similarity index 99% rename from tests/test_tokenization_prophetnet.py rename to tests/prophetnet/test_tokenization_prophetnet.py index c073304aa9..270bbf53fd 100644 --- a/tests/test_tokenization_prophetnet.py +++ b/tests/prophetnet/test_tokenization_prophetnet.py @@ -28,7 +28,7 @@ from transformers.models.bert.tokenization_bert import ( from transformers.models.prophetnet.tokenization_prophetnet import VOCAB_FILES_NAMES, ProphetNetTokenizer from transformers.testing_utils import require_torch, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin class ProphetNetTokenizationTest(TokenizerTesterMixin, unittest.TestCase): diff --git a/tests/qdqbert/__init__.py b/tests/qdqbert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_qdqbert.py b/tests/qdqbert/test_modeling_qdqbert.py similarity index 99% rename from tests/test_modeling_qdqbert.py rename to tests/qdqbert/test_modeling_qdqbert.py index b667b830c8..5e53e59126 100644 --- a/tests/test_modeling_qdqbert.py +++ b/tests/qdqbert/test_modeling_qdqbert.py @@ -18,12 +18,11 @@ import unittest -from tests.test_modeling_common import floats_tensor from transformers import QDQBertConfig, is_torch_available from transformers.testing_utils import require_pytorch_quantization, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/rag/__init__.py b/tests/rag/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_rag.py b/tests/rag/test_modeling_rag.py similarity index 99% rename from tests/test_modeling_rag.py rename to tests/rag/test_modeling_rag.py index dd377d289f..ecd431a5a1 100644 --- a/tests/test_modeling_rag.py +++ b/tests/rag/test_modeling_rag.py @@ -19,6 +19,7 @@ import os import shutil import tempfile import unittest +from os.path import dirname from unittest.mock import patch import numpy as np @@ -37,15 +38,14 @@ from transformers.testing_utils import ( torch_device, ) -from .test_modeling_bart import BartModelTester -from .test_modeling_dpr import DPRModelTester -from .test_modeling_t5 import T5ModelTester +from ..bart.test_modeling_bart import BartModelTester +from ..dpr.test_modeling_dpr import DPRModelTester +from ..t5.test_modeling_t5 import T5ModelTester TOLERANCE = 1e-3 -T5_SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") - +T5_SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model") if is_torch_available() and is_datasets_available() and is_faiss_available(): import torch from datasets import Dataset diff --git a/tests/test_modeling_tf_rag.py b/tests/rag/test_modeling_tf_rag.py similarity index 99% rename from tests/test_modeling_tf_rag.py rename to tests/rag/test_modeling_tf_rag.py index f9c940f76b..7f201e7638 100644 --- a/tests/test_modeling_tf_rag.py +++ b/tests/rag/test_modeling_tf_rag.py @@ -34,8 +34,8 @@ if is_tf_available() and is_datasets_available() and is_faiss_available(): from transformers.modeling_tf_outputs import TFBaseModelOutput -from .test_modeling_tf_bart import TFBartModelTester -from .test_modeling_tf_dpr import TFDPRModelTester +from ..bart.test_modeling_tf_bart import TFBartModelTester +from ..dpr.test_modeling_tf_dpr import TFDPRModelTester TOLERANCE = 1e-3 diff --git a/tests/test_retrieval_rag.py b/tests/rag/test_retrieval_rag.py similarity index 100% rename from tests/test_retrieval_rag.py rename to tests/rag/test_retrieval_rag.py diff --git a/tests/test_tokenization_rag.py b/tests/rag/test_tokenization_rag.py similarity index 100% rename from tests/test_tokenization_rag.py rename to tests/rag/test_tokenization_rag.py diff --git a/tests/realm/__init__.py b/tests/realm/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_realm.py b/tests/realm/test_modeling_realm.py similarity index 99% rename from tests/test_modeling_realm.py rename to tests/realm/test_modeling_realm.py index d9d0ede90c..99d09ac48f 100644 --- a/tests/test_modeling_realm.py +++ b/tests/realm/test_modeling_realm.py @@ -19,12 +19,11 @@ import unittest import numpy as np -from tests.test_modeling_common import floats_tensor from transformers import RealmConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_retrieval_realm.py b/tests/realm/test_retrieval_realm.py similarity index 100% rename from tests/test_retrieval_realm.py rename to tests/realm/test_retrieval_realm.py diff --git a/tests/test_tokenization_realm.py b/tests/realm/test_tokenization_realm.py similarity index 99% rename from tests/test_tokenization_realm.py rename to tests/realm/test_tokenization_realm.py index 95e0d720f8..6bc31eaa57 100644 --- a/tests/test_tokenization_realm.py +++ b/tests/realm/test_tokenization_realm.py @@ -28,7 +28,7 @@ from transformers.models.bert.tokenization_bert import ( from transformers.models.realm.tokenization_realm import RealmTokenizer from transformers.testing_utils import require_tokenizers, slow -from .test_tokenization_common import TokenizerTesterMixin, filter_non_english +from ..test_tokenization_common import TokenizerTesterMixin, filter_non_english @require_tokenizers diff --git a/tests/reformer/__init__.py b/tests/reformer/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_reformer.py b/tests/reformer/test_modeling_reformer.py similarity index 99% rename from tests/test_modeling_reformer.py rename to tests/reformer/test_modeling_reformer.py index 4ccaa41245..d0259bacae 100644 --- a/tests/test_modeling_reformer.py +++ b/tests/reformer/test_modeling_reformer.py @@ -25,9 +25,9 @@ from transformers.testing_utils import ( torch_device, ) -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_tokenization_reformer.py b/tests/reformer/test_tokenization_reformer.py similarity index 98% rename from tests/test_tokenization_reformer.py rename to tests/reformer/test_tokenization_reformer.py index 398f3fd8e6..3ca818d1cd 100644 --- a/tests/test_tokenization_reformer.py +++ b/tests/reformer/test_tokenization_reformer.py @@ -14,15 +14,16 @@ import os import unittest +from os.path import dirname from transformers import SPIECE_UNDERLINE, ReformerTokenizer, ReformerTokenizerFast from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") +SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model") @require_sentencepiece diff --git a/tests/rembert/__init__.py b/tests/rembert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_rembert.py b/tests/rembert/test_modeling_rembert.py similarity index 99% rename from tests/test_modeling_rembert.py rename to tests/rembert/test_modeling_rembert.py index 688b96b484..94ec90497f 100644 --- a/tests/test_modeling_rembert.py +++ b/tests/rembert/test_modeling_rembert.py @@ -17,12 +17,11 @@ import unittest -from tests.test_modeling_common import floats_tensor from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_modeling_tf_rembert.py b/tests/rembert/test_modeling_tf_rembert.py similarity index 99% rename from tests/test_modeling_tf_rembert.py rename to tests/rembert/test_modeling_tf_rembert.py index a6d7d35cf9..81dad5d327 100644 --- a/tests/test_modeling_tf_rembert.py +++ b/tests/rembert/test_modeling_tf_rembert.py @@ -19,8 +19,8 @@ import unittest from transformers import RemBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor if is_tf_available(): diff --git a/tests/roberta/__init__.py b/tests/roberta/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_flax_roberta.py b/tests/roberta/test_modeling_flax_roberta.py similarity index 98% rename from tests/test_modeling_flax_roberta.py rename to tests/roberta/test_modeling_flax_roberta.py index aadbc135bc..db92868769 100644 --- a/tests/test_modeling_flax_roberta.py +++ b/tests/roberta/test_modeling_flax_roberta.py @@ -19,7 +19,7 @@ import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): diff --git a/tests/test_modeling_roberta.py b/tests/roberta/test_modeling_roberta.py similarity index 99% rename from tests/test_modeling_roberta.py rename to tests/roberta/test_modeling_roberta.py index 1a55fda152..ab92c9dfbd 100644 --- a/tests/test_modeling_roberta.py +++ b/tests/roberta/test_modeling_roberta.py @@ -20,9 +20,9 @@ from copy import deepcopy from transformers import RobertaConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_modeling_tf_roberta.py b/tests/roberta/test_modeling_tf_roberta.py similarity index 98% rename from tests/test_modeling_tf_roberta.py rename to tests/roberta/test_modeling_tf_roberta.py index 082df3b0bb..5cda74ccc4 100644 --- a/tests/test_modeling_tf_roberta.py +++ b/tests/roberta/test_modeling_tf_roberta.py @@ -19,8 +19,8 @@ import unittest from transformers import RobertaConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_roberta.py b/tests/roberta/test_tokenization_roberta.py similarity index 99% rename from tests/test_tokenization_roberta.py rename to tests/roberta/test_tokenization_roberta.py index 8b37a20e5a..a898d9bf5f 100644 --- a/tests/test_tokenization_roberta.py +++ b/tests/roberta/test_tokenization_roberta.py @@ -23,7 +23,7 @@ from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin @require_tokenizers diff --git a/tests/roformer/__init__.py b/tests/roformer/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_flax_roformer.py b/tests/roformer/test_modeling_flax_roformer.py similarity index 98% rename from tests/test_modeling_flax_roformer.py rename to tests/roformer/test_modeling_flax_roformer.py index cd1af7caf6..01b643e897 100644 --- a/tests/test_modeling_flax_roformer.py +++ b/tests/roformer/test_modeling_flax_roformer.py @@ -19,7 +19,7 @@ import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): diff --git a/tests/test_modeling_roformer.py b/tests/roformer/test_modeling_roformer.py similarity index 99% rename from tests/test_modeling_roformer.py rename to tests/roformer/test_modeling_roformer.py index 9a32c63079..f5177a91d5 100644 --- a/tests/test_modeling_roformer.py +++ b/tests/roformer/test_modeling_roformer.py @@ -17,12 +17,11 @@ import unittest -from tests.test_modeling_common import floats_tensor from transformers import RoFormerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_modeling_tf_roformer.py b/tests/roformer/test_modeling_tf_roformer.py similarity index 99% rename from tests/test_modeling_tf_roformer.py rename to tests/roformer/test_modeling_tf_roformer.py index 5b045187d5..1f26f7e2ad 100644 --- a/tests/test_modeling_tf_roformer.py +++ b/tests/roformer/test_modeling_tf_roformer.py @@ -19,8 +19,8 @@ import unittest from transformers import RoFormerConfig, is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_roformer.py b/tests/roformer/test_tokenization_roformer.py similarity index 97% rename from tests/test_tokenization_roformer.py rename to tests/roformer/test_tokenization_roformer.py index c5e19b66b2..e5db42890d 100644 --- a/tests/test_tokenization_roformer.py +++ b/tests/roformer/test_tokenization_roformer.py @@ -18,7 +18,7 @@ import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin @require_rjieba diff --git a/tests/segformer/__init__.py b/tests/segformer/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_feature_extraction_segformer.py b/tests/segformer/test_feature_extraction_segformer.py similarity index 99% rename from tests/test_feature_extraction_segformer.py rename to tests/segformer/test_feature_extraction_segformer.py index 2e0b5ff5a9..6aa29e935d 100644 --- a/tests/test_feature_extraction_segformer.py +++ b/tests/segformer/test_feature_extraction_segformer.py @@ -22,7 +22,7 @@ from datasets import load_dataset from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision -from .test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs +from ..test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs if is_torch_available(): diff --git a/tests/test_modeling_segformer.py b/tests/segformer/test_modeling_segformer.py similarity index 99% rename from tests/test_modeling_segformer.py rename to tests/segformer/test_modeling_segformer.py index f359e23781..b7321dd690 100644 --- a/tests/test_modeling_segformer.py +++ b/tests/segformer/test_modeling_segformer.py @@ -22,8 +22,8 @@ from transformers import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor if is_torch_available(): diff --git a/tests/sew/__init__.py b/tests/sew/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_sew.py b/tests/sew/test_modeling_sew.py similarity index 99% rename from tests/test_modeling_sew.py rename to tests/sew/test_modeling_sew.py index debced3cdc..d3d44b52e1 100644 --- a/tests/test_modeling_sew.py +++ b/tests/sew/test_modeling_sew.py @@ -20,12 +20,17 @@ import unittest import pytest -from tests.test_modeling_common import floats_tensor, ids_tensor, random_attention_mask from transformers import SEWConfig, is_torch_available from transformers.testing_utils import require_soundfile, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, _config_zero_init +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ( + ModelTesterMixin, + _config_zero_init, + floats_tensor, + ids_tensor, + random_attention_mask, +) if is_torch_available(): diff --git a/tests/sew_d/__init__.py b/tests/sew_d/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_sew_d.py b/tests/sew_d/test_modeling_sew_d.py similarity index 99% rename from tests/test_modeling_sew_d.py rename to tests/sew_d/test_modeling_sew_d.py index d5b82e27bf..796bd8805e 100644 --- a/tests/test_modeling_sew_d.py +++ b/tests/sew_d/test_modeling_sew_d.py @@ -20,12 +20,17 @@ import unittest import pytest -from tests.test_modeling_common import floats_tensor, ids_tensor, random_attention_mask from transformers import SEWDConfig, is_torch_available from transformers.testing_utils import require_soundfile, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, _config_zero_init +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ( + ModelTesterMixin, + _config_zero_init, + floats_tensor, + ids_tensor, + random_attention_mask, +) if is_torch_available(): diff --git a/tests/speech_encoder_decoder/__init__.py b/tests/speech_encoder_decoder/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_speech_encoder_decoder.py b/tests/speech_encoder_decoder/test_modeling_speech_encoder_decoder.py similarity index 98% rename from tests/test_modeling_speech_encoder_decoder.py rename to tests/speech_encoder_decoder/test_modeling_speech_encoder_decoder.py index 4cdd46d878..7fc26a76ba 100644 --- a/tests/test_modeling_speech_encoder_decoder.py +++ b/tests/speech_encoder_decoder/test_modeling_speech_encoder_decoder.py @@ -20,11 +20,11 @@ import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_modeling_bert import BertModelTester -from .test_modeling_common import floats_tensor, ids_tensor, random_attention_mask -from .test_modeling_speech_to_text import Speech2TextModelTester -from .test_modeling_speech_to_text_2 import Speech2Text2StandaloneDecoderModelTester -from .test_modeling_wav2vec2 import Wav2Vec2ModelTester +from ..bert.test_modeling_bert import BertModelTester +from ..speech_to_text.test_modeling_speech_to_text import Speech2TextModelTester +from ..speech_to_text_2.test_modeling_speech_to_text_2 import Speech2Text2StandaloneDecoderModelTester +from ..test_modeling_common import floats_tensor, ids_tensor, random_attention_mask +from ..wav2vec2.test_modeling_wav2vec2 import Wav2Vec2ModelTester if is_torch_available(): diff --git a/tests/speech_to_text/__init__.py b/tests/speech_to_text/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_feature_extraction_speech_to_text.py b/tests/speech_to_text/test_feature_extraction_speech_to_text.py similarity index 99% rename from tests/test_feature_extraction_speech_to_text.py rename to tests/speech_to_text/test_feature_extraction_speech_to_text.py index 3731133afe..9d719e4e1b 100644 --- a/tests/test_feature_extraction_speech_to_text.py +++ b/tests/speech_to_text/test_feature_extraction_speech_to_text.py @@ -23,7 +23,7 @@ import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio -from .test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin +from ..test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_speech_available(): diff --git a/tests/test_modeling_speech_to_text.py b/tests/speech_to_text/test_modeling_speech_to_text.py similarity index 99% rename from tests/test_modeling_speech_to_text.py rename to tests/speech_to_text/test_modeling_speech_to_text.py index f1c02b0a3c..95322c2b23 100644 --- a/tests/test_modeling_speech_to_text.py +++ b/tests/speech_to_text/test_modeling_speech_to_text.py @@ -32,9 +32,9 @@ from transformers.testing_utils import ( torch_device, ) -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor if is_torch_available(): diff --git a/tests/test_modeling_tf_speech_to_text.py b/tests/speech_to_text/test_modeling_tf_speech_to_text.py similarity index 99% rename from tests/test_modeling_tf_speech_to_text.py rename to tests/speech_to_text/test_modeling_tf_speech_to_text.py index 6253ccf953..b9036ae3a1 100644 --- a/tests/test_modeling_tf_speech_to_text.py +++ b/tests/speech_to_text/test_modeling_tf_speech_to_text.py @@ -21,8 +21,8 @@ from transformers import Speech2TextConfig from transformers.file_utils import cached_property, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor if is_tf_available(): diff --git a/tests/test_processor_speech_to_text.py b/tests/speech_to_text/test_processor_speech_to_text.py similarity index 97% rename from tests/test_processor_speech_to_text.py rename to tests/speech_to_text/test_processor_speech_to_text.py index 76a7a74461..93275d3a56 100644 --- a/tests/test_processor_speech_to_text.py +++ b/tests/speech_to_text/test_processor_speech_to_text.py @@ -16,6 +16,7 @@ import os import shutil import tempfile import unittest +from os.path import dirname from pathlib import Path from shutil import copyfile @@ -31,7 +32,7 @@ if is_speech_available(): from transformers import Speech2TextFeatureExtractor, Speech2TextProcessor -SAMPLE_SP = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") +SAMPLE_SP = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model") @require_torch diff --git a/tests/test_tokenization_speech_to_text.py b/tests/speech_to_text/test_tokenization_speech_to_text.py similarity index 98% rename from tests/test_tokenization_speech_to_text.py rename to tests/speech_to_text/test_tokenization_speech_to_text.py index 649e638791..43f26092ff 100644 --- a/tests/test_tokenization_speech_to_text.py +++ b/tests/speech_to_text/test_tokenization_speech_to_text.py @@ -14,6 +14,7 @@ import os import unittest +from os.path import dirname from pathlib import Path from shutil import copyfile @@ -22,10 +23,10 @@ from transformers.models.speech_to_text import Speech2TextTokenizer from transformers.models.speech_to_text.tokenization_speech_to_text import VOCAB_FILES_NAMES, save_json from transformers.testing_utils import require_sentencepiece, require_tokenizers, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin -SAMPLE_SP = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") +SAMPLE_SP = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model") if is_sentencepiece_available(): import sentencepiece as sp diff --git a/tests/speech_to_text_2/__init__.py b/tests/speech_to_text_2/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_speech_to_text_2.py b/tests/speech_to_text_2/test_modeling_speech_to_text_2.py similarity index 97% rename from tests/test_modeling_speech_to_text_2.py rename to tests/speech_to_text_2/test_modeling_speech_to_text_2.py index aaded0c8aa..861e4acedc 100644 --- a/tests/test_modeling_speech_to_text_2.py +++ b/tests/speech_to_text_2/test_modeling_speech_to_text_2.py @@ -19,9 +19,9 @@ import unittest from transformers import Speech2Text2Config from transformers.testing_utils import is_torch_available, require_torch, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/test_tokenization_speech_to_text_2.py b/tests/speech_to_text_2/test_tokenization_speech_to_text_2.py similarity index 98% rename from tests/test_tokenization_speech_to_text_2.py rename to tests/speech_to_text_2/test_tokenization_speech_to_text_2.py index b077c2c8ba..072473851f 100644 --- a/tests/test_tokenization_speech_to_text_2.py +++ b/tests/speech_to_text_2/test_tokenization_speech_to_text_2.py @@ -21,7 +21,7 @@ import unittest from transformers.models.speech_to_text_2 import Speech2Text2Tokenizer from transformers.models.speech_to_text_2.tokenization_speech_to_text_2 import VOCAB_FILES_NAMES -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin class SpeechToTextTokenizerTest(TokenizerTesterMixin, unittest.TestCase): diff --git a/tests/splinter/__init__.py b/tests/splinter/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_splinter.py b/tests/splinter/test_modeling_splinter.py similarity index 98% rename from tests/test_modeling_splinter.py rename to tests/splinter/test_modeling_splinter.py index 8e06868494..1b6cfeac95 100644 --- a/tests/test_modeling_splinter.py +++ b/tests/splinter/test_modeling_splinter.py @@ -20,8 +20,8 @@ import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/squeezebert/__init__.py b/tests/squeezebert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_squeezebert.py b/tests/squeezebert/test_modeling_squeezebert.py similarity index 98% rename from tests/test_modeling_squeezebert.py rename to tests/squeezebert/test_modeling_squeezebert.py index a81f1a3fed..d1d446499a 100644 --- a/tests/test_modeling_squeezebert.py +++ b/tests/squeezebert/test_modeling_squeezebert.py @@ -19,8 +19,8 @@ import unittest from transformers import SqueezeBertConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_tokenization_squeezebert.py b/tests/squeezebert/test_tokenization_squeezebert.py similarity index 96% rename from tests/test_tokenization_squeezebert.py rename to tests/squeezebert/test_tokenization_squeezebert.py index 3637717a0c..88d715bcc1 100644 --- a/tests/test_tokenization_squeezebert.py +++ b/tests/squeezebert/test_tokenization_squeezebert.py @@ -17,7 +17,7 @@ from transformers import SqueezeBertTokenizer, SqueezeBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow -from .test_tokenization_bert import BertTokenizationTest +from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers diff --git a/tests/swin/__init__.py b/tests/swin/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_swin.py b/tests/swin/test_modeling_swin.py similarity index 98% rename from tests/test_modeling_swin.py rename to tests/swin/test_modeling_swin.py index edfff892f5..e79b12533d 100644 --- a/tests/test_modeling_swin.py +++ b/tests/swin/test_modeling_swin.py @@ -18,13 +18,12 @@ import copy import inspect import unittest -from tests.test_modeling_common import floats_tensor from transformers import SwinConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor if is_torch_available(): diff --git a/tests/t5/__init__.py b/tests/t5/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_flax_t5.py b/tests/t5/test_modeling_flax_t5.py similarity index 99% rename from tests/test_modeling_flax_t5.py rename to tests/t5/test_modeling_flax_t5.py index 8c59c84919..f4d8ebbab1 100644 --- a/tests/test_modeling_flax_t5.py +++ b/tests/t5/test_modeling_flax_t5.py @@ -27,9 +27,9 @@ from transformers.testing_utils import ( slow, ) -from .test_configuration_common import ConfigTester -from .test_generation_flax_utils import FlaxGenerationTesterMixin -from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor +from ..generation.test_generation_flax_utils import FlaxGenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): diff --git a/tests/test_modeling_t5.py b/tests/t5/test_modeling_t5.py similarity index 99% rename from tests/test_modeling_t5.py rename to tests/t5/test_modeling_t5.py index c0b5739bca..c48a0efa4c 100644 --- a/tests/test_modeling_t5.py +++ b/tests/t5/test_modeling_t5.py @@ -22,9 +22,9 @@ from transformers import T5Config, is_torch_available from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/test_modeling_tf_t5.py b/tests/t5/test_modeling_tf_t5.py similarity index 99% rename from tests/test_modeling_tf_t5.py rename to tests/t5/test_modeling_tf_t5.py index 9a5a1de199..d83e30bc16 100644 --- a/tests/test_modeling_tf_t5.py +++ b/tests/t5/test_modeling_tf_t5.py @@ -19,8 +19,8 @@ from transformers import T5Config, is_tf_available from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_t5.py b/tests/t5/test_tokenization_t5.py similarity index 99% rename from tests/test_tokenization_t5.py rename to tests/t5/test_tokenization_t5.py index 4025801bf2..2683e5cbf1 100644 --- a/tests/test_tokenization_t5.py +++ b/tests/t5/test_tokenization_t5.py @@ -21,7 +21,7 @@ from transformers import SPIECE_UNDERLINE, AddedToken, BatchEncoding, T5Tokenize from transformers.file_utils import cached_property, is_tf_available, is_torch_available from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin SAMPLE_VOCAB = get_tests_dir("fixtures/test_sentencepiece.model") diff --git a/tests/tapas/__init__.py b/tests/tapas/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_tapas.py b/tests/tapas/test_modeling_tapas.py similarity index 99% rename from tests/test_modeling_tapas.py rename to tests/tapas/test_modeling_tapas.py index 6a4d853fd3..17f9a9096a 100644 --- a/tests/test_modeling_tapas.py +++ b/tests/tapas/test_modeling_tapas.py @@ -35,8 +35,8 @@ from transformers.file_utils import cached_property from transformers.models.auto import get_values from transformers.testing_utils import require_scatter, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_modeling_tf_tapas.py b/tests/tapas/test_modeling_tf_tapas.py similarity index 99% rename from tests/test_modeling_tf_tapas.py rename to tests/tapas/test_modeling_tf_tapas.py index ca44781973..9481c24857 100644 --- a/tests/test_modeling_tf_tapas.py +++ b/tests/tapas/test_modeling_tf_tapas.py @@ -37,8 +37,8 @@ from transformers.file_utils import cached_property from transformers.models.auto import get_values from transformers.testing_utils import require_tensorflow_probability, require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_tokenization_tapas.py b/tests/tapas/test_tokenization_tapas.py similarity index 99% rename from tests/test_tokenization_tapas.py rename to tests/tapas/test_tokenization_tapas.py index ed39ce59f7..a5c6da2a41 100644 --- a/tests/test_tokenization_tapas.py +++ b/tests/tapas/test_tokenization_tapas.py @@ -41,7 +41,7 @@ from transformers.testing_utils import ( slow, ) -from .test_tokenization_common import TokenizerTesterMixin, filter_non_english, merge_model_tokenizer_mappings +from ..test_tokenization_common import TokenizerTesterMixin, filter_non_english, merge_model_tokenizer_mappings @require_tokenizers diff --git a/tests/tokenization/__init__.py b/tests/tokenization/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_tokenization_fast.py b/tests/tokenization/test_tokenization_fast.py similarity index 99% rename from tests/test_tokenization_fast.py rename to tests/tokenization/test_tokenization_fast.py index b3fd682484..9e5ad178e5 100644 --- a/tests/test_tokenization_fast.py +++ b/tests/tokenization/test_tokenization_fast.py @@ -23,7 +23,7 @@ import unittest from transformers import AutoTokenizer, PreTrainedTokenizerFast from transformers.testing_utils import require_tokenizers -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin @require_tokenizers diff --git a/tests/test_tokenization_utils.py b/tests/tokenization/test_tokenization_utils.py similarity index 100% rename from tests/test_tokenization_utils.py rename to tests/tokenization/test_tokenization_utils.py diff --git a/tests/trainer/__init__.py b/tests/trainer/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_data_collator.py b/tests/trainer/test_data_collator.py similarity index 100% rename from tests/test_data_collator.py rename to tests/trainer/test_data_collator.py diff --git a/tests/test_trainer.py b/tests/trainer/test_trainer.py similarity index 99% rename from tests/test_trainer.py rename to tests/trainer/test_trainer.py index a730c0df6d..4e8fd2b125 100644 --- a/tests/test_trainer.py +++ b/tests/trainer/test_trainer.py @@ -370,7 +370,7 @@ class TrainerIntegrationPrerunTest(TestCasePlus, TrainerIntegrationCommon): def setUp(self): super().setUp() - args = TrainingArguments(".") + args = TrainingArguments("..") self.n_epochs = args.num_train_epochs self.batch_size = args.train_batch_size trainer = get_regression_trainer(learning_rate=0.1) @@ -536,7 +536,7 @@ class TrainerIntegrationPrerunTest(TestCasePlus, TrainerIntegrationCommon): class TrainerIntegrationTest(TestCasePlus, TrainerIntegrationCommon): def setUp(self): super().setUp() - args = TrainingArguments(".") + args = TrainingArguments("..") self.n_epochs = args.num_train_epochs self.batch_size = args.train_batch_size @@ -1148,7 +1148,7 @@ class TrainerIntegrationTest(TestCasePlus, TrainerIntegrationCommon): data = FiniteIterableDataset(length=num_samples) train_args = TrainingArguments( - ".", + "..", max_steps=available_steps + 1, # set a higher number than actually available per_device_train_batch_size=batch_size, ) @@ -1589,7 +1589,7 @@ class TrainerIntegrationWithHubTester(unittest.TestCase): @require_optuna class TrainerHyperParameterOptunaIntegrationTest(unittest.TestCase): def setUp(self): - args = TrainingArguments(".") + args = TrainingArguments("..") self.n_epochs = args.num_train_epochs self.batch_size = args.train_batch_size @@ -1635,7 +1635,7 @@ class TrainerHyperParameterOptunaIntegrationTest(unittest.TestCase): @require_ray class TrainerHyperParameterRayIntegrationTest(unittest.TestCase): def setUp(self): - args = TrainingArguments(".") + args = TrainingArguments("..") self.n_epochs = args.num_train_epochs self.batch_size = args.train_batch_size @@ -1699,7 +1699,7 @@ class TrainerHyperParameterRayIntegrationTest(unittest.TestCase): @require_sigopt class TrainerHyperParameterSigOptIntegrationTest(unittest.TestCase): def setUp(self): - args = TrainingArguments(".") + args = TrainingArguments("..") self.n_epochs = args.num_train_epochs self.batch_size = args.train_batch_size @@ -1845,7 +1845,7 @@ class TrainerOptimizerChoiceTest(unittest.TestCase): @require_wandb class TrainerHyperParameterWandbIntegrationTest(unittest.TestCase): def setUp(self): - args = TrainingArguments(".") + args = TrainingArguments("..") self.n_epochs = args.num_train_epochs self.batch_size = args.train_batch_size diff --git a/tests/test_trainer_callback.py b/tests/trainer/test_trainer_callback.py similarity index 100% rename from tests/test_trainer_callback.py rename to tests/trainer/test_trainer_callback.py diff --git a/tests/test_trainer_distributed.py b/tests/trainer/test_trainer_distributed.py similarity index 100% rename from tests/test_trainer_distributed.py rename to tests/trainer/test_trainer_distributed.py diff --git a/tests/test_trainer_seq2seq.py b/tests/trainer/test_trainer_seq2seq.py similarity index 100% rename from tests/test_trainer_seq2seq.py rename to tests/trainer/test_trainer_seq2seq.py diff --git a/tests/test_trainer_tpu.py b/tests/trainer/test_trainer_tpu.py similarity index 100% rename from tests/test_trainer_tpu.py rename to tests/trainer/test_trainer_tpu.py diff --git a/tests/test_trainer_utils.py b/tests/trainer/test_trainer_utils.py similarity index 100% rename from tests/test_trainer_utils.py rename to tests/trainer/test_trainer_utils.py diff --git a/tests/transfo_xl/__init__.py b/tests/transfo_xl/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_tf_transfo_xl.py b/tests/transfo_xl/test_modeling_tf_transfo_xl.py similarity index 98% rename from tests/test_modeling_tf_transfo_xl.py rename to tests/transfo_xl/test_modeling_tf_transfo_xl.py index 1b38c92585..87aca5097a 100644 --- a/tests/test_modeling_tf_transfo_xl.py +++ b/tests/transfo_xl/test_modeling_tf_transfo_xl.py @@ -20,8 +20,8 @@ import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_modeling_transfo_xl.py b/tests/transfo_xl/test_modeling_transfo_xl.py similarity index 99% rename from tests/test_modeling_transfo_xl.py rename to tests/transfo_xl/test_modeling_transfo_xl.py index c69f3b2490..51597f2338 100644 --- a/tests/test_modeling_transfo_xl.py +++ b/tests/transfo_xl/test_modeling_transfo_xl.py @@ -20,9 +20,9 @@ import unittest from transformers import TransfoXLConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/test_tokenization_transfo_xl.py b/tests/transfo_xl/test_tokenization_transfo_xl.py similarity index 98% rename from tests/test_tokenization_transfo_xl.py rename to tests/transfo_xl/test_tokenization_transfo_xl.py index fab3694844..261fcf0044 100644 --- a/tests/test_tokenization_transfo_xl.py +++ b/tests/transfo_xl/test_tokenization_transfo_xl.py @@ -19,7 +19,7 @@ import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin class TransfoXLTokenizationTest(TokenizerTesterMixin, unittest.TestCase): diff --git a/tests/trocr/__init__.py b/tests/trocr/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_trocr.py b/tests/trocr/test_modeling_trocr.py similarity index 97% rename from tests/test_modeling_trocr.py rename to tests/trocr/test_modeling_trocr.py index d2d67c8bfb..b15b059f92 100644 --- a/tests/test_modeling_trocr.py +++ b/tests/trocr/test_modeling_trocr.py @@ -19,9 +19,9 @@ import unittest from transformers import TrOCRConfig from transformers.testing_utils import is_torch_available, require_torch, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor if is_torch_available(): diff --git a/tests/unispeech/__init__.py b/tests/unispeech/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_unispeech.py b/tests/unispeech/test_modeling_unispeech.py similarity index 99% rename from tests/test_modeling_unispeech.py rename to tests/unispeech/test_modeling_unispeech.py index 111f7d1c26..03e1d6dacd 100644 --- a/tests/test_modeling_unispeech.py +++ b/tests/unispeech/test_modeling_unispeech.py @@ -21,12 +21,17 @@ import numpy as np import pytest from datasets import load_dataset -from tests.test_modeling_common import floats_tensor, ids_tensor, random_attention_mask from transformers import UniSpeechConfig, is_torch_available from transformers.testing_utils import require_soundfile, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, _config_zero_init +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ( + ModelTesterMixin, + _config_zero_init, + floats_tensor, + ids_tensor, + random_attention_mask, +) if is_torch_available(): diff --git a/tests/unispeech_sat/__init__.py b/tests/unispeech_sat/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_unispeech_sat.py b/tests/unispeech_sat/test_modeling_unispeech_sat.py similarity index 99% rename from tests/test_modeling_unispeech_sat.py rename to tests/unispeech_sat/test_modeling_unispeech_sat.py index f1db27888c..46f862806e 100644 --- a/tests/test_modeling_unispeech_sat.py +++ b/tests/unispeech_sat/test_modeling_unispeech_sat.py @@ -21,12 +21,17 @@ import numpy as np import pytest from datasets import load_dataset -from tests.test_modeling_common import floats_tensor, ids_tensor, random_attention_mask from transformers import UniSpeechSatConfig, is_torch_available from transformers.testing_utils import require_soundfile, require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, _config_zero_init +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ( + ModelTesterMixin, + _config_zero_init, + floats_tensor, + ids_tensor, + random_attention_mask, +) if is_torch_available(): diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_activations.py b/tests/utils/test_activations.py similarity index 100% rename from tests/test_activations.py rename to tests/utils/test_activations.py diff --git a/tests/test_activations_tf.py b/tests/utils/test_activations_tf.py similarity index 100% rename from tests/test_activations_tf.py rename to tests/utils/test_activations_tf.py diff --git a/tests/test_add_new_model_like.py b/tests/utils/test_add_new_model_like.py similarity index 99% rename from tests/test_add_new_model_like.py rename to tests/utils/test_add_new_model_like.py index d1134bad52..edd84dfe98 100644 --- a/tests/test_add_new_model_like.py +++ b/tests/utils/test_add_new_model_like.py @@ -1008,7 +1008,7 @@ else: """ with tempfile.TemporaryDirectory() as tmp_dir: - file_name = os.path.join(tmp_dir, "__init__.py") + file_name = os.path.join(tmp_dir, "../__init__.py") self.init_file(file_name, test_init) clean_frameworks_in_init(file_name, keep_processing=False) @@ -1156,7 +1156,7 @@ else: """ with tempfile.TemporaryDirectory() as tmp_dir: - file_name = os.path.join(tmp_dir, "__init__.py") + file_name = os.path.join(tmp_dir, "../__init__.py") self.init_file(file_name, test_init) clean_frameworks_in_init(file_name, keep_processing=False) diff --git a/tests/test_cli.py b/tests/utils/test_cli.py similarity index 100% rename from tests/test_cli.py rename to tests/utils/test_cli.py diff --git a/tests/test_doc_samples.py b/tests/utils/test_doc_samples.py similarity index 100% rename from tests/test_doc_samples.py rename to tests/utils/test_doc_samples.py diff --git a/tests/test_file_utils.py b/tests/utils/test_file_utils.py similarity index 100% rename from tests/test_file_utils.py rename to tests/utils/test_file_utils.py diff --git a/tests/test_hf_argparser.py b/tests/utils/test_hf_argparser.py similarity index 100% rename from tests/test_hf_argparser.py rename to tests/utils/test_hf_argparser.py diff --git a/tests/test_image_utils.py b/tests/utils/test_image_utils.py similarity index 100% rename from tests/test_image_utils.py rename to tests/utils/test_image_utils.py diff --git a/tests/test_logging.py b/tests/utils/test_logging.py similarity index 100% rename from tests/test_logging.py rename to tests/utils/test_logging.py diff --git a/tests/test_model_card.py b/tests/utils/test_model_card.py similarity index 100% rename from tests/test_model_card.py rename to tests/utils/test_model_card.py diff --git a/tests/test_model_output.py b/tests/utils/test_model_output.py similarity index 100% rename from tests/test_model_output.py rename to tests/utils/test_model_output.py diff --git a/tests/test_modeling_tf_core.py b/tests/utils/test_modeling_tf_core.py similarity index 99% rename from tests/test_modeling_tf_core.py rename to tests/utils/test_modeling_tf_core.py index bd4e0b0942..8edfc8eab0 100644 --- a/tests/test_modeling_tf_core.py +++ b/tests/utils/test_modeling_tf_core.py @@ -23,7 +23,7 @@ from transformers import is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import _tf_gpu_memory_limit, require_tf, slow -from .test_modeling_tf_common import ids_tensor +from ..test_modeling_tf_common import ids_tensor if is_tf_available(): diff --git a/tests/test_offline.py b/tests/utils/test_offline.py similarity index 100% rename from tests/test_offline.py rename to tests/utils/test_offline.py diff --git a/tests/test_skip_decorators.py b/tests/utils/test_skip_decorators.py similarity index 100% rename from tests/test_skip_decorators.py rename to tests/utils/test_skip_decorators.py diff --git a/tests/test_utils_check_copies.py b/tests/utils/test_utils_check_copies.py similarity index 99% rename from tests/test_utils_check_copies.py rename to tests/utils/test_utils_check_copies.py index 5151c3a490..407e187720 100644 --- a/tests/test_utils_check_copies.py +++ b/tests/utils/test_utils_check_copies.py @@ -22,7 +22,7 @@ import unittest import black -git_repo_path = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) +git_repo_path = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_copies # noqa: E402 diff --git a/tests/test_versions_utils.py b/tests/utils/test_versions_utils.py similarity index 100% rename from tests/test_versions_utils.py rename to tests/utils/test_versions_utils.py diff --git a/tests/vilt/__init__.py b/tests/vilt/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_feature_extraction_vilt.py b/tests/vilt/test_feature_extraction_vilt.py similarity index 98% rename from tests/test_feature_extraction_vilt.py rename to tests/vilt/test_feature_extraction_vilt.py index 350c1758ff..ed22ebbb07 100644 --- a/tests/test_feature_extraction_vilt.py +++ b/tests/vilt/test_feature_extraction_vilt.py @@ -21,7 +21,7 @@ import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision -from .test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs +from ..test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs if is_torch_available(): diff --git a/tests/test_modeling_vilt.py b/tests/vilt/test_modeling_vilt.py similarity index 99% rename from tests/test_modeling_vilt.py rename to tests/vilt/test_modeling_vilt.py index f1bac75a6c..d84162973e 100644 --- a/tests/test_modeling_vilt.py +++ b/tests/vilt/test_modeling_vilt.py @@ -23,8 +23,8 @@ from transformers.file_utils import cached_property from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/vision_encoder_decoder/__init__.py b/tests/vision_encoder_decoder/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_flax_vision_encoder_decoder.py b/tests/vision_encoder_decoder/test_modeling_flax_vision_encoder_decoder.py similarity index 99% rename from tests/test_modeling_flax_vision_encoder_decoder.py rename to tests/vision_encoder_decoder/test_modeling_flax_vision_encoder_decoder.py index ad4c81935b..163b8ddaa2 100644 --- a/tests/test_modeling_flax_vision_encoder_decoder.py +++ b/tests/vision_encoder_decoder/test_modeling_flax_vision_encoder_decoder.py @@ -22,9 +22,9 @@ import numpy as np from transformers import is_flax_available, is_torch_available, is_vision_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, require_vision, slow, torch_device -from .test_modeling_flax_common import floats_tensor, ids_tensor -from .test_modeling_flax_gpt2 import FlaxGPT2ModelTester -from .test_modeling_flax_vit import FlaxViTModelTester +from ..gpt2.test_modeling_flax_gpt2 import FlaxGPT2ModelTester +from ..test_modeling_flax_common import floats_tensor, ids_tensor +from ..vit.test_modeling_flax_vit import FlaxViTModelTester if is_flax_available(): diff --git a/tests/test_modeling_tf_vision_encoder_decoder.py b/tests/vision_encoder_decoder/test_modeling_tf_vision_encoder_decoder.py similarity index 97% rename from tests/test_modeling_tf_vision_encoder_decoder.py rename to tests/vision_encoder_decoder/test_modeling_tf_vision_encoder_decoder.py index 3f1783e034..891c1aa55d 100644 --- a/tests/test_modeling_tf_vision_encoder_decoder.py +++ b/tests/vision_encoder_decoder/test_modeling_tf_vision_encoder_decoder.py @@ -32,9 +32,9 @@ from transformers.testing_utils import ( torch_device, ) -from .test_modeling_tf_common import floats_tensor, ids_tensor -from .test_modeling_tf_gpt2 import TFGPT2ModelTester -from .test_modeling_tf_vit import TFViTModelTester +from ..gpt2.test_modeling_tf_gpt2 import TFGPT2ModelTester +from ..test_modeling_tf_common import floats_tensor, ids_tensor +from ..vit.test_modeling_tf_vit import TFViTModelTester if is_tf_available(): @@ -527,7 +527,9 @@ class TFVisionEncoderDecoderMixin: @require_tf class TFViT2GPT2EncoderDecoderModelTest(TFVisionEncoderDecoderMixin, unittest.TestCase): def get_pretrained_model(self): - return TFVisionEncoderDecoderModel.from_encoder_decoder_pretrained("google/vit-base-patch16-224-in21k", "gpt2") + return TFVisionEncoderDecoderModel.from_encoder_decoder_pretrained( + "google/vit-base-patch16-224-in21k", "../gpt2" + ) def get_encoder_decoder_model(self, config, decoder_config): encoder_model = TFViTModel(config, name="encoder") @@ -572,10 +574,12 @@ class TFViT2GPT2EncoderDecoderModelTest(TFVisionEncoderDecoderMixin, unittest.Te @require_tf class TFVisionEncoderDecoderModelTest(unittest.TestCase): def get_from_encoderdecoder_pretrained_model(self): - return TFVisionEncoderDecoderModel.from_encoder_decoder_pretrained("google/vit-base-patch16-224-in21k", "gpt2") + return TFVisionEncoderDecoderModel.from_encoder_decoder_pretrained( + "google/vit-base-patch16-224-in21k", "../gpt2" + ) def get_decoder_config(self): - config = AutoConfig.from_pretrained("gpt2") + config = AutoConfig.from_pretrained("../gpt2") config.is_decoder = True config.add_cross_attention = True return config @@ -585,7 +589,7 @@ class TFVisionEncoderDecoderModelTest(unittest.TestCase): def get_encoder_decoder_models(self): encoder_model = TFViTModel.from_pretrained("google/vit-base-patch16-224-in21k", name="encoder") - decoder_model = TFGPT2LMHeadModel.from_pretrained("gpt2", config=self.get_decoder_config(), name="decoder") + decoder_model = TFGPT2LMHeadModel.from_pretrained("../gpt2", config=self.get_decoder_config(), name="decoder") return {"encoder": encoder_model, "decoder": decoder_model} def _check_configuration_tie(self, model): @@ -614,7 +618,7 @@ def prepare_img(): class TFVisionEncoderDecoderModelSaveLoadTests(unittest.TestCase): def get_encoder_decoder_config(self): encoder_config = AutoConfig.from_pretrained("google/vit-base-patch16-224-in21k") - decoder_config = AutoConfig.from_pretrained("gpt2", is_decoder=True, add_cross_attention=True) + decoder_config = AutoConfig.from_pretrained("../gpt2", is_decoder=True, add_cross_attention=True) return VisionEncoderDecoderConfig.from_encoder_decoder_configs(encoder_config, decoder_config) def get_encoder_decoder_config_small(self): @@ -729,7 +733,7 @@ class TFVisionEncoderDecoderModelSaveLoadTests(unittest.TestCase): config = self.get_encoder_decoder_config() feature_extractor = AutoFeatureExtractor.from_pretrained("google/vit-base-patch16-224-in21k") - decoder_tokenizer = AutoTokenizer.from_pretrained("gpt2") + decoder_tokenizer = AutoTokenizer.from_pretrained("../gpt2") img = prepare_img() pixel_values = feature_extractor(images=img, return_tensors="tf").pixel_values @@ -746,7 +750,7 @@ class TFVisionEncoderDecoderModelSaveLoadTests(unittest.TestCase): encoder = TFAutoModel.from_pretrained("google/vit-base-patch16-224-in21k", name="encoder") # It's necessary to specify `add_cross_attention=True` here. decoder = TFAutoModelForCausalLM.from_pretrained( - "gpt2", is_decoder=True, add_cross_attention=True, name="decoder" + "../gpt2", is_decoder=True, add_cross_attention=True, name="decoder" ) pretrained_encoder_dir = os.path.join(tmp_dirname, "pretrained_encoder") pretrained_decoder_dir = os.path.join(tmp_dirname, "pretrained_decoder") diff --git a/tests/test_modeling_vision_encoder_decoder.py b/tests/vision_encoder_decoder/test_modeling_vision_encoder_decoder.py similarity index 98% rename from tests/test_modeling_vision_encoder_decoder.py rename to tests/vision_encoder_decoder/test_modeling_vision_encoder_decoder.py index d9d676a8db..3111611588 100644 --- a/tests/test_modeling_vision_encoder_decoder.py +++ b/tests/vision_encoder_decoder/test_modeling_vision_encoder_decoder.py @@ -22,11 +22,11 @@ from datasets import load_dataset from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device -from .test_modeling_bert import BertModelTester -from .test_modeling_common import floats_tensor, ids_tensor, random_attention_mask -from .test_modeling_deit import DeiTModelTester -from .test_modeling_trocr import TrOCRStandaloneDecoderModelTester -from .test_modeling_vit import ViTModelTester +from ..bert.test_modeling_bert import BertModelTester +from ..deit.test_modeling_deit import DeiTModelTester +from ..test_modeling_common import floats_tensor, ids_tensor, random_attention_mask +from ..trocr.test_modeling_trocr import TrOCRStandaloneDecoderModelTester +from ..vit.test_modeling_vit import ViTModelTester if is_torch_available(): diff --git a/tests/vision_text_dual_encoder/__init__.py b/tests/vision_text_dual_encoder/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_flax_vision_text_dual_encoder.py b/tests/vision_text_dual_encoder/test_modeling_flax_vision_text_dual_encoder.py similarity index 98% rename from tests/test_modeling_flax_vision_text_dual_encoder.py rename to tests/vision_text_dual_encoder/test_modeling_flax_vision_text_dual_encoder.py index 06f37061b8..f176678670 100644 --- a/tests/test_modeling_flax_vision_text_dual_encoder.py +++ b/tests/vision_text_dual_encoder/test_modeling_flax_vision_text_dual_encoder.py @@ -31,10 +31,10 @@ from transformers.testing_utils import ( torch_device, ) -from .test_modeling_flax_bert import FlaxBertModelTester -from .test_modeling_flax_clip import FlaxCLIPVisionModelTester -from .test_modeling_flax_common import floats_tensor, ids_tensor, random_attention_mask -from .test_modeling_flax_vit import FlaxViTModelTester +from ..bert.test_modeling_flax_bert import FlaxBertModelTester +from ..clip.test_modeling_flax_clip import FlaxCLIPVisionModelTester +from ..test_modeling_flax_common import floats_tensor, ids_tensor, random_attention_mask +from ..vit.test_modeling_flax_vit import FlaxViTModelTester if is_flax_available(): diff --git a/tests/test_modeling_vision_text_dual_encoder.py b/tests/vision_text_dual_encoder/test_modeling_vision_text_dual_encoder.py similarity index 98% rename from tests/test_modeling_vision_text_dual_encoder.py rename to tests/vision_text_dual_encoder/test_modeling_vision_text_dual_encoder.py index b9048c8786..a84e4d6171 100644 --- a/tests/test_modeling_vision_text_dual_encoder.py +++ b/tests/vision_text_dual_encoder/test_modeling_vision_text_dual_encoder.py @@ -24,12 +24,12 @@ import numpy as np from transformers.file_utils import is_flax_available, is_torch_available, is_vision_available from transformers.testing_utils import is_pt_flax_cross_test, require_torch, require_vision, slow, torch_device -from .test_modeling_bert import BertModelTester -from .test_modeling_clip import CLIPVisionModelTester -from .test_modeling_common import floats_tensor, ids_tensor, random_attention_mask -from .test_modeling_deit import DeiTModelTester -from .test_modeling_roberta import RobertaModelTester -from .test_modeling_vit import ViTModelTester +from ..bert.test_modeling_bert import BertModelTester +from ..clip.test_modeling_clip import CLIPVisionModelTester +from ..deit.test_modeling_deit import DeiTModelTester +from ..roberta.test_modeling_roberta import RobertaModelTester +from ..test_modeling_common import floats_tensor, ids_tensor, random_attention_mask +from ..vit.test_modeling_vit import ViTModelTester if is_torch_available(): diff --git a/tests/test_processor_vision_text_dual_encoder.py b/tests/vision_text_dual_encoder/test_processor_vision_text_dual_encoder.py similarity index 100% rename from tests/test_processor_vision_text_dual_encoder.py rename to tests/vision_text_dual_encoder/test_processor_vision_text_dual_encoder.py diff --git a/tests/visual_bert/__init__.py b/tests/visual_bert/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_visual_bert.py b/tests/visual_bert/test_modeling_visual_bert.py similarity index 99% rename from tests/test_modeling_visual_bert.py rename to tests/visual_bert/test_modeling_visual_bert.py index 4b48c5f386..e84b4d11a1 100644 --- a/tests/test_modeling_visual_bert.py +++ b/tests/visual_bert/test_modeling_visual_bert.py @@ -17,12 +17,11 @@ import copy import unittest -from tests.test_modeling_common import floats_tensor from transformers import VisualBertConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor if is_torch_available(): diff --git a/tests/vit/__init__.py b/tests/vit/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_feature_extraction_vit.py b/tests/vit/test_feature_extraction_vit.py similarity index 98% rename from tests/test_feature_extraction_vit.py rename to tests/vit/test_feature_extraction_vit.py index 283a94d8ac..67135d4d2e 100644 --- a/tests/test_feature_extraction_vit.py +++ b/tests/vit/test_feature_extraction_vit.py @@ -21,7 +21,7 @@ import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision -from .test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs +from ..test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs if is_torch_available(): diff --git a/tests/test_modeling_flax_vit.py b/tests/vit/test_modeling_flax_vit.py similarity index 98% rename from tests/test_modeling_flax_vit.py rename to tests/vit/test_modeling_flax_vit.py index 276777e000..63808a3cdf 100644 --- a/tests/test_modeling_flax_vit.py +++ b/tests/vit/test_modeling_flax_vit.py @@ -20,8 +20,8 @@ import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow -from .test_configuration_common import ConfigTester -from .test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor if is_flax_available(): diff --git a/tests/test_modeling_tf_vit.py b/tests/vit/test_modeling_tf_vit.py similarity index 99% rename from tests/test_modeling_tf_vit.py rename to tests/vit/test_modeling_tf_vit.py index ea493fc593..74408fea36 100644 --- a/tests/test_modeling_tf_vit.py +++ b/tests/vit/test_modeling_tf_vit.py @@ -24,8 +24,8 @@ from transformers import ViTConfig from transformers.file_utils import cached_property, is_tf_available, is_vision_available from transformers.testing_utils import require_tf, require_vision, slow, tooslow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor if is_tf_available(): diff --git a/tests/test_modeling_vit.py b/tests/vit/test_modeling_vit.py similarity index 99% rename from tests/test_modeling_vit.py rename to tests/vit/test_modeling_vit.py index e0c38d7b4c..f6e0a314f2 100644 --- a/tests/test_modeling_vit.py +++ b/tests/vit/test_modeling_vit.py @@ -22,8 +22,8 @@ from transformers import ViTConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor if is_torch_available(): diff --git a/tests/vit_mae/__init__.py b/tests/vit_mae/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_vit_mae.py b/tests/vit_mae/test_modeling_vit_mae.py similarity index 99% rename from tests/test_modeling_vit_mae.py rename to tests/vit_mae/test_modeling_vit_mae.py index 3c428938b7..c53ce21808 100644 --- a/tests/test_modeling_vit_mae.py +++ b/tests/vit_mae/test_modeling_vit_mae.py @@ -26,8 +26,8 @@ from transformers import ViTMAEConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor if is_torch_available(): diff --git a/tests/wav2vec2/__init__.py b/tests/wav2vec2/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_feature_extraction_wav2vec2.py b/tests/wav2vec2/test_feature_extraction_wav2vec2.py similarity index 99% rename from tests/test_feature_extraction_wav2vec2.py rename to tests/wav2vec2/test_feature_extraction_wav2vec2.py index 58848f4dd5..67c4e050fd 100644 --- a/tests/test_feature_extraction_wav2vec2.py +++ b/tests/wav2vec2/test_feature_extraction_wav2vec2.py @@ -23,7 +23,7 @@ import numpy as np from transformers import WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST, Wav2Vec2Config, Wav2Vec2FeatureExtractor from transformers.testing_utils import require_torch, slow -from .test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin +from ..test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin global_rng = random.Random() diff --git a/tests/test_modeling_flax_wav2vec2.py b/tests/wav2vec2/test_modeling_flax_wav2vec2.py similarity index 99% rename from tests/test_modeling_flax_wav2vec2.py rename to tests/wav2vec2/test_modeling_flax_wav2vec2.py index 03c309e564..40579d4fd1 100644 --- a/tests/test_modeling_flax_wav2vec2.py +++ b/tests/wav2vec2/test_modeling_flax_wav2vec2.py @@ -30,7 +30,7 @@ from transformers.testing_utils import ( slow, ) -from .test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, random_attention_mask +from ..test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, random_attention_mask if is_flax_available(): diff --git a/tests/test_modeling_tf_wav2vec2.py b/tests/wav2vec2/test_modeling_tf_wav2vec2.py similarity index 99% rename from tests/test_modeling_tf_wav2vec2.py rename to tests/wav2vec2/test_modeling_tf_wav2vec2.py index dfc7280484..110e0717b4 100644 --- a/tests/test_modeling_tf_wav2vec2.py +++ b/tests/wav2vec2/test_modeling_tf_wav2vec2.py @@ -29,8 +29,8 @@ from transformers import Wav2Vec2Config, is_tf_available from transformers.file_utils import is_librosa_available, is_pyctcdecode_available from transformers.testing_utils import require_librosa, require_pyctcdecode, require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_modeling_wav2vec2.py b/tests/wav2vec2/test_modeling_wav2vec2.py similarity index 99% rename from tests/test_modeling_wav2vec2.py rename to tests/wav2vec2/test_modeling_wav2vec2.py index b5e1bcd2cd..126882bf57 100644 --- a/tests/test_modeling_wav2vec2.py +++ b/tests/wav2vec2/test_modeling_wav2vec2.py @@ -20,7 +20,6 @@ import unittest import numpy as np from datasets import load_dataset -from tests.test_modeling_common import floats_tensor, ids_tensor, random_attention_mask from transformers import Wav2Vec2Config, is_torch_available from transformers.testing_utils import ( is_pt_flax_cross_test, @@ -34,8 +33,14 @@ from transformers.testing_utils import ( torch_device, ) -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, _config_zero_init +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ( + ModelTesterMixin, + _config_zero_init, + floats_tensor, + ids_tensor, + random_attention_mask, +) if is_torch_available(): diff --git a/tests/test_processor_wav2vec2.py b/tests/wav2vec2/test_processor_wav2vec2.py similarity index 100% rename from tests/test_processor_wav2vec2.py rename to tests/wav2vec2/test_processor_wav2vec2.py diff --git a/tests/test_tokenization_wav2vec2.py b/tests/wav2vec2/test_tokenization_wav2vec2.py similarity index 99% rename from tests/test_tokenization_wav2vec2.py rename to tests/wav2vec2/test_tokenization_wav2vec2.py index ce278cd8f0..4a75e65325 100644 --- a/tests/test_tokenization_wav2vec2.py +++ b/tests/wav2vec2/test_tokenization_wav2vec2.py @@ -32,7 +32,7 @@ from transformers import ( from transformers.models.wav2vec2.tokenization_wav2vec2 import VOCAB_FILES_NAMES, Wav2Vec2CTCTokenizerOutput from transformers.testing_utils import require_torch, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin global_rng = random.Random() diff --git a/tests/wav2vec2_phoneme/__init__.py b/tests/wav2vec2_phoneme/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_tokenization_wav2vec2_phoneme.py b/tests/wav2vec2_phoneme/test_tokenization_wav2vec2_phoneme.py similarity index 99% rename from tests/test_tokenization_wav2vec2_phoneme.py rename to tests/wav2vec2_phoneme/test_tokenization_wav2vec2_phoneme.py index e72ffce1f6..73f47010b7 100644 --- a/tests/test_tokenization_wav2vec2_phoneme.py +++ b/tests/wav2vec2_phoneme/test_tokenization_wav2vec2_phoneme.py @@ -23,7 +23,7 @@ from transformers.models.wav2vec2.tokenization_wav2vec2 import VOCAB_FILES_NAMES from transformers.models.wav2vec2_phoneme.tokenization_wav2vec2_phoneme import Wav2Vec2PhonemeCTCTokenizerOutput from transformers.testing_utils import require_phonemizer -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin @require_phonemizer diff --git a/tests/wav2vec2_with_lm/__init__.py b/tests/wav2vec2_with_lm/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_processor_wav2vec2_with_lm.py b/tests/wav2vec2_with_lm/test_processor_wav2vec2_with_lm.py similarity index 99% rename from tests/test_processor_wav2vec2_with_lm.py rename to tests/wav2vec2_with_lm/test_processor_wav2vec2_with_lm.py index 1d31b37c47..7ab65de523 100644 --- a/tests/test_processor_wav2vec2_with_lm.py +++ b/tests/wav2vec2_with_lm/test_processor_wav2vec2_with_lm.py @@ -28,7 +28,7 @@ from transformers.models.wav2vec2 import Wav2Vec2CTCTokenizer, Wav2Vec2FeatureEx from transformers.models.wav2vec2.tokenization_wav2vec2 import VOCAB_FILES_NAMES from transformers.testing_utils import require_pyctcdecode -from .test_feature_extraction_wav2vec2 import floats_list +from ..wav2vec2.test_feature_extraction_wav2vec2 import floats_list if is_pyctcdecode_available(): diff --git a/tests/wavlm/__init__.py b/tests/wavlm/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_wavlm.py b/tests/wavlm/test_modeling_wavlm.py similarity index 99% rename from tests/test_modeling_wavlm.py rename to tests/wavlm/test_modeling_wavlm.py index fca90b1aa3..7687dc3936 100644 --- a/tests/test_modeling_wavlm.py +++ b/tests/wavlm/test_modeling_wavlm.py @@ -20,12 +20,17 @@ import unittest import pytest from datasets import load_dataset -from tests.test_modeling_common import floats_tensor, ids_tensor, random_attention_mask from transformers import WavLMConfig, is_torch_available from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, _config_zero_init +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ( + ModelTesterMixin, + _config_zero_init, + floats_tensor, + ids_tensor, + random_attention_mask, +) if is_torch_available(): diff --git a/tests/xglm/__init__.py b/tests/xglm/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_flax_xglm.py b/tests/xglm/test_modeling_flax_xglm.py similarity index 98% rename from tests/test_modeling_flax_xglm.py rename to tests/xglm/test_modeling_flax_xglm.py index 5b2bc8aaac..45399d9624 100644 --- a/tests/test_modeling_flax_xglm.py +++ b/tests/xglm/test_modeling_flax_xglm.py @@ -21,8 +21,8 @@ import transformers from transformers import XGLMConfig, XGLMTokenizer, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, require_sentencepiece, slow -from .test_generation_flax_utils import FlaxGenerationTesterMixin -from .test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask +from ..generation.test_generation_flax_utils import FlaxGenerationTesterMixin +from ..test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): diff --git a/tests/test_modeling_xglm.py b/tests/xglm/test_modeling_xglm.py similarity index 98% rename from tests/test_modeling_xglm.py rename to tests/xglm/test_modeling_xglm.py index 4f56741c18..456c4eaf10 100644 --- a/tests/test_modeling_xglm.py +++ b/tests/xglm/test_modeling_xglm.py @@ -21,9 +21,9 @@ import unittest from transformers import XGLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_tokenization_xglm.py b/tests/xglm/test_tokenization_xglm.py similarity index 98% rename from tests/test_tokenization_xglm.py rename to tests/xglm/test_tokenization_xglm.py index 14b9fe15c4..a86de6a2ff 100644 --- a/tests/test_tokenization_xglm.py +++ b/tests/xglm/test_tokenization_xglm.py @@ -23,10 +23,10 @@ from transformers import SPIECE_UNDERLINE, XGLMTokenizer, XGLMTokenizerFast from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tokenizers, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") +SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../fixtures/test_sentencepiece.model") @require_sentencepiece diff --git a/tests/xlm/__init__.py b/tests/xlm/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_tf_xlm.py b/tests/xlm/test_modeling_tf_xlm.py similarity index 99% rename from tests/test_modeling_tf_xlm.py rename to tests/xlm/test_modeling_tf_xlm.py index 03dc1f0d46..5fc4d2413f 100644 --- a/tests/test_modeling_tf_xlm.py +++ b/tests/xlm/test_modeling_tf_xlm.py @@ -19,8 +19,8 @@ import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_modeling_xlm.py b/tests/xlm/test_modeling_xlm.py similarity index 98% rename from tests/test_modeling_xlm.py rename to tests/xlm/test_modeling_xlm.py index 82adbdc949..f336221072 100644 --- a/tests/test_modeling_xlm.py +++ b/tests/xlm/test_modeling_xlm.py @@ -18,9 +18,9 @@ import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/test_tokenization_xlm.py b/tests/xlm/test_tokenization_xlm.py similarity index 98% rename from tests/test_tokenization_xlm.py rename to tests/xlm/test_tokenization_xlm.py index cf0296ddd9..bd056b69d4 100644 --- a/tests/test_tokenization_xlm.py +++ b/tests/xlm/test_tokenization_xlm.py @@ -21,7 +21,7 @@ import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin class XLMTokenizationTest(TokenizerTesterMixin, unittest.TestCase): diff --git a/tests/xlm_prophetnet/__init__.py b/tests/xlm_prophetnet/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_xlm_prophetnet.py b/tests/xlm_prophetnet/test_modeling_xlm_prophetnet.py similarity index 100% rename from tests/test_modeling_xlm_prophetnet.py rename to tests/xlm_prophetnet/test_modeling_xlm_prophetnet.py diff --git a/tests/test_tokenization_xlm_prophetnet.py b/tests/xlm_prophetnet/test_tokenization_xlm_prophetnet.py similarity index 97% rename from tests/test_tokenization_xlm_prophetnet.py rename to tests/xlm_prophetnet/test_tokenization_xlm_prophetnet.py index 5620477a2c..317fde014c 100644 --- a/tests/test_tokenization_xlm_prophetnet.py +++ b/tests/xlm_prophetnet/test_tokenization_xlm_prophetnet.py @@ -15,15 +15,16 @@ import os import unittest +from os.path import dirname from transformers.file_utils import cached_property from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import require_sentencepiece, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") +SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model") @require_sentencepiece diff --git a/tests/xlm_roberta/__init__.py b/tests/xlm_roberta/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_tf_xlm_roberta.py b/tests/xlm_roberta/test_modeling_tf_xlm_roberta.py similarity index 100% rename from tests/test_modeling_tf_xlm_roberta.py rename to tests/xlm_roberta/test_modeling_tf_xlm_roberta.py diff --git a/tests/test_modeling_xlm_roberta.py b/tests/xlm_roberta/test_modeling_xlm_roberta.py similarity index 100% rename from tests/test_modeling_xlm_roberta.py rename to tests/xlm_roberta/test_modeling_xlm_roberta.py diff --git a/tests/test_tokenization_xlm_roberta.py b/tests/xlm_roberta/test_tokenization_xlm_roberta.py similarity index 98% rename from tests/test_tokenization_xlm_roberta.py rename to tests/xlm_roberta/test_tokenization_xlm_roberta.py index f7bff78483..5266a2a28a 100644 --- a/tests/test_tokenization_xlm_roberta.py +++ b/tests/xlm_roberta/test_tokenization_xlm_roberta.py @@ -18,15 +18,16 @@ import pickle import shutil import tempfile import unittest +from os.path import dirname from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.file_utils import cached_property from transformers.testing_utils import require_sentencepiece, require_tokenizers, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") +SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model") @require_sentencepiece diff --git a/tests/xlm_roberta_xl/__init__.py b/tests/xlm_roberta_xl/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_xlm_roberta_xl.py b/tests/xlm_roberta_xl/test_modeling_xlm_roberta_xl.py similarity index 98% rename from tests/test_modeling_xlm_roberta_xl.py rename to tests/xlm_roberta_xl/test_modeling_xlm_roberta_xl.py index 7ab9462993..a3e7e64481 100644 --- a/tests/test_modeling_xlm_roberta_xl.py +++ b/tests/xlm_roberta_xl/test_modeling_xlm_roberta_xl.py @@ -19,9 +19,9 @@ import unittest from transformers import XLMRobertaXLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available(): diff --git a/tests/xlnet/__init__.py b/tests/xlnet/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_tf_xlnet.py b/tests/xlnet/test_modeling_tf_xlnet.py similarity index 99% rename from tests/test_modeling_tf_xlnet.py rename to tests/xlnet/test_modeling_tf_xlnet.py index 1455b1ee13..6dde2c0518 100644 --- a/tests/test_modeling_tf_xlnet.py +++ b/tests/xlnet/test_modeling_tf_xlnet.py @@ -21,8 +21,8 @@ import unittest from transformers import XLNetConfig, is_tf_available from transformers.testing_utils import require_tf, slow -from .test_configuration_common import ConfigTester -from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor +from ..test_configuration_common import ConfigTester +from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor if is_tf_available(): diff --git a/tests/test_modeling_xlnet.py b/tests/xlnet/test_modeling_xlnet.py similarity index 99% rename from tests/test_modeling_xlnet.py rename to tests/xlnet/test_modeling_xlnet.py index f4e90fbe77..46ed90460c 100644 --- a/tests/test_modeling_xlnet.py +++ b/tests/xlnet/test_modeling_xlnet.py @@ -19,9 +19,9 @@ import unittest from transformers import XLNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_generation_utils import GenerationTesterMixin -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..generation.test_generation_utils import GenerationTesterMixin +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask if is_torch_available(): @@ -526,7 +526,6 @@ class XLNetModelTest(ModelTesterMixin, GenerationTesterMixin, unittest.TestCase) all_generative_model_classes = ( (XLNetLMHeadModel,) if is_torch_available() else () ) # TODO (PVP): Check other models whether language generation is also applicable - test_pruning = False # XLNet has 2 QA models -> need to manually set the correct labels for one of them here diff --git a/tests/test_tokenization_xlnet.py b/tests/xlnet/test_tokenization_xlnet.py similarity index 98% rename from tests/test_tokenization_xlnet.py rename to tests/xlnet/test_tokenization_xlnet.py index 292958eec1..707c975201 100644 --- a/tests/test_tokenization_xlnet.py +++ b/tests/xlnet/test_tokenization_xlnet.py @@ -15,14 +15,15 @@ import os import unittest +from os.path import dirname from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import require_sentencepiece, require_tokenizers, slow -from .test_tokenization_common import TokenizerTesterMixin +from ..test_tokenization_common import TokenizerTesterMixin -SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model") +SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model") @require_sentencepiece diff --git a/tests/yoso/__init__.py b/tests/yoso/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_modeling_yoso.py b/tests/yoso/test_modeling_yoso.py similarity index 98% rename from tests/test_modeling_yoso.py rename to tests/yoso/test_modeling_yoso.py index 9cd00856ce..f6d013b1bf 100644 --- a/tests/test_modeling_yoso.py +++ b/tests/yoso/test_modeling_yoso.py @@ -17,12 +17,11 @@ import unittest -from tests.test_modeling_common import floats_tensor from transformers import YosoConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device -from .test_configuration_common import ConfigTester -from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask +from ..test_configuration_common import ConfigTester +from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_torch_available():