8000 [Dynamo][Trace PyDispatcher] Remove disable from HigherOrderOperator.__call__ by yanboliang · Pull Request #146270 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

[Dynamo][Trace PyDispatcher] Remove disable from HigherOrderOperator.__call__ #146270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions test/dynamo/test_higher_order_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -2283,7 +2283,8 @@ def body(x):

res = mod_for_compile(torch.Tensor([[6, 4, 5], [3, 4, 5], [6, 6, 6]]))
# There is graph break right when we enter body of map
self.assertEqual(len(backend.graphs), 0)
# Since we are tracing through the Python dispatch logic, it ends up 8 graphs.
self.assertEqual(len(backend.graphs), 8)
self.assertEqual(
res, mod_for_eager(torch.Tensor([[6, 4, 5], [3, 4, 5], [6, 6, 6]]))
)
Expand Down Expand Up @@ -2319,7 +2320,8 @@ def body(x):
eager = mod_for_eager(torch.Tensor([[6, 4, 5], [3, 4, 5], [6, 6, 6]]))
eager = mod_for_eager(torch.Tensor([[6, 4, 5], [3, 4, 5], [6, 6, 6]]))

self.assertEqual(len(backend.graphs), 0)
# Since we are tracing through the Python dispatch logic, it ends up 9 graphs.
self.assertEqual(len(backend.graphs), 9)
self.assertEqual(res, eager)

def test_wrap_subgraph_name_is_valid(self):
Expand Down
5 changes: 0 additions & 5 deletions torch/_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,6 @@ def check_overloaded(arg):

@abc.abstractmethod
def __call__(self, /, *args, **kwargs):
# Dynamo already traces the body of HigherOrderOp beforehand when it
# so no need to trace into it.
from torch._dynamo import disable

@disable
def wrapper():
flat_args = _to_flat_tuple(args, kwargs)
if torch.overrides.has_torch_function(flat_args):
Expand Down
Loading
0