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
4d181999
"examples/summarization/vscode:/vscode.git/clone" did not exist on "ab5d06a094ad32722018a069c2fb9707d1c6a8b1"
Commit
4d181999
authored
Nov 12, 2019
by
Rémi Louf
Committed by
Julien Chaumond
Dec 09, 2019
Browse files
cast bool tensor to long for pytorch < 1.3
parent
9f75565e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
0 deletions
+1
-0
transformers/modeling_bert.py
transformers/modeling_bert.py
+1
-0
No files found.
transformers/modeling_bert.py
View file @
4d181999
...
...
@@ -675,6 +675,7 @@ class BertModel(BertPreTrainedModel):
batch_size
,
seq_length
=
input_shape
seq_ids
=
torch
.
arange
(
seq_length
,
device
=
device
)
causal_mask
=
seq_ids
[
None
,
None
,
:].
repeat
(
batch_size
,
seq_length
,
1
)
<=
seq_ids
[
None
,
:,
None
]
causal_mask
=
causal_mask
.
to
(
torch
.
long
)
# not converting to long will cause errors with pytorch version < 1.3
extended_attention_mask
=
causal_mask
[:,
None
,
:,
:]
*
attention_mask
[:,
None
,
None
,
:]
else
:
extended_attention_mask
=
attention_mask
[:,
None
,
None
,
:]
...
...
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