mirror of
https://github.com/huggingface/transformers.git
synced 2025-10-20 17:13:56 +08:00
Remove bad test skips (#41109)
* remove bad skips * remove more * fix inits
This commit is contained in:
@ -459,6 +459,12 @@ class DFinePreTrainedModel(PreTrainedModel):
|
||||
nn.init.constant_(layer.layers[-1].weight, 0)
|
||||
nn.init.constant_(layer.layers[-1].bias, 0)
|
||||
|
||||
if hasattr(module, "reg_scale"):
|
||||
module.reg_scale.fill_(self.config.reg_scale)
|
||||
|
||||
if hasattr(module, "up"):
|
||||
module.up.fill_(self.config.up)
|
||||
|
||||
if isinstance(module, DFineMultiscaleDeformableAttention):
|
||||
nn.init.constant_(module.sampling_offsets.weight.data, 0.0)
|
||||
default_dtype = torch.get_default_dtype()
|
||||
@ -496,6 +502,10 @@ class DFinePreTrainedModel(PreTrainedModel):
|
||||
init.constant_(module.reg_conf.layers[-1].bias, 0)
|
||||
init.constant_(module.reg_conf.layers[-1].weight, 0)
|
||||
|
||||
if isinstance(module, nn.LayerNorm):
|
||||
module.weight.data.fill_(1.0)
|
||||
module.bias.data.zero_()
|
||||
|
||||
if hasattr(module, "weight_embedding") and self.config.learn_initial_query:
|
||||
nn.init.xavier_uniform_(module.weight_embedding.weight)
|
||||
if hasattr(module, "denoising_class_embed") and self.config.num_denoising > 0:
|
||||
|
@ -635,6 +635,12 @@ class DFinePreTrainedModel(RTDetrPreTrainedModel):
|
||||
nn.init.constant_(layer.layers[-1].weight, 0)
|
||||
nn.init.constant_(layer.layers[-1].bias, 0)
|
||||
|
||||
if hasattr(module, "reg_scale"):
|
||||
module.reg_scale.fill_(self.config.reg_scale)
|
||||
|
||||
if hasattr(module, "up"):
|
||||
module.up.fill_(self.config.up)
|
||||
|
||||
if isinstance(module, DFineMultiscaleDeformableAttention):
|
||||
nn.init.constant_(module.sampling_offsets.weight.data, 0.0)
|
||||
default_dtype = torch.get_default_dtype()
|
||||
@ -672,6 +678,10 @@ class DFinePreTrainedModel(RTDetrPreTrainedModel):
|
||||
init.constant_(module.reg_conf.layers[-1].bias, 0)
|
||||
init.constant_(module.reg_conf.layers[-1].weight, 0)
|
||||
|
||||
if isinstance(module, nn.LayerNorm):
|
||||
module.weight.data.fill_(1.0)
|
||||
module.bias.data.zero_()
|
||||
|
||||
if hasattr(module, "weight_embedding") and self.config.learn_initial_query:
|
||||
nn.init.xavier_uniform_(module.weight_embedding.weight)
|
||||
if hasattr(module, "denoising_class_embed") and self.config.num_denoising > 0:
|
||||
|
@ -332,7 +332,6 @@ class XcodecPreTrainedModel(PreTrainedAudioTokenizerBase):
|
||||
module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
|
||||
if module.bias is not None:
|
||||
module.bias.data.zero_()
|
||||
|
||||
elif isinstance(module, (nn.LayerNorm, nn.GroupNorm)):
|
||||
module.bias.data.zero_()
|
||||
module.weight.data.fill_(1.0)
|
||||
@ -341,6 +340,23 @@ class XcodecPreTrainedModel(PreTrainedAudioTokenizerBase):
|
||||
if module.bias is not None:
|
||||
k = math.sqrt(module.groups / (module.in_channels * module.kernel_size[0]))
|
||||
nn.init.uniform_(module.bias, a=-k, b=k)
|
||||
elif module.__class__.__name__ == "Snake1d":
|
||||
module.alpha.data.fill_(1.0)
|
||||
elif isinstance(module, nn.ConvTranspose1d):
|
||||
module.reset_parameters()
|
||||
elif isinstance(module, nn.Embedding):
|
||||
module.weight.data.normal_(mean=0.0, std=0.02)
|
||||
elif isinstance(module, XcodecModel):
|
||||
# The conv1d are not handled correctly, as `self.acoustic_encoder/decoder` are initialized from a PreTrainedModel,
|
||||
# but then only the submodules are used (which are not PreTrainedModels...) -> here we reinit them as in DacModel
|
||||
for submodule in module.acoustic_encoder.modules():
|
||||
if isinstance(submodule, nn.Conv1d):
|
||||
nn.init.trunc_normal_(submodule.weight, std=0.02)
|
||||
nn.init.constant_(submodule.bias, 0)
|
||||
for submodule in module.acoustic_decoder.modules():
|
||||
if isinstance(submodule, nn.Conv1d):
|
||||
nn.init.trunc_normal_(submodule.weight, std=0.02)
|
||||
nn.init.constant_(submodule.bias, 0)
|
||||
|
||||
def apply_weight_norm(self):
|
||||
"""Apply weight norm in the acoustic encoder and decoder because the original checkpoint has weight norm applied."""
|
||||
@ -396,6 +412,9 @@ class XcodecModel(XcodecPreTrainedModel):
|
||||
self.fc2 = nn.Linear(config.hidden_size, config.acoustic_model_config.hidden_size)
|
||||
self.quantizer = XcodecResidualVectorQuantization(config)
|
||||
|
||||
# Initialize weights and apply final processing
|
||||
self.post_init()
|
||||
|
||||
@staticmethod
|
||||
def _adjust_dac_decoder(decoder: nn.Module):
|
||||
r"""
|
||||
|
@ -361,10 +361,6 @@ class DFineModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
def test_resize_tokens_embeddings(self):
|
||||
pass
|
||||
|
||||
@unittest.skip(reason="Not relevant for the model")
|
||||
def test_can_init_all_missing_weights(self):
|
||||
pass
|
||||
|
||||
@unittest.skip(reason="Feed forward chunking is not implemented")
|
||||
def test_feed_forward_chunking(self):
|
||||
pass
|
||||
|
@ -148,7 +148,6 @@ class Gemma3nAudioModelTest(ModelTesterMixin, unittest.TestCase):
|
||||
_is_stateful = True
|
||||
main_input_name = "audio_mel"
|
||||
test_initialization = False
|
||||
test_can_init_all_missing_weights = False
|
||||
|
||||
def setUp(self):
|
||||
self.model_tester = Gemma3nAudioModelTester(self)
|
||||
|
@ -189,10 +189,6 @@ class HGNetV2ForImageClassificationTest(ModelTesterMixin, PipelineTesterMixin, u
|
||||
def setUp(self):
|
||||
self.model_tester = HGNetV2ModelTester(self)
|
||||
|
||||
@unittest.skip(reason="Does not work on the tiny model.")
|
||||
def test_model_parallelism(self):
|
||||
super().test_model_parallelism()
|
||||
|
||||
@unittest.skip(reason="HGNetV2 does not output attentions")
|
||||
def test_attention_outputs(self):
|
||||
pass
|
||||
@ -209,14 +205,6 @@ class HGNetV2ForImageClassificationTest(ModelTesterMixin, PipelineTesterMixin, u
|
||||
def test_model_common_attributes(self):
|
||||
pass
|
||||
|
||||
@unittest.skip(reason="HGNetV2 does not have a model")
|
||||
def test_model(self):
|
||||
pass
|
||||
|
||||
@unittest.skip(reason="Not relevant for the model")
|
||||
def test_can_init_all_missing_weights(self):
|
||||
pass
|
||||
|
||||
def test_backbone(self):
|
||||
config_and_inputs = self.model_tester.prepare_config_and_inputs()
|
||||
self.model_tester.create_and_check_backbone(*config_and_inputs)
|
||||
|
@ -114,7 +114,6 @@ class XcodecModelTest(ModelTesterMixin, unittest.TestCase):
|
||||
test_headmasking = False
|
||||
test_resize_embeddings = False
|
||||
test_torchscript = False
|
||||
test_can_init_all_missing_weights = False
|
||||
|
||||
def _prepare_for_class(self, inputs_dict, model_class, return_labels=False):
|
||||
# model does not support returning hidden states
|
||||
|
Reference in New Issue
Block a user