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
e5c12c03
Unverified
Commit
e5c12c03
authored
Dec 05, 2023
by
Bram Willemsen
Committed by
GitHub
Dec 05, 2023
Browse files
Move tensors to same device to enable IDEFICS naive MP training (#27746)
parent
3e68944c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
src/transformers/models/idefics/modeling_idefics.py
src/transformers/models/idefics/modeling_idefics.py
+2
-1
No files found.
src/transformers/models/idefics/modeling_idefics.py
View file @
e5c12c03
...
@@ -1510,9 +1510,10 @@ class IdeficsForVisionText2Text(IdeficsPreTrainedModel):
...
@@ -1510,9 +1510,10 @@ class IdeficsForVisionText2Text(IdeficsPreTrainedModel):
loss
=
None
loss
=
None
if
labels
is
not
None
:
if
labels
is
not
None
:
labels
=
labels
.
to
(
logits
.
device
)
# Shift so that tokens < n predict n
# Shift so that tokens < n predict n
if
attention_mask
is
not
None
:
if
attention_mask
is
not
None
:
shift_attention_mask
=
attention_mask
[...,
1
:]
shift_attention_mask
=
attention_mask
[...,
1
:]
.
to
(
logits
.
device
)
shift_logits
=
logits
[...,
:
-
1
,
:][
shift_attention_mask
!=
0
].
contiguous
()
shift_logits
=
logits
[...,
:
-
1
,
:][
shift_attention_mask
!=
0
].
contiguous
()
shift_labels
=
labels
[...,
1
:][
shift_attention_mask
!=
0
].
contiguous
()
shift_labels
=
labels
[...,
1
:][
shift_attention_mask
!=
0
].
contiguous
()
else
:
else
:
...
...
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