Skip to content

Commit

Permalink
[export] Remove redundant no_grad() for exported program execution. (p…
Browse files Browse the repository at this point in the history
…ytorch#109686)

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

Fixes #ISSUE_NUMBER

Pull Request resolved: pytorch#109686
Approved by: https://github.com/angelayi
  • Loading branch information
zhxchen17 authored and pytorchmergebot committed Sep 21, 2023
1 parent e4d8ec9 commit 7a04ae6
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions torch/export/exported_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,11 @@ def __call__(self, *args: Any, **kwargs: Any) -> Any:
)
self._check_input_constraints(*ordered_params, *ordered_buffers, *args)

with torch.no_grad():
# NOTE: calling convention is first params, then buffers, then args as user supplied them.
# See: torch/_functorch/aot_autograd.py#L1034
res = torch.fx.Interpreter(self.graph_module).run(
*ordered_params, *ordered_buffers, *args, enable_io_processing=False
)
# NOTE: calling convention is first params, then buffers, then args as user supplied them.
# See: torch/_functorch/aot_autograd.py#L1034
res = torch.fx.Interpreter(self.graph_module).run(
*ordered_params, *ordered_buffers, *args, enable_io_processing=False
)

if self.call_spec.out_spec is not None:
mutation = self.graph_signature.buffers_to_mutate
Expand Down

0 comments on commit 7a04ae6

Please sign in to comment.