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 3f2dae258b21..40e43f25e893 100644 --- a/conftest.py +++ b/conftest.py @@ -53,7 +53,7 @@ "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 f2d1655f25a0..fd71b2c3df36 100644 --- a/tests/models/align/test_modeling_align.py +++ b/tests/models/align/test_modeling_align.py @@ -171,7 +171,7 @@ def test_inputs_embeds_matches_input_ids(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 c7c735b19f8e..4f258e4ddb23 100755 --- a/tests/models/altclip/test_modeling_altclip.py +++ b/tests/models/altclip/test_modeling_altclip.py @@ -153,7 +153,7 @@ def test_config(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 9ab07b55088f..0bbefda7ba50 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 @@ def test_config(self): 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 fb00c403f677..f0cd5dad37b1 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 @@ def test_attention_outputs(self): 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 67c18288a8a2..47e0beaeae80 100644 --- a/tests/models/bark/test_modeling_bark.py +++ b/tests/models/bark/test_modeling_bark.py @@ -809,7 +809,7 @@ def test_forward_signature(self): 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 0fd17efaf67c..84ca3cdd621a 100644 --- a/tests/models/beit/test_modeling_beit.py +++ b/tests/models/beit/test_modeling_beit.py @@ -270,7 +270,7 @@ def test_multi_gpu_data_parallel_forward(self): 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 ec666ec97326..baf7afa85684 100644 --- a/tests/models/bit/test_modeling_bit.py +++ b/tests/models/bit/test_modeling_bit.py @@ -196,7 +196,7 @@ def test_inputs_embeds(self): 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 2ea4f09214d9..db71336e3466 100644 --- a/tests/models/blip/test_modeling_blip.py +++ b/tests/models/blip/test_modeling_blip.py @@ -168,7 +168,7 @@ def test_config(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 @@ def test_inputs_embeds(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 f32ffea850b8..9e295325b3fd 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 @@ def test_config(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 b8de60ac5c69..44e6a404f623 100644 --- a/tests/models/bridgetower/test_modeling_bridgetower.py +++ b/tests/models/bridgetower/test_modeling_bridgetower.py @@ -499,7 +499,7 @@ def test_initialization(self): ) @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 2d2dfef40e13..3e7b27638c24 100644 --- a/tests/models/canine/test_modeling_canine.py +++ b/tests/models/canine/test_modeling_canine.py @@ -506,7 +506,7 @@ def test_inputs_embeds_matches_input_ids(self): 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 0b8220c8ed59..17d8ddcb1c43 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 @@ def test_config(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 835a06b0ce62..1255a31b819a 100644 --- a/tests/models/clap/test_modeling_clap.py +++ b/tests/models/clap/test_modeling_clap.py @@ -177,7 +177,7 @@ def test_config(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 fa33176363ef..5221274ffae9 100644 --- a/tests/models/clip/test_modeling_clip.py +++ b/tests/models/clip/test_modeling_clip.py @@ -191,7 +191,7 @@ def test_config(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 @@ def test_inputs_embeds(self): 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 9e819d3b263e..e9bfd2201e88 100644 --- a/tests/models/clipseg/test_modeling_clipseg.py +++ b/tests/models/clipseg/test_modeling_clipseg.py @@ -169,7 +169,7 @@ def test_config(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 1370c9acc871..0cf89a745233 100644 --- a/tests/models/clvp/test_modeling_clvp.py +++ b/tests/models/clvp/test_modeling_clvp.py @@ -489,7 +489,7 @@ def test_inputs_embeds(self): 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 9efde402b076..18f85a71e071 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 @@ def test_inputs_embeds_matches_input_ids(self): 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 b618608f0e9b..99145eee6aa3 100644 --- a/tests/models/convnext/test_modeling_convnext.py +++ b/tests/models/convnext/test_modeling_convnext.py @@ -202,7 +202,7 @@ def test_inputs_embeds(self): 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 3201de6f9364..f3ca05f80b81 100644 --- a/tests/models/convnextv2/test_modeling_convnextv2.py +++ b/tests/models/convnextv2/test_modeling_convnextv2.py @@ -210,7 +210,7 @@ def test_inputs_embeds(self): 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 9facafcd778d..588599e409b5 100644 --- a/tests/models/cvt/test_modeling_cvt.py +++ b/tests/models/cvt/test_modeling_cvt.py @@ -185,7 +185,7 @@ def test_inputs_embeds(self): 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 0376edad2dcf..d2e0e2853f05 100644 --- a/tests/models/data2vec/test_modeling_data2vec_audio.py +++ b/tests/models/data2vec/test_modeling_data2vec_audio.py @@ -442,7 +442,7 @@ def test_resize_tokens_embeddings(self): # 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 fabf543c021a..8f8a1fad447e 100644 --- a/tests/models/data2vec/test_modeling_data2vec_vision.py +++ b/tests/models/data2vec/test_modeling_data2vec_vision.py @@ -207,7 +207,7 @@ def test_inputs_embeds(self): 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 5d69bbd0b239..27d1598167e6 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 @@ def test_forward_signature(self): 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 b1fc9b23b3c2..5d7b027394d5 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 @@ def test_inputs_embeds_matches_input_ids(self): 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 d1357d129702..daf13d207b0a 100644 --- a/tests/models/deit/test_modeling_deit.py +++ b/tests/models/deit/test_modeling_deit.py @@ -241,7 +241,7 @@ def test_config(self): 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 7a08ecb85e75..eb51f1ef342d 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 @@ def test_training_gradient_checkpointing(self): 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 0aea506b5fb8..be75423827a3 100644 --- a/tests/models/detr/test_modeling_detr.py +++ b/tests/models/detr/test_modeling_detr.py @@ -251,7 +251,7 @@ def test_inputs_embeds_matches_input_ids(self): 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 2fe9de14b9e7..ebfd49af937b 100644 --- a/tests/models/dinat/test_modeling_dinat.py +++ b/tests/models/dinat/test_modeling_dinat.py @@ -253,7 +253,7 @@ def test_inputs_embeds(self): 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 5bf2d51b2da7..88be7061cf45 100644 --- a/tests/models/dinov2/test_modeling_dinov2.py +++ b/tests/models/dinov2/test_modeling_dinov2.py @@ -258,7 +258,7 @@ def test_training_gradient_checkpointing_use_reentrant(self): 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 8b86dffab156..2173a90ae996 100644 --- a/tests/models/donut/test_modeling_donut_swin.py +++ b/tests/models/donut/test_modeling_donut_swin.py @@ -175,7 +175,7 @@ def test_inputs_embeds(self): # 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 db35483d962e..5232b4cf462d 100644 --- a/tests/models/dpt/test_modeling_dpt.py +++ b/tests/models/dpt/test_modeling_dpt.py @@ -183,7 +183,7 @@ def test_config(self): 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 2b37b816f4b7..35283eebf5ed 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 @@ def test_initialization(self): ) @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 2caa8d71aecf..ab117c14416f 100644 --- a/tests/models/dpt/test_modeling_dpt_hybrid.py +++ b/tests/models/dpt/test_modeling_dpt_hybrid.py @@ -198,7 +198,7 @@ def test_config(self): 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 eaf0f4ec8796..0db10706ebc2 100644 --- a/tests/models/efficientnet/test_modeling_efficientnet.py +++ b/tests/models/efficientnet/test_modeling_efficientnet.py @@ -162,7 +162,7 @@ def test_inputs_embeds(self): 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 c2974943e0a8..be3d7161c64e 100644 --- a/tests/models/encodec/test_modeling_encodec.py +++ b/tests/models/encodec/test_modeling_encodec.py @@ -183,7 +183,7 @@ def test_inputs_embeds(self): 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 cf57ee079a82..5191105bc2a1 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 @@ def test_inputs_embeds(self): 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 @@ def test_inputs_embeds(self): 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 1287a297a428..7e067115e7b6 100644 --- a/tests/models/flava/test_modeling_flava.py +++ b/tests/models/flava/test_modeling_flava.py @@ -180,7 +180,7 @@ def test_inputs_embeds(self): # 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 @@ def test_forward_signature(self): 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 @@ def test_forward_signature(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 2cd29fc2c318..230a5412fb51 100644 --- a/tests/models/focalnet/test_modeling_focalnet.py +++ b/tests/models/focalnet/test_modeling_focalnet.py @@ -288,7 +288,7 @@ def test_inputs_embeds(self): 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 1b6fddbc072d..c3ad05e300f7 100644 --- a/tests/models/fsmt/test_modeling_fsmt.py +++ b/tests/models/fsmt/test_modeling_fsmt.py @@ -193,8 +193,8 @@ def setUp(self): 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 0ef74d818431..ee2cf4927a56 100644 --- a/tests/models/git/test_modeling_git.py +++ b/tests/models/git/test_modeling_git.py @@ -142,7 +142,7 @@ def test_config(self): 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 2e1486039e07..151162fb1bb9 100644 --- a/tests/models/glpn/test_modeling_glpn.py +++ b/tests/models/glpn/test_modeling_glpn.py @@ -173,7 +173,7 @@ def test_inputs_embeds(self): 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 fe67deb9383c..4ced752c0ef4 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 @@ def test_inputs_embeds(self): 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 15e7ad29fcdf..74c07b775bc9 100644 --- a/tests/models/groupvit/test_modeling_groupvit.py +++ b/tests/models/groupvit/test_modeling_groupvit.py @@ -174,7 +174,7 @@ def test_pt_tf_model_equivalence(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 3e54e7d2db77..7bf19757fa39 100644 --- a/tests/models/hubert/test_modeling_hubert.py +++ b/tests/models/hubert/test_modeling_hubert.py @@ -366,7 +366,7 @@ def test_resize_tokens_embeddings(self): # 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 @@ def test_resize_tokens_embeddings(self): # 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 feb1c026457e..342d81754553 100644 --- a/tests/models/ibert/test_modeling_ibert.py +++ b/tests/models/ibert/test_modeling_ibert.py @@ -334,7 +334,7 @@ def test_create_position_ids_from_inputs_embeds(self): 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 d81711a8ec09..5eab89a3adb3 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 @@ def test_attention_outputs(self): 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 50252629314a..1aaa8e1a8b68 100644 --- a/tests/models/instructblip/test_modeling_instructblip.py +++ b/tests/models/instructblip/test_modeling_instructblip.py @@ -165,7 +165,7 @@ def test_config(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 6303e0365fa5..69ac6a6a8fb0 100644 --- a/tests/models/levit/test_modeling_levit.py +++ b/tests/models/levit/test_modeling_levit.py @@ -209,7 +209,7 @@ def test_inputs_embeds(self): 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 1065607e0be8..64e2de13857c 100644 --- a/tests/models/mask2former/test_modeling_mask2former.py +++ b/tests/models/mask2former/test_modeling_mask2former.py @@ -225,7 +225,7 @@ def test_inputs_embeds(self): 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 4c9c69ed5ff7..025261841b30 100644 --- a/tests/models/maskformer/test_modeling_maskformer.py +++ b/tests/models/maskformer/test_modeling_maskformer.py @@ -251,7 +251,7 @@ def test_inputs_embeds(self): 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 01e9ed0e6756..c7c8c1b212ff 100644 --- a/tests/models/maskformer/test_modeling_maskformer_swin.py +++ b/tests/models/maskformer/test_modeling_maskformer_swin.py @@ -224,7 +224,7 @@ def test_inputs_embeds(self): 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 ec1ac5a24a4d..559a9e596840 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 @@ def test_model(self): 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 54fb057b3729..a04cfba45f64 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 @@ def test_inputs_embeds(self): 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 eb3105e427d7..7df6cbd1196b 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 @@ def test_inputs_embeds(self): 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 381763d4497b..9eb5878500d5 100644 --- a/tests/models/mobilevit/test_modeling_mobilevit.py +++ b/tests/models/mobilevit/test_modeling_mobilevit.py @@ -211,7 +211,7 @@ def test_inputs_embeds(self): 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 340bd22fbbc7..e2b565e4b9ce 100644 --- a/tests/models/mobilevitv2/test_modeling_mobilevitv2.py +++ b/tests/models/mobilevitv2/test_modeling_mobilevitv2.py @@ -213,7 +213,7 @@ def test_inputs_embeds(self): 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 e21ccb71f073..dd1a92cb75de 100644 --- a/tests/models/musicgen/test_modeling_musicgen.py +++ b/tests/models/musicgen/test_modeling_musicgen.py @@ -256,7 +256,7 @@ def test_inputs_embeds(self): 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 @@ def test_initialization(self): ) # 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 7587b61abf38..125ca87ac749 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 @@ def test_inputs_embeds(self): 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 @@ def test_initialization(self): ) # 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 b5bb55cb48a9..429920ac99e6 100644 --- a/tests/models/oneformer/test_modeling_oneformer.py +++ b/tests/models/oneformer/test_modeling_oneformer.py @@ -293,7 +293,7 @@ def test_inputs_embeds(self): 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 eb85a66a1b7d..c25a162dc814 100644 --- a/tests/models/owlv2/test_modeling_owlv2.py +++ b/tests/models/owlv2/test_modeling_owlv2.py @@ -162,7 +162,7 @@ def test_config(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 64fe046fb984..28b149bf09af 100644 --- a/tests/models/owlvit/test_modeling_owlvit.py +++ b/tests/models/owlvit/test_modeling_owlvit.py @@ -160,7 +160,7 @@ def test_config(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 64a9c1dbc550..13b0476e203a 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 @@ def test_forward_signature(self): 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 381800e84558..3d0774f37268 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 @@ def test_forward_signature(self): 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 379b4774caef..86a1f154f1c0 100644 --- a/tests/models/perceiver/test_modeling_perceiver.py +++ b/tests/models/perceiver/test_modeling_perceiver.py @@ -377,7 +377,7 @@ def test_for_image_classification_conv(self): ) 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 980fd078ea39..f92512d4d5b5 100644 --- a/tests/models/pix2struct/test_modeling_pix2struct.py +++ b/tests/models/pix2struct/test_modeling_pix2struct.py @@ -162,7 +162,7 @@ def test_config(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 66216c6a7a4e..fafae6ae250c 100644 --- a/tests/models/poolformer/test_modeling_poolformer.py +++ b/tests/models/poolformer/test_modeling_poolformer.py @@ -149,7 +149,7 @@ def test_inputs_embeds(self): 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 feda0adeec86..de172258caea 100644 --- a/tests/models/pvt/test_modeling_pvt.py +++ b/tests/models/pvt/test_modeling_pvt.py @@ -183,7 +183,7 @@ def test_inputs_embeds(self): 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 9d8dfafa7cff..96d4997489cd 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 @@ def test_inputs_embeds(self): 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 78935c4e5749..373566d88c76 100644 --- a/tests/models/regnet/test_modeling_regnet.py +++ b/tests/models/regnet/test_modeling_regnet.py @@ -155,7 +155,7 @@ def test_inputs_embeds(self): 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 5595ebde69c8..08fbbdadfa51 100644 --- a/tests/models/resnet/test_modeling_resnet.py +++ b/tests/models/resnet/test_modeling_resnet.py @@ -200,7 +200,7 @@ def test_inputs_embeds(self): 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 1590d4f80669..65f653e287fd 100644 --- a/tests/models/sam/test_modeling_sam.py +++ b/tests/models/sam/test_modeling_sam.py @@ -326,7 +326,7 @@ def test_config(self): 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 f0f125933b03..620675d39e2f 100644 --- a/tests/models/segformer/test_modeling_segformer.py +++ b/tests/models/segformer/test_modeling_segformer.py @@ -205,7 +205,7 @@ def test_inputs_embeds(self): 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 46c370db7739..50d141aaeff0 100644 --- a/tests/models/seggpt/test_modeling_seggpt.py +++ b/tests/models/seggpt/test_modeling_seggpt.py @@ -187,7 +187,7 @@ def test_config(self): 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 2394ed015d76..fd8ba9725e82 100644 --- a/tests/models/sew/test_modeling_sew.py +++ b/tests/models/sew/test_modeling_sew.py @@ -352,7 +352,7 @@ def test_resize_tokens_embeddings(self): # 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 a9af49722630..7e907f40b48e 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 @@ def test_resize_tokens_embeddings(self): # 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 afd7912e5f7d..12ac11251dc4 100644 --- a/tests/models/siglip/test_modeling_siglip.py +++ b/tests/models/siglip/test_modeling_siglip.py @@ -166,7 +166,7 @@ def test_config(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 @@ def test_inputs_embeds(self): 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 f28cf60eb522..2bd28cdeb4f0 100644 --- a/tests/models/speecht5/test_modeling_speecht5.py +++ b/tests/models/speecht5/test_modeling_speecht5.py @@ -217,7 +217,7 @@ def test_inputs_embeds(self): 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 @@ def test_inputs_embeds(self): 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 @@ def test_inputs_embeds(self): 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 6e10a8a21dd0..78ba38f0fced 100644 --- a/tests/models/superpoint/test_modeling_superpoint.py +++ b/tests/models/superpoint/test_modeling_superpoint.py @@ -143,7 +143,7 @@ def test_inputs_embeds(self): 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 ea90023b19fa..3b8b3eb5ed65 100644 --- a/tests/models/swiftformer/test_modeling_swiftformer.py +++ b/tests/models/swiftformer/test_modeling_swiftformer.py @@ -166,7 +166,7 @@ def test_config(self): 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 99917adafc9f..078b548642a6 100644 --- a/tests/models/swin/test_modeling_swin.py +++ b/tests/models/swin/test_modeling_swin.py @@ -289,7 +289,7 @@ def test_inputs_embeds(self): 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 2c09be2760a6..08c584946834 100644 --- a/tests/models/swin2sr/test_modeling_swin2sr.py +++ b/tests/models/swin2sr/test_modeling_swin2sr.py @@ -222,7 +222,7 @@ def test_training_gradient_checkpointing_use_reentrant(self): 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 c0ab1081f43c..74586fb4a1d4 100644 --- a/tests/models/swinv2/test_modeling_swinv2.py +++ b/tests/models/swinv2/test_modeling_swinv2.py @@ -256,7 +256,7 @@ def test_multi_gpu_data_parallel_forward(self): 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 f6cef9e8fe40..beb5119faa4c 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 @@ def test_inputs_embeds_matches_input_ids(self): 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 a2694fd0b3fa..074d5f1a81cf 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 @@ def test_create_network_inputs(self, prediction_length, context_length, lags_seq 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 e3c6d7fad3ea..060f49c2e947 100644 --- a/tests/models/timesformer/test_modeling_timesformer.py +++ b/tests/models/timesformer/test_modeling_timesformer.py @@ -192,7 +192,7 @@ def test_config(self): 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 3926ae983b35..56ce94f7f6c0 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 @@ def test_inputs_embeds(self): 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 b8f5fa48226c..2912b8778424 100644 --- a/tests/models/tvp/test_modeling_tvp.py +++ b/tests/models/tvp/test_modeling_tvp.py @@ -191,7 +191,7 @@ def test_inputs_embeds(self): 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 7735fe4ffa28..79532cef853a 100644 --- a/tests/models/unispeech/test_modeling_unispeech.py +++ b/tests/models/unispeech/test_modeling_unispeech.py @@ -369,7 +369,7 @@ def test_resize_tokens_embeddings(self): # 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 a48ed3688847..0b6438f86a00 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 @@ def test_resize_tokens_embeddings(self): # 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 @@ def test_resize_tokens_embeddings(self): # 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 88a610cfbb00..1f579b9c91bf 100644 --- a/tests/models/univnet/test_modeling_univnet.py +++ b/tests/models/univnet/test_modeling_univnet.py @@ -163,7 +163,7 @@ def test_inputs_embeds(self): 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 820e82acbf34..e536377c3f8f 100644 --- a/tests/models/upernet/test_modeling_upernet.py +++ b/tests/models/upernet/test_modeling_upernet.py @@ -184,7 +184,7 @@ def test_inputs_embeds(self): 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 cef2ac33ae15..dfcd296edbdf 100644 --- a/tests/models/videomae/test_modeling_videomae.py +++ b/tests/models/videomae/test_modeling_videomae.py @@ -220,7 +220,7 @@ def test_config(self): 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 961fab54baf8..cace1d377034 100644 --- a/tests/models/vit/test_modeling_vit.py +++ b/tests/models/vit/test_modeling_vit.py @@ -226,7 +226,7 @@ def test_config(self): 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 506660f089fb..6020edca81a7 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 @@ def test_config(self): 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 f911749c829b..3d4262d44970 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 @@ def test_config(self): 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 49076afb4d53..a994f50ee32e 100644 --- a/tests/models/vitdet/test_modeling_vitdet.py +++ b/tests/models/vitdet/test_modeling_vitdet.py @@ -204,7 +204,7 @@ def test_config(self): 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 07be1edeb632..b8ef1ab5f84f 100644 --- a/tests/models/vitmatte/test_modeling_vitmatte.py +++ b/tests/models/vitmatte/test_modeling_vitmatte.py @@ -185,7 +185,7 @@ def test_training_gradient_checkpointing_use_reentrant_false(self): 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 791071e0960c..d43115b9c840 100644 --- a/tests/models/vits/test_modeling_vits.py +++ b/tests/models/vits/test_modeling_vits.py @@ -265,7 +265,7 @@ def test_inputs_embeds(self): 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 dd13d0306a17..19a179a6a3e0 100644 --- a/tests/models/vivit/test_modeling_vivit.py +++ b/tests/models/vivit/test_modeling_vivit.py @@ -192,7 +192,7 @@ def test_config(self): 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 eed419910d58..ad70a69811e9 100644 --- a/tests/models/wav2vec2/test_modeling_wav2vec2.py +++ b/tests/models/wav2vec2/test_modeling_wav2vec2.py @@ -567,7 +567,7 @@ def test_resize_tokens_embeddings(self): # 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 @@ def test_resize_tokens_embeddings(self): # 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 8fae3a4bad1e..80237fea9d1e 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 @@ def test_resize_tokens_embeddings(self): # 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 020f61c82f4c..dd8a4570d326 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 @@ def test_resize_tokens_embeddings(self): # 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 2e8754d19f3d..7305898eacec 100644 --- a/tests/models/wavlm/test_modeling_wavlm.py +++ b/tests/models/wavlm/test_modeling_wavlm.py @@ -387,7 +387,7 @@ def test_resize_tokens_embeddings(self): # 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 18b1eb36ccf4..a0c5afa4d6fb 100644 --- a/tests/models/whisper/test_modeling_whisper.py +++ b/tests/models/whisper/test_modeling_whisper.py @@ -3153,7 +3153,7 @@ def test_encoder_outputs(self): 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 3f7628a945e3..c678d304ffab 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 @@ def test_config(self): 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 @@ def test_retain_grad_hidden_states_attentions(self): 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 f8edfc7ff8ce..e28ac437f10f 100644 --- a/tests/models/yolos/test_modeling_yolos.py +++ b/tests/models/yolos/test_modeling_yolos.py @@ -210,7 +210,7 @@ def test_inputs_embeds(self): # 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 30010cde9116..f81bd5c8c38c 100755 --- a/tests/test_modeling_common.py +++ b/tests/test_modeling_common.py @@ -1971,13 +1971,17 @@ def test_resize_embeddings_untied(self): # 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))