Skip to content

Commit 7642026

Browse files
[CI] Add sheet summary for E2E tests (#1064)
1 parent 6df9301 commit 7642026

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

.github/scripts/inductor_summary.py

+80
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import pandas as pd
44
from scipy.stats import gmean
55
from styleframe import StyleFrame, Styler, utils
6+
import numpy as np
7+
from openpyxl import Workbook
68

79
parser = argparse.ArgumentParser(description="Generate report")
810
parser.add_argument('-s', '--suite', default=["huggingface"], nargs='*', type=str, help='model suite name')
@@ -665,6 +667,73 @@ def update_summary(excel, scenario, suite):
665667
sf.set_row_height(j, 30)
666668
sf.to_excel(sheet_name=suite + '_' + scenario + '_Summary', excel_writer=excel)
667669

670+
def summary_conclusion(scenario, excel):
671+
excel.book.save(excel)
672+
df = pd.read_excel(excel, sheet_name = None, header = None)
673+
#df = pd.DataFrame(excel)
674+
if scenario == 'performance':
675+
sheet_names = list(df.keys())
676+
sheet_names = [s for s in sheet_names if 'Summary' in s and 'performance' in s]
677+
sheet_names.sort()
678+
print(f"Merge excel as below:\n{sheet_names}")
679+
print("\n")
680+
features = [[]] * 21
681+
for sheet_name in sheet_names:
682+
df_sheet = df[sheet_name]
683+
df_sheet = df_sheet.values
684+
features = np.hstack((features, df_sheet))
685+
686+
if len(sheet_names) == 1:
687+
print("sheet not merge")
688+
elif len(sheet_names) == 2:
689+
print("2 sheets merge")
690+
if 'huggingface' in sheet_names[0]:
691+
features[:, 4:5] = features[:, 14:15]
692+
features[:, 6:7] = features[:, 16:17]
693+
else:
694+
features[:, 4:5] = features[:, 14:15]
695+
else:
696+
print("3 sheets merge")
697+
features[:, 4:5] = features[:, 24:25]
698+
features[:, 6:7] = features[:, 16:17]
699+
700+
df_concat = StyleFrame(pd.DataFrame(features).iloc[:,:10])
701+
for i in range(10):
702+
df_concat.set_column_width(i, 22)
703+
for j in range(1, 23):
704+
df_concat.set_row_height(j, 30)
705+
df_concat.to_excel(sheet_name='Perf_Summary', excel_writer=excel, index=False)
706+
else:
707+
sheet_names = list(df.keys())
708+
sheet_names = [s for s in sheet_names if 'Summary' in s and 'accuracy' in s]
709+
sheet_names.sort()
710+
print(f"Merge excel as below:\n{sheet_names}")
711+
print("\n")
712+
features = [[]] * 11
713+
for sheet_name in sheet_names:
714+
df_sheet = df[sheet_name]
715+
df_sheet = df_sheet.values
716+
features = np.hstack((features, df_sheet))
717+
if len(sheet_names) == 1:
718+
print("sheet not merge")
719+
elif len(sheet_names) == 2:
720+
print("2 sheets merge")
721+
if 'huggingface' in sheet_names[0]:
722+
features[:, 3:4] = features[:, 12:13]
723+
features[:, 5:6] = features[:, 14:15]
724+
else:
725+
features[:, 3:4] = features[:, 12:13]
726+
else:
727+
print("3 sheets merge")
728+
features[:, 3:4] = features[:, 21:22]
729+
features[:, 5:6] = features[:, 14:15]
730+
731+
df_concat = StyleFrame(pd.DataFrame(features).iloc[:,:9])
732+
for i in range(10):
733+
df_concat.set_column_width(i, 22)
734+
for j in range(1, 13):
735+
df_concat.set_row_height(j, 30)
736+
df_concat.to_excel(sheet_name='Acc_Summary', excel_writer=excel, index=False)
668737

669738
def generate_report(excel, scenario_list, precision_list, mode_list, suite_list):
670739
for sc in scenario_list:
@@ -693,8 +762,19 @@ def excel_postprocess(file, scenario, precison, mode, suite):
693762
wdt.merge_cells(start_row=1, end_row=1, start_column=13, end_column=16)
694763
wb.save(file)
695764

765+
if len(scenario) == 2:
766+
wb.move_sheet("Perf_Summary", -(len(wb.worksheets)-1))
767+
wb.move_sheet("Acc_Summary", -(len(wb.worksheets)-1))
768+
elif len(scenario) == 1 and sc == 'accuracy':
769+
wb.move_sheet("Acc_Summary", -(len(wb.worksheets)-1))
770+
else:
771+
wb.move_sheet("Perf_Summary", -(len(wb.worksheets)-1))
772+
696773

697774
if __name__ == '__main__':
698775
excel = StyleFrame.ExcelWriter('inductor_log/Inductor_E2E_Test_Report.xlsx')
699776
generate_report(excel, args.scenario, args.precision, args.mode, args.suite)
777+
for sc in args.scenario:
778+
summary_conclusion(sc, excel)
700779
excel_postprocess(excel, args.scenario, args.precision, args.mode, args.suite)
780+
excel.close()

0 commit comments

Comments
 (0)