diff --git a/conftest.py b/conftest.py index 3f2dae258b211c..40e43f25e8933d 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 f2d1655f25a0bf..fd71b2c3df3648 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 c7c735b19f8e14..4f258e4ddb23c7 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 9ab07b55088fca..0bbefda7ba50e8 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 fb00c403f67782..f0cd5dad37b1b5 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 67c18288a8a296..47e0beaeae80d3 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 0fd17efaf67c7a..84ca3cdd621a2d 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 ec666ec97326de..baf7afa8568475 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 2ea4f09214d97b..db71336e346612 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 f32ffea850b8b6..9e295325b3fd66 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 b8de60ac5c6952..44e6a404f6235d 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 2d2dfef40e134d..3e7b27638c24cb 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 0b8220c8ed5913..17d8ddcb1c436a 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 835a06b0ce6281..1255a31b819a99 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 fa33176363efaa..5221274ffae9b2 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 9e819d3b263eb6..e9bfd2201e88ab 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 1370c9acc8715f..0cf89a74523364 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 9efde402b0760f..18f85a71e07135 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 b618608f0e9b67..99145eee6aa38a 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 3201de6f936495..f3ca05f80b814a 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 9facafcd778de8..588599e409b5ac 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 0376edad2dcf3d..d2e0e2853f057d 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 fabf543c021a43..8f8a1fad447ed2 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 5d69bbd0b23963..27d1598167e695 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 b1fc9b23b3c20c..5d7b027394d5bb 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 d1357d12970296..daf13d207b0a8a 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 7a08ecb85e7552..eb51f1ef342d53 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 0aea506b5fb8c2..be75423827a31c 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 2fe9de14b9e79e..ebfd49af937b3c 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 5bf2d51b2da7d1..88be7061cf45bb 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 8b86dffab1565a..2173a90ae99654 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 db35483d962e3c..5232b4cf462d8c 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 2b37b816f4b728..35283eebf5edca 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 2caa8d71aecfbc..ab117c14416f2d 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 eaf0f4ec8796b0..0db10706ebc2bb 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 c2974943e0a81b..be3d7161c64ed3 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 cf57ee079a82e2..5191105bc2a1f2 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 1287a297a42836..7e067115e7b665 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 2cd29fc2c318ef..230a5412fb5169 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 1b6fddbc072d89..c3ad05e300f7ac 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 0ef74d818431e6..ee2cf4927a56bc 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 2e1486039e0774..151162fb1bb9cf 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 fe67deb9383cf8..4ced752c0ef4ad 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 15e7ad29fcdfe8..74c07b775bc932 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 3e54e7d2db7726..7bf19757fa39d6 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 feb1c026457ee3..342d81754553a3 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 d81711a8ec09f1..5eab89a3adb32d 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 50252629314a4a..1aaa8e1a8b6819 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 6303e0365fa5a4..69ac6a6a8fb061 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 1065607e0be8e4..64e2de13857c8c 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 4c9c69ed5ff75f..025261841b300f 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 01e9ed0e675649..c7c8c1b212ff97 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 ec1ac5a24a4d6c..559a9e596840c6 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 54fb057b372966..a04cfba45f645a 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 eb3105e427d7aa..7df6cbd1196bc0 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 381763d4497bbc..9eb5878500d59e 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 340bd22fbbc738..e2b565e4b9ce3e 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 e21ccb71f0730c..dd1a92cb75dea6 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 7587b61abf3875..125ca87ac749bb 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 b5bb55cb48a9de..429920ac99e6ca 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 eb85a66a1b7d06..c25a162dc814b6 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 64fe046fb984f6..28b149bf09af71 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 64a9c1dbc5508e..13b0476e203a09 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 381800e84558b5..3d0774f3726800 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 379b4774caefb5..86a1f154f1c08e 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 980fd078ea3937..f92512d4d5b502 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 66216c6a7a4ecf..fafae6ae250c70 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 feda0adeec8664..de172258caea59 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 9d8dfafa7cffc0..96d4997489cd9b 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 78935c4e5749c3..373566d88c76ca 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 5595ebde69c842..08fbbdadfa515f 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 1590d4f806696f..65f653e287fd9a 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 f0f125933b0392..620675d39e2f76 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 46c370db77395e..50d141aaeff0ec 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 2394ed015d7668..fd8ba9725e82a7 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 a9af497226305c..7e907f40b48e86 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 afd7912e5f7d66..12ac11251dc4c9 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 f28cf60eb522b0..2bd28cdeb4f0db 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 6e10a8a21dd0d1..78ba38f0fced7b 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 ea90023b19fac7..3b8b3eb5ed65f4 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 99917adafc9faa..078b548642a693 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 2c09be2760a637..08c58494683475 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 c0ab1081f43c5a..74586fb4a1d453 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 f6cef9e8fe4033..beb5119faa4c02 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 a2694fd0b3fa0c..074d5f1a81cf10 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 e3c6d7fad3ea1c..060f49c2e947aa 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 3926ae983b35c7..56ce94f7f6c026 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 b8f5fa48226c03..2912b877842447 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 7735fe4ffa287d..79532cef853aa3 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 a48ed36888474e..0b6438f86a006c 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 88a610cfbb00e6..1f579b9c91bfbe 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 820e82acbf342d..e536377c3f8f66 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 cef2ac33ae1555..dfcd296edbdf52 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 961fab54baf890..cace1d377034fb 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 506660f089fbb8..6020edca81a7ec 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 f911749c829b26..3d4262d44970fe 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 49076afb4d539b..a994f50ee32ed1 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 07be1edeb6325a..b8ef1ab5f84f06 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 791071e0960cfc..d43115b9c8408b 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 dd13d0306a1733..19a179a6a3e030 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 eed419910d5804..ad70a69811e9bc 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 8fae3a4bad1ee9..80237fea9d1e43 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 020f61c82f4c6e..dd8a4570d326eb 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 2e8754d19f3dda..7305898eacec54 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 18b1eb36ccf442..a0c5afa4d6fb2f 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 3f7628a945e3e5..c678d304ffab23 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 f8edfc7ff8cec7..e28ac437f10fb9 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 30010cde9116dc..f81bd5c8c38cf4 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))