Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
1eb125fb
Commit
1eb125fb
authored
Sep 04, 2019
by
thomwolf
Browse files
be sure we have uint8
parent
7fba47b7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
pytorch_transformers/modeling_transfo_xl.py
pytorch_transformers/modeling_transfo_xl.py
+2
-2
No files found.
pytorch_transformers/modeling_transfo_xl.py
View file @
1eb125fb
...
...
@@ -1135,7 +1135,7 @@ class TransfoXLModel(TransfoXLPreTrainedModel):
mlen
=
mems
[
0
].
size
(
0
)
if
mems
is
not
None
else
0
klen
=
mlen
+
qlen
if
self
.
same_length
:
all_ones
=
word_emb
.
new_ones
(
qlen
,
klen
)
all_ones
=
word_emb
.
new_ones
(
(
qlen
,
klen
)
,
dtype
=
torch
.
uint8
)
mask_len
=
klen
-
self
.
mem_len
if
mask_len
>
0
:
mask_shift_len
=
qlen
-
mask_len
...
...
@@ -1145,7 +1145,7 @@ class TransfoXLModel(TransfoXLPreTrainedModel):
+
torch
.
tril
(
all_ones
,
-
mask_shift_len
))[:,
:,
None
]
# -1
else
:
dec_attn_mask
=
torch
.
triu
(
word_emb
.
new_ones
(
qlen
,
klen
),
diagonal
=
1
+
mlen
)[:,:,
None
]
word_emb
.
new_ones
(
(
qlen
,
klen
),
dtype
=
torch
.
uint8
),
diagonal
=
1
+
mlen
)[:,:,
None
]
hids
=
[]
attentions
=
[]
...
...
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