Skip to content

Commit

Permalink
add sheet summary
Browse files Browse the repository at this point in the history
  • Loading branch information
RUIJIEZHONG66166 committed Dec 18, 2024
1 parent 6df9301 commit ef2f2bd
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions .github/scripts/inductor_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import pandas as pd
from scipy.stats import gmean
from styleframe import StyleFrame, Styler, utils
import numpy as np
from openpyxl import Workbook

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

def summary_conclusion(scenario, excel):
excel.book.save(excel)
df = pd.read_excel(excel, sheet_name = None, header = None)
#df = pd.DataFrame(excel)
if scenario == 'performance':
sheet_names = list(df.keys())
sheet_names = [s for s in sheet_names if 'Summary' in s and 'performance' in s]
sheet_names.sort()
print(f"Merge excel as below:\n{sheet_names}")
print("\n")
features = [[]] * 21
for sheet_name in sheet_names:
df_sheet = df[sheet_name]
df_sheet = df_sheet.values
features = np.hstack((features, df_sheet))

if len(sheet_names) == 1:
print("sheet not merge")
elif len(sheet_names) == 2:
print("2 sheets merge")
if 'huggingface' in sheet_names[0]:
features[:, 4:5] = features[:, 14:15]
features[:, 6:7] = features[:, 16:17]
else:
features[:, 4:5] = features[:, 14:15]
else:
print("3 sheets merge")
features[:, 4:5] = features[:, 24:25]
features[:, 6:7] = features[:, 16:17]

df_concat = StyleFrame(pd.DataFrame(features).iloc[:,:10])
for i in range(10):
df_concat.set_column_width(i, 22)
for j in range(1, 23):
df_concat.set_row_height(j, 30)
df_concat.to_excel(sheet_name='Perf_Summary', excel_writer=excel, index=False)
else:
sheet_names = list(df.keys())
sheet_names = [s for s in sheet_names if 'Summary' in s and 'accuracy' in s]
sheet_names.sort()
print(f"Merge excel as below:\n{sheet_names}")
print("\n")
features = [[]] * 11
for sheet_name in sheet_names:
df_sheet = df[sheet_name]
df_sheet = df_sheet.values
features = np.hstack((features, df_sheet))
if len(sheet_names) == 1:
print("sheet not merge")
elif len(sheet_names) == 2:
print("2 sheets merge")
if 'huggingface' in sheet_names[0]:
features[:, 3:4] = features[:, 12:13]
features[:, 5:6] = features[:, 14:15]
else:
features[:, 3:4] = features[:, 12:13]
else:
print("3 sheets merge")
features[:, 3:4] = features[:, 21:22]
features[:, 5:6] = features[:, 14:15]

df_concat = StyleFrame(pd.DataFrame(features).iloc[:,:9])
for i in range(10):
df_concat.set_column_width(i, 22)
for j in range(1, 13):
df_concat.set_row_height(j, 30)
df_concat.to_excel(sheet_name='Acc_Summary', excel_writer=excel, index=False)

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

if len(scenario) == 2:
wb.move_sheet("Perf_Summary", -(len(wb.worksheets)-1))
wb.move_sheet("Acc_Summary", -(len(wb.worksheets)-1))
elif len(scenario) == 1 and sc == 'accuracy':
wb.move_sheet("Acc_Summary", -(len(wb.worksheets)-1))
else:
wb.move_sheet("Perf_Summary", -(len(wb.worksheets)-1))


if __name__ == '__main__':
excel = StyleFrame.ExcelWriter('inductor_log/Inductor_E2E_Test_Report.xlsx')
generate_report(excel, args.scenario, args.precision, args.mode, args.suite)
for sc in args.scenario:
summary_conclusion(sc, excel)
excel_postprocess(excel, args.scenario, args.precision, args.mode, args.suite)
excel.close()

0 comments on commit ef2f2bd

Please sign in to comment.