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
df2f2812
"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "6a08162ad4ef2e08de45301cc9197f2bee01cbef"
Unverified
Commit
df2f2812
authored
Oct 11, 2022
by
Partho
Committed by
GitHub
Oct 10, 2022
Browse files
wrap forward passes with torch.no_grad() (#19412)
parent
5f5e264a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
tests/models/flaubert/test_modeling_flaubert.py
tests/models/flaubert/test_modeling_flaubert.py
+2
-1
No files found.
tests/models/flaubert/test_modeling_flaubert.py
View file @
df2f2812
...
@@ -437,7 +437,8 @@ class FlaubertModelIntegrationTest(unittest.TestCase):
...
@@ -437,7 +437,8 @@ class FlaubertModelIntegrationTest(unittest.TestCase):
def
test_inference_no_head_absolute_embedding
(
self
):
def
test_inference_no_head_absolute_embedding
(
self
):
model
=
FlaubertModel
.
from_pretrained
(
"flaubert/flaubert_base_cased"
)
model
=
FlaubertModel
.
from_pretrained
(
"flaubert/flaubert_base_cased"
)
input_ids
=
torch
.
tensor
([[
0
,
345
,
232
,
328
,
740
,
140
,
1695
,
69
,
6078
,
1588
,
2
]])
input_ids
=
torch
.
tensor
([[
0
,
345
,
232
,
328
,
740
,
140
,
1695
,
69
,
6078
,
1588
,
2
]])
output
=
model
(
input_ids
)[
0
]
with
torch
.
no_grad
():
output
=
model
(
input_ids
)[
0
]
expected_shape
=
torch
.
Size
((
1
,
11
,
768
))
expected_shape
=
torch
.
Size
((
1
,
11
,
768
))
self
.
assertEqual
(
output
.
shape
,
expected_shape
)
self
.
assertEqual
(
output
.
shape
,
expected_shape
)
expected_slice
=
torch
.
tensor
(
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