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
f71fb5c3
Unverified
Commit
f71fb5c3
authored
Jan 06, 2022
by
Tavin Turner
Committed by
GitHub
Jan 06, 2022
Browse files
Add 'with torch.no_grad()' to BertGeneration integration test forward passes (#14963)
parent
d2183a46
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
tests/test_modeling_bert_generation.py
tests/test_modeling_bert_generation.py
+4
-2
No files found.
tests/test_modeling_bert_generation.py
View file @
f71fb5c3
...
...
@@ -307,7 +307,8 @@ class BertGenerationEncoderIntegrationTest(unittest.TestCase):
def
test_inference_no_head_absolute_embedding
(
self
):
model
=
BertGenerationEncoder
.
from_pretrained
(
"google/bert_for_seq_generation_L-24_bbc_encoder"
)
input_ids
=
torch
.
tensor
([[
101
,
7592
,
1010
,
2026
,
3899
,
2003
,
10140
,
102
]])
output
=
model
(
input_ids
)[
0
]
with
torch
.
no_grad
():
output
=
model
(
input_ids
)[
0
]
expected_shape
=
torch
.
Size
([
1
,
8
,
1024
])
self
.
assertEqual
(
output
.
shape
,
expected_shape
)
expected_slice
=
torch
.
tensor
(
...
...
@@ -322,7 +323,8 @@ class BertGenerationDecoderIntegrationTest(unittest.TestCase):
def
test_inference_no_head_absolute_embedding
(
self
):
model
=
BertGenerationDecoder
.
from_pretrained
(
"google/bert_for_seq_generation_L-24_bbc_encoder"
)
input_ids
=
torch
.
tensor
([[
101
,
7592
,
1010
,
2026
,
3899
,
2003
,
10140
,
102
]])
output
=
model
(
input_ids
)[
0
]
with
torch
.
no_grad
():
output
=
model
(
input_ids
)[
0
]
expected_shape
=
torch
.
Size
([
1
,
8
,
50358
])
self
.
assertEqual
(
output
.
shape
,
expected_shape
)
expected_slice
=
torch
.
tensor
(
...
...
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