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
9fd11bf1
"...git@developer.sourcefind.cn:OpenDAS/nni.git" did not exist on "d48ad0270d1870781732eeecfa1499912d3a63af"
Unverified
Commit
9fd11bf1
authored
Sep 09, 2020
by
Henry Dashwood
Committed by
GitHub
Sep 09, 2020
Browse files
replace torch.triu with onnx compatible code (#6929)
parent
ed71c21d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
src/transformers/modeling_bart.py
src/transformers/modeling_bart.py
+4
-3
No files found.
src/transformers/modeling_bart.py
View file @
9fd11bf1
...
...
@@ -154,9 +154,10 @@ def _prepare_bart_decoder_inputs(
if
decoder_padding_mask
is
not
None
and
decoder_padding_mask
.
shape
[
1
]
>
1
:
# never mask leading token, even if it is pad
decoder_padding_mask
[:,
0
]
=
decoder_padding_mask
[:,
1
]
causal_mask
=
torch
.
triu
(
fill_with_neg_inf
(
torch
.
zeros
(
tgt_len
,
tgt_len
)),
1
).
to
(
dtype
=
causal_mask_dtype
,
device
=
decoder_input_ids
.
device
)
tmp
=
fill_with_neg_inf
(
torch
.
zeros
(
tgt_len
,
tgt_len
))
mask
=
torch
.
arange
(
tmp
.
size
(
-
1
))
tmp
.
masked_fill_
(
mask
<
(
mask
+
1
).
view
(
tmp
.
size
(
-
1
),
1
),
0
)
causal_mask
=
tmp
.
to
(
dtype
=
causal_mask_dtype
,
device
=
decoder_input_ids
.
device
)
return
decoder_input_ids
,
decoder_padding_mask
,
causal_mask
...
...
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