Skip to content

Commit

Permalink
plt update perf, test=model
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeref996 committed Oct 18, 2024
1 parent 1200484 commit 916d900
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
43 changes: 43 additions & 0 deletions framework/e2e/PaddleLT_new/pltools/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,49 @@ def kernel_perf_gsb_gen(compare_dict, compare_list):
return gsb_dict


def sublayer_perf_ratio_gen(compare_dict, compare_list):
"""
平均性能提升, 计算公式: mean(layer1_perf_engine1/layer1_perf_engine2 + layer2_perf_engine1/layer2_perf_engine2...)
:param compare_dict:{'layer1':
{'dy2st_eval_cinn_perf^layercase': 0.2333,
'dy_eval_perf^layercase': 0.114514,
'dy2st_eval_cinn_perf^dy_eval_perf^compare': '20%'}}
:return: dict
"""
ratio_dict = {}
for compare in compare_list:
if compare["baseline"] == "ground_truth":
ratio_dict[compare["latest"] + "^" + "compare"] = {"add_ratio": 0, "num_count": 0}
else:
ratio_dict[compare["latest"] + "^" + compare["baseline"] + "^" + "compare"] = {
"add_ratio": 0,
"num_count": 0,
}

for layer_name, perf_dict in compare_dict.items():
for compare in compare_list:
if compare["baseline"] == "ground_truth":
ratio_dict[compare["latest"] + "^" + "compare"]["add_ratio"] = (
ratio_dict[compare["latest"] + "^" + "compare"]["add_ratio"]
+ float(perf_dict[compare["latest"] + "^" + "compare"].strip("%")) / 100
)
ratio_dict[compare["latest"] + "^" + "compare"]["num_count"] += 1

else:
ratio_dict[compare["latest"] + "^" + compare["baseline"] + "^" + "compare"]["add_ratio"] = (
ratio_dict[compare["latest"] + "^" + compare["baseline"] + "^" + "compare"]["add_ratio"]
+ float(perf_dict[compare["latest"] + "^" + compare["baseline"] + "^" + "compare"].strip("%")) / 100
)
ratio_dict[compare["latest"] + "^" + compare["baseline"] + "^" + "compare"]["num_count"] += 1

for key, value in ratio_dict.items():
ratio_dict[key][
"mean_ratio"
] = f"{round(ratio_dict[key]['add_ratio'] / ratio_dict[key]['num_count'] * 100, 2)}%"

return ratio_dict


# def gsb_gen(sublayer_dict, compare_list):
# """
# 等级分类
Expand Down
4 changes: 3 additions & 1 deletion framework/e2e/PaddleLT_new/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from pltools.json_loader import JSONLoader
from pltools.res_save import xlsx_save, download_sth, create_tar_gz, extract_tar_gz, load_pickle, save_txt
from pltools.upload_bos import UploadBos
from pltools.statistics import split_list, sublayer_perf_gsb_gen, kernel_perf_gsb_gen
from pltools.statistics import split_list, sublayer_perf_gsb_gen, kernel_perf_gsb_gen, sublayer_perf_ratio_gen
from pltools.alarm import Alarm


Expand Down Expand Up @@ -643,6 +643,8 @@ def _perf_report_gen(
latest_layer_type=self.layer_type,
)
gsb_dict = sublayer_perf_gsb_gen(compare_dict=compare_dict, compare_list=compare_list)
ratio_dict = sublayer_perf_ratio_gen(compare_dict=compare_dict, compare_list=compare_list)
gsb_dict = {**gsb_dict, **ratio_dict}
save_txt(data=gsb_dict, filename="gsb_dict")
xlsx_save(
sublayer_dict=compare_dict,
Expand Down

0 comments on commit 916d900

Please sign in to comment.