Skip to content

Commit 2b98694

Browse files
committed
Added profile_format and added docstring to the debugger
1 parent bf817ea commit 2b98694

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

py/torch_tensorrt/dynamo/_compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ def contains_metadata(gm: torch.fx.GraphModule) -> bool:
924924
os.makedirs(path, exist_ok=True)
925925
trt_module.enable_profiling(
926926
profiling_results_dir=path,
927-
profile_format="trex",
927+
profile_format=_debugger_settings.profile_format,
928928
)
929929

930930
# Parse the graph I/O and store it in dryrun tracker

py/torch_tensorrt/dynamo/conversion/_TRTInterpreter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ def run(
719719
if self.compilation_settings.reuse_cached_engines:
720720
interpreter_result = self._pull_cached_engine(hash_val)
721721
if interpreter_result is not None: # hit the cache
722-
return interpreter_result
722+
return interpreter_result # type: ignore[no-any-return]
723723

724724
self._construct_trt_network_def()
725725

py/torch_tensorrt/dynamo/debug/_Debugger.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,38 @@ def __init__(
3030
capture_fx_graph_before: Optional[List[str]] = None,
3131
capture_fx_graph_after: Optional[List[str]] = None,
3232
save_engine_profile: bool = False,
33+
profile_format: str = "perfetto",
3334
engine_builder_monitor: bool = True,
3435
logging_dir: str = tempfile.gettempdir(),
3536
):
37+
"""Initialize a debugger for TensorRT conversion.
38+
39+
Args:
40+
log_level (str): Logging level to use. Valid options are:
41+
'debug', 'info', 'warning', 'error', 'internal_errors', 'graphs'.
42+
Defaults to 'debug'.
43+
capture_fx_graph_before (List[str], optional): List of pass names to visualize FX graph
44+
before execution of a lowering pass. Defaults to None.
45+
capture_fx_graph_after (List[str], optional): List of pass names to visualize FX graph
46+
after execution of a lowering pass. Defaults to None.
47+
save_engine_profile (bool): Whether to save TensorRT engine profiling information.
48+
Defaults to False.
49+
profile_format (str): Format for profiling data. Can be either 'perfetto' or 'trex'.
50+
If you need to generate engine graph using the profiling files, set it to 'trex' .
51+
Defaults to 'perfetto'.
52+
engine_builder_monitor (bool): Whether to monitor TensorRT engine building process.
53+
Defaults to True.
54+
logging_dir (str): Directory to save debug logs and profiles.
55+
Defaults to system temp directory.
56+
"""
3657

3758
os.makedirs(logging_dir, exist_ok=True)
3859
self.cfg = DebuggerConfig(
3960
log_level=log_level,
4061
save_engine_profile=save_engine_profile,
4162
engine_builder_monitor=engine_builder_monitor,
4263
logging_dir=logging_dir,
64+
profile_format=profile_format,
4365
)
4466

4567
if log_level == "debug":

py/torch_tensorrt/dynamo/debug/_DebuggerConfig.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ class DebuggerConfig:
88
save_engine_profile: bool = False
99
engine_builder_monitor: bool = True
1010
logging_dir: str = tempfile.gettempdir()
11+
profile_format: str = "perfetto"

py/torch_tensorrt/dynamo/debug/_supports_debugger.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
from typing import Any, Callable, Type, TypeVar
1+
from typing import Any, Callable, Type, TypeVar, cast
22

33
T = TypeVar("T")
4-
4+
F = TypeVar("F", bound=Callable[..., Any])
55

66
_DEBUG_ENABLED_FUNCS = []
77
_DEBUG_ENABLED_CLS = []
88

9-
F = TypeVar("F", bound=Callable[..., Any])
10-
119

1210
def fn_supports_debugger(func: F) -> F:
1311
_DEBUG_ENABLED_FUNCS.append(func)
14-
return func
12+
return cast(F, func)
1513

1614

1715
def cls_supports_debugger(cls: Type[T]) -> Type[T]:

0 commit comments

Comments
 (0)