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
OpenDAS
apex
Commits
14e34f7f
Commit
14e34f7f
authored
May 24, 2019
by
ptrblck
Committed by
mcarilli
May 24, 2019
Browse files
add backwards compatibility for PyTorch 0.4 for named_buffers (#331)
parent
e6eec3ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
1 deletion
+10
-1
apex/amp/_initialize.py
apex/amp/_initialize.py
+10
-1
No files found.
apex/amp/_initialize.py
View file @
14e34f7f
...
...
@@ -89,7 +89,16 @@ def check_params_fp32(models):
"you chose. Use model.to('cuda') to use the default device."
.
format
(
name
,
param
.
type
()))
for
name
,
buf
in
model
.
named_buffers
():
# Backward compatibility for PyTorch 0.4
if
hasattr
(
model
,
'named_buffers'
):
buf_iter
=
model
.
named_buffers
()
else
:
buf_iter
=
model
.
_buffers
for
obj
in
buf_iter
:
if
type
(
obj
)
==
tuple
:
name
,
buf
=
obj
else
:
name
,
buf
=
obj
,
buf_iter
[
obj
]
if
buf
.
is_floating_point
():
if
'Half'
in
buf
.
type
():
warn_or_err
(
"Found buffer {} with type {}, expected torch.cuda.FloatTensor.
\n
"
...
...
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