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
41c186d2
Unverified
Commit
41c186d2
authored
Sep 23, 2021
by
Lysandre Debut
Committed by
GitHub
Sep 23, 2021
Browse files
Replace torch.set_grad_enabled by torch.no_grad (#13703)
parent
f888e5c3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
38 deletions
+37
-38
src/transformers/onnx/convert.py
src/transformers/onnx/convert.py
+37
-38
No files found.
src/transformers/onnx/convert.py
View file @
41c186d2
...
...
@@ -90,7 +90,7 @@ def export(
raise
AssertionError
(
f
"Unsupported PyTorch version, minimum required is 1.8.0, got:
{
torch_version
}
"
)
logger
.
info
(
f
"Using framework PyTorch:
{
torch
.
__version__
}
"
)
torch
.
set
_grad
_enabled
(
False
)
with
torch
.
no
_grad
():
model
.
config
.
return_dict
=
True
model
.
eval
()
...
...
@@ -127,7 +127,6 @@ def export(
)
config
.
restore_ops
()
torch
.
set_grad_enabled
(
True
)
return
matched_inputs
,
onnx_outputs
...
...
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