@@ -108,6 +108,13 @@ def log(level: Level, msg: str):
108
108
Graph = LogLevel .GRAPH
109
109
110
110
class internal_errors :
111
+ """Context-manager to limit displayed log messages to just internal errors
112
+
113
+ Example::
114
+
115
+ with torch_tensorrt.logging.internal_errors():
116
+ outputs = model_torchtrt(inputs)
117
+ """
111
118
def __enter__ (self ):
112
119
self .external_lvl = get_reportable_log_level ()
113
120
set_reportable_log_level (Level .InternalError )
@@ -116,6 +123,13 @@ def __exit__(self, exc_type, exc_value, exc_tb):
116
123
set_reportable_log_level (self .external_lvl )
117
124
118
125
class errors :
126
+ """Context-manager to limit displayed log messages to just errors and above
127
+
128
+ Example::
129
+
130
+ with torch_tensorrt.logging.errors():
131
+ outputs = model_torchtrt(inputs)
132
+ """
119
133
def __enter__ (self ):
120
134
self .external_lvl = get_reportable_log_level ()
121
135
set_reportable_log_level (Level .Error )
@@ -124,6 +138,14 @@ def __exit__(self, exc_type, exc_value, exc_tb):
124
138
set_reportable_log_level (self .external_lvl )
125
139
126
140
class warnings :
141
+ """Context-manager to limit displayed log messages to just warnings and above
142
+
143
+ Example::
144
+
145
+ with torch_tensorrt.logging.warnings():
146
+ model_trt = torch_tensorrt.compile(model, **spec)
147
+ """
148
+
127
149
def __enter__ (self ):
128
150
self .external_lvl = get_reportable_log_level ()
129
151
set_reportable_log_level (Level .Warning )
@@ -132,6 +154,13 @@ def __exit__(self, exc_type, exc_value, exc_tb):
132
154
set_reportable_log_level (self .external_lvl )
133
155
134
156
class info :
157
+ """Context-manager to display all info and greater severity messages
158
+
159
+ Example::
160
+
161
+ with torch_tensorrt.logging.info():
162
+ model_trt = torch_tensorrt.compile(model, **spec)
163
+ """
135
164
def __enter__ (self ):
136
165
self .external_lvl = get_reportable_log_level ()
137
166
set_reportable_log_level (Level .Info )
@@ -140,6 +169,13 @@ def __exit__(self, exc_type, exc_value, exc_tb):
140
169
set_reportable_log_level (self .external_lvl )
141
170
142
171
class debug :
172
+ """Context-manager to display full debug information through the logger
173
+
174
+ Example::
175
+
176
+ with torch_tensorrt.logging.debug():
177
+ model_trt = torch_tensorrt.compile(model, **spec)
178
+ """
143
179
def __enter__ (self ):
144
180
self .external_lvl = get_reportable_log_level ()
145
181
set_reportable_log_level (Level .Debug )
@@ -148,6 +184,14 @@ def __exit__(self, exc_type, exc_value, exc_tb):
148
184
set_reportable_log_level (self .external_lvl )
149
185
150
186
class graphs :
187
+ """Context-manager to display the results of intermediate lowering passes
188
+ as well as full debug information through the logger
189
+
190
+ Example::
191
+
192
+ with torch_tensorrt.logging.graphs():
193
+ model_trt = torch_tensorrt.compile(model, **spec)
194
+ """
151
195
def __enter__ (self ):
152
196
self .external_lvl = get_reportable_log_level ()
153
197
set_reportable_log_level (Level .Graph )
0 commit comments