From 57faf3cd55a70942ee70ba9fb38387a63401e620 Mon Sep 17 00:00:00 2001 From: sunyiming Date: Tue, 8 Aug 2023 03:28:14 +0000 Subject: [PATCH 1/3] update debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py. Signed-off-by: sunyiming --- .../api_accuracy_checker/compare/algorithm.py | 13 +++++-------- 1 file changed, 5 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 17243a74158..73178f463fa 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py @@ -45,8 +45,8 @@ def cosine_standard(compare_result): def cosine_sim(cpu_output, npu_output): - n_value = npu_output.cpu().detach().numpy().reshape(-1) - b_value = cpu_output.detach().numpy().reshape(-1) + n_value = npu_output.cpu().detach().numpy().flatten() + b_value = cpu_output.detach().numpy().flatten() cos = CompareConst.NA np.seterr(divide="ignore", invalid="ignore") if len(n_value) == 1: @@ -54,15 +54,12 @@ def cosine_sim(cpu_output, npu_output): return get_max_rel_err(n_value, b_value) if n_value.dtype == np.uint8: return compare_uint8_data(n_value, b_value) - n_max = np.max(np.abs(n_value)) - b_max = np.max(np.abs(b_value)) + n_max, b_max = np.max(np.abs(n_value)), np.max(np.abs(b_value)) if n_max <= np.finfo(float).eps and b_max <= np.finfo(float).eps: return cos, True - elif n_max <= np.finfo(float).eps: - print_warn_log("All the data is Zero in npu dump data. Compare by relative error.") + elif n_max <= np.finfo(float).eps or b_max <= np.finfo(float).eps: + print_warn_log("All the data is Zero in either npu dump data or bench dump data. Compare by relative error.") return get_max_rel_err(n_value, b_value) - elif b_max <= np.finfo(float).eps: - print_warn_log("All the data is Zero in bench dump data. Compare by relative error.") else: n_value = n_value.astype(float) / n_max b_value = b_value.astype(float) / b_max -- Gitee From 462ee4d06577e5ceabed9844d731546f1e4df1ec Mon Sep 17 00:00:00 2001 From: sunyiming Date: Tue, 8 Aug 2023 03:30:18 +0000 Subject: [PATCH 2/3] update debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py. Signed-off-by: sunyiming --- .../accuracy_tools/api_accuracy_checker/compare/algorithm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py b/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py index 73178f463fa..d0f7749fe40 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py @@ -45,8 +45,8 @@ def cosine_standard(compare_result): def cosine_sim(cpu_output, npu_output): - n_value = npu_output.cpu().detach().numpy().flatten() - b_value = cpu_output.detach().numpy().flatten() + n_value = npu_output.cpu().detach().numpy().reshape(-1) + b_value = cpu_output.detach().numpy().reshape(-1) cos = CompareConst.NA np.seterr(divide="ignore", invalid="ignore") if len(n_value) == 1: -- Gitee From 19e40b8867e234ed3616068eaf28b5df95591e41 Mon Sep 17 00:00:00 2001 From: sunyiming Date: Tue, 8 Aug 2023 03:32:40 +0000 Subject: [PATCH 3/3] update debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py. Signed-off-by: sunyiming --- debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py b/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py index d0f7749fe40..5f0ac6a5c59 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/algorithm.py @@ -58,7 +58,7 @@ def cosine_sim(cpu_output, npu_output): if n_max <= np.finfo(float).eps and b_max <= np.finfo(float).eps: return cos, True elif n_max <= np.finfo(float).eps or b_max <= np.finfo(float).eps: - print_warn_log("All the data is Zero in either npu dump data or bench dump data. Compare by relative error.") + print_warn_log("All the data is Zero in either npu or bench dump data. Compare by relative error.") return get_max_rel_err(n_value, b_value) else: n_value = n_value.astype(float) / n_max -- Gitee