From 6e49c1fae414c754f28e5369bd7f3302aea3efa2 Mon Sep 17 00:00:00 2001 From: s30048155 Date: Mon, 25 Sep 2023 14:49:10 +0800 Subject: [PATCH 1/4] 14f --- debug/accuracy_tools/api_accuracy_checker/compare/compare.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py index 1dad82f9d6..a0df5c9869 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py @@ -95,10 +95,12 @@ class Comparator: if isinstance(fwd_result, list): for i, test_subject in enumerate(fwd_result): subject = subject_prefix + ".forward.output." + str(i) + test_subject = ["{:.14f}".format(item) if isinstance(item, float) else item for item in test_subject] 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_subject = ["{:.14f}".format(item) if isinstance(item, float) else item for item in test_subject] test_rows.append([subject] + list(test_subject)) write_csv(test_rows, self.detail_save_path) -- Gitee From 48f3af60fcede57115dd2d12abc717046f92843b Mon Sep 17 00:00:00 2001 From: s30048155 Date: Mon, 25 Sep 2023 16:07:25 +0800 Subject: [PATCH 2/4] precision --- debug/accuracy_tools/api_accuracy_checker/common/config.py | 5 ++++- .../accuracy_tools/api_accuracy_checker/compare/compare.py | 6 +++--- debug/accuracy_tools/api_accuracy_checker/config.yaml | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/common/config.py b/debug/accuracy_tools/api_accuracy_checker/common/config.py index 07dd4e6bfc..ea12113a47 100644 --- a/debug/accuracy_tools/api_accuracy_checker/common/config.py +++ b/debug/accuracy_tools/api_accuracy_checker/common/config.py @@ -19,12 +19,15 @@ class Config: 'dump_step': int, 'error_data_path': str, 'enable_dataloader': bool, - 'target_iter': int + 'target_iter': int, + 'precision': int } if not isinstance(value, validators[key]): raise ValueError(f"{key} must be {validators[key].__name__} type") if key == 'target_iter' and value < 0: raise ValueError("target_iter must be greater than 0") + if key == 'precision' and value <= 0: + raise ValueError("precision must be greater than 0") return value def __getattr__(self, item): diff --git a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py index a0df5c9869..37c04ad101 100644 --- a/debug/accuracy_tools/api_accuracy_checker/compare/compare.py +++ b/debug/accuracy_tools/api_accuracy_checker/compare/compare.py @@ -5,7 +5,7 @@ from api_accuracy_checker.compare.algorithm import compare_core, cosine_sim, cos 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_info_log, write_csv from api_accuracy_checker.compare.compare_utils import CompareConst - +from api_accuracy_checker.common.config import msCheckerConfig class Comparator: TEST_FILE_NAME = "accuracy_checking_result.csv" @@ -95,12 +95,12 @@ class Comparator: if isinstance(fwd_result, list): for i, test_subject in enumerate(fwd_result): subject = subject_prefix + ".forward.output." + str(i) - test_subject = ["{:.14f}".format(item) if isinstance(item, float) else item for item in test_subject] + test_subject = ["{:.{}f}".format(item, msCheckerConfig.precision) if isinstance(item, float) else item for item in test_subject] 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_subject = ["{:.14f}".format(item) if isinstance(item, float) else item for item in test_subject] + test_subject = ["{:.{}f}".format(item, msCheckerConfig.precision) if isinstance(item, float) else item for item in test_subject] test_rows.append([subject] + list(test_subject)) write_csv(test_rows, self.detail_save_path) diff --git a/debug/accuracy_tools/api_accuracy_checker/config.yaml b/debug/accuracy_tools/api_accuracy_checker/config.yaml index 46f0ed8d41..08f4ee0572 100644 --- a/debug/accuracy_tools/api_accuracy_checker/config.yaml +++ b/debug/accuracy_tools/api_accuracy_checker/config.yaml @@ -6,4 +6,5 @@ real_data: False dump_step: 1000 error_data_path: './' enable_dataloader: True -target_iter: 1 \ No newline at end of file +target_iter: 1 +precision: 14 \ No newline at end of file -- Gitee From 4d41d759427eb4fe42345c5dd9e6f43d66523545 Mon Sep 17 00:00:00 2001 From: s30048155 Date: Mon, 25 Sep 2023 17:07:21 +0800 Subject: [PATCH 3/4] fix --- debug/accuracy_tools/api_accuracy_checker/common/config.py | 2 +- debug/accuracy_tools/api_accuracy_checker/config.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/common/config.py b/debug/accuracy_tools/api_accuracy_checker/common/config.py index ea12113a47..2bf26d7355 100644 --- a/debug/accuracy_tools/api_accuracy_checker/common/config.py +++ b/debug/accuracy_tools/api_accuracy_checker/common/config.py @@ -26,7 +26,7 @@ class Config: raise ValueError(f"{key} must be {validators[key].__name__} type") if key == 'target_iter' and value < 0: raise ValueError("target_iter must be greater than 0") - if key == 'precision' and value <= 0: + if key == 'precision' and value < 0: raise ValueError("precision must be greater than 0") return value diff --git a/debug/accuracy_tools/api_accuracy_checker/config.yaml b/debug/accuracy_tools/api_accuracy_checker/config.yaml index 08f4ee0572..66ba3e8939 100644 --- a/debug/accuracy_tools/api_accuracy_checker/config.yaml +++ b/debug/accuracy_tools/api_accuracy_checker/config.yaml @@ -7,4 +7,4 @@ dump_step: 1000 error_data_path: './' enable_dataloader: True target_iter: 1 -precision: 14 \ No newline at end of file +precision: 14 -- Gitee From 2289258426740777ab757228d490c4a7a7e297c2 Mon Sep 17 00:00:00 2001 From: s30048155 Date: Mon, 25 Sep 2023 17:08:13 +0800 Subject: [PATCH 4/4] update --- debug/accuracy_tools/api_accuracy_checker/config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/debug/accuracy_tools/api_accuracy_checker/config.yaml b/debug/accuracy_tools/api_accuracy_checker/config.yaml index 66ba3e8939..143629d92c 100644 --- a/debug/accuracy_tools/api_accuracy_checker/config.yaml +++ b/debug/accuracy_tools/api_accuracy_checker/config.yaml @@ -8,3 +8,4 @@ error_data_path: './' enable_dataloader: True target_iter: 1 precision: 14 + \ No newline at end of file -- Gitee