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
fd9aa82b
"docs/vscode:/vscode.git/clone" did not exist on "8cf4a6f0a63ed3aeed68192a9304fed2bd0ce100"
Unverified
Commit
fd9aa82b
authored
Aug 16, 2022
by
Joao Gante
Committed by
GitHub
Aug 16, 2022
Browse files
TF: Fix generation repetition penalty with XLA (#18648)
parent
81ab1112
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
src/transformers/generation_tf_logits_process.py
src/transformers/generation_tf_logits_process.py
+3
-1
No files found.
src/transformers/generation_tf_logits_process.py
View file @
fd9aa82b
...
...
@@ -262,9 +262,11 @@ class TFRepetitionPenaltyLogitsProcessor(TFLogitsProcessor):
# Scatters the penalties
token_penalties
=
tf
.
ones
(
logits
.
shape
)
batch_size
=
input_ids
.
shape
[
0
]
seq_len
=
tf
.
shape
(
input_ids
)[
1
]
# the sequence length has dynamic size, hence the dynamic shape
indexable_prev_input_ids
=
tf
.
concat
(
(
tf
.
expand_dims
(
tf
.
repeat
(
tf
.
range
(
input_ids
.
shape
[
0
]),
input_ids
.
shape
[
1
]
),
axis
=-
1
),
tf
.
expand_dims
(
tf
.
repeat
(
tf
.
range
(
batch_size
),
seq_len
),
axis
=-
1
),
tf
.
expand_dims
(
tf
.
reshape
(
input_ids
,
[
-
1
]),
axis
=-
1
),
),
axis
=
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