From 9a5c48ae6f6c357e680efa92faf915b7dc6a04e7 Mon Sep 17 00:00:00 2001 From: wangchao285 Date: Wed, 6 Mar 2024 11:40:53 +0800 Subject: [PATCH] add atat command --- debug/__init__.py | 0 .../api_accuracy_checker/run_ut/run_ut.py | 11 ++-- debug/accuracy_tools/atat/__init__.py | 0 debug/accuracy_tools/atat/atat.py | 56 +++++++++++++++++++ debug/accuracy_tools/setup.py | 5 +- 5 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 debug/__init__.py create mode 100644 debug/accuracy_tools/atat/__init__.py create mode 100644 debug/accuracy_tools/atat/atat.py diff --git a/debug/__init__.py b/debug/__init__.py new file mode 100644 index 0000000000..e69de29bb2 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 0035e0dab4..59381d182c 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 @@ -373,10 +373,7 @@ def preprocess_forward_content(forward_content): return processed_content -def _run_ut(): - parser = argparse.ArgumentParser() - _run_ut_parser(parser) - args = parser.parse_args(sys.argv[1:]) +def run_ut_command(args): if not is_gpu: torch.npu.set_compile_mode(jit_compile=args.jit_compile) used_device = current_device + ":" + str(args.device_id[0]) @@ -421,6 +418,12 @@ def _run_ut(): args.result_csv_path, args.real_data_path) run_ut(run_ut_config) +def _run_ut(parser = None): + if not parser: + parser = argparse.ArgumentParser() + parser = _run_ut_parser(parser) + args = parser.parse_args(sys.argv[1:]) + run_ut_command(args) class UtDataInfo: def __init__(self, bench_grad_out, device_grad_out, device_out, bench_out, grad_in, in_fwd_data_list): diff --git a/debug/accuracy_tools/atat/__init__.py b/debug/accuracy_tools/atat/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/debug/accuracy_tools/atat/atat.py b/debug/accuracy_tools/atat/atat.py new file mode 100644 index 0000000000..4e51118a45 --- /dev/null +++ b/debug/accuracy_tools/atat/atat.py @@ -0,0 +1,56 @@ +# Copyright (c) 2024, 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 argparse +import sys +#import ptdbg_ascend.src.python.ptdbg_ascend +#import api_accuracy_checker.run_ut +from api_accuracy_checker.run_ut.run_ut import _run_ut_parser, run_ut_command + +def main(): + #subcommands = [parse, _run_ut, multi_run_ut, run_overflow_check, benchmark_compare] + parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, + description="atat(Ascend Training Accuracy Tools), [Powered by MindStudio].\n", + # "Providing one-site debugging and optimization toolkit for inference on Ascend Devices.\n" + # f"For any issue, refer FAQ first: {AIT_FAQ_HOME}", + ) + subparsers = parser.add_subparsers(help='commands') + #parse_cmd_parser = subparsers.add_parser('parse', help='[TODO]parse command') + run_ut_cmd_parser = subparsers.add_parser('run_ut', help='[TODO]run_ut command') + #multi_run_ut_cmd_parser = subparsers.add_parser('parse', help='[TODO]multi_run_ut command') + #benchmark_compare_cmd_parser = subparsers.add_parser('parse', help='[TODO]benchmark_compare command') + parser.set_defaults(print_help=parser.print_help) + run_parser = _run_ut_parser(run_ut_cmd_parser) + args = parser.parse_args(sys.argv[1:]) + if sys.argv[1] == "run_ut": + run_ut_command(args) + + # subcommands关联命令 + + + +if __name__ == "__main__": + main() + + + # run_ut_parser = subparsers.add_parser( + # 'compare', help='Compare network or single op.') + # multi_run_ut_parser = subparsers.add_parser( + # 'convert', help='Convert my dump data to numpy data or bin data.') + # benchmark_compare_parser = subparsers.add_parser( + # 'overflow', help='Analyze the information of the overflow operators.') + # run_overflow_check_parser = subparsers.add_parser( + # 'file_compare', help='Compare two single .npy file.') diff --git a/debug/accuracy_tools/setup.py b/debug/accuracy_tools/setup.py index af16d18e11..2f2e6e9484 100644 --- a/debug/accuracy_tools/setup.py +++ b/debug/accuracy_tools/setup.py @@ -33,4 +33,7 @@ setup( ], include_package_data=True, ext_modules=[], - zip_safe=False) \ No newline at end of file + zip_safe=False, + entry_points={ + 'console_scripts': ['atat=atat.atat:main'], + },) -- Gitee