mindspore 2.6.0__cp311-cp311-win_amd64.whl → 2.7.0__cp311-cp311-win_amd64.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.
Potentially problematic release.
This version of mindspore might be problematic. Click here for more details.
- mindspore/.commit_id +1 -1
- mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
- mindspore/Newtonsoft.Json.dll +0 -0
- mindspore/__init__.py +2 -2
- mindspore/_c_dataengine.cp311-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp311-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp311-win_amd64.pyd +0 -0
- mindspore/_checkparam.py +42 -11
- mindspore/_extends/builtin_operations.py +3 -3
- mindspore/{_deprecated → _extends/optimize}/__init__.py +9 -3
- mindspore/_extends/optimize/cell_utils.py +96 -0
- mindspore/_extends/parallel_compile/akg_compiler/custom.py +1109 -0
- mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
- mindspore/_extends/parse/__init__.py +3 -3
- mindspore/_extends/parse/compile_config.py +44 -22
- mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +1 -2
- mindspore/_extends/parse/parser.py +64 -83
- mindspore/_extends/parse/resources.py +39 -0
- mindspore/_extends/parse/standard_method.py +47 -14
- mindspore/_extends/parse/trope.py +8 -1
- mindspore/_extends/pijit/__init__.py +1 -2
- mindspore/_extends/pijit/pijit_func_white_list.py +2 -5
- mindspore/amp.py +4 -22
- mindspore/atlprov.dll +0 -0
- mindspore/avcodec-59.dll +0 -0
- mindspore/avdevice-59.dll +0 -0
- mindspore/avfilter-8.dll +0 -0
- mindspore/avformat-59.dll +0 -0
- mindspore/avutil-57.dll +0 -0
- mindspore/boost/adasum.py +1 -1
- mindspore/boost/boost_cell_wrapper.py +4 -4
- mindspore/c1.dll +0 -0
- mindspore/c1xx.dll +0 -0
- mindspore/c2.dll +0 -0
- mindspore/common/__init__.py +43 -12
- mindspore/common/_grad_function.py +2 -1
- mindspore/common/_pijit_context.py +28 -7
- mindspore/common/_stub_tensor.py +1 -209
- mindspore/common/_tensor_cpp_method.py +1 -1
- mindspore/common/_tensor_docs.py +177 -52
- mindspore/common/_utils.py +9 -1
- mindspore/common/api.py +338 -208
- mindspore/common/dtype.py +108 -57
- mindspore/common/dump.py +11 -16
- mindspore/common/dynamic_shape/__init__.py +0 -0
- mindspore/common/{auto_dynamic_shape.py → dynamic_shape/auto_dynamic_shape.py} +17 -23
- mindspore/common/dynamic_shape/enable_dynamic.py +197 -0
- mindspore/common/file_system.py +59 -9
- mindspore/common/generator.py +2 -3
- mindspore/common/hook_handle.py +33 -5
- mindspore/common/jit_config.py +1 -1
- mindspore/common/jit_trace.py +84 -105
- mindspore/common/np_dtype.py +3 -3
- mindspore/common/parameter.py +27 -29
- mindspore/common/recompute.py +5 -7
- mindspore/common/sparse_tensor.py +0 -3
- mindspore/common/symbol.py +0 -1
- mindspore/common/tensor.py +84 -133
- mindspore/communication/_comm_helper.py +46 -4
- mindspore/communication/management.py +79 -7
- mindspore/context.py +47 -38
- mindspore/dataset/__init__.py +1 -1
- mindspore/dataset/audio/transforms.py +1 -1
- mindspore/dataset/core/config.py +38 -4
- mindspore/dataset/engine/datasets.py +350 -322
- mindspore/dataset/engine/datasets_user_defined.py +69 -23
- mindspore/dataset/engine/iterators.py +2 -2
- mindspore/dataset/engine/obs/config_loader.py +2 -2
- mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +8 -0
- mindspore/dataset/transforms/c_transforms.py +2 -2
- mindspore/dataset/transforms/py_transforms.py +7 -3
- mindspore/dataset/transforms/transforms.py +10 -6
- mindspore/dataset/vision/__init__.py +1 -1
- mindspore/dataset/vision/py_transforms.py +8 -8
- mindspore/dataset/vision/transforms.py +17 -5
- mindspore/dataset/vision/utils.py +632 -21
- mindspore/dataset/vision/validators.py +1 -0
- mindspore/device_context/ascend/device.py +1 -1
- mindspore/device_context/ascend/op_tuning.py +35 -1
- mindspore/device_context/gpu/__init__.py +2 -2
- mindspore/device_context/gpu/device.py +1 -1
- mindspore/device_context/gpu/op_precision.py +4 -2
- mindspore/device_context/gpu/op_tuning.py +6 -3
- mindspore/device_manager.py +16 -9
- mindspore/dnnl.dll +0 -0
- mindspore/dpcmi.dll +0 -0
- mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +5 -4
- mindspore/experimental/llm_boost/atb/boost_base.py +2 -3
- mindspore/experimental/optim/adadelta.py +13 -20
- mindspore/experimental/optim/adagrad.py +15 -22
- mindspore/experimental/optim/adam.py +17 -24
- mindspore/experimental/optim/adamax.py +14 -22
- mindspore/experimental/optim/adamw.py +28 -34
- mindspore/experimental/optim/asgd.py +15 -25
- mindspore/experimental/optim/lr_scheduler.py +27 -45
- mindspore/experimental/optim/nadam.py +14 -24
- mindspore/experimental/optim/optimizer.py +13 -23
- mindspore/experimental/optim/radam.py +18 -24
- mindspore/experimental/optim/rmsprop.py +14 -25
- mindspore/experimental/optim/rprop.py +15 -26
- mindspore/experimental/optim/sgd.py +9 -19
- mindspore/hal/__init__.py +4 -4
- mindspore/hal/contiguous_tensors_handle.py +2 -2
- mindspore/hal/memory.py +1 -0
- mindspore/include/api/cell.h +65 -5
- mindspore/include/api/cfg.h +24 -7
- mindspore/include/api/context.h +1 -0
- mindspore/include/api/delegate.h +10 -2
- mindspore/include/api/dual_abi_helper.h +100 -19
- mindspore/include/api/graph.h +14 -1
- mindspore/include/api/kernel.h +16 -3
- mindspore/include/api/kernel_api.h +9 -1
- mindspore/include/api/metrics/accuracy.h +9 -0
- mindspore/include/api/model.h +8 -1
- mindspore/include/api/model_group.h +4 -0
- mindspore/include/api/model_parallel_runner.h +2 -0
- mindspore/include/api/status.h +48 -10
- mindspore/include/api/types.h +8 -3
- mindspore/include/c_api/model_c.h +0 -58
- mindspore/include/c_api/tensor_c.h +0 -26
- mindspore/include/dataset/constants.h +9 -0
- mindspore/include/dataset/vision_ascend.h +1 -1
- mindspore/jpeg62.dll +0 -0
- mindspore/mindrecord/tools/cifar10.py +61 -11
- mindspore/mindrecord/tools/cifar10_to_mr.py +5 -0
- mindspore/mindspore_backend_common.dll +0 -0
- mindspore/mindspore_backend_manager.dll +0 -0
- mindspore/mindspore_common.dll +0 -0
- mindspore/mindspore_core.dll +0 -0
- mindspore/mindspore_cpu_res_manager.dll +0 -0
- mindspore/mindspore_dump.dll +0 -0
- mindspore/mindspore_frontend.dll +0 -0
- mindspore/mindspore_glog.dll +0 -0
- mindspore/mindspore_memory_pool.dll +0 -0
- mindspore/mindspore_ms_backend.dll +0 -0
- mindspore/mindspore_ops.dll +0 -0
- mindspore/mindspore_ops_host.dll +0 -0
- mindspore/mindspore_ops_kernel_common.dll +0 -0
- mindspore/mindspore_profiler.dll +0 -0
- mindspore/mindspore_pyboost.dll +0 -0
- mindspore/mindspore_pynative.dll +0 -0
- mindspore/mindspore_res_manager.dll +0 -0
- mindspore/mindspore_runtime_pipeline.dll +0 -0
- mindspore/mint/__init__.py +4 -44
- mindspore/mint/distributed/__init__.py +5 -0
- mindspore/mint/distributed/distributed.py +425 -19
- mindspore/mint/nn/__init__.py +1 -1
- mindspore/mint/nn/functional.py +53 -6
- mindspore/mint/nn/layer/_functions.py +163 -294
- mindspore/mint/nn/layer/activation.py +8 -6
- mindspore/mint/nn/layer/conv.py +125 -101
- mindspore/mint/nn/layer/normalization.py +11 -25
- mindspore/mint/optim/adam.py +19 -18
- mindspore/mint/optim/adamw.py +14 -8
- mindspore/mint/optim/sgd.py +5 -5
- mindspore/msobj140.dll +0 -0
- mindspore/mspdb140.dll +0 -0
- mindspore/mspdbcore.dll +0 -0
- mindspore/mspdbst.dll +0 -0
- mindspore/mspft140.dll +0 -0
- mindspore/msvcdis140.dll +0 -0
- mindspore/msvcp140_1.dll +0 -0
- mindspore/msvcp140_2.dll +0 -0
- mindspore/msvcp140_atomic_wait.dll +0 -0
- mindspore/msvcp140_codecvt_ids.dll +0 -0
- mindspore/nn/cell.py +488 -620
- mindspore/nn/grad/cell_grad.py +11 -12
- mindspore/nn/layer/activation.py +36 -36
- mindspore/nn/layer/basic.py +74 -77
- mindspore/nn/layer/channel_shuffle.py +4 -4
- mindspore/nn/layer/combined.py +4 -2
- mindspore/nn/layer/conv.py +86 -85
- mindspore/nn/layer/dense.py +9 -7
- mindspore/nn/layer/embedding.py +50 -52
- mindspore/nn/layer/image.py +38 -40
- mindspore/nn/layer/math.py +111 -112
- mindspore/nn/layer/normalization.py +56 -44
- mindspore/nn/layer/pooling.py +58 -63
- mindspore/nn/layer/rnn_cells.py +33 -33
- mindspore/nn/layer/rnns.py +56 -56
- mindspore/nn/layer/thor_layer.py +74 -73
- mindspore/nn/layer/transformer.py +11 -1
- mindspore/nn/learning_rate_schedule.py +20 -20
- mindspore/nn/loss/loss.py +79 -81
- mindspore/nn/optim/adam.py +2 -4
- mindspore/nn/optim/adasum.py +2 -2
- mindspore/nn/optim/lamb.py +1 -3
- mindspore/nn/optim/optimizer.py +1 -1
- mindspore/nn/optim/tft_wrapper.py +2 -3
- mindspore/nn/optim/thor.py +2 -2
- mindspore/nn/probability/distribution/_utils/utils.py +2 -2
- mindspore/nn/probability/distribution/exponential.py +2 -1
- mindspore/nn/probability/distribution/poisson.py +2 -1
- mindspore/nn/sparse/sparse.py +3 -3
- mindspore/nn/wrap/cell_wrapper.py +73 -42
- mindspore/nn/wrap/grad_reducer.py +37 -52
- mindspore/nn/wrap/loss_scale.py +72 -74
- mindspore/numpy/array_creations.py +7 -7
- mindspore/numpy/fft.py +1 -1
- mindspore/numpy/math_ops.py +1 -1
- mindspore/numpy/utils_const.py +1 -1
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/opencv_imgproc452.dll +0 -0
- mindspore/ops/_grad_experimental/grad_comm_ops.py +51 -13
- mindspore/ops/_grad_experimental/grad_debug_ops.py +14 -0
- mindspore/ops/_grad_experimental/grad_inner_ops.py +0 -9
- mindspore/ops/_op_impl/cpu/__init__.py +1 -0
- mindspore/{experimental/es/__init__.py → ops/_op_impl/cpu/joinedstr_op.py} +12 -6
- mindspore/ops/_vmap/vmap_array_ops.py +6 -13
- mindspore/ops/_vmap/vmap_nn_ops.py +8 -16
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +29 -10
- mindspore/ops/auto_generate/gen_extend_func.py +5 -55
- mindspore/ops/auto_generate/gen_ops_def.py +753 -273
- mindspore/ops/auto_generate/gen_ops_prim.py +1687 -958
- mindspore/ops/auto_generate/pyboost_inner_prim.py +31 -1
- mindspore/ops/composite/__init__.py +10 -0
- mindspore/ops/composite/base.py +9 -5
- mindspore/ops/composite/multitype_ops/__init__.py +12 -1
- mindspore/ops/composite/multitype_ops/_compile_utils.py +132 -108
- mindspore/ops/composite/multitype_ops/_constexpr_utils.py +1 -1
- mindspore/ops/composite/multitype_ops/add_impl.py +70 -2
- mindspore/ops/composite/multitype_ops/div_impl.py +49 -0
- mindspore/ops/composite/multitype_ops/floordiv_impl.py +29 -0
- mindspore/ops/composite/multitype_ops/getitem_impl.py +11 -0
- mindspore/ops/composite/multitype_ops/mod_impl.py +5 -3
- mindspore/ops/composite/multitype_ops/mul_impl.py +49 -0
- mindspore/ops/composite/multitype_ops/setitem_impl.py +57 -0
- mindspore/ops/composite/multitype_ops/sub_impl.py +34 -0
- mindspore/ops/composite/multitype_ops/zeros_like_impl.py +14 -0
- mindspore/ops/function/__init__.py +4 -1
- mindspore/ops/function/_add_attr_func.py +11 -6
- mindspore/ops/function/array_func.py +17 -100
- mindspore/ops/function/debug_func.py +8 -5
- mindspore/ops/function/grad/grad_func.py +5 -13
- mindspore/ops/function/math_func.py +65 -399
- mindspore/ops/function/nn_func.py +44 -61
- mindspore/ops/function/other_func.py +4 -1
- mindspore/ops/function/random_func.py +31 -4
- mindspore/ops/functional.py +2 -3
- mindspore/ops/functional_overload.py +486 -18
- mindspore/ops/op_info_register.py +21 -0
- mindspore/ops/operations/__init__.py +5 -2
- mindspore/ops/operations/_custom_ops_utils.py +675 -8
- mindspore/ops/operations/_inner_ops.py +14 -18
- mindspore/ops/operations/_sequence_ops.py +1 -1
- mindspore/ops/operations/array_ops.py +4 -50
- mindspore/ops/operations/comm_ops.py +186 -41
- mindspore/ops/operations/custom_ops.py +244 -175
- mindspore/ops/operations/debug_ops.py +55 -4
- mindspore/ops/operations/image_ops.py +13 -13
- mindspore/ops/operations/manually_defined/ops_def.py +27 -28
- mindspore/ops/operations/math_ops.py +8 -9
- mindspore/ops/operations/nn_ops.py +6 -7
- mindspore/ops/primitive.py +9 -20
- mindspore/ops/tensor_method.py +52 -11
- mindspore/ops_generate/api/cpp_create_prim_instance_helper_generator.py +1 -1
- mindspore/ops_generate/api/functional_map_cpp_generator.py +10 -9
- mindspore/ops_generate/api/functions_cc_generator.py +58 -10
- mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +1 -1
- mindspore/ops_generate/common/base_generator.py +14 -0
- mindspore/ops_generate/common/gen_constants.py +7 -2
- mindspore/ops_generate/common/gen_utils.py +0 -19
- mindspore/ops_generate/common/op_proto.py +11 -4
- mindspore/ops_generate/common/template.py +88 -11
- mindspore/ops_generate/gen_ops.py +1 -1
- mindspore/ops_generate/op_def/lite_ops_cpp_generator.py +4 -4
- mindspore/ops_generate/op_def/ops_name_h_generator.py +0 -3
- mindspore/ops_generate/op_def/ops_primitive_h_generator.py +0 -4
- mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -2
- mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +49 -8
- mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +2 -2
- mindspore/ops_generate/pyboost/gen_pyboost_func.py +31 -16
- mindspore/ops_generate/pyboost/op_template_parser.py +98 -72
- mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +70 -273
- mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +14 -6
- mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +316 -0
- mindspore/ops_generate/pyboost/pyboost_functions_py_generator.py +1 -1
- mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +5 -3
- mindspore/ops_generate/pyboost/pyboost_inner_prim_generator.py +1 -1
- mindspore/ops_generate/pyboost/pyboost_internal_functions_cpp_generator.py +76 -0
- mindspore/ops_generate/pyboost/pyboost_internal_functions_h_generator.py +76 -0
- mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +125 -0
- mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +4 -3
- mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +348 -61
- mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +1 -1
- mindspore/ops_generate/pyboost/pyboost_utils.py +118 -9
- mindspore/ops_generate/tensor_py_cc_generator.py +1 -24
- mindspore/parallel/_auto_parallel_context.py +9 -17
- mindspore/parallel/_cell_wrapper.py +106 -40
- mindspore/parallel/_parallel_serialization.py +4 -3
- mindspore/parallel/_ps_context.py +4 -6
- mindspore/parallel/_tensor.py +167 -12
- mindspore/parallel/_transformer/moe.py +1 -1
- mindspore/parallel/_transformer/transformer.py +17 -12
- mindspore/parallel/_utils.py +5 -11
- mindspore/parallel/auto_parallel.py +33 -12
- mindspore/parallel/checkpoint_convert.py +3 -3
- mindspore/parallel/checkpoint_transform.py +5 -1
- mindspore/parallel/cluster/process_entity/_api.py +88 -49
- mindspore/parallel/cluster/process_entity/_utils.py +95 -7
- mindspore/parallel/cluster/run.py +48 -7
- mindspore/parallel/function/__init__.py +8 -1
- mindspore/parallel/function/reshard_func.py +7 -6
- mindspore/parallel/nn/__init__.py +15 -2
- mindspore/parallel/nn/parallel_cell_wrapper.py +50 -14
- mindspore/parallel/nn/parallel_grad_reducer.py +7 -14
- mindspore/parallel/shard.py +9 -23
- mindspore/parallel/transform_safetensors.py +468 -174
- mindspore/pgodb140.dll +0 -0
- mindspore/pgort140.dll +0 -0
- mindspore/profiler/__init__.py +2 -1
- mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +7 -7
- mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +3 -0
- mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +3 -0
- mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +3 -3
- mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +3 -3
- mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +4 -4
- mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +3 -3
- mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +4 -1
- mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +2 -1
- mindspore/profiler/analysis/task_manager.py +1 -1
- mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +5 -1
- mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +2 -1
- mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +10 -9
- mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +43 -23
- mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +3 -2
- mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +9 -5
- mindspore/profiler/analysis/viewer/ms_operator_details_viewer.py +132 -0
- mindspore/profiler/common/constant.py +16 -0
- mindspore/profiler/common/msprof_cmd_tool.py +2 -2
- mindspore/profiler/common/path_manager.py +9 -0
- mindspore/profiler/common/profiler_context.py +50 -29
- mindspore/profiler/common/profiler_info.py +0 -16
- mindspore/profiler/common/profiler_meta_data.py +1 -0
- mindspore/profiler/common/profiler_op_analyse.py +239 -0
- mindspore/profiler/common/profiler_output_path.py +23 -8
- mindspore/profiler/common/profiler_parameters.py +128 -35
- mindspore/profiler/dynamic_profile/__init__.py +0 -0
- mindspore/profiler/dynamic_profile/dynamic_monitor_proxy.py +39 -0
- mindspore/profiler/dynamic_profile/dynamic_profiler_config_context.py +666 -0
- mindspore/profiler/dynamic_profile/dynamic_profiler_utils.py +62 -0
- mindspore/profiler/dynamic_profiler.py +374 -338
- mindspore/profiler/envprofiler.py +42 -12
- mindspore/profiler/experimental_config.py +112 -7
- mindspore/profiler/mstx.py +33 -12
- mindspore/profiler/platform/__init__.py +2 -3
- mindspore/profiler/platform/cpu_profiler.py +10 -4
- mindspore/profiler/platform/npu_profiler.py +30 -20
- mindspore/profiler/profiler.py +218 -154
- mindspore/profiler/profiler_action_controller.py +65 -77
- mindspore/profiler/profiler_interface.py +2 -2
- mindspore/profiler/schedule.py +10 -4
- mindspore/rewrite/common/config.py +1 -0
- mindspore/rewrite/common/namer.py +1 -0
- mindspore/rewrite/common/namespace.py +1 -0
- mindspore/rewrite/node/node.py +31 -11
- mindspore/rewrite/parsers/assign_parser.py +1 -1
- mindspore/rewrite/symbol_tree/symbol_tree.py +2 -2
- mindspore/run_check/_check_version.py +7 -10
- mindspore/runtime/__init__.py +8 -6
- mindspore/runtime/event.py +10 -4
- mindspore/runtime/executor.py +87 -45
- mindspore/runtime/memory.py +22 -30
- mindspore/runtime/thread_bind_core.py +299 -165
- mindspore/safeguard/rewrite_obfuscation.py +12 -13
- mindspore/swresample-4.dll +0 -0
- mindspore/swscale-6.dll +0 -0
- mindspore/tbbmalloc.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/_utils.py +9 -5
- mindspore/train/amp.py +43 -23
- mindspore/train/callback/__init__.py +5 -5
- mindspore/train/callback/_callback.py +2 -1
- mindspore/train/callback/_checkpoint.py +4 -14
- mindspore/train/callback/_flops_collector.py +11 -7
- mindspore/train/callback/_landscape.py +0 -1
- mindspore/train/callback/_train_fault_tolerance.py +72 -18
- mindspore/train/data_sink.py +15 -6
- mindspore/train/dataset_helper.py +14 -5
- mindspore/train/model.py +49 -47
- mindspore/train/serialization.py +168 -126
- mindspore/train/summary/summary_record.py +13 -2
- mindspore/train/train_thor/model_thor.py +2 -2
- mindspore/turbojpeg.dll +0 -0
- mindspore/utils/__init__.py +3 -2
- mindspore/utils/dryrun.py +0 -6
- mindspore/utils/runtime_execution_order_check.py +162 -78
- mindspore/utils/sdc_detect.py +68 -0
- mindspore/utils/utils.py +14 -17
- mindspore/vcmeta.dll +0 -0
- mindspore/vcruntime140.dll +0 -0
- mindspore/vcruntime140_1.dll +0 -0
- mindspore/version.py +1 -1
- {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/METADATA +5 -4
- {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/RECORD +400 -439
- mindspore/_deprecated/jit.py +0 -198
- mindspore/_extends/remote/kernel_build_server_ascend.py +0 -75
- mindspore/communication/_hccl_management.py +0 -297
- mindspore/experimental/es/embedding_service.py +0 -891
- mindspore/experimental/es/embedding_service_layer.py +0 -581
- mindspore/profiler/common/validator/__init__.py +0 -14
- mindspore/profiler/common/validator/validate_path.py +0 -84
- mindspore/profiler/parser/__init__.py +0 -14
- mindspore/profiler/parser/aicpu_data_parser.py +0 -272
- mindspore/profiler/parser/ascend_analysis/__init__.py +0 -14
- mindspore/profiler/parser/ascend_analysis/constant.py +0 -71
- mindspore/profiler/parser/ascend_analysis/file_manager.py +0 -180
- mindspore/profiler/parser/ascend_analysis/function_event.py +0 -185
- mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +0 -136
- mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +0 -131
- mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +0 -104
- mindspore/profiler/parser/ascend_analysis/path_manager.py +0 -313
- mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +0 -123
- mindspore/profiler/parser/ascend_analysis/tlv_decoder.py +0 -86
- mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +0 -75
- mindspore/profiler/parser/ascend_cluster_generator.py +0 -116
- mindspore/profiler/parser/ascend_communicate_generator.py +0 -314
- mindspore/profiler/parser/ascend_flops_generator.py +0 -116
- mindspore/profiler/parser/ascend_fpbp_generator.py +0 -82
- mindspore/profiler/parser/ascend_hccl_generator.py +0 -271
- mindspore/profiler/parser/ascend_integrate_generator.py +0 -42
- mindspore/profiler/parser/ascend_memory_generator.py +0 -185
- mindspore/profiler/parser/ascend_msprof_exporter.py +0 -282
- mindspore/profiler/parser/ascend_msprof_generator.py +0 -187
- mindspore/profiler/parser/ascend_op_generator.py +0 -334
- mindspore/profiler/parser/ascend_steptrace_generator.py +0 -94
- mindspore/profiler/parser/ascend_timeline_generator.py +0 -545
- mindspore/profiler/parser/base_timeline_generator.py +0 -483
- mindspore/profiler/parser/container.py +0 -229
- mindspore/profiler/parser/cpu_gpu_timeline_generator.py +0 -697
- mindspore/profiler/parser/flops_parser.py +0 -531
- mindspore/profiler/parser/framework_enum.py +0 -111
- mindspore/profiler/parser/framework_parser.py +0 -464
- mindspore/profiler/parser/framework_struct.py +0 -61
- mindspore/profiler/parser/gpu_analysis/__init__.py +0 -14
- mindspore/profiler/parser/gpu_analysis/function_event.py +0 -44
- mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +0 -89
- mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +0 -72
- mindspore/profiler/parser/hccl_parser.py +0 -573
- mindspore/profiler/parser/hwts_log_parser.py +0 -122
- mindspore/profiler/parser/integrator.py +0 -526
- mindspore/profiler/parser/memory_usage_parser.py +0 -277
- mindspore/profiler/parser/minddata_analyzer.py +0 -800
- mindspore/profiler/parser/minddata_parser.py +0 -186
- mindspore/profiler/parser/minddata_pipeline_parser.py +0 -299
- mindspore/profiler/parser/op_intermediate_parser.py +0 -149
- mindspore/profiler/parser/optime_parser.py +0 -250
- mindspore/profiler/parser/profiler_info.py +0 -213
- mindspore/profiler/parser/step_trace_parser.py +0 -666
- mindspore/utils/hooks.py +0 -81
- /mindspore/common/{_auto_dynamic.py → dynamic_shape/_auto_dynamic.py} +0 -0
- {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/WHEEL +0 -0
- {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/entry_points.txt +0 -0
- {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/top_level.txt +0 -0
|
@@ -1,531 +0,0 @@
|
|
|
1
|
-
# Copyright 2021 Huawei Technologies Co., Ltd
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
# ============================================================================
|
|
15
|
-
"""Flops parser which parsing flops from aicore file."""
|
|
16
|
-
import os
|
|
17
|
-
import struct
|
|
18
|
-
import json
|
|
19
|
-
import stat
|
|
20
|
-
|
|
21
|
-
from mindspore import log as logger
|
|
22
|
-
from mindspore.profiler.common.exceptions.exceptions import ProfilerIOException, \
|
|
23
|
-
ProfilerFileNotFoundException, ProfilerRawFileException, ProfilerPathErrorException
|
|
24
|
-
from mindspore.profiler.common.validator.validate_path import \
|
|
25
|
-
validate_and_normalize_path
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
class FlopsParser:
|
|
29
|
-
"""
|
|
30
|
-
The parser for parsing flops from aicore file.
|
|
31
|
-
|
|
32
|
-
Args:
|
|
33
|
-
input_dir (str): Directory(JOBXXX) where the original profiling data are located.
|
|
34
|
-
output_dir (str): Directory(profiler-{timestamp}) where the parsed profiling files are located.
|
|
35
|
-
op_task_dict (dict): The mapping relation of task_id and op_full_name.
|
|
36
|
-
device_id (str): The device ID.
|
|
37
|
-
"""
|
|
38
|
-
HEX = 16
|
|
39
|
-
PMU_COUNT = 8
|
|
40
|
-
AICORE_LOG_SIZE = 128 # the size of each struct is 128 Byte.
|
|
41
|
-
RUNTIME_COMMON = "BBHHHII10Q8I"
|
|
42
|
-
|
|
43
|
-
# If the task id is less than the task id threshold,
|
|
44
|
-
# the combination of task id and Stream id represents one operator,
|
|
45
|
-
# else the task id represents one operator.
|
|
46
|
-
_task_id_threshold = 65536
|
|
47
|
-
|
|
48
|
-
def __init__(self, input_dir, output_dir, op_task_dict, device_id, rank_id, is_training_mode_flag=True):
|
|
49
|
-
self._input_dir = input_dir
|
|
50
|
-
self._output_dir = output_dir
|
|
51
|
-
self._op_task_dict = op_task_dict
|
|
52
|
-
self._device_id = device_id
|
|
53
|
-
self._rank_id = rank_id
|
|
54
|
-
self.is_training_mode_flag = is_training_mode_flag
|
|
55
|
-
# output files.
|
|
56
|
-
self._flops_filename = f'flops_{self._rank_id}.txt'
|
|
57
|
-
self._flops_summary_filename = f'flops_summary_{self._rank_id}.json'
|
|
58
|
-
self._flops_scope_filename = f'flops_scope_{self._rank_id}.json'
|
|
59
|
-
self._flops_utilization_step_filename = f'flops_utilization_step_{self._rank_id}.json'
|
|
60
|
-
# input files.
|
|
61
|
-
self._aicore_filename_pref = f'aicore.data.{self._device_id}.slice'
|
|
62
|
-
self._optime_filename = f'output_op_compute_time_{self._rank_id}.txt'
|
|
63
|
-
self._info_json = f'info.json.{self._device_id}'
|
|
64
|
-
self._step_trace_filename = f'step_trace_raw_{self._rank_id}_detail_time.csv'
|
|
65
|
-
self._timeline_data_filename = f'output_timeline_data_{self._rank_id}.txt'
|
|
66
|
-
self._flops_summary = {
|
|
67
|
-
'FLOPs': 0,
|
|
68
|
-
'FLOPS': 0,
|
|
69
|
-
'FLOPS_Utilization': 0
|
|
70
|
-
}
|
|
71
|
-
self._flops_each_scope = {}
|
|
72
|
-
self._flops_sankey_diagram = {}
|
|
73
|
-
self._max_scope_num = 0
|
|
74
|
-
|
|
75
|
-
@staticmethod
|
|
76
|
-
def _read_line(start_dot, end_dot, op_avg_time_lines, op_all_step_time, op_all_step_comp):
|
|
77
|
-
"""Read the bp and fp time from line."""
|
|
78
|
-
for op_avg_idx in op_avg_time_lines:
|
|
79
|
-
line = op_avg_idx.split(',')
|
|
80
|
-
fp = float(line[start_dot]) / 100000.0
|
|
81
|
-
bp = float(line[end_dot]) / 100000.0
|
|
82
|
-
op_all_step_time.append([fp, bp])
|
|
83
|
-
op_all_step_comp.append([0.0, bp - fp])
|
|
84
|
-
return op_all_step_time, op_all_step_comp
|
|
85
|
-
|
|
86
|
-
@staticmethod
|
|
87
|
-
def _add_step_flops_time(op_name, task_fops, op_idx, step_idx, op_start_time,
|
|
88
|
-
op_all_step_time, op_all_step_comp):
|
|
89
|
-
"""Get the start time from the current task."""
|
|
90
|
-
while((op_idx < len(op_start_time)) and (op_name != op_start_time[op_idx][0])):
|
|
91
|
-
op_idx += 1
|
|
92
|
-
if op_idx >= len(op_start_time):
|
|
93
|
-
logger.debug(f"Op name {op_name} does not exist in timeline dict.")
|
|
94
|
-
return op_idx, step_idx, op_all_step_comp
|
|
95
|
-
|
|
96
|
-
# do not add the op FLOPS that not in fp_and_bp time.
|
|
97
|
-
while((step_idx < len(op_all_step_time)) and
|
|
98
|
-
(op_start_time[op_idx][1] >= op_all_step_time[step_idx][1])):
|
|
99
|
-
step_idx += 1
|
|
100
|
-
if step_idx >= len(op_all_step_time):
|
|
101
|
-
logger.info(f"Op name {op_name} does not exist in timeline dict.")
|
|
102
|
-
|
|
103
|
-
# add the op FLOPS that in fp_and_bp time.
|
|
104
|
-
if ((step_idx < len(op_all_step_time)) and
|
|
105
|
-
(op_start_time[op_idx][1] >= op_all_step_time[step_idx][0]) and
|
|
106
|
-
(op_start_time[op_idx][1] <= op_all_step_time[step_idx][1])):
|
|
107
|
-
op_all_step_comp[step_idx][0] += task_fops
|
|
108
|
-
# next op.
|
|
109
|
-
op_idx += 1
|
|
110
|
-
return op_idx, step_idx, op_all_step_comp
|
|
111
|
-
|
|
112
|
-
def execute(self):
|
|
113
|
-
"""Get the flops of aicore operators and write to file."""
|
|
114
|
-
peak_flops = self._get_peak_flops()
|
|
115
|
-
|
|
116
|
-
op_avg_time_dict = self._get_op_avg_time_dict()
|
|
117
|
-
op_flops_list = []
|
|
118
|
-
op_name_set = set()
|
|
119
|
-
op_compute_dict = dict()
|
|
120
|
-
# get all step time.
|
|
121
|
-
op_all_step_time, op_all_step_comp = self._get_all_step_time()
|
|
122
|
-
op_start_time = self._get_op_start_time()
|
|
123
|
-
op_idx = 0
|
|
124
|
-
step_idx = 0
|
|
125
|
-
aicore_file_doc = os.path.join(self._input_dir, "data")
|
|
126
|
-
source_files = self._get_aicore_files(aicore_file_doc)
|
|
127
|
-
if not source_files:
|
|
128
|
-
return
|
|
129
|
-
# parse all sliced aicore files.
|
|
130
|
-
for source_file in source_files:
|
|
131
|
-
source_file = validate_and_normalize_path(source_file)
|
|
132
|
-
read_count, all_log_struct = self._load_aicore_data(source_file)
|
|
133
|
-
|
|
134
|
-
for idx in range(read_count):
|
|
135
|
-
log_struct = all_log_struct[idx * self.AICORE_LOG_SIZE:
|
|
136
|
-
(idx + 1) * self.AICORE_LOG_SIZE]
|
|
137
|
-
result = [hex(i) for i in struct.unpack(self.RUNTIME_COMMON, log_struct)]
|
|
138
|
-
op_name = self._get_op_name(result)
|
|
139
|
-
|
|
140
|
-
if op_name == "":
|
|
141
|
-
# filter out the blank line in the file.
|
|
142
|
-
continue
|
|
143
|
-
if op_name not in op_avg_time_dict:
|
|
144
|
-
logger.info(f"Op name {op_name} does not exist in op average time dict.")
|
|
145
|
-
continue
|
|
146
|
-
# Convert the unit of task_fops to MFLOPs(1e6).
|
|
147
|
-
if op_name in op_compute_dict:
|
|
148
|
-
task_fops = op_compute_dict.get(op_name)
|
|
149
|
-
else:
|
|
150
|
-
task_fops = self._compute_task_flops(result) * 1e-6
|
|
151
|
-
op_compute_dict[op_name] = task_fops
|
|
152
|
-
|
|
153
|
-
# add the op FLOPS in current step.
|
|
154
|
-
if len(op_start_time) >= 1 and len(op_all_step_time) >= 1:
|
|
155
|
-
op_idx, step_idx, op_all_step_comp = self._add_step_flops_time(
|
|
156
|
-
op_name, task_fops, op_idx, step_idx, op_start_time, op_all_step_time, op_all_step_comp)
|
|
157
|
-
|
|
158
|
-
# calculate averge op FLOPS.
|
|
159
|
-
if op_name in op_name_set:
|
|
160
|
-
continue
|
|
161
|
-
op_avg_time = op_avg_time_dict.get(op_name)
|
|
162
|
-
# Time unit of op_avg_time is ms.
|
|
163
|
-
# The unit of gflop_per_second is GFLOPS(1e9).
|
|
164
|
-
if float(op_avg_time) == 0.0:
|
|
165
|
-
raise ValueError("All operators take 0 ms.")
|
|
166
|
-
if peak_flops == 0:
|
|
167
|
-
raise ValueError("The frequency of an operator is 0.")
|
|
168
|
-
gflop_per_second = task_fops / float(op_avg_time)
|
|
169
|
-
flops_utilization = (gflop_per_second * 1e9 / peak_flops) * 100
|
|
170
|
-
self._flops_summary['FLOPs'] += task_fops
|
|
171
|
-
self._flops_summary['FLOPS'] += gflop_per_second
|
|
172
|
-
op_flops = [op_name, str(task_fops), str(gflop_per_second), str(flops_utilization)]
|
|
173
|
-
op_flops_list.append(op_flops)
|
|
174
|
-
op_name_set.add(op_name)
|
|
175
|
-
self._add_flops_to_each_scope(op_name, task_fops)
|
|
176
|
-
|
|
177
|
-
if not op_name_set:
|
|
178
|
-
raise ProfilerRawFileException("No aicore operator found.")
|
|
179
|
-
self._flops_summary['FLOPS'] /= len(op_name_set)
|
|
180
|
-
|
|
181
|
-
sum_flops_utilization = 0.0
|
|
182
|
-
# calculate the every step FLOPS utilization and the average values.
|
|
183
|
-
utilization_save_filename = os.path.join(self._output_dir, self._flops_utilization_step_filename)
|
|
184
|
-
with os.fdopen(os.open(utilization_save_filename, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600), 'w') as f:
|
|
185
|
-
f.write("steps, FLOPS_Utilization %\n")
|
|
186
|
-
for i, x in enumerate(op_all_step_comp):
|
|
187
|
-
current_utilization = x[0] / x[1] * 1e9 / peak_flops * 100
|
|
188
|
-
sum_flops_utilization += current_utilization
|
|
189
|
-
f.write(str(i + 1))
|
|
190
|
-
f.write(",")
|
|
191
|
-
f.write(str(current_utilization))
|
|
192
|
-
f.write("\n")
|
|
193
|
-
os.chmod(utilization_save_filename, stat.S_IREAD | stat.S_IWRITE)
|
|
194
|
-
|
|
195
|
-
if len(op_all_step_comp) >= 1:
|
|
196
|
-
self._flops_summary['FLOPS_Utilization'] = sum_flops_utilization / len(op_all_step_comp)
|
|
197
|
-
else:
|
|
198
|
-
logger.warning("The number of data calculation steps is 0, please check whether the "
|
|
199
|
-
"output timeline data is none.")
|
|
200
|
-
self._flops_summary['FLOPS_Utilization'] = 0.0
|
|
201
|
-
self._format_scope_flops()
|
|
202
|
-
self._write_file(op_flops_list)
|
|
203
|
-
|
|
204
|
-
def _load_aicore_data(self, aicore_file_path):
|
|
205
|
-
"""Load the original binary aicore data."""
|
|
206
|
-
logger.info("the aicore file path is %s", aicore_file_path)
|
|
207
|
-
|
|
208
|
-
if not os.path.exists(aicore_file_path):
|
|
209
|
-
logger.critical(f'The file {aicore_file_path} does not exist.')
|
|
210
|
-
raise ProfilerFileNotFoundException('aicore.data')
|
|
211
|
-
|
|
212
|
-
file_size = os.path.getsize(aicore_file_path)
|
|
213
|
-
read_count = file_size // self.AICORE_LOG_SIZE
|
|
214
|
-
|
|
215
|
-
if not read_count:
|
|
216
|
-
logger.critical(f'the file {aicore_file_path} '
|
|
217
|
-
f'does not have enough content to be parsed.')
|
|
218
|
-
raise ProfilerRawFileException(
|
|
219
|
-
'aicore.data file does not have enough content to be parsed'
|
|
220
|
-
)
|
|
221
|
-
aicore_file_path = os.path.realpath(aicore_file_path)
|
|
222
|
-
try:
|
|
223
|
-
with open(aicore_file_path, "rb") as aicore_file:
|
|
224
|
-
all_log_struct = aicore_file.read(self.AICORE_LOG_SIZE * read_count)
|
|
225
|
-
except (IOError, OSError) as err:
|
|
226
|
-
logger.critical(f'Error occurred when read {aicore_file_path} file: {err}')
|
|
227
|
-
raise ProfilerIOException() from err
|
|
228
|
-
|
|
229
|
-
return read_count, all_log_struct
|
|
230
|
-
|
|
231
|
-
def _get_peak_flops(self):
|
|
232
|
-
"""Get the peak FLOPS of current ascend device."""
|
|
233
|
-
info_json_file_path = os.path.join(
|
|
234
|
-
self._input_dir,
|
|
235
|
-
self._info_json
|
|
236
|
-
)
|
|
237
|
-
|
|
238
|
-
if not os.path.exists(info_json_file_path):
|
|
239
|
-
logger.critical(f'The file {info_json_file_path} does not exist.')
|
|
240
|
-
raise ProfilerFileNotFoundException(info_json_file_path)
|
|
241
|
-
|
|
242
|
-
try:
|
|
243
|
-
with open(info_json_file_path, 'r', encoding='utf-8') as info_file:
|
|
244
|
-
device_info = json.load(info_file)['DeviceInfo'][0]
|
|
245
|
-
device_frequency = float(device_info["aic_frequency"])
|
|
246
|
-
ai_core_num = float(device_info["ai_core_num"])
|
|
247
|
-
# peak_flops formula (provided by Hisi): device_frequency * num_of_aicore * 4096 * 2.
|
|
248
|
-
peak_flops = device_frequency * 1e6 * ai_core_num * 4096 * 2
|
|
249
|
-
except (IOError, OSError, json.JSONDecodeError) as err:
|
|
250
|
-
logger.critical(f'Error occurred when read {info_json_file_path} file: {err}')
|
|
251
|
-
raise ProfilerIOException() from err
|
|
252
|
-
|
|
253
|
-
return peak_flops
|
|
254
|
-
|
|
255
|
-
def _compute_task_flops(self, log_result):
|
|
256
|
-
"""Compute the FLOPs of each task."""
|
|
257
|
-
pmu_cnt = list(
|
|
258
|
-
int(i.replace('0x', ''), self.HEX)
|
|
259
|
-
for i in log_result[9:17]
|
|
260
|
-
)
|
|
261
|
-
cube_fp16_exec = pmu_cnt[0]
|
|
262
|
-
cube_int8_exec = pmu_cnt[1]
|
|
263
|
-
vec_fp32 = pmu_cnt[2]
|
|
264
|
-
vec_fp16_128lane_exec = pmu_cnt[3]
|
|
265
|
-
vec_fp16_64lane_exec = pmu_cnt[4]
|
|
266
|
-
vec_int32_exec = pmu_cnt[5]
|
|
267
|
-
vec_misc_exec = pmu_cnt[6]
|
|
268
|
-
|
|
269
|
-
# These formula is provided by HISI profiling.
|
|
270
|
-
# a cube_fp16 instruction has (16**3)*2 float point operation.
|
|
271
|
-
# a cube_fp16 instruction has 16*16*32*2 float point operation.
|
|
272
|
-
cube_fops = cube_fp16_exec * (16 ** 3) * 2 + cube_int8_exec * 16 * 16 * 32 * 2
|
|
273
|
-
vec_fops = vec_fp32 * 32 + vec_fp16_128lane_exec * 128 + \
|
|
274
|
-
vec_fp16_64lane_exec * 64 + vec_int32_exec * 64 + vec_misc_exec * 32
|
|
275
|
-
task_fops = cube_fops + vec_fops
|
|
276
|
-
|
|
277
|
-
return task_fops
|
|
278
|
-
|
|
279
|
-
def _get_op_name(self, log_result):
|
|
280
|
-
"""Get the operator name for current task_id."""
|
|
281
|
-
task_id = int(log_result[4].replace('0x', ''), self.HEX)
|
|
282
|
-
stream_id = int(log_result[17].replace('0x', ''), self.HEX)
|
|
283
|
-
if task_id < self._task_id_threshold:
|
|
284
|
-
task_id = '_'.join([str(stream_id), str(task_id)])
|
|
285
|
-
if str(task_id) not in self._op_task_dict:
|
|
286
|
-
return ""
|
|
287
|
-
op_name = self._op_task_dict[str(task_id)]
|
|
288
|
-
|
|
289
|
-
return op_name
|
|
290
|
-
|
|
291
|
-
def _get_op_avg_time_dict(self):
|
|
292
|
-
"""Get the op average execution time."""
|
|
293
|
-
op_avg_time_dict = {}
|
|
294
|
-
optime_file_path = os.path.join(self._output_dir, self._optime_filename)
|
|
295
|
-
|
|
296
|
-
if not os.path.exists(optime_file_path):
|
|
297
|
-
logger.critical(f'The {optime_file_path} file does not exist.')
|
|
298
|
-
raise ProfilerFileNotFoundException(optime_file_path)
|
|
299
|
-
optime_file_path = os.path.realpath(optime_file_path)
|
|
300
|
-
try:
|
|
301
|
-
with open(optime_file_path, 'r') as f:
|
|
302
|
-
lines = f.readlines()
|
|
303
|
-
op_avg_time_lines = lines[3:] # the first three lines are table header.
|
|
304
|
-
for line in op_avg_time_lines:
|
|
305
|
-
op_name, avg_time = line.split()[:2]
|
|
306
|
-
op_avg_time_dict[op_name] = avg_time
|
|
307
|
-
except (IOError, OSError) as err:
|
|
308
|
-
logger.critical(f'Error occurred when read {optime_file_path} file: {err}')
|
|
309
|
-
raise ProfilerIOException() from err
|
|
310
|
-
|
|
311
|
-
return op_avg_time_dict
|
|
312
|
-
|
|
313
|
-
def _add_flops_to_each_scope(self, op_name, task_fops):
|
|
314
|
-
"""
|
|
315
|
-
Add task_fops to each scope of the op_name.
|
|
316
|
-
|
|
317
|
-
The top-level scope name is "Default" or "recompute_Default" or "Gradients".
|
|
318
|
-
To classify the same scope name under different top-level scope, a suffix name is added.
|
|
319
|
-
For op_name like "Default/network", the "network" will be renamed as "network(Default)".
|
|
320
|
-
For op_name like "recompute_Default/network", "network" --> "network(recompute_Default)".
|
|
321
|
-
For op_name like "Gradients/network", "network" --> "network(Gradients)".
|
|
322
|
-
For op_name like "Gradients/recompute_Default/network", "network" --> "network(recompute_Gradients)".
|
|
323
|
-
"""
|
|
324
|
-
# Only extracts the scope name, remove the operator name.
|
|
325
|
-
scope_list = op_name.split('/')[:-1]
|
|
326
|
-
self._max_scope_num = max(self._max_scope_num, len(scope_list))
|
|
327
|
-
top_level_scope = scope_list[0]
|
|
328
|
-
suffix_name = ""
|
|
329
|
-
if op_name.startswith("Gradients/recompute_Default"):
|
|
330
|
-
suffix_name = "recompute_Gradients"
|
|
331
|
-
else:
|
|
332
|
-
suffix_name = top_level_scope
|
|
333
|
-
# To distinguish the same scope name at different scope level and different top level scope,
|
|
334
|
-
# the scope level and top level scope is added.
|
|
335
|
-
for level, scope_name in enumerate(scope_list):
|
|
336
|
-
scope_list[level] = scope_name + f"({level}_{suffix_name})"
|
|
337
|
-
scope_list[0] = top_level_scope
|
|
338
|
-
|
|
339
|
-
# Add root node (refers to total flops).
|
|
340
|
-
scope_list.insert(0, "Total")
|
|
341
|
-
scope_depth = len(scope_list)
|
|
342
|
-
for idx in range(scope_depth - 1):
|
|
343
|
-
key_name = '{} {}'.format(scope_list[idx], scope_list[idx + 1])
|
|
344
|
-
self._flops_each_scope.setdefault(key_name, 0)
|
|
345
|
-
self._flops_each_scope[key_name] += task_fops
|
|
346
|
-
|
|
347
|
-
def _format_scope_flops(self):
|
|
348
|
-
"""
|
|
349
|
-
Format the flops of each scope to a Sankey Diagram.
|
|
350
|
-
|
|
351
|
-
The format of Sankey Diagram is:
|
|
352
|
-
{"nodes": [
|
|
353
|
-
{"name": "Default"},
|
|
354
|
-
{"name": "network"}
|
|
355
|
-
],
|
|
356
|
-
"links": [
|
|
357
|
-
{"source": "Total", "target": "Default", "value": 555},
|
|
358
|
-
{"source": "Default", "target": "network", "value": 555}
|
|
359
|
-
]
|
|
360
|
-
}
|
|
361
|
-
"""
|
|
362
|
-
nodes, links = [], []
|
|
363
|
-
scope_name_set = set()
|
|
364
|
-
for scope_link, task_fops in self._flops_each_scope.items():
|
|
365
|
-
source, target = scope_link.split()
|
|
366
|
-
scope_name_set.update({source, target})
|
|
367
|
-
link = {
|
|
368
|
-
"source": source,
|
|
369
|
-
"target": target,
|
|
370
|
-
"value": round(task_fops, 3)
|
|
371
|
-
}
|
|
372
|
-
links.append(link)
|
|
373
|
-
|
|
374
|
-
for scope_name in scope_name_set:
|
|
375
|
-
node = {"name": scope_name}
|
|
376
|
-
nodes.append(node)
|
|
377
|
-
|
|
378
|
-
sankey_diagram = {"nodes": nodes, "links": links}
|
|
379
|
-
self._flops_sankey_diagram = {
|
|
380
|
-
"data": sankey_diagram,
|
|
381
|
-
"max_scope_num": self._max_scope_num
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
def _write_file(self, op_flops_list):
|
|
385
|
-
"""Write the operator's flops related information into file."""
|
|
386
|
-
join_file_path = lambda x: os.path.join(self._output_dir, x)
|
|
387
|
-
output_file_path = join_file_path(self._flops_filename)
|
|
388
|
-
output_summary_file_path = join_file_path(self._flops_summary_filename)
|
|
389
|
-
output_flops_scope_file_path = join_file_path(self._flops_scope_filename)
|
|
390
|
-
|
|
391
|
-
try:
|
|
392
|
-
with os.fdopen(os.open(output_file_path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600), 'w') as f:
|
|
393
|
-
header = "op_full_name, MFLOPs(10^6), GFLOPS(10^9), FLOPS utilization(%) \n"
|
|
394
|
-
f.writelines(header)
|
|
395
|
-
for op_flops in op_flops_list:
|
|
396
|
-
line = ", ".join(op_flops)
|
|
397
|
-
f.writelines(line + '\n')
|
|
398
|
-
os.chmod(output_file_path, stat.S_IREAD | stat.S_IWRITE)
|
|
399
|
-
except (IOError, OSError) as err:
|
|
400
|
-
logger.critical(f'Error occurred when writing {output_file_path} file: {err}')
|
|
401
|
-
raise ProfilerIOException() from err
|
|
402
|
-
|
|
403
|
-
for key in self._flops_summary:
|
|
404
|
-
self._flops_summary[key] = round(self._flops_summary[key], 3)
|
|
405
|
-
try:
|
|
406
|
-
with os.fdopen(os.open(output_summary_file_path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600),
|
|
407
|
-
'w') as json_file:
|
|
408
|
-
json.dump(self._flops_summary, json_file)
|
|
409
|
-
os.chmod(output_summary_file_path, stat.S_IREAD | stat.S_IWRITE)
|
|
410
|
-
except (IOError, OSError) as err:
|
|
411
|
-
logger.critical(f'Error occurred when write {output_summary_file_path} file: {err}')
|
|
412
|
-
raise ProfilerIOException() from err
|
|
413
|
-
|
|
414
|
-
try:
|
|
415
|
-
with os.fdopen(os.open(output_flops_scope_file_path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600),
|
|
416
|
-
'w') as json_file:
|
|
417
|
-
json.dump(self._flops_sankey_diagram, json_file)
|
|
418
|
-
os.chmod(output_flops_scope_file_path, stat.S_IREAD | stat.S_IWRITE)
|
|
419
|
-
except (IOError, OSError) as err:
|
|
420
|
-
logger.critical(f'Error occurred when write {output_flops_scope_file_path} file: {err}')
|
|
421
|
-
raise ProfilerIOException() from err
|
|
422
|
-
|
|
423
|
-
def _get_aicore_files(self, profiler_dir):
|
|
424
|
-
"""Get aicore files."""
|
|
425
|
-
aicore_files = self._search_file(profiler_dir)
|
|
426
|
-
if not aicore_files:
|
|
427
|
-
logger.warning("Aicore file does not exist.")
|
|
428
|
-
return[]
|
|
429
|
-
|
|
430
|
-
return aicore_files
|
|
431
|
-
|
|
432
|
-
def _search_file(self, input_dir):
|
|
433
|
-
"""Search aicore file under specific input directory."""
|
|
434
|
-
# validate input_dir
|
|
435
|
-
if not os.path.isdir(input_dir):
|
|
436
|
-
raise ProfilerPathErrorException(
|
|
437
|
-
'{} does not exist or is not a dir'.format(input_dir)
|
|
438
|
-
)
|
|
439
|
-
# get aicore files
|
|
440
|
-
files = os.listdir(input_dir)
|
|
441
|
-
aicore_files = list(
|
|
442
|
-
filter(
|
|
443
|
-
lambda file: file.startswith(self._aicore_filename_pref) and not file.endswith('.done'),
|
|
444
|
-
files
|
|
445
|
-
)
|
|
446
|
-
)
|
|
447
|
-
# validate result
|
|
448
|
-
if len(aicore_files) > 1:
|
|
449
|
-
# the format of file name is like `aicore.data.$id.slice_$number`.
|
|
450
|
-
# use the $number as the sorted key
|
|
451
|
-
try:
|
|
452
|
-
aicore_files.sort(key=lambda path: int(path.rsplit('_', 1)[-1]))
|
|
453
|
-
except ValueError as err:
|
|
454
|
-
logger.warning("Unable to parse file names: %s. %s", aicore_files, err)
|
|
455
|
-
aicore_files = []
|
|
456
|
-
else:
|
|
457
|
-
aicore_files = list(
|
|
458
|
-
filter(
|
|
459
|
-
lambda file: file.startswith(self._aicore_filename_pref) and not file.endswith('.done'),
|
|
460
|
-
files
|
|
461
|
-
)
|
|
462
|
-
)
|
|
463
|
-
if len(aicore_files) >= 1:
|
|
464
|
-
logger.warning("The aicore file structure is changed, please upgrade " \
|
|
465
|
-
"mindspore and regenerate profiling data")
|
|
466
|
-
|
|
467
|
-
file_paths = [os.path.join(input_dir, file) for file in aicore_files]
|
|
468
|
-
logger.info("Find %d aicore files.", len(file_paths))
|
|
469
|
-
return file_paths
|
|
470
|
-
|
|
471
|
-
def _get_all_step_time(self):
|
|
472
|
-
"""Get the op average execution time."""
|
|
473
|
-
op_all_step_time = []
|
|
474
|
-
op_all_step_comp = []
|
|
475
|
-
_step_trace_file_path = os.path.join(self._output_dir, self._step_trace_filename)
|
|
476
|
-
|
|
477
|
-
if not os.path.exists(_step_trace_file_path):
|
|
478
|
-
logger.warning(f'The {_step_trace_file_path} file does not exist.')
|
|
479
|
-
return op_all_step_time, op_all_step_comp
|
|
480
|
-
try:
|
|
481
|
-
with open(_step_trace_file_path, 'r') as f:
|
|
482
|
-
lines = f.readlines()
|
|
483
|
-
op_all_step_time, op_all_step_comp = \
|
|
484
|
-
self._get_bp_fp_time_by_line(lines, op_all_step_time, op_all_step_comp)
|
|
485
|
-
except (IOError, OSError) as err:
|
|
486
|
-
logger.critical(f'Error occurred when read {_step_trace_file_path} file: {err}')
|
|
487
|
-
raise ProfilerIOException() from err
|
|
488
|
-
logger.info("the train step is %d .", len(op_all_step_time))
|
|
489
|
-
if not op_all_step_time:
|
|
490
|
-
logger.warning(f'Empty when read {_step_trace_file_path} file, please check the valid'
|
|
491
|
-
'data of this file.')
|
|
492
|
-
return op_all_step_time, op_all_step_comp
|
|
493
|
-
|
|
494
|
-
def _get_bp_fp_time_by_line(self, lines, op_all_step_time, op_all_step_comp):
|
|
495
|
-
"""Get the bp and fp time with lines."""
|
|
496
|
-
# the last line is the average info.
|
|
497
|
-
op_avg_time_lines = lines[1:-1]
|
|
498
|
-
# train mode.
|
|
499
|
-
if self.is_training_mode_flag:
|
|
500
|
-
op_all_step_time, op_all_step_comp = \
|
|
501
|
-
self._read_line(4, 5, op_avg_time_lines, op_all_step_time, op_all_step_comp)
|
|
502
|
-
else:
|
|
503
|
-
# eval mode.
|
|
504
|
-
op_all_step_time, op_all_step_comp = \
|
|
505
|
-
self._read_line(4, 2, op_avg_time_lines, op_all_step_time, op_all_step_comp)
|
|
506
|
-
return op_all_step_time, op_all_step_comp
|
|
507
|
-
|
|
508
|
-
def _get_op_start_time(self):
|
|
509
|
-
"""Get the op average execution time."""
|
|
510
|
-
op_start_time = []
|
|
511
|
-
_timeline_file_path = os.path.join(self._output_dir, self._timeline_data_filename)
|
|
512
|
-
|
|
513
|
-
if not os.path.exists(_timeline_file_path):
|
|
514
|
-
logger.critical(f'The {_timeline_file_path} file does not exist.')
|
|
515
|
-
raise ProfilerFileNotFoundException(_timeline_file_path)
|
|
516
|
-
try:
|
|
517
|
-
with open(_timeline_file_path, 'r') as f:
|
|
518
|
-
lines = f.readlines()
|
|
519
|
-
op_avg_time_lines = lines[1:]
|
|
520
|
-
for op_avg_idx in op_avg_time_lines:
|
|
521
|
-
line = op_avg_idx.split(',')
|
|
522
|
-
op_name = line[0]
|
|
523
|
-
op_start = float(line[2])
|
|
524
|
-
op_start_time.append([op_name, op_start])
|
|
525
|
-
except (IOError, OSError) as err:
|
|
526
|
-
logger.critical(f'Error occurred when read {_timeline_file_path} file: {err}')
|
|
527
|
-
raise ProfilerIOException() from err
|
|
528
|
-
if not op_start_time:
|
|
529
|
-
logger.warning(f'Empty when read {_timeline_file_path} file, please check the valid'
|
|
530
|
-
'data of this file.')
|
|
531
|
-
return op_start_time
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
# Copyright 2021-2022 Huawei Technologies Co., Ltd
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
# ============================================================================
|
|
15
|
-
"""Define framework enum data."""
|
|
16
|
-
|
|
17
|
-
from enum import Enum, IntEnum
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class FileDataType(Enum):
|
|
21
|
-
"""Define framework file data type."""
|
|
22
|
-
STEP_INFO = 'step_info'
|
|
23
|
-
HASH_DIC = 'hash_dic'
|
|
24
|
-
TENSOR_DATA_INFO = 'tensor_data_info'
|
|
25
|
-
TASK_DESC_INFO = 'task_desc_info'
|
|
26
|
-
|
|
27
|
-
@classmethod
|
|
28
|
-
def members(cls):
|
|
29
|
-
"""Initializes a value of an object."""
|
|
30
|
-
return {member.value for member in cls}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class VmDataType(IntEnum):
|
|
34
|
-
"""Definition of vm data type."""
|
|
35
|
-
NUMBER_TYPE_BEGIN = 29
|
|
36
|
-
BOOL = 30
|
|
37
|
-
INT = 31
|
|
38
|
-
INT8 = 32
|
|
39
|
-
INT16 = 33
|
|
40
|
-
INT32 = 34
|
|
41
|
-
INT64 = 35
|
|
42
|
-
UINT = 36
|
|
43
|
-
UINT8 = 37
|
|
44
|
-
UINT16 = 38
|
|
45
|
-
UINT32 = 39
|
|
46
|
-
UINT64 = 40
|
|
47
|
-
FLOAT = 41
|
|
48
|
-
FLOAT16 = 42
|
|
49
|
-
FLOAT32 = 43
|
|
50
|
-
FLOAT64 = 44
|
|
51
|
-
COMPLEX = 45
|
|
52
|
-
NUMBER_TYPE_END = 46
|
|
53
|
-
|
|
54
|
-
@classmethod
|
|
55
|
-
def get_data_type_name(cls, num):
|
|
56
|
-
"""
|
|
57
|
-
Get the name of data type by enum number.
|
|
58
|
-
|
|
59
|
-
Args:
|
|
60
|
-
num (int): Enum number.
|
|
61
|
-
|
|
62
|
-
Returns:
|
|
63
|
-
str, the name of data type.
|
|
64
|
-
"""
|
|
65
|
-
data_type = cls._value2member_map_.get(num)
|
|
66
|
-
return 'UNKNOWN' if data_type is None else data_type.name
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
class VmFormat(IntEnum):
|
|
70
|
-
"""Define mindspore data type."""
|
|
71
|
-
UNKNOWN = 0
|
|
72
|
-
DEFAULT = 1
|
|
73
|
-
NC1KHKWHWC0 = 2
|
|
74
|
-
ND = 3
|
|
75
|
-
NCHW = 4
|
|
76
|
-
NHWC = 5
|
|
77
|
-
HWCN = 6
|
|
78
|
-
NC1HWC0 = 7
|
|
79
|
-
FRAC_Z = 8
|
|
80
|
-
C1HWNCOC0 = 9
|
|
81
|
-
FRAC_NZ = 10
|
|
82
|
-
NC1HWC0_C04 = 11
|
|
83
|
-
FRACTAL_Z_C04 = 12
|
|
84
|
-
NDHWC = 13
|
|
85
|
-
FRACTAL_ZN_LSTM = 14
|
|
86
|
-
FRACTAL_ZN_RNN = 15
|
|
87
|
-
ND_RNN_BIAS = 16
|
|
88
|
-
NDC1HWC0 = 17
|
|
89
|
-
NCDHW = 18
|
|
90
|
-
FRACTAL_Z_3D = 19
|
|
91
|
-
DHWNC = 20
|
|
92
|
-
DHWCN = 21
|
|
93
|
-
|
|
94
|
-
@classmethod
|
|
95
|
-
def get_format_name(cls, num):
|
|
96
|
-
"""
|
|
97
|
-
Get the name of format by enum number.
|
|
98
|
-
|
|
99
|
-
Args:
|
|
100
|
-
num (int): Enum number.
|
|
101
|
-
|
|
102
|
-
Returns:
|
|
103
|
-
str, the name of data type.
|
|
104
|
-
"""
|
|
105
|
-
format_name = cls._value2member_map_.get(num)
|
|
106
|
-
return 'UNKNOWN' if format_name is None else format_name.name
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
MSPROF_DIFFERENCE = 200
|
|
110
|
-
MSPROF_MIX_DATA_HASH_ID = 0
|
|
111
|
-
MSPROF_MIX_DATA_STRING = 1
|