mindspore 2.5.0__cp311-cp311-win_amd64.whl → 2.6.0rc1__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 +6 -4
- 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/_check_jit_forbidden_api.py +3 -0
- mindspore/_checkparam.py +3 -33
- mindspore/_deprecated/__init__.py +17 -0
- mindspore/_deprecated/jit.py +198 -0
- mindspore/_extends/builtin_operations.py +1 -1
- mindspore/_extends/parse/__init__.py +6 -7
- mindspore/_extends/parse/compile_config.py +19 -0
- mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +22 -3
- mindspore/_extends/parse/jit_fallback_modules/__init__.py +0 -0
- mindspore/_extends/parse/jit_fallback_modules/check_utils.py +123 -0
- mindspore/_extends/parse/jit_fallback_modules/third_party_modules.py +50 -0
- mindspore/_extends/parse/parser.py +24 -193
- mindspore/_extends/parse/resources.py +1 -5
- mindspore/_extends/parse/standard_method.py +97 -74
- mindspore/_extends/pijit/__init__.py +2 -2
- mindspore/_extends/pijit/pijit_func_white_list.py +16 -11
- mindspore/_extends/pijit/tensor_func_list.py +27 -0
- mindspore/_extends/utils.py +1 -1
- mindspore/amp.py +4 -4
- 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/__init__.py +2 -2
- mindspore/boost/base.py +3 -7
- mindspore/boost/boost_cell_wrapper.py +2 -2
- mindspore/c1.dll +0 -0
- mindspore/c1xx.dll +0 -0
- mindspore/c2.dll +0 -0
- mindspore/common/__init__.py +4 -3
- mindspore/common/_grad_function.py +56 -0
- mindspore/common/_pijit_context.py +14 -5
- mindspore/common/_register_for_tensor.py +1 -1
- mindspore/common/_stub_tensor.py +5 -10
- mindspore/common/_tensor_cpp_method.py +1 -1
- mindspore/common/_tensor_docs.py +1915 -3287
- mindspore/common/api.py +341 -354
- mindspore/common/auto_dynamic_shape.py +41 -44
- mindspore/common/dtype.py +5 -2
- mindspore/common/dump.py +7 -5
- mindspore/common/file_system.py +3 -0
- mindspore/common/hook_handle.py +5 -3
- mindspore/common/initializer.py +10 -6
- mindspore/common/jit_begin_end.py +94 -0
- mindspore/common/jit_config.py +6 -1
- mindspore/common/jit_context.py +76 -0
- mindspore/common/jit_trace.py +378 -0
- mindspore/common/lazy_inline.py +2 -2
- mindspore/common/mutable.py +5 -4
- mindspore/common/parameter.py +106 -39
- mindspore/common/seed.py +2 -2
- mindspore/common/sparse_tensor.py +23 -17
- mindspore/common/tensor.py +297 -714
- mindspore/communication/__init__.py +7 -5
- mindspore/communication/_comm_helper.py +47 -2
- mindspore/communication/comm_func.py +70 -53
- mindspore/communication/management.py +83 -17
- mindspore/context.py +214 -560
- mindspore/dataset/__init__.py +44 -20
- mindspore/dataset/audio/__init__.py +2 -8
- mindspore/dataset/audio/transforms.py +3 -17
- mindspore/dataset/core/config.py +3 -3
- mindspore/dataset/engine/cache_client.py +1 -1
- mindspore/dataset/engine/datasets.py +102 -120
- mindspore/dataset/engine/datasets_audio.py +22 -22
- mindspore/dataset/engine/datasets_standard_format.py +43 -24
- mindspore/dataset/engine/datasets_text.py +78 -85
- mindspore/dataset/engine/datasets_user_defined.py +108 -76
- mindspore/dataset/engine/datasets_vision.py +111 -108
- mindspore/dataset/engine/iterators.py +5 -3
- mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +1 -1
- mindspore/dataset/engine/samplers.py +279 -57
- mindspore/dataset/engine/serializer_deserializer.py +2 -1
- mindspore/dataset/engine/validators.py +10 -0
- mindspore/dataset/text/__init__.py +7 -6
- mindspore/dataset/text/transforms.py +6 -5
- mindspore/dataset/text/utils.py +3 -3
- mindspore/dataset/transforms/__init__.py +0 -9
- mindspore/dataset/transforms/transforms.py +3 -3
- mindspore/dataset/utils/browse_dataset.py +1 -1
- mindspore/dataset/vision/__init__.py +2 -9
- mindspore/dataset/vision/transforms.py +202 -158
- mindspore/dataset/vision/utils.py +7 -5
- mindspore/device_context/ascend/op_debug.py +60 -1
- mindspore/device_context/ascend/op_tuning.py +0 -4
- mindspore/device_manager.py +39 -3
- mindspore/dnnl.dll +0 -0
- mindspore/dpcmi.dll +0 -0
- mindspore/experimental/es/embedding_service.py +35 -27
- mindspore/experimental/map_parameter.py +4 -4
- mindspore/experimental/optim/adadelta.py +22 -26
- mindspore/experimental/optim/adagrad.py +4 -4
- mindspore/experimental/optim/adam.py +4 -0
- mindspore/experimental/optim/adamax.py +4 -4
- mindspore/experimental/optim/adamw.py +4 -0
- mindspore/experimental/optim/asgd.py +1 -1
- mindspore/experimental/optim/lr_scheduler.py +40 -22
- mindspore/experimental/optim/radam.py +5 -5
- mindspore/experimental/optim/rprop.py +1 -1
- mindspore/experimental/optim/sgd.py +1 -1
- mindspore/hal/contiguous_tensors_handle.py +6 -10
- mindspore/hal/device.py +55 -81
- mindspore/hal/event.py +38 -55
- mindspore/hal/memory.py +93 -144
- mindspore/hal/stream.py +81 -125
- mindspore/include/dataset/constants.h +7 -4
- mindspore/include/dataset/execute.h +2 -2
- mindspore/jpeg62.dll +0 -0
- mindspore/log.py +40 -2
- mindspore/mindrecord/__init__.py +20 -7
- 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_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_backend.dll → 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 +131 -700
- mindspore/mint/distributed/__init__.py +5 -1
- mindspore/mint/distributed/distributed.py +194 -109
- mindspore/mint/linalg/__init__.py +2 -0
- mindspore/mint/nn/__init__.py +280 -18
- mindspore/mint/nn/functional.py +282 -64
- mindspore/mint/nn/layer/__init__.py +4 -0
- mindspore/mint/nn/layer/_functions.py +7 -3
- mindspore/mint/nn/layer/activation.py +120 -13
- mindspore/mint/nn/layer/conv.py +218 -24
- mindspore/mint/nn/layer/normalization.py +15 -16
- mindspore/mint/nn/layer/padding.py +1 -1
- mindspore/mint/nn/layer/pooling.py +66 -1
- mindspore/mint/optim/__init__.py +2 -1
- mindspore/mint/optim/sgd.py +171 -0
- 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/__init__.py +4 -1
- mindspore/nn/cell.py +1250 -176
- mindspore/nn/layer/activation.py +23 -21
- mindspore/nn/layer/basic.py +22 -16
- mindspore/nn/layer/container.py +1 -1
- mindspore/nn/layer/conv.py +22 -17
- mindspore/nn/layer/embedding.py +9 -8
- mindspore/nn/layer/normalization.py +48 -42
- mindspore/nn/layer/pooling.py +75 -31
- mindspore/nn/layer/transformer.py +11 -10
- mindspore/nn/learning_rate_schedule.py +4 -2
- mindspore/nn/loss/loss.py +27 -19
- mindspore/nn/optim/ada_grad.py +6 -5
- mindspore/nn/optim/adadelta.py +9 -7
- mindspore/nn/optim/adafactor.py +1 -1
- mindspore/nn/optim/adam.py +16 -12
- mindspore/nn/optim/adamax.py +8 -7
- mindspore/nn/optim/adasum.py +5 -5
- mindspore/nn/optim/asgd.py +1 -1
- mindspore/nn/optim/ftrl.py +11 -9
- mindspore/nn/optim/lamb.py +1 -1
- mindspore/nn/optim/lazyadam.py +12 -10
- mindspore/nn/optim/momentum.py +7 -6
- mindspore/nn/optim/optimizer.py +2 -2
- mindspore/nn/optim/proximal_ada_grad.py +12 -10
- mindspore/nn/optim/rmsprop.py +13 -12
- mindspore/nn/optim/rprop.py +9 -7
- mindspore/nn/optim/sgd.py +9 -6
- mindspore/nn/optim/tft_wrapper.py +5 -2
- mindspore/nn/probability/bijector/bijector.py +17 -11
- mindspore/nn/probability/bijector/gumbel_cdf.py +5 -5
- mindspore/nn/probability/bijector/invert.py +2 -2
- mindspore/nn/probability/bijector/scalar_affine.py +3 -3
- mindspore/nn/probability/bijector/softplus.py +3 -2
- mindspore/nn/probability/distribution/beta.py +3 -3
- mindspore/nn/probability/distribution/categorical.py +1 -1
- mindspore/nn/probability/distribution/cauchy.py +4 -2
- mindspore/nn/probability/distribution/exponential.py +6 -7
- mindspore/nn/probability/distribution/gamma.py +2 -2
- mindspore/nn/probability/distribution/gumbel.py +2 -2
- mindspore/nn/probability/distribution/half_normal.py +5 -3
- mindspore/nn/probability/distribution/logistic.py +5 -3
- mindspore/nn/probability/distribution/poisson.py +1 -1
- mindspore/nn/probability/distribution/uniform.py +5 -3
- mindspore/nn/reinforcement/_tensors_queue.py +1 -1
- mindspore/nn/reinforcement/tensor_array.py +1 -1
- mindspore/nn/wrap/__init__.py +6 -6
- mindspore/nn/wrap/cell_wrapper.py +178 -117
- mindspore/nn/wrap/grad_reducer.py +45 -36
- mindspore/nn/wrap/loss_scale.py +3 -3
- mindspore/numpy/array_creations.py +3 -3
- mindspore/numpy/array_ops.py +1 -1
- mindspore/numpy/math_ops.py +4 -4
- mindspore/numpy/utils.py +1 -2
- mindspore/numpy/utils_const.py +1 -2
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/opencv_imgproc452.dll +0 -0
- mindspore/ops/__init__.py +3 -2
- mindspore/ops/_grad_experimental/grad_comm_ops.py +18 -3
- mindspore/ops/_grad_experimental/grad_debug_ops.py +8 -1
- mindspore/ops/_grad_experimental/taylor_rule.py +29 -0
- mindspore/ops/_register_for_op.py +0 -11
- mindspore/{ops_generate → ops/_utils}/arg_dtype_cast.py +123 -4
- mindspore/{ops_generate → ops/_utils}/arg_handler.py +3 -4
- mindspore/ops/_vmap/vmap_array_ops.py +7 -6
- mindspore/ops/_vmap/vmap_grad_nn_ops.py +2 -1
- mindspore/ops/_vmap/vmap_math_ops.py +4 -7
- mindspore/ops/_vmap/vmap_nn_ops.py +9 -8
- mindspore/ops/auto_generate/__init__.py +4 -3
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +102 -49
- mindspore/ops/auto_generate/gen_extend_func.py +281 -135
- mindspore/ops/auto_generate/gen_ops_def.py +2574 -2326
- mindspore/ops/auto_generate/gen_ops_prim.py +8566 -2755
- mindspore/ops/auto_generate/pyboost_inner_prim.py +106 -76
- mindspore/ops/composite/__init__.py +2 -1
- mindspore/ops/composite/base.py +19 -24
- mindspore/ops/composite/math_ops.py +6 -16
- mindspore/ops/composite/multitype_ops/__init__.py +5 -2
- mindspore/ops/composite/multitype_ops/_compile_utils.py +2 -3
- mindspore/ops/composite/multitype_ops/_constexpr_utils.py +1 -2
- mindspore/ops/composite/multitype_ops/add_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/bitwise_and_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/bitwise_or_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/bitwise_xor_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/div_impl.py +6 -4
- mindspore/ops/composite/multitype_ops/equal_impl.py +4 -3
- mindspore/ops/composite/multitype_ops/floordiv_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/getitem_impl.py +3 -2
- mindspore/ops/composite/multitype_ops/greater_equal_impl.py +4 -3
- mindspore/ops/composite/multitype_ops/greater_impl.py +4 -3
- mindspore/ops/composite/multitype_ops/in_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/invert_impl.py +50 -0
- mindspore/ops/composite/multitype_ops/left_shift_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/less_equal_impl.py +4 -3
- mindspore/ops/composite/multitype_ops/less_impl.py +4 -3
- mindspore/ops/composite/multitype_ops/logic_not_impl.py +3 -2
- mindspore/ops/composite/multitype_ops/logical_and_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/logical_or_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/mod_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/mul_impl.py +3 -2
- mindspore/ops/composite/multitype_ops/negative_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/not_equal_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/not_in_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/ones_like_impl.py +18 -0
- mindspore/ops/composite/multitype_ops/pow_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/right_shift_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/setitem_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/sub_impl.py +2 -1
- mindspore/ops/function/__init__.py +28 -2
- mindspore/ops/function/_add_attr_func.py +58 -0
- mindspore/ops/function/array_func.py +1629 -2345
- mindspore/ops/function/clip_func.py +38 -45
- mindspore/ops/function/debug_func.py +36 -44
- mindspore/ops/function/grad/__init__.py +1 -0
- mindspore/ops/function/grad/grad_func.py +104 -71
- mindspore/ops/function/image_func.py +1 -1
- mindspore/ops/function/linalg_func.py +46 -78
- mindspore/ops/function/math_func.py +3035 -3705
- mindspore/ops/function/nn_func.py +676 -241
- mindspore/ops/function/other_func.py +159 -1
- mindspore/ops/function/parameter_func.py +17 -30
- mindspore/ops/function/random_func.py +204 -361
- mindspore/ops/function/reshard_func.py +4 -70
- mindspore/ops/function/sparse_func.py +3 -3
- mindspore/ops/function/sparse_unary_func.py +5 -5
- mindspore/ops/function/spectral_func.py +25 -58
- mindspore/ops/function/vmap_func.py +24 -17
- mindspore/ops/functional.py +6 -4
- mindspore/ops/functional_overload.py +547 -4
- mindspore/ops/op_info_register.py +32 -244
- mindspore/ops/operations/__init__.py +10 -5
- mindspore/ops/operations/_custom_ops_utils.py +247 -0
- mindspore/ops/operations/_grad_ops.py +1 -10
- mindspore/ops/operations/_inner_ops.py +5 -76
- mindspore/ops/operations/_ms_kernel.py +4 -10
- mindspore/ops/operations/_rl_inner_ops.py +1 -1
- mindspore/ops/operations/_scalar_ops.py +3 -2
- mindspore/ops/operations/_sequence_ops.py +1 -1
- mindspore/ops/operations/_tensor_array.py +1 -1
- mindspore/ops/operations/array_ops.py +37 -22
- mindspore/ops/operations/comm_ops.py +150 -107
- mindspore/ops/operations/custom_ops.py +221 -23
- mindspore/ops/operations/debug_ops.py +115 -16
- mindspore/ops/operations/inner_ops.py +1 -1
- mindspore/ops/operations/linalg_ops.py +1 -58
- mindspore/ops/operations/manually_defined/_inner.py +1 -1
- mindspore/ops/operations/manually_defined/ops_def.py +746 -79
- mindspore/ops/operations/math_ops.py +21 -18
- mindspore/ops/operations/nn_ops.py +65 -191
- mindspore/ops/operations/other_ops.py +62 -9
- mindspore/ops/operations/random_ops.py +13 -7
- mindspore/ops/operations/reshard_ops.py +1 -1
- mindspore/ops/operations/sparse_ops.py +2 -2
- mindspore/ops/primitive.py +43 -32
- mindspore/ops/tensor_method.py +232 -13
- mindspore/ops_generate/__init__.py +0 -5
- mindspore/ops_generate/aclnn/__init__.py +0 -0
- mindspore/ops_generate/{aclnn_kernel_register_auto_cc_generator.py → aclnn/aclnn_kernel_register_auto_cc_generator.py} +43 -18
- mindspore/ops_generate/{gen_aclnn_implement.py → aclnn/gen_aclnn_implement.py} +49 -51
- mindspore/ops_generate/api/__init__.py +0 -0
- mindspore/ops_generate/{add_tensor_docs_generator.py → api/add_tensor_docs_generator.py} +9 -7
- mindspore/ops_generate/{cpp_create_prim_instance_helper_generator.py → api/cpp_create_prim_instance_helper_generator.py} +6 -9
- mindspore/ops_generate/{functional_map_cpp_generator.py → api/functional_map_cpp_generator.py} +25 -12
- mindspore/ops_generate/{functional_overload_py_generator.py → api/functional_overload_py_generator.py} +8 -6
- mindspore/ops_generate/{functions_cc_generator.py → api/functions_cc_generator.py} +14 -10
- mindspore/ops_generate/api/gen_api.py +103 -0
- mindspore/ops_generate/{op_api_proto.py → api/op_api_proto.py} +98 -69
- mindspore/ops_generate/{tensor_func_reg_cpp_generator.py → api/tensor_func_reg_cpp_generator.py} +82 -43
- mindspore/ops_generate/common/__init__.py +0 -0
- mindspore/ops_generate/common/gen_constants.py +91 -0
- mindspore/ops_generate/{gen_utils.py → common/gen_utils.py} +72 -19
- mindspore/ops_generate/{op_proto.py → common/op_proto.py} +64 -1
- mindspore/ops_generate/{template.py → common/template.py} +96 -84
- mindspore/ops_generate/gen_ops.py +23 -325
- mindspore/ops_generate/op_def/__init__.py +0 -0
- mindspore/ops_generate/op_def/gen_op_def.py +90 -0
- mindspore/ops_generate/{lite_ops_cpp_generator.py → op_def/lite_ops_cpp_generator.py} +47 -11
- mindspore/ops_generate/{ops_def_cc_generator.py → op_def/ops_def_cc_generator.py} +18 -7
- mindspore/ops_generate/{ops_def_h_generator.py → op_def/ops_def_h_generator.py} +5 -5
- mindspore/ops_generate/{ops_name_h_generator.py → op_def/ops_name_h_generator.py} +30 -15
- mindspore/ops_generate/op_def/ops_primitive_h_generator.py +125 -0
- mindspore/ops_generate/op_def_py/__init__.py +0 -0
- mindspore/ops_generate/op_def_py/gen_op_def_py.py +47 -0
- mindspore/ops_generate/{op_def_py_generator.py → op_def_py/op_def_py_generator.py} +6 -5
- mindspore/ops_generate/{op_prim_py_generator.py → op_def_py/op_prim_py_generator.py} +24 -15
- mindspore/ops_generate/pyboost/__init__.py +0 -0
- mindspore/ops_generate/{auto_grad_impl_cc_generator.py → pyboost/auto_grad_impl_cc_generator.py} +11 -7
- mindspore/ops_generate/{auto_grad_reg_cc_generator.py → pyboost/auto_grad_reg_cc_generator.py} +7 -7
- mindspore/ops_generate/{gen_pyboost_func.py → pyboost/gen_pyboost_func.py} +40 -16
- mindspore/ops_generate/{op_template_parser.py → pyboost/op_template_parser.py} +105 -24
- mindspore/ops_generate/{pyboost_functions_cpp_generator.py → pyboost/pyboost_functions_cpp_generator.py} +55 -18
- mindspore/ops_generate/{pyboost_functions_h_generator.py → pyboost/pyboost_functions_h_generator.py} +42 -10
- mindspore/ops_generate/{pyboost_functions_py_generator.py → pyboost/pyboost_functions_py_generator.py} +6 -6
- mindspore/ops_generate/{pyboost_grad_function_cpp_generator.py → pyboost/pyboost_grad_function_cpp_generator.py} +11 -10
- mindspore/ops_generate/{pyboost_inner_prim_generator.py → pyboost/pyboost_inner_prim_generator.py} +8 -7
- mindspore/ops_generate/{pyboost_native_grad_functions_generator.py → pyboost/pyboost_native_grad_functions_generator.py} +14 -10
- mindspore/ops_generate/{pyboost_op_cpp_code_generator.py → pyboost/pyboost_op_cpp_code_generator.py} +140 -53
- mindspore/ops_generate/{pyboost_overload_functions_cpp_generator.py → pyboost/pyboost_overload_functions_cpp_generator.py} +28 -15
- mindspore/ops_generate/{pyboost_utils.py → pyboost/pyboost_utils.py} +88 -4
- mindspore/ops_generate/resources/__init__.py +0 -0
- mindspore/ops_generate/resources/resource_list.py +30 -0
- mindspore/ops_generate/resources/resource_loader.py +36 -0
- mindspore/ops_generate/resources/resource_manager.py +64 -0
- mindspore/ops_generate/resources/yaml_loader.py +88 -0
- mindspore/ops_generate/tensor_py_cc_generator.py +122 -0
- mindspore/parallel/__init__.py +6 -2
- mindspore/parallel/_auto_parallel_context.py +133 -6
- mindspore/parallel/_cell_wrapper.py +130 -15
- mindspore/parallel/_parallel_serialization.py +95 -4
- mindspore/parallel/_ps_context.py +1 -1
- mindspore/parallel/_recovery_context.py +7 -2
- mindspore/parallel/_tensor.py +142 -18
- mindspore/parallel/_utils.py +198 -25
- mindspore/parallel/algo_parameter_config.py +3 -3
- mindspore/parallel/auto_parallel.py +732 -0
- mindspore/parallel/checkpoint_convert.py +159 -0
- mindspore/parallel/checkpoint_transform.py +656 -37
- mindspore/parallel/cluster/process_entity/_api.py +151 -19
- mindspore/parallel/cluster/run.py +1 -1
- mindspore/parallel/function/__init__.py +24 -0
- mindspore/parallel/function/reshard_func.py +259 -0
- mindspore/parallel/nn/__init__.py +25 -0
- mindspore/parallel/nn/parallel_cell_wrapper.py +263 -0
- mindspore/parallel/nn/parallel_grad_reducer.py +169 -0
- mindspore/parallel/parameter_broadcast.py +24 -13
- mindspore/parallel/shard.py +137 -61
- mindspore/parallel/transform_safetensors.py +287 -95
- mindspore/pgodb140.dll +0 -0
- mindspore/pgort140.dll +0 -0
- mindspore/profiler/__init__.py +9 -5
- mindspore/profiler/analysis/parser/ascend_cann_parser.py +6 -2
- mindspore/profiler/analysis/parser/ms_framework_parser.py +4 -4
- mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +7 -4
- mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +22 -0
- mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +3 -3
- mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +241 -86
- mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +41 -2
- mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +33 -35
- mindspore/profiler/analysis/viewer/ascend_memory_viewer.py +7 -0
- mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +8 -3
- mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +141 -30
- mindspore/profiler/analysis/viewer/ms_dataset_viewer.py +5 -6
- mindspore/profiler/common/ascend_msprof_exporter.py +5 -4
- mindspore/profiler/common/constant.py +12 -0
- mindspore/profiler/common/msprof_cmd_tool.py +42 -23
- mindspore/profiler/common/path_manager.py +24 -0
- mindspore/profiler/common/profiler_context.py +26 -2
- mindspore/profiler/common/profiler_meta_data.py +74 -0
- mindspore/profiler/common/profiler_parameters.py +59 -18
- mindspore/profiler/common/profiler_path_manager.py +66 -7
- mindspore/profiler/dynamic_profiler.py +112 -79
- mindspore/profiler/envprofiler.py +26 -1
- mindspore/profiler/experimental_config.py +197 -0
- mindspore/profiler/mstx.py +57 -14
- mindspore/profiler/platform/npu_profiler.py +33 -7
- mindspore/profiler/profiler.py +541 -45
- mindspore/profiler/profiler_action_controller.py +1 -1
- mindspore/profiler/profiler_interface.py +4 -0
- mindspore/profiler/schedule.py +57 -22
- mindspore/rewrite/api/node.py +15 -13
- mindspore/rewrite/api/symbol_tree.py +1 -1
- mindspore/run_check/_check_version.py +25 -14
- mindspore/run_check/run_check.py +1 -1
- mindspore/runtime/__init__.py +2 -2
- mindspore/runtime/executor.py +40 -11
- mindspore/runtime/memory.py +25 -8
- mindspore/safeguard/rewrite_obfuscation.py +12 -9
- mindspore/swresample-4.dll +0 -0
- mindspore/swscale-6.dll +0 -0
- mindspore/tbbmalloc.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/__init__.py +8 -8
- mindspore/train/_utils.py +35 -7
- mindspore/train/amp.py +1 -1
- mindspore/train/callback/__init__.py +2 -2
- mindspore/train/callback/_callback.py +2 -16
- mindspore/train/callback/_checkpoint.py +24 -40
- mindspore/train/callback/_cluster_monitor.py +14 -18
- mindspore/train/callback/_flops_collector.py +2 -3
- mindspore/train/callback/_history.py +7 -4
- mindspore/train/callback/_lambda_callback.py +2 -2
- mindspore/train/callback/_landscape.py +0 -3
- mindspore/train/callback/_loss_monitor.py +2 -1
- mindspore/train/callback/_on_request_exit.py +6 -5
- mindspore/train/callback/_reduce_lr_on_plateau.py +11 -6
- mindspore/train/callback/_summary_collector.py +8 -13
- mindspore/train/callback/_time_monitor.py +2 -1
- mindspore/train/callback/{_tft_register.py → _train_fault_tolerance.py} +179 -103
- mindspore/train/data_sink.py +25 -2
- mindspore/train/dataset_helper.py +4 -5
- mindspore/train/loss_scale_manager.py +8 -7
- mindspore/train/metrics/accuracy.py +3 -3
- mindspore/train/metrics/confusion_matrix.py +9 -9
- mindspore/train/metrics/error.py +3 -3
- mindspore/train/metrics/hausdorff_distance.py +4 -4
- mindspore/train/metrics/mean_surface_distance.py +3 -3
- mindspore/train/metrics/metric.py +0 -12
- mindspore/train/metrics/occlusion_sensitivity.py +4 -2
- mindspore/train/metrics/precision.py +8 -6
- mindspore/train/metrics/recall.py +9 -9
- mindspore/train/metrics/root_mean_square_surface_distance.py +2 -2
- mindspore/train/mind_ir_pb2.py +19 -12
- mindspore/train/model.py +176 -103
- mindspore/train/serialization.py +246 -988
- mindspore/train/summary/_summary_adapter.py +2 -2
- mindspore/train/summary/summary_record.py +1 -1
- mindspore/turbojpeg.dll +0 -0
- mindspore/utils/__init__.py +3 -2
- mindspore/utils/dryrun.py +4 -2
- mindspore/utils/hooks.py +81 -0
- mindspore/utils/utils.py +138 -4
- mindspore/vcmeta.dll +0 -0
- mindspore/vcruntime140.dll +0 -0
- mindspore/vcruntime140_1.dll +0 -0
- mindspore/version.py +1 -1
- {mindspore-2.5.0.dist-info → mindspore-2.6.0rc1.dist-info}/METADATA +2 -1
- {mindspore-2.5.0.dist-info → mindspore-2.6.0rc1.dist-info}/RECORD +483 -438
- mindspore/_install_custom.py +0 -43
- mindspore/common/_register_for_adapter.py +0 -74
- mindspore/ops/auto_generate/gen_arg_dtype_cast.py +0 -252
- mindspore/ops/auto_generate/gen_arg_handler.py +0 -136
- mindspore/ops/operations/_opaque_predicate_registry.py +0 -41
- mindspore/ops_generate/gen_constants.py +0 -190
- mindspore/ops_generate/gen_ops_inner_prim.py +0 -131
- mindspore/ops_generate/ops_primitive_h_generator.py +0 -81
- /mindspore/ops_generate/{base_generator.py → common/base_generator.py} +0 -0
- {mindspore-2.5.0.dist-info → mindspore-2.6.0rc1.dist-info}/WHEEL +0 -0
- {mindspore-2.5.0.dist-info → mindspore-2.6.0rc1.dist-info}/entry_points.txt +0 -0
- {mindspore-2.5.0.dist-info → mindspore-2.6.0rc1.dist-info}/top_level.txt +0 -0
mindspore/profiler/profiler.py
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"""Profiling api file."""
|
|
16
16
|
import os
|
|
17
17
|
import json
|
|
18
|
-
from typing import Optional, Dict
|
|
18
|
+
from typing import Optional, Dict, Callable, Any
|
|
19
19
|
from sys import getsizeof
|
|
20
20
|
from concurrent.futures import ProcessPoolExecutor, as_completed
|
|
21
21
|
|
|
@@ -24,24 +24,36 @@ from mindspore.profiler.common.constant import ProfilerStepNameConstant, DeviceT
|
|
|
24
24
|
from mindspore.profiler.common.profiler_context import ProfilerContext
|
|
25
25
|
from mindspore.profiler.platform.npu_profiler import NPUProfilerAnalysis
|
|
26
26
|
from mindspore.profiler.profiler_action_controller import ProfilerActionController
|
|
27
|
+
from mindspore.profiler.experimental_config import _ExperimentalConfig
|
|
27
28
|
from mindspore.profiler.profiler_interface import ProfilerInterface
|
|
28
|
-
from mindspore.profiler.schedule import _default_schedule_fn, ProfilerAction
|
|
29
|
+
from mindspore.profiler.schedule import _default_schedule_fn, ProfilerAction, Schedule
|
|
29
30
|
from mindspore.profiler.common.record_function import RecordFunction
|
|
30
31
|
from mindspore.profiler.common.path_manager import PathManager
|
|
31
|
-
from mindspore.profiler.common.file_manager import FileManager
|
|
32
32
|
from mindspore.profiler.common.profiler_path_manager import ProfilerPathManager
|
|
33
|
+
from mindspore.profiler.common.profiler_meta_data import ProfilerMetaData
|
|
33
34
|
|
|
34
35
|
|
|
35
|
-
def
|
|
36
|
+
def tensorboard_trace_handler(dir_name: str = None, worker_name: str = None,
|
|
37
|
+
analyse_flag: bool = True, async_mode: bool = False):
|
|
36
38
|
"""
|
|
37
39
|
For each step in dynamic graph mode, call this method for online analyse.
|
|
38
40
|
|
|
41
|
+
Args:
|
|
42
|
+
dir_name (str, optional): Specifies the directory path to save the analysis results. The default is ``None``.
|
|
43
|
+
The default save path is ``"./data"``.
|
|
44
|
+
worker_name (str, optional): Specifies the system version name. The default is ``None``. The default project
|
|
45
|
+
thread name is ``"Name of the current operating system + process ID"``.
|
|
46
|
+
analyse_flag (bool, optional): Whether to enable online analysis. The default value is ``True``.
|
|
47
|
+
Indicates online analysis.
|
|
48
|
+
async_mode (bool, optional): Whether to use asynchronous parsing mode. The default value is ``False``. Indicates
|
|
49
|
+
the use of synchronous parsing mode.
|
|
50
|
+
|
|
39
51
|
Examples:
|
|
40
52
|
>>> import numpy as np
|
|
41
|
-
>>> import mindspore
|
|
53
|
+
>>> import mindspore
|
|
42
54
|
>>> import mindspore.dataset as ds
|
|
43
|
-
>>> from mindspore import context, nn
|
|
44
|
-
>>> from mindspore.profiler import
|
|
55
|
+
>>> from mindspore import context, nn
|
|
56
|
+
>>> from mindspore.profiler import ProfilerLevel, AicoreMetrics, ExportType, ProfilerActivity
|
|
45
57
|
>>>
|
|
46
58
|
>>> class Net(nn.Cell):
|
|
47
59
|
... def __init__(self):
|
|
@@ -59,32 +71,55 @@ def tensor_board_trace_handler():
|
|
|
59
71
|
... optimizer = nn.Momentum(test_net.trainable_params(), 1, 0.9)
|
|
60
72
|
... loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True)
|
|
61
73
|
... data = ds.GeneratorDataset(generator_net(), ["data", "label"])
|
|
62
|
-
... model =
|
|
74
|
+
... model = mindspore.train.Model(test_net, loss, optimizer)
|
|
63
75
|
... model.train(1, data)
|
|
64
76
|
>>>
|
|
65
77
|
>>> if __name__ == '__main__':
|
|
66
|
-
...
|
|
78
|
+
... # If the device_target is GPU, set the device_target to "GPU"
|
|
79
|
+
... context.set_context(mode=mindspore.GRAPH_MODE)
|
|
80
|
+
... mindspore.set_device("Ascend")
|
|
67
81
|
...
|
|
82
|
+
... # Init Profiler
|
|
83
|
+
... experimental_config = mindspore.profiler._ExperimentalConfig(
|
|
84
|
+
... profiler_level=ProfilerLevel.Level0,
|
|
85
|
+
... aic_metrics=AicoreMetrics.AiCoreNone,
|
|
86
|
+
... l2_cache=False,
|
|
87
|
+
... mstx=False,
|
|
88
|
+
... data_simplification=False,
|
|
89
|
+
... export_type=[ExportType.Text])
|
|
90
|
+
... steps = 10
|
|
68
91
|
... net = Net()
|
|
69
|
-
...
|
|
92
|
+
... # Note that the Profiler should be initialized before model.train
|
|
93
|
+
... with mindspore.profiler.profile(activities=[ProfilerActivity.CPU, ProfilerActivity.NPU],
|
|
94
|
+
... schedule=mindspore.profiler.schedule(wait=1, warmup=1, active=2,
|
|
95
|
+
... repeat=1, skip_first=2),
|
|
96
|
+
... on_trace_ready=mindspore.profiler.tensorboard_trace_handler("./data"),
|
|
97
|
+
... profile_memory=False,
|
|
98
|
+
... experimental_config=experimental_config) as prof:
|
|
70
99
|
...
|
|
71
|
-
...
|
|
72
|
-
...
|
|
73
|
-
... for i in range(STEP_NUM):
|
|
100
|
+
... # Train Model
|
|
101
|
+
... for step in range(steps):
|
|
74
102
|
... train(net)
|
|
75
103
|
... prof.step()
|
|
76
104
|
"""
|
|
105
|
+
ProfilerPathManager().init(worker_name, dir_name)
|
|
106
|
+
if not isinstance(analyse_flag, bool):
|
|
107
|
+
logger.warning("analyse_flag is not bool, set by default.")
|
|
108
|
+
analyse_flag = True
|
|
109
|
+
if not isinstance(async_mode, bool):
|
|
110
|
+
logger.warning("async_mode is not bool, set by default.")
|
|
111
|
+
async_mode = False
|
|
77
112
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
logger.error("Call tensorboard_trace_handler failed. Exception: %s", str(e))
|
|
113
|
+
def handler_fn() -> None:
|
|
114
|
+
if analyse_flag:
|
|
115
|
+
NPUProfilerAnalysis.online_analyse(async_mode=async_mode)
|
|
116
|
+
|
|
117
|
+
return handler_fn
|
|
84
118
|
|
|
85
119
|
|
|
86
120
|
class Profiler:
|
|
87
121
|
r"""
|
|
122
|
+
The current interface is deprecated, please use: :class:`mindspore.profiler.profile` instead.
|
|
88
123
|
This class to enable the profiling of MindSpore neural networks.
|
|
89
124
|
MindSpore users can import the mindspore.Profiler, initialize the Profiler object to start profiling,
|
|
90
125
|
and use Profiler.analyse() to stop profiling and analyse the results.
|
|
@@ -100,6 +135,8 @@ class Profiler:
|
|
|
100
135
|
profiler_level (ProfilerLevel, optional): (Ascend only) The level of profiling.
|
|
101
136
|
Default: ``ProfilerLevel.Level0``.
|
|
102
137
|
|
|
138
|
+
- ProfilerLevel.LevelNone: This setting takes effect only when mstx is enabled, indicating that no operator
|
|
139
|
+
data is collected on the device side.
|
|
103
140
|
- ProfilerLevel.Level0: Leanest level of profiling data collection, collects information about the elapsed
|
|
104
141
|
time of the computational operators on the NPU and communication large operator information.
|
|
105
142
|
- ProfilerLevel.Level1: Collect more CANN layer AscendCL data and AICore performance metrics and
|
|
@@ -112,18 +149,23 @@ class Profiler:
|
|
|
112
149
|
- ProfilerActivity.NPU: Collect CANN software stack and NPU data.
|
|
113
150
|
- ProfilerActivity.GPU: Collect GPU data.
|
|
114
151
|
schedule (schedule, optional): Sets the action strategy for the capture, defined by the schedule class,
|
|
115
|
-
to be used with the step interface. Default: ``None``.
|
|
152
|
+
to be used with the step interface. Default: ``None``. Performance data of all steps is collected.
|
|
153
|
+
For details, see :class:`mindspore.profiler.schedule` .
|
|
116
154
|
on_trace_ready (Callable, optional): Sets the callback function to be executed when the performance data
|
|
117
|
-
is collected. Default: ``None``.
|
|
155
|
+
is collected. Default: ``None``. It indicates that only performance data is collected, but not resolved.
|
|
156
|
+
For details, see :func:`mindspore.profiler.tensorboard_trace_handler` .
|
|
118
157
|
profile_memory (bool, optional): (Ascend only) Whether to collect tensor memory data, collect when ``True`` .
|
|
119
158
|
When using this parameter, `activities` must set to ``[ProfilerActivity.CPU, ProfilerActivity.NPU]``.
|
|
120
159
|
Collecting operator memory data when the graph compilation level is O2 requires collecting from the
|
|
121
160
|
first step. Default: ``False`` . The operator name currently collected by this parameter is incomplete.
|
|
122
161
|
This issue will be resolved in later versions. It is recommended to use the environment variable
|
|
123
162
|
``MS_ALLOC_CONF`` instead.
|
|
124
|
-
|
|
163
|
+
aic_metrics (AicoreMetrics, optional): (Ascend only) Types of AICORE performance data collected,
|
|
125
164
|
when using this parameter, `activities` must include ``ProfilerActivity.NPU`` , and the value
|
|
126
|
-
must be a member of AicoreMetrics.
|
|
165
|
+
must be a member of AicoreMetrics. When `profiler_level` is ``ProfilerLevel.Level0``, the default value is
|
|
166
|
+
``AicoreMetrics.AiCoreNone``; when `profiler_level` is ``ProfilerLevel.Level1`` or ``ProfilerLevel.Level2``,
|
|
167
|
+
the default value is ``AicoreMetrics.PipeUtilization``.
|
|
168
|
+
|
|
127
169
|
The data items contained in each metric are as follows:
|
|
128
170
|
|
|
129
171
|
- AicoreMetrics.AiCoreNone: Does not collect AICORE data.
|
|
@@ -140,15 +182,18 @@ class Profiler:
|
|
|
140
182
|
ub\_/write_bw_scalar etc.
|
|
141
183
|
- AicoreMetrics.L2Cache: L2Cache contains write_cache_hit, write_cache_miss_allocate, r0_read_cache_hit,
|
|
142
184
|
r1_read_cache_hit etc. This function only support Atlas A2 training series products.
|
|
143
|
-
|
|
185
|
+
- AicoreMetrics.MemoryAccess: Statistics on storage access bandwidth and storage capacity of main
|
|
186
|
+
storage and l2 cache etc.
|
|
187
|
+
with_stack (bool, optional): (Ascend only) Whether to collect frame host call stack data
|
|
188
|
+
on the Python side. This
|
|
144
189
|
data is presented in the form of a flame graph in the timeline. When using this parameter, `activities` must
|
|
145
190
|
include ``ProfilerActivity.CPU``. Default value: ``False`` .
|
|
146
191
|
data_simplification (bool, optional): (Ascend only) Whether to remove FRAMEWORK data and other redundant data.
|
|
147
|
-
If set to True, only the
|
|
148
|
-
|
|
149
|
-
Default value: ``True`` .
|
|
192
|
+
If set to True, only the profiler deliverables and raw performance data under the PROF_XXX directory are
|
|
193
|
+
kept to save space. Default value: ``True`` .
|
|
150
194
|
l2_cache (bool, optional): (Ascend only) Whether to collect l2 cache data, collect when True.
|
|
151
|
-
Default: ``False`` .
|
|
195
|
+
Default: ``False`` . The l2_cache.csv file is generated in the ASCEND_PROFILER_OUTPUT folder.In O2 mode,
|
|
196
|
+
only wait and skip_first parameters in schedule configuration can be set to 0.
|
|
152
197
|
hbm_ddr (bool, optional): (Ascend only) Whether to collect On-Chip Memory/DDR read and write rate data,
|
|
153
198
|
collect when True. Default: ``False`` .
|
|
154
199
|
pcie (bool, optional): (Ascend only) Whether to collect PCIe bandwidth data, collect when True.
|
|
@@ -206,7 +251,7 @@ class Profiler:
|
|
|
206
251
|
... # Note that the Profiler should be initialized before model.train
|
|
207
252
|
... profiler = Profiler(profiler_level=ProfilerLevel.Level0,
|
|
208
253
|
... activities=[ProfilerActivity.CPU, ProfilerActivity.NPU],
|
|
209
|
-
...
|
|
254
|
+
... aic_metrics=AicoreMetrics.AiCoreNone)
|
|
210
255
|
...
|
|
211
256
|
... # Train Model
|
|
212
257
|
... net = Net()
|
|
@@ -325,7 +370,7 @@ class Profiler:
|
|
|
325
370
|
self.action_controller.transit_action(self.current_action, None)
|
|
326
371
|
else:
|
|
327
372
|
ProfilerInterface.stop()
|
|
328
|
-
|
|
373
|
+
ProfilerMetaData.dump_metadata()
|
|
329
374
|
|
|
330
375
|
def analyse(self, offline_path=None, pretty=False, step_list=None, mode="sync") -> None:
|
|
331
376
|
"""
|
|
@@ -395,7 +440,7 @@ class Profiler:
|
|
|
395
440
|
Analyze training performance data offline, which is invoked after performance data collection is completed.
|
|
396
441
|
|
|
397
442
|
Args:
|
|
398
|
-
path (str): The profiling data path which
|
|
443
|
+
path (str): The profiling data path which needs to be analyzed offline.
|
|
399
444
|
There needs to be a profiler directory in this path.
|
|
400
445
|
pretty (bool, optional): Whether to pretty json files. Default: ``False``.
|
|
401
446
|
step_list (list, optional): A list of steps that need to be analyzed, the steps must be
|
|
@@ -431,7 +476,7 @@ class Profiler:
|
|
|
431
476
|
for future in as_completed(futures):
|
|
432
477
|
try:
|
|
433
478
|
future.result()
|
|
434
|
-
except Exception as e:
|
|
479
|
+
except Exception as e: # pylint: disable=W0703
|
|
435
480
|
logger.error("offline analysis failed: %s", str(e))
|
|
436
481
|
|
|
437
482
|
def step(self) -> None:
|
|
@@ -447,7 +492,8 @@ class Profiler:
|
|
|
447
492
|
>>> import mindspore as ms
|
|
448
493
|
>>> import mindspore.dataset as ds
|
|
449
494
|
>>> from mindspore import context, nn, Profiler
|
|
450
|
-
>>> from mindspore.profiler import schedule,
|
|
495
|
+
>>> from mindspore.profiler import schedule, tensorboard_trace_handler, ProfilerLevel, AicoreMetrics,
|
|
496
|
+
>>> ExportType, ProfilerActivity
|
|
451
497
|
>>>
|
|
452
498
|
>>> class Net(nn.Cell):
|
|
453
499
|
... def __init__(self):
|
|
@@ -475,8 +521,8 @@ class Profiler:
|
|
|
475
521
|
... STEP_NUM = 15
|
|
476
522
|
...
|
|
477
523
|
... with Profiler(schedule=schedule(wait=1, warmup=1, active=2, repeat=1, skip_first=2),
|
|
478
|
-
... on_trace_ready=
|
|
479
|
-
... for
|
|
524
|
+
... on_trace_ready=tensorboard_trace_handler) as prof:
|
|
525
|
+
... for _ in range(STEP_NUM):
|
|
480
526
|
... train(net)
|
|
481
527
|
... prof.step()
|
|
482
528
|
"""
|
|
@@ -511,7 +557,7 @@ class Profiler:
|
|
|
511
557
|
>>> # Call Profiler add_metadata
|
|
512
558
|
>>> profiler.add_metadata("test_key", "test_value")
|
|
513
559
|
>>> # Profiler end
|
|
514
|
-
>>> profiler.
|
|
560
|
+
>>> profiler.stop()
|
|
515
561
|
"""
|
|
516
562
|
if not isinstance(key, str) or not isinstance(value, str):
|
|
517
563
|
logger.warning("The key and value of metadata must be string. Skip this metadata.")
|
|
@@ -522,6 +568,7 @@ class Profiler:
|
|
|
522
568
|
if key in self._metadata:
|
|
523
569
|
logger.warning(f"{key} is already saved as metadata, override it.")
|
|
524
570
|
self._metadata[key] = value
|
|
571
|
+
ProfilerMetaData.set_metadata(self._metadata)
|
|
525
572
|
else:
|
|
526
573
|
logger.warning("Too many metadata added. Skip this metadata")
|
|
527
574
|
|
|
@@ -541,7 +588,7 @@ class Profiler:
|
|
|
541
588
|
>>> # Call Profiler add_metadata_json
|
|
542
589
|
>>> profiler.add_metadata_json("test_key", json.dumps({"key1": 1, "key2": 2}))
|
|
543
590
|
>>> # Profiler end, metadata will be saved in profiler_metadata.json
|
|
544
|
-
>>> profiler.
|
|
591
|
+
>>> profiler.stop()
|
|
545
592
|
"""
|
|
546
593
|
if not isinstance(key, str) or not isinstance(value, str):
|
|
547
594
|
logger.warning("The key and value of metadata must be string. Skip this metadata.")
|
|
@@ -553,6 +600,7 @@ class Profiler:
|
|
|
553
600
|
if key in self._metadata:
|
|
554
601
|
logger.warning(f"{key} is already saved as metadata, override it.")
|
|
555
602
|
self._metadata[key] = json.loads(value)
|
|
603
|
+
ProfilerMetaData.set_metadata(self._metadata)
|
|
556
604
|
except ValueError:
|
|
557
605
|
logger.warning("The metadata value must be json format string. Skip this metadata")
|
|
558
606
|
else:
|
|
@@ -617,14 +665,6 @@ class Profiler:
|
|
|
617
665
|
op_info = parser.parse()
|
|
618
666
|
return op_info
|
|
619
667
|
|
|
620
|
-
def _dump_metadata(self):
|
|
621
|
-
"""Dump metadata to file."""
|
|
622
|
-
if not self._metadata:
|
|
623
|
-
return
|
|
624
|
-
save_path = os.path.join(self._prof_context.ascend_ms_dir, "profiler_metadata.json")
|
|
625
|
-
FileManager.create_json_file(save_path, self._metadata, indent=4)
|
|
626
|
-
self._metadata.clear()
|
|
627
|
-
|
|
628
668
|
def __enter__(self) -> 'Profiler':
|
|
629
669
|
if not self._has_started:
|
|
630
670
|
self.start()
|
|
@@ -638,3 +678,459 @@ class Profiler:
|
|
|
638
678
|
if self._has_started:
|
|
639
679
|
self.stop()
|
|
640
680
|
logger.warning("Profiler is stopped at the end of the program.")
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
class Profile:
|
|
684
|
+
r"""
|
|
685
|
+
This class to enable the profiling of MindSpore neural networks.
|
|
686
|
+
MindSpore users can import the mindspore.profiler.profile, initialize the profile object to start profiling,
|
|
687
|
+
Use profile.start() to start the analysis, and use profile.stop() to stop collecting and analyzing the results.
|
|
688
|
+
Users can visualize the results using the `MindStudio Insight
|
|
689
|
+
<https://www.hiascend.com/developer/download/community/result?module=pt+sto+cann>`_ tool.
|
|
690
|
+
Now, profile supports AICORE operator, AICPU operator, HostCPU operator, memory,
|
|
691
|
+
correspondence, cluster, etc data analysis.
|
|
692
|
+
|
|
693
|
+
Args:
|
|
694
|
+
start_profile (bool, optional): The start_profile parameter controls whether to enable or disable performance
|
|
695
|
+
data collection based on conditions. Default: ``True`` .
|
|
696
|
+
activities (list, optional): The activities to collect.
|
|
697
|
+
Default: ``[ProfilerActivity.CPU, ProfilerActivity.NPU]``.
|
|
698
|
+
|
|
699
|
+
- ProfilerActivity.CPU: Collect MindSpore framework data.
|
|
700
|
+
- ProfilerActivity.NPU: Collect CANN software stack and NPU data.
|
|
701
|
+
- 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
|
+
with_stack (bool, optional): (Ascend only) Whether to collect frame host call stack data
|
|
715
|
+
on the Python side. This
|
|
716
|
+
data is presented in the form of a flame graph in the timeline. When using this parameter, `activities` must
|
|
717
|
+
include ``ProfilerActivity.CPU``. Default value: ``False`` .
|
|
718
|
+
hbm_ddr (bool, optional): (Ascend only) Whether to collect On-Chip Memory/DDR read and write rate data,
|
|
719
|
+
collect when True. Default: ``False`` .
|
|
720
|
+
pcie (bool, optional): (Ascend only) Whether to collect PCIe bandwidth data, collect when True.
|
|
721
|
+
Default: ``False`` .
|
|
722
|
+
data_process (bool, optional): (Ascend/GPU) Whether to collect data to prepare performance data.
|
|
723
|
+
Default value: ``False`` .
|
|
724
|
+
parallel_strategy (bool, optional): (Ascend only) Whether to collect parallel policy performance data.
|
|
725
|
+
Default value: ``False`` .
|
|
726
|
+
sync_enable (bool, optional): (GPU only) Whether the profiler collects operators in a synchronous way.
|
|
727
|
+
Default: ``True`` .
|
|
728
|
+
|
|
729
|
+
- True: The synchronous way. Before sending the operator to the GPU, the CPU records the start timestamp.
|
|
730
|
+
Then the operator is returned to the CPU after execution, and the end timestamp is recorded,
|
|
731
|
+
The duration of the operator is the difference between the two timestamps.
|
|
732
|
+
- False: The asynchronous way. The duration of the operator is that of sending from the CPU to the GPU.
|
|
733
|
+
This method can reduce the impact of adding profiler on overall training time.
|
|
734
|
+
experimental_config (_ExperimentalConfig, optional): expandable parameters can be configured in this
|
|
735
|
+
configuration item. For details, see :class:`mindspore.profiler._ExperimentalConfig` .
|
|
736
|
+
Raises:
|
|
737
|
+
RuntimeError: When the version of CANN does not match the version of MindSpore,
|
|
738
|
+
MindSpore cannot parse the generated ascend_job_id directory structure.
|
|
739
|
+
|
|
740
|
+
Supported Platforms:
|
|
741
|
+
``Ascend`` ``GPU``
|
|
742
|
+
|
|
743
|
+
Examples:
|
|
744
|
+
>>> import numpy as np
|
|
745
|
+
>>> import mindspore
|
|
746
|
+
>>> from mindspore import nn, context
|
|
747
|
+
>>> import mindspore.dataset as ds
|
|
748
|
+
>>> from mindspore.profiler import ProfilerLevel, ProfilerActivity, AicoreMetrics, ExportType
|
|
749
|
+
>>>
|
|
750
|
+
>>> class Net(nn.Cell):
|
|
751
|
+
... def __init__(self):
|
|
752
|
+
... super(Net, self).__init__()
|
|
753
|
+
... self.fc = nn.Dense(2,2)
|
|
754
|
+
... def construct(self, x):
|
|
755
|
+
... return self.fc(x)
|
|
756
|
+
>>>
|
|
757
|
+
>>> def generator():
|
|
758
|
+
... for i in range(2):
|
|
759
|
+
... yield np.ones([2, 2]).astype(np.float32), np.ones([2]).astype(np.int32)
|
|
760
|
+
>>>
|
|
761
|
+
>>> def train(net):
|
|
762
|
+
... optimizer = nn.Momentum(net.trainable_params(), 1, 0.9)
|
|
763
|
+
... loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True)
|
|
764
|
+
... data = ds.GeneratorDataset(generator, ["data", "label"])
|
|
765
|
+
... model = mindspore.train.Model(net, loss, optimizer)
|
|
766
|
+
... model.train(1, data)
|
|
767
|
+
>>>
|
|
768
|
+
>>> if __name__ == '__main__':
|
|
769
|
+
... # If the device_target is GPU, set the device_target to "GPU"
|
|
770
|
+
... context.set_context(mode=mindspore.GRAPH_MODE)
|
|
771
|
+
... mindspore.set_device("Ascend")
|
|
772
|
+
...
|
|
773
|
+
... # Init Profiler
|
|
774
|
+
... experimental_config = mindspore.profiler._ExperimentalConfig(
|
|
775
|
+
... profiler_level=ProfilerLevel.Level0,
|
|
776
|
+
... aic_metrics=AicoreMetrics.AiCoreNone,
|
|
777
|
+
... l2_cache=False,
|
|
778
|
+
... mstx=False,
|
|
779
|
+
... data_simplification=False,
|
|
780
|
+
... export_type=[ExportType.Text])
|
|
781
|
+
... steps = 10
|
|
782
|
+
... net = Net()
|
|
783
|
+
... # Note that the Profiler should be initialized before model.train
|
|
784
|
+
... with mindspore.profiler.profile(activities=[ProfilerActivity.CPU, ProfilerActivity.NPU],
|
|
785
|
+
... schedule=mindspore.profiler.schedule(wait=1, warmup=1, active=2,
|
|
786
|
+
... repeat=1, skip_first=2),
|
|
787
|
+
... on_trace_ready=mindspore.profiler.
|
|
788
|
+
... tensorboard_trace_handler("./data"),
|
|
789
|
+
... profile_memory=False,
|
|
790
|
+
... experimental_config=experimental_config) as prof:
|
|
791
|
+
...
|
|
792
|
+
... # Train Model
|
|
793
|
+
... for step in range(steps):
|
|
794
|
+
... train(net)
|
|
795
|
+
... prof.step()
|
|
796
|
+
"""
|
|
797
|
+
|
|
798
|
+
def __init__(
|
|
799
|
+
self,
|
|
800
|
+
activities: list = None,
|
|
801
|
+
with_stack: bool = False,
|
|
802
|
+
profile_memory: bool = False,
|
|
803
|
+
data_process: bool = False,
|
|
804
|
+
parallel_strategy: bool = False,
|
|
805
|
+
start_profile: bool = True,
|
|
806
|
+
hbm_ddr: bool = False,
|
|
807
|
+
pcie: bool = False,
|
|
808
|
+
sync_enable: bool = True,
|
|
809
|
+
schedule: Schedule = None,
|
|
810
|
+
on_trace_ready: Optional[Callable[..., Any]] = None,
|
|
811
|
+
experimental_config: Optional[_ExperimentalConfig] = None,
|
|
812
|
+
):
|
|
813
|
+
self._activities = activities
|
|
814
|
+
self._with_stack = with_stack
|
|
815
|
+
self._profile_memory = profile_memory
|
|
816
|
+
self._data_process = data_process
|
|
817
|
+
self._parallel_strategy = parallel_strategy
|
|
818
|
+
self._start_profile = start_profile
|
|
819
|
+
self._hbm_ddr = hbm_ddr
|
|
820
|
+
self._pcie = pcie
|
|
821
|
+
self._sync_enable = sync_enable
|
|
822
|
+
self._schedule = schedule
|
|
823
|
+
self._on_trace_ready = on_trace_ready
|
|
824
|
+
self._experimental_config = experimental_config or _ExperimentalConfig()
|
|
825
|
+
self._profiler = Profiler(
|
|
826
|
+
profiler_level=self._experimental_config.profiler_level,
|
|
827
|
+
activities=self._activities,
|
|
828
|
+
aic_metrics=self._experimental_config.aic_metrics,
|
|
829
|
+
with_stack=self._with_stack,
|
|
830
|
+
profile_memory=self._profile_memory,
|
|
831
|
+
data_process=self._data_process,
|
|
832
|
+
parallel_strategy=self._parallel_strategy,
|
|
833
|
+
start_profile=self._start_profile,
|
|
834
|
+
l2_cache=self._experimental_config.l2_cache,
|
|
835
|
+
hbm_ddr=self._hbm_ddr,
|
|
836
|
+
pcie=self._pcie,
|
|
837
|
+
sync_enable=self._sync_enable,
|
|
838
|
+
data_simplification=self._experimental_config.data_simplification,
|
|
839
|
+
mstx=self._experimental_config.mstx,
|
|
840
|
+
export_type=self._experimental_config.export_type,
|
|
841
|
+
schedule=self._schedule,
|
|
842
|
+
on_trace_ready=self._on_trace_ready,
|
|
843
|
+
)
|
|
844
|
+
|
|
845
|
+
def __enter__(self) -> 'Profile':
|
|
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__()
|
|
854
|
+
|
|
855
|
+
def start(self) -> None:
|
|
856
|
+
"""
|
|
857
|
+
Turn on profile data collection. profile can be turned on by condition.
|
|
858
|
+
|
|
859
|
+
Raises:
|
|
860
|
+
RuntimeError: If the profile has already started.
|
|
861
|
+
RuntimeError: If the `start_profile` parameter is not set or is set to ``True``.
|
|
862
|
+
|
|
863
|
+
Examples:
|
|
864
|
+
>>> import numpy as np
|
|
865
|
+
>>> import mindspore
|
|
866
|
+
>>> from mindspore import nn, context
|
|
867
|
+
>>> import mindspore.dataset as ds
|
|
868
|
+
>>> from mindspore.profiler import ProfilerLevel, ProfilerActivity, AicoreMetrics, ExportType
|
|
869
|
+
>>>
|
|
870
|
+
>>> class Net(nn.Cell):
|
|
871
|
+
... def __init__(self):
|
|
872
|
+
... super(Net, self).__init__()
|
|
873
|
+
... self.fc = nn.Dense(2,2)
|
|
874
|
+
... def construct(self, x):
|
|
875
|
+
... return self.fc(x)
|
|
876
|
+
>>>
|
|
877
|
+
>>> def generator():
|
|
878
|
+
... for i in range(2):
|
|
879
|
+
... yield np.ones([2, 2]).astype(np.float32), np.ones([2]).astype(np.int32)
|
|
880
|
+
>>>
|
|
881
|
+
>>> def train(net):
|
|
882
|
+
... optimizer = nn.Momentum(net.trainable_params(), 1, 0.9)
|
|
883
|
+
... loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True)
|
|
884
|
+
... data = ds.GeneratorDataset(generator, ["data", "label"])
|
|
885
|
+
... model = mindspore.train.Model(net, loss, optimizer)
|
|
886
|
+
... model.train(1, data)
|
|
887
|
+
>>>
|
|
888
|
+
>>> if __name__ == '__main__':
|
|
889
|
+
... # If the device_target is GPU, set the device_target to "GPU"
|
|
890
|
+
... context.set_context(mode=mindspore.GRAPH_MODE)
|
|
891
|
+
... mindspore.set_device("Ascend")
|
|
892
|
+
...
|
|
893
|
+
... # Init Profiler
|
|
894
|
+
... experimental_config = mindspore.profiler._ExperimentalConfig(
|
|
895
|
+
... profiler_level=ProfilerLevel.Level0,
|
|
896
|
+
... aic_metrics=AicoreMetrics.AiCoreNone,
|
|
897
|
+
... l2_cache=False,
|
|
898
|
+
... mstx=False,
|
|
899
|
+
... data_simplification=False,
|
|
900
|
+
... export_type=[ExportType.Text])
|
|
901
|
+
... steps = 10
|
|
902
|
+
... net = Net()
|
|
903
|
+
... # Note that the Profiler should be initialized before model.train
|
|
904
|
+
... prof = mindspore.profiler.profile(activities=[ProfilerActivity.CPU, ProfilerActivity.NPU],
|
|
905
|
+
... schedule=mindspore.profiler.schedule(wait=1, warmup=1, active=2,
|
|
906
|
+
... repeat=1, skip_first=2),
|
|
907
|
+
... on_trace_ready=mindspore.profiler.
|
|
908
|
+
... tensorboard_trace_handler("./data"),
|
|
909
|
+
... profile_memory=False,
|
|
910
|
+
... experimental_config=experimental_config)
|
|
911
|
+
... prof.start()
|
|
912
|
+
... # Train Model
|
|
913
|
+
... for step in range(steps):
|
|
914
|
+
... train(net)
|
|
915
|
+
... prof.step()
|
|
916
|
+
... prof.stop()
|
|
917
|
+
"""
|
|
918
|
+
self._profiler.start()
|
|
919
|
+
|
|
920
|
+
def stop(self) -> None:
|
|
921
|
+
"""
|
|
922
|
+
Turn off profile data collection. profile can be turned off by condition.
|
|
923
|
+
|
|
924
|
+
Raises:
|
|
925
|
+
RuntimeError: If the profile has not started, this function is disabled.
|
|
926
|
+
|
|
927
|
+
Examples:
|
|
928
|
+
>>> import numpy as np
|
|
929
|
+
>>> import mindspore
|
|
930
|
+
>>> from mindspore import nn, context
|
|
931
|
+
>>> import mindspore.dataset as ds
|
|
932
|
+
>>> from mindspore.profiler import ProfilerLevel, ProfilerActivity, AicoreMetrics, ExportType
|
|
933
|
+
>>>
|
|
934
|
+
>>> class Net(nn.Cell):
|
|
935
|
+
... def __init__(self):
|
|
936
|
+
... super(Net, self).__init__()
|
|
937
|
+
... self.fc = nn.Dense(2,2)
|
|
938
|
+
... def construct(self, x):
|
|
939
|
+
... return self.fc(x)
|
|
940
|
+
>>>
|
|
941
|
+
>>> def generator():
|
|
942
|
+
... for i in range(2):
|
|
943
|
+
... yield np.ones([2, 2]).astype(np.float32), np.ones([2]).astype(np.int32)
|
|
944
|
+
>>>
|
|
945
|
+
>>> def train(net):
|
|
946
|
+
... optimizer = nn.Momentum(net.trainable_params(), 1, 0.9)
|
|
947
|
+
... loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True)
|
|
948
|
+
... data = ds.GeneratorDataset(generator, ["data", "label"])
|
|
949
|
+
... model = mindspore.train.Model(net, loss, optimizer)
|
|
950
|
+
... model.train(1, data)
|
|
951
|
+
>>>
|
|
952
|
+
>>> if __name__ == '__main__':
|
|
953
|
+
... # If the device_target is GPU, set the device_target to "GPU"
|
|
954
|
+
... context.set_context(mode=mindspore.GRAPH_MODE)
|
|
955
|
+
... mindspore.set_device("Ascend")
|
|
956
|
+
...
|
|
957
|
+
... # Init Profiler
|
|
958
|
+
... experimental_config = mindspore.profiler._ExperimentalConfig(
|
|
959
|
+
... profiler_level=ProfilerLevel.Level0,
|
|
960
|
+
... aic_metrics=AicoreMetrics.AiCoreNone,
|
|
961
|
+
... l2_cache=False,
|
|
962
|
+
... mstx=False,
|
|
963
|
+
... data_simplification=False,
|
|
964
|
+
... export_type=[ExportType.Text])
|
|
965
|
+
... steps = 10
|
|
966
|
+
... net = Net()
|
|
967
|
+
... # Note that the Profiler should be initialized before model.train
|
|
968
|
+
... prof = mindspore.profiler.profile(activities=[ProfilerActivity.CPU, ProfilerActivity.NPU],
|
|
969
|
+
... schedule=mindspore.profiler.schedule(wait=1, warmup=1, active=2,
|
|
970
|
+
... repeat=1, skip_first=2),
|
|
971
|
+
... on_trace_ready=mindspore.profiler.
|
|
972
|
+
... tensorboard_trace_handler("./data"),
|
|
973
|
+
... profile_memory=False,
|
|
974
|
+
... experimental_config=experimental_config)
|
|
975
|
+
... prof.start()
|
|
976
|
+
... # Train Model
|
|
977
|
+
... for step in range(steps):
|
|
978
|
+
... train(net)
|
|
979
|
+
... prof.step()
|
|
980
|
+
... prof.stop()
|
|
981
|
+
"""
|
|
982
|
+
self._profiler.stop()
|
|
983
|
+
|
|
984
|
+
def step(self) -> None:
|
|
985
|
+
"""
|
|
986
|
+
Used for Ascend, distinguish step collection and parsing performance data through schedule and on_trace_ready.
|
|
987
|
+
|
|
988
|
+
Raises:
|
|
989
|
+
RuntimeError: If the `start_profile` parameter is not set or the Profiler is not started.
|
|
990
|
+
RuntimeError: If the `schedule` parameter is not set.
|
|
991
|
+
|
|
992
|
+
Examples:
|
|
993
|
+
>>> import numpy as np
|
|
994
|
+
>>> import mindspore
|
|
995
|
+
>>> from mindspore import nn, context
|
|
996
|
+
>>> import mindspore.dataset as ds
|
|
997
|
+
>>> from mindspore.profiler import ProfilerLevel, ProfilerActivity, AicoreMetrics, ExportType
|
|
998
|
+
>>>
|
|
999
|
+
>>> class Net(nn.Cell):
|
|
1000
|
+
... def __init__(self):
|
|
1001
|
+
... super(Net, self).__init__()
|
|
1002
|
+
... self.fc = nn.Dense(2,2)
|
|
1003
|
+
... def construct(self, x):
|
|
1004
|
+
... return self.fc(x)
|
|
1005
|
+
>>>
|
|
1006
|
+
>>> def generator():
|
|
1007
|
+
... for i in range(2):
|
|
1008
|
+
... yield np.ones([2, 2]).astype(np.float32), np.ones([2]).astype(np.int32)
|
|
1009
|
+
>>>
|
|
1010
|
+
>>> def train(net):
|
|
1011
|
+
... optimizer = nn.Momentum(net.trainable_params(), 1, 0.9)
|
|
1012
|
+
... loss = nn.SoftmaxCrossEntropyWithLogits(sparse=True)
|
|
1013
|
+
... data = ds.GeneratorDataset(generator, ["data", "label"])
|
|
1014
|
+
... model = mindspore.train.Model(net, loss, optimizer)
|
|
1015
|
+
... model.train(1, data)
|
|
1016
|
+
>>>
|
|
1017
|
+
>>> if __name__ == '__main__':
|
|
1018
|
+
... # If the device_target is GPU, set the device_target to "GPU"
|
|
1019
|
+
... context.set_context(mode=mindspore.GRAPH_MODE)
|
|
1020
|
+
... mindspore.set_device("Ascend")
|
|
1021
|
+
...
|
|
1022
|
+
... # Init Profiler
|
|
1023
|
+
... experimental_config = mindspore.profiler._ExperimentalConfig(
|
|
1024
|
+
... profiler_level=ProfilerLevel.Level0,
|
|
1025
|
+
... aic_metrics=AicoreMetrics.AiCoreNone,
|
|
1026
|
+
... l2_cache=False,
|
|
1027
|
+
... mstx=False,
|
|
1028
|
+
... data_simplification=False,
|
|
1029
|
+
... export_type=[ExportType.Text])
|
|
1030
|
+
... steps = 10
|
|
1031
|
+
... net = Net()
|
|
1032
|
+
... # Note that the Profiler should be initialized before model.train
|
|
1033
|
+
... with mindspore.profiler.profile(activities=[ProfilerActivity.CPU, ProfilerActivity.NPU],
|
|
1034
|
+
... schedule=mindspore.profiler.schedule(wait=1, warmup=1, active=2,
|
|
1035
|
+
... repeat=1, skip_first=2),
|
|
1036
|
+
... on_trace_ready=mindspore.profiler.tensorboard_trace_handler("./data"),
|
|
1037
|
+
... profile_memory=False,
|
|
1038
|
+
... experimental_config=experimental_config) as prof:
|
|
1039
|
+
...
|
|
1040
|
+
... # Train Model
|
|
1041
|
+
... for step in range(steps):
|
|
1042
|
+
... train(net)
|
|
1043
|
+
... prof.step()
|
|
1044
|
+
"""
|
|
1045
|
+
self._profiler.step()
|
|
1046
|
+
|
|
1047
|
+
def add_metadata(self, key: str, value: str):
|
|
1048
|
+
"""
|
|
1049
|
+
Report custom metadata key-value pair data.
|
|
1050
|
+
|
|
1051
|
+
Args:
|
|
1052
|
+
key (str): The key to the metadata.
|
|
1053
|
+
value (str): The value to the metadata.
|
|
1054
|
+
|
|
1055
|
+
Examples:
|
|
1056
|
+
>>> import mindspore
|
|
1057
|
+
>>> # Profiler init.
|
|
1058
|
+
>>> with mindspore.profiler.profile() as prof:
|
|
1059
|
+
... # Call Profiler add_metadata
|
|
1060
|
+
... prof.add_metadata("test_key", "test_value")
|
|
1061
|
+
"""
|
|
1062
|
+
|
|
1063
|
+
self._profiler.add_metadata(key, value)
|
|
1064
|
+
|
|
1065
|
+
def add_metadata_json(self, key: str, value: str):
|
|
1066
|
+
"""
|
|
1067
|
+
Report custom metadata key-value pair data with the value as a JSON string data.
|
|
1068
|
+
|
|
1069
|
+
Args:
|
|
1070
|
+
key (str): The key to the metadata.
|
|
1071
|
+
value (str): The json str format value to the metadata.
|
|
1072
|
+
|
|
1073
|
+
Examples:
|
|
1074
|
+
>>> import json
|
|
1075
|
+
>>> import mindspore
|
|
1076
|
+
>>> # Profiler init.
|
|
1077
|
+
>>> with mindspore.profiler.profile() as prof:
|
|
1078
|
+
... # Call Profiler add_metadata_json
|
|
1079
|
+
... prof.add_metadata_json("test_key", json.dumps({"key1": 1, "key2": 2}))
|
|
1080
|
+
"""
|
|
1081
|
+
self._profiler.add_metadata_json(key, value)
|
|
1082
|
+
|
|
1083
|
+
|
|
1084
|
+
def analyse(profiler_path: str, max_process_number: int = os.cpu_count() // 2, pretty=False, step_list=None,
|
|
1085
|
+
data_simplification=True):
|
|
1086
|
+
"""
|
|
1087
|
+
Analyze training performance data offline, which is invoked after performance data collection is completed.
|
|
1088
|
+
|
|
1089
|
+
Args:
|
|
1090
|
+
profiler_path (str): The path to profiling data that needs to be analyzed offline,
|
|
1091
|
+
specified to the upper directory ``*_ascend_ms``.
|
|
1092
|
+
max_process_number (int, optional): Maximum number of processes.
|
|
1093
|
+
The default value is ``os.cpu_count() // 2``.
|
|
1094
|
+
pretty (bool, optional): Format the JSON file. Default: ``False``,
|
|
1095
|
+
indicating that the formatting is not performed.
|
|
1096
|
+
step_list (list, optional): Only the performance data of the specified step is parsed. The specified step must
|
|
1097
|
+
be a consecutive integer. It supports CallBack collection only in GRAPH mode, and can only slice the CANN
|
|
1098
|
+
layer and the following information. Default value: ``None``, that is, full resolution.
|
|
1099
|
+
data_simplification (bool, optional): Whether to enable data simplification. Default: ``True``,
|
|
1100
|
+
indicating the data simplification is enabled.
|
|
1101
|
+
|
|
1102
|
+
Examples:
|
|
1103
|
+
>>> from mindspore.profiler.profiler import analyse
|
|
1104
|
+
>>> analyse(profiler_path="./profiling_path")
|
|
1105
|
+
"""
|
|
1106
|
+
if not isinstance(max_process_number, int) or isinstance(max_process_number, bool) or max_process_number <= 0:
|
|
1107
|
+
logger.warning(f"Parameter 'max_process_number' should be of type int, but got "
|
|
1108
|
+
f"{type(max_process_number).__name__}. reset to int {os.cpu_count() // 2}.")
|
|
1109
|
+
max_process_number = os.cpu_count() // 2
|
|
1110
|
+
|
|
1111
|
+
real_path = PathManager.get_real_path(profiler_path)
|
|
1112
|
+
PathManager.check_input_directory_path(real_path)
|
|
1113
|
+
ascend_ms_path_list = PathManager.get_ascend_ms_path_list(real_path)
|
|
1114
|
+
|
|
1115
|
+
if not ascend_ms_path_list:
|
|
1116
|
+
msg = (f"Invalid path: {real_path}. Expected a *_ascend_ms_* directory "
|
|
1117
|
+
"or a parent directory of multiple *_ascend_ms_*")
|
|
1118
|
+
logger.error(msg)
|
|
1119
|
+
return
|
|
1120
|
+
|
|
1121
|
+
with ProcessPoolExecutor(max_workers=max_process_number) as executor:
|
|
1122
|
+
futures = [
|
|
1123
|
+
executor.submit(
|
|
1124
|
+
NPUProfilerAnalysis.offline_analyse,
|
|
1125
|
+
ascend_ms_path,
|
|
1126
|
+
pretty,
|
|
1127
|
+
step_list,
|
|
1128
|
+
data_simplification
|
|
1129
|
+
) for ascend_ms_path in ascend_ms_path_list
|
|
1130
|
+
]
|
|
1131
|
+
# Wait for all tasks to complete
|
|
1132
|
+
for future in as_completed(futures):
|
|
1133
|
+
try:
|
|
1134
|
+
future.result()
|
|
1135
|
+
except Exception as e: # pylint: disable=W0703
|
|
1136
|
+
logger.error("offline analysis failed: %s", str(e))
|