mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Do not log exception when recording is disabled or already recording (#151038)
I am not sure why do we log all exceptions here and re-raise them , but at least when recording is disabled this should be transparent. namely logging dde could be spamming. before: <img width="995" alt="Screenshot 2025-04-10 at 12 47 31 PM" src="https://github.com/user-attachments/assets/f90d4557-d958-4558-a917-0d687366cad1" /> Pull Request resolved: https://github.com/pytorch/pytorch/pull/151038 Approved by: https://github.com/bobrenjc93
This commit is contained in:
parent
b22fda9e1c
commit
5a9868b78c
|
|
@ -252,8 +252,9 @@ def record_shapeenv_event(*, save_tracked_fakes: bool = False) -> Callable:
|
|||
trace_shape_events_log.debug("%s-> %s", " " * (NEST - 1), r)
|
||||
return r
|
||||
|
||||
shape_env = args[0]
|
||||
|
||||
try:
|
||||
shape_env = args[0]
|
||||
if not shape_env.should_record_events or shape_env.is_recording: # type: ignore[has-type]
|
||||
# If ShapeEnv is already recording an event, call the wrapped
|
||||
# function directly.
|
||||
|
|
@ -296,6 +297,9 @@ def record_shapeenv_event(*, save_tracked_fakes: bool = False) -> Callable:
|
|||
raise
|
||||
|
||||
except Exception:
|
||||
if not shape_env.should_record_events or shape_env.is_recording:
|
||||
# If ShapeEnv is disabled or already recording an event, re-raise the exception without logging.
|
||||
raise
|
||||
log.error( # noqa: G201
|
||||
"failed while running %s(*%s, **%s)",
|
||||
name,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user