From 79f5639ccc425873e68cef494fd22bc16ac640df Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Tue, 15 Aug 2023 07:02:18 +0000 Subject: [PATCH 01/15] update debug/accuracy_tools/api_accuracy_checker/compare/compare.py. Signed-off-by: jiangchangting1 --- .../api_accuracy_checker/compare/compare.py | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py index 7a1c069e2e..524c268e1e 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py @@ -3,13 +3,15 @@ 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 -from api_accuracy_checker.common.utils import get_json_contents, print_error_log, print_info_log, write_csv +from api_accuracy_checker.common.utils import get_json_contents, print_error_log, print_info_log, write_csv, write_seg_csv from api_accuracy_checker.compare.compare_utils import CompareConst class Comparator: TEST_FILE_NAME = "pretest_result.csv" DETAIL_TEST_FILE_NAME = "pretest_details.csv" + TEST_SEG_FILE_NAME = "pretest_result_seg.csv" + DETAIL_TEST_SEG_FILE_NAME = "pretest_details_seg.csv" # consts for result csv COLUMN_API_NAME = "API name" COLUMN_FORWARD_SUCCESS = "Forward Test Success" @@ -19,6 +21,8 @@ class Comparator: def __init__(self, result_save_path, stack_info_json_path=None): self.save_path = os.path.join(result_save_path, self.TEST_FILE_NAME) self.detail_save_path = os.path.join(result_save_path, self.DETAIL_TEST_FILE_NAME) + self.seg_save_path = os.path.join(result_save_path, self.TEST_SEG_FILE_NAME) + self.seg_detail_save_path = os.path.join(result_save_path, self.DETAIL_TEST_SEG_FILE_NAME) if stack_info_json_path: self.stack_info = get_json_contents(stack_info_json_path) else: @@ -84,8 +88,43 @@ class Comparator: write_csv(test_rows, self.detail_save_path) + def write_seg_summary_csv(self): + test_rows = [] + if self.stack_info: + test_rows[0].append(self.COLUMN_STACK_INFO) + for result in self.test_seg_results: + name = result[0] + df_row = list(result[:3]) + if self.stack_info: + stack_info = "\n".join(self.stack_info[name]) + df_row.append(stack_info) + test_rows.append(df_row) + write_seg_csv(test_rows, self.seg_save_path) + + def write_seg_detail_csv(self): + test_rows = [] + for test_result in self.test_seg_results: + subject_prefix = test_result[0] + fwd_result = test_result[3] + bwd_result = test_result[4] + if isinstance(fwd_result, list): + for i, test_subject in enumerate(fwd_result): + subject = subject_prefix + ".forward.output." + str(i) + test_rows.append([subject] + list(test_subject)) + if isinstance(bwd_result, list): + for i, test_subject in enumerate(bwd_result): + subject = subject_prefix + ".backward.output." + str(i) + test_rows.append([subject] + list(test_subject)) + + write_seg_csv(test_rows, self.seg_detail_save_path) + def record_results(self, *args): self.test_results.append(args) + self.test_seg_results.append(args) + if len(self.test_seg_results) == 100: + self.write_seg_summary_csv() + self.write_seg_detail_csv() + self.test_seg_results = [] def register_compare_algorithm(self, name, compare_func, standard): self.compare_alg.update({name: (compare_func, standard)}) -- Gitee From 97347935ba7d3d5475d45c57c0e55acee0d2979a Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Tue, 15 Aug 2023 07:03:20 +0000 Subject: [PATCH 02/15] update debug/accuracy_tools/api_accuracy_checker/compare/compare.py. Signed-off-by: jiangchangting1 --- debug/accuracy_tools/api_accuracy_checker/compare/compare.py | 1 + 1 file changed, 1 insertion(+) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py index 524c268e1e..c6bad71cff 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py @@ -32,6 +32,7 @@ class Comparator: self.register_compare_algorithm("Max Relative Error", get_max_rel_err, None) self.register_compare_algorithm("Default: isEqual", compare_builtin_type, None) self.test_results = [] + self.test_seg_results = [] self.test_result_cnt = { "forward_fail_num": 0, "backward_fail_num": 0, "forward_and_backward_fail_num": 0, "success_num": 0 } -- Gitee From 1aa13116b718cd7dad62a37de9c26f5c829872f5 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Tue, 15 Aug 2023 07:04:55 +0000 Subject: [PATCH 03/15] update debug/accuracy_tools/api_accuracy_checker/common/utils.py. Signed-off-by: jiangchangting1 --- debug/accuracy_tools/api_accuracy_checker/common/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/debug/accuracy_tools/api_accuracy_checker/common/utils.py b/debug/accuracy_tools/api_accuracy_checker/common/utils.py index 4d9db1aecc..cb116177c8 100644 --- a/debug/accuracy_tools/api_accuracy_checker/common/utils.py +++ b/debug/accuracy_tools/api_accuracy_checker/common/utils.py @@ -190,6 +190,10 @@ def write_csv(data, filepath): data_frame = pd.DataFrame(columns=data) data_frame.to_csv(filepath, index=False) +def write_seg_csv(data, filepath): + data_frame = pd.DataFrame(columns=data) + data_frame.to_csv(filepath, mode='a', index=False) + def _print_log(level, msg): current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))) pid = os.getgid() -- Gitee From 34773f24333ebb4b9fc95b5e50f4f63f07dd9d23 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Tue, 15 Aug 2023 07:06:01 +0000 Subject: [PATCH 04/15] update debug/accuracy_tools/api_accuracy_checker/run_ut/run_ut.py. Signed-off-by: jiangchangting1 --- debug/accuracy_tools/api_accuracy_checker/run_ut/run_ut.py | 2 ++ 1 file changed, 2 insertions(+) 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 ee0a45e6fa..146faacfc1 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 @@ -83,6 +83,8 @@ def run_ut(forward_file, backward_file, out_path, save_error_data): compare.print_pretest_result() compare.write_compare_csv() + compare.write_seg_summary_csv() + compare.write_seg_detail_csv() def run_torch_api(api_full_name, api_setting_dict, backward_content, api_info_dict): -- Gitee From ab755df68ea00e0f8db8a70748b3615cb9ad66e4 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Tue, 22 Aug 2023 07:36:52 +0000 Subject: [PATCH 05/15] update debug/accuracy_tools/api_accuracy_checker/compare/compare.py. Signed-off-by: jiangchangting1 --- .../api_accuracy_checker/compare/compare.py | 69 +++++++------------ 1 file changed, 24 insertions(+), 45 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py index e80e30d73b..65f06b3740 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py @@ -3,7 +3,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, 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.common.utils import get_json_contents, print_error_log, print_info_log, write_csv, write_seg_csv from api_accuracy_checker.compare.compare_utils import CompareConst @@ -39,6 +39,7 @@ class Comparator: "forward_fail_num": 0, "backward_fail_num": 0, "forward_and_backward_fail_num": 0, "success_num": 0 } self.result_save_path = result_save_path + self.write_csv_title() def print_pretest_result(self): res_dict = { @@ -54,63 +55,41 @@ class Comparator: print_info_log(info_tb) def write_compare_csv(self): - self.write_summary_csv() - self.write_detail_csv() - - def write_summary_csv(self): - test_rows = [[self.COLUMN_API_NAME, self.COLUMN_FORWARD_SUCCESS, self.COLUMN_BACKWARD_SUCCESS]] - if self.stack_info: - test_rows[0].append(self.COLUMN_STACK_INFO) - for result in self.test_results: - name = result[0] - df_row = list(result[:3]) - if self.stack_info: - stack_info = "\n".join(self.stack_info[name]) - df_row.append(stack_info) - test_rows.append(df_row) - write_csv(test_rows, self.save_path) - - def write_detail_csv(self): - test_rows = [[ - "Subject", "Bench Dtype", "NPU Dtype", - "Cosine Similarity", "Cosine Similarity Pass", "Cosine Similarity Message", + self.write_summary_csv(self.test_results, self.save_path) + self.write_detail_csv(self.test_results, self.detail_save_path) + self.write_summary_csv(self.test_seg_results, self.seg_save_path) + self.write_detail_csv(self.test_seg_results, self.seg_detail_save_path) + + def write_csv_title(self): + summary_test_rows = [[self.COLUMN_API_NAME, self.COLUMN_FORWARD_SUCCESS, self.COLUMN_BACKWARD_SUCCESS]] + write_csv(summary_test_rows, self.save_path) + write_csv(summary_test_rows, self.seg_save_path) + detail_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" - ]] - for test_result in self.test_results: - subject_prefix = test_result[0] - fwd_result = test_result[3] - bwd_result = test_result[4] - if isinstance(fwd_result, list): - for i, test_subject in enumerate(fwd_result): - subject = subject_prefix + ".forward.output." + str(i) - test_rows.append([subject] + list(test_subject)) - if isinstance(bwd_result, list): - for i, test_subject in enumerate(bwd_result): - subject = subject_prefix + ".backward.output." + str(i) - test_rows.append([subject] + list(test_subject)) + ]] + write_csv(detail_test_rows, self.detail_save_path) + write_csv(detail_test_rows, self.seg_detail_save_path) - write_csv(test_rows, self.detail_save_path) - def write_seg_summary_csv(self): + def write_summary_csv(self, test_results, data_path): test_rows = [] if self.stack_info: test_rows[0].append(self.COLUMN_STACK_INFO) - for result in self.test_seg_results: + for result in test_results: name = result[0] df_row = list(result[:3]) if self.stack_info: stack_info = "\n".join(self.stack_info[name]) df_row.append(stack_info) test_rows.append(df_row) - write_seg_csv(test_rows, self.seg_save_path) + write_seg_csv(test_rows, data_path) - def write_seg_detail_csv(self): + def write_detail_csv(self, test_results, data_path): test_rows = [] - for test_result in self.test_seg_results: + for test_result in test_results: subject_prefix = test_result[0] fwd_result = test_result[3] bwd_result = test_result[4] @@ -123,14 +102,14 @@ class Comparator: subject = subject_prefix + ".backward.output." + str(i) test_rows.append([subject] + list(test_subject)) - write_seg_csv(test_rows, self.seg_detail_save_path) + write_seg_csv(test_rows, data_path) def record_results(self, *args): self.test_results.append(args) self.test_seg_results.append(args) if len(self.test_seg_results) == 100: - self.write_seg_summary_csv() - self.write_seg_detail_csv() + self.write_summary_csv(self.test_seg_results, self.seg_save_path) + self.write_detail_csv(self.test_seg_results, self.seg_detail_save_path) self.test_seg_results = [] def register_compare_algorithm(self, name, compare_func, standard): -- Gitee From 8ed598bebec9a60a53249b754df884e748be83b3 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Wed, 23 Aug 2023 03:10:25 +0000 Subject: [PATCH 06/15] update debug/accuracy_tools/api_accuracy_checker/compare/compare.py. Signed-off-by: jiangchangting1 --- debug/accuracy_tools/api_accuracy_checker/compare/compare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py index 192d95a4b6..e39bb62ece 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py @@ -64,7 +64,7 @@ class Comparator: summary_test_rows = [[self.COLUMN_API_NAME, self.COLUMN_FORWARD_SUCCESS, self.COLUMN_BACKWARD_SUCCESS]] write_csv(summary_test_rows, self.save_path) write_csv(summary_test_rows, self.seg_save_path) - test_rows = [[ + detail_test_rows = [[ "Subject", "Bench Dtype", "NPU Dtype", "Cosine Similarity", "Cosine Similarity Message", "Max Rel Error", "Max Rel Err Message", -- Gitee From a7fbc7e756f67a95aa4c7ae1cb8c0f54ab2a1fa3 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Wed, 23 Aug 2023 03:12:27 +0000 Subject: [PATCH 07/15] update debug/accuracy_tools/api_accuracy_checker/compare/compare.py. Signed-off-by: jiangchangting1 --- .../accuracy_tools/api_accuracy_checker/compare/compare.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py index e39bb62ece..7c7ab1c9f6 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py @@ -110,10 +110,9 @@ class Comparator: def record_results(self, *args): self.test_results.append(args) self.test_seg_results.append(args) - if len(self.test_seg_results) == 100: - self.write_summary_csv(self.test_seg_results, self.seg_save_path) - self.write_detail_csv(self.test_seg_results, self.seg_detail_save_path) - self.test_seg_results = [] + self.write_summary_csv(self.test_seg_results, self.seg_save_path) + self.write_detail_csv(self.test_seg_results, self.seg_detail_save_path) + self.test_seg_results = [] def register_compare_algorithm(self, name, compare_func, standard): self.compare_alg.update({name: (compare_func, standard)}) -- Gitee From d7f1e7dcbf42531c6eb8cbf8521a5ca7c9faa009 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Wed, 23 Aug 2023 03:13:36 +0000 Subject: [PATCH 08/15] update debug/accuracy_tools/api_accuracy_checker/common/utils.py. Signed-off-by: jiangchangting1 --- .../api_accuracy_checker/common/utils.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/common/utils.py b/debug/accuracy_tools/api_accuracy_checker/common/utils.py index cb116177c8..5f11c7f625 100644 --- a/debug/accuracy_tools/api_accuracy_checker/common/utils.py +++ b/debug/accuracy_tools/api_accuracy_checker/common/utils.py @@ -187,12 +187,14 @@ def read_json(file): return obj def write_csv(data, filepath): - data_frame = pd.DataFrame(columns=data) - data_frame.to_csv(filepath, index=False) + with open(filepath, 'w') as f: + writer = csv.writer(f) + writer.writerows(data) def write_seg_csv(data, filepath): - data_frame = pd.DataFrame(columns=data) - data_frame.to_csv(filepath, mode='a', index=False) + with open(filepath, 'a') as f: + writer = csv.writer(f) + writer.writerows(data) def _print_log(level, msg): current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(int(time.time()))) -- Gitee From ee28d0bdea2a651e7f263cd61c8cdc4ebf0eea09 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Wed, 23 Aug 2023 09:21:50 +0000 Subject: [PATCH 09/15] update debug/accuracy_tools/api_accuracy_checker/run_ut/run_ut.py. Signed-off-by: jiangchangting1 --- debug/accuracy_tools/api_accuracy_checker/run_ut/run_ut.py | 3 --- 1 file changed, 3 deletions(-) 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 391f5d4500..7fcb0dbd96 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 @@ -86,9 +86,6 @@ def run_ut(forward_file, backward_file, out_path, save_error_data): print_error_log(f"Run {api_full_name} UT Error: %s" % str(err)) compare.print_pretest_result() - compare.write_compare_csv() - compare.write_seg_summary_csv() - compare.write_seg_detail_csv() def run_torch_api(api_full_name, api_setting_dict, backward_content, api_info_dict): -- Gitee From 451144a1bd5ced13d7ac950dc0855dde10b5470e Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Wed, 23 Aug 2023 09:28:21 +0000 Subject: [PATCH 10/15] update debug/accuracy_tools/api_accuracy_checker/compare/compare.py. Signed-off-by: jiangchangting1 --- .../api_accuracy_checker/compare/compare.py | 76 +++++++++---------- 1 file changed, 34 insertions(+), 42 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py index 7c7ab1c9f6..a38cec9d15 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py @@ -10,8 +10,7 @@ from api_accuracy_checker.compare.compare_utils import CompareConst class Comparator: TEST_FILE_NAME = "pretest_result.csv" DETAIL_TEST_FILE_NAME = "pretest_details.csv" - TEST_SEG_FILE_NAME = "pretest_result_seg.csv" - DETAIL_TEST_SEG_FILE_NAME = "pretest_details_seg.csv" + # consts for result csv COLUMN_API_NAME = "API name" COLUMN_FORWARD_SUCCESS = "Forward Test Success" @@ -21,8 +20,8 @@ class Comparator: def __init__(self, result_save_path, stack_info_json_path=None): self.save_path = os.path.join(result_save_path, self.TEST_FILE_NAME) self.detail_save_path = os.path.join(result_save_path, self.DETAIL_TEST_FILE_NAME) - self.seg_save_path = os.path.join(result_save_path, self.TEST_SEG_FILE_NAME) - self.seg_detail_save_path = os.path.join(result_save_path, self.DETAIL_TEST_SEG_FILE_NAME) + + if stack_info_json_path: self.stack_info = get_json_contents(stack_info_json_path) else: @@ -33,8 +32,7 @@ class Comparator: 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_seg_results = [] + self.test_result_cnt = { "forward_fail_num": 0, "backward_fail_num": 0, "forward_and_backward_fail_num": 0, "success_num": 0 } @@ -54,11 +52,7 @@ class Comparator: info_tb = str(tb) print_info_log(info_tb) - def write_compare_csv(self): - self.write_summary_csv(self.test_results, self.save_path) - self.write_detail_csv(self.test_results, self.detail_save_path) - self.write_summary_csv(self.test_seg_results, self.seg_save_path) - self.write_detail_csv(self.test_seg_results, self.seg_detail_save_path) + def write_csv_title(self): summary_test_rows = [[self.COLUMN_API_NAME, self.COLUMN_FORWARD_SUCCESS, self.COLUMN_BACKWARD_SUCCESS]] @@ -74,45 +68,43 @@ class Comparator: "Pass" ]] write_csv(detail_test_rows, self.detail_save_path) - write_csv(detail_test_rows, self.seg_detail_save_path) - def write_summary_csv(self, test_results, data_path): + + def write_summary_csv(self, test_result): test_rows = [] if self.stack_info: test_rows[0].append(self.COLUMN_STACK_INFO) - for result in test_results: - name = result[0] - df_row = list(result[:3]) - if self.stack_info: - stack_info = "\n".join(self.stack_info[name]) - df_row.append(stack_info) - test_rows.append(df_row) - write_seg_csv(test_rows, data_path) - - def write_detail_csv(self, test_results, data_path): + + name = test_result[0] + df_row = list(test_result[:3]) + if self.stack_info: + stack_info = "\n".join(self.stack_info[name]) + df_row.append(stack_info) + test_rows.append(df_row) + write_seg_csv(test_rows, self.save_path) + + def write_detail_csv(self, test_result): test_rows = [] - for test_result in test_results: - subject_prefix = test_result[0] - fwd_result = test_result[3] - bwd_result = test_result[4] - if isinstance(fwd_result, list): - for i, test_subject in enumerate(fwd_result): - subject = subject_prefix + ".forward.output." + str(i) - test_rows.append([subject] + list(test_subject)) - if isinstance(bwd_result, list): - for i, test_subject in enumerate(bwd_result): - subject = subject_prefix + ".backward.output." + str(i) - test_rows.append([subject] + list(test_subject)) - - write_seg_csv(test_rows, data_path) + + subject_prefix = test_result[0] + fwd_result = test_result[3] + bwd_result = test_result[4] + if isinstance(fwd_result, list): + for i, test_subject in enumerate(fwd_result): + subject = subject_prefix + ".forward.output." + str(i) + test_rows.append([subject] + list(test_subject)) + if isinstance(bwd_result, list): + for i, test_subject in enumerate(bwd_result): + subject = subject_prefix + ".backward.output." + str(i) + test_rows.append([subject] + list(test_subject)) + + write_seg_csv(test_rows, self.detail_save_path) def record_results(self, *args): - self.test_results.append(args) - self.test_seg_results.append(args) - self.write_summary_csv(self.test_seg_results, self.seg_save_path) - self.write_detail_csv(self.test_seg_results, self.seg_detail_save_path) - self.test_seg_results = [] + self.write_summary_csv(args) + self.write_detail_csv(args) + def register_compare_algorithm(self, name, compare_func, standard): self.compare_alg.update({name: (compare_func, standard)}) -- Gitee From c7f746c3a2dd8d60a39df5be2bf9547a143821de Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Wed, 23 Aug 2023 09:32:37 +0000 Subject: [PATCH 11/15] update debug/accuracy_tools/api_accuracy_checker/compare/compare.py. Signed-off-by: jiangchangting1 --- .../accuracy_tools/api_accuracy_checker/compare/compare.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py index a38cec9d15..300f762097 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py @@ -20,8 +20,6 @@ class Comparator: def __init__(self, result_save_path, stack_info_json_path=None): self.save_path = os.path.join(result_save_path, self.TEST_FILE_NAME) self.detail_save_path = os.path.join(result_save_path, self.DETAIL_TEST_FILE_NAME) - - if stack_info_json_path: self.stack_info = get_json_contents(stack_info_json_path) else: @@ -57,7 +55,7 @@ class Comparator: def write_csv_title(self): summary_test_rows = [[self.COLUMN_API_NAME, self.COLUMN_FORWARD_SUCCESS, self.COLUMN_BACKWARD_SUCCESS]] write_csv(summary_test_rows, self.save_path) - write_csv(summary_test_rows, self.seg_save_path) + detail_test_rows = [[ "Subject", "Bench Dtype", "NPU Dtype", "Cosine Similarity", "Cosine Similarity Message", @@ -69,8 +67,6 @@ class Comparator: ]] write_csv(detail_test_rows, self.detail_save_path) - - def write_summary_csv(self, test_result): test_rows = [] if self.stack_info: -- Gitee From 4fb04dd27c8b3fdddbde4c8dbe27eea42076e6ba Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Wed, 23 Aug 2023 09:35:18 +0000 Subject: [PATCH 12/15] update debug/accuracy_tools/api_accuracy_checker/compare/compare.py. Signed-off-by: jiangchangting1 --- debug/accuracy_tools/api_accuracy_checker/compare/compare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py index 300f762097..fa778b2ad3 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py @@ -35,7 +35,7 @@ class Comparator: "forward_fail_num": 0, "backward_fail_num": 0, "forward_and_backward_fail_num": 0, "success_num": 0 } self.result_save_path = result_save_path - self.write_csv_title() + self.write_csv_title() def print_pretest_result(self): res_dict = { -- Gitee From 257343c84ecfee539248df96571a988c92118c75 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Wed, 23 Aug 2023 09:36:57 +0000 Subject: [PATCH 13/15] update debug/accuracy_tools/api_accuracy_checker/compare/compare.py. Signed-off-by: jiangchangting1 --- debug/accuracy_tools/api_accuracy_checker/compare/compare.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py index fa778b2ad3..c5b09d56b8 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py @@ -35,7 +35,7 @@ class Comparator: "forward_fail_num": 0, "backward_fail_num": 0, "forward_and_backward_fail_num": 0, "success_num": 0 } self.result_save_path = result_save_path - self.write_csv_title() + self.write_csv_title() def print_pretest_result(self): res_dict = { -- Gitee From afb9d97667435ed9f795f85b77a6ba5c6a4527f4 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Thu, 24 Aug 2023 03:25:55 +0000 Subject: [PATCH 14/15] update debug/accuracy_tools/api_accuracy_checker/common/utils.py. Signed-off-by: jiangchangting1 --- debug/accuracy_tools/api_accuracy_checker/common/utils.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/common/utils.py b/debug/accuracy_tools/api_accuracy_checker/common/utils.py index 5f11c7f625..a6241ea9ba 100644 --- a/debug/accuracy_tools/api_accuracy_checker/common/utils.py +++ b/debug/accuracy_tools/api_accuracy_checker/common/utils.py @@ -187,11 +187,6 @@ def read_json(file): return obj def write_csv(data, filepath): - with open(filepath, 'w') as f: - writer = csv.writer(f) - writer.writerows(data) - -def write_seg_csv(data, filepath): with open(filepath, 'a') as f: writer = csv.writer(f) writer.writerows(data) -- Gitee From d36aeaccd3d189cb7c455a3f7179ff0b6a856f04 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Thu, 24 Aug 2023 03:27:07 +0000 Subject: [PATCH 15/15] update debug/accuracy_tools/api_accuracy_checker/compare/compare.py. Signed-off-by: jiangchangting1 --- .../accuracy_tools/api_accuracy_checker/compare/compare.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py index c5b09d56b8..f57a8a96c1 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py @@ -3,7 +3,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, 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, write_seg_csv +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 @@ -78,7 +78,7 @@ class Comparator: stack_info = "\n".join(self.stack_info[name]) df_row.append(stack_info) test_rows.append(df_row) - write_seg_csv(test_rows, self.save_path) + write_csv(test_rows, self.save_path) def write_detail_csv(self, test_result): test_rows = [] @@ -95,7 +95,7 @@ class Comparator: subject = subject_prefix + ".backward.output." + str(i) test_rows.append([subject] + list(test_subject)) - write_seg_csv(test_rows, self.detail_save_path) + write_csv(test_rows, self.detail_save_path) def record_results(self, *args): self.write_summary_csv(args) -- Gitee