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
344e2664
"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "5164ea91a7b4d35cb03867233527fa383a651775"
Unverified
Commit
344e2664
authored
Oct 17, 2022
by
Sylvain Gugger
Committed by
GitHub
Oct 17, 2022
Browse files
Fix dtype in radnomly initialized head (#19690)
parent
07f66902
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
src/transformers/modeling_utils.py
src/transformers/modeling_utils.py
+2
-2
No files found.
src/transformers/modeling_utils.py
View file @
344e2664
...
...
@@ -2446,9 +2446,9 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
param
=
model_state_dict
[
key
]
if
param
.
device
==
torch
.
device
(
"meta"
):
if
not
load_in_8bit
:
set_module_tensor_to_device
(
model
,
key
,
"cpu"
,
torch
.
empty
(
*
param
.
size
()))
set_module_tensor_to_device
(
model
,
key
,
"cpu"
,
torch
.
empty
(
*
param
.
size
()
,
dtype
=
dtype
))
else
:
set_module_8bit_tensor_to_device
(
model
,
key
,
"cpu"
,
torch
.
empty
(
*
param
.
size
()))
set_module_8bit_tensor_to_device
(
model
,
key
,
"cpu"
,
torch
.
empty
(
*
param
.
size
()
,
dtype
=
dtype
))
# retrieve unintialized modules and initialize before maybe overriding that with the pretrained weights.
if
_fast_init
:
...
...
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