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
b370cc7e
Commit
b370cc7e
authored
Feb 26, 2020
by
Julien Chaumond
Browse files
[gpu] Fixup
fdd61b19
parent
f5516805
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
tests/test_modeling_gpt2.py
tests/test_modeling_gpt2.py
+4
-2
No files found.
tests/test_modeling_gpt2.py
View file @
b370cc7e
...
...
@@ -205,7 +205,7 @@ class GPT2ModelTest(ModelTesterMixin, unittest.TestCase):
model
.
eval
()
# create attention mask
attn_mask
=
torch
.
ones
(
input_ids
.
shape
).
long
(
)
attn_mask
=
torch
.
ones
(
input_ids
.
shape
,
dtype
=
torch
.
long
,
device
=
torch_device
)
half_seq_length
=
self
.
seq_length
//
2
attn_mask
[:,
half_seq_length
:]
=
0
...
...
@@ -222,7 +222,9 @@ class GPT2ModelTest(ModelTesterMixin, unittest.TestCase):
# append to next input_ids and attn_mask
next_input_ids
=
torch
.
cat
([
input_ids
,
next_tokens
],
dim
=-
1
)
attn_mask
=
torch
.
cat
([
attn_mask
,
torch
.
ones
((
attn_mask
.
shape
[
0
],
1
)).
long
()],
dim
=
1
)
attn_mask
=
torch
.
cat
(
[
attn_mask
,
torch
.
ones
((
attn_mask
.
shape
[
0
],
1
),
dtype
=
torch
.
long
,
device
=
torch_device
)],
dim
=
1
)
# get two different outputs
output_from_no_past
,
_
=
model
(
next_input_ids
,
attention_mask
=
attn_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