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
870a9542
"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "ea50b64bea95b80cb3e8fcceaeb8304b90b5900c"
Unverified
Commit
870a9542
authored
Oct 11, 2022
by
Partho
Committed by
GitHub
Oct 10, 2022
Browse files
wrap forward passes with torch.no_grad() (#19438)
parent
692c5be7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
tests/models/roformer/test_modeling_roformer.py
tests/models/roformer/test_modeling_roformer.py
+2
-1
No files found.
tests/models/roformer/test_modeling_roformer.py
View file @
870a9542
...
@@ -457,7 +457,8 @@ class RoFormerModelIntegrationTest(unittest.TestCase):
...
@@ -457,7 +457,8 @@ class RoFormerModelIntegrationTest(unittest.TestCase):
def
test_inference_masked_lm
(
self
):
def
test_inference_masked_lm
(
self
):
model
=
RoFormerForMaskedLM
.
from_pretrained
(
"junnyu/roformer_chinese_base"
)
model
=
RoFormerForMaskedLM
.
from_pretrained
(
"junnyu/roformer_chinese_base"
)
input_ids
=
torch
.
tensor
([[
0
,
1
,
2
,
3
,
4
,
5
]])
input_ids
=
torch
.
tensor
([[
0
,
1
,
2
,
3
,
4
,
5
]])
output
=
model
(
input_ids
)[
0
]
with
torch
.
no_grad
():
output
=
model
(
input_ids
)[
0
]
# TODO Replace vocab size
# TODO Replace vocab size
vocab_size
=
50000
vocab_size
=
50000
...
...
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