From aeda9e8db933009d1daa0a06b39214091054d297 Mon Sep 17 00:00:00 2001 From: l30044004 Date: Thu, 17 Aug 2023 16:47:32 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=9B=B8=E5=AF=B9?= =?UTF-8?q?=E8=AF=AF=E5=B7=AE=E5=8F=8C=E5=8D=83=E5=88=86=E4=B9=8B=E4=B8=80?= =?UTF-8?q?=E3=80=81=E5=8F=8C=E4=B8=87=E5=88=86=E4=B9=8B=E4=B8=80=E6=AF=94?= =?UTF-8?q?=E4=BE=8B=E6=8C=87=E6=A0=87=EF=BC=8C=E4=BF=9D=E5=AD=98=E6=9C=AA?= =?UTF-8?q?=E8=BE=BE=E6=A0=87=E7=9A=84api=E8=BE=93=E5=85=A5=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api_accuracy_checker/compare/algorithm.py | 24 ++++++++++++++++-- .../api_accuracy_checker/compare/compare.py | 25 ++++++++++++++++--- .../api_accuracy_checker/run_ut/run_ut.py | 9 ++++--- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py b/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py index 58e05cf74..9416869ed 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py @@ -29,7 +29,7 @@ def compare_bool_tensor(cpu_output, npu_output): return error_rate, error_rate < 0.001, "" -def get_max_rel_err(n_value, b_value): +def get_msg_and_handle_value(n_value, b_value): msg = "" if not isinstance(n_value, np.ndarray) or not isinstance(b_value, np.ndarray): msg = f"Max rel err only support numpy array! The actual type is {type(n_value)}, {type(b_value)}." @@ -52,12 +52,32 @@ def get_max_rel_err(n_value, b_value): zero_mask = (b_value == 0) b_value[zero_mask] += np.finfo(float).eps n_value[zero_mask] += np.finfo(float).eps + return n_value, b_value, msg + + +def get_max_rel_err(n_value, b_value): + n_value, b_value, msg = get_msg_and_handle_value(n_value, b_value) rel_err = np.abs((n_value - b_value) / b_value).max() bool_result = rel_err < 0.001 - return rel_err, bool_result, msg +def get_rel_err_ratio_thousandth(n_value, b_value): + n_value, b_value, msg = get_msg_and_handle_value(n_value, b_value) + rel_errs = np.abs((n_value - b_value) / b_value) + ratio = np.divide(np.sum(rel_errs < 0.001), np.size(rel_errs)) + bool_result = ratio > 0.999 + return ratio, bool_result, msg + + +def get_rel_err_ratio_ten_thousandth(n_value, b_value): + n_value, b_value, msg = get_msg_and_handle_value(n_value, b_value) + rel_errs = np.abs((n_value - b_value) / b_value) + ratio = np.divide(np.sum(rel_errs < 0.0001), np.size(rel_errs)) + bool_result = ratio > 0.9999 + return ratio, bool_result, msg + + def max_rel_err_standard(max_rel_errs): bool_result = np.array(max_rel_errs) < 0.001 return np.all(bool_result), bool_result diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py index 7a1c069e2..3960a56df 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py @@ -2,7 +2,7 @@ import os from prettytable import PrettyTable from api_accuracy_checker.compare.algorithm import compare_core, cosine_sim, cosine_standard, get_max_rel_err, \ - compare_builtin_type + compare_builtin_type, get_rel_err_ratio_thousandth, get_rel_err_ratio_ten_thousandth from api_accuracy_checker.common.utils import get_json_contents, print_error_log, print_info_log, write_csv from api_accuracy_checker.compare.compare_utils import CompareConst @@ -26,11 +26,14 @@ class Comparator: self.compare_alg = {} self.register_compare_algorithm("Cosine Similarity", cosine_sim, cosine_standard) self.register_compare_algorithm("Max Relative Error", get_max_rel_err, None) + self.register_compare_algorithm("Thousandth Relative Error Ratio", get_rel_err_ratio_thousandth, None) + self.register_compare_algorithm("Ten Thousandth Relative Error Ratio", get_rel_err_ratio_ten_thousandth, None) self.register_compare_algorithm("Default: isEqual", compare_builtin_type, None) self.test_results = [] self.test_result_cnt = { "forward_fail_num": 0, "backward_fail_num": 0, "forward_and_backward_fail_num": 0, "success_num": 0 } + self.result_save_path = result_save_path def print_pretest_result(self): res_dict = { @@ -66,6 +69,8 @@ class Comparator: test_rows = [[ "Subject", "Cosine Similarity", "Cosine Similarity Pass", "Cosine Similarity Message", "Max Rel Error", "Max Rel Err Pass", "Max Rel Err Message", + "Thousandth Rel Error Ratio", "Thousandth Rel Error Ratio Pass", "Thousandth Rel Error Ratio Message", + "Ten Thousandth Rel Error Ratio", "Ten Thousandth Rel Error Ratio Pass", "Ten Thousandth Rel Error Ratio Message", "Compare Builtin Type", "Builtin Type Pass", "Builtin Type Message" ]] @@ -90,7 +95,7 @@ class Comparator: def register_compare_algorithm(self, name, compare_func, standard): self.compare_alg.update({name: (compare_func, standard)}) - def compare_output(self, api_name, bench_out, npu_out, bench_grad=None, npu_grad=None): + def compare_output(self, api_name, bench_out, npu_out, bench_grad=None, npu_grad=None, save_biased_data=False): if "dropout" in api_name: is_fwd_success, fwd_compare_alg_results = self._compare_dropout(bench_out, npu_out) else: @@ -111,6 +116,20 @@ class Comparator: self.test_result_cnt['forward_fail_num'] += 1 else: self.test_result_cnt['backward_fail_num'] += 1 + if (not is_fwd_success or not is_bwd_success) and save_biased_data: + self.save_biased_data(self.result_save_path, api_name, bench_out, npu_out) + + + def save_biased_data(self, save_path, api_name, bench_out, npu_out): + biased_data_dir = os.path.join(save_path, 'biased_data_out') + if not os.path.exists(biased_data_dir): + os.mkdir(biased_data_dir, mode=0o750) + bench_out_path = os.path.join(biased_data_dir, f'{api_name}_bench_out.npy') + npu_out_path = os.path.join(biased_data_dir, f'{api_name}_npu_out.npy') + np.save(bench_out_path, bench_out.contiguous().cpu().detach().numpy()) + np.save(npu_out_path, npu_out.contiguous().cpu().detach().numpy()) + + def _compare_core_wrapper(self, bench_out, npu_out): detailed_result_total = [] @@ -118,7 +137,7 @@ class Comparator: for name in self.compare_alg.keys(): alg = self.compare_alg[name][0] detailed_result, test_success = compare_core(bench_out, npu_out, alg) - if name != "Max Relative Error": + if name not in ["Max Relative Error", "Thousandth Relative Error Ratio", "Ten Thousandth Relative Error Ratio"]: test_success_total = test_success_total and test_success if detailed_result_total: for i in range(len(detailed_result_total)): diff --git a/debug/accuracy_tools/api_accuracy_checker/run_ut/run_ut.py b/debug/accuracy_tools/api_accuracy_checker/run_ut/run_ut.py index e5737b511..ca5b64808 100644 --- a/debug/accuracy_tools/api_accuracy_checker/run_ut/run_ut.py +++ b/debug/accuracy_tools/api_accuracy_checker/run_ut/run_ut.py @@ -63,7 +63,7 @@ def generate_npu_params(cpu_args, cpu_kwargs, need_backward): return npu_args, npu_kwargs -def run_ut(forward_file, backward_file, out_path, save_error_data): +def run_ut(forward_file, backward_file, out_path, save_error_data, save_biased_data): print_info_log("start UT test") forward_content = get_json_contents(forward_file) backward_content = get_json_contents(backward_file) @@ -73,7 +73,7 @@ def run_ut(forward_file, backward_file, out_path, save_error_data): try: grad_out, npu_grad_out, npu_out, out = run_torch_api(api_full_name, api_setting_dict, backward_content, api_info_dict) - compare.compare_output(api_full_name, out, npu_out, grad_out, npu_grad_out) + compare.compare_output(api_full_name, out, npu_out, grad_out, npu_grad_out, save_biased_data) except Exception as err: [_, api_name, _] = api_full_name.split("*") if "not implemented for 'Half'" in str(err): @@ -171,6 +171,8 @@ def _run_ut_parser(parser): default=False, required=False) parser.add_argument("-d", "--device", dest="device_id", type=int, help=" set NPU device id to run ut", default=0, required=False) + parser.add_argument('-save_biased_data', dest="save_biased_data", action="store_true", + help=" Save compare biased api output.", required=False) def _run_ut(): @@ -190,7 +192,8 @@ def _run_ut(): raise ValueError("The forward_input_file and backward_input_file should be a json file!") out_path = os.path.realpath(args.out_path) if args.out_path else "./" save_error_data = args.save_error_data - run_ut(forward_file, backward_file, out_path, save_error_data) + save_biased_data = args.save_biased_data + run_ut(forward_file, backward_file, out_path, save_error_data, save_biased_data) if __name__ == '__main__': -- Gitee From 152e8420570b396b49d32a09e9af32ff421218c2 Mon Sep 17 00:00:00 2001 From: l30044004 Date: Fri, 18 Aug 2023 16:28:41 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=9B=B8=E5=AF=B9?= =?UTF-8?q?=E8=AF=AF=E5=B7=AE=E5=8F=8C=E5=8D=83=E5=88=86=E4=B9=8B=E4=B8=80?= =?UTF-8?q?=E3=80=81=E5=8F=8C=E4=B8=87=E5=88=86=E4=B9=8B=E4=B8=80=E6=AF=94?= =?UTF-8?q?=E4=BE=8B=E6=8C=87=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api_accuracy_checker/compare/compare.py | 15 +-------------- .../api_accuracy_checker/run_ut/run_ut.py | 9 +++------ 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py index 3960a56df..209234150 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py @@ -95,7 +95,7 @@ class Comparator: def register_compare_algorithm(self, name, compare_func, standard): self.compare_alg.update({name: (compare_func, standard)}) - def compare_output(self, api_name, bench_out, npu_out, bench_grad=None, npu_grad=None, save_biased_data=False): + def compare_output(self, api_name, bench_out, npu_out, bench_grad=None, npu_grad=None): if "dropout" in api_name: is_fwd_success, fwd_compare_alg_results = self._compare_dropout(bench_out, npu_out) else: @@ -116,19 +116,6 @@ class Comparator: self.test_result_cnt['forward_fail_num'] += 1 else: self.test_result_cnt['backward_fail_num'] += 1 - if (not is_fwd_success or not is_bwd_success) and save_biased_data: - self.save_biased_data(self.result_save_path, api_name, bench_out, npu_out) - - - def save_biased_data(self, save_path, api_name, bench_out, npu_out): - biased_data_dir = os.path.join(save_path, 'biased_data_out') - if not os.path.exists(biased_data_dir): - os.mkdir(biased_data_dir, mode=0o750) - bench_out_path = os.path.join(biased_data_dir, f'{api_name}_bench_out.npy') - npu_out_path = os.path.join(biased_data_dir, f'{api_name}_npu_out.npy') - np.save(bench_out_path, bench_out.contiguous().cpu().detach().numpy()) - np.save(npu_out_path, npu_out.contiguous().cpu().detach().numpy()) - def _compare_core_wrapper(self, bench_out, npu_out): diff --git a/debug/accuracy_tools/api_accuracy_checker/run_ut/run_ut.py b/debug/accuracy_tools/api_accuracy_checker/run_ut/run_ut.py index ca5b64808..e5737b511 100644 --- a/debug/accuracy_tools/api_accuracy_checker/run_ut/run_ut.py +++ b/debug/accuracy_tools/api_accuracy_checker/run_ut/run_ut.py @@ -63,7 +63,7 @@ def generate_npu_params(cpu_args, cpu_kwargs, need_backward): return npu_args, npu_kwargs -def run_ut(forward_file, backward_file, out_path, save_error_data, save_biased_data): +def run_ut(forward_file, backward_file, out_path, save_error_data): print_info_log("start UT test") forward_content = get_json_contents(forward_file) backward_content = get_json_contents(backward_file) @@ -73,7 +73,7 @@ def run_ut(forward_file, backward_file, out_path, save_error_data, save_biased_d try: grad_out, npu_grad_out, npu_out, out = run_torch_api(api_full_name, api_setting_dict, backward_content, api_info_dict) - compare.compare_output(api_full_name, out, npu_out, grad_out, npu_grad_out, save_biased_data) + compare.compare_output(api_full_name, out, npu_out, grad_out, npu_grad_out) except Exception as err: [_, api_name, _] = api_full_name.split("*") if "not implemented for 'Half'" in str(err): @@ -171,8 +171,6 @@ def _run_ut_parser(parser): default=False, required=False) parser.add_argument("-d", "--device", dest="device_id", type=int, help=" set NPU device id to run ut", default=0, required=False) - parser.add_argument('-save_biased_data', dest="save_biased_data", action="store_true", - help=" Save compare biased api output.", required=False) def _run_ut(): @@ -192,8 +190,7 @@ def _run_ut(): raise ValueError("The forward_input_file and backward_input_file should be a json file!") out_path = os.path.realpath(args.out_path) if args.out_path else "./" save_error_data = args.save_error_data - save_biased_data = args.save_biased_data - run_ut(forward_file, backward_file, out_path, save_error_data, save_biased_data) + run_ut(forward_file, backward_file, out_path, save_error_data) if __name__ == '__main__': -- Gitee From 04effc859c6dc0d8614a95bd5793170ac3543c65 Mon Sep 17 00:00:00 2001 From: l30044004 Date: Fri, 18 Aug 2023 16:40:47 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=9B=B8=E5=AF=B9?= =?UTF-8?q?=E8=AF=AF=E5=B7=AE=E5=8F=8C=E5=8D=83=E5=88=86=E4=B9=8B=E4=B8=80?= =?UTF-8?q?=E3=80=81=E5=8F=8C=E4=B8=87=E5=88=86=E4=B9=8B=E4=B8=80=E6=AF=94?= =?UTF-8?q?=E4=BE=8B=E6=8C=87=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api_accuracy_checker/compare/algorithm.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py b/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py index 9416869ed..8ca5a7dab 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py @@ -63,18 +63,17 @@ def get_max_rel_err(n_value, b_value): def get_rel_err_ratio_thousandth(n_value, b_value): - n_value, b_value, msg = get_msg_and_handle_value(n_value, b_value) - rel_errs = np.abs((n_value - b_value) / b_value) - ratio = np.divide(np.sum(rel_errs < 0.001), np.size(rel_errs)) - bool_result = ratio > 0.999 - return ratio, bool_result, msg + return get_rel_err_ratio(n_value, b_value, 0.001) def get_rel_err_ratio_ten_thousandth(n_value, b_value): + return get_rel_err_ratio(n_value, b_value, 0.0001) + +def get_rel_err_ratio(n_value, b_value, index): n_value, b_value, msg = get_msg_and_handle_value(n_value, b_value) rel_errs = np.abs((n_value - b_value) / b_value) - ratio = np.divide(np.sum(rel_errs < 0.0001), np.size(rel_errs)) - bool_result = ratio > 0.9999 + ratio = np.divide(np.sum(rel_errs < index), np.size(rel_errs)) + bool_result = ratio > (1 - index) return ratio, bool_result, msg -- Gitee From 743f629251ca486094a44db6f8fc7a48a7d970c5 Mon Sep 17 00:00:00 2001 From: l30044004 Date: Sat, 19 Aug 2023 10:42:27 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=AF=94=E5=AF=B9?= =?UTF-8?q?=E7=BB=93=E6=9E=9Cdtype?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api_accuracy_checker/compare/algorithm.py | 37 +++++++++++++++---- .../api_accuracy_checker/compare/compare.py | 17 +++++++-- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py b/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py index 8ca5a7dab..953fdb2d0 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py @@ -67,7 +67,11 @@ def get_rel_err_ratio_thousandth(n_value, b_value): def get_rel_err_ratio_ten_thousandth(n_value, b_value): - return get_rel_err_ratio(n_value, b_value, 0.0001) + ratio, bool_result, msg = get_rel_err_ratio(n_value, b_value, 0.0001) + if b_value.dtype == np.float16: + msg = f"This indicator is not used to evaluate {b_value.dtype} data" + return ratio, CompareConst.NA, msg + return ratio, bool_result, msg def get_rel_err_ratio(n_value, b_value, index): n_value, b_value, msg = get_msg_and_handle_value(n_value, b_value) @@ -146,33 +150,50 @@ def flatten_compare_result(result): def compare_core(bench_out, npu_out, alg): msg = "" if not isinstance(bench_out, type(npu_out)): - return CompareConst.NAN, False, "bench and npu output type is different." + return CompareConst.NAN, False, "bench and npu output type is different.", CompareConst.NAN, CompareConst.NAN if isinstance(bench_out, (list, tuple)): - compare_result, test_success = [], True + compare_result, test_success, bench_dtype, npu_dtype = [], True, [], [] if len(bench_out) != len(npu_out): - return CompareConst.NAN, False, "bench and npu output structure is different" + return CompareConst.NAN, False, "bench and npu output structure is different", CompareConst.NAN, CompareConst.NAN for b_out_i, n_out_i in zip(bench_out, npu_out): - compare_result_i, test_success_i = compare_core(b_out_i, n_out_i, alg) + compare_result_i, test_success_i, bench_dtype_i, npu_dtype_i = compare_core(b_out_i, n_out_i, alg) compare_result.append(compare_result_i) test_success = test_success and test_success_i + bench_dtype.append(bench_dtype_i) + npu_dtype.append(npu_dtype_i) elif isinstance(bench_out, dict): b_keys, n_keys = set(bench_out.keys()), set(npu_out.keys()) if b_keys != n_keys: - compare_result, test_success, msg = CompareConst.NAN, False, "bench and npu output dict keys are different" - compare_result, test_success = compare_core(list(bench_out.values()), list(npu_out.values())) + compare_result, test_success, msg = CompareConst.NAN, False, "bench and npu output dict keys are different", \ + CompareConst.NAN, CompareConst.NAN + compare_result, test_success, bench_dtype, npu_dtype = compare_core(list(bench_out.values()), list(npu_out.values()), alg) elif isinstance(bench_out, torch.Tensor): compare_result, test_success, msg = compare_torch_tensor(bench_out.detach().numpy(), npu_out.detach().cpu().numpy(), alg) + bench_dtype = str(bench_out.dtype) + npu_dtype = str(npu_out.dtype) elif isinstance(bench_out, (bool, int, float, str)): compare_result, test_success, msg = compare_builtin_type(bench_out, npu_out) + bench_dtype = str(type(bench_out)) + npu_dtype = str(type(npu_out)) elif bench_out is None: compare_result, test_success, msg = CompareConst.NA, True, "output is None" + bench_dtype = CompareConst.NAN + npu_dtype = CompareConst.NAN else: compare_result, test_success, msg = CompareConst.NA, True, "Unexpected output type \ in compare_core: {}".format(type(bench_out)) + bench_dtype = CompareConst.NAN + npu_dtype = CompareConst.NAN if isinstance(compare_result, list): compare_result = flatten_compare_result(compare_result) else: compare_result = [(compare_result, str(test_success), msg)] - return compare_result, test_success + if isinstance(bench_dtype, list): + bench_dtype = flatten_compare_result(bench_dtype) + npu_dtype = flatten_compare_result(npu_dtype) + else: + bench_dtype = [bench_dtype] + npu_dtype = [npu_dtype] + return compare_result, test_success, bench_dtype, npu_dtype diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py index 209234150..dd2d5f3b0 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py @@ -67,7 +67,8 @@ class Comparator: def write_detail_csv(self): test_rows = [[ - "Subject", "Cosine Similarity", "Cosine Similarity Pass", "Cosine Similarity Message", + "Subject", "Bench Dtype", "NPU Dtype", + "Cosine Similarity", "Cosine Similarity Pass", "Cosine Similarity Message", "Max Rel Error", "Max Rel Err Pass", "Max Rel Err Message", "Thousandth Rel Error Ratio", "Thousandth Rel Error Ratio Pass", "Thousandth Rel Error Ratio Message", "Ten Thousandth Rel Error Ratio", "Ten Thousandth Rel Error Ratio Pass", "Ten Thousandth Rel Error Ratio Message", @@ -120,17 +121,27 @@ class Comparator: def _compare_core_wrapper(self, bench_out, npu_out): detailed_result_total = [] + bench_dtype_total = [] + npu_dtype_total = [] test_success_total = True for name in self.compare_alg.keys(): alg = self.compare_alg[name][0] - detailed_result, test_success = compare_core(bench_out, npu_out, alg) - if name not in ["Max Relative Error", "Thousandth Relative Error Ratio", "Ten Thousandth Relative Error Ratio"]: + detailed_result, test_success, bench_dtype, npu_dtype = compare_core(bench_out, npu_out, alg) + bench_dtype_total = bench_dtype + npu_dtype_total = npu_dtype + if name != "Max Relative Error" and test_success != CompareConst.NA: test_success_total = test_success_total and test_success if detailed_result_total: for i in range(len(detailed_result_total)): detailed_result_total[i] += detailed_result[i] else: detailed_result_total = detailed_result + # dtype加到所有指标的前面 + for i in range(len(detailed_result_total)): + detailed_result = list(detailed_result_total[i]) + detailed_result.insert(0, bench_dtype_total[i]) + detailed_result.insert(1, npu_dtype_total[i]) + detailed_result_total[i] = tuple(detailed_result) return test_success_total, detailed_result_total @staticmethod -- Gitee From 31fba0db281906fcea3b28671d1478ccc52116f1 Mon Sep 17 00:00:00 2001 From: l30044004 Date: Mon, 21 Aug 2023 14:37:12 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E9=A2=84=E6=A3=80=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E9=92=88=E5=AF=B9=E6=9C=AA=E8=BE=BE=E5=88=B0=E9=A2=84=E8=AE=BE?= =?UTF-8?q?=E6=A0=87=E5=87=86=E7=9A=84api=E4=BF=9D=E5=AD=98=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api_accuracy_checker/compare/algorithm.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py b/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py index 953fdb2d0..c8ecea17b 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py @@ -73,11 +73,11 @@ def get_rel_err_ratio_ten_thousandth(n_value, b_value): return ratio, CompareConst.NA, msg return ratio, bool_result, msg -def get_rel_err_ratio(n_value, b_value, index): +def get_rel_err_ratio(n_value, b_value, thresholding): n_value, b_value, msg = get_msg_and_handle_value(n_value, b_value) rel_errs = np.abs((n_value - b_value) / b_value) - ratio = np.divide(np.sum(rel_errs < index), np.size(rel_errs)) - bool_result = ratio > (1 - index) + ratio = np.divide(np.sum(rel_errs < thresholding), np.size(rel_errs)) + bool_result = ratio > (1 - thresholding) return ratio, bool_result, msg -- Gitee