Skip to content

Commit

Permalink
Revert "[2/N] Dynamo supports skip by function & removes skipfiles ci…
Browse files Browse the repository at this point in the history
…rcular import (pytorch#110835)"

This reverts commit 0bd4ce7.

Reverted pytorch#110835 on behalf of https://github.com/DanilBaibak due to Broken trunk ([comment](pytorch#110835 (comment)))
  • Loading branch information
pytorchmergebot committed Oct 11, 2023
1 parent 80dfc97 commit d3205f8
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 296 deletions.
101 changes: 0 additions & 101 deletions test/dynamo/test_allow_inline_skip.py

This file was deleted.

28 changes: 0 additions & 28 deletions test/dynamo/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# Owner(s): ["module: dynamo"]
import importlib
import os
import sys
import types

import torch
import torch._dynamo
Expand All @@ -24,27 +20,3 @@ def wrapped(*args):
return torch.sin(a + 1), inner_func()

return wrapped


# Create a dummy python module and function to test skipfiles rules.
module_code = """
def add(x):
return x + 1
"""


def add(x):
return x + 1


def create_dummy_module_and_function():
module = types.ModuleType("dummy_module")
module.__spec__ = importlib.machinery.ModuleSpec(
"dummy_module", None, origin=os.path.abspath(__file__)
)
exec(module_code, module.__dict__)
sys.modules["dummy_module"] = module
# Need to override the original function since its __code__.co_filename is not a regular python file name,
# and the skipfiles rules use filename when checking SKIP_DIRS.
module.add = add
return module, module.add
8 changes: 4 additions & 4 deletions torch/_dynamo/eval_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def __init__(self, mod: torch.nn.Module, dynamo_ctx):
def _initialize(self):
# Do this stuff in constructor to lower overhead slightly
if isinstance(self._orig_mod.forward, types.MethodType) and skipfiles.check(
self._orig_mod.forward
inspect.getsourcefile(self._orig_mod.forward)
):
# This may be a torch.nn.* instance in skipfiles.py which
# won't trigger a frame evaluation workaround to add an extra
Expand Down Expand Up @@ -362,7 +362,7 @@ def get_compiler_config():
except TypeError:
filename = None
if (
(filename is None or skipfiles.check(fn))
(filename is None or skipfiles.check(filename))
and (
getattr(fn, "__name__", "") not in ["_call_impl", "_wrapped_call_impl"]
)
Expand Down Expand Up @@ -519,7 +519,7 @@ def catch_errors(frame, cache_entry, frame_state):
if (
# TODO: the first condition is not covered by any test
frame.f_lasti >= first_real_inst_idx(frame.f_code)
or skipfiles.check(frame.f_code)
or skipfiles.check(frame.f_code.co_filename)
or config.disable
):
log.debug("skipping %s %s", frame.f_code.co_name, frame.f_code.co_filename)
Expand Down Expand Up @@ -1218,7 +1218,7 @@ def result_capturing_wrapper(*graph_inputs):
if (
(shape_env := getattr(fake_mode, "shape_env", None)) is not None
and (dim_constraints := shape_env.dim_constraints) is not None
and not skipfiles.check(call_to_inspect)
and not skipfiles.check(inspect.getsourcefile(call_to_inspect))
):
dim_constraints.solve()
dim_constraints.remove_redundant_dynamic_results()
Expand Down
Loading

0 comments on commit d3205f8

Please sign in to comment.