Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zly-idleness committed Sep 23, 2024
1 parent 252ae88 commit 12893d3
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions src/transformers/modeling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4348,28 +4348,6 @@ def _load_pretrained_model(
# Now assign the updated list to loaded_keys
loaded_keys = updated_loaded_keys

def _fix_key(key):
if "beta" in key:
return key.replace("beta", "bias")
if "gamma" in key:
return key.replace("gamma", "weight")

# to avoid logging parametrized weight norm renaming
if hasattr(nn.utils.parametrizations, "weight_norm"):
if "weight_g" in key:
return key.replace("weight_g", "parametrizations.weight.original0")
if "weight_v" in key:
return key.replace("weight_v", "parametrizations.weight.original1")
else:
if "parametrizations.weight.original0" in key:
return key.replace("parametrizations.weight.original0", "weight_g")
if "parametrizations.weight.original1" in key:
return key.replace("parametrizations.weight.original1", "weight_v")
return key

original_loaded_keys = loaded_keys
loaded_keys = [_fix_key(key) for key in loaded_keys]

if len(prefix) > 0:
has_prefix_module = any(s.startswith(prefix) for s in loaded_keys)
expects_prefix_module = any(s.startswith(prefix)
Expand Down

0 comments on commit 12893d3

Please sign in to comment.