Skip to content

Commit 475ba1d

Browse files
laithsakkapytorchmergebot
authored andcommitted
Expliclty avoid recording when should_record_events is false in record_shapeenv_event (pytorch#138965)
Looking at the function record_shapeenv_event its hard to tell that it does not always run but we do disable it by setting top level is_recording to True self.should_record_events is false this makes it more explicit to avoid confusion and overloading is_recording. alternativley we can rename is_recording to do_no_record. Pull Request resolved: pytorch#138965 Approved by: https://github.com/ezyang ghstack dependencies: pytorch#138804
1 parent a688c57 commit 475ba1d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

torch/fx/experimental/recording.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ def retlog(r):
253253
return r
254254

255255
try:
256-
if args[0].is_recording: # type: ignore[has-type]
256+
shape_env = args[0]
257+
if not shape_env.should_record_events or shape_env.is_recording: # type: ignore[has-type]
257258
# If ShapeEnv is already recording an event, call the wrapped
258259
# function directly.
259260
#

torch/fx/experimental/symbolic_shapes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2918,7 +2918,7 @@ def __init__(
29182918
)
29192919

29202920
# This will make sure we only record the top-level function call.
2921-
self.is_recording = not self.should_record_events
2921+
self.is_recording = False
29222922
# Keep track of the list of tracked fakes.
29232923
self.tracked_fakes = tracked_fakes
29242924
# List of events for reconstructing ShapeEnv at arbitrary points in time.

0 commit comments

Comments
 (0)