mindstudio-probe 1.1.0__py3-none-any.whl → 1.2.1__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.0.dist-info → mindstudio_probe-1.2.1.dist-info}/METADATA +7 -6
- mindstudio_probe-1.2.1.dist-info/RECORD +396 -0
- {mindstudio_probe-1.1.0.dist-info → mindstudio_probe-1.2.1.dist-info}/WHEEL +1 -1
- {mindstudio_probe-1.1.0.dist-info → mindstudio_probe-1.2.1.dist-info}/entry_points.txt +0 -1
- msprobe/CMakeLists.txt +5 -0
- msprobe/README.md +51 -20
- msprobe/config.json +2 -3
- msprobe/core/advisor/advisor.py +8 -3
- msprobe/core/common/const.py +264 -15
- msprobe/core/common/exceptions.py +27 -3
- msprobe/core/common/file_utils.py +176 -26
- msprobe/core/common/inplace_op_checker.py +15 -0
- msprobe/core/common/inplace_ops.yaml +3 -0
- msprobe/core/common/log.py +27 -9
- msprobe/core/common/utils.py +204 -77
- msprobe/core/common_config.py +49 -14
- msprobe/core/compare/acc_compare.py +274 -198
- msprobe/core/compare/check.py +32 -33
- msprobe/core/compare/compare_cli.py +32 -14
- msprobe/core/compare/highlight.py +283 -127
- msprobe/core/compare/layer_mapping/__init__.py +19 -0
- msprobe/core/compare/layer_mapping/data_scope_parser.py +246 -0
- msprobe/core/compare/layer_mapping/layer_mapping.py +249 -0
- msprobe/core/compare/layer_mapping/postprocess_pass.py +95 -0
- msprobe/core/compare/merge_result/merge_result.py +380 -0
- msprobe/core/compare/merge_result/merge_result_cli.py +31 -0
- msprobe/core/compare/multiprocessing_compute.py +2 -2
- msprobe/core/compare/npy_compare.py +135 -144
- msprobe/core/compare/utils.py +419 -274
- msprobe/core/data_dump/data_collector.py +60 -28
- msprobe/core/data_dump/data_processor/base.py +84 -36
- msprobe/core/data_dump/data_processor/factory.py +5 -3
- msprobe/core/data_dump/data_processor/mindspore_processor.py +152 -18
- msprobe/core/data_dump/data_processor/pytorch_processor.py +267 -110
- msprobe/core/data_dump/json_writer.py +29 -1
- msprobe/core/data_dump/scope.py +119 -39
- msprobe/core/grad_probe/constant.py +27 -13
- msprobe/core/grad_probe/grad_compare.py +18 -1
- msprobe/core/grad_probe/utils.py +30 -2
- msprobe/core/overflow_check/abnormal_scene.py +189 -0
- msprobe/core/overflow_check/api_info.py +55 -0
- msprobe/core/overflow_check/checker.py +138 -0
- msprobe/core/overflow_check/filter.py +157 -0
- msprobe/core/overflow_check/ignore_rules.yaml +55 -0
- msprobe/core/overflow_check/level.py +22 -0
- msprobe/core/overflow_check/utils.py +28 -0
- msprobe/docs/01.installation.md +96 -7
- msprobe/docs/02.config_introduction.md +50 -23
- msprobe/docs/03.config_examples.md +2 -9
- msprobe/docs/04.kernel_dump_PyTorch.md +73 -0
- msprobe/docs/05.data_dump_PyTorch.md +93 -61
- msprobe/docs/06.data_dump_MindSpore.md +200 -95
- msprobe/docs/07.accuracy_checker_PyTorch.md +28 -28
- msprobe/docs/08.accuracy_checker_online_PyTorch.md +1 -6
- msprobe/docs/09.accuracy_checker_MindSpore.md +44 -8
- msprobe/docs/10.accuracy_compare_PyTorch.md +114 -50
- msprobe/docs/11.accuracy_compare_MindSpore.md +340 -48
- msprobe/docs/12.overflow_check_PyTorch.md +2 -2
- msprobe/docs/13.overflow_check_MindSpore.md +6 -6
- msprobe/docs/15.free_benchmarking_PyTorch.md +4 -5
- msprobe/docs/16.free_benchmarking_MindSpore.md +56 -37
- msprobe/docs/17.grad_probe.md +5 -6
- msprobe/docs/19.monitor.md +561 -0
- msprobe/docs/20.monitor_performance_baseline.md +52 -0
- msprobe/docs/21.visualization_PyTorch.md +466 -0
- msprobe/docs/22.visualization_MindSpore.md +481 -0
- msprobe/docs/23.generate_operator_PyTorch.md +107 -0
- msprobe/docs/24.code_mapping_Mindspore.md +28 -0
- msprobe/docs/25.tool_function_introduction.md +29 -0
- msprobe/docs/26.data_dump_PyTorch_baseline.md +37 -0
- msprobe/docs/27.dump_json_instruction.md +521 -0
- msprobe/docs/FAQ.md +29 -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/data_dump_MindSpore/dynamic_graph_quick_start_example.md +211 -0
- msprobe/docs/img/compare_result.png +0 -0
- msprobe/docs/img/merge_result.png +0 -0
- msprobe/docs/img/monitor/cpu_info.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 +25 -0
- msprobe/mindspore/api_accuracy_checker/api_accuracy_checker.py +151 -151
- msprobe/mindspore/api_accuracy_checker/api_info.py +21 -6
- msprobe/mindspore/api_accuracy_checker/api_runner.py +43 -18
- msprobe/mindspore/api_accuracy_checker/base_compare_algorithm.py +21 -7
- msprobe/mindspore/api_accuracy_checker/checker_support_api.yaml +77 -0
- msprobe/mindspore/api_accuracy_checker/cmd_parser.py +64 -1
- msprobe/mindspore/api_accuracy_checker/compute_element.py +64 -31
- msprobe/mindspore/api_accuracy_checker/data_manager.py +301 -0
- msprobe/mindspore/api_accuracy_checker/main.py +28 -3
- msprobe/mindspore/api_accuracy_checker/multi_api_accuracy_checker.py +212 -0
- msprobe/mindspore/api_accuracy_checker/multi_data_manager.py +60 -0
- msprobe/mindspore/api_accuracy_checker/type_mapping.py +22 -5
- msprobe/mindspore/api_accuracy_checker/utils.py +34 -17
- msprobe/mindspore/cell_processor.py +33 -12
- 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 +35 -13
- msprobe/mindspore/common/log.py +5 -9
- msprobe/mindspore/common/utils.py +88 -4
- msprobe/mindspore/compare/distributed_compare.py +22 -24
- msprobe/mindspore/compare/ms_compare.py +333 -268
- msprobe/mindspore/compare/ms_graph_compare.py +95 -52
- msprobe/mindspore/debugger/debugger_config.py +7 -1
- msprobe/mindspore/debugger/precision_debugger.py +87 -12
- msprobe/mindspore/dump/dump_tool_factory.py +3 -1
- msprobe/mindspore/dump/hook_cell/api_registry.py +95 -18
- msprobe/mindspore/dump/hook_cell/hook_cell.py +60 -38
- msprobe/mindspore/dump/hook_cell/primitive_hooks.py +45 -30
- msprobe/mindspore/dump/hook_cell/support_wrap_ops.yaml +36 -1
- msprobe/mindspore/dump/hook_cell/wrap_api.py +92 -1
- msprobe/mindspore/dump/jit_dump.py +17 -5
- msprobe/mindspore/dump/kernel_dump/kernel_config.py +33 -0
- msprobe/mindspore/dump/kernel_graph_dump.py +9 -4
- msprobe/mindspore/dump/kernel_kbyk_dump.py +2 -4
- msprobe/mindspore/dym_loader/hook_dynamic_loader.cc +140 -0
- msprobe/mindspore/dym_loader/hook_dynamic_loader.h +53 -0
- msprobe/mindspore/free_benchmark/api_pynative_self_check.py +156 -41
- msprobe/mindspore/free_benchmark/common/handler_params.py +1 -2
- msprobe/mindspore/free_benchmark/common/utils.py +19 -4
- msprobe/mindspore/free_benchmark/data/support_wrap_ops.yaml +0 -204
- msprobe/mindspore/free_benchmark/handler/base_handler.py +3 -3
- msprobe/mindspore/free_benchmark/handler/check_handler.py +4 -5
- msprobe/mindspore/free_benchmark/handler/fix_handler.py +4 -4
- msprobe/mindspore/free_benchmark/handler/handler_factory.py +4 -4
- msprobe/mindspore/free_benchmark/perturbation/add_noise.py +2 -2
- msprobe/mindspore/free_benchmark/perturbation/base_perturbation.py +15 -6
- msprobe/mindspore/free_benchmark/perturbation/bit_noise.py +2 -2
- msprobe/mindspore/free_benchmark/perturbation/exchange_value.py +2 -2
- msprobe/mindspore/free_benchmark/perturbation/improve_precision.py +13 -6
- msprobe/mindspore/free_benchmark/perturbation/perturbation_factory.py +2 -2
- msprobe/mindspore/free_benchmark/self_check_tool_factory.py +2 -2
- msprobe/mindspore/grad_probe/global_context.py +28 -8
- msprobe/mindspore/grad_probe/grad_analyzer.py +50 -24
- msprobe/mindspore/grad_probe/grad_monitor.py +16 -1
- msprobe/mindspore/grad_probe/grad_stat_csv.py +33 -5
- msprobe/mindspore/grad_probe/hook.py +35 -12
- msprobe/mindspore/grad_probe/utils.py +18 -5
- msprobe/mindspore/mindtorch/__init__.py +18 -0
- msprobe/mindspore/mindtorch/mindtorch_adaptor.py +255 -0
- msprobe/mindspore/ms_config.py +27 -16
- msprobe/mindspore/overflow_check/kernel_graph_overflow_check.py +9 -4
- msprobe/mindspore/runtime.py +15 -0
- msprobe/mindspore/service.py +285 -113
- msprobe/mindspore/task_handler_factory.py +15 -0
- msprobe/msprobe.py +48 -10
- msprobe/pytorch/__init__.py +8 -6
- msprobe/pytorch/api_accuracy_checker/common/config.py +62 -0
- 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 +103 -271
- 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/config_op.json +9 -0
- msprobe/pytorch/api_accuracy_checker/generate_op_script/op_generator.py +478 -0
- msprobe/pytorch/api_accuracy_checker/generate_op_script/operator_replication.template +365 -0
- 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 +63 -2
- msprobe/pytorch/api_accuracy_checker/run_ut/multi_run_ut.py +21 -15
- msprobe/pytorch/api_accuracy_checker/run_ut/run_overflow_check.py +54 -22
- msprobe/pytorch/api_accuracy_checker/run_ut/run_ut.py +140 -71
- msprobe/pytorch/api_accuracy_checker/run_ut/run_ut_utils.py +49 -8
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/attl.py +9 -24
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/client.py +4 -12
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/device_dispatch.py +5 -3
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/dump_dispatch.py +9 -4
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/server.py +3 -11
- msprobe/pytorch/api_accuracy_checker/tensor_transport_layer/utils.py +2 -2
- msprobe/pytorch/bench_functions/confusion_transpose.py +5 -1
- msprobe/pytorch/bench_functions/matmul_backward.py +12 -0
- msprobe/pytorch/bench_functions/npu_fusion_attention.py +142 -16
- msprobe/pytorch/bench_functions/rotary_mul.py +4 -0
- msprobe/pytorch/bench_functions/swiglu.py +10 -2
- msprobe/pytorch/common/parse_json.py +7 -6
- msprobe/pytorch/common/utils.py +101 -7
- msprobe/pytorch/compare/distributed_compare.py +17 -30
- msprobe/pytorch/compare/pt_compare.py +44 -22
- msprobe/pytorch/debugger/debugger_config.py +46 -27
- msprobe/pytorch/debugger/precision_debugger.py +42 -12
- msprobe/pytorch/dump/kernel_dump/kernel_config.py +33 -0
- msprobe/pytorch/dump/module_dump/module_dump.py +86 -0
- msprobe/pytorch/{module_processer.py → dump/module_dump/module_processer.py} +81 -10
- msprobe/pytorch/free_benchmark/common/constant.py +15 -0
- msprobe/pytorch/free_benchmark/common/counter.py +15 -0
- msprobe/pytorch/free_benchmark/common/enums.py +15 -0
- msprobe/pytorch/free_benchmark/common/params.py +10 -2
- msprobe/pytorch/free_benchmark/common/utils.py +29 -4
- msprobe/pytorch/free_benchmark/compare/grad_saver.py +20 -5
- msprobe/pytorch/free_benchmark/compare/single_benchmark.py +2 -0
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/add_noise.py +3 -1
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/bit_noise.py +6 -4
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/change_value.py +2 -0
- msprobe/pytorch/free_benchmark/perturbed_layers/npu/improve_precision.py +4 -0
- msprobe/pytorch/free_benchmark/result_handlers/base_handler.py +41 -47
- msprobe/pytorch/free_benchmark/result_handlers/fix_handler.py +6 -5
- msprobe/pytorch/free_benchmark/result_handlers/preheat_handler.py +0 -4
- msprobe/pytorch/grad_probe/grad_monitor.py +23 -6
- msprobe/pytorch/grad_probe/grad_stat_csv.py +40 -10
- 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 +35 -0
- msprobe/pytorch/hook_module/wrap_distributed.py +6 -8
- msprobe/pytorch/hook_module/wrap_functional.py +0 -38
- msprobe/pytorch/monitor/__init__.py +0 -0
- msprobe/pytorch/monitor/anomaly_analyse.py +201 -0
- msprobe/pytorch/monitor/anomaly_detect.py +425 -0
- msprobe/pytorch/monitor/csv2tb.py +166 -0
- msprobe/pytorch/monitor/distributed/__init__.py +0 -0
- msprobe/pytorch/monitor/distributed/distributed_ops.yaml +19 -0
- msprobe/pytorch/monitor/distributed/stack_blacklist.yaml +5 -0
- msprobe/pytorch/monitor/distributed/wrap_distributed.py +283 -0
- msprobe/pytorch/monitor/features.py +108 -0
- msprobe/pytorch/monitor/module_hook.py +1076 -0
- msprobe/pytorch/monitor/module_metric.py +172 -0
- msprobe/pytorch/monitor/module_spec_verifier.py +95 -0
- msprobe/pytorch/monitor/optimizer_collect.py +333 -0
- msprobe/pytorch/monitor/unittest/__init__.py +0 -0
- msprobe/pytorch/monitor/unittest/test_monitor.py +160 -0
- msprobe/pytorch/monitor/utils.py +321 -0
- msprobe/pytorch/monitor/visualizer.py +59 -0
- msprobe/pytorch/online_dispatch/__init__.py +2 -3
- msprobe/pytorch/online_dispatch/compare.py +29 -38
- msprobe/pytorch/online_dispatch/dispatch.py +58 -27
- msprobe/pytorch/online_dispatch/dump_compare.py +21 -9
- msprobe/pytorch/online_dispatch/single_compare.py +53 -32
- msprobe/pytorch/online_dispatch/torch_ops_config.yaml +1 -1
- msprobe/pytorch/online_dispatch/utils.py +49 -21
- msprobe/pytorch/parse_tool/lib/compare.py +21 -27
- msprobe/pytorch/parse_tool/lib/config.py +6 -8
- 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 +12 -12
- msprobe/pytorch/parse_tool/lib/utils.py +33 -53
- msprobe/pytorch/parse_tool/lib/visualization.py +11 -10
- msprobe/pytorch/pt_config.py +31 -8
- msprobe/pytorch/service.py +188 -108
- msprobe/visualization/__init__.py +14 -0
- msprobe/visualization/builder/__init__.py +14 -0
- msprobe/visualization/builder/graph_builder.py +222 -0
- msprobe/visualization/builder/msprobe_adapter.py +227 -0
- msprobe/visualization/compare/__init__.py +14 -0
- msprobe/visualization/compare/graph_comparator.py +180 -0
- msprobe/visualization/compare/mode_adapter.py +197 -0
- msprobe/visualization/graph/__init__.py +14 -0
- msprobe/visualization/graph/base_node.py +119 -0
- msprobe/visualization/graph/distributed_analyzer.py +318 -0
- msprobe/visualization/graph/graph.py +209 -0
- msprobe/visualization/graph/node_colors.py +95 -0
- msprobe/visualization/graph/node_op.py +39 -0
- msprobe/visualization/graph_service.py +288 -0
- msprobe/visualization/utils.py +217 -0
- mindstudio_probe-1.1.0.dist-info/RECORD +0 -287
- msprobe/docs/04.acl_config_examples.md +0 -78
- msprobe/mindspore/compare/layer_mapping.py +0 -146
- msprobe/mindspore/compare/modify_mapping.py +0 -107
- msprobe/mindspore/free_benchmark/decorator/dec_forward.py +0 -57
- msprobe/mindspore/free_benchmark/decorator/decorator_factory.py +0 -122
- msprobe/pytorch/functional/module_dump.py +0 -84
- {mindstudio_probe-1.1.0.dist-info → mindstudio_probe-1.2.1.dist-info}/LICENSE +0 -0
- {mindstudio_probe-1.1.0.dist-info → mindstudio_probe-1.2.1.dist-info}/top_level.txt +0 -0
- /msprobe/mindspore/{free_benchmark/decorator → code_mapping}/__init__.py +0 -0
- /msprobe/pytorch/{functional → dump/module_dump}/__init__.py +0 -0
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
# List of apis that support self check
|
|
2
|
-
|
|
3
|
-
communication:
|
|
4
|
-
- all_gather_into_tensor
|
|
5
|
-
- gather_into_tensor
|
|
6
|
-
- all_reduce
|
|
7
|
-
- reduce
|
|
8
|
-
- reduce_scatter_tensor
|
|
9
2
|
|
|
10
3
|
ops:
|
|
11
4
|
- adaptive_avg_pool1d
|
|
@@ -18,18 +11,10 @@ ops:
|
|
|
18
11
|
- avg_pool3d
|
|
19
12
|
- batch_norm
|
|
20
13
|
- bias_add
|
|
21
|
-
- ctc_greedy_decoder
|
|
22
14
|
- conv1d
|
|
23
15
|
- conv2d
|
|
24
16
|
- conv3d
|
|
25
17
|
- deformable_conv2d
|
|
26
|
-
- dense
|
|
27
|
-
- dropout
|
|
28
|
-
- dropout1d
|
|
29
|
-
- dropout2d
|
|
30
|
-
- dropout3d
|
|
31
|
-
- flatten
|
|
32
|
-
- fold
|
|
33
18
|
- fractional_max_pool3d
|
|
34
19
|
- lp_pool1d
|
|
35
20
|
- lp_pool2d
|
|
@@ -39,7 +24,6 @@ ops:
|
|
|
39
24
|
- max_unpool1d
|
|
40
25
|
- max_unpool2d
|
|
41
26
|
- max_unpool3d
|
|
42
|
-
- unfold
|
|
43
27
|
- binary_cross_entropy
|
|
44
28
|
- binary_cross_entropy_with_logits
|
|
45
29
|
- cosine_embedding_loss
|
|
@@ -105,8 +89,6 @@ ops:
|
|
|
105
89
|
- pixel_shuffle
|
|
106
90
|
- pixel_unshuffle
|
|
107
91
|
- upsample
|
|
108
|
-
- abs
|
|
109
|
-
- absolute
|
|
110
92
|
- accumulate_n
|
|
111
93
|
- acos
|
|
112
94
|
- arccos
|
|
@@ -143,16 +125,9 @@ ops:
|
|
|
143
125
|
- bessel_k1e
|
|
144
126
|
- bessel_y0
|
|
145
127
|
- bessel_y1
|
|
146
|
-
- bitwise_and
|
|
147
|
-
- bitwise_left_shift
|
|
148
|
-
- bitwise_or
|
|
149
|
-
- bitwise_right_shift
|
|
150
|
-
- bitwise_xor
|
|
151
128
|
- ceil
|
|
152
129
|
- clamp
|
|
153
130
|
- clip
|
|
154
|
-
- combinations
|
|
155
|
-
- copysign
|
|
156
131
|
- cos
|
|
157
132
|
- cosh
|
|
158
133
|
- cosine_similarity
|
|
@@ -200,12 +175,8 @@ ops:
|
|
|
200
175
|
- mul
|
|
201
176
|
- multiply
|
|
202
177
|
- mvlgamma
|
|
203
|
-
- neg
|
|
204
|
-
- negative
|
|
205
|
-
- nextafter
|
|
206
178
|
- polar
|
|
207
179
|
- polygamma
|
|
208
|
-
- positive
|
|
209
180
|
- pow
|
|
210
181
|
- rad2deg
|
|
211
182
|
- ravel
|
|
@@ -225,7 +196,6 @@ ops:
|
|
|
225
196
|
- square
|
|
226
197
|
- sub
|
|
227
198
|
- subtract
|
|
228
|
-
- t
|
|
229
199
|
- tan
|
|
230
200
|
- tanhshrink
|
|
231
201
|
- trapz
|
|
@@ -238,11 +208,9 @@ ops:
|
|
|
238
208
|
- xdivy
|
|
239
209
|
- xlogy
|
|
240
210
|
- zeta
|
|
241
|
-
- all
|
|
242
211
|
- amax
|
|
243
212
|
- amin
|
|
244
213
|
- aminmax
|
|
245
|
-
- any
|
|
246
214
|
- argmax
|
|
247
215
|
- argmin
|
|
248
216
|
- cummax
|
|
@@ -264,28 +232,10 @@ ops:
|
|
|
264
232
|
- var_mean
|
|
265
233
|
- argsort
|
|
266
234
|
- approximate_equal
|
|
267
|
-
- equal
|
|
268
|
-
- ge
|
|
269
|
-
- greater
|
|
270
|
-
- greater_equal
|
|
271
|
-
- gt
|
|
272
235
|
- intopk
|
|
273
|
-
- isclose
|
|
274
|
-
- isfinite
|
|
275
|
-
- isinf
|
|
276
|
-
- isnan
|
|
277
|
-
- isneginf
|
|
278
|
-
- isposinf
|
|
279
|
-
- isreal
|
|
280
|
-
- le
|
|
281
|
-
- less
|
|
282
|
-
- less_equal
|
|
283
|
-
- lt
|
|
284
236
|
- maximum
|
|
285
237
|
- minimum
|
|
286
238
|
- msort
|
|
287
|
-
- ne
|
|
288
|
-
- not_equal
|
|
289
239
|
- searchsorted
|
|
290
240
|
- topk
|
|
291
241
|
- bmm
|
|
@@ -329,30 +279,12 @@ ops:
|
|
|
329
279
|
- hamming_window
|
|
330
280
|
- hann_window
|
|
331
281
|
- kaiser_window
|
|
332
|
-
- eye
|
|
333
|
-
- fill
|
|
334
|
-
- full
|
|
335
|
-
- full_like
|
|
336
|
-
- linspace
|
|
337
|
-
- logspace
|
|
338
|
-
- one_hot
|
|
339
|
-
- arange
|
|
340
|
-
- range
|
|
341
282
|
- heaviside
|
|
342
283
|
- bernoulli
|
|
343
284
|
- gamma
|
|
344
285
|
- laplace
|
|
345
286
|
- multinomial
|
|
346
287
|
- multinomial_with_replacement
|
|
347
|
-
- rand
|
|
348
|
-
- rand_like
|
|
349
|
-
- randint
|
|
350
|
-
- randint_like
|
|
351
|
-
- randn
|
|
352
|
-
- randn_like
|
|
353
|
-
- random_gamma
|
|
354
|
-
- random_poisson
|
|
355
|
-
- randperm
|
|
356
288
|
- standard_laplace
|
|
357
289
|
- standard_normal
|
|
358
290
|
- uniform
|
|
@@ -361,14 +293,10 @@ ops:
|
|
|
361
293
|
- bincount
|
|
362
294
|
- block_diag
|
|
363
295
|
- broadcast_to
|
|
364
|
-
- cat
|
|
365
296
|
- channel_shuffle
|
|
366
|
-
- chunk
|
|
367
297
|
- column_stack
|
|
368
|
-
- concat
|
|
369
298
|
- conj
|
|
370
299
|
- count_nonzero
|
|
371
|
-
- deepcopy
|
|
372
300
|
- diag
|
|
373
301
|
- diagflat
|
|
374
302
|
- diagonal
|
|
@@ -395,49 +323,22 @@ ops:
|
|
|
395
323
|
- nan_to_num
|
|
396
324
|
- nansum
|
|
397
325
|
- normal
|
|
398
|
-
- nonzero
|
|
399
326
|
- population_count
|
|
400
|
-
- rank
|
|
401
|
-
- repeat_elements
|
|
402
|
-
- repeat_interleave
|
|
403
|
-
- reshape
|
|
404
|
-
- reverse
|
|
405
|
-
- reverse_sequence
|
|
406
|
-
- roll
|
|
407
|
-
- select
|
|
408
327
|
- sequence_mask
|
|
409
|
-
- shuffle
|
|
410
|
-
- size
|
|
411
|
-
- slice
|
|
412
|
-
- sort
|
|
413
328
|
- space_to_batch_nd
|
|
414
329
|
- sparse_segment_mean
|
|
415
|
-
- split
|
|
416
|
-
- squeeze
|
|
417
|
-
- stack
|
|
418
|
-
- strided_slice
|
|
419
330
|
- sum
|
|
420
331
|
- swapaxes
|
|
421
332
|
- swapdims
|
|
422
|
-
- tensor_split
|
|
423
|
-
- tile
|
|
424
333
|
- tril
|
|
425
334
|
- triu
|
|
426
|
-
- transpose
|
|
427
335
|
- unbind
|
|
428
|
-
- unique
|
|
429
|
-
- unique_consecutive
|
|
430
|
-
- unique_with_pad
|
|
431
336
|
- unsorted_segment_max
|
|
432
337
|
- unsorted_segment_min
|
|
433
338
|
- unsorted_segment_prod
|
|
434
339
|
- unsorted_segment_sum
|
|
435
|
-
- unsqueeze
|
|
436
|
-
- unstack
|
|
437
|
-
- view_as_real
|
|
438
340
|
- vsplit
|
|
439
341
|
- vstack
|
|
440
|
-
- where
|
|
441
342
|
- cross
|
|
442
343
|
- renorm
|
|
443
344
|
- tuple_to_array
|
|
@@ -447,7 +348,6 @@ ops:
|
|
|
447
348
|
- jet
|
|
448
349
|
|
|
449
350
|
Tensor:
|
|
450
|
-
- __abs__
|
|
451
351
|
- __add__
|
|
452
352
|
- __and__
|
|
453
353
|
- __iadd__
|
|
@@ -459,8 +359,6 @@ Tensor:
|
|
|
459
359
|
- __matmul__
|
|
460
360
|
- __mod__
|
|
461
361
|
- __mul__
|
|
462
|
-
- __neg__
|
|
463
|
-
- __or__
|
|
464
362
|
- __pow__
|
|
465
363
|
- __radd__
|
|
466
364
|
- __rmatmul__
|
|
@@ -471,8 +369,6 @@ Tensor:
|
|
|
471
369
|
- __sub__
|
|
472
370
|
- __truediv__
|
|
473
371
|
- __xor__
|
|
474
|
-
- abs
|
|
475
|
-
- absolute
|
|
476
372
|
- acos
|
|
477
373
|
- acosh
|
|
478
374
|
- add
|
|
@@ -504,18 +400,11 @@ Tensor:
|
|
|
504
400
|
- baddbmm
|
|
505
401
|
- bernoulli
|
|
506
402
|
- bincount
|
|
507
|
-
- bitwise_and
|
|
508
|
-
- bitwise_or
|
|
509
|
-
- bitwise_xor
|
|
510
403
|
- bmm
|
|
511
404
|
- broadcast_to
|
|
512
|
-
- ceil
|
|
513
405
|
- cholesky_solve
|
|
514
406
|
- cholesky
|
|
515
|
-
- clamp
|
|
516
|
-
- clip
|
|
517
407
|
- conj
|
|
518
|
-
- copysign
|
|
519
408
|
- cos
|
|
520
409
|
- cosh
|
|
521
410
|
- cross
|
|
@@ -530,7 +419,6 @@ Tensor:
|
|
|
530
419
|
- digamma
|
|
531
420
|
- div
|
|
532
421
|
- divide
|
|
533
|
-
- equal
|
|
534
422
|
- erf
|
|
535
423
|
- erfc
|
|
536
424
|
- erfinv
|
|
@@ -541,14 +429,11 @@ Tensor:
|
|
|
541
429
|
- fliplr
|
|
542
430
|
- flipud
|
|
543
431
|
- float_power
|
|
544
|
-
- floor
|
|
545
432
|
- fmod
|
|
546
433
|
- frac
|
|
547
434
|
- gather_elements
|
|
548
435
|
- geqrf
|
|
549
436
|
- ger
|
|
550
|
-
- greater
|
|
551
|
-
- greater_equal
|
|
552
437
|
- half
|
|
553
438
|
- hardshrink
|
|
554
439
|
- heaviside
|
|
@@ -559,13 +444,7 @@ Tensor:
|
|
|
559
444
|
- igammac
|
|
560
445
|
- imag
|
|
561
446
|
- index_add
|
|
562
|
-
- index_fill
|
|
563
|
-
- index_put
|
|
564
|
-
- index_select
|
|
565
447
|
- inner
|
|
566
|
-
- int
|
|
567
|
-
- inverse
|
|
568
|
-
- item
|
|
569
448
|
- lcm
|
|
570
449
|
- ldexp
|
|
571
450
|
- lerp
|
|
@@ -587,30 +466,17 @@ Tensor:
|
|
|
587
466
|
- masked_scatter
|
|
588
467
|
- masked_select
|
|
589
468
|
- matmul
|
|
590
|
-
- max
|
|
591
|
-
- maximum
|
|
592
469
|
- mean
|
|
593
470
|
- median
|
|
594
|
-
- min
|
|
595
|
-
- minimum
|
|
596
471
|
- moveaxis
|
|
597
472
|
- movedim
|
|
598
|
-
- msort
|
|
599
473
|
- multinomial
|
|
600
474
|
- multiply
|
|
601
475
|
- mvlgamma
|
|
602
|
-
- nan_to_num
|
|
603
476
|
- nansum
|
|
604
477
|
- narrow
|
|
605
|
-
- neg
|
|
606
|
-
- negative
|
|
607
478
|
- nelement
|
|
608
|
-
- new_ones
|
|
609
|
-
- new_zeros
|
|
610
|
-
- nextafter
|
|
611
479
|
- norm
|
|
612
|
-
- nonzero
|
|
613
|
-
- not_equal
|
|
614
480
|
- ormqr
|
|
615
481
|
- permute
|
|
616
482
|
- pow
|
|
@@ -622,10 +488,6 @@ Tensor:
|
|
|
622
488
|
- remainder
|
|
623
489
|
- renorm
|
|
624
490
|
- rad2deg
|
|
625
|
-
- tile
|
|
626
|
-
- repeat_interleave
|
|
627
|
-
- reshape
|
|
628
|
-
- reshape
|
|
629
491
|
- round
|
|
630
492
|
- rot90
|
|
631
493
|
- rsqrt
|
|
@@ -641,73 +503,44 @@ Tensor:
|
|
|
641
503
|
- sinh
|
|
642
504
|
- slogdet
|
|
643
505
|
- sort
|
|
644
|
-
- split
|
|
645
506
|
- sqrt
|
|
646
507
|
- square
|
|
647
|
-
- squeeze
|
|
648
508
|
- std
|
|
649
509
|
- subtract
|
|
650
510
|
- subtract
|
|
651
511
|
- svd
|
|
652
512
|
- swapaxes
|
|
653
513
|
- swapdims
|
|
654
|
-
- t
|
|
655
|
-
- take
|
|
656
514
|
- tan
|
|
657
515
|
- tanh
|
|
658
516
|
- trace
|
|
659
517
|
- swapaxes
|
|
660
|
-
- tile
|
|
661
518
|
- topk
|
|
662
519
|
- tril
|
|
663
|
-
- tensor_split
|
|
664
|
-
- transpose
|
|
665
520
|
- true_divide
|
|
666
521
|
- trunc
|
|
667
522
|
- unbind
|
|
668
523
|
- unique_consecutive
|
|
669
|
-
- unsqueeze
|
|
670
524
|
- var
|
|
671
|
-
- view
|
|
672
|
-
- where
|
|
673
525
|
- xlogy
|
|
674
526
|
- from_numpy
|
|
675
527
|
- std
|
|
676
|
-
- take
|
|
677
528
|
- var
|
|
678
|
-
- all
|
|
679
|
-
- any
|
|
680
|
-
- copy
|
|
681
529
|
- diagonal
|
|
682
|
-
- flatten
|
|
683
|
-
- resize
|
|
684
530
|
- sum
|
|
685
531
|
|
|
686
532
|
mint:
|
|
687
|
-
- abs
|
|
688
|
-
- absolute_import
|
|
689
533
|
- add
|
|
690
534
|
- add_ex
|
|
691
|
-
- all
|
|
692
|
-
- any
|
|
693
535
|
- any_ex
|
|
694
|
-
- arange
|
|
695
536
|
- argmax
|
|
696
537
|
- avg_pool2d
|
|
697
538
|
- baddbmm
|
|
698
539
|
- baddbmm_ex
|
|
699
540
|
- batch_norm
|
|
700
541
|
- binary_cross_entropy_with_logits
|
|
701
|
-
- bitwise_and
|
|
702
|
-
- bitwise_or
|
|
703
|
-
- bitwise_xor
|
|
704
542
|
- bmm
|
|
705
543
|
- broadcast_to
|
|
706
|
-
- cat
|
|
707
|
-
- cat_ex
|
|
708
|
-
- ceil
|
|
709
|
-
- chunk
|
|
710
|
-
- clamp
|
|
711
544
|
- conv2d
|
|
712
545
|
- conv_transpose2d
|
|
713
546
|
- cos
|
|
@@ -717,59 +550,32 @@ mint:
|
|
|
717
550
|
- cumsum
|
|
718
551
|
- div
|
|
719
552
|
- divide
|
|
720
|
-
- dropout
|
|
721
553
|
- embedding
|
|
722
|
-
- eq
|
|
723
554
|
- erf
|
|
724
555
|
- erfinv
|
|
725
556
|
- exp
|
|
726
|
-
- flatten
|
|
727
|
-
- flip
|
|
728
|
-
- flip_ex
|
|
729
|
-
- fold
|
|
730
|
-
- full
|
|
731
557
|
- gather
|
|
732
558
|
- gelu
|
|
733
559
|
- greater
|
|
734
560
|
- grid_sample
|
|
735
561
|
- group_norm
|
|
736
|
-
- gt
|
|
737
562
|
- index_select
|
|
738
563
|
- interpolate
|
|
739
|
-
- isclose
|
|
740
|
-
- isfinite
|
|
741
564
|
- layer_norm
|
|
742
|
-
- le
|
|
743
565
|
- leaky_relu
|
|
744
|
-
- less
|
|
745
|
-
- less_equal
|
|
746
566
|
- linear
|
|
747
567
|
- linspace
|
|
748
568
|
- log
|
|
749
569
|
- logical_and
|
|
750
570
|
- logical_not
|
|
751
571
|
- logical_or
|
|
752
|
-
- lt
|
|
753
572
|
- masked_select
|
|
754
573
|
- matmul
|
|
755
|
-
- max
|
|
756
574
|
- max_pool2d
|
|
757
|
-
- maximum
|
|
758
575
|
- mean
|
|
759
576
|
- mean_ex
|
|
760
|
-
- min
|
|
761
|
-
- minimum
|
|
762
577
|
- mul
|
|
763
|
-
- ne
|
|
764
|
-
- neg
|
|
765
|
-
- negative
|
|
766
|
-
- nonzero
|
|
767
578
|
- normal
|
|
768
|
-
- one_hot
|
|
769
|
-
- ones
|
|
770
|
-
- ones_ex
|
|
771
|
-
- ones_like
|
|
772
|
-
- pad
|
|
773
579
|
- permute
|
|
774
580
|
- permute_ex
|
|
775
581
|
- pow
|
|
@@ -786,7 +592,6 @@ mint:
|
|
|
786
592
|
- softmax
|
|
787
593
|
- softplus
|
|
788
594
|
- sort
|
|
789
|
-
- split
|
|
790
595
|
- sqrt
|
|
791
596
|
- sqrt_ex
|
|
792
597
|
- square
|
|
@@ -795,17 +600,9 @@ mint:
|
|
|
795
600
|
- sub_ex
|
|
796
601
|
- sum
|
|
797
602
|
- tanh
|
|
798
|
-
- tile
|
|
799
603
|
- topk
|
|
800
|
-
- tril
|
|
801
604
|
- triu
|
|
802
|
-
- unfold
|
|
803
|
-
- unique
|
|
804
|
-
- where
|
|
805
605
|
- xlogy
|
|
806
|
-
- zeros
|
|
807
|
-
- zeros_ex
|
|
808
|
-
- zeros_like
|
|
809
606
|
|
|
810
607
|
mint.nn.functional:
|
|
811
608
|
- absolute_import
|
|
@@ -816,7 +613,6 @@ mint.nn.functional:
|
|
|
816
613
|
- binary_cross_entropy_with_logits
|
|
817
614
|
- conv_transpose2d
|
|
818
615
|
- dense
|
|
819
|
-
- dropout
|
|
820
616
|
- embedding
|
|
821
617
|
- fold
|
|
822
618
|
- gelu
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2024-2024, Huawei Technologies Co., Ltd.
|
|
2
2
|
# All rights reserved.
|
|
3
3
|
#
|
|
4
|
-
# Licensed under the Apache License, Version 2.0
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
# you may not use this file except in compliance with the License.
|
|
6
6
|
# You may obtain a copy of the License at
|
|
7
7
|
#
|
|
@@ -28,8 +28,8 @@ from msprobe.mindspore.free_benchmark.common.utils import Tools
|
|
|
28
28
|
|
|
29
29
|
class BaseHandler(ABC):
|
|
30
30
|
|
|
31
|
-
def __init__(self,
|
|
32
|
-
self.
|
|
31
|
+
def __init__(self, api_name_with_id: str):
|
|
32
|
+
self.api_name_with_id = api_name_with_id
|
|
33
33
|
|
|
34
34
|
@staticmethod
|
|
35
35
|
def pre_calculate(original_output, fuzzed_output):
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2024-2024, Huawei Technologies Co., Ltd.
|
|
2
2
|
# All rights reserved.
|
|
3
3
|
#
|
|
4
|
-
# Licensed under the Apache License, Version 2.0
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
# you may not use this file except in compliance with the License.
|
|
6
6
|
# You may obtain a copy of the License at
|
|
7
7
|
#
|
|
@@ -32,19 +32,19 @@ class CheckHandler(BaseHandler):
|
|
|
32
32
|
is_consistent, ratio = self.npu_compare(original_output, fuzzed_output)
|
|
33
33
|
params.is_consistent = params.is_consistent and is_consistent
|
|
34
34
|
if not is_consistent:
|
|
35
|
-
row = make_unequal_row(self.
|
|
35
|
+
row = make_unequal_row(self.api_name_with_id, params, ratio, output_index)
|
|
36
36
|
data_dict = asdict(row)
|
|
37
37
|
DataWriter.write_data_to_csv(
|
|
38
38
|
data_dict.values(),
|
|
39
39
|
data_dict.keys(),
|
|
40
40
|
Config.dump_path
|
|
41
41
|
)
|
|
42
|
-
logger.error(f"{self.
|
|
42
|
+
logger.error(f"{self.api_name_with_id} is not consistent")
|
|
43
43
|
|
|
44
44
|
def handle(self, params: HandlerParams) -> Any:
|
|
45
45
|
try:
|
|
46
46
|
if not self.is_float_tensor(params.fuzzed_result):
|
|
47
|
-
return
|
|
47
|
+
return
|
|
48
48
|
if isinstance(params.fuzzed_result, Tensor):
|
|
49
49
|
self.npu_compare_and_save(params.original_result, params.fuzzed_result, params)
|
|
50
50
|
elif isinstance(params.fuzzed_result, (list, tuple)):
|
|
@@ -53,4 +53,3 @@ class CheckHandler(BaseHandler):
|
|
|
53
53
|
self.npu_compare_and_save(item, params.fuzzed_result[i], params, output_index=i)
|
|
54
54
|
except Exception as e:
|
|
55
55
|
logger.error(str(e))
|
|
56
|
-
return params.original_result
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2024-2024, Huawei Technologies Co., Ltd.
|
|
2
2
|
# All rights reserved.
|
|
3
3
|
#
|
|
4
|
-
# Licensed under the Apache License, Version 2.0
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
# you may not use this file except in compliance with the License.
|
|
6
6
|
# You may obtain a copy of the License at
|
|
7
7
|
#
|
|
@@ -23,8 +23,8 @@ from msprobe.mindspore.free_benchmark.common.handler_params import HandlerParams
|
|
|
23
23
|
|
|
24
24
|
class FixHandler:
|
|
25
25
|
|
|
26
|
-
def __init__(self,
|
|
27
|
-
self.
|
|
26
|
+
def __init__(self, api_name_with_id: str):
|
|
27
|
+
self.api_name_with_id = api_name_with_id
|
|
28
28
|
|
|
29
29
|
@staticmethod
|
|
30
30
|
def use_fuzzed_result(original_result, fuzzed_result):
|
|
@@ -46,6 +46,6 @@ class FixHandler:
|
|
|
46
46
|
try:
|
|
47
47
|
return FixHandler.use_fuzzed_result(params.original_result, params.fuzzed_result)
|
|
48
48
|
except Exception as e:
|
|
49
|
-
logger.error(f"{self.
|
|
49
|
+
logger.error(f"{self.api_name_with_id} failed to fix.")
|
|
50
50
|
logger.error(str(e))
|
|
51
51
|
return params.original_result
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2024-2024, Huawei Technologies Co., Ltd.
|
|
2
2
|
# All rights reserved.
|
|
3
3
|
#
|
|
4
|
-
# Licensed under the Apache License, Version 2.0
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
# you may not use this file except in compliance with the License.
|
|
6
6
|
# You may obtain a copy of the License at
|
|
7
7
|
#
|
|
@@ -23,14 +23,14 @@ from msprobe.mindspore.free_benchmark.handler.fix_handler import FixHandler
|
|
|
23
23
|
class HandlerFactory:
|
|
24
24
|
result_handlers = {
|
|
25
25
|
FreeBenchmarkConst.CHECK: CheckHandler,
|
|
26
|
-
FreeBenchmarkConst.FIX: FixHandler
|
|
26
|
+
FreeBenchmarkConst.FIX: FixHandler
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
@staticmethod
|
|
30
|
-
def create(
|
|
30
|
+
def create(api_name_with_id: str):
|
|
31
31
|
handler = HandlerFactory.result_handlers.get(Config.handler_type)
|
|
32
32
|
if handler:
|
|
33
|
-
return handler(
|
|
33
|
+
return handler(api_name_with_id)
|
|
34
34
|
else:
|
|
35
35
|
logger.error(f"{Config.handler_type} is not supported.")
|
|
36
36
|
raise Exception
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2024-2024, Huawei Technologies Co., Ltd.
|
|
2
2
|
# All rights reserved.
|
|
3
3
|
#
|
|
4
|
-
# Licensed under the Apache License, Version 2.0
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
# you may not use this file except in compliance with the License.
|
|
6
6
|
# You may obtain a copy of the License at
|
|
7
7
|
#
|
|
@@ -32,7 +32,7 @@ class AddNoisePerturbation(BasePerturbation):
|
|
|
32
32
|
"""
|
|
33
33
|
params.fuzzed_value = self.add_noise(params.args[params.index])
|
|
34
34
|
if not self.is_fuzzed:
|
|
35
|
-
logger.warning(f"{self.
|
|
35
|
+
logger.warning(f"{self.api_name_with_id} can not add noise.")
|
|
36
36
|
return False
|
|
37
37
|
return self.get_fuzzed_result(params)
|
|
38
38
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2024-2024, Huawei Technologies Co., Ltd.
|
|
2
2
|
# All rights reserved.
|
|
3
3
|
#
|
|
4
|
-
# Licensed under the Apache License, Version 2.0
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
# you may not use this file except in compliance with the License.
|
|
6
6
|
# You may obtain a copy of the License at
|
|
7
7
|
#
|
|
@@ -15,21 +15,30 @@
|
|
|
15
15
|
|
|
16
16
|
from typing import Any
|
|
17
17
|
|
|
18
|
+
from msprobe.core.common.const import Const
|
|
19
|
+
from msprobe.mindspore.free_benchmark.common.config import Config
|
|
18
20
|
from msprobe.mindspore.free_benchmark.common.handler_params import HandlerParams
|
|
21
|
+
from msprobe.mindspore.free_benchmark.common.utils import Tools
|
|
19
22
|
|
|
20
23
|
|
|
21
24
|
class BasePerturbation:
|
|
22
25
|
|
|
23
|
-
def __init__(self,
|
|
24
|
-
self.
|
|
26
|
+
def __init__(self, api_name_with_id: str):
|
|
27
|
+
self.api_name_with_id = api_name_with_id
|
|
25
28
|
self.is_fuzzed = False
|
|
26
29
|
self.perturbation_value = None
|
|
27
30
|
|
|
28
31
|
@staticmethod
|
|
29
32
|
def get_fuzzed_result(params: HandlerParams):
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
if Config.stage == Const.BACKWARD:
|
|
34
|
+
fuzzed_result = Tools.get_grad(params.original_func, *params.args[:params.index],
|
|
35
|
+
params.fuzzed_value, *params.args[params.index + 1:], **params.kwargs)
|
|
36
|
+
|
|
37
|
+
if fuzzed_result is None:
|
|
38
|
+
return False
|
|
39
|
+
else:
|
|
40
|
+
fuzzed_result = params.original_func(*params.args[:params.index], params.fuzzed_value,
|
|
41
|
+
*params.args[params.index + 1:], **params.kwargs)
|
|
33
42
|
return fuzzed_result
|
|
34
43
|
|
|
35
44
|
def handler(self, params: HandlerParams) -> Any:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2024-2024, Huawei Technologies Co., Ltd.
|
|
2
2
|
# All rights reserved.
|
|
3
3
|
#
|
|
4
|
-
# Licensed under the Apache License, Version 2.0
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
# you may not use this file except in compliance with the License.
|
|
6
6
|
# You may obtain a copy of the License at
|
|
7
7
|
#
|
|
@@ -55,7 +55,7 @@ class BitNoisePerturbation(BasePerturbation):
|
|
|
55
55
|
args = params.args
|
|
56
56
|
params.fuzzed_value = self.add_bit_noise(params.args[params.index])
|
|
57
57
|
if not self.is_fuzzed:
|
|
58
|
-
logger.warning(f"{self.
|
|
58
|
+
logger.warning(f"{self.api_name_with_id} can not add bit noise.")
|
|
59
59
|
return False
|
|
60
60
|
params.args = args
|
|
61
61
|
return self.get_fuzzed_result(params)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2024-2024, Huawei Technologies Co., Ltd.
|
|
2
2
|
# All rights reserved.
|
|
3
3
|
#
|
|
4
|
-
# Licensed under the Apache License, Version 2.0
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
# you may not use this file except in compliance with the License.
|
|
6
6
|
# You may obtain a copy of the License at
|
|
7
7
|
#
|
|
@@ -41,7 +41,7 @@ class ExchangeValuePerturbation(BasePerturbation):
|
|
|
41
41
|
"""
|
|
42
42
|
params.fuzzed_value = self.exchange_value(params.args[params.index])
|
|
43
43
|
if not self.is_fuzzed:
|
|
44
|
-
logger.warning(f"{self.
|
|
44
|
+
logger.warning(f"{self.api_name_with_id} can not exchange value.")
|
|
45
45
|
return False
|
|
46
46
|
return self.get_fuzzed_result(params)
|
|
47
47
|
|