From 0312c667b6af93493f399f29c34c132d71e90573 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Tue, 28 Nov 2023 12:19:27 +0000 Subject: [PATCH 01/29] update debug/accuracy_tools/api_accuracy_checker/config.yaml. Signed-off-by: jiangchangting1 --- 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 4a1420eb463..0bd145893e8 100644 --- a/debug/accuracy_tools/api_accuracy_checker/config.yaml +++ b/debug/accuracy_tools/api_accuracy_checker/config.yaml @@ -5,4 +5,5 @@ dump_step: 1000 error_data_path: './' target_iter: [1] precision: 14 +white_list: [] \ No newline at end of file -- Gitee From e95ea0c96c75a967cdba2823fd8a98ad63dfc9d5 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Tue, 28 Nov 2023 13:55:25 +0000 Subject: [PATCH 02/29] update debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_functional.py. Signed-off-by: jiangchangting1 --- .../api_accuracy_checker/hook_module/wrap_functional.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_functional.py b/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_functional.py index a1c9af127f2..bf647e2e171 100644 --- a/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_functional.py +++ b/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_functional.py @@ -23,6 +23,7 @@ import yaml from api_accuracy_checker.hook_module.hook_module import HOOKModule from api_accuracy_checker.common.utils import torch_device_guard from ptdbg_ascend.src.python.ptdbg_ascend.common.file_check_util import FileOpen +from api_accuracy_checker.common.config import msCheckerConfig cur_path = os.path.dirname(os.path.realpath(__file__)) yaml_path = os.path.join(cur_path, "support_wrap_ops.yaml") @@ -36,7 +37,10 @@ for f in dir(torch.nn.functional): def get_functional_ops(): global WrapFunctionalOps _all_functional_ops = dir(torch.nn.functional) - return set(WrapFunctionalOps) & set(_all_functional_ops) + if msCheckerConfig.white_list: + return set(WrapFunctionalOps) & set(_all_functional_ops) & set(msCheckerConfig.white_list) + else: + return set(WrapFunctionalOps) & set(_all_functional_ops) class HOOKFunctionalOP(object): -- Gitee From 12100436179d265dfde444d4df0664df461c1afa Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Tue, 28 Nov 2023 13:56:49 +0000 Subject: [PATCH 03/29] update debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_tensor.py. Signed-off-by: jiangchangting1 --- .../api_accuracy_checker/hook_module/wrap_tensor.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_tensor.py b/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_tensor.py index 547955ec187..805b37b3e24 100644 --- a/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_tensor.py +++ b/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_tensor.py @@ -22,6 +22,7 @@ import yaml from api_accuracy_checker.hook_module.hook_module import HOOKModule from api_accuracy_checker.common.utils import torch_device_guard +from api_accuracy_checker.common.config import msCheckerConfig from ptdbg_ascend.src.python.ptdbg_ascend.common.file_check_util import FileOpen cur_path = os.path.dirname(os.path.realpath(__file__)) @@ -33,7 +34,10 @@ with FileOpen(yaml_path, 'r') as f: def get_tensor_ops(): global WrapTensorOps _tensor_ops = dir(torch._C._TensorBase) - return set(WrapTensorOps) & set(_tensor_ops) + if msCheckerConfig.white_list: + return set(WrapTensorOps) & set(_tensor_ops) & set(msCheckerConfig.white_list) + else: + return set(WrapTensorOps) & set(_tensor_ops) class HOOKTensor(object): -- Gitee From 70a460a91527e6a23fcdcb693355f41401389a2b Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Tue, 28 Nov 2023 13:57:35 +0000 Subject: [PATCH 04/29] update debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_functional.py. Signed-off-by: jiangchangting1 --- .../api_accuracy_checker/hook_module/wrap_functional.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_functional.py b/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_functional.py index bf647e2e171..1a45c8dbfd0 100644 --- a/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_functional.py +++ b/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_functional.py @@ -22,8 +22,8 @@ import yaml from api_accuracy_checker.hook_module.hook_module import HOOKModule from api_accuracy_checker.common.utils import torch_device_guard -from ptdbg_ascend.src.python.ptdbg_ascend.common.file_check_util import FileOpen from api_accuracy_checker.common.config import msCheckerConfig +from ptdbg_ascend.src.python.ptdbg_ascend.common.file_check_util import FileOpen cur_path = os.path.dirname(os.path.realpath(__file__)) yaml_path = os.path.join(cur_path, "support_wrap_ops.yaml") -- Gitee From 6373b1ebe1afe0e79ac2032fa992fb35c82cfbcc Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Tue, 28 Nov 2023 13:58:48 +0000 Subject: [PATCH 05/29] update debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_torch.py. Signed-off-by: jiangchangting1 --- .../api_accuracy_checker/hook_module/wrap_torch.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_torch.py b/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_torch.py index 70461b0acc2..de0d3e0691b 100644 --- a/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_torch.py +++ b/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_torch.py @@ -22,6 +22,7 @@ import yaml from api_accuracy_checker.hook_module.hook_module import HOOKModule from api_accuracy_checker.common.utils import torch_device_guard +from api_accuracy_checker.common.config import msCheckerConfig from ptdbg_ascend.src.python.ptdbg_ascend.common.file_check_util import FileOpen @@ -34,7 +35,10 @@ with FileOpen(yaml_path, 'r') as f: def get_torch_ops(): global WrapTorchOps _torch_ops = dir(torch._C._VariableFunctionsClass) - return set(WrapTorchOps) & set(_torch_ops) + if msCheckerConfig.white_list: + return return set(WrapTorchOps) & set(_torch_ops) & set(msCheckerConfig.white_list) + else: + return set(WrapTorchOps) & set(_torch_ops) class HOOKTorchOP(object): -- Gitee From 15f277c3179926fa9f2e0c012248e8eee4d104d8 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Tue, 28 Nov 2023 13:59:54 +0000 Subject: [PATCH 06/29] 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, 1 insertion(+), 1 deletion(-) 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 c8dee876069..7ab59d046dd 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 @@ -29,7 +29,7 @@ def init_environment(): with FileOpen(yaml_path, 'r') as f: WrapFunctionalOps = yaml.safe_load(f).get('functional') for f in dir(torch.nn.functional): - if f != "__name__": + if f != "__name__" and f in msCheckerConfig.white_list: locals().update({f: getattr(torch.nn.functional, f)}) -- Gitee From 7c469f766cdc95c46a6d56fecbcfdc92fded68b3 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Wed, 29 Nov 2023 03:18:53 +0000 Subject: [PATCH 07/29] 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 7ab59d046dd..0b5dc91e7d3 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 @@ -29,7 +29,11 @@ def init_environment(): with FileOpen(yaml_path, 'r') as f: WrapFunctionalOps = yaml.safe_load(f).get('functional') for f in dir(torch.nn.functional): - if f != "__name__" and f in msCheckerConfig.white_list: + if f == "__name__": + continue + if msCheckerConfig.white_list and f in msCheckerConfig.white_list:: + locals().update({f: getattr(torch.nn.functional, f)}) + else: locals().update({f: getattr(torch.nn.functional, f)}) -- Gitee From 81c885d1f8f17c53d5e202352f5e3ed8fe971e20 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Wed, 29 Nov 2023 09:27:28 +0000 Subject: [PATCH 08/29] update debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_torch.py. Signed-off-by: jiangchangting1 --- .../api_accuracy_checker/hook_module/wrap_torch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_torch.py b/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_torch.py index de0d3e0691b..8a0aa99d63e 100644 --- a/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_torch.py +++ b/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_torch.py @@ -36,7 +36,7 @@ def get_torch_ops(): global WrapTorchOps _torch_ops = dir(torch._C._VariableFunctionsClass) if msCheckerConfig.white_list: - return return set(WrapTorchOps) & set(_torch_ops) & set(msCheckerConfig.white_list) + return set(WrapTorchOps) & set(_torch_ops) & set(msCheckerConfig.white_list) else: return set(WrapTorchOps) & set(_torch_ops) -- Gitee From d8b9113c49b80ea8c5338b1c1e0ba83b31dccf3c Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Wed, 29 Nov 2023 09:32:01 +0000 Subject: [PATCH 09/29] 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, 1 insertion(+), 1 deletion(-) 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 0b5dc91e7d3..479f1b0d911 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 @@ -31,7 +31,7 @@ def init_environment(): for f in dir(torch.nn.functional): if f == "__name__": continue - if msCheckerConfig.white_list and f in msCheckerConfig.white_list:: + if msCheckerConfig.white_list and f in msCheckerConfig.white_list: locals().update({f: getattr(torch.nn.functional, f)}) else: locals().update({f: getattr(torch.nn.functional, f)}) -- Gitee From 0200405621c1fa0fc1b2beac8b586789a9bd3009 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Thu, 30 Nov 2023 08:23:06 +0000 Subject: [PATCH 10/29] update debug/accuracy_tools/api_accuracy_checker/common/config.py. Signed-off-by: jiangchangting1 --- .../api_accuracy_checker/common/config.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/common/config.py b/debug/accuracy_tools/api_accuracy_checker/common/config.py index 7d355b7b9b8..d1e0a0294f7 100644 --- a/debug/accuracy_tools/api_accuracy_checker/common/config.py +++ b/debug/accuracy_tools/api_accuracy_checker/common/config.py @@ -19,7 +19,8 @@ class Config: 'dump_step': int, 'error_data_path': str, 'target_iter': list, - 'precision': int + 'precision': int, + 'white_list': list } if not isinstance(value, validators.get(key)): raise ValueError(f"{key} must be {validators[key].__name__} type") @@ -34,6 +35,13 @@ class Config: raise ValueError("All elements in target_iter must be greater than or equal to 0") if key == 'precision' and value < 0: raise ValueError("precision must be greater than 0") + if key == 'white_list': + if not isinstance(value, list): + raise ValueError("white_list must be a list type") + if any(isinstance(i, bool) for i in value): + raise ValueError("white_list cannot contain boolean values") + if not all(isinstance(i, str) for i in value): + raise ValueError("All elements in white_list must be of int type") return value def __getattr__(self, item): -- Gitee From 311889d22d95f85fcd88962ff413f17f5852cc64 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Thu, 30 Nov 2023 08:23:27 +0000 Subject: [PATCH 11/29] update debug/accuracy_tools/api_accuracy_checker/common/config.py. Signed-off-by: jiangchangting1 --- debug/accuracy_tools/api_accuracy_checker/common/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/common/config.py b/debug/accuracy_tools/api_accuracy_checker/common/config.py index d1e0a0294f7..b7a86742520 100644 --- a/debug/accuracy_tools/api_accuracy_checker/common/config.py +++ b/debug/accuracy_tools/api_accuracy_checker/common/config.py @@ -41,7 +41,7 @@ class Config: if any(isinstance(i, bool) for i in value): raise ValueError("white_list cannot contain boolean values") if not all(isinstance(i, str) for i in value): - raise ValueError("All elements in white_list must be of int type") + raise ValueError("All elements in white_list must be of str type") return value def __getattr__(self, item): -- Gitee From f23b335b5a8f62cc0be82f2cb3c9b69bb9c965e4 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Thu, 30 Nov 2023 08:30:32 +0000 Subject: [PATCH 12/29] update debug/accuracy_tools/api_accuracy_checker/run_ut/run_ut.py. Signed-off-by: jiangchangting1 --- .../api_accuracy_checker/run_ut/run_ut.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 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 479f1b0d911..f97a19d5f9f 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 @@ -28,12 +28,12 @@ def init_environment(): yaml_path = os.path.join(cur_path, "../hook_module/support_wrap_ops.yaml") with FileOpen(yaml_path, 'r') as f: WrapFunctionalOps = yaml.safe_load(f).get('functional') - for f in dir(torch.nn.functional): - if f == "__name__": - continue - if msCheckerConfig.white_list and f in msCheckerConfig.white_list: - locals().update({f: getattr(torch.nn.functional, f)}) - else: + if msCheckerConfig.white_list: + functional_dict = set(dir(torch.nn.functional)) & set(msCheckerConfig.white_list) + else: + functional_dict = dir(torch.nn.functional) + for f in functional_dict: + if f != "__name__": locals().update({f: getattr(torch.nn.functional, f)}) -- Gitee From e88eea5a97fc1dcfc7a8f8ff90964ab086d20cd9 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Fri, 1 Dec 2023 07:44:33 +0000 Subject: [PATCH 13/29] 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 | 4 ++++ 1 file changed, 4 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 f97a19d5f9f..eea771d64f4 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 @@ -116,6 +116,10 @@ def run_ut(forward_file, backward_file, out_path, save_error_data): compare = Comparator(out_path) for api_full_name, api_info_dict in tqdm(forward_content.items()): try: + if msCheckerConfig.white_list: + [_, api_name, _] = api_full_name.split("*") + if api_name not in msCheckerConfig.white_list: + continue data_info = run_torch_api(api_full_name, api_setting_dict, backward_content, api_info_dict) is_fwd_success, is_bwd_success = compare.compare_output(api_full_name, data_info.bench_out, -- Gitee From d005ff465f6c1427d3340440ca01c297c0121a55 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Fri, 1 Dec 2023 08:32:49 +0000 Subject: [PATCH 14/29] 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, 1 insertion(+), 1 deletion(-) 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 eea771d64f4..c665f259961 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 @@ -118,7 +118,7 @@ def run_ut(forward_file, backward_file, out_path, save_error_data): try: if msCheckerConfig.white_list: [_, api_name, _] = api_full_name.split("*") - if api_name not in msCheckerConfig.white_list: + if api_name not in set(msCheckerConfig.white_list): continue data_info = run_torch_api(api_full_name, api_setting_dict, backward_content, api_info_dict) is_fwd_success, is_bwd_success = compare.compare_output(api_full_name, -- Gitee From 9841ff0bf8a29536cd537606db94a5f2adb88cfb Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Mon, 4 Dec 2023 11:32:25 +0000 Subject: [PATCH 15/29] update debug/accuracy_tools/api_accuracy_checker/common/config.py. Signed-off-by: jiangchangting1 --- .../api_accuracy_checker/common/config.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/common/config.py b/debug/accuracy_tools/api_accuracy_checker/common/config.py index b7a86742520..ef6b016950f 100644 --- a/debug/accuracy_tools/api_accuracy_checker/common/config.py +++ b/debug/accuracy_tools/api_accuracy_checker/common/config.py @@ -1,8 +1,10 @@ import os import yaml from api_accuracy_checker.common.utils import check_file_or_directory_path +from api_accuracy_checker.hook_module.utils import WrapTorchOps, WrapFunctionalOps, WrapTensorOps from ptdbg_ascend.src.python.ptdbg_ascend.common.file_check_util import FileOpen +WrapApi = set(WrapTorchOps) | set(WrapFunctionalOps) | set(WrapTensorOps) class Config: def __init__(self, yaml_file): @@ -38,10 +40,11 @@ class Config: if key == 'white_list': if not isinstance(value, list): raise ValueError("white_list must be a list type") - if any(isinstance(i, bool) for i in value): - raise ValueError("white_list cannot contain boolean values") if not all(isinstance(i, str) for i in value): raise ValueError("All elements in white_list must be of str type") + invalid_api = [i for i in value if i not in WrapApi] + if invalid_api: + raise ValueError(f"{', '.join(invalid_api)} is not in support_wrap_ops.yaml, please check the white_list") return value def __getattr__(self, item): @@ -50,13 +53,14 @@ class Config: def __str__(self): return '\n'.join(f"{key}={value}" for key, value in self.config.items()) - def update_config(self, dump_path, real_data=False, target_iter=None): + def update_config(self, dump_path, real_data=False, target_iter=None, white_list=None): if target_iter is None: target_iter = self.config.get('target_iter',[1]) args = { "dump_path": dump_path, "real_data": real_data, - "target_iter": target_iter + "target_iter": target_iter if target_iter else self.config.get("target_iter", [1]), + "white_list": white_list if white_list else self.config.get("white_list", []) } for key, value in args.items(): if key in self.config: -- Gitee From 0d86047f4d79587473815f324a5ac9361df0ad4e Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Mon, 4 Dec 2023 11:33:14 +0000 Subject: [PATCH 16/29] update debug/accuracy_tools/api_accuracy_checker/dump/dump.py. Signed-off-by: jiangchangting1 --- debug/accuracy_tools/api_accuracy_checker/dump/dump.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/dump/dump.py b/debug/accuracy_tools/api_accuracy_checker/dump/dump.py index fc1a57bc7b6..677ac2c5c20 100644 --- a/debug/accuracy_tools/api_accuracy_checker/dump/dump.py +++ b/debug/accuracy_tools/api_accuracy_checker/dump/dump.py @@ -49,7 +49,7 @@ class DumpUtil(object): if DumpUtil.call_num in msCheckerConfig.target_iter: set_dump_switch("ON") elif DumpUtil.call_num > max(msCheckerConfig.target_iter): - raise Exception("Model pretest: exit after iteration {}".format(DumpUtil.call_num)) + raise Exception("Model pretest: exit after iteration {}".format(DumpUtil.call_num - 1)) else: set_dump_switch("OFF") DumpUtil.call_num += 1 -- Gitee From 8506fc158b622219e4fa130779bf1e062def3d6f Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Mon, 4 Dec 2023 11:34:24 +0000 Subject: [PATCH 17/29] add debug/accuracy_tools/api_accuracy_checker/hook_module/utils.py. Signed-off-by: jiangchangting1 --- debug/accuracy_tools/api_accuracy_checker/hook_module/utils.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 debug/accuracy_tools/api_accuracy_checker/hook_module/utils.py diff --git a/debug/accuracy_tools/api_accuracy_checker/hook_module/utils.py b/debug/accuracy_tools/api_accuracy_checker/hook_module/utils.py new file mode 100644 index 00000000000..ac92f206578 --- /dev/null +++ b/debug/accuracy_tools/api_accuracy_checker/hook_module/utils.py @@ -0,0 +1 @@ +import os -- Gitee From 46e6482940270efaa8d9e81353c103d4645c5687 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Mon, 4 Dec 2023 11:36:39 +0000 Subject: [PATCH 18/29] update debug/accuracy_tools/api_accuracy_checker/hook_module/utils.py. Signed-off-by: jiangchangting1 --- .../api_accuracy_checker/hook_module/utils.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/debug/accuracy_tools/api_accuracy_checker/hook_module/utils.py b/debug/accuracy_tools/api_accuracy_checker/hook_module/utils.py index ac92f206578..300cd7a67fa 100644 --- a/debug/accuracy_tools/api_accuracy_checker/hook_module/utils.py +++ b/debug/accuracy_tools/api_accuracy_checker/hook_module/utils.py @@ -1 +1,29 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +# Copyright (C) 2019-2020. Huawei Technologies Co., Ltd. All rights reserved. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" + import os +import yaml + +from ptdbg_ascend.src.python.ptdbg_ascend.common.file_check_util import FileOpen + +cur_path = os.path.dirname(os.path.realpath(__file__)) +yaml_path = os.path.join(cur_path, "support_wrap_ops.yaml") +with FileOpen(yaml_path, 'r') as f: + Ops = yaml.safe_load(f) + WrapFunctionalOps = Ops.get('functional') + WrapTensorOps = Ops.get('tensor') + WrapTorchOps = Ops.get('torch') \ No newline at end of file -- Gitee From 904656f31b8ac79b2545881ecb910178ac465111 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Mon, 4 Dec 2023 11:38:01 +0000 Subject: [PATCH 19/29] update debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_functional.py. Signed-off-by: jiangchangting1 --- .../api_accuracy_checker/hook_module/wrap_functional.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_functional.py b/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_functional.py index 1a45c8dbfd0..e224838c67f 100644 --- a/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_functional.py +++ b/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_functional.py @@ -23,13 +23,9 @@ import yaml from api_accuracy_checker.hook_module.hook_module import HOOKModule from api_accuracy_checker.common.utils import torch_device_guard from api_accuracy_checker.common.config import msCheckerConfig +from api_accuracy_checker.hook_module.utils import WrapFunctionalOps from ptdbg_ascend.src.python.ptdbg_ascend.common.file_check_util import FileOpen -cur_path = os.path.dirname(os.path.realpath(__file__)) -yaml_path = os.path.join(cur_path, "support_wrap_ops.yaml") -with FileOpen(yaml_path, 'r') as f: - WrapFunctionalOps = yaml.safe_load(f).get('functional') - for f in dir(torch.nn.functional): locals().update({f: getattr(torch.nn.functional, f)}) -- Gitee From 06d5fe4cc29acfa2b6f23db40844ca92a293188d Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Mon, 4 Dec 2023 11:38:55 +0000 Subject: [PATCH 20/29] update debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_tensor.py. Signed-off-by: jiangchangting1 --- .../api_accuracy_checker/hook_module/wrap_tensor.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_tensor.py b/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_tensor.py index 805b37b3e24..03e73d4b2d3 100644 --- a/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_tensor.py +++ b/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_tensor.py @@ -23,13 +23,9 @@ import yaml from api_accuracy_checker.hook_module.hook_module import HOOKModule from api_accuracy_checker.common.utils import torch_device_guard from api_accuracy_checker.common.config import msCheckerConfig +from api_accuracy_checker.hook_module.utils import WrapTensorOps from ptdbg_ascend.src.python.ptdbg_ascend.common.file_check_util import FileOpen -cur_path = os.path.dirname(os.path.realpath(__file__)) -yaml_path = os.path.join(cur_path, "support_wrap_ops.yaml") -with FileOpen(yaml_path, 'r') as f: - WrapTensorOps = yaml.safe_load(f).get('tensor') - def get_tensor_ops(): global WrapTensorOps -- Gitee From 026b16002e7fea688046ce2ce78c7fe3bf26c550 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Mon, 4 Dec 2023 11:39:41 +0000 Subject: [PATCH 21/29] update debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_torch.py. Signed-off-by: jiangchangting1 --- .../api_accuracy_checker/hook_module/wrap_torch.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_torch.py b/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_torch.py index 8a0aa99d63e..458af67ae95 100644 --- a/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_torch.py +++ b/debug/accuracy_tools/api_accuracy_checker/hook_module/wrap_torch.py @@ -23,14 +23,9 @@ import yaml from api_accuracy_checker.hook_module.hook_module import HOOKModule from api_accuracy_checker.common.utils import torch_device_guard from api_accuracy_checker.common.config import msCheckerConfig - +from api_accuracy_checker.hook_module.utils import WrapTorchOps from ptdbg_ascend.src.python.ptdbg_ascend.common.file_check_util import FileOpen -cur_path = os.path.dirname(os.path.realpath(__file__)) -yaml_path = os.path.join(cur_path, "support_wrap_ops.yaml") -with FileOpen(yaml_path, 'r') as f: - WrapTorchOps = yaml.safe_load(f).get('torch') - def get_torch_ops(): global WrapTorchOps -- Gitee From 3432510728762d51f2270de63e0f197ec3da7809 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Mon, 4 Dec 2023 11:40:53 +0000 Subject: [PATCH 22/29] update debug/accuracy_tools/api_accuracy_checker/common/config.py. Signed-off-by: jiangchangting1 --- debug/accuracy_tools/api_accuracy_checker/common/config.py | 4 ++-- 1 file 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 ef6b016950f..00d7ad944ca 100644 --- a/debug/accuracy_tools/api_accuracy_checker/common/config.py +++ b/debug/accuracy_tools/api_accuracy_checker/common/config.py @@ -1,10 +1,10 @@ import os import yaml from api_accuracy_checker.common.utils import check_file_or_directory_path -from api_accuracy_checker.hook_module.utils import WrapTorchOps, WrapFunctionalOps, WrapTensorOps +from api_accuracy_checker.hook_module.utils import WrapFunctionalOps, WrapTensorOps, WrapTorchOps from ptdbg_ascend.src.python.ptdbg_ascend.common.file_check_util import FileOpen -WrapApi = set(WrapTorchOps) | set(WrapFunctionalOps) | set(WrapTensorOps) +WrapApi = set(WrapFunctionalOps) | set(WrapTensorOps) | set(WrapTorchOps) class Config: def __init__(self, yaml_file): -- Gitee From d0c6bcff6d63599081b4f25e09348f4900be23f3 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Mon, 4 Dec 2023 12:30:56 +0000 Subject: [PATCH 23/29] update debug/accuracy_tools/api_accuracy_checker/common/config.py. Signed-off-by: jiangchangting1 --- debug/accuracy_tools/api_accuracy_checker/common/config.py | 4 ++-- 1 file 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 00d7ad944ca..5b0d5a57b81 100644 --- a/debug/accuracy_tools/api_accuracy_checker/common/config.py +++ b/debug/accuracy_tools/api_accuracy_checker/common/config.py @@ -53,11 +53,11 @@ class Config: def __str__(self): return '\n'.join(f"{key}={value}" for key, value in self.config.items()) - def update_config(self, dump_path, real_data=False, target_iter=None, white_list=None): + def update_config(self, dump_path=None, real_data=False, target_iter=None, white_list=None): if target_iter is None: target_iter = self.config.get('target_iter',[1]) args = { - "dump_path": dump_path, + "dump_path": dump_path dump_path if dump_path else self.config.get("dump_path", './'), "real_data": real_data, "target_iter": target_iter if target_iter else self.config.get("target_iter", [1]), "white_list": white_list if white_list else self.config.get("white_list", []) -- Gitee From bd67b67b5d7682958163c46efdeec93d1f429ade Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Mon, 4 Dec 2023 12:37:36 +0000 Subject: [PATCH 24/29] update debug/accuracy_tools/api_accuracy_checker/common/config.py. Signed-off-by: jiangchangting1 --- debug/accuracy_tools/api_accuracy_checker/common/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/common/config.py b/debug/accuracy_tools/api_accuracy_checker/common/config.py index 5b0d5a57b81..2038ba6ae22 100644 --- a/debug/accuracy_tools/api_accuracy_checker/common/config.py +++ b/debug/accuracy_tools/api_accuracy_checker/common/config.py @@ -57,7 +57,7 @@ class Config: if target_iter is None: target_iter = self.config.get('target_iter',[1]) args = { - "dump_path": dump_path dump_path if dump_path else self.config.get("dump_path", './'), + "dump_path": dump_path if dump_path else self.config.get("dump_path", './'), "real_data": real_data, "target_iter": target_iter if target_iter else self.config.get("target_iter", [1]), "white_list": white_list if white_list else self.config.get("white_list", []) -- Gitee From 7293e323c7aae11c88ba5a55d4d389f0da0a67c5 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Tue, 5 Dec 2023 01:24:53 +0000 Subject: [PATCH 25/29] update debug/accuracy_tools/api_accuracy_checker/run_ut/run_ut.py. Signed-off-by: jiangchangting1 --- .../api_accuracy_checker/run_ut/run_ut.py | 17 ----------------- 1 file changed, 17 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 c665f259961..945efd47bad 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 @@ -23,23 +23,6 @@ from ptdbg_ascend.src.python.ptdbg_ascend.common.file_check_util import FileOpen ut_error_data_dir = 'ut_error_data' -def init_environment(): - cur_path = os.path.dirname(os.path.realpath(__file__)) - yaml_path = os.path.join(cur_path, "../hook_module/support_wrap_ops.yaml") - with FileOpen(yaml_path, 'r') as f: - WrapFunctionalOps = yaml.safe_load(f).get('functional') - if msCheckerConfig.white_list: - functional_dict = set(dir(torch.nn.functional)) & set(msCheckerConfig.white_list) - else: - functional_dict = dir(torch.nn.functional) - for f in functional_dict: - if f != "__name__": - locals().update({f: getattr(torch.nn.functional, f)}) - - -init_environment() - - def exec_api(api_type, api_name, args, kwargs): if api_type == "Functional": functional_api = FunctionalOPTemplate(api_name, str, False) -- Gitee From 2c538647b40b9be27d91e9111abcb2989d70a228 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Tue, 5 Dec 2023 01:42:02 +0000 Subject: [PATCH 26/29] update debug/accuracy_tools/api_accuracy_checker/hook_module/utils.py. Signed-off-by: jiangchangting1 --- debug/accuracy_tools/api_accuracy_checker/hook_module/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/hook_module/utils.py b/debug/accuracy_tools/api_accuracy_checker/hook_module/utils.py index 300cd7a67fa..7d16ac993ed 100644 --- a/debug/accuracy_tools/api_accuracy_checker/hook_module/utils.py +++ b/debug/accuracy_tools/api_accuracy_checker/hook_module/utils.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ -# Copyright (C) 2019-2020. Huawei Technologies Co., Ltd. All rights reserved. +# Copyright (C) 2023-2023. Huawei Technologies Co., Ltd. All rights reserved. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -- Gitee From eb4f8c3a73c7590090ce3b1069400feb20446e09 Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Tue, 5 Dec 2023 01:44:05 +0000 Subject: [PATCH 27/29] update debug/accuracy_tools/api_accuracy_checker/common/config.py. Signed-off-by: jiangchangting1 --- debug/accuracy_tools/api_accuracy_checker/common/config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/debug/accuracy_tools/api_accuracy_checker/common/config.py b/debug/accuracy_tools/api_accuracy_checker/common/config.py index 2038ba6ae22..f9b882f47b1 100644 --- a/debug/accuracy_tools/api_accuracy_checker/common/config.py +++ b/debug/accuracy_tools/api_accuracy_checker/common/config.py @@ -6,6 +6,7 @@ from ptdbg_ascend.src.python.ptdbg_ascend.common.file_check_util import FileOpen WrapApi = set(WrapFunctionalOps) | set(WrapTensorOps) | set(WrapTorchOps) + class Config: def __init__(self, yaml_file): check_file_or_directory_path(yaml_file, False) -- Gitee From 08a93e0058a13fa865c24610d1c1e9900b7cf8ff Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Tue, 5 Dec 2023 01:58:23 +0000 Subject: [PATCH 28/29] update debug/accuracy_tools/api_accuracy_checker/run_ut/run_overflow_check.py. Signed-off-by: jiangchangting1 --- .../run_ut/run_overflow_check.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/run_ut/run_overflow_check.py b/debug/accuracy_tools/api_accuracy_checker/run_ut/run_overflow_check.py index 55a344b7290..f2ce72f5819 100644 --- a/debug/accuracy_tools/api_accuracy_checker/run_ut/run_overflow_check.py +++ b/debug/accuracy_tools/api_accuracy_checker/run_ut/run_overflow_check.py @@ -4,15 +4,24 @@ import sys import torch_npu import torch from tqdm import tqdm -from api_accuracy_checker.run_ut.run_ut import exec_api, generate_npu_params, run_backward, init_environment, \ - get_api_info +from api_accuracy_checker.run_ut.run_ut import exec_api, generate_npu_params, run_backward, get_api_info from api_accuracy_checker.common.utils import print_info_log, print_warn_log, get_json_contents, api_info_preprocess, \ print_error_log from ptdbg_ascend.src.python.ptdbg_ascend.common.file_check_util import FileCheckConst, check_file_suffix, check_link -init_environment() +# def init_environment(): +# cur_path = os.path.dirname(os.path.realpath(__file__)) +# yaml_path = os.path.join(cur_path, "../hook_module/support_wrap_ops.yaml") +# with FileOpen(yaml_path, 'r') as f: +# WrapFunctionalOps = yaml.safe_load(f).get('functional') +# for f in dir(torch.nn.functional): +# if f != "__name__": +# locals().update({f: getattr(torch.nn.functional, f)}) + + +# init_environment() def check_tensor_overflow(x): -- Gitee From c06074646cd95fc69927c191c7dac557a8f2a5fb Mon Sep 17 00:00:00 2001 From: jiangchangting1 Date: Tue, 5 Dec 2023 03:52:45 +0000 Subject: [PATCH 29/29] update debug/accuracy_tools/api_accuracy_checker/run_ut/run_overflow_check.py. Signed-off-by: jiangchangting1 --- .../run_ut/run_overflow_check.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/debug/accuracy_tools/api_accuracy_checker/run_ut/run_overflow_check.py b/debug/accuracy_tools/api_accuracy_checker/run_ut/run_overflow_check.py index 4b7f11dc7df..fb455434cf5 100644 --- a/debug/accuracy_tools/api_accuracy_checker/run_ut/run_overflow_check.py +++ b/debug/accuracy_tools/api_accuracy_checker/run_ut/run_overflow_check.py @@ -11,19 +11,6 @@ from api_accuracy_checker.common.utils import print_info_log, print_warn_log, ge from ptdbg_ascend.src.python.ptdbg_ascend.common.file_check_util import FileCheckConst, check_file_suffix, check_link -# def init_environment(): -# cur_path = os.path.dirname(os.path.realpath(__file__)) -# yaml_path = os.path.join(cur_path, "../hook_module/support_wrap_ops.yaml") -# with FileOpen(yaml_path, 'r') as f: -# WrapFunctionalOps = yaml.safe_load(f).get('functional') -# for f in dir(torch.nn.functional): -# if f != "__name__": -# locals().update({f: getattr(torch.nn.functional, f)}) - - -# init_environment() - - def check_tensor_overflow(x): if isinstance(x, torch.Tensor) and x.numel() != 0 and x.dtype != torch.bool: if len(x.shape) == 0: -- Gitee