@@ -10,29 +10,6 @@ def parse_args():
1010 return parser .parse_args ()
1111
1212
13- def parse_folder_name (folder_name ):
14- """
15- Parse folder name to extract suite and dtype.
16-
17- Expected format: logs-{suite}-{dtype}-{mode}-accuracy, where mode can contain `-` characters
18- Examples:
19- - logs-torchbench-float32-inference-accuracy -> suite=torchbench, dtype=float32
20- - logs-huggingface-amp_bf16-training-accuracy -> suite=huggingface, dtype=amp_bf16
21- """
22- parts = folder_name .split ('-' )
23-
24- # Check if it follows the expected pattern
25- if len (parts ) < 4 or parts [0 ] != 'logs' or parts [- 1 ] != 'accuracy' :
26- return None , None , None
27-
28- suite = parts [1 ]
29- dtype = parts [2 ]
30- # Extract mode, can include dashes
31- mode = '-' .join (parts [3 :- 1 ])
32-
33- return suite , dtype , mode
34-
35-
3613def build_suite_report (combined_df , output_path ):
3714 print ('=======================================' )
3815 print ('= SUMMARY REPORT =' )
@@ -110,6 +87,50 @@ def build_pytorch_report(combined_df, output_path):
11087 pivoted_df .to_csv (torch_report_dir / f'inductor_{ suite } _{ mode } .csv' , index = False )
11188
11289
90+ def parse_mode (report_path ):
91+ """
92+ Parse report file path to extract `mode`.
93+
94+ Expected filename: 'inductor_{suite}_{dtype}_{mode}_xpu_accuracy.csv', where mode can contain `-` characters
95+ and dtype can contain `_` characters (e.g., `amp_bf16`).
96+
97+ Returns:
98+ mode (str): Extracted mode from the filename
99+ error (str or None): Error message if parsing fails, otherwise None
100+ """
101+ parts = report_path .name .split ('_' )
102+
103+ # Check if it follows the expected pattern
104+ if len (parts ) < 6 or parts [0 ] != 'inductor' or parts [- 1 ] != 'accuracy.csv' :
105+ txt = f'Unexpected filename format: { report_path .name } , parsed parts: { parts } '
106+ print (txt )
107+ return None , txt
108+ return parts [- 3 ], None
109+
110+
111+ def load_reports (input_path ):
112+ dfs = []
113+ problems = []
114+ for suite_path in filter (Path .is_dir , input_path .iterdir ()):
115+ suite = suite_path .name
116+
117+ for dtype_path in filter (Path .is_dir , suite_path .iterdir ()):
118+ dtype = dtype_path .name
119+
120+ for report_path in dtype_path .glob ('inductor_*_xpu_accuracy.csv' ):
121+ print (f'Reading { report_path } ' )
122+ mode , problem = parse_mode (report_path )
123+ if mode is None :
124+ problems .append (problem )
125+ continue
126+ df = pd .read_csv (report_path )
127+ df ['suite' ] = suite
128+ df ['mode' ] = mode
129+ df ['dtype' ] = dtype
130+ dfs .append (df )
131+ return dfs , problems
132+
133+
113134def main (input_dir , output_dir ):
114135 """
115136 Main function to aggregate end-to-end test results.
@@ -129,23 +150,7 @@ def main(input_dir, output_dir):
129150 print (f'Processing results from: { input_path } ' )
130151 print (f'Output will be saved to: { output_path } ' )
131152
132- dfs = []
133- for item_path in input_path .iterdir ():
134- name = item_path .name
135- if not item_path .is_dir ():
136- continue
137-
138- suite , dtype , mode = parse_folder_name (name )
139- if suite is None :
140- print (f'Folder name \' { name } \' does not match expected pattern, skipping' )
141- continue
142- filepath = item_path / suite / dtype / f'inductor_{ suite } _{ dtype } _{ mode } _xpu_accuracy.csv'
143- df = pd .read_csv (filepath )
144- df ['suite' ] = suite
145- df ['mode' ] = mode
146- df ['dtype' ] = dtype
147- dfs .append (df )
148-
153+ dfs , problems = load_reports (input_path )
149154 combined_df = pd .concat (dfs , ignore_index = True )
150155 combined_df = combined_df .sort_values (['suite' , 'mode' , 'dtype' ])
151156
@@ -157,6 +162,12 @@ def main(input_dir, output_dir):
157162 # 3. Agg report with 45 rows (suite, mode, dtype, passed, failed_REASON, failed_REASON model list)
158163 build_suite_report (combined_df , output_path = output_path )
159164
165+ if problems :
166+ print ('Problems found during parsing:' )
167+ for problem in problems :
168+ print (problem )
169+ raise RuntimeError ('Errors found during parsing, see above' )
170+
160171
161172if __name__ == '__main__' :
162173 args = parse_args ()
0 commit comments