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
mindspore/profiler/profiler.py
CHANGED
|
@@ -15,18 +15,19 @@
|
|
|
15
15
|
"""Profiling api file."""
|
|
16
16
|
import os
|
|
17
17
|
import json
|
|
18
|
-
|
|
18
|
+
import warnings
|
|
19
|
+
from typing import Optional, Dict, Callable, Any, Iterable
|
|
19
20
|
from sys import getsizeof
|
|
20
21
|
from concurrent.futures import ProcessPoolExecutor, as_completed
|
|
21
22
|
|
|
22
23
|
from mindspore import log as logger
|
|
23
|
-
from mindspore.profiler.common.constant import ProfilerStepNameConstant, DeviceTarget
|
|
24
|
+
from mindspore.profiler.common.constant import ProfilerStepNameConstant, DeviceTarget, ProfilerActivity
|
|
24
25
|
from mindspore.profiler.common.profiler_context import ProfilerContext
|
|
25
26
|
from mindspore.profiler.platform.npu_profiler import NPUProfilerAnalysis
|
|
26
27
|
from mindspore.profiler.profiler_action_controller import ProfilerActionController
|
|
27
28
|
from mindspore.profiler.experimental_config import _ExperimentalConfig
|
|
28
29
|
from mindspore.profiler.profiler_interface import ProfilerInterface
|
|
29
|
-
from mindspore.profiler.schedule import _default_schedule_fn, ProfilerAction
|
|
30
|
+
from mindspore.profiler.schedule import _default_schedule_fn, ProfilerAction
|
|
30
31
|
from mindspore.profiler.common.record_function import RecordFunction
|
|
31
32
|
from mindspore.profiler.common.path_manager import PathManager
|
|
32
33
|
from mindspore.profiler.common.profiler_path_manager import ProfilerPathManager
|
|
@@ -91,8 +92,8 @@ def tensorboard_trace_handler(dir_name: str = None, worker_name: str = None,
|
|
|
91
92
|
... net = Net()
|
|
92
93
|
... # Note that the Profiler should be initialized before model.train
|
|
93
94
|
... with mindspore.profiler.profile(activities=[ProfilerActivity.CPU, ProfilerActivity.NPU],
|
|
94
|
-
... schedule=mindspore.profiler.schedule(wait=
|
|
95
|
-
... repeat=1, skip_first=
|
|
95
|
+
... schedule=mindspore.profiler.schedule(wait=0, warmup=0, active=1,
|
|
96
|
+
... repeat=1, skip_first=0),
|
|
96
97
|
... on_trace_ready=mindspore.profiler.tensorboard_trace_handler("./data"),
|
|
97
98
|
... profile_memory=False,
|
|
98
99
|
... experimental_config=experimental_config) as prof:
|
|
@@ -110,9 +111,9 @@ def tensorboard_trace_handler(dir_name: str = None, worker_name: str = None,
|
|
|
110
111
|
logger.warning("async_mode is not bool, set by default.")
|
|
111
112
|
async_mode = False
|
|
112
113
|
|
|
113
|
-
def handler_fn() -> None:
|
|
114
|
+
def handler_fn(prof_inst) -> None:
|
|
114
115
|
if analyse_flag:
|
|
115
|
-
|
|
116
|
+
prof_inst.analyse(async_mode=async_mode)
|
|
116
117
|
|
|
117
118
|
return handler_fn
|
|
118
119
|
|
|
@@ -156,8 +157,8 @@ class Profiler:
|
|
|
156
157
|
For details, see :func:`mindspore.profiler.tensorboard_trace_handler` .
|
|
157
158
|
profile_memory (bool, optional): (Ascend only) Whether to collect tensor memory data, collect when ``True`` .
|
|
158
159
|
When using this parameter, `activities` must set to ``[ProfilerActivity.CPU, ProfilerActivity.NPU]``.
|
|
159
|
-
Collecting operator memory data when
|
|
160
|
-
|
|
160
|
+
Collecting operator memory data when GE backend requires collecting from the first step.
|
|
161
|
+
Default: ``False`` . The operator name currently collected by this parameter is incomplete.
|
|
161
162
|
This issue will be resolved in later versions. It is recommended to use the environment variable
|
|
162
163
|
``MS_ALLOC_CONF`` instead.
|
|
163
164
|
aic_metrics (AicoreMetrics, optional): (Ascend only) Types of AICORE performance data collected,
|
|
@@ -192,7 +193,7 @@ class Profiler:
|
|
|
192
193
|
If set to True, only the profiler deliverables and raw performance data under the PROF_XXX directory are
|
|
193
194
|
kept to save space. Default value: ``True`` .
|
|
194
195
|
l2_cache (bool, optional): (Ascend only) Whether to collect l2 cache data, collect when True.
|
|
195
|
-
Default: ``False`` . The l2_cache.csv file is generated in the ASCEND_PROFILER_OUTPUT folder.In
|
|
196
|
+
Default: ``False`` . The l2_cache.csv file is generated in the ASCEND_PROFILER_OUTPUT folder.In GE backend,
|
|
196
197
|
only wait and skip_first parameters in schedule configuration can be set to 0.
|
|
197
198
|
hbm_ddr (bool, optional): (Ascend only) Whether to collect On-Chip Memory/DDR read and write rate data,
|
|
198
199
|
collect when True. Default: ``False`` .
|
|
@@ -260,9 +261,10 @@ class Profiler:
|
|
|
260
261
|
... # Profiler end
|
|
261
262
|
... profiler.analyse()
|
|
262
263
|
"""
|
|
263
|
-
MAX_META_SIZE = 100 * 1024 * 1024 # 100MB
|
|
264
264
|
|
|
265
265
|
def __init__(self, **kwargs) -> None:
|
|
266
|
+
logger.warning("'mindspore.Profiler' will be deprecated and removed in a future version. Please use the api "
|
|
267
|
+
"'mindspore.profiler.profile' instead.")
|
|
266
268
|
self._metadata: Dict[str, str] = {}
|
|
267
269
|
self._prof_context: ProfilerContext = ProfilerContext()
|
|
268
270
|
self._prof_context.set_params(**kwargs)
|
|
@@ -492,8 +494,7 @@ class Profiler:
|
|
|
492
494
|
>>> import mindspore as ms
|
|
493
495
|
>>> import mindspore.dataset as ds
|
|
494
496
|
>>> from mindspore import context, nn, Profiler
|
|
495
|
-
>>> from mindspore.profiler import schedule, tensorboard_trace_handler
|
|
496
|
-
>>> ExportType, ProfilerActivity
|
|
497
|
+
>>> from mindspore.profiler import schedule, tensorboard_trace_handler
|
|
497
498
|
>>>
|
|
498
499
|
>>> class Net(nn.Cell):
|
|
499
500
|
... def __init__(self):
|
|
@@ -564,7 +565,7 @@ class Profiler:
|
|
|
564
565
|
return
|
|
565
566
|
|
|
566
567
|
add_size = getsizeof(key) + getsizeof(value)
|
|
567
|
-
if getsizeof(self._metadata) + add_size <
|
|
568
|
+
if getsizeof(self._metadata) + add_size < ProfilerMetaData.MAX_META_SIZE:
|
|
568
569
|
if key in self._metadata:
|
|
569
570
|
logger.warning(f"{key} is already saved as metadata, override it.")
|
|
570
571
|
self._metadata[key] = value
|
|
@@ -595,7 +596,7 @@ class Profiler:
|
|
|
595
596
|
return
|
|
596
597
|
|
|
597
598
|
add_size = getsizeof(key) + getsizeof(value)
|
|
598
|
-
if getsizeof(self._metadata) + add_size <
|
|
599
|
+
if getsizeof(self._metadata) + add_size < ProfilerMetaData.MAX_META_SIZE:
|
|
599
600
|
try:
|
|
600
601
|
if key in self._metadata:
|
|
601
602
|
logger.warning(f"{key} is already saved as metadata, override it.")
|
|
@@ -646,6 +647,9 @@ class Profiler:
|
|
|
646
647
|
>>>
|
|
647
648
|
>>> profiler.op_analyse(op_name=["BiasAdd", "Conv2D"])
|
|
648
649
|
"""
|
|
650
|
+
warnings.warn(
|
|
651
|
+
"mindspore.Profiler.op_analyse is deprecated and will be removed in future versions. "
|
|
652
|
+
)
|
|
649
653
|
if self._prof_context.device_target == DeviceTarget.NPU.value:
|
|
650
654
|
raise RuntimeError("The Interface 'Profiler.op_analyse()' is not supported on Ascend currently.")
|
|
651
655
|
|
|
@@ -659,9 +663,9 @@ class Profiler:
|
|
|
659
663
|
if not op_name:
|
|
660
664
|
raise TypeError(f"For 'Profiler.op_analyse()', the parameter op_name cannot be "", '' or [].")
|
|
661
665
|
|
|
662
|
-
from mindspore.profiler.
|
|
666
|
+
from mindspore.profiler.common.profiler_op_analyse import OpAnalyser
|
|
663
667
|
dev_id = self._prof_context.device_id if device_id is None else device_id
|
|
664
|
-
parser =
|
|
668
|
+
parser = OpAnalyser(self._prof_context.framework_path, dev_id, op_name)
|
|
665
669
|
op_info = parser.parse()
|
|
666
670
|
return op_info
|
|
667
671
|
|
|
@@ -685,44 +689,40 @@ class Profile:
|
|
|
685
689
|
This class to enable the profiling of MindSpore neural networks.
|
|
686
690
|
MindSpore users can import the mindspore.profiler.profile, initialize the profile object to start profiling,
|
|
687
691
|
Use profile.start() to start the analysis, and use profile.stop() to stop collecting and analyzing the results.
|
|
692
|
+
For detailed usage, please refer to `Ascend Performance Tuning
|
|
693
|
+
<https://www.mindspore.cn/tutorials/en/master/debug/profiler.html>`_ .
|
|
688
694
|
Users can visualize the results using the `MindStudio Insight
|
|
689
695
|
<https://www.hiascend.com/developer/download/community/result?module=pt+sto+cann>`_ tool.
|
|
690
696
|
Now, profile supports AICORE operator, AICPU operator, HostCPU operator, memory,
|
|
691
697
|
correspondence, cluster, etc data analysis.
|
|
692
698
|
|
|
693
699
|
Args:
|
|
694
|
-
|
|
695
|
-
data collection based on conditions. Default: ``True`` .
|
|
696
|
-
activities (list, optional): The activities to collect.
|
|
700
|
+
activities (Iterable, optional): The activities to collect.
|
|
697
701
|
Default: ``[ProfilerActivity.CPU, ProfilerActivity.NPU]``.
|
|
698
702
|
|
|
699
703
|
- ProfilerActivity.CPU: Collect MindSpore framework data.
|
|
700
704
|
- ProfilerActivity.NPU: Collect CANN software stack and NPU data.
|
|
701
705
|
- ProfilerActivity.GPU: Collect GPU data.
|
|
702
|
-
schedule (schedule, optional): Sets the action strategy for the capture, defined by the schedule class,
|
|
703
|
-
to be used with the step interface. Default: ``None``. Performance data of all steps is collected.
|
|
704
|
-
For details, see :class:`mindspore.profiler.schedule` .
|
|
705
|
-
on_trace_ready (Callable, optional): Sets the callback function to be executed when the performance data
|
|
706
|
-
is collected. Default: ``None``. It indicates that only performance data is collected, but not resolved.
|
|
707
|
-
For details, see :func:`mindspore.profiler.tensorboard_trace_handler` .
|
|
708
|
-
profile_memory (bool, optional): (Ascend only) Whether to collect tensor memory data, collect when ``True`` .
|
|
709
|
-
When using this parameter, `activities` must set to ``[ProfilerActivity.CPU, ProfilerActivity.NPU]``.
|
|
710
|
-
Collecting operator memory data when the graph compilation level is O2 requires collecting from the
|
|
711
|
-
first step. Default: ``False`` . The operator name currently collected by this parameter is incomplete.
|
|
712
|
-
This issue will be resolved in later versions. It is recommended to use the environment variable
|
|
713
|
-
``MS_ALLOC_CONF`` instead.
|
|
714
706
|
with_stack (bool, optional): (Ascend only) Whether to collect frame host call stack data
|
|
715
707
|
on the Python side. This
|
|
716
708
|
data is presented in the form of a flame graph in the timeline. When using this parameter, `activities` must
|
|
717
709
|
include ``ProfilerActivity.CPU``. Default value: ``False`` .
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
Default: ``False`` .
|
|
710
|
+
profile_memory (bool, optional): (Ascend only) Whether to collect tensor memory data, collect when ``True`` .
|
|
711
|
+
When using this parameter, `activities` must set to ``[ProfilerActivity.CPU, ProfilerActivity.NPU]``.
|
|
712
|
+
Collecting operator memory data when GE backend requires collecting from the first step.
|
|
713
|
+
Default: ``False`` . The operator name currently collected by this parameter is incomplete.
|
|
714
|
+
This issue will be resolved in later versions. It is recommended to use the environment variable
|
|
715
|
+
``MS_ALLOC_CONF`` instead.
|
|
722
716
|
data_process (bool, optional): (Ascend/GPU) Whether to collect data to prepare performance data.
|
|
723
717
|
Default value: ``False`` .
|
|
724
718
|
parallel_strategy (bool, optional): (Ascend only) Whether to collect parallel policy performance data.
|
|
725
719
|
Default value: ``False`` .
|
|
720
|
+
start_profile (bool, optional): The start_profile parameter controls whether to enable or disable performance
|
|
721
|
+
data collection based on conditions. Default: ``True`` .
|
|
722
|
+
hbm_ddr (bool, optional): (Ascend only) Whether to collect On-Chip Memory/DDR read and write rate data,
|
|
723
|
+
collect when True. Default: ``False`` .
|
|
724
|
+
pcie (bool, optional): (Ascend only) Whether to collect PCIe bandwidth data, collect when True.
|
|
725
|
+
Default: ``False`` .
|
|
726
726
|
sync_enable (bool, optional): (GPU only) Whether the profiler collects operators in a synchronous way.
|
|
727
727
|
Default: ``True`` .
|
|
728
728
|
|
|
@@ -731,6 +731,15 @@ class Profile:
|
|
|
731
731
|
The duration of the operator is the difference between the two timestamps.
|
|
732
732
|
- False: The asynchronous way. The duration of the operator is that of sending from the CPU to the GPU.
|
|
733
733
|
This method can reduce the impact of adding profiler on overall training time.
|
|
734
|
+
record_shapes (bool, optional): (Ascend only) Whether to collect operator input tensor shapes data, collect
|
|
735
|
+
when ``True`` . When using this parameter, `activities` must include ``ProfilerActivity.CPU``.
|
|
736
|
+
Default: ``False``.
|
|
737
|
+
schedule (Callable, optional): Sets the action strategy for the capture, defined by the schedule class,
|
|
738
|
+
to be used with the step interface. Default: ``None``. Performance data of all steps is collected.
|
|
739
|
+
For details, see :class:`mindspore.profiler.schedule` .
|
|
740
|
+
on_trace_ready (Callable, optional): Sets the callback function to be executed when the performance data
|
|
741
|
+
is collected. Default: ``None``. It indicates that only performance data is collected, but not resolved.
|
|
742
|
+
For details, see :func:`mindspore.profiler.tensorboard_trace_handler` .
|
|
734
743
|
experimental_config (_ExperimentalConfig, optional): expandable parameters can be configured in this
|
|
735
744
|
configuration item. For details, see :class:`mindspore.profiler._ExperimentalConfig` .
|
|
736
745
|
Raises:
|
|
@@ -782,8 +791,8 @@ class Profile:
|
|
|
782
791
|
... net = Net()
|
|
783
792
|
... # Note that the Profiler should be initialized before model.train
|
|
784
793
|
... with mindspore.profiler.profile(activities=[ProfilerActivity.CPU, ProfilerActivity.NPU],
|
|
785
|
-
... schedule=mindspore.profiler.schedule(wait=
|
|
786
|
-
... repeat=1, skip_first=
|
|
794
|
+
... schedule=mindspore.profiler.schedule(wait=0, warmup=0, active=1,
|
|
795
|
+
... repeat=1, skip_first=0),
|
|
787
796
|
... on_trace_ready=mindspore.profiler.
|
|
788
797
|
... tensorboard_trace_handler("./data"),
|
|
789
798
|
... profile_memory=False,
|
|
@@ -795,62 +804,54 @@ class Profile:
|
|
|
795
804
|
... prof.step()
|
|
796
805
|
"""
|
|
797
806
|
|
|
798
|
-
def __init__(
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
self.
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
)
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
self._profiler.__enter__()
|
|
847
|
-
return self
|
|
848
|
-
|
|
849
|
-
def __exit__(self, exe_type, exe_val, exc_tb):
|
|
850
|
-
self._profiler.__exit__(exe_type, exe_val, exc_tb)
|
|
851
|
-
|
|
852
|
-
def __del__(self):
|
|
853
|
-
self._profiler.__del__()
|
|
807
|
+
def __init__(self,
|
|
808
|
+
activities: Optional[Iterable[ProfilerActivity]] = None,
|
|
809
|
+
with_stack: bool = False,
|
|
810
|
+
profile_memory: bool = False,
|
|
811
|
+
data_process: bool = False,
|
|
812
|
+
parallel_strategy: bool = False,
|
|
813
|
+
start_profile: bool = True,
|
|
814
|
+
hbm_ddr: bool = False,
|
|
815
|
+
pcie: bool = False,
|
|
816
|
+
sync_enable: bool = True,
|
|
817
|
+
record_shapes: bool = False,
|
|
818
|
+
schedule: Optional[Callable[[int], ProfilerAction]] = None,
|
|
819
|
+
on_trace_ready: Optional[Callable[..., Any]] = None,
|
|
820
|
+
experimental_config: Optional[_ExperimentalConfig] = None):
|
|
821
|
+
self._metadata: Dict[str, str] = {}
|
|
822
|
+
self._prof_context: ProfilerContext = ProfilerContext()
|
|
823
|
+
kwargs = {
|
|
824
|
+
"activities": activities,
|
|
825
|
+
"with_stack": with_stack,
|
|
826
|
+
"profile_memory": profile_memory,
|
|
827
|
+
"data_process": data_process,
|
|
828
|
+
"parallel_strategy": parallel_strategy,
|
|
829
|
+
"start_profile": start_profile,
|
|
830
|
+
"hbm_ddr": hbm_ddr,
|
|
831
|
+
"pcie": pcie,
|
|
832
|
+
"sync_enable": sync_enable,
|
|
833
|
+
"record_shapes": record_shapes,
|
|
834
|
+
"schedule": schedule,
|
|
835
|
+
"on_trace_ready": on_trace_ready,
|
|
836
|
+
"experimental_config": experimental_config,
|
|
837
|
+
}
|
|
838
|
+
self._prof_context.set_params(**kwargs)
|
|
839
|
+
self._has_started: bool = False
|
|
840
|
+
if schedule and isinstance(schedule, Callable):
|
|
841
|
+
self.schedule = schedule
|
|
842
|
+
# add step markers into the trace and table view
|
|
843
|
+
self.record_steps = True
|
|
844
|
+
else:
|
|
845
|
+
if schedule:
|
|
846
|
+
logger.warning("schedule is not Callable, set by default.")
|
|
847
|
+
self.schedule = _default_schedule_fn
|
|
848
|
+
self.record_steps = False
|
|
849
|
+
self._step_rec_fn: Optional[RecordFunction] = None
|
|
850
|
+
self.step_num = 0
|
|
851
|
+
self.current_action: ProfilerAction = self.schedule(self.step_num)
|
|
852
|
+
self.action_controller = ProfilerActionController(ProfilerInterface, self._prof_context.on_trace_ready)
|
|
853
|
+
if self._prof_context.start_profile:
|
|
854
|
+
self.start()
|
|
854
855
|
|
|
855
856
|
def start(self) -> None:
|
|
856
857
|
"""
|
|
@@ -902,8 +903,8 @@ class Profile:
|
|
|
902
903
|
... net = Net()
|
|
903
904
|
... # Note that the Profiler should be initialized before model.train
|
|
904
905
|
... prof = mindspore.profiler.profile(activities=[ProfilerActivity.CPU, ProfilerActivity.NPU],
|
|
905
|
-
... schedule=mindspore.profiler.schedule(wait=
|
|
906
|
-
... repeat=1, skip_first=
|
|
906
|
+
... schedule=mindspore.profiler.schedule(wait=0, warmup=0, active=1,
|
|
907
|
+
... repeat=1, skip_first=0),
|
|
907
908
|
... on_trace_ready=mindspore.profiler.
|
|
908
909
|
... tensorboard_trace_handler("./data"),
|
|
909
910
|
... profile_memory=False,
|
|
@@ -915,7 +916,14 @@ class Profile:
|
|
|
915
916
|
... prof.step()
|
|
916
917
|
... prof.stop()
|
|
917
918
|
"""
|
|
918
|
-
self.
|
|
919
|
+
if self._has_started:
|
|
920
|
+
logger.warning("The profile has already started. Do not turn on again in the open state.")
|
|
921
|
+
return
|
|
922
|
+
self._has_started = True
|
|
923
|
+
self.action_controller.transit_action(ProfilerAction.NONE, self.current_action)
|
|
924
|
+
if self.record_steps:
|
|
925
|
+
self._step_rec_fn = RecordFunction(ProfilerStepNameConstant.PROFILER_STEP + str(self.step_num))
|
|
926
|
+
self._step_rec_fn.start()
|
|
919
927
|
|
|
920
928
|
def stop(self) -> None:
|
|
921
929
|
"""
|
|
@@ -966,8 +974,8 @@ class Profile:
|
|
|
966
974
|
... net = Net()
|
|
967
975
|
... # Note that the Profiler should be initialized before model.train
|
|
968
976
|
... prof = mindspore.profiler.profile(activities=[ProfilerActivity.CPU, ProfilerActivity.NPU],
|
|
969
|
-
... schedule=mindspore.profiler.schedule(wait=
|
|
970
|
-
... repeat=1, skip_first=
|
|
977
|
+
... schedule=mindspore.profiler.schedule(wait=0, warmup=0, active=1,
|
|
978
|
+
... repeat=1, skip_first=0),
|
|
971
979
|
... on_trace_ready=mindspore.profiler.
|
|
972
980
|
... tensorboard_trace_handler("./data"),
|
|
973
981
|
... profile_memory=False,
|
|
@@ -979,7 +987,13 @@ class Profile:
|
|
|
979
987
|
... prof.step()
|
|
980
988
|
... prof.stop()
|
|
981
989
|
"""
|
|
982
|
-
self.
|
|
990
|
+
if not self._has_started:
|
|
991
|
+
logger.error("The profile has not started. Do not turn off again in the closed state.")
|
|
992
|
+
return
|
|
993
|
+
self._has_started = False
|
|
994
|
+
if self.record_steps and self._step_rec_fn:
|
|
995
|
+
self._step_rec_fn.stop()
|
|
996
|
+
self.action_controller.transit_action(self.current_action, None)
|
|
983
997
|
|
|
984
998
|
def step(self) -> None:
|
|
985
999
|
"""
|
|
@@ -990,59 +1004,71 @@ class Profile:
|
|
|
990
1004
|
RuntimeError: If the `schedule` parameter is not set.
|
|
991
1005
|
|
|
992
1006
|
Examples:
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1007
|
+
>>> import numpy as np
|
|
1008
|
+
>>> import mindspore
|
|
1009
|
+
>>> from mindspore import nn, context
|
|
1010
|
+
>>> import mindspore.dataset as ds
|
|
1011
|
+
>>> from mindspore.profiler import ProfilerLevel, ProfilerActivity, AicoreMetrics, ExportType
|
|
1012
|
+
>>>
|
|
1013
|
+
>>> class Net(nn.Cell):
|
|
1014
|
+
... def __init__(self):
|
|
1015
|
+
... super(Net, self).__init__()
|
|
1016
|
+
... self.fc = nn.Dense(2,2)
|
|
1017
|
+
... def construct(self, x):
|
|
1018
|
+
... return self.fc(x)
|
|
1019
|
+
>>>
|
|
1020
|
+
>>> def generator():
|
|
1021
|
+
... for i in range(2):
|
|
1022
|
+
... yield np.ones([2, 2]).astype(np.float32), np.ones([2]).astype(np.int32)
|
|
1023
|
+
>>>
|
|
1024
|
+
>>> def train(net):
|
|
1025
|
+
... optimizer = nn.Momentum(net.trainable_params(), 1, 0.9)
|
|
1026
|
+
... loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True)
|
|
1027
|
+
... data = ds.GeneratorDataset(generator, ["data", "label"])
|
|
1028
|
+
... model = mindspore.train.Model(net, loss, optimizer)
|
|
1029
|
+
... model.train(1, data)
|
|
1030
|
+
>>>
|
|
1031
|
+
>>> if __name__ == '__main__':
|
|
1032
|
+
... # If the device_target is GPU, set the device_target to "GPU"
|
|
1033
|
+
... context.set_context(mode=mindspore.GRAPH_MODE)
|
|
1034
|
+
... mindspore.set_device("Ascend")
|
|
1035
|
+
...
|
|
1036
|
+
... # Init Profiler
|
|
1037
|
+
... experimental_config = mindspore.profiler._ExperimentalConfig(
|
|
1038
|
+
... profiler_level=ProfilerLevel.Level0,
|
|
1039
|
+
... aic_metrics=AicoreMetrics.AiCoreNone,
|
|
1040
|
+
... l2_cache=False,
|
|
1041
|
+
... mstx=False,
|
|
1042
|
+
... data_simplification=False,
|
|
1043
|
+
... export_type=[ExportType.Text])
|
|
1044
|
+
... steps = 10
|
|
1045
|
+
... net = Net()
|
|
1046
|
+
... # Note that the Profiler should be initialized before model.train
|
|
1047
|
+
... with mindspore.profiler.profile(activities=[ProfilerActivity.CPU, ProfilerActivity.NPU],
|
|
1048
|
+
... schedule=mindspore.profiler.schedule(wait=0, warmup=0, active=1,
|
|
1049
|
+
... repeat=1, skip_first=0),
|
|
1050
|
+
... on_trace_ready=mindspore.profiler.
|
|
1051
|
+
... tensorboard_trace_handler("./data"),
|
|
1052
|
+
... profile_memory=False,
|
|
1053
|
+
... experimental_config=experimental_config) as prof:
|
|
1054
|
+
...
|
|
1055
|
+
... # Train Model
|
|
1056
|
+
... for step in range(steps):
|
|
1057
|
+
... train(net)
|
|
1058
|
+
... prof.step()
|
|
1044
1059
|
"""
|
|
1045
|
-
self.
|
|
1060
|
+
if not self._has_started:
|
|
1061
|
+
logger.error("profile is stopped, step takes no effect!")
|
|
1062
|
+
return
|
|
1063
|
+
if self.record_steps and self._step_rec_fn:
|
|
1064
|
+
self._step_rec_fn.stop()
|
|
1065
|
+
prev_action = self.current_action
|
|
1066
|
+
self.step_num += 1
|
|
1067
|
+
self.current_action = self.schedule(self.step_num)
|
|
1068
|
+
self.action_controller.transit_action(prev_action, self.current_action)
|
|
1069
|
+
if self.record_steps:
|
|
1070
|
+
self._step_rec_fn = RecordFunction(ProfilerStepNameConstant.PROFILER_STEP + str(self.step_num))
|
|
1071
|
+
self._step_rec_fn.start()
|
|
1046
1072
|
|
|
1047
1073
|
def add_metadata(self, key: str, value: str):
|
|
1048
1074
|
"""
|
|
@@ -1059,8 +1085,18 @@ class Profile:
|
|
|
1059
1085
|
... # Call Profiler add_metadata
|
|
1060
1086
|
... prof.add_metadata("test_key", "test_value")
|
|
1061
1087
|
"""
|
|
1088
|
+
if not isinstance(key, str) or not isinstance(value, str):
|
|
1089
|
+
logger.warning("The key and value of metadata must be string. Skip this metadata.")
|
|
1090
|
+
return
|
|
1062
1091
|
|
|
1063
|
-
|
|
1092
|
+
add_size = getsizeof(key) + getsizeof(value)
|
|
1093
|
+
if getsizeof(self._metadata) + add_size < ProfilerMetaData.MAX_META_SIZE:
|
|
1094
|
+
if key in self._metadata:
|
|
1095
|
+
logger.warning(f"{key} is already saved as metadata, override it.")
|
|
1096
|
+
self._metadata[key] = value
|
|
1097
|
+
ProfilerMetaData.set_metadata(self._metadata)
|
|
1098
|
+
else:
|
|
1099
|
+
logger.warning("Too many metadata added. Skip this metadata")
|
|
1064
1100
|
|
|
1065
1101
|
def add_metadata_json(self, key: str, value: str):
|
|
1066
1102
|
"""
|
|
@@ -1078,7 +1114,35 @@ class Profile:
|
|
|
1078
1114
|
... # Call Profiler add_metadata_json
|
|
1079
1115
|
... prof.add_metadata_json("test_key", json.dumps({"key1": 1, "key2": 2}))
|
|
1080
1116
|
"""
|
|
1081
|
-
|
|
1117
|
+
if not isinstance(key, str) or not isinstance(value, str):
|
|
1118
|
+
logger.warning("The key and value of metadata must be string. Skip this metadata.")
|
|
1119
|
+
return
|
|
1120
|
+
|
|
1121
|
+
add_size = getsizeof(key) + getsizeof(value)
|
|
1122
|
+
if getsizeof(self._metadata) + add_size < ProfilerMetaData.MAX_META_SIZE:
|
|
1123
|
+
try:
|
|
1124
|
+
if key in self._metadata:
|
|
1125
|
+
logger.warning(f"{key} is already saved as metadata, override it.")
|
|
1126
|
+
self._metadata[key] = json.loads(value)
|
|
1127
|
+
ProfilerMetaData.set_metadata(self._metadata)
|
|
1128
|
+
except ValueError:
|
|
1129
|
+
logger.warning("The metadata value must be json format string. Skip this metadata")
|
|
1130
|
+
else:
|
|
1131
|
+
logger.warning("Too many metadata added. Skip this metadata")
|
|
1132
|
+
|
|
1133
|
+
def __enter__(self) -> 'Profile':
|
|
1134
|
+
if not self._has_started:
|
|
1135
|
+
self.start()
|
|
1136
|
+
return self
|
|
1137
|
+
|
|
1138
|
+
def __exit__(self, exc_type, exc_value, traceback) -> None:
|
|
1139
|
+
if self._has_started:
|
|
1140
|
+
self.stop()
|
|
1141
|
+
|
|
1142
|
+
def __del__(self):
|
|
1143
|
+
if self._has_started:
|
|
1144
|
+
self.stop()
|
|
1145
|
+
logger.warning("profile is stopped at the end of the program.")
|
|
1082
1146
|
|
|
1083
1147
|
|
|
1084
1148
|
def analyse(profiler_path: str, max_process_number: int = os.cpu_count() // 2, pretty=False, step_list=None,
|