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
7e00247f
"sgl-router/src/routers/vscode:/vscode.git/clone" did not exist on "f4e3ebeb056002fdb2649cba1f3758522516e81a"
Unverified
Commit
7e00247f
authored
Mar 11, 2022
by
feifang24
Committed by
GitHub
Mar 11, 2022
Browse files
check for key 'torch.dtype' in nested dicts in config (#16065)
parent
5d2fed2e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
src/transformers/configuration_utils.py
src/transformers/configuration_utils.py
+6
-3
No files found.
src/transformers/configuration_utils.py
View file @
7e00247f
...
...
@@ -849,12 +849,15 @@ class PretrainedConfig(PushToHubMixin):
def
dict_torch_dtype_to_str
(
self
,
d
:
Dict
[
str
,
Any
])
->
None
:
"""
Checks whether the passed dictionary
has
a *torch_dtype* key and if it's not None,
converts torch.dtype to a
string of just the type. For example, `torch.float32` get converted into *"float32"*
string, which can then be
stored in the json format.
Checks whether the passed dictionary
and its nested dicts have
a *torch_dtype* key and if it's not None,
converts torch.dtype to a
string of just the type. For example, `torch.float32` get converted into *"float32"*
string, which can then be
stored in the json format.
"""
if
d
.
get
(
"torch_dtype"
,
None
)
is
not
None
and
not
isinstance
(
d
[
"torch_dtype"
],
str
):
d
[
"torch_dtype"
]
=
str
(
d
[
"torch_dtype"
]).
split
(
"."
)[
1
]
for
value
in
d
.
values
():
if
isinstance
(
value
,
dict
):
self
.
dict_torch_dtype_to_str
(
value
)
@
classmethod
def
register_for_auto_class
(
cls
,
auto_class
=
"AutoConfig"
):
...
...
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