Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
337225ec
Unverified
Commit
337225ec
authored
Apr 19, 2023
by
Elabonga Atuo
Committed by
GitHub
Apr 19, 2023
Browse files
feat(model parallelism): move labels to the same device as logits for M2M100 (#22850)
moved logits for m2m_100
parent
6bd8ae26
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
0 deletions
+2
-0
src/transformers/models/m2m_100/modeling_m2m_100.py
src/transformers/models/m2m_100/modeling_m2m_100.py
+2
-0
No files found.
src/transformers/models/m2m_100/modeling_m2m_100.py
View file @
337225ec
...
...
@@ -1353,6 +1353,8 @@ class M2M100ForConditionalGeneration(M2M100PreTrainedModel):
masked_lm_loss
=
None
if
labels
is
not
None
:
# move labels to the correct device to enable PP
labels
=
labels
.
to
(
lm_logits
.
device
)
loss_fct
=
CrossEntropyLoss
()
masked_lm_loss
=
loss_fct
(
lm_logits
.
view
(
-
1
,
self
.
config
.
vocab_size
),
labels
.
view
(
-
1
))
...
...
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