Skip to content

Commit df7ef35

Browse files
committed
fix broken output
1 parent fc277da commit df7ef35

File tree

2 files changed

+51
-14
lines changed

2 files changed

+51
-14
lines changed
File renamed without changes.

docs/source/tutorials_source/devtools-integration-tutorial.py

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -201,22 +201,15 @@ def forward(self, x):
201201
# sphinx_gallery_end_ignore
202202
inspector.print_data_tabular()
203203

204-
# sphinx_gallery_start_ignore
205-
# Display the actural inspector tabular table image
206-
import matplotlib.image as mpimg
207-
import matplotlib.pyplot as plt
208-
209-
# Load and display the image
210-
img = mpimg.imread("tabular_result.png")
211-
fig, ax = plt.subplots(figsize=(8, 6), dpi=150) # Adjust figsize and dpi as needed
212-
ax.imshow(img)
213-
ax.axis("off") # Hide axes
214-
plt.show()
215-
# sphinx_gallery_end_ignore
204+
####################################
205+
#
206+
# Here is an example output:
207+
#
208+
# .. image:: ../_static/img/tabular_result.png
216209

217210
# sphinx_gallery_start_ignore
218-
inspector_patch.stop()
219-
inspector_patch_print.stop()
211+
_ = inspector_patch.stop()
212+
_ = inspector_patch_print.stop()
220213
# sphinx_gallery_end_ignore
221214

222215
######################################################################
@@ -253,6 +246,21 @@ def forward(self, x):
253246
print(df[["event_name", "raw"]])
254247
print()
255248

249+
####################################
250+
# Exmaple output:
251+
#
252+
# Empty DataFrame
253+
# Columns: [event_name, raw]
254+
# Index: []
255+
256+
# native_call_addmm.out [0.040962]
257+
# native_call_addmm.out [0.007191]
258+
# native_call_addmm.out [0.000691]
259+
# event_name raw
260+
# 14 native_call_addmm.out [0.040962]
261+
# 20 native_call_addmm.out [0.007191]
262+
# 26 native_call_addmm.out [0.000691]
263+
256264
######################################################################
257265
# If a user wants to trace an operator back to their model code, they would do
258266
# something similar to finding the module hierarchy and stack trace of the
@@ -277,12 +285,37 @@ def forward(self, x):
277285
df = df[df.event_name == "native_call_convolution.out"]
278286
if len(df) > 0:
279287
slowest = df.loc[df["p50"].idxmax()]
288+
assert slowest is not None
280289
print(slowest.name)
281290
print()
282291
pp.pprint(slowest.stack_traces if slowest.stack_traces else "")
283292
print()
284293
pp.pprint(slowest.module_hierarchy if slowest.module_hierarchy else "")
285294

295+
####################################
296+
# native_call_convolution.out
297+
298+
# {'aten_convolution_default_1_': ' File '
299+
# '"/home/gasoonjia/et_proj/et_debug_playground.py", '
300+
# 'line 34, in forward\n'
301+
# ' x = F.max_pool2d(F.relu(self.conv2(x)), '
302+
# '2)\n'}
303+
304+
# {'aten_convolution_default_1_': {'L__self__': ('', '__main__.Net'),
305+
# 'L__self___conv2': ('conv2',
306+
# 'torch.nn.modules.conv.Conv2d')}}
307+
# 6
308+
309+
# {'aten_convolution_default_1_': ' File '
310+
# '"/home/gasoonjia/et_proj/et_debug_playground.py", '
311+
# 'line 34, in forward\n'
312+
# ' x = F.max_pool2d(F.relu(self.conv2(x)), '
313+
# '2)\n'}
314+
315+
# {'aten_convolution_default_1_': {'L__self__': ('', '__main__.Net'),
316+
# 'L__self___conv2': ('conv2',
317+
# 'torch.nn.modules.conv.Conv2d')}}
318+
286319
######################################################################
287320
# If a user wants the total runtime of a module, they can use
288321
# ``find_total_for_module``.
@@ -293,6 +326,10 @@ def forward(self, x):
293326
######################################################################
294327
# Note: ``find_total_for_module`` is a special first class method of
295328
# `Inspector <../model-inspector.html>`__
329+
#
330+
# Example output:
331+
# 1.889086
332+
# 1.031719
296333

297334
######################################################################
298335
# Conclusion

0 commit comments

Comments
 (0)