Skip to content

Commit 78b99c3

Browse files
committed
stacklevel
1 parent 97a2c46 commit 78b99c3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

onnx_diagnostic/torch_export_patches/patches/patch_torch.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import inspect
22
import os
33
import traceback
4+
import warnings
45
from typing import Any, Callable, Dict, List, Sequence, Tuple, Union
56
import torch
67
from torch._subclasses.fake_tensor import FakeTensorMode
@@ -360,8 +361,10 @@ def _log_guard(
360361
) -> None:
361362
self._log_guard_remember(prefix=prefix, g=g, forcing_spec=forcing_spec)
362363
sloc, _maybe_extra_debug = self._get_stack_summary(True)
363-
raise AssertionError(
364+
warnings.warn(
364365
f"A guard was added, prefix={prefix!r}, g={g!r}, "
365366
f"forcing_spec={forcing_spec}, location=\n{sloc}\n"
366-
f"--stack trace--\n{retrieve_stacktrace()}"
367+
f"--stack trace--\n{retrieve_stacktrace()}",
368+
RuntimeWarning,
369+
stacklevel=0,
367370
)

0 commit comments

Comments
 (0)