MCPcopy Create free account
hub / github.com/pytorch/executorch / parse_tables

Function parse_tables

examples/arm/visualize.py:36–57  ·  view source on GitHub ↗

Parse the XML debug tables file and extract required tables as pandas DataFrames.

(tables_path: Path)

Source from the content-addressed store, hash-verified

34
35
36def parse_tables(tables_path: Path) -> Tables:
37 """
38 Parse the XML debug tables file and extract required tables as pandas DataFrames.
39 """
40 required_tables = {"queue", "group", "perf", "source"}
41 try:
42 tree = ET.parse(tables_path) # nosec B314
43 except ET.ParseError as e:
44 raise ValueError(f"Failed to parse XML tables file {tables_path}: {e}")
45
46 tables: Dict[str, pd.DataFrame] = {}
47 for table in tree.getroot().findall("table"):
48 name = table.attrib.get("name")
49 if name in required_tables:
50 text = table.text or ""
51 tables[name] = pd.read_csv(io.StringIO(text))
52
53 missing = required_tables - tables.keys()
54 if missing:
55 raise ValueError(f"Missing required tables in XML: {missing}")
56
57 return Tables(**tables)
58
59
60def get_trace_file_objects(trace_file_path: Path) -> list[Dict[str, Any]]:

Callers 1

build_overlay_dataFunction · 0.85

Calls 3

TablesClass · 0.85
keysMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected