diff --git a/framework/e2e/PaddleLT_new/layertest.py b/framework/e2e/PaddleLT_new/layertest.py index 703e2077fc..d083eaef64 100644 --- a/framework/e2e/PaddleLT_new/layertest.py +++ b/framework/e2e/PaddleLT_new/layertest.py @@ -10,7 +10,7 @@ import traceback # from engine.engine_map import engine_map -from strategy.compare import base_compare +from strategy.compare import base_compare, infer_compare from tools.yaml_loader import YamlLoader from tools.logger import Logger from tools.res_save import save_tensor, load_tensor, save_pickle @@ -163,7 +163,11 @@ def _case_run(self): compare_res_list.append(tmp) else: precision = comparing.get("precision") - compare_res = base_compare( + if comparing.get("compare_method") == "infer_compare": + compare_methon = infer_compare + else: + compare_methon = base_compare + compare_res = compare_methon( result=result, expect=expect, res_name=latest, diff --git a/framework/e2e/PaddleLT_new/strategy/compare.py b/framework/e2e/PaddleLT_new/strategy/compare.py index 9bec4389dd..64dcebb8ad 100644 --- a/framework/e2e/PaddleLT_new/strategy/compare.py +++ b/framework/e2e/PaddleLT_new/strategy/compare.py @@ -148,6 +148,43 @@ def base_compare(result, expect, res_name, exp_name, logger, delta=1e-10, rtol=1 return exc_dict +def infer_compare(result, expect, res_name, exp_name, logger, delta=1e-10, rtol=1e-10, exc_dict={}): + """ + 比较函数 + :param result: 待测值 + :param expect: 基线值 + :param delta: 误差值 + :param rtol: 相对误差 + :return: + """ + # 去除反向结果的数据 + forward_handled_result = {"logit": []} + forward_handled_expect = {"logit": []} + + # 去除非tensor数值的影响 + if isinstance(expect["logit"], (tuple, list)): + for item in expect["logit"]: + if not isinstance(item, (int, bool, float)): + forward_handled_expect["logit"].append(item) + + if isinstance(result["logit"], (tuple, list)): + for item in result["logit"]: + if not isinstance(item, (int, bool, float)): + forward_handled_result["logit"].append(item) + + exc_dict = base_compare( + result=result, + expect=expect, + res_name=res_name, + exp_name=exp_name, + logger=logger, + delta=1e-10, + rtol=1e-10, + exc_dict=exc_dict, + ) + return exc_dict + + def perf_compare_legacy(baseline, latest): """ 比较函数 diff --git a/framework/e2e/PaddleLT_new/yaml/dy^dy2st_train_static_inputspec^export_st_inputspec^ppinfer_new_exc_pir.yml b/framework/e2e/PaddleLT_new/yaml/dy^dy2st_train_static_inputspec^export_st_inputspec^ppinfer_new_exc_pir.yml index 792fee8fcd..5e71b204c3 100644 --- a/framework/e2e/PaddleLT_new/yaml/dy^dy2st_train_static_inputspec^export_st_inputspec^ppinfer_new_exc_pir.yml +++ b/framework/e2e/PaddleLT_new/yaml/dy^dy2st_train_static_inputspec^export_st_inputspec^ppinfer_new_exc_pir.yml @@ -33,18 +33,21 @@ compare: - baseline: 'dy_train' latest: 'dy2st_train_static_inputspec' + compare_method: "base_compare" precision: delta: 0.00001 rtol: 0.000001 - baseline: 'dy_train' latest: 'paddle_infer_new_exc_pir' + compare_method: "infer_compare" precision: delta: 0.00001 rtol: 0.000001 - baseline: 'dy2st_train_static_inputspec' latest: 'paddle_infer_new_exc_pir' + compare_method: "infer_compare" precision: delta: 0.00001 rtol: 0.000001 diff --git a/framework/e2e/PaddleLT_new/yaml/dy^dy2stcinn_train^export_cinn_st_inputspec^ppinfer_new_exc_pir.yml b/framework/e2e/PaddleLT_new/yaml/dy^dy2stcinn_train^export_cinn_st_inputspec^ppinfer_new_exc_pir.yml index 2efbb3e9ac..a804cd2b37 100644 --- a/framework/e2e/PaddleLT_new/yaml/dy^dy2stcinn_train^export_cinn_st_inputspec^ppinfer_new_exc_pir.yml +++ b/framework/e2e/PaddleLT_new/yaml/dy^dy2stcinn_train^export_cinn_st_inputspec^ppinfer_new_exc_pir.yml @@ -33,18 +33,21 @@ compare: - baseline: 'dy_train' latest: 'dy2st_train_cinn' + compare_method: "base_compare" precision: delta: 0.00001 rtol: 0.000001 - baseline: 'dy_train' latest: 'paddle_infer_new_exc_pir' + compare_method: "infer_compare" precision: delta: 0.00001 rtol: 0.000001 - baseline: 'dy2st_train_cinn' latest: 'paddle_infer_new_exc_pir' + compare_method: "infer_compare" precision: delta: 0.00001 rtol: 0.000001