From 25245ec26dc29bcf6102e1b4ddd0dfd02e720cf5 Mon Sep 17 00:00:00 2001 From: amyeroberts <22614925+amyeroberts@users.noreply.github.com> Date: Fri, 7 Jun 2024 19:40:26 +0100 Subject: [PATCH] Rename test_model_common_attributes -> test_model_get_set_embeddings (#31321) * Rename to test_model_common_attributes The method name is misleading - it is testing being able to get and set embeddings, not common attributes to all models * Explicitly skip --- conftest.py | 2 +- tests/models/align/test_modeling_align.py | 4 ++-- tests/models/altclip/test_modeling_altclip.py | 4 ++-- .../test_modeling_audio_spectrogram_transformer.py | 2 +- tests/models/autoformer/test_modeling_autoformer.py | 5 ++++- tests/models/bark/test_modeling_bark.py | 2 +- tests/models/beit/test_modeling_beit.py | 2 +- tests/models/bit/test_modeling_bit.py | 2 +- tests/models/blip/test_modeling_blip.py | 10 +++++----- tests/models/blip_2/test_modeling_blip_2.py | 6 +++--- tests/models/bridgetower/test_modeling_bridgetower.py | 2 +- tests/models/canine/test_modeling_canine.py | 2 +- .../models/chinese_clip/test_modeling_chinese_clip.py | 4 ++-- tests/models/clap/test_modeling_clap.py | 4 ++-- tests/models/clip/test_modeling_clip.py | 6 +++--- tests/models/clipseg/test_modeling_clipseg.py | 4 ++-- tests/models/clvp/test_modeling_clvp.py | 2 +- .../conditional_detr/test_modeling_conditional_detr.py | 2 +- tests/models/convnext/test_modeling_convnext.py | 2 +- tests/models/convnextv2/test_modeling_convnextv2.py | 2 +- tests/models/cvt/test_modeling_cvt.py | 2 +- tests/models/data2vec/test_modeling_data2vec_audio.py | 2 +- tests/models/data2vec/test_modeling_data2vec_vision.py | 2 +- .../test_modeling_decision_transformer.py | 5 ++++- .../deformable_detr/test_modeling_deformable_detr.py | 2 +- tests/models/deit/test_modeling_deit.py | 2 +- .../depth_anything/test_modeling_depth_anything.py | 2 +- tests/models/detr/test_modeling_detr.py | 2 +- tests/models/dinat/test_modeling_dinat.py | 2 +- tests/models/dinov2/test_modeling_dinov2.py | 2 +- tests/models/donut/test_modeling_donut_swin.py | 2 +- tests/models/dpt/test_modeling_dpt.py | 2 +- tests/models/dpt/test_modeling_dpt_auto_backbone.py | 2 +- tests/models/dpt/test_modeling_dpt_hybrid.py | 2 +- .../models/efficientnet/test_modeling_efficientnet.py | 2 +- tests/models/encodec/test_modeling_encodec.py | 2 +- .../test_modeling_fastspeech2_conformer.py | 4 ++-- tests/models/flava/test_modeling_flava.py | 8 ++++---- tests/models/focalnet/test_modeling_focalnet.py | 2 +- tests/models/fsmt/test_modeling_fsmt.py | 4 ++-- tests/models/git/test_modeling_git.py | 2 +- tests/models/glpn/test_modeling_glpn.py | 2 +- .../grounding_dino/test_modeling_grounding_dino.py | 2 +- tests/models/groupvit/test_modeling_groupvit.py | 4 ++-- tests/models/hubert/test_modeling_hubert.py | 4 ++-- tests/models/ibert/test_modeling_ibert.py | 2 +- tests/models/informer/test_modeling_informer.py | 5 ++++- .../models/instructblip/test_modeling_instructblip.py | 4 ++-- tests/models/levit/test_modeling_levit.py | 2 +- tests/models/mask2former/test_modeling_mask2former.py | 2 +- tests/models/maskformer/test_modeling_maskformer.py | 2 +- .../models/maskformer/test_modeling_maskformer_swin.py | 2 +- tests/models/mgp_str/test_modeling_mgp_str.py | 2 +- .../models/mobilenet_v1/test_modeling_mobilenet_v1.py | 2 +- .../models/mobilenet_v2/test_modeling_mobilenet_v2.py | 2 +- tests/models/mobilevit/test_modeling_mobilevit.py | 2 +- tests/models/mobilevitv2/test_modeling_mobilevitv2.py | 2 +- tests/models/musicgen/test_modeling_musicgen.py | 4 ++-- .../musicgen_melody/test_modeling_musicgen_melody.py | 4 ++-- tests/models/oneformer/test_modeling_oneformer.py | 2 +- tests/models/owlv2/test_modeling_owlv2.py | 6 +++--- tests/models/owlvit/test_modeling_owlvit.py | 6 +++--- .../models/patchtsmixer/test_modeling_patchtsmixer.py | 5 ++++- tests/models/patchtst/test_modeling_patchtst.py | 5 ++++- tests/models/perceiver/test_modeling_perceiver.py | 2 +- tests/models/pix2struct/test_modeling_pix2struct.py | 4 ++-- tests/models/poolformer/test_modeling_poolformer.py | 2 +- tests/models/pvt/test_modeling_pvt.py | 2 +- tests/models/pvt_v2/test_modeling_pvt_v2.py | 2 +- tests/models/regnet/test_modeling_regnet.py | 2 +- tests/models/resnet/test_modeling_resnet.py | 2 +- tests/models/sam/test_modeling_sam.py | 2 +- tests/models/segformer/test_modeling_segformer.py | 2 +- tests/models/seggpt/test_modeling_seggpt.py | 2 +- tests/models/sew/test_modeling_sew.py | 2 +- tests/models/sew_d/test_modeling_sew_d.py | 2 +- tests/models/siglip/test_modeling_siglip.py | 8 ++++---- tests/models/speecht5/test_modeling_speecht5.py | 6 +++--- tests/models/superpoint/test_modeling_superpoint.py | 2 +- tests/models/swiftformer/test_modeling_swiftformer.py | 2 +- tests/models/swin/test_modeling_swin.py | 2 +- tests/models/swin2sr/test_modeling_swin2sr.py | 2 +- tests/models/swinv2/test_modeling_swinv2.py | 2 +- .../test_modeling_table_transformer.py | 2 +- .../test_modeling_time_series_transformer.py | 5 ++++- tests/models/timesformer/test_modeling_timesformer.py | 2 +- .../timm_backbone/test_modeling_timm_backbone.py | 2 +- tests/models/tvp/test_modeling_tvp.py | 2 +- tests/models/unispeech/test_modeling_unispeech.py | 2 +- .../unispeech_sat/test_modeling_unispeech_sat.py | 4 ++-- tests/models/univnet/test_modeling_univnet.py | 2 +- tests/models/upernet/test_modeling_upernet.py | 2 +- tests/models/videomae/test_modeling_videomae.py | 2 +- tests/models/vit/test_modeling_vit.py | 2 +- tests/models/vit_mae/test_modeling_vit_mae.py | 2 +- tests/models/vit_msn/test_modeling_vit_msn.py | 2 +- tests/models/vitdet/test_modeling_vitdet.py | 2 +- tests/models/vitmatte/test_modeling_vitmatte.py | 2 +- tests/models/vits/test_modeling_vits.py | 2 +- tests/models/vivit/test_modeling_vivit.py | 2 +- tests/models/wav2vec2/test_modeling_wav2vec2.py | 4 ++-- .../wav2vec2_bert/test_modeling_wav2vec2_bert.py | 2 +- .../test_modeling_wav2vec2_conformer.py | 2 +- tests/models/wavlm/test_modeling_wavlm.py | 2 +- tests/models/whisper/test_modeling_whisper.py | 2 +- tests/models/x_clip/test_modeling_x_clip.py | 4 ++-- tests/models/yolos/test_modeling_yolos.py | 2 +- tests/test_modeling_common.py | 8 ++++++-- 108 files changed, 167 insertions(+), 145 deletions(-) diff --git a/conftest.py b/conftest.py index 3f2dae258b2..40e43f25e89 100644 --- a/conftest.py +++ b/conftest.py @@ -53,7 +53,7 @@ NOT_DEVICE_TESTS = { "test_torch_save_load", "test_initialization", "test_forward_signature", - "test_model_common_attributes", + "test_model_get_set_embeddings", "test_model_main_input_name", "test_correct_missing_keys", "test_tie_model_weights", diff --git a/tests/models/align/test_modeling_align.py b/tests/models/align/test_modeling_align.py index f2d1655f25a..fd71b2c3df3 100644 --- a/tests/models/align/test_modeling_align.py +++ b/tests/models/align/test_modeling_align.py @@ -171,7 +171,7 @@ class AlignVisionModelTest(ModelTesterMixin, unittest.TestCase): pass @unittest.skip(reason="AlignVisionModel does not support input and output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_forward_signature(self): @@ -489,7 +489,7 @@ class AlignModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip(reason="AlignModel does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass # override as the `temperature` parameter initilization is different for ALIGN diff --git a/tests/models/altclip/test_modeling_altclip.py b/tests/models/altclip/test_modeling_altclip.py index c7c735b19f8..4f258e4ddb2 100755 --- a/tests/models/altclip/test_modeling_altclip.py +++ b/tests/models/altclip/test_modeling_altclip.py @@ -153,7 +153,7 @@ class AltCLIPVisionModelTest(ModelTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: @@ -459,7 +459,7 @@ class AltCLIPModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase) pass @unittest.skip(reason="CLIPModel does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass # override as the `logit_scale` parameter initilization is different for AltCLIP diff --git a/tests/models/audio_spectrogram_transformer/test_modeling_audio_spectrogram_transformer.py b/tests/models/audio_spectrogram_transformer/test_modeling_audio_spectrogram_transformer.py index 9ab07b55088..0bbefda7ba5 100644 --- a/tests/models/audio_spectrogram_transformer/test_modeling_audio_spectrogram_transformer.py +++ b/tests/models/audio_spectrogram_transformer/test_modeling_audio_spectrogram_transformer.py @@ -185,7 +185,7 @@ class ASTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/autoformer/test_modeling_autoformer.py b/tests/models/autoformer/test_modeling_autoformer.py index fb00c403f67..f0cd5dad37b 100644 --- a/tests/models/autoformer/test_modeling_autoformer.py +++ b/tests/models/autoformer/test_modeling_autoformer.py @@ -212,7 +212,6 @@ class AutoformerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCa test_missing_keys = False test_torchscript = False test_inputs_embeds = False - test_model_common_attributes = False def setUp(self): self.model_tester = AutoformerModelTester(self) @@ -403,6 +402,10 @@ class AutoformerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCa def test_retain_grad_hidden_states_attentions(self): super().test_retain_grad_hidden_states_attentions() + @unittest.skip(reason="Model does not have input embeddings") + def test_model_get_set_embeddings(self): + pass + def prepare_batch(filename="train-batch.pt"): file = hf_hub_download(repo_id="hf-internal-testing/tourism-monthly-batch", filename=filename, repo_type="dataset") diff --git a/tests/models/bark/test_modeling_bark.py b/tests/models/bark/test_modeling_bark.py index 67c18288a8a..47e0beaeae8 100644 --- a/tests/models/bark/test_modeling_bark.py +++ b/tests/models/bark/test_modeling_bark.py @@ -809,7 +809,7 @@ class BarkFineModelTest(ModelTesterMixin, unittest.TestCase): expected_arg_names = ["codebook_idx", "input_ids"] self.assertListEqual(arg_names[:2], expected_arg_names) - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): # one embedding layer per codebook config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common() diff --git a/tests/models/beit/test_modeling_beit.py b/tests/models/beit/test_modeling_beit.py index 0fd17efaf67..84ca3cdd621 100644 --- a/tests/models/beit/test_modeling_beit.py +++ b/tests/models/beit/test_modeling_beit.py @@ -270,7 +270,7 @@ class BeitModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): def test_feed_forward_chunking(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/bit/test_modeling_bit.py b/tests/models/bit/test_modeling_bit.py index ec666ec9732..baf7afa8568 100644 --- a/tests/models/bit/test_modeling_bit.py +++ b/tests/models/bit/test_modeling_bit.py @@ -196,7 +196,7 @@ class BitModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip(reason="Bit does not support input and output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_model(self): diff --git a/tests/models/blip/test_modeling_blip.py b/tests/models/blip/test_modeling_blip.py index 2ea4f09214d..db71336e346 100644 --- a/tests/models/blip/test_modeling_blip.py +++ b/tests/models/blip/test_modeling_blip.py @@ -168,7 +168,7 @@ class BlipVisionModelTest(ModelTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: @@ -462,7 +462,7 @@ class BlipModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip(reason="BlipModel does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass # override as the `logit_scale` parameter initilization is different for Blip @@ -867,7 +867,7 @@ class BlipVQAModelTest(ModelTesterMixin, unittest.TestCase): pass @unittest.skip(reason="BlipModel does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @@ -901,7 +901,7 @@ class BlipTextRetrievalModelTest(ModelTesterMixin, unittest.TestCase): pass @unittest.skip(reason="BlipModel does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_forward_signature(self): @@ -1129,7 +1129,7 @@ class BlipTextImageModelTest(ModelTesterMixin, unittest.TestCase): pass @unittest.skip(reason="BlipModel does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_forward_signature(self): diff --git a/tests/models/blip_2/test_modeling_blip_2.py b/tests/models/blip_2/test_modeling_blip_2.py index f32ffea850b..9e295325b3f 100644 --- a/tests/models/blip_2/test_modeling_blip_2.py +++ b/tests/models/blip_2/test_modeling_blip_2.py @@ -162,7 +162,7 @@ class Blip2VisionModelTest(ModelTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: @@ -463,7 +463,7 @@ class Blip2ForConditionalGenerationDecoderOnlyTest(ModelTesterMixin, GenerationT pass @unittest.skip(reason="Blip2Model does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="There's no base Blip2Model") @@ -722,7 +722,7 @@ class Blip2ModelTest(ModelTesterMixin, PipelineTesterMixin, GenerationTesterMixi pass @unittest.skip(reason="Blip2Model does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="There's no base Blip2Model") diff --git a/tests/models/bridgetower/test_modeling_bridgetower.py b/tests/models/bridgetower/test_modeling_bridgetower.py index b8de60ac5c6..44e6a404f62 100644 --- a/tests/models/bridgetower/test_modeling_bridgetower.py +++ b/tests/models/bridgetower/test_modeling_bridgetower.py @@ -499,7 +499,7 @@ class BridgeTowerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC ) @unittest.skip(reason="""Bridge Tower does not have input/output embeddings. So this test is not applicable.""") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="""Bridge Tower does not have input/output embeddings. Thus this test is not applicable.""") diff --git a/tests/models/canine/test_modeling_canine.py b/tests/models/canine/test_modeling_canine.py index 2d2dfef40e1..3e7b27638c2 100644 --- a/tests/models/canine/test_modeling_canine.py +++ b/tests/models/canine/test_modeling_canine.py @@ -506,7 +506,7 @@ class CanineModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip("CANINE does not have a get_input_embeddings() method.") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip( diff --git a/tests/models/chinese_clip/test_modeling_chinese_clip.py b/tests/models/chinese_clip/test_modeling_chinese_clip.py index 0b8220c8ed5..17d8ddcb1c4 100644 --- a/tests/models/chinese_clip/test_modeling_chinese_clip.py +++ b/tests/models/chinese_clip/test_modeling_chinese_clip.py @@ -441,7 +441,7 @@ class ChineseCLIPVisionModelTest(ModelTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: @@ -589,7 +589,7 @@ class ChineseCLIPModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC pass @unittest.skip(reason="ChineseCLIPModel does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass # override as the `logit_scale` parameter initilization is different for CHINESE_CLIP diff --git a/tests/models/clap/test_modeling_clap.py b/tests/models/clap/test_modeling_clap.py index 835a06b0ce6..1255a31b819 100644 --- a/tests/models/clap/test_modeling_clap.py +++ b/tests/models/clap/test_modeling_clap.py @@ -177,7 +177,7 @@ class ClapAudioModelTest(ModelTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: @@ -533,7 +533,7 @@ class ClapModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip(reason="ClapModel does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass # override as the `logit_scale` parameter initilization is different for CLAP diff --git a/tests/models/clip/test_modeling_clip.py b/tests/models/clip/test_modeling_clip.py index fa33176363e..5221274ffae 100644 --- a/tests/models/clip/test_modeling_clip.py +++ b/tests/models/clip/test_modeling_clip.py @@ -191,7 +191,7 @@ class CLIPVisionModelTest(ModelTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: @@ -506,7 +506,7 @@ class CLIPModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip(reason="CLIPModel does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass # override as the `logit_scale` parameter initilization is different for CLIP @@ -783,7 +783,7 @@ class CLIPForImageClassificationModelTest(ModelTesterMixin, PipelineTesterMixin, pass @unittest.skip(reason="CLIPForImageClassification does not support inputs_embeds") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="CLIPForImageClassification does not support gradient checkpointing yet") diff --git a/tests/models/clipseg/test_modeling_clipseg.py b/tests/models/clipseg/test_modeling_clipseg.py index 9e819d3b263..e9bfd2201e8 100644 --- a/tests/models/clipseg/test_modeling_clipseg.py +++ b/tests/models/clipseg/test_modeling_clipseg.py @@ -169,7 +169,7 @@ class CLIPSegVisionModelTest(ModelTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: @@ -490,7 +490,7 @@ class CLIPSegModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase) pass @unittest.skip(reason="CLIPSegModel does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip( diff --git a/tests/models/clvp/test_modeling_clvp.py b/tests/models/clvp/test_modeling_clvp.py index 1370c9acc87..0cf89a74523 100644 --- a/tests/models/clvp/test_modeling_clvp.py +++ b/tests/models/clvp/test_modeling_clvp.py @@ -489,7 +489,7 @@ class ClvpModelForConditionalGenerationTest(ModelTesterMixin, unittest.TestCase) pass @unittest.skip(reason="ClvpModelForConditionalGeneration does not have get_input_embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass # override as the `logit_scale` parameter initilization is different for Clvp diff --git a/tests/models/conditional_detr/test_modeling_conditional_detr.py b/tests/models/conditional_detr/test_modeling_conditional_detr.py index 9efde402b07..18f85a71e07 100644 --- a/tests/models/conditional_detr/test_modeling_conditional_detr.py +++ b/tests/models/conditional_detr/test_modeling_conditional_detr.py @@ -251,7 +251,7 @@ class ConditionalDetrModelTest(ModelTesterMixin, GenerationTesterMixin, Pipeline pass @unittest.skip(reason="Conditional DETR does not have a get_input_embeddings method") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="Conditional DETR is not a generative model") diff --git a/tests/models/convnext/test_modeling_convnext.py b/tests/models/convnext/test_modeling_convnext.py index b618608f0e9..99145eee6aa 100644 --- a/tests/models/convnext/test_modeling_convnext.py +++ b/tests/models/convnext/test_modeling_convnext.py @@ -202,7 +202,7 @@ class ConvNextModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase pass @unittest.skip(reason="ConvNext does not support input and output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="ConvNext does not use feedforward chunking") diff --git a/tests/models/convnextv2/test_modeling_convnextv2.py b/tests/models/convnextv2/test_modeling_convnextv2.py index 3201de6f936..f3ca05f80b8 100644 --- a/tests/models/convnextv2/test_modeling_convnextv2.py +++ b/tests/models/convnextv2/test_modeling_convnextv2.py @@ -210,7 +210,7 @@ class ConvNextV2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCa pass @unittest.skip(reason="ConvNextV2 does not support input and output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="ConvNextV2 does not use feedforward chunking") diff --git a/tests/models/cvt/test_modeling_cvt.py b/tests/models/cvt/test_modeling_cvt.py index 9facafcd778..588599e409b 100644 --- a/tests/models/cvt/test_modeling_cvt.py +++ b/tests/models/cvt/test_modeling_cvt.py @@ -185,7 +185,7 @@ class CvtModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip(reason="Cvt does not support input and output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_model(self): diff --git a/tests/models/data2vec/test_modeling_data2vec_audio.py b/tests/models/data2vec/test_modeling_data2vec_audio.py index 0376edad2dc..d2e0e2853f0 100644 --- a/tests/models/data2vec/test_modeling_data2vec_audio.py +++ b/tests/models/data2vec/test_modeling_data2vec_audio.py @@ -442,7 +442,7 @@ class Data2VecAudioModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Tes # Data2VecAudio has no inputs_embeds # and thus the `get_input_embeddings` fn # is not implemented - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @is_pt_flax_cross_test diff --git a/tests/models/data2vec/test_modeling_data2vec_vision.py b/tests/models/data2vec/test_modeling_data2vec_vision.py index fabf543c021..8f8a1fad447 100644 --- a/tests/models/data2vec/test_modeling_data2vec_vision.py +++ b/tests/models/data2vec/test_modeling_data2vec_vision.py @@ -207,7 +207,7 @@ class Data2VecVisionModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Te def test_multi_gpu_data_parallel_forward(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/decision_transformer/test_modeling_decision_transformer.py b/tests/models/decision_transformer/test_modeling_decision_transformer.py index 5d69bbd0b23..27d1598167e 100644 --- a/tests/models/decision_transformer/test_modeling_decision_transformer.py +++ b/tests/models/decision_transformer/test_modeling_decision_transformer.py @@ -143,7 +143,6 @@ class DecisionTransformerModelTest(ModelTesterMixin, GenerationTesterMixin, Pipe test_attention_outputs = False test_hidden_states_output = False test_inputs_embeds = False - test_model_common_attributes = False test_gradient_checkpointing = False test_torchscript = False @@ -184,6 +183,10 @@ class DecisionTransformerModelTest(ModelTesterMixin, GenerationTesterMixin, Pipe self.assertListEqual(arg_names[: len(expected_arg_names)], expected_arg_names) + @unittest.skip(reason="Model does not have input embeddings") + def test_model_get_set_embeddings(self): + pass + @require_torch class DecisionTransformerModelIntegrationTest(unittest.TestCase): diff --git a/tests/models/deformable_detr/test_modeling_deformable_detr.py b/tests/models/deformable_detr/test_modeling_deformable_detr.py index b1fc9b23b3c..5d7b027394d 100644 --- a/tests/models/deformable_detr/test_modeling_deformable_detr.py +++ b/tests/models/deformable_detr/test_modeling_deformable_detr.py @@ -257,7 +257,7 @@ class DeformableDetrModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineT pass @unittest.skip(reason="Deformable DETR does not have a get_input_embeddings method") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="Deformable DETR is not a generative model") diff --git a/tests/models/deit/test_modeling_deit.py b/tests/models/deit/test_modeling_deit.py index d1357d12970..daf13d207b0 100644 --- a/tests/models/deit/test_modeling_deit.py +++ b/tests/models/deit/test_modeling_deit.py @@ -241,7 +241,7 @@ class DeiTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/depth_anything/test_modeling_depth_anything.py b/tests/models/depth_anything/test_modeling_depth_anything.py index 7a08ecb85e7..eb51f1ef342 100644 --- a/tests/models/depth_anything/test_modeling_depth_anything.py +++ b/tests/models/depth_anything/test_modeling_depth_anything.py @@ -178,7 +178,7 @@ class DepthAnythingModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Tes pass @unittest.skip(reason="Depth Anything with AutoBackbone does not have a base model and hence no input_embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="Depth Anything with AutoBackbone does not have a base model") diff --git a/tests/models/detr/test_modeling_detr.py b/tests/models/detr/test_modeling_detr.py index 0aea506b5fb..be75423827a 100644 --- a/tests/models/detr/test_modeling_detr.py +++ b/tests/models/detr/test_modeling_detr.py @@ -251,7 +251,7 @@ class DetrModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin pass @unittest.skip(reason="DETR does not have a get_input_embeddings method") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="DETR is not a generative model") diff --git a/tests/models/dinat/test_modeling_dinat.py b/tests/models/dinat/test_modeling_dinat.py index 2fe9de14b9e..ebfd49af937 100644 --- a/tests/models/dinat/test_modeling_dinat.py +++ b/tests/models/dinat/test_modeling_dinat.py @@ -253,7 +253,7 @@ class DinatModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): def test_feed_forward_chunking(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/dinov2/test_modeling_dinov2.py b/tests/models/dinov2/test_modeling_dinov2.py index 5bf2d51b2da..88be7061cf4 100644 --- a/tests/models/dinov2/test_modeling_dinov2.py +++ b/tests/models/dinov2/test_modeling_dinov2.py @@ -258,7 +258,7 @@ class Dinov2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): def test_training_gradient_checkpointing_use_reentrant_false(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/donut/test_modeling_donut_swin.py b/tests/models/donut/test_modeling_donut_swin.py index 8b86dffab15..2173a90ae99 100644 --- a/tests/models/donut/test_modeling_donut_swin.py +++ b/tests/models/donut/test_modeling_donut_swin.py @@ -175,7 +175,7 @@ class DonutSwinModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCas # DonutSwin does not use inputs_embeds pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/dpt/test_modeling_dpt.py b/tests/models/dpt/test_modeling_dpt.py index db35483d962..5232b4cf462 100644 --- a/tests/models/dpt/test_modeling_dpt.py +++ b/tests/models/dpt/test_modeling_dpt.py @@ -183,7 +183,7 @@ class DPTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/dpt/test_modeling_dpt_auto_backbone.py b/tests/models/dpt/test_modeling_dpt_auto_backbone.py index 2b37b816f4b..35283eebf5e 100644 --- a/tests/models/dpt/test_modeling_dpt_auto_backbone.py +++ b/tests/models/dpt/test_modeling_dpt_auto_backbone.py @@ -217,7 +217,7 @@ class DPTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): ) @unittest.skip(reason="DPT with AutoBackbone does not have a base model and hence no input_embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="DPT with AutoBackbone does not have a base model") diff --git a/tests/models/dpt/test_modeling_dpt_hybrid.py b/tests/models/dpt/test_modeling_dpt_hybrid.py index 2caa8d71aec..ab117c14416 100644 --- a/tests/models/dpt/test_modeling_dpt_hybrid.py +++ b/tests/models/dpt/test_modeling_dpt_hybrid.py @@ -198,7 +198,7 @@ class DPTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/efficientnet/test_modeling_efficientnet.py b/tests/models/efficientnet/test_modeling_efficientnet.py index eaf0f4ec879..0db10706ebc 100644 --- a/tests/models/efficientnet/test_modeling_efficientnet.py +++ b/tests/models/efficientnet/test_modeling_efficientnet.py @@ -162,7 +162,7 @@ class EfficientNetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Test pass @unittest.skip(reason="EfficientNet does not support input and output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="EfficientNet does not use feedforward chunking") diff --git a/tests/models/encodec/test_modeling_encodec.py b/tests/models/encodec/test_modeling_encodec.py index c2974943e0a..be3d7161c64 100644 --- a/tests/models/encodec/test_modeling_encodec.py +++ b/tests/models/encodec/test_modeling_encodec.py @@ -183,7 +183,7 @@ class EncodecModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase) pass @unittest.skip("The EncodecModel is not transformers based, thus it does not have `inputs_embeds` logics") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip("The EncodecModel is not transformers based, thus it does not have the usual `attention` logic") diff --git a/tests/models/fastspeech2_conformer/test_modeling_fastspeech2_conformer.py b/tests/models/fastspeech2_conformer/test_modeling_fastspeech2_conformer.py index cf57ee079a8..5191105bc2a 100644 --- a/tests/models/fastspeech2_conformer/test_modeling_fastspeech2_conformer.py +++ b/tests/models/fastspeech2_conformer/test_modeling_fastspeech2_conformer.py @@ -344,7 +344,7 @@ class FastSpeech2ConformerModelTest(ModelTesterMixin, unittest.TestCase): pass @unittest.skip(reason="FastSpeech2Conformer has no input embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip( @@ -766,7 +766,7 @@ class FastSpeech2ConformerWithHifiGanTest(ModelTesterMixin, unittest.TestCase): pass @unittest.skip(reason="FastSpeech2Conformer has no input embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip( diff --git a/tests/models/flava/test_modeling_flava.py b/tests/models/flava/test_modeling_flava.py index 1287a297a42..7e067115e7b 100644 --- a/tests/models/flava/test_modeling_flava.py +++ b/tests/models/flava/test_modeling_flava.py @@ -180,7 +180,7 @@ class FlavaImageModelTest(ModelTesterMixin, unittest.TestCase): # FLAVA does not use inputs_embeds pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: @@ -619,7 +619,7 @@ class FlavaMultimodalModelTest(ModelTesterMixin, unittest.TestCase): expected_arg_names = ["hidden_states"] self.assertListEqual(arg_names[:1], expected_arg_names) - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): # No embedding in multimodal model pass @@ -742,7 +742,7 @@ class FlavaImageCodebookTest(ModelTesterMixin, unittest.TestCase): def test_attention_outputs(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): # No embedding in multimodal model pass @@ -944,7 +944,7 @@ class FlavaModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass # FlavaModel does not have input/output embeddings - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass # override as the `logit_scale` parameter initilization is different for FLAVA diff --git a/tests/models/focalnet/test_modeling_focalnet.py b/tests/models/focalnet/test_modeling_focalnet.py index 2cd29fc2c31..230a5412fb5 100644 --- a/tests/models/focalnet/test_modeling_focalnet.py +++ b/tests/models/focalnet/test_modeling_focalnet.py @@ -288,7 +288,7 @@ class FocalNetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase def test_feed_forward_chunking(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes[:-1]: diff --git a/tests/models/fsmt/test_modeling_fsmt.py b/tests/models/fsmt/test_modeling_fsmt.py index 1b6fddbc072..c3ad05e300f 100644 --- a/tests/models/fsmt/test_modeling_fsmt.py +++ b/tests/models/fsmt/test_modeling_fsmt.py @@ -193,8 +193,8 @@ class FSMTModelTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin def test_config(self): self.config_tester.run_common_tests() - # XXX: override test_model_common_attributes / different Embedding type - def test_model_common_attributes(self): + # XXX: override test_model_get_set_embeddings / different Embedding type + def test_model_get_set_embeddings(self): config, inputs_dict = self.model_tester.prepare_config_and_inputs() for model_class in self.all_model_classes: diff --git a/tests/models/git/test_modeling_git.py b/tests/models/git/test_modeling_git.py index 0ef74d81843..ee2cf4927a5 100644 --- a/tests/models/git/test_modeling_git.py +++ b/tests/models/git/test_modeling_git.py @@ -142,7 +142,7 @@ class GitVisionModelTest(ModelTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/glpn/test_modeling_glpn.py b/tests/models/glpn/test_modeling_glpn.py index 2e1486039e0..151162fb1bb 100644 --- a/tests/models/glpn/test_modeling_glpn.py +++ b/tests/models/glpn/test_modeling_glpn.py @@ -173,7 +173,7 @@ class GLPNModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip("GLPN does not have get_input_embeddings method and get_output_embeddings methods") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_attention_outputs(self): diff --git a/tests/models/grounding_dino/test_modeling_grounding_dino.py b/tests/models/grounding_dino/test_modeling_grounding_dino.py index fe67deb9383..4ced752c0ef 100644 --- a/tests/models/grounding_dino/test_modeling_grounding_dino.py +++ b/tests/models/grounding_dino/test_modeling_grounding_dino.py @@ -269,7 +269,7 @@ class GroundingDinoModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Tes pass @unittest.skip(reason="Grounding DINO does not have a get_input_embeddings method") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="Grounding DINO does not use token embeddings") diff --git a/tests/models/groupvit/test_modeling_groupvit.py b/tests/models/groupvit/test_modeling_groupvit.py index 15e7ad29fcd..74c07b775bc 100644 --- a/tests/models/groupvit/test_modeling_groupvit.py +++ b/tests/models/groupvit/test_modeling_groupvit.py @@ -174,7 +174,7 @@ class GroupViTVisionModelTest(ModelTesterMixin, unittest.TestCase): tf.random.set_seed(seed) return super().test_pt_tf_model_equivalence() - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: @@ -573,7 +573,7 @@ class GroupViTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase pass @unittest.skip(reason="GroupViTModel does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass # overwritten from parent as this equivalent test needs a specific `seed` and hard to get a good one! diff --git a/tests/models/hubert/test_modeling_hubert.py b/tests/models/hubert/test_modeling_hubert.py index 3e54e7d2db7..7bf19757fa3 100644 --- a/tests/models/hubert/test_modeling_hubert.py +++ b/tests/models/hubert/test_modeling_hubert.py @@ -366,7 +366,7 @@ class HubertModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): # Hubert has no inputs_embeds # and thus the `get_input_embeddings` fn # is not implemented - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_retain_grad_hidden_states_attentions(self): @@ -631,7 +631,7 @@ class HubertRobustModelTest(ModelTesterMixin, unittest.TestCase): # Hubert has no inputs_embeds # and thus the `get_input_embeddings` fn # is not implemented - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_retain_grad_hidden_states_attentions(self): diff --git a/tests/models/ibert/test_modeling_ibert.py b/tests/models/ibert/test_modeling_ibert.py index feb1c026457..342d8175455 100644 --- a/tests/models/ibert/test_modeling_ibert.py +++ b/tests/models/ibert/test_modeling_ibert.py @@ -334,7 +334,7 @@ class IBertModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): self.assertTrue(torch.all(torch.eq(position_ids, expected_positions))) # Override - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/informer/test_modeling_informer.py b/tests/models/informer/test_modeling_informer.py index d81711a8ec0..5eab89a3adb 100644 --- a/tests/models/informer/test_modeling_informer.py +++ b/tests/models/informer/test_modeling_informer.py @@ -198,7 +198,6 @@ class InformerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase test_missing_keys = False test_torchscript = False test_inputs_embeds = False - test_model_common_attributes = False def setUp(self): self.model_tester = InformerModelTester(self) @@ -468,6 +467,10 @@ class InformerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase def test_retain_grad_hidden_states_attentions(self): super().test_retain_grad_hidden_states_attentions() + @unittest.skip(reason="Model does not have input embeddings") + def test_model_get_set_embeddings(self): + pass + def prepare_batch(filename="train-batch.pt"): file = hf_hub_download(repo_id="hf-internal-testing/tourism-monthly-batch", filename=filename, repo_type="dataset") diff --git a/tests/models/instructblip/test_modeling_instructblip.py b/tests/models/instructblip/test_modeling_instructblip.py index 50252629314..1aaa8e1a8b6 100644 --- a/tests/models/instructblip/test_modeling_instructblip.py +++ b/tests/models/instructblip/test_modeling_instructblip.py @@ -165,7 +165,7 @@ class InstructBlipVisionModelTest(ModelTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: @@ -485,7 +485,7 @@ class InstructBlipForConditionalGenerationDecoderOnlyTest(ModelTesterMixin, Gene pass @unittest.skip(reason="InstructBlipModel does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="There's no base InstructBlipModel") diff --git a/tests/models/levit/test_modeling_levit.py b/tests/models/levit/test_modeling_levit.py index 6303e0365fa..69ac6a6a8fb 100644 --- a/tests/models/levit/test_modeling_levit.py +++ b/tests/models/levit/test_modeling_levit.py @@ -209,7 +209,7 @@ class LevitModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip(reason="Levit does not support input and output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="Levit does not output attentions") diff --git a/tests/models/mask2former/test_modeling_mask2former.py b/tests/models/mask2former/test_modeling_mask2former.py index 1065607e0be..64e2de13857 100644 --- a/tests/models/mask2former/test_modeling_mask2former.py +++ b/tests/models/mask2former/test_modeling_mask2former.py @@ -225,7 +225,7 @@ class Mask2FormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC pass @unittest.skip(reason="Mask2Former does not have a get_input_embeddings method") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="Mask2Former is not a generative model") diff --git a/tests/models/maskformer/test_modeling_maskformer.py b/tests/models/maskformer/test_modeling_maskformer.py index 4c9c69ed5ff..025261841b3 100644 --- a/tests/models/maskformer/test_modeling_maskformer.py +++ b/tests/models/maskformer/test_modeling_maskformer.py @@ -251,7 +251,7 @@ class MaskFormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCa pass @unittest.skip(reason="MaskFormer does not have a get_input_embeddings method") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="MaskFormer is not a generative model") diff --git a/tests/models/maskformer/test_modeling_maskformer_swin.py b/tests/models/maskformer/test_modeling_maskformer_swin.py index 01e9ed0e675..c7c8c1b212f 100644 --- a/tests/models/maskformer/test_modeling_maskformer_swin.py +++ b/tests/models/maskformer/test_modeling_maskformer_swin.py @@ -224,7 +224,7 @@ class MaskFormerSwinModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Te def test_feed_forward_chunking(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/mgp_str/test_modeling_mgp_str.py b/tests/models/mgp_str/test_modeling_mgp_str.py index ec1ac5a24a4..559a9e59684 100644 --- a/tests/models/mgp_str/test_modeling_mgp_str.py +++ b/tests/models/mgp_str/test_modeling_mgp_str.py @@ -145,7 +145,7 @@ class MgpstrModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/mobilenet_v1/test_modeling_mobilenet_v1.py b/tests/models/mobilenet_v1/test_modeling_mobilenet_v1.py index 54fb057b372..a04cfba45f6 100644 --- a/tests/models/mobilenet_v1/test_modeling_mobilenet_v1.py +++ b/tests/models/mobilenet_v1/test_modeling_mobilenet_v1.py @@ -167,7 +167,7 @@ class MobileNetV1ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC pass @unittest.skip(reason="MobileNetV1 does not support input and output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="MobileNetV1 does not output attentions") diff --git a/tests/models/mobilenet_v2/test_modeling_mobilenet_v2.py b/tests/models/mobilenet_v2/test_modeling_mobilenet_v2.py index eb3105e427d..7df6cbd1196 100644 --- a/tests/models/mobilenet_v2/test_modeling_mobilenet_v2.py +++ b/tests/models/mobilenet_v2/test_modeling_mobilenet_v2.py @@ -218,7 +218,7 @@ class MobileNetV2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC pass @unittest.skip(reason="MobileNetV2 does not support input and output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="MobileNetV2 does not output attentions") diff --git a/tests/models/mobilevit/test_modeling_mobilevit.py b/tests/models/mobilevit/test_modeling_mobilevit.py index 381763d4497..9eb5878500d 100644 --- a/tests/models/mobilevit/test_modeling_mobilevit.py +++ b/tests/models/mobilevit/test_modeling_mobilevit.py @@ -211,7 +211,7 @@ class MobileViTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCas pass @unittest.skip(reason="MobileViT does not support input and output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="MobileViT does not output attentions") diff --git a/tests/models/mobilevitv2/test_modeling_mobilevitv2.py b/tests/models/mobilevitv2/test_modeling_mobilevitv2.py index 340bd22fbbc..e2b565e4b9c 100644 --- a/tests/models/mobilevitv2/test_modeling_mobilevitv2.py +++ b/tests/models/mobilevitv2/test_modeling_mobilevitv2.py @@ -213,7 +213,7 @@ class MobileViTV2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC pass @unittest.skip(reason="MobileViTV2 does not support input and output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="MobileViTV2 does not output attentions") diff --git a/tests/models/musicgen/test_modeling_musicgen.py b/tests/models/musicgen/test_modeling_musicgen.py index e21ccb71f07..dd1a92cb75d 100644 --- a/tests/models/musicgen/test_modeling_musicgen.py +++ b/tests/models/musicgen/test_modeling_musicgen.py @@ -256,7 +256,7 @@ class MusicgenDecoderTest(ModelTesterMixin, GenerationTesterMixin, PipelineTeste model(**inputs)[0] # override since we have embeddings / LM heads over multiple codebooks - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: @@ -1401,7 +1401,7 @@ class MusicgenTest(ModelTesterMixin, GenerationTesterMixin, PipelineTesterMixin, ) # override since we have embeddings / LM heads over multiple codebooks - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/musicgen_melody/test_modeling_musicgen_melody.py b/tests/models/musicgen_melody/test_modeling_musicgen_melody.py index 7587b61abf3..125ca87ac74 100644 --- a/tests/models/musicgen_melody/test_modeling_musicgen_melody.py +++ b/tests/models/musicgen_melody/test_modeling_musicgen_melody.py @@ -259,7 +259,7 @@ class MusicgenMelodyDecoderTest(ModelTesterMixin, GenerationTesterMixin, unittes model(**inputs)[0] # override since we have embeddings / LM heads over multiple codebooks - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: @@ -1385,7 +1385,7 @@ class MusicgenMelodyTest(ModelTesterMixin, GenerationTesterMixin, PipelineTester ) # override since we have embeddings / LM heads over multiple codebooks - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/oneformer/test_modeling_oneformer.py b/tests/models/oneformer/test_modeling_oneformer.py index b5bb55cb48a..429920ac99e 100644 --- a/tests/models/oneformer/test_modeling_oneformer.py +++ b/tests/models/oneformer/test_modeling_oneformer.py @@ -293,7 +293,7 @@ class OneFormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCas pass @unittest.skip(reason="OneFormer does not have a get_input_embeddings method") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="OneFormer is not a generative model") diff --git a/tests/models/owlv2/test_modeling_owlv2.py b/tests/models/owlv2/test_modeling_owlv2.py index eb85a66a1b7..c25a162dc81 100644 --- a/tests/models/owlv2/test_modeling_owlv2.py +++ b/tests/models/owlv2/test_modeling_owlv2.py @@ -162,7 +162,7 @@ class Owlv2VisionModelTest(ModelTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: @@ -465,7 +465,7 @@ class Owlv2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip(reason="Owlv2Model does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass # override as the `logit_scale` parameter initilization is different for OWLV2 @@ -671,7 +671,7 @@ class Owlv2ForObjectDetectionTest(ModelTesterMixin, unittest.TestCase): pass @unittest.skip(reason="Owlv2Model does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="Test_initialization is tested in individual model tests") diff --git a/tests/models/owlvit/test_modeling_owlvit.py b/tests/models/owlvit/test_modeling_owlvit.py index 64fe046fb98..28b149bf09a 100644 --- a/tests/models/owlvit/test_modeling_owlvit.py +++ b/tests/models/owlvit/test_modeling_owlvit.py @@ -160,7 +160,7 @@ class OwlViTVisionModelTest(ModelTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: @@ -460,7 +460,7 @@ class OwlViTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip(reason="OwlViTModel does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass # override as the `logit_scale` parameter initilization is different for OWLVIT @@ -664,7 +664,7 @@ class OwlViTForObjectDetectionTest(ModelTesterMixin, unittest.TestCase): pass @unittest.skip(reason="OwlViTModel does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="Test_initialization is tested in individual model tests") diff --git a/tests/models/patchtsmixer/test_modeling_patchtsmixer.py b/tests/models/patchtsmixer/test_modeling_patchtsmixer.py index 64a9c1dbc55..13b0476e203 100644 --- a/tests/models/patchtsmixer/test_modeling_patchtsmixer.py +++ b/tests/models/patchtsmixer/test_modeling_patchtsmixer.py @@ -229,7 +229,6 @@ class PatchTSMixerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Test test_missing_keys = False test_torchscript = False test_inputs_embeds = False - test_model_common_attributes = False test_resize_embeddings = True test_resize_position_embeddings = False @@ -448,6 +447,10 @@ class PatchTSMixerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Test def test_retain_grad_hidden_states_attentions(self): super().test_retain_grad_hidden_states_attentions() + @unittest.skip(reason="Model does not have input embeddings") + def test_model_get_set_embeddings(self): + pass + def prepare_batch(repo_id="ibm/patchtsmixer-etth1-test-data", file="pretrain_batch.pt"): # TODO: Make repo public diff --git a/tests/models/patchtst/test_modeling_patchtst.py b/tests/models/patchtst/test_modeling_patchtst.py index 381800e8455..3d0774f3726 100644 --- a/tests/models/patchtst/test_modeling_patchtst.py +++ b/tests/models/patchtst/test_modeling_patchtst.py @@ -165,7 +165,6 @@ class PatchTSTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase test_missing_keys = True test_torchscript = False test_inputs_embeds = False - test_model_common_attributes = False test_resize_embeddings = True test_resize_position_embeddings = False @@ -297,6 +296,10 @@ class PatchTSTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase def test_retain_grad_hidden_states_attentions(self): super().test_retain_grad_hidden_states_attentions() + @unittest.skip(reason="Model does not have input embeddings") + def test_model_get_set_embeddings(self): + pass + def prepare_batch(repo_id="hf-internal-testing/etth1-hourly-batch", file="train-batch.pt"): file = hf_hub_download(repo_id=repo_id, filename=file, repo_type="dataset") diff --git a/tests/models/perceiver/test_modeling_perceiver.py b/tests/models/perceiver/test_modeling_perceiver.py index 379b4774cae..86a1f154f1c 100644 --- a/tests/models/perceiver/test_modeling_perceiver.py +++ b/tests/models/perceiver/test_modeling_perceiver.py @@ -377,7 +377,7 @@ class PerceiverModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCas ) self.model_tester.create_and_check_for_image_classification_conv(*config_and_inputs) - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): for model_class in self.all_model_classes: config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_model_class(model_class) model = model_class(config) diff --git a/tests/models/pix2struct/test_modeling_pix2struct.py b/tests/models/pix2struct/test_modeling_pix2struct.py index 980fd078ea3..f92512d4d5b 100644 --- a/tests/models/pix2struct/test_modeling_pix2struct.py +++ b/tests/models/pix2struct/test_modeling_pix2struct.py @@ -162,7 +162,7 @@ class Pix2StructVisionModelTest(ModelTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: @@ -458,7 +458,7 @@ class Pix2StructModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCa pass @unittest.skip(reason="Pix2StructModel does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_forward_signature(self): diff --git a/tests/models/poolformer/test_modeling_poolformer.py b/tests/models/poolformer/test_modeling_poolformer.py index 66216c6a7a4..fafae6ae250 100644 --- a/tests/models/poolformer/test_modeling_poolformer.py +++ b/tests/models/poolformer/test_modeling_poolformer.py @@ -149,7 +149,7 @@ class PoolFormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCa pass @unittest.skip("PoolFormer does not have get_input_embeddings method and get_output_embeddings methods") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_hidden_states_output(self): diff --git a/tests/models/pvt/test_modeling_pvt.py b/tests/models/pvt/test_modeling_pvt.py index feda0adeec8..de172258cae 100644 --- a/tests/models/pvt/test_modeling_pvt.py +++ b/tests/models/pvt/test_modeling_pvt.py @@ -183,7 +183,7 @@ class PvtModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip("Pvt does not have get_input_embeddings method and get_output_embeddings methods") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_initialization(self): diff --git a/tests/models/pvt_v2/test_modeling_pvt_v2.py b/tests/models/pvt_v2/test_modeling_pvt_v2.py index 9d8dfafa7cf..96d4997489c 100644 --- a/tests/models/pvt_v2/test_modeling_pvt_v2.py +++ b/tests/models/pvt_v2/test_modeling_pvt_v2.py @@ -219,7 +219,7 @@ class PvtV2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip("Pvt-V2 does not have get_input_embeddings method and get_output_embeddings methods") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="This architecture does not work with using reentrant.") diff --git a/tests/models/regnet/test_modeling_regnet.py b/tests/models/regnet/test_modeling_regnet.py index 78935c4e574..373566d88c7 100644 --- a/tests/models/regnet/test_modeling_regnet.py +++ b/tests/models/regnet/test_modeling_regnet.py @@ -155,7 +155,7 @@ class RegNetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip(reason="RegNet does not support input and output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_model(self): diff --git a/tests/models/resnet/test_modeling_resnet.py b/tests/models/resnet/test_modeling_resnet.py index 5595ebde69c..08fbbdadfa5 100644 --- a/tests/models/resnet/test_modeling_resnet.py +++ b/tests/models/resnet/test_modeling_resnet.py @@ -200,7 +200,7 @@ class ResNetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip(reason="ResNet does not support input and output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_model(self): diff --git a/tests/models/sam/test_modeling_sam.py b/tests/models/sam/test_modeling_sam.py index 1590d4f8066..65f653e287f 100644 --- a/tests/models/sam/test_modeling_sam.py +++ b/tests/models/sam/test_modeling_sam.py @@ -326,7 +326,7 @@ class SamModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/segformer/test_modeling_segformer.py b/tests/models/segformer/test_modeling_segformer.py index f0f125933b0..620675d39e2 100644 --- a/tests/models/segformer/test_modeling_segformer.py +++ b/tests/models/segformer/test_modeling_segformer.py @@ -205,7 +205,7 @@ class SegformerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCas pass @unittest.skip("SegFormer does not have get_input_embeddings method and get_output_embeddings methods") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_attention_outputs(self): diff --git a/tests/models/seggpt/test_modeling_seggpt.py b/tests/models/seggpt/test_modeling_seggpt.py index 46c370db773..50d141aaeff 100644 --- a/tests/models/seggpt/test_modeling_seggpt.py +++ b/tests/models/seggpt/test_modeling_seggpt.py @@ -187,7 +187,7 @@ class SegGptModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/sew/test_modeling_sew.py b/tests/models/sew/test_modeling_sew.py index 2394ed015d7..fd8ba9725e8 100644 --- a/tests/models/sew/test_modeling_sew.py +++ b/tests/models/sew/test_modeling_sew.py @@ -352,7 +352,7 @@ class SEWModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): # SEW has no inputs_embeds # and thus the `get_input_embeddings` fn # is not implemented - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip("No support for low_cpu_mem_usage=True.") diff --git a/tests/models/sew_d/test_modeling_sew_d.py b/tests/models/sew_d/test_modeling_sew_d.py index a9af4972263..7e907f40b48 100644 --- a/tests/models/sew_d/test_modeling_sew_d.py +++ b/tests/models/sew_d/test_modeling_sew_d.py @@ -374,7 +374,7 @@ class SEWDModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): # SEW has no inputs_embeds # and thus the `get_input_embeddings` fn # is not implemented - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_retain_grad_hidden_states_attentions(self): diff --git a/tests/models/siglip/test_modeling_siglip.py b/tests/models/siglip/test_modeling_siglip.py index afd7912e5f7..12ac11251dc 100644 --- a/tests/models/siglip/test_modeling_siglip.py +++ b/tests/models/siglip/test_modeling_siglip.py @@ -166,7 +166,7 @@ class SiglipVisionModelTest(ModelTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: @@ -469,8 +469,8 @@ class SiglipModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip(reason="SiglipModel does not have input/output embeddings") - # Copied from tests.models.clip.test_modeling_clip.CLIPModelTest.test_model_common_attributes - def test_model_common_attributes(self): + # Copied from tests.models.clip.test_modeling_clip.CLIPModelTest.test_model_get_set_embeddings + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="SiglipModel does not support training") @@ -627,7 +627,7 @@ class SiglipForImageClassificationModelTest(ModelTesterMixin, PipelineTesterMixi pass @unittest.skip(reason="SiglipForImageClassification does not support inputs_embeds") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="SiglipForImageClassification does not support gradient checkpointing yet") diff --git a/tests/models/speecht5/test_modeling_speecht5.py b/tests/models/speecht5/test_modeling_speecht5.py index f28cf60eb52..2bd28cdeb4f 100644 --- a/tests/models/speecht5/test_modeling_speecht5.py +++ b/tests/models/speecht5/test_modeling_speecht5.py @@ -217,7 +217,7 @@ class SpeechT5ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase pass # this model has no input embeddings - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_retain_grad_hidden_states_attentions(self): @@ -1654,7 +1654,7 @@ class SpeechT5ForSpeechToSpeechTest(ModelTesterMixin, unittest.TestCase): pass # this model has no input embeddings - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass # skipped because there is always dropout in SpeechT5SpeechDecoderPrenet @@ -1848,7 +1848,7 @@ class SpeechT5HifiGanTest(ModelTesterMixin, unittest.TestCase): pass # this model has no input embeddings - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass # skip as this model doesn't support all arguments tested diff --git a/tests/models/superpoint/test_modeling_superpoint.py b/tests/models/superpoint/test_modeling_superpoint.py index 6e10a8a21dd..78ba38f0fce 100644 --- a/tests/models/superpoint/test_modeling_superpoint.py +++ b/tests/models/superpoint/test_modeling_superpoint.py @@ -143,7 +143,7 @@ class SuperPointModelTest(ModelTesterMixin, unittest.TestCase): pass @unittest.skip(reason="SuperPointForKeypointDetection does not support input and output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="SuperPointForKeypointDetection does not use feedforward chunking") diff --git a/tests/models/swiftformer/test_modeling_swiftformer.py b/tests/models/swiftformer/test_modeling_swiftformer.py index ea90023b19f..3b8b3eb5ed6 100644 --- a/tests/models/swiftformer/test_modeling_swiftformer.py +++ b/tests/models/swiftformer/test_modeling_swiftformer.py @@ -166,7 +166,7 @@ class SwiftFormerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/swin/test_modeling_swin.py b/tests/models/swin/test_modeling_swin.py index 99917adafc9..078b548642a 100644 --- a/tests/models/swin/test_modeling_swin.py +++ b/tests/models/swin/test_modeling_swin.py @@ -289,7 +289,7 @@ class SwinModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): def test_feed_forward_chunking(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/swin2sr/test_modeling_swin2sr.py b/tests/models/swin2sr/test_modeling_swin2sr.py index 2c09be2760a..08c58494683 100644 --- a/tests/models/swin2sr/test_modeling_swin2sr.py +++ b/tests/models/swin2sr/test_modeling_swin2sr.py @@ -222,7 +222,7 @@ class Swin2SRModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase) def test_training_gradient_checkpointing_use_reentrant_false(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/swinv2/test_modeling_swinv2.py b/tests/models/swinv2/test_modeling_swinv2.py index c0ab1081f43..74586fb4a1d 100644 --- a/tests/models/swinv2/test_modeling_swinv2.py +++ b/tests/models/swinv2/test_modeling_swinv2.py @@ -256,7 +256,7 @@ class Swinv2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/table_transformer/test_modeling_table_transformer.py b/tests/models/table_transformer/test_modeling_table_transformer.py index f6cef9e8fe4..beb5119faa4 100644 --- a/tests/models/table_transformer/test_modeling_table_transformer.py +++ b/tests/models/table_transformer/test_modeling_table_transformer.py @@ -265,7 +265,7 @@ class TableTransformerModelTest(ModelTesterMixin, GenerationTesterMixin, Pipelin pass @unittest.skip(reason="Table Transformer does not have a get_input_embeddings method") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="Table Transformer is not a generative model") diff --git a/tests/models/time_series_transformer/test_modeling_time_series_transformer.py b/tests/models/time_series_transformer/test_modeling_time_series_transformer.py index a2694fd0b3f..074d5f1a81c 100644 --- a/tests/models/time_series_transformer/test_modeling_time_series_transformer.py +++ b/tests/models/time_series_transformer/test_modeling_time_series_transformer.py @@ -187,7 +187,6 @@ class TimeSeriesTransformerModelTest(ModelTesterMixin, PipelineTesterMixin, unit test_missing_keys = False test_torchscript = False test_inputs_embeds = False - test_model_common_attributes = False def setUp(self): self.model_tester = TimeSeriesTransformerModelTester(self) @@ -476,6 +475,10 @@ class TimeSeriesTransformerModelTest(ModelTesterMixin, PipelineTesterMixin, unit def test_retain_grad_hidden_states_attentions(self): super().test_retain_grad_hidden_states_attentions() + @unittest.skip(reason="Model does not have input embeddings") + def test_model_get_set_embeddings(self): + pass + def prepare_batch(filename="train-batch.pt"): file = hf_hub_download(repo_id="hf-internal-testing/tourism-monthly-batch", filename=filename, repo_type="dataset") diff --git a/tests/models/timesformer/test_modeling_timesformer.py b/tests/models/timesformer/test_modeling_timesformer.py index e3c6d7fad3e..060f49c2e94 100644 --- a/tests/models/timesformer/test_modeling_timesformer.py +++ b/tests/models/timesformer/test_modeling_timesformer.py @@ -192,7 +192,7 @@ class TimesformerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestC def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/timm_backbone/test_modeling_timm_backbone.py b/tests/models/timm_backbone/test_modeling_timm_backbone.py index 3926ae983b3..56ce94f7f6c 100644 --- a/tests/models/timm_backbone/test_modeling_timm_backbone.py +++ b/tests/models/timm_backbone/test_modeling_timm_backbone.py @@ -158,7 +158,7 @@ class TimmBackboneModelTest(ModelTesterMixin, BackboneTesterMixin, PipelineTeste pass @unittest.skip("TimmBackbone models doesn't have inputs_embeds") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip("TimmBackbone model cannot be created without specifying a backbone checkpoint") diff --git a/tests/models/tvp/test_modeling_tvp.py b/tests/models/tvp/test_modeling_tvp.py index b8f5fa48226..2912b877842 100644 --- a/tests/models/tvp/test_modeling_tvp.py +++ b/tests/models/tvp/test_modeling_tvp.py @@ -191,7 +191,7 @@ class TVPModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip(reason="TVPModel does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass # override as the `logit_scale` parameter initilization is different for TVP diff --git a/tests/models/unispeech/test_modeling_unispeech.py b/tests/models/unispeech/test_modeling_unispeech.py index 7735fe4ffa2..79532cef853 100644 --- a/tests/models/unispeech/test_modeling_unispeech.py +++ b/tests/models/unispeech/test_modeling_unispeech.py @@ -369,7 +369,7 @@ class UniSpeechRobustModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.T # UniSpeech has no inputs_embeds # and thus the `get_input_embeddings` fn # is not implemented - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_retain_grad_hidden_states_attentions(self): diff --git a/tests/models/unispeech_sat/test_modeling_unispeech_sat.py b/tests/models/unispeech_sat/test_modeling_unispeech_sat.py index a48ed368884..0b6438f86a0 100644 --- a/tests/models/unispeech_sat/test_modeling_unispeech_sat.py +++ b/tests/models/unispeech_sat/test_modeling_unispeech_sat.py @@ -419,7 +419,7 @@ class UniSpeechSatModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Test # UniSpeechSat has no inputs_embeds # and thus the `get_input_embeddings` fn # is not implemented - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_retain_grad_hidden_states_attentions(self): @@ -631,7 +631,7 @@ class UniSpeechSatRobustModelTest(ModelTesterMixin, unittest.TestCase): # UniSpeechSat has no inputs_embeds # and thus the `get_input_embeddings` fn # is not implemented - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_retain_grad_hidden_states_attentions(self): diff --git a/tests/models/univnet/test_modeling_univnet.py b/tests/models/univnet/test_modeling_univnet.py index 88a610cfbb0..1f579b9c91b 100644 --- a/tests/models/univnet/test_modeling_univnet.py +++ b/tests/models/univnet/test_modeling_univnet.py @@ -163,7 +163,7 @@ class UnivNetModelTest(ModelTesterMixin, unittest.TestCase): pass @unittest.skip(reason="UnivNetModel does not use input embeddings and thus has no get_input_embeddings method.") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="UnivNetModel does not support all arguments tested, such as output_hidden_states.") diff --git a/tests/models/upernet/test_modeling_upernet.py b/tests/models/upernet/test_modeling_upernet.py index 820e82acbf3..e536377c3f8 100644 --- a/tests/models/upernet/test_modeling_upernet.py +++ b/tests/models/upernet/test_modeling_upernet.py @@ -184,7 +184,7 @@ class UperNetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase) pass @unittest.skip(reason="UperNet does not support input and output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="UperNet does not have a base model") diff --git a/tests/models/videomae/test_modeling_videomae.py b/tests/models/videomae/test_modeling_videomae.py index cef2ac33ae1..dfcd296edbd 100644 --- a/tests/models/videomae/test_modeling_videomae.py +++ b/tests/models/videomae/test_modeling_videomae.py @@ -220,7 +220,7 @@ class VideoMAEModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/vit/test_modeling_vit.py b/tests/models/vit/test_modeling_vit.py index 961fab54baf..cace1d37703 100644 --- a/tests/models/vit/test_modeling_vit.py +++ b/tests/models/vit/test_modeling_vit.py @@ -226,7 +226,7 @@ class ViTModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/vit_mae/test_modeling_vit_mae.py b/tests/models/vit_mae/test_modeling_vit_mae.py index 506660f089f..6020edca81a 100644 --- a/tests/models/vit_mae/test_modeling_vit_mae.py +++ b/tests/models/vit_mae/test_modeling_vit_mae.py @@ -186,7 +186,7 @@ class ViTMAEModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/vit_msn/test_modeling_vit_msn.py b/tests/models/vit_msn/test_modeling_vit_msn.py index f911749c829..3d4262d4497 100644 --- a/tests/models/vit_msn/test_modeling_vit_msn.py +++ b/tests/models/vit_msn/test_modeling_vit_msn.py @@ -174,7 +174,7 @@ class ViTMSNModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/vitdet/test_modeling_vitdet.py b/tests/models/vitdet/test_modeling_vitdet.py index 49076afb4d5..a994f50ee32 100644 --- a/tests/models/vitdet/test_modeling_vitdet.py +++ b/tests/models/vitdet/test_modeling_vitdet.py @@ -204,7 +204,7 @@ class VitDetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/vitmatte/test_modeling_vitmatte.py b/tests/models/vitmatte/test_modeling_vitmatte.py index 07be1edeb63..b8ef1ab5f84 100644 --- a/tests/models/vitmatte/test_modeling_vitmatte.py +++ b/tests/models/vitmatte/test_modeling_vitmatte.py @@ -185,7 +185,7 @@ class VitMatteModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase pass @unittest.skip(reason="ViTMatte does not support input and output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_model(self): diff --git a/tests/models/vits/test_modeling_vits.py b/tests/models/vits/test_modeling_vits.py index 791071e0960..d43115b9c84 100644 --- a/tests/models/vits/test_modeling_vits.py +++ b/tests/models/vits/test_modeling_vits.py @@ -265,7 +265,7 @@ class VitsModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip("VITS has no input embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass # override since the model is not deterministic, so we need to set the seed for each forward pass diff --git a/tests/models/vivit/test_modeling_vivit.py b/tests/models/vivit/test_modeling_vivit.py index dd13d0306a1..19a179a6a3e 100644 --- a/tests/models/vivit/test_modeling_vivit.py +++ b/tests/models/vivit/test_modeling_vivit.py @@ -192,7 +192,7 @@ class VivitModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/wav2vec2/test_modeling_wav2vec2.py b/tests/models/wav2vec2/test_modeling_wav2vec2.py index eed419910d5..ad70a69811e 100644 --- a/tests/models/wav2vec2/test_modeling_wav2vec2.py +++ b/tests/models/wav2vec2/test_modeling_wav2vec2.py @@ -567,7 +567,7 @@ class Wav2Vec2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase # Wav2Vec2 has no inputs_embeds # and thus the `get_input_embeddings` fn # is not implemented - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @is_pt_flax_cross_test @@ -921,7 +921,7 @@ class Wav2Vec2RobustModelTest(ModelTesterMixin, unittest.TestCase): # Wav2Vec2 has no inputs_embeds # and thus the `get_input_embeddings` fn # is not implemented - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass def test_retain_grad_hidden_states_attentions(self): diff --git a/tests/models/wav2vec2_bert/test_modeling_wav2vec2_bert.py b/tests/models/wav2vec2_bert/test_modeling_wav2vec2_bert.py index 8fae3a4bad1..80237fea9d1 100644 --- a/tests/models/wav2vec2_bert/test_modeling_wav2vec2_bert.py +++ b/tests/models/wav2vec2_bert/test_modeling_wav2vec2_bert.py @@ -557,7 +557,7 @@ class Wav2Vec2BertModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.Test # Ignore copy @unittest.skip(reason="Wav2Vec2Bert has no inputs_embeds") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass # Ignore copy diff --git a/tests/models/wav2vec2_conformer/test_modeling_wav2vec2_conformer.py b/tests/models/wav2vec2_conformer/test_modeling_wav2vec2_conformer.py index 020f61c82f4..dd8a4570d32 100644 --- a/tests/models/wav2vec2_conformer/test_modeling_wav2vec2_conformer.py +++ b/tests/models/wav2vec2_conformer/test_modeling_wav2vec2_conformer.py @@ -528,7 +528,7 @@ class Wav2Vec2ConformerModelTest(ModelTesterMixin, PipelineTesterMixin, unittest # Wav2Vec2Conformer has no inputs_embeds # and thus the `get_input_embeddings` fn # is not implemented - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @is_pt_flax_cross_test diff --git a/tests/models/wavlm/test_modeling_wavlm.py b/tests/models/wavlm/test_modeling_wavlm.py index 2e8754d19f3..7305898eace 100644 --- a/tests/models/wavlm/test_modeling_wavlm.py +++ b/tests/models/wavlm/test_modeling_wavlm.py @@ -387,7 +387,7 @@ class WavLMModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): # WavLM has no inputs_embeds # and thus the `get_input_embeddings` fn # is not implemented - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass # WavLM uses PyTorch's multi-head-attention class diff --git a/tests/models/whisper/test_modeling_whisper.py b/tests/models/whisper/test_modeling_whisper.py index 18b1eb36ccf..a0c5afa4d6f 100644 --- a/tests/models/whisper/test_modeling_whisper.py +++ b/tests/models/whisper/test_modeling_whisper.py @@ -3153,7 +3153,7 @@ class WhisperEncoderModelTest(ModelTesterMixin, GenerationTesterMixin, unittest. self.assertTrue((outputs_embeds == outputs).all()) # Needs to override as the encoder input embedding is a Conv1d - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/models/x_clip/test_modeling_x_clip.py b/tests/models/x_clip/test_modeling_x_clip.py index 3f7628a945e..c678d304ffa 100644 --- a/tests/models/x_clip/test_modeling_x_clip.py +++ b/tests/models/x_clip/test_modeling_x_clip.py @@ -161,7 +161,7 @@ class XCLIPVisionModelTest(ModelTesterMixin, unittest.TestCase): def test_inputs_embeds(self): pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: @@ -561,7 +561,7 @@ class XCLIPModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): pass @unittest.skip(reason="XCLIPModel does not have input/output embeddings") - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): pass @unittest.skip(reason="XCLIPModel does not support feedforward chunking") diff --git a/tests/models/yolos/test_modeling_yolos.py b/tests/models/yolos/test_modeling_yolos.py index f8edfc7ff8c..e28ac437f10 100644 --- a/tests/models/yolos/test_modeling_yolos.py +++ b/tests/models/yolos/test_modeling_yolos.py @@ -210,7 +210,7 @@ class YolosModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase): # YOLOS does not use inputs_embeds pass - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, _ = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: diff --git a/tests/test_modeling_common.py b/tests/test_modeling_common.py index 30010cde911..f81bd5c8c38 100755 --- a/tests/test_modeling_common.py +++ b/tests/test_modeling_common.py @@ -1971,13 +1971,17 @@ class ModelTesterMixin: # Check that the model can still do a forward pass successfully (every parameter should be resized) model(**self._prepare_for_class(inputs_dict, model_class)) - def test_model_common_attributes(self): + def test_model_get_set_embeddings(self): config, inputs_dict = self.model_tester.prepare_config_and_inputs_for_common() for model_class in self.all_model_classes: model = model_class(config) self.assertIsInstance(model.get_input_embeddings(), (nn.Embedding, AdaptiveEmbedding)) - model.set_input_embeddings(nn.Embedding(10, 10)) + + new_input_embedding_layer = nn.Embedding(10, 10) + model.set_input_embeddings(new_input_embedding_layer) + self.assertEqual(model.get_input_embeddings(), new_input_embedding_layer) + x = model.get_output_embeddings() self.assertTrue(x is None or isinstance(x, nn.Linear))