MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / _tabulate_ml

Function _tabulate_ml

imperative/python/megengine/tools/profile_analyze.py:18–40  ·  view source on GitHub ↗

r"""Tabulate profile output with multi-line support.

(tab, **kwargs)

Source from the content-addressed store, hash-verified

16
17
18def _tabulate_ml(tab, **kwargs):
19 r"""Tabulate profile output with multi-line support."""
20 new_tab = []
21 new_tab_is_row = []
22 for row in tab:
23 col_lines = [str(i).split("\n") for i in row]
24 max_nr_line = max(map(len, col_lines))
25 new_tab_is_row.append(True)
26 if max_nr_line > 1:
27 new_tab_is_row.extend([False] * (max_nr_line - 1))
28 for i in col_lines:
29 if len(i) < max_nr_line:
30 i.extend([""] * (max_nr_line - len(i)))
31 new_tab.extend(zip(*col_lines))
32 else:
33 new_tab.append(row)
34
35 assert len(new_tab_is_row) == len(new_tab)
36 ret = [i + "\n" for i in tabulate(new_tab, **kwargs).split("\n")]
37 for idx, val in enumerate(new_tab_is_row):
38 if not val:
39 ret[idx * 2 + 2] = ""
40 return "".join(ret)[:-1]
41
42
43def _tabulate_confluence(tab, **kwargs):

Callers 1

prof_detailsFunction · 0.85

Calls 4

strFunction · 0.85
maxFunction · 0.85
joinMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected