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
0106826a
Unverified
Commit
0106826a
authored
Oct 20, 2021
by
Kwanghee Choi
Committed by
GitHub
Oct 20, 2021
Browse files
Fix missing autocast() in Trainer.prediction_step() (#14075)
Co-authored-by:
jonas
<
jonas@hpcnt.com
>
parent
a43d9352
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
src/transformers/trainer.py
src/transformers/trainer.py
+5
-1
No files found.
src/transformers/trainer.py
View file @
0106826a
...
...
@@ -2486,7 +2486,11 @@ class Trainer:
logits
=
smp_nested_concat
(
logits_mb
)
else
:
if
has_labels
:
loss
,
outputs
=
self
.
compute_loss
(
model
,
inputs
,
return_outputs
=
True
)
if
self
.
use_amp
:
with
autocast
():
loss
,
outputs
=
self
.
compute_loss
(
model
,
inputs
,
return_outputs
=
True
)
else
:
loss
,
outputs
=
self
.
compute_loss
(
model
,
inputs
,
return_outputs
=
True
)
loss
=
loss
.
mean
().
detach
()
if
isinstance
(
outputs
,
dict
):
logits
=
tuple
(
v
for
k
,
v
in
outputs
.
items
()
if
k
not
in
ignore_keys
+
[
"loss"
])
...
...
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