Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
f4d4f0a1
"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "0e83c9664b2a440ade59066a77fb01d0143e4d18"
Unverified
Commit
f4d4f0a1
authored
Apr 08, 2022
by
Laura Hanu
Committed by
GitHub
Apr 08, 2022
Browse files
only load state dict when the checkpoint is not None (#16673)
parent
d57da992
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
src/transformers/modeling_utils.py
src/transformers/modeling_utils.py
+1
-1
No files found.
src/transformers/modeling_utils.py
View file @
f4d4f0a1
...
@@ -1792,7 +1792,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
...
@@ -1792,7 +1792,7 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
# load pt weights early so that we know which dtype to init the model under
# load pt weights early so that we know which dtype to init the model under
if
from_pt
:
if
from_pt
:
if
not
is_sharded
:
if
not
is_sharded
and
state_dict
is
None
:
# Time to load the checkpoint
# Time to load the checkpoint
state_dict
=
load_state_dict
(
resolved_archive_file
)
state_dict
=
load_state_dict
(
resolved_archive_file
)
# set dtype to instantiate the model under:
# set dtype to instantiate the model under:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment