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
fded6f41
Unverified
Commit
fded6f41
authored
Jul 06, 2023
by
Zach Mueller
Committed by
GitHub
Jul 06, 2023
Browse files
Fix integration with Accelerate and failing test (#24691)
Fix integration
parent
bbf30908
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
src/transformers/trainer.py
src/transformers/trainer.py
+10
-4
No files found.
src/transformers/trainer.py
View file @
fded6f41
...
@@ -3176,13 +3176,19 @@ class Trainer:
...
@@ -3176,13 +3176,19 @@ class Trainer:
# Gather all remaining tensors and put them back on the CPU
# Gather all remaining tensors and put them back on the CPU
if
losses_host
is
not
None
:
if
losses_host
is
not
None
:
all_losses
=
nested_numpify
(
losses_host
)
losses
=
nested_numpify
(
losses_host
)
all_losses
=
losses
if
all_losses
is
None
else
np
.
concatenate
((
all_losses
,
losses
),
axis
=
0
)
if
preds_host
is
not
None
:
if
preds_host
is
not
None
:
all_preds
=
nested_numpify
(
preds_host
)
logits
=
nested_numpify
(
preds_host
)
all_preds
=
logits
if
all_preds
is
None
else
nested_concat
(
all_preds
,
logits
,
padding_index
=-
100
)
if
inputs_host
is
not
None
:
if
inputs_host
is
not
None
:
all_inputs
=
nested_numpify
(
inputs_host
)
inputs_decode
=
nested_numpify
(
inputs_host
)
all_inputs
=
(
inputs_decode
if
all_inputs
is
None
else
nested_concat
(
all_inputs
,
inputs_decode
,
padding_index
=-
100
)
)
if
labels_host
is
not
None
:
if
labels_host
is
not
None
:
all_labels
=
nested_numpify
(
labels_host
)
labels
=
nested_numpify
(
labels_host
)
all_labels
=
labels
if
all_labels
is
None
else
nested_concat
(
all_labels
,
labels
,
padding_index
=-
100
)
# Number of samples
# Number of samples
if
has_length
(
eval_dataset
):
if
has_length
(
eval_dataset
):
...
...
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