Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust cpp torch trt logging level with compiler option #3181

Merged
merged 5 commits into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions py/torch_tensorrt/dynamo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from torch._subclasses.fake_tensor import FakeTensor
from torch_tensorrt._Device import Device
from torch_tensorrt._enums import dtype
from torch_tensorrt._features import ENABLED_FEATURES
from torch_tensorrt._Input import Input
from torch_tensorrt.dynamo import _defaults
from torch_tensorrt.dynamo._defaults import default_device
Expand Down Expand Up @@ -204,10 +205,27 @@ def set_log_level(parent_logger: Any, level: Any) -> None:
Sets the log level to the user provided level.
This is used to set debug logging at a global level
at entry points of tracing, dynamo and torch_compile compilation.
And set log level for c++ torch trt logger if runtime is available.
"""
if parent_logger:
parent_logger.setLevel(level)

if ENABLED_FEATURES.torch_tensorrt_runtime:
if level == logging.DEBUG:
log_level = trt.ILogger.Severity.VERBOSE
elif level == logging.INFO:
log_level = trt.ILogger.Severity.INFO
elif level == logging.WARNING:
log_level = trt.ILogger.Severity.WARNING
elif level == logging.ERROR:
log_level = trt.ILogger.Severity.ERROR
elif level == logging.CRITICAL:
log_level = trt.ILogger.Severity.INTERNAL_ERROR
else:
raise AssertionError(f"{level} is not valid log level")

torch.ops.tensorrt.set_logging_level(int(log_level))


def prepare_inputs(
inputs: Input | torch.Tensor | Sequence[Any] | Dict[Any, Any],
Expand Down
Loading