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
5c009186
Unverified
Commit
5c009186
authored
Apr 23, 2021
by
Kiran R
Committed by
GitHub
Apr 23, 2021
Browse files
added support for exporting of t5 to onnx with past_key_values (#10651)
parent
50f4539b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
src/transformers/models/t5/modeling_t5.py
src/transformers/models/t5/modeling_t5.py
+3
-1
No files found.
src/transformers/models/t5/modeling_t5.py
View file @
5c009186
...
...
@@ -423,6 +423,8 @@ class T5Attention(nn.Module):
# past_key_value[0] is (batch_size, n_heads, q_len - 1, dim_per_head)
batch_size
,
seq_length
=
hidden_states
.
shape
[:
2
]
int_seq_length
=
int
(
seq_length
)
real_seq_length
=
seq_length
if
past_key_value
is
not
None
:
...
...
@@ -489,7 +491,7 @@ class T5Attention(nn.Module):
# if key and values are already calculated
# we want only the last query position bias
if
past_key_value
is
not
None
:
position_bias
=
position_bias
[:,
:,
-
seq_length
:,
:]
position_bias
=
position_bias
[:,
:,
-
int_
seq_length
:,
:]
if
mask
is
not
None
:
position_bias
=
position_bias
+
mask
# (batch_size, n_heads, seq_length, key_length)
...
...
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