mindstudio-probe 1.1.1__py3-none-any.whl → 1.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mindstudio_probe-1.1.1.dist-info → mindstudio_probe-1.2.2.dist-info}/METADATA +3 -2
- mindstudio_probe-1.2.2.dist-info/RECORD +415 -0
- msprobe/CMakeLists.txt +5 -0
- msprobe/README.md +16 -21
- msprobe/config.json +1 -0
- msprobe/core/common/const.py +185 -11
- msprobe/core/common/exceptions.py +3 -1
- msprobe/core/common/file_utils.py +33 -7
- msprobe/core/common/inplace_ops.yaml +4 -0
- msprobe/core/common/utils.py +42 -14
- msprobe/core/common_config.py +6 -0
- msprobe/core/compare/acc_compare.py +139 -128
- msprobe/core/compare/check.py +31 -29
- msprobe/core/compare/compare_cli.py +17 -16
- msprobe/core/compare/highlight.py +186 -99
- msprobe/core/compare/layer_mapping/data_scope_parser.py +19 -8
- msprobe/core/compare/layer_mapping/layer_mapping.py +21 -14
- msprobe/core/compare/layer_mapping/postprocess_pass.py +4 -3
- msprobe/core/compare/merge_result/merge_result.py +381 -0
- msprobe/core/compare/merge_result/merge_result_cli.py +31 -0
- msprobe/core/compare/merge_result/utils.py +81 -0
- msprobe/core/compare/multiprocessing_compute.py +2 -2
- msprobe/core/compare/npy_compare.py +109 -147
- msprobe/core/compare/utils.py +199 -69
- msprobe/core/data_dump/data_collector.py +100 -25
- msprobe/core/data_dump/data_processor/base.py +130 -28
- msprobe/core/data_dump/data_processor/factory.py +8 -3
- msprobe/core/data_dump/data_processor/mindspore_processor.py +170 -23
- msprobe/core/data_dump/data_processor/pytorch_processor.py +175 -64
- msprobe/core/data_dump/json_writer.py +54 -8
- msprobe/core/data_dump/scope.py +19 -18
- msprobe/core/overflow_check/abnormal_scene.py +9 -5
- msprobe/core/overflow_check/checker.py +1 -1
- msprobe/core/overflow_check/utils.py +1 -1
- msprobe/docs/01.installation.md +121 -17
- msprobe/docs/02.config_introduction.md +18 -16
- msprobe/docs/03.config_examples.md +24 -0
- msprobe/docs/05.data_dump_PyTorch.md +107 -58
- msprobe/docs/06.data_dump_MindSpore.md +95 -34
- msprobe/docs/07.accuracy_checker_PyTorch.md +18 -18
- msprobe/docs/09.accuracy_checker_MindSpore.md +8 -6
- msprobe/docs/10.accuracy_compare_PyTorch.md +99 -41
- msprobe/docs/11.accuracy_compare_MindSpore.md +249 -48
- msprobe/docs/12.overflow_check_PyTorch.md +1 -1
- msprobe/docs/19.monitor.md +310 -220
- msprobe/docs/21.visualization_PyTorch.md +125 -35
- msprobe/docs/22.visualization_MindSpore.md +149 -41
- msprobe/docs/23.generate_operator_PyTorch.md +107 -0
- msprobe/docs/24.code_mapping_Mindspore.md +28 -0
- msprobe/docs/{23.tool_function_introduction.md → 25.tool_function_introduction.md} +1 -0
- msprobe/docs/26.data_dump_PyTorch_baseline.md +37 -0
- msprobe/docs/27.dump_json_instruction.md +525 -0
- msprobe/docs/28.debugger_save_instruction.md +94 -0
- msprobe/docs/28.kernel_dump_MindSpore.md +69 -0
- msprobe/docs/FAQ.md +26 -2
- msprobe/docs/accuracy_checker_MindSpore/accuracy_checker_MindSpore_baseline.md +14 -0
- msprobe/docs/data_dump_MindSpore/data_dump_MindSpore_baseline.md +22 -0
- msprobe/docs/img/merge_result.png +0 -0
- msprobe/docs/img/monitor/step_count_per_record.png +0 -0
- msprobe/docs/img/visualization/fuzzy_match_ms.png +0 -0
- msprobe/docs/img/visualization/fuzzy_match_pt.png +0 -0
- msprobe/docs/img/visualization/tensorboard_1.png +0 -0
- msprobe/docs/img/visualization/tensorboard_2.png +0 -0
- msprobe/docs/img/visualization/vis_browser_1.png +0 -0
- msprobe/docs/img/visualization/vis_browser_2.png +0 -0
- msprobe/docs/img/visualization/vis_precision_info.png +0 -0
- msprobe/docs/img/visualization/vis_search_info.png +0 -0
- msprobe/docs/img/visualization/vis_show_info.png +0 -0
- msprobe/docs/img/visualization/vis_showcase.png +0 -0
- msprobe/docs/img/visualization/vis_unmatch_info.png +0 -0
- msprobe/docs/visualization/GPTModel.png +0 -0
- msprobe/docs/visualization/ParallelMLP.png +0 -0
- msprobe/docs/visualization/layer_mapping_example.md +132 -0
- msprobe/docs/visualization/mapping.png +0 -0
- msprobe/docs/visualization/mapping1.png +0 -0
- msprobe/docs/visualization/module_name.png +0 -0
- msprobe/docs/visualization/module_name1.png +0 -0
- msprobe/docs/visualization/no_mapping.png +0 -0
- msprobe/docs/visualization/no_mapping1.png +0 -0
- msprobe/docs/visualization/no_mapping_analyze.png +0 -0
- msprobe/docs/visualization/top_layer.png +0 -0
- msprobe/mindspore/__init__.py +11 -0
- msprobe/mindspore/api_accuracy_checker/api_accuracy_checker.py +80 -28
- msprobe/mindspore/api_accuracy_checker/api_runner.py +54 -16
- msprobe/mindspore/api_accuracy_checker/cmd_parser.py +2 -1
- msprobe/mindspore/api_accuracy_checker/compute_element.py +52 -8
- msprobe/mindspore/api_accuracy_checker/data_manager.py +37 -0
- msprobe/mindspore/api_accuracy_checker/main.py +1 -0
- msprobe/mindspore/api_accuracy_checker/multi_api_accuracy_checker.py +12 -6
- msprobe/mindspore/api_accuracy_checker/multi_data_manager.py +3 -1
- msprobe/mindspore/api_accuracy_checker/torch_mindtorch_importer.py +129 -0
- msprobe/mindspore/api_accuracy_checker/type_mapping.py +24 -1
- msprobe/mindspore/api_accuracy_checker/utils.py +6 -1
- msprobe/mindspore/code_mapping/bind.py +264 -0
- msprobe/mindspore/code_mapping/cmd_parser.py +40 -0
- msprobe/mindspore/code_mapping/graph.py +49 -0
- msprobe/mindspore/code_mapping/graph_parser.py +226 -0
- msprobe/mindspore/code_mapping/main.py +24 -0
- msprobe/mindspore/code_mapping/processor.py +34 -0
- msprobe/mindspore/common/const.py +3 -1
- msprobe/mindspore/common/utils.py +68 -5
- msprobe/mindspore/compare/distributed_compare.py +0 -2
- msprobe/mindspore/compare/ms_compare.py +105 -63
- msprobe/mindspore/compare/ms_graph_compare.py +14 -5
- msprobe/mindspore/debugger/debugger_config.py +28 -2
- msprobe/mindspore/debugger/precision_debugger.py +100 -12
- msprobe/mindspore/dump/hook_cell/api_registry.py +85 -16
- msprobe/mindspore/dump/hook_cell/hook_cell.py +60 -38
- msprobe/mindspore/dump/hook_cell/primitive_hooks.py +33 -15
- msprobe/mindspore/dump/hook_cell/support_wrap_ops.yaml +11 -1
- msprobe/mindspore/dump/hook_cell/wrap_api.py +92 -1
- msprobe/mindspore/dump/jit_dump.py +7 -6
- msprobe/mindspore/dump/kernel_dump/kernel_config.py +33 -0
- msprobe/mindspore/dump/kernel_graph_dump.py +7 -0
- msprobe/mindspore/free_benchmark/api_pynative_self_check.py +13 -4
- msprobe/mindspore/free_benchmark/perturbation/bit_noise.py +2 -2
- msprobe/mindspore/grad_probe/grad_analyzer.py +24 -12
- msprobe/mindspore/grad_probe/hook.py +13 -4
- msprobe/mindspore/mindtorch/__init__.py +18 -0
- msprobe/mindspore/mindtorch/mindtorch_adaptor.py +255 -0
- msprobe/mindspore/monitor/anomaly_detect.py +404 -0
- msprobe/mindspore/monitor/distributed/__init__.py +0 -0
- msprobe/mindspore/monitor/distributed/distributed_ops.yaml +15 -0
- msprobe/mindspore/monitor/distributed/stack_blacklist.yaml +5 -0
- msprobe/mindspore/monitor/distributed/wrap_distributed.py +300 -0
- msprobe/mindspore/monitor/features.py +63 -0
- msprobe/mindspore/monitor/module_hook.py +821 -0
- msprobe/mindspore/monitor/module_spec_verifier.py +94 -0
- msprobe/mindspore/monitor/utils.py +267 -0
- msprobe/mindspore/ms_config.py +13 -3
- msprobe/mindspore/overflow_check/kernel_graph_overflow_check.py +7 -0
- msprobe/mindspore/service.py +347 -107
- msprobe/msprobe.py +24 -3
- msprobe/pytorch/__init__.py +7 -7
- msprobe/pytorch/api_accuracy_checker/common/utils.py +31 -16
- msprobe/pytorch/api_accuracy_checker/compare/algorithm.py +41 -8
- msprobe/pytorch/api_accuracy_checker/compare/api_precision_compare.py +100 -267
- msprobe/pytorch/api_accuracy_checker/compare/api_precision_standard.yaml +4 -1
- msprobe/pytorch/api_accuracy_checker/compare/compare.py +69 -68
- msprobe/pytorch/api_accuracy_checker/compare/compare_column.py +54 -0
- msprobe/pytorch/api_accuracy_checker/compare/compare_input.py +51 -0
- msprobe/pytorch/api_accuracy_checker/compare/compare_utils.py +2 -4
- msprobe/pytorch/api_accuracy_checker/generate_op_script/op_generator.py +55 -31
- msprobe/pytorch/api_accuracy_checker/precision_standard/absolute_threshold.py +106 -0
- msprobe/pytorch/api_accuracy_checker/precision_standard/accumulative_error_compare.py +107 -0
- msprobe/pytorch/api_accuracy_checker/precision_standard/base_standard.py +151 -0
- msprobe/pytorch/api_accuracy_checker/precision_standard/benchmark_compare.py +226 -0
- msprobe/pytorch/api_accuracy_checker/precision_standard/binary_consistency.py +68 -0
- msprobe/pytorch/api_accuracy_checker/precision_standard/standard_config.py +218 -0
- msprobe/pytorch/api_accuracy_checker/precision_standard/standard_register.py +104 -0
- msprobe/pytorch/api_accuracy_checker/precision_standard/thousandth_standard.py +63 -0
- msprobe/pytorch/api_accuracy_checker/precision_standard/ulp_compare.py +200 -0
- msprobe/pytorch/api_accuracy_checker/run_ut/data_generate.py +57 -1
- msprobe/pytorch/api_accuracy_checker/run_ut/multi_run_ut.py +2 -1
- msprobe/pytorch/api_accuracy_checker/run_ut/run_overflow_check.py +42 -14
- msprobe/pytorch/api_accuracy_checker/run_ut/run_ut.py +64 -19
- msprobe/pytorch/api_accuracy_checker/run_ut/run_ut_utils.py +34 -4
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/device_dispatch.py +5 -3
- msprobe/pytorch/bench_functions/apply_adam.py +215 -0
- msprobe/pytorch/bench_functions/group_norm_silu.py +27 -0
- msprobe/pytorch/bench_functions/mish.py +21 -0
- msprobe/pytorch/bench_functions/moe_gating_top_k_softmax.py +44 -0
- msprobe/pytorch/bench_functions/npu_fusion_attention.py +42 -10
- msprobe/pytorch/bench_functions/sort_v2.py +21 -0
- msprobe/pytorch/common/parse_json.py +2 -1
- msprobe/pytorch/common/utils.py +116 -2
- msprobe/pytorch/compare/distributed_compare.py +17 -29
- msprobe/pytorch/compare/pt_compare.py +40 -20
- msprobe/pytorch/debugger/debugger_config.py +42 -17
- msprobe/pytorch/debugger/precision_debugger.py +56 -12
- msprobe/pytorch/dump/module_dump/__init__.py +0 -0
- msprobe/pytorch/dump/module_dump/module_dump.py +86 -0
- msprobe/pytorch/dump/module_dump/module_processer.py +204 -0
- msprobe/pytorch/free_benchmark/common/params.py +2 -1
- msprobe/pytorch/free_benchmark/common/utils.py +3 -0
- msprobe/pytorch/free_benchmark/compare/grad_saver.py +0 -2
- msprobe/pytorch/free_benchmark/result_handlers/base_handler.py +31 -47
- msprobe/pytorch/free_benchmark/result_handlers/preheat_handler.py +0 -4
- msprobe/pytorch/function_factory.py +7 -1
- msprobe/pytorch/hook_module/__init__.py +1 -1
- msprobe/pytorch/hook_module/hook_module.py +14 -11
- msprobe/pytorch/hook_module/register_optimizer_hook.py +59 -0
- msprobe/pytorch/hook_module/support_wrap_ops.yaml +36 -1
- msprobe/pytorch/hook_module/wrap_distributed.py +10 -8
- msprobe/pytorch/hook_module/wrap_functional.py +0 -40
- msprobe/pytorch/monitor/anomaly_analyse.py +1 -1
- msprobe/pytorch/monitor/anomaly_detect.py +98 -28
- msprobe/pytorch/monitor/csv2tb.py +164 -0
- msprobe/pytorch/monitor/distributed/wrap_distributed.py +25 -14
- msprobe/pytorch/monitor/features.py +3 -3
- msprobe/pytorch/monitor/module_hook.py +543 -318
- msprobe/pytorch/monitor/module_metric.py +27 -48
- msprobe/pytorch/monitor/module_spec_verifier.py +3 -1
- msprobe/pytorch/monitor/optimizer_collect.py +76 -56
- msprobe/pytorch/monitor/unittest/test_monitor.py +24 -9
- msprobe/pytorch/monitor/utils.py +84 -48
- msprobe/pytorch/online_dispatch/dispatch.py +8 -2
- msprobe/pytorch/parse_tool/lib/compare.py +10 -10
- msprobe/pytorch/parse_tool/lib/config.py +5 -7
- msprobe/pytorch/parse_tool/lib/file_desc.py +15 -1
- msprobe/pytorch/parse_tool/lib/interactive_cli.py +10 -10
- msprobe/pytorch/parse_tool/lib/parse_exception.py +7 -7
- msprobe/pytorch/parse_tool/lib/parse_tool.py +11 -10
- msprobe/pytorch/parse_tool/lib/utils.py +18 -19
- msprobe/pytorch/parse_tool/lib/visualization.py +9 -10
- msprobe/pytorch/pt_config.py +19 -22
- msprobe/pytorch/service.py +264 -115
- msprobe/visualization/builder/graph_builder.py +93 -10
- msprobe/visualization/builder/msprobe_adapter.py +30 -6
- msprobe/visualization/compare/graph_comparator.py +64 -14
- msprobe/visualization/compare/mode_adapter.py +1 -15
- msprobe/visualization/graph/base_node.py +15 -19
- msprobe/visualization/graph/distributed_analyzer.py +395 -0
- msprobe/visualization/graph/graph.py +9 -0
- msprobe/visualization/graph/node_op.py +4 -2
- msprobe/visualization/graph_service.py +100 -27
- msprobe/visualization/utils.py +24 -31
- mindstudio_probe-1.1.1.dist-info/RECORD +0 -341
- msprobe/pytorch/functional/module_dump.py +0 -84
- msprobe/pytorch/module_processer.py +0 -150
- {mindstudio_probe-1.1.1.dist-info → mindstudio_probe-1.2.2.dist-info}/LICENSE +0 -0
- {mindstudio_probe-1.1.1.dist-info → mindstudio_probe-1.2.2.dist-info}/WHEEL +0 -0
- {mindstudio_probe-1.1.1.dist-info → mindstudio_probe-1.2.2.dist-info}/entry_points.txt +0 -0
- {mindstudio_probe-1.1.1.dist-info → mindstudio_probe-1.2.2.dist-info}/top_level.txt +0 -0
- /msprobe/docs/{data_dump_Mindspore → data_dump_MindSpore}/dynamic_graph_quick_start_example.md +0 -0
- /msprobe/{pytorch/functional → mindspore/code_mapping}/__init__.py +0 -0
|
@@ -56,7 +56,7 @@ class PtdbgDispatch(TorchDispatchMode):
|
|
|
56
56
|
|
|
57
57
|
self.device_id = torch_npu._C._npu_getDevice()
|
|
58
58
|
self.dump_mode = dump_mode
|
|
59
|
-
self.dump_api_list = api_list
|
|
59
|
+
self.dump_api_list = api_list or []
|
|
60
60
|
self.debug_flag = debug
|
|
61
61
|
self.api_index = 0
|
|
62
62
|
self.single_api_index_dict = {}
|
|
@@ -182,7 +182,13 @@ class PtdbgDispatch(TorchDispatchMode):
|
|
|
182
182
|
npu_out_cpu = safe_get_value(npu_out_cpu, 0, "npu_out_cpu")
|
|
183
183
|
|
|
184
184
|
with TimeStatistics("CPU RUN", run_param):
|
|
185
|
-
|
|
185
|
+
try:
|
|
186
|
+
cpu_out = func(*cpu_args, **cpu_kwargs)
|
|
187
|
+
except RuntimeError as e:
|
|
188
|
+
self.api_index -= 1
|
|
189
|
+
logger.warning(f"RuntimeError: {e}")
|
|
190
|
+
logger.warning(f"This aten_api {aten_api} does not support running on cpu, so skip it.")
|
|
191
|
+
return npu_out
|
|
186
192
|
|
|
187
193
|
if isinstance(cpu_out, torch.Tensor) and cpu_out.dtype in [torch.bfloat16, torch.float16, torch.half]:
|
|
188
194
|
cpu_out = cpu_out.float()
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
#
|
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
1
|
+
# Copyright (c) 2024-2025, Huawei Technologies Co., Ltd.
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
5
|
# you may not use this file except in compliance with the License.
|
|
7
6
|
# You may obtain a copy of the License at
|
|
8
7
|
#
|
|
@@ -13,16 +12,17 @@
|
|
|
13
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
13
|
# See the License for the specific language governing permissions and
|
|
15
14
|
# limitations under the License.
|
|
16
|
-
"""
|
|
17
15
|
|
|
18
16
|
import os
|
|
19
17
|
import time
|
|
20
|
-
import numpy as np
|
|
21
18
|
from collections import namedtuple
|
|
22
|
-
|
|
19
|
+
|
|
20
|
+
import numpy as np
|
|
21
|
+
|
|
22
|
+
from msprobe.core.common.file_utils import create_directory, load_npy, save_npy_to_txt, write_csv, os_walk_for_files
|
|
23
23
|
from msprobe.pytorch.parse_tool.lib.config import Const
|
|
24
24
|
from msprobe.pytorch.parse_tool.lib.parse_exception import ParseException
|
|
25
|
-
from msprobe.
|
|
25
|
+
from msprobe.pytorch.parse_tool.lib.utils import Util
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
class Compare:
|
|
@@ -126,7 +126,7 @@ class Compare:
|
|
|
126
126
|
all_close = np.allclose(data_left, data_right, atol=al, rtol=rl)
|
|
127
127
|
np.seterr(divide='raise')
|
|
128
128
|
cos_sim = np.dot(data_left, data_right) / (
|
|
129
|
-
|
|
129
|
+
np.sqrt(np.dot(data_left, data_left)) * np.sqrt(np.dot(data_right, data_right)))
|
|
130
130
|
err_cnt = 0
|
|
131
131
|
total_cnt = data_left.shape[0]
|
|
132
132
|
diff_table_columns = ['Index', 'Left', 'Right', 'Diff']
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
#
|
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
1
|
+
# Copyright (c) 2024-2025, Huawei Technologies Co., Ltd.
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
5
|
# you may not use this file except in compliance with the License.
|
|
7
6
|
# You may obtain a copy of the License at
|
|
8
7
|
#
|
|
@@ -13,14 +12,13 @@
|
|
|
13
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
13
|
# See the License for the specific language governing permissions and
|
|
15
14
|
# limitations under the License.
|
|
16
|
-
"""
|
|
17
15
|
|
|
18
16
|
import os
|
|
17
|
+
|
|
19
18
|
import numpy as np
|
|
20
19
|
|
|
21
20
|
|
|
22
21
|
class Const:
|
|
23
|
-
|
|
24
22
|
MS_ACCU_CMP_PATH = '/usr/local/Ascend/ascend-toolkit/latest/tools/operator_cmp/compare/msaccucmp.py'
|
|
25
23
|
MS_ACCU_CMP_FILE_NAME = 'msaccucmp.py'
|
|
26
24
|
ROOT_DIR = ""
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Copyright (c) 2024-2025, Huawei Technologies Co., Ltd.
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
|
|
2
16
|
import os
|
|
3
17
|
|
|
4
18
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
#
|
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
1
|
+
# Copyright (c) 2024-2025, Huawei Technologies Co., Ltd.
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
5
|
# you may not use this file except in compliance with the License.
|
|
7
6
|
# You may obtain a copy of the License at
|
|
8
7
|
#
|
|
@@ -13,13 +12,14 @@
|
|
|
13
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
13
|
# See the License for the specific language governing permissions and
|
|
15
14
|
# limitations under the License.
|
|
16
|
-
|
|
17
|
-
import cmd
|
|
15
|
+
|
|
18
16
|
import argparse
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
import cmd
|
|
18
|
+
|
|
21
19
|
from msprobe.pytorch.parse_tool.lib.config import Const
|
|
22
20
|
from msprobe.pytorch.parse_tool.lib.parse_exception import catch_exception
|
|
21
|
+
from msprobe.pytorch.parse_tool.lib.parse_tool import ParseTool
|
|
22
|
+
from msprobe.pytorch.parse_tool.lib.utils import Util
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
class InteractiveCli(cmd.Cmd):
|
|
@@ -81,7 +81,7 @@ class InteractiveCli(cmd.Cmd):
|
|
|
81
81
|
self.util.check_files_in_path(args.my_dump_path)
|
|
82
82
|
self.util.check_files_in_path(args.golden_dump_path)
|
|
83
83
|
if self.util.dir_contains_only(args.my_dump_path, ".npy") and \
|
|
84
|
-
|
|
84
|
+
self.util.dir_contains_only(args.golden_dump_path, ".npy"):
|
|
85
85
|
self.parse_tool.do_compare_converted_dir(args)
|
|
86
86
|
else:
|
|
87
87
|
self.parse_tool.do_vector_compare(args)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
#
|
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
1
|
+
# Copyright (c) 2024-2025, Huawei Technologies Co., Ltd.
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
5
|
# you may not use this file except in compliance with the License.
|
|
7
6
|
# You may obtain a copy of the License at
|
|
8
7
|
#
|
|
@@ -13,13 +12,13 @@
|
|
|
13
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
13
|
# See the License for the specific language governing permissions and
|
|
15
14
|
# limitations under the License.
|
|
16
|
-
|
|
15
|
+
|
|
17
16
|
import logging
|
|
17
|
+
|
|
18
18
|
from msprobe.core.common.exceptions import FileCheckException
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class ParseException(Exception):
|
|
22
|
-
|
|
23
22
|
PARSE_INVALID_PATH_ERROR = 0
|
|
24
23
|
PARSE_NO_FILE_ERROR = 1
|
|
25
24
|
PARSE_NO_MODULE_ERROR = 2
|
|
@@ -51,4 +50,5 @@ def catch_exception(func):
|
|
|
51
50
|
except FileCheckException:
|
|
52
51
|
log.error("Command execution failed")
|
|
53
52
|
return result
|
|
53
|
+
|
|
54
54
|
return inner
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
#
|
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
1
|
+
# Copyright (c) 2024-2025, Huawei Technologies Co., Ltd.
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
5
|
# you may not use this file except in compliance with the License.
|
|
7
6
|
# You may obtain a copy of the License at
|
|
8
7
|
#
|
|
@@ -13,17 +12,18 @@
|
|
|
13
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
13
|
# See the License for the specific language governing permissions and
|
|
15
14
|
# limitations under the License.
|
|
16
|
-
|
|
15
|
+
|
|
17
16
|
import argparse
|
|
18
17
|
import os
|
|
19
18
|
from collections import namedtuple
|
|
20
19
|
|
|
20
|
+
from msprobe.core.common.file_utils import create_directory
|
|
21
|
+
from msprobe.pytorch.parse_tool.lib.compare import Compare
|
|
21
22
|
from msprobe.pytorch.parse_tool.lib.config import Const
|
|
23
|
+
from msprobe.pytorch.parse_tool.lib.parse_exception import catch_exception, ParseException
|
|
22
24
|
from msprobe.pytorch.parse_tool.lib.utils import Util
|
|
23
|
-
from msprobe.pytorch.parse_tool.lib.compare import Compare
|
|
24
25
|
from msprobe.pytorch.parse_tool.lib.visualization import Visualization
|
|
25
|
-
|
|
26
|
-
from msprobe.core.common.file_utils import create_directory
|
|
26
|
+
|
|
27
27
|
|
|
28
28
|
class ParseTool:
|
|
29
29
|
def __init__(self):
|
|
@@ -117,7 +117,8 @@ class ParseTool:
|
|
|
117
117
|
self.util.check_path_valid(args.golden_dump_path)
|
|
118
118
|
self.util.check_file_path_format(args.my_dump_path, Const.NPY_SUFFIX)
|
|
119
119
|
self.util.check_file_path_format(args.golden_dump_path, Const.NPY_SUFFIX)
|
|
120
|
-
compare_data_args = namedtuple('compare_data_args',
|
|
120
|
+
compare_data_args = namedtuple('compare_data_args',
|
|
121
|
+
['my_dump_path', 'golden_dump_path', 'save', 'rtol', 'atol', 'count'])
|
|
121
122
|
compare_data_args.__new__.__defaults__ = (False, 0.001, 0.001, 20)
|
|
122
123
|
res = compare_data_args(args.my_dump_path, args.golden_dump_path, args.save, args.rtol, args.atol, args.count)
|
|
123
124
|
self.compare.compare_data(res)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
#
|
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
1
|
+
# Copyright (c) 2024-2025, Huawei Technologies Co., Ltd.
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
5
|
# you may not use this file except in compliance with the License.
|
|
7
6
|
# You may obtain a copy of the License at
|
|
8
7
|
#
|
|
@@ -13,24 +12,24 @@
|
|
|
13
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
13
|
# See the License for the specific language governing permissions and
|
|
15
14
|
# limitations under the License.
|
|
16
|
-
|
|
15
|
+
|
|
16
|
+
import hashlib
|
|
17
17
|
import os
|
|
18
18
|
import re
|
|
19
|
-
import sys
|
|
20
19
|
import subprocess
|
|
21
|
-
import
|
|
20
|
+
import sys
|
|
22
21
|
import time
|
|
23
|
-
import numpy as np
|
|
24
22
|
from collections import namedtuple
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
from msprobe.pytorch.parse_tool.lib.parse_exception import ParseException
|
|
28
|
-
from msprobe.core.common.file_utils import change_mode, check_other_user_writable,\
|
|
29
|
-
check_path_executable, check_path_owner_consistent
|
|
23
|
+
|
|
24
|
+
import numpy as np
|
|
30
25
|
from msprobe.core.common.const import FileCheckConst
|
|
26
|
+
from msprobe.core.common.file_utils import change_mode, check_other_user_writable, \
|
|
27
|
+
check_path_executable, check_path_owner_consistent
|
|
31
28
|
from msprobe.core.common.file_utils import check_file_or_directory_path, remove_path, check_file_type, os_walk_for_files
|
|
32
29
|
from msprobe.pytorch.common.log import logger
|
|
33
|
-
|
|
30
|
+
from msprobe.pytorch.parse_tool.lib.config import Const
|
|
31
|
+
from msprobe.pytorch.parse_tool.lib.file_desc import DumpDecodeFileDesc, FileDesc
|
|
32
|
+
from msprobe.pytorch.parse_tool.lib.parse_exception import ParseException
|
|
34
33
|
|
|
35
34
|
try:
|
|
36
35
|
from rich.traceback import install
|
|
@@ -135,7 +134,7 @@ class Util:
|
|
|
135
134
|
zero_mask = (data == 0)
|
|
136
135
|
data[zero_mask] += np.finfo(float).eps
|
|
137
136
|
return data
|
|
138
|
-
|
|
137
|
+
|
|
139
138
|
@staticmethod
|
|
140
139
|
def dir_contains_only(path, endfix):
|
|
141
140
|
files = os_walk_for_files(path, Const.MAX_TRAVERSAL_DEPTH)
|
|
@@ -143,11 +142,11 @@ class Util:
|
|
|
143
142
|
if not file['file'].endswith(endfix):
|
|
144
143
|
return False
|
|
145
144
|
return True
|
|
146
|
-
|
|
145
|
+
|
|
147
146
|
@staticmethod
|
|
148
147
|
def localtime_str():
|
|
149
148
|
return time.strftime("%Y%m%d%H%M%S", time.localtime())
|
|
150
|
-
|
|
149
|
+
|
|
151
150
|
@staticmethod
|
|
152
151
|
def change_filemode_safe(path):
|
|
153
152
|
change_mode(path, FileCheckConst.DATA_FILE_AUTHORITY)
|
|
@@ -208,7 +207,7 @@ class Util:
|
|
|
208
207
|
|
|
209
208
|
def list_numpy_files(self, path, extern_pattern=''):
|
|
210
209
|
return self.list_file_with_pattern(path, Const.NUMPY_PATTERN, extern_pattern,
|
|
211
|
-
|
|
210
|
+
self._gen_numpy_file_info)
|
|
212
211
|
|
|
213
212
|
def create_columns(self, content):
|
|
214
213
|
if not Columns:
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
#
|
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
1
|
+
# Copyright (c) 2024-2025, Huawei Technologies Co., Ltd.
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
5
|
# you may not use this file except in compliance with the License.
|
|
7
6
|
# You may obtain a copy of the License at
|
|
8
7
|
#
|
|
@@ -13,14 +12,14 @@
|
|
|
13
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
13
|
# See the License for the specific language governing permissions and
|
|
15
14
|
# limitations under the License.
|
|
16
|
-
|
|
15
|
+
|
|
17
16
|
import json
|
|
18
|
-
import numpy as np
|
|
19
17
|
|
|
18
|
+
import numpy as np
|
|
19
|
+
from msprobe.core.common.file_utils import FileOpen, load_npy, save_npy_to_txt
|
|
20
20
|
from msprobe.pytorch.parse_tool.lib.config import Const
|
|
21
|
-
from msprobe.pytorch.parse_tool.lib.utils import Util
|
|
22
21
|
from msprobe.pytorch.parse_tool.lib.parse_exception import ParseException
|
|
23
|
-
from msprobe.
|
|
22
|
+
from msprobe.pytorch.parse_tool.lib.utils import Util
|
|
24
23
|
|
|
25
24
|
|
|
26
25
|
class Visualization:
|
|
@@ -77,7 +76,7 @@ class Visualization:
|
|
|
77
76
|
self.util.log.info(" File \"{}\", line {}, in {}".format(item[0], item[1], item[2]))
|
|
78
77
|
self.util.log.info(" {}".format(item[3]))
|
|
79
78
|
continue
|
|
80
|
-
if len(msg) > 5 and len(msg[5]) >=
|
|
79
|
+
if len(msg) > 5 and len(msg[5]) >= 3:
|
|
81
80
|
summery_info = " [{}][dtype: {}][shape: {}][max: {}][min: {}][mean: {}]" \
|
|
82
81
|
.format(msg[0], msg[3], msg[4], msg[5][0], msg[5][1], msg[5][2])
|
|
83
82
|
if not title_printed:
|
msprobe/pytorch/pt_config.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2024-
|
|
1
|
+
# Copyright (c) 2024-2025, Huawei Technologies Co., Ltd.
|
|
2
2
|
# All rights reserved.
|
|
3
3
|
#
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -303,28 +303,25 @@ class GradToolConfig(BaseConfig):
|
|
|
303
303
|
check_bounds(self.bounds)
|
|
304
304
|
|
|
305
305
|
|
|
306
|
+
class StructureConfig(BaseConfig):
|
|
307
|
+
def __init__(self, json_config):
|
|
308
|
+
super().__init__(json_config)
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
TaskDict = {
|
|
312
|
+
Const.TENSOR: TensorConfig,
|
|
313
|
+
Const.STATISTICS: StatisticsConfig,
|
|
314
|
+
Const.OVERFLOW_CHECK: OverflowCheckConfig,
|
|
315
|
+
Const.FREE_BENCHMARK: FreeBenchmarkCheckConfig,
|
|
316
|
+
Const.RUN_UT: RunUTConfig,
|
|
317
|
+
Const.GRAD_PROBE: GradToolConfig,
|
|
318
|
+
Const.STRUCTURE: StructureConfig
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
|
|
306
322
|
def parse_task_config(task, json_config):
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
config_dic = json_config.get(Const.TENSOR, default_dic)
|
|
310
|
-
return TensorConfig(config_dic)
|
|
311
|
-
elif task == Const.STATISTICS:
|
|
312
|
-
config_dic = json_config.get(Const.STATISTICS, default_dic)
|
|
313
|
-
return StatisticsConfig(config_dic)
|
|
314
|
-
elif task == Const.OVERFLOW_CHECK:
|
|
315
|
-
config_dic = json_config.get(Const.OVERFLOW_CHECK, default_dic)
|
|
316
|
-
return OverflowCheckConfig(config_dic)
|
|
317
|
-
elif task == Const.FREE_BENCHMARK:
|
|
318
|
-
config_dic = json_config.get(Const.FREE_BENCHMARK, default_dic)
|
|
319
|
-
return FreeBenchmarkCheckConfig(config_dic)
|
|
320
|
-
elif task == Const.RUN_UT:
|
|
321
|
-
config_dic = json_config.get(Const.RUN_UT, default_dic)
|
|
322
|
-
return RunUTConfig(config_dic)
|
|
323
|
-
elif task == Const.GRAD_PROBE:
|
|
324
|
-
config_dic = json_config.get(Const.GRAD_PROBE, default_dic)
|
|
325
|
-
return GradToolConfig(config_dic)
|
|
326
|
-
else:
|
|
327
|
-
return StatisticsConfig(default_dic)
|
|
323
|
+
task_map = json_config.get(task, dict())
|
|
324
|
+
return TaskDict.get(task)(task_map)
|
|
328
325
|
|
|
329
326
|
|
|
330
327
|
def parse_json_config(json_file_path, task):
|