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
cea17acd
Unverified
Commit
cea17acd
authored
Nov 29, 2021
by
Patrick von Platen
Committed by
GitHub
Nov 29, 2021
Browse files
[Generate] Fix generate with inputs_embeds on GPU (#14564)
parent
25156eb2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
src/transformers/generation_utils.py
src/transformers/generation_utils.py
+1
-1
No files found.
src/transformers/generation_utils.py
View file @
cea17acd
...
@@ -401,7 +401,7 @@ class GenerationMixin:
...
@@ -401,7 +401,7 @@ class GenerationMixin:
# First if `inputs_embeds` are given, but no `attention_mask` assume that full attention_mask is used
# First if `inputs_embeds` are given, but no `attention_mask` assume that full attention_mask is used
if
inputs_embeds
is
not
None
:
if
inputs_embeds
is
not
None
:
return
torch
.
ones
((
inputs_embeds
.
shape
[
0
],
inputs_embeds
.
shape
[
1
]),
dtype
=
torch
.
long
)
return
torch
.
ones
((
inputs_embeds
.
shape
[
0
],
inputs_embeds
.
shape
[
1
]),
dtype
=
torch
.
long
,
device
=
self
.
device
)
# Otherwise, use `input_ids`
# Otherwise, use `input_ids`
is_pad_token_in_inputs_ids
=
(
pad_token_id
is
not
None
)
and
(
pad_token_id
in
input_ids
)
is_pad_token_in_inputs_ids
=
(
pad_token_id
is
not
None
)
and
(
pad_token_id
in
input_ids
)
...
...
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