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
1b5ea747
"src/vscode:/vscode.git/clone" did not exist on "6bae64f6ebf5737bb8648b81584cd1b644e003d2"
Unverified
Commit
1b5ea747
authored
Jul 07, 2022
by
Sylvain Gugger
Committed by
GitHub
Jul 07, 2022
Browse files
Place inputs on device when include_inputs_for_metrics is True (#18046)
parent
870ff9e1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
src/transformers/trainer.py
src/transformers/trainer.py
+2
-2
No files found.
src/transformers/trainer.py
View file @
1b5ea747
...
@@ -2804,7 +2804,7 @@ class Trainer:
...
@@ -2804,7 +2804,7 @@ class Trainer:
# Prediction step
# Prediction step
loss
,
logits
,
labels
=
self
.
prediction_step
(
model
,
inputs
,
prediction_loss_only
,
ignore_keys
=
ignore_keys
)
loss
,
logits
,
labels
=
self
.
prediction_step
(
model
,
inputs
,
prediction_loss_only
,
ignore_keys
=
ignore_keys
)
inputs_decode
=
inputs
[
"input_ids"
]
if
args
.
include_inputs_for_metrics
else
None
inputs_decode
=
self
.
_prepare_input
(
inputs
[
"input_ids"
]
)
if
args
.
include_inputs_for_metrics
else
None
if
is_torch_tpu_available
():
if
is_torch_tpu_available
():
xm
.
mark_step
()
xm
.
mark_step
()
...
@@ -3352,7 +3352,7 @@ class Trainer:
...
@@ -3352,7 +3352,7 @@ class Trainer:
for
step
,
inputs
in
enumerate
(
dataloader
):
for
step
,
inputs
in
enumerate
(
dataloader
):
loss
,
logits
,
labels
=
self
.
prediction_step
(
model
,
inputs
,
prediction_loss_only
,
ignore_keys
=
ignore_keys
)
loss
,
logits
,
labels
=
self
.
prediction_step
(
model
,
inputs
,
prediction_loss_only
,
ignore_keys
=
ignore_keys
)
inputs_decode
=
inputs
[
"input_ids"
]
if
args
.
include_inputs_for_metrics
else
None
inputs_decode
=
self
.
_prepare_input
(
inputs
[
"input_ids"
]
)
if
args
.
include_inputs_for_metrics
else
None
if
loss
is
not
None
:
if
loss
is
not
None
:
losses
=
loss
.
repeat
(
batch_size
)
losses
=
loss
.
repeat
(
batch_size
)
...
...
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