Skip to content

Commit 6bb9853

Browse files
anijain2305facebook-github-bot
authored andcommitted
Record the pre-graph bytecode using fast record function event
Summary: reland of pytorch/pytorch#154769 cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx ipiszy chenyang78 kadeng muchulee8 amjames chauhang aakhundov X-link: pytorch/pytorch#154974 Reviewed By: Lucaskabela Differential Revision: D75849934 Pulled By: anijain2305 fbshipit-source-id: 2d3cf61730774edf191d50d6205226a2221d3ea7
1 parent 73c93cf commit 6bb9853

File tree

1 file changed

+15
-1
lines changed
  • userbenchmark/dynamo/dynamobench/_dynamo

1 file changed

+15
-1
lines changed

userbenchmark/dynamo/dynamobench/_dynamo/utils.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
import warnings
4848
import weakref
4949
from collections import Counter, OrderedDict
50-
from contextlib import contextmanager
50+
from contextlib import AbstractContextManager, contextmanager
5151
from dataclasses import is_dataclass
5252
from functools import lru_cache
5353
from types import MethodWrapperType
@@ -4674,3 +4674,17 @@ def maybe_disable_inference_mode_for_fake_prop() -> Generator[None, None, None]:
46744674

46754675
def is_node_meta_valid(node: Optional[torch.fx.Node]) -> bool:
46764676
return node is None or "example_value" in node.meta or "val" in node.meta
4677+
4678+
4679+
def record_pregraph_bytecode_enter() -> AbstractContextManager[None]:
4680+
cm: AbstractContextManager[None] = (
4681+
torch._C._profiler._RecordFunctionFast("Pregraph bytecode")
4682+
if torch.autograd.profiler._is_profiler_enabled
4683+
else contextlib.nullcontext()
4684+
)
4685+
cm.__enter__()
4686+
return cm
4687+
4688+
4689+
def record_pregraph_bytecode_exit(cm: AbstractContextManager[None]) -> None:
4690+
cm.__exit__(None, None, None)

0 commit comments

Comments
 (0)