mindspore 2.4.10__cp39-cp39-win_amd64.whl → 2.5.0__cp39-cp39-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.

Files changed (389) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
  3. mindspore/Newtonsoft.Json.dll +0 -0
  4. mindspore/__init__.py +8 -3
  5. mindspore/_c_dataengine.cp39-win_amd64.pyd +0 -0
  6. mindspore/_c_expression.cp39-win_amd64.pyd +0 -0
  7. mindspore/_c_mindrecord.cp39-win_amd64.pyd +0 -0
  8. mindspore/_checkparam.py +0 -5
  9. mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
  10. mindspore/_extends/parse/compile_config.py +64 -0
  11. mindspore/_extends/parse/deprecated/__init__.py +0 -0
  12. mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +375 -0
  13. mindspore/_extends/parse/parser.py +23 -5
  14. mindspore/_extends/parse/standard_method.py +123 -27
  15. mindspore/_extends/pijit/pijit_func_white_list.py +1 -1
  16. mindspore/amp.py +7 -1
  17. mindspore/atlprov.dll +0 -0
  18. mindspore/avcodec-59.dll +0 -0
  19. mindspore/avdevice-59.dll +0 -0
  20. mindspore/avfilter-8.dll +0 -0
  21. mindspore/avformat-59.dll +0 -0
  22. mindspore/avutil-57.dll +0 -0
  23. mindspore/boost/boost_cell_wrapper.py +136 -41
  24. mindspore/c1.dll +0 -0
  25. mindspore/c1xx.dll +0 -0
  26. mindspore/c2.dll +0 -0
  27. mindspore/common/__init__.py +3 -1
  28. mindspore/common/_register_for_tensor.py +0 -1
  29. mindspore/common/_stub_tensor.py +25 -4
  30. mindspore/common/_tensor_cpp_method.py +17 -0
  31. mindspore/common/_tensor_docs.py +6132 -0
  32. mindspore/common/api.py +98 -21
  33. mindspore/common/dtype.py +34 -34
  34. mindspore/common/dump.py +2 -1
  35. mindspore/common/file_system.py +8 -3
  36. mindspore/common/generator.py +2 -0
  37. mindspore/common/hook_handle.py +3 -1
  38. mindspore/common/initializer.py +3 -4
  39. mindspore/common/lazy_inline.py +8 -2
  40. mindspore/common/mindir_util.py +10 -2
  41. mindspore/common/parameter.py +31 -15
  42. mindspore/common/tensor.py +713 -1337
  43. mindspore/communication/__init__.py +1 -1
  44. mindspore/communication/_comm_helper.py +5 -0
  45. mindspore/communication/comm_func.py +215 -173
  46. mindspore/communication/management.py +23 -20
  47. mindspore/context.py +285 -191
  48. mindspore/dataset/__init__.py +23 -19
  49. mindspore/dataset/callback/ds_callback.py +2 -1
  50. mindspore/dataset/core/config.py +84 -3
  51. mindspore/dataset/engine/cache_admin.py +3 -3
  52. mindspore/dataset/engine/cache_client.py +5 -4
  53. mindspore/dataset/engine/datasets.py +192 -149
  54. mindspore/dataset/engine/datasets_audio.py +14 -0
  55. mindspore/dataset/engine/datasets_standard_format.py +11 -11
  56. mindspore/dataset/engine/datasets_text.py +38 -1
  57. mindspore/dataset/engine/datasets_user_defined.py +100 -66
  58. mindspore/dataset/engine/datasets_vision.py +81 -8
  59. mindspore/dataset/engine/iterators.py +281 -63
  60. mindspore/dataset/engine/obs/util.py +8 -0
  61. mindspore/dataset/engine/queue.py +40 -0
  62. mindspore/dataset/engine/samplers.py +26 -2
  63. mindspore/dataset/engine/serializer_deserializer.py +1 -1
  64. mindspore/dataset/engine/validators.py +43 -11
  65. mindspore/dataset/transforms/py_transforms_util.py +17 -0
  66. mindspore/dataset/transforms/transforms.py +29 -12
  67. mindspore/dataset/vision/validators.py +1 -2
  68. mindspore/device_context/__init__.py +21 -0
  69. mindspore/device_context/ascend/__init__.py +25 -0
  70. mindspore/device_context/ascend/device.py +72 -0
  71. mindspore/device_context/ascend/op_debug.py +94 -0
  72. mindspore/device_context/ascend/op_precision.py +193 -0
  73. mindspore/device_context/ascend/op_tuning.py +127 -0
  74. mindspore/device_context/cpu/__init__.py +25 -0
  75. mindspore/device_context/cpu/device.py +62 -0
  76. mindspore/device_context/cpu/op_tuning.py +43 -0
  77. mindspore/device_context/gpu/__init__.py +21 -0
  78. mindspore/device_context/gpu/device.py +70 -0
  79. mindspore/device_context/gpu/op_precision.py +67 -0
  80. mindspore/device_context/gpu/op_tuning.py +175 -0
  81. mindspore/device_manager.py +134 -0
  82. mindspore/dnnl.dll +0 -0
  83. mindspore/dpcmi.dll +0 -0
  84. mindspore/experimental/llm_boost/__init__.py +1 -0
  85. mindspore/experimental/llm_boost/ascend_native/__init__.py +22 -0
  86. mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +211 -0
  87. mindspore/experimental/llm_boost/ascend_native/llm_boost.py +52 -0
  88. mindspore/experimental/llm_boost/atb/boost_base.py +2 -3
  89. mindspore/experimental/llm_boost/atb/llama_boost.py +6 -1
  90. mindspore/experimental/llm_boost/register.py +1 -0
  91. mindspore/experimental/optim/adadelta.py +26 -22
  92. mindspore/experimental/optim/adam.py +3 -0
  93. mindspore/experimental/optim/lr_scheduler.py +33 -24
  94. mindspore/experimental/optim/radam.py +33 -30
  95. mindspore/hal/device.py +28 -0
  96. mindspore/hal/event.py +17 -0
  97. mindspore/hal/memory.py +94 -3
  98. mindspore/hal/stream.py +91 -6
  99. mindspore/include/api/context.h +0 -1
  100. mindspore/jpeg62.dll +0 -0
  101. mindspore/log.py +12 -0
  102. mindspore/mindrecord/__init__.py +1 -1
  103. mindspore/mindrecord/config.py +17 -316
  104. mindspore/mindrecord/filereader.py +1 -9
  105. mindspore/mindrecord/filewriter.py +5 -15
  106. mindspore/mindrecord/mindpage.py +1 -9
  107. mindspore/mindspore_backend.dll +0 -0
  108. mindspore/mindspore_common.dll +0 -0
  109. mindspore/mindspore_core.dll +0 -0
  110. mindspore/mindspore_glog.dll +0 -0
  111. mindspore/mindspore_ops.dll +0 -0
  112. mindspore/mint/__init__.py +824 -218
  113. mindspore/mint/distributed/__init__.py +66 -4
  114. mindspore/mint/distributed/distributed.py +2594 -44
  115. mindspore/mint/linalg/__init__.py +6 -0
  116. mindspore/mint/nn/__init__.py +473 -14
  117. mindspore/mint/nn/functional.py +486 -11
  118. mindspore/mint/nn/layer/__init__.py +17 -4
  119. mindspore/mint/nn/layer/_functions.py +330 -0
  120. mindspore/mint/nn/layer/activation.py +169 -1
  121. mindspore/mint/nn/layer/basic.py +123 -0
  122. mindspore/mint/nn/layer/conv.py +727 -0
  123. mindspore/mint/nn/layer/normalization.py +215 -19
  124. mindspore/mint/nn/layer/padding.py +797 -0
  125. mindspore/mint/nn/layer/pooling.py +170 -0
  126. mindspore/mint/optim/__init__.py +2 -1
  127. mindspore/mint/optim/adam.py +223 -0
  128. mindspore/mint/optim/adamw.py +26 -19
  129. mindspore/mint/special/__init__.py +2 -1
  130. mindspore/msobj140.dll +0 -0
  131. mindspore/mspdb140.dll +0 -0
  132. mindspore/mspdbcore.dll +0 -0
  133. mindspore/mspdbst.dll +0 -0
  134. mindspore/mspft140.dll +0 -0
  135. mindspore/msvcdis140.dll +0 -0
  136. mindspore/msvcp140_1.dll +0 -0
  137. mindspore/msvcp140_2.dll +0 -0
  138. mindspore/msvcp140_atomic_wait.dll +0 -0
  139. mindspore/msvcp140_codecvt_ids.dll +0 -0
  140. mindspore/multiprocessing/__init__.py +5 -0
  141. mindspore/nn/cell.py +126 -19
  142. mindspore/nn/dynamic_lr.py +2 -1
  143. mindspore/nn/layer/activation.py +6 -6
  144. mindspore/nn/layer/basic.py +35 -25
  145. mindspore/nn/layer/channel_shuffle.py +3 -3
  146. mindspore/nn/layer/embedding.py +3 -3
  147. mindspore/nn/layer/normalization.py +8 -7
  148. mindspore/nn/layer/padding.py +4 -3
  149. mindspore/nn/layer/pooling.py +47 -13
  150. mindspore/nn/layer/rnn_cells.py +1 -1
  151. mindspore/nn/layer/rnns.py +2 -1
  152. mindspore/nn/layer/timedistributed.py +5 -5
  153. mindspore/nn/layer/transformer.py +48 -26
  154. mindspore/nn/learning_rate_schedule.py +5 -3
  155. mindspore/nn/loss/loss.py +31 -36
  156. mindspore/nn/optim/ada_grad.py +1 -0
  157. mindspore/nn/optim/adadelta.py +2 -2
  158. mindspore/nn/optim/adam.py +1 -1
  159. mindspore/nn/optim/lars.py +1 -4
  160. mindspore/nn/optim/optimizer.py +1 -1
  161. mindspore/nn/optim/rprop.py +2 -2
  162. mindspore/nn/optim/thor.py +2 -1
  163. mindspore/nn/utils/init.py +13 -11
  164. mindspore/nn/wrap/cell_wrapper.py +4 -6
  165. mindspore/nn/wrap/loss_scale.py +3 -4
  166. mindspore/numpy/array_creations.py +60 -62
  167. mindspore/numpy/array_ops.py +148 -143
  168. mindspore/numpy/logic_ops.py +41 -42
  169. mindspore/numpy/math_ops.py +361 -359
  170. mindspore/numpy/utils.py +16 -16
  171. mindspore/numpy/utils_const.py +4 -4
  172. mindspore/opencv_core452.dll +0 -0
  173. mindspore/opencv_imgcodecs452.dll +0 -0
  174. mindspore/opencv_imgproc452.dll +0 -0
  175. mindspore/ops/__init__.py +2 -1
  176. mindspore/ops/_grad_experimental/grad_comm_ops.py +94 -13
  177. mindspore/ops/_grad_experimental/grad_debug_ops.py +6 -1
  178. mindspore/ops/_grad_experimental/grad_inner_ops.py +9 -0
  179. mindspore/ops/_grad_experimental/grad_math_ops.py +2 -1
  180. mindspore/ops/_op_impl/cpu/__init__.py +1 -0
  181. mindspore/ops/_op_impl/cpu/raise_op.py +28 -0
  182. mindspore/ops/_vmap/vmap_array_ops.py +20 -19
  183. mindspore/ops/_vmap/vmap_base.py +0 -2
  184. mindspore/ops/_vmap/vmap_grad_nn_ops.py +19 -13
  185. mindspore/ops/_vmap/vmap_math_ops.py +11 -9
  186. mindspore/ops/_vmap/vmap_nn_ops.py +20 -34
  187. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +149 -12
  188. mindspore/ops/auto_generate/gen_arg_handler.py +0 -61
  189. mindspore/ops/auto_generate/gen_extend_func.py +554 -60
  190. mindspore/ops/auto_generate/gen_ops_def.py +1621 -115
  191. mindspore/ops/auto_generate/gen_ops_prim.py +8024 -3409
  192. mindspore/ops/auto_generate/pyboost_inner_prim.py +183 -79
  193. mindspore/ops/composite/base.py +1 -1
  194. mindspore/ops/composite/multitype_ops/_compile_utils.py +229 -30
  195. mindspore/ops/composite/multitype_ops/pow_impl.py +0 -29
  196. mindspore/ops/function/__init__.py +12 -0
  197. mindspore/ops/function/array_func.py +561 -159
  198. mindspore/ops/function/clip_func.py +64 -0
  199. mindspore/ops/function/debug_func.py +28 -20
  200. mindspore/ops/function/image_func.py +1 -1
  201. mindspore/ops/function/linalg_func.py +5 -4
  202. mindspore/ops/function/math_func.py +1659 -290
  203. mindspore/ops/function/nn_func.py +988 -317
  204. mindspore/ops/function/parameter_func.py +3 -56
  205. mindspore/ops/function/random_func.py +243 -33
  206. mindspore/ops/function/sparse_unary_func.py +1 -1
  207. mindspore/ops/functional.py +18 -5
  208. mindspore/ops/functional_overload.py +897 -0
  209. mindspore/ops/operations/__init__.py +3 -2
  210. mindspore/ops/operations/_embedding_cache_ops.py +4 -4
  211. mindspore/ops/operations/_grad_ops.py +2 -34
  212. mindspore/ops/operations/_infer_ops.py +2 -1
  213. mindspore/ops/operations/_inner_ops.py +38 -8
  214. mindspore/ops/operations/array_ops.py +45 -303
  215. mindspore/ops/operations/comm_ops.py +19 -16
  216. mindspore/ops/operations/custom_ops.py +11 -55
  217. mindspore/ops/operations/debug_ops.py +42 -47
  218. mindspore/ops/operations/inner_ops.py +6 -4
  219. mindspore/ops/operations/linalg_ops.py +3 -2
  220. mindspore/ops/operations/manually_defined/ops_def.py +185 -104
  221. mindspore/ops/operations/math_ops.py +11 -216
  222. mindspore/ops/operations/nn_ops.py +146 -308
  223. mindspore/ops/primitive.py +23 -21
  224. mindspore/ops/tensor_method.py +1669 -0
  225. mindspore/ops_generate/aclnn_kernel_register_auto_cc_generator.py +110 -0
  226. mindspore/ops_generate/add_tensor_docs_generator.py +54 -0
  227. mindspore/ops_generate/arg_handler.py +0 -61
  228. mindspore/ops_generate/auto_grad_impl_cc_generator.py +135 -0
  229. mindspore/ops_generate/auto_grad_reg_cc_generator.py +93 -0
  230. mindspore/ops_generate/base_generator.py +11 -0
  231. mindspore/ops_generate/cpp_create_prim_instance_helper_generator.py +108 -0
  232. mindspore/ops_generate/functional_map_cpp_generator.py +491 -0
  233. mindspore/ops_generate/functional_overload_py_generator.py +110 -0
  234. mindspore/ops_generate/functions_cc_generator.py +233 -0
  235. mindspore/ops_generate/gen_aclnn_implement.py +110 -114
  236. mindspore/ops_generate/gen_constants.py +157 -3
  237. mindspore/ops_generate/gen_ops.py +245 -990
  238. mindspore/ops_generate/gen_pyboost_func.py +97 -998
  239. mindspore/ops_generate/gen_utils.py +119 -33
  240. mindspore/ops_generate/lite_ops_cpp_generator.py +155 -0
  241. mindspore/ops_generate/op_api_proto.py +206 -0
  242. mindspore/ops_generate/op_def_py_generator.py +131 -0
  243. mindspore/ops_generate/op_prim_py_generator.py +480 -0
  244. mindspore/ops_generate/op_proto.py +373 -108
  245. mindspore/ops_generate/op_template_parser.py +436 -0
  246. mindspore/ops_generate/ops_def_cc_generator.py +288 -0
  247. mindspore/ops_generate/ops_def_h_generator.py +74 -0
  248. mindspore/ops_generate/ops_name_h_generator.py +68 -0
  249. mindspore/ops_generate/ops_primitive_h_generator.py +81 -0
  250. mindspore/ops_generate/pyboost_functions_cpp_generator.py +370 -0
  251. mindspore/ops_generate/pyboost_functions_h_generator.py +68 -0
  252. mindspore/ops_generate/pyboost_functions_py_generator.py +148 -0
  253. mindspore/ops_generate/pyboost_grad_function_cpp_generator.py +154 -0
  254. mindspore/ops_generate/pyboost_inner_prim_generator.py +131 -0
  255. mindspore/ops_generate/pyboost_native_grad_functions_generator.py +268 -0
  256. mindspore/ops_generate/pyboost_op_cpp_code_generator.py +851 -0
  257. mindspore/ops_generate/pyboost_overload_functions_cpp_generator.py +344 -0
  258. mindspore/ops_generate/pyboost_utils.py +92 -33
  259. mindspore/ops_generate/template.py +294 -44
  260. mindspore/ops_generate/tensor_func_reg_cpp_generator.py +422 -0
  261. mindspore/parallel/__init__.py +3 -3
  262. mindspore/parallel/_auto_parallel_context.py +24 -33
  263. mindspore/parallel/_parallel_serialization.py +13 -2
  264. mindspore/parallel/_utils.py +4 -1
  265. mindspore/parallel/algo_parameter_config.py +1 -1
  266. mindspore/parallel/checkpoint_transform.py +44 -0
  267. mindspore/parallel/cluster/process_entity/_api.py +131 -37
  268. mindspore/parallel/cluster/process_entity/_utils.py +41 -6
  269. mindspore/parallel/cluster/run.py +20 -3
  270. mindspore/parallel/parameter_broadcast.py +1 -1
  271. mindspore/parallel/shard.py +3 -0
  272. mindspore/parallel/transform_safetensors.py +119 -253
  273. mindspore/pgodb140.dll +0 -0
  274. mindspore/pgort140.dll +0 -0
  275. mindspore/profiler/__init__.py +17 -4
  276. mindspore/profiler/analysis/__init__.py +0 -0
  277. mindspore/profiler/analysis/parser/__init__.py +0 -0
  278. mindspore/profiler/analysis/parser/ascend_cann_parser.py +166 -0
  279. mindspore/profiler/analysis/parser/base_parser.py +158 -0
  280. mindspore/profiler/analysis/parser/framework_cann_relation_parser.py +45 -0
  281. mindspore/profiler/analysis/parser/ms_framework_parser.py +142 -0
  282. mindspore/profiler/analysis/parser/ms_minddata_parser.py +145 -0
  283. mindspore/profiler/analysis/parser/timeline_assembly_factory/__init__.py +0 -0
  284. mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +261 -0
  285. mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +40 -0
  286. mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +84 -0
  287. mindspore/profiler/analysis/parser/timeline_creator/__init__.py +0 -0
  288. mindspore/profiler/analysis/parser/timeline_creator/base_timeline_creator.py +44 -0
  289. mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +90 -0
  290. mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +76 -0
  291. mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +103 -0
  292. mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +134 -0
  293. mindspore/profiler/analysis/parser/timeline_event/__init__.py +0 -0
  294. mindspore/profiler/analysis/parser/timeline_event/base_event.py +233 -0
  295. mindspore/profiler/analysis/parser/timeline_event/cpu_op_event.py +47 -0
  296. mindspore/profiler/analysis/parser/timeline_event/flow_event.py +36 -0
  297. mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +260 -0
  298. mindspore/profiler/analysis/parser/timeline_event/msprof_event.py +73 -0
  299. mindspore/profiler/analysis/parser/timeline_event/scope_layer_event.py +53 -0
  300. mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +146 -0
  301. mindspore/profiler/analysis/task_manager.py +131 -0
  302. mindspore/profiler/analysis/time_converter.py +84 -0
  303. mindspore/profiler/analysis/viewer/__init__.py +0 -0
  304. mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +333 -0
  305. mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +87 -0
  306. mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +252 -0
  307. mindspore/profiler/analysis/viewer/ascend_memory_viewer.py +313 -0
  308. mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +322 -0
  309. mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +265 -0
  310. mindspore/profiler/analysis/viewer/ascend_timeline_viewer.py +58 -0
  311. mindspore/profiler/analysis/viewer/base_viewer.py +26 -0
  312. mindspore/profiler/analysis/viewer/ms_dataset_viewer.py +97 -0
  313. mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +581 -0
  314. mindspore/profiler/analysis/work_flow.py +73 -0
  315. mindspore/profiler/common/ascend_msprof_exporter.py +138 -0
  316. mindspore/profiler/common/command_executor.py +90 -0
  317. mindspore/profiler/common/constant.py +174 -3
  318. mindspore/profiler/common/file_manager.py +208 -0
  319. mindspore/profiler/common/log.py +130 -0
  320. mindspore/profiler/common/msprof_cmd_tool.py +202 -0
  321. mindspore/profiler/common/path_manager.py +371 -0
  322. mindspore/profiler/common/process_bar.py +168 -0
  323. mindspore/profiler/common/process_pool.py +9 -3
  324. mindspore/profiler/common/profiler_context.py +476 -0
  325. mindspore/profiler/common/profiler_info.py +304 -0
  326. mindspore/profiler/common/profiler_output_path.py +284 -0
  327. mindspore/profiler/common/profiler_parameters.py +210 -0
  328. mindspore/profiler/common/profiler_path_manager.py +120 -0
  329. mindspore/profiler/common/record_function.py +76 -0
  330. mindspore/profiler/common/tlv_decoder.py +76 -0
  331. mindspore/profiler/common/util.py +75 -2
  332. mindspore/profiler/dynamic_profiler.py +270 -37
  333. mindspore/profiler/envprofiler.py +138 -0
  334. mindspore/profiler/mstx.py +199 -0
  335. mindspore/profiler/platform/__init__.py +21 -0
  336. mindspore/profiler/platform/base_profiler.py +40 -0
  337. mindspore/profiler/platform/cpu_profiler.py +124 -0
  338. mindspore/profiler/platform/gpu_profiler.py +74 -0
  339. mindspore/profiler/platform/npu_profiler.py +309 -0
  340. mindspore/profiler/profiler.py +580 -93
  341. mindspore/profiler/profiler_action_controller.py +187 -0
  342. mindspore/profiler/profiler_interface.py +114 -0
  343. mindspore/profiler/schedule.py +208 -0
  344. mindspore/rewrite/api/symbol_tree.py +1 -2
  345. mindspore/run_check/_check_version.py +2 -6
  346. mindspore/runtime/__init__.py +37 -0
  347. mindspore/runtime/device.py +27 -0
  348. mindspore/runtime/event.py +209 -0
  349. mindspore/runtime/executor.py +148 -0
  350. mindspore/runtime/memory.py +392 -0
  351. mindspore/runtime/stream.py +460 -0
  352. mindspore/runtime/thread_bind_core.py +401 -0
  353. mindspore/swresample-4.dll +0 -0
  354. mindspore/swscale-6.dll +0 -0
  355. mindspore/tbbmalloc.dll +0 -0
  356. mindspore/tinyxml2.dll +0 -0
  357. mindspore/train/__init__.py +2 -2
  358. mindspore/train/_utils.py +53 -18
  359. mindspore/train/amp.py +8 -4
  360. mindspore/train/callback/_checkpoint.py +32 -18
  361. mindspore/train/callback/_early_stop.py +1 -1
  362. mindspore/train/callback/_flops_collector.py +105 -69
  363. mindspore/train/callback/_history.py +1 -1
  364. mindspore/train/callback/_summary_collector.py +44 -6
  365. mindspore/train/callback/_tft_register.py +31 -10
  366. mindspore/train/dataset_helper.py +11 -11
  367. mindspore/train/metrics/precision.py +4 -5
  368. mindspore/train/mind_ir_pb2.py +167 -46
  369. mindspore/train/model.py +13 -15
  370. mindspore/train/serialization.py +462 -76
  371. mindspore/train/summary/summary_record.py +1 -2
  372. mindspore/train/train_thor/model_thor.py +1 -1
  373. mindspore/turbojpeg.dll +0 -0
  374. mindspore/utils/__init__.py +4 -2
  375. mindspore/utils/dryrun.py +138 -0
  376. mindspore/utils/runtime_execution_order_check.py +550 -0
  377. mindspore/vcmeta.dll +0 -0
  378. mindspore/vcruntime140.dll +0 -0
  379. mindspore/vcruntime140_1.dll +0 -0
  380. mindspore/version.py +1 -1
  381. {mindspore-2.4.10.dist-info → mindspore-2.5.0.dist-info}/METADATA +2 -3
  382. {mindspore-2.4.10.dist-info → mindspore-2.5.0.dist-info}/RECORD +385 -261
  383. {mindspore-2.4.10.dist-info → mindspore-2.5.0.dist-info}/entry_points.txt +1 -1
  384. mindspore/common/_tensor_overload.py +0 -139
  385. mindspore/mindspore_np_dtype.dll +0 -0
  386. mindspore/profiler/envprofiling.py +0 -254
  387. mindspore/profiler/profiling.py +0 -1926
  388. {mindspore-2.4.10.dist-info → mindspore-2.5.0.dist-info}/WHEEL +0 -0
  389. {mindspore-2.4.10.dist-info → mindspore-2.5.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,168 @@
1
+ # Copyright 2024 Huawei Technologies Co., Ltd
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # ============================================================================
15
+ """Process bar."""
16
+ import os
17
+ import sys
18
+ import time
19
+ from typing import Iterable, Optional, Any
20
+ import threading
21
+
22
+
23
+ class ProcessBar:
24
+ """
25
+ A progress bar for tracking the progress of an iterable or a process with a known total.
26
+ """
27
+ BLANK_SPACE_NUM = 20
28
+ FINISH_TEXT = "Done"
29
+
30
+ def __init__(
31
+ self,
32
+ iterable: Optional[Iterable] = None,
33
+ desc: str = "",
34
+ bar_length: int = 20,
35
+ update_interval: float = 1.0,
36
+ ):
37
+ """
38
+ Initialize the ProcessBar.
39
+
40
+ Args:
41
+ iterable: An optional iterable to track progress.
42
+ desc: A description of the process being tracked.
43
+ bar_length: The length of the progress bar in characters.
44
+ update_interval: The minimum time interval between progress bar updates.
45
+ """
46
+ if not isinstance(iterable, Iterable):
47
+ raise ValueError("Must provide an iterable")
48
+
49
+ if not isinstance(desc, str):
50
+ raise ValueError("desc must be a string")
51
+
52
+ if not isinstance(bar_length, int):
53
+ raise ValueError("bar_length must be an integer")
54
+
55
+ if bar_length <= 0:
56
+ raise ValueError("bar_length must be greater than 0")
57
+
58
+ if not isinstance(update_interval, float):
59
+ raise ValueError("update_interval must be a float")
60
+
61
+ if update_interval < 0:
62
+ raise ValueError("update_interval must be greater than 0")
63
+
64
+ self.iterable: Iterable = iterable
65
+ self.total: int = len(iterable)
66
+ self.desc: str = f"[{os.getpid()}] {desc}"
67
+ self.bar_length: int = bar_length
68
+ self.update_interval: float = update_interval
69
+ self.current: int = 0
70
+ self.cur_item_name: Optional[str] = None
71
+ self.start_time: float = time.time()
72
+ self.last_update_time: float = self.start_time
73
+ self._stop_refresh = False
74
+ self._refresh_thread = None
75
+ self._start_auto_refresh()
76
+
77
+ def _start_auto_refresh(self) -> None:
78
+ """
79
+ Start auto refresh thread.
80
+ """
81
+ def refresh_loop():
82
+ while not self._stop_refresh:
83
+ if self.current > 0:
84
+ self._print_progress(time.time())
85
+ time.sleep(self.update_interval)
86
+
87
+ self._refresh_thread = threading.Thread(target=refresh_loop, daemon=True)
88
+ self._refresh_thread.start()
89
+
90
+ def update(self, n: int = 1, item_name: Optional[str] = None) -> None:
91
+ """
92
+ Update the progress bar.
93
+
94
+ Args:
95
+ n: The number of items or steps to increment the progress by.
96
+ item_name: The name of the current item being processed.
97
+ """
98
+ self.current += n
99
+ self.cur_item_name = item_name
100
+
101
+ def _print_progress(self, now: float) -> None:
102
+ """
103
+ Print the current progress to the console.
104
+
105
+ Args:
106
+ now: The current timestamp.
107
+ """
108
+ elapsed = now - self.start_time
109
+ if self.total > 0:
110
+ progress = min(1, self.current / self.total)
111
+ block = int(round(self.bar_length * progress))
112
+
113
+ text = (
114
+ f"\r{self.desc}: [{block * '#' + (self.bar_length - block) * ' '}] "
115
+ f"{self.current}/{self.total} {self.cur_item_name} "
116
+ f"Elapsed: {int(elapsed)}s"
117
+ )
118
+ # 添加额外的空格和回车来清除可能的残留字符
119
+ text = text + ' ' * self.BLANK_SPACE_NUM + '\r'
120
+ sys.stdout.write(text)
121
+ sys.stdout.flush()
122
+
123
+ def __iter__(self) -> Iterable[Any]:
124
+ """
125
+ Iterate over the items in the iterable, updating the progress bar for each item.
126
+
127
+ Yields:
128
+ The next item from the iterable.
129
+
130
+ Raises:
131
+ ValueError: If no iterable was provided during initialization.
132
+ """
133
+ if self.iterable is None:
134
+ raise ValueError("Must provide an iterable")
135
+ try:
136
+ iterator = iter(self.iterable)
137
+ # 预先获取第一个元素
138
+ try:
139
+ first_item = next(iterator)
140
+ except StopIteration:
141
+ return
142
+
143
+ # 初始化显示,显示0/total和第一个元素的名称
144
+ self.cur_item_name = first_item.__class__.__name__
145
+ self._print_progress(time.time())
146
+
147
+ # 处理第一个元素
148
+ yield first_item
149
+ self.update(item_name=first_item.__class__.__name__)
150
+ self._print_progress(time.time())
151
+
152
+ # 处理剩余元素
153
+ for item in iterator:
154
+ # 先更新当前要处理的元素名称
155
+ self.cur_item_name = item.__class__.__name__
156
+ self._print_progress(time.time())
157
+ yield item
158
+ self.update()
159
+
160
+ # 显示完成状态
161
+ self.cur_item_name = self.FINISH_TEXT
162
+ self._print_progress(time.time())
163
+ sys.stdout.write("\n")
164
+
165
+ finally:
166
+ self._stop_refresh = True
167
+ if self._refresh_thread:
168
+ self._refresh_thread.join()
@@ -28,9 +28,15 @@ class MultiProcessPool:
28
28
  self.porcess_list: List[Process] = []
29
29
  atexit.register(self.wait_all_job_finished)
30
30
 
31
- def add_async_job(self, func):
32
- """Add job and run in subprocess"""
33
- process = Process(target=func)
31
+ def add_async_job(self, func, *args, **kwargs):
32
+ """Add job and run in subprocess.
33
+
34
+ Args:
35
+ func: The function to be executed in subprocess.
36
+ args: The positional arguments to be passed to the function.
37
+ kwargs: The keyword arguments to be passed to the function.
38
+ """
39
+ process = Process(target=func, args=args, kwargs=kwargs)
34
40
  process.start()
35
41
  self.porcess_list.append(process)
36
42
 
@@ -0,0 +1,476 @@
1
+ # Copyright 2024 Huawei Technologies Co., Ltd
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # ============================================================================
15
+ """Profiler Context"""
16
+ import os
17
+ from typing import (
18
+ Dict,
19
+ Any,
20
+ Optional,
21
+ List,
22
+ Set,
23
+ Callable,
24
+ )
25
+
26
+ from mindspore.communication.management import GlobalComm
27
+ from mindspore.communication.management import get_local_rank
28
+ from mindspore.communication.management import get_rank
29
+ from mindspore.profiler.common.constant import (
30
+ DeviceTarget,
31
+ ProfilerLevel,
32
+ ProfilerActivity,
33
+ AicoreMetrics
34
+ )
35
+ from mindspore.profiler.common.profiler_output_path import ProfilerOutputPath
36
+ from mindspore.profiler.common.profiler_parameters import ProfilerParameters
37
+ from mindspore.profiler.common.constant import AnalysisMode
38
+ from mindspore.profiler.common.singleton import Singleton
39
+ from mindspore.profiler.schedule import Schedule
40
+
41
+ from mindspore import context
42
+ from mindspore import log as logger
43
+ from mindspore.profiler.common.profiler_info import ProfilerInfo
44
+
45
+
46
+ @Singleton
47
+ class ProfilerContext:
48
+ """
49
+ Profiler context manage all parameters and paths on runtime.
50
+ """
51
+
52
+ def __init__(self):
53
+ self._profiler_params_mgr: ProfilerParameters = None
54
+ self._device_id: Optional[str] = None
55
+ self._rank_id: Optional[str] = None
56
+ self._device_target: Optional[str] = None
57
+ self._dynamic_status: Optional[bool] = None
58
+ self._step_list: Optional[int] = None
59
+ self._mode: str = AnalysisMode.SYNC_MODE.value
60
+ self._pretty: bool = False
61
+ self._profiler_path_mgr: ProfilerOutputPath = None
62
+ self._jit_level: Optional[str] = ""
63
+ self._context_mode: Optional[int] = -1
64
+
65
+ self._init_device_target()
66
+ self._init_device_id()
67
+ self._init_rank_id()
68
+ self._init_context_mode()
69
+
70
+ def set_params(self, **kwargs):
71
+ """
72
+ Set profiler parameters and paths
73
+ """
74
+ self._profiler_params_mgr: ProfilerParameters = ProfilerParameters(**kwargs)
75
+ self._profiler_path_mgr: ProfilerOutputPath = ProfilerOutputPath(
76
+ device_id=int(self._device_id), rank_id=int(self._rank_id)
77
+ )
78
+ self._profiler_path_mgr.output_path = self._profiler_params_mgr.output_path
79
+
80
+ def to_dict(self) -> Dict[str, Any]:
81
+ """
82
+ Convert the profiler context to a dictionary for multiprocessing.
83
+ """
84
+ return {
85
+ **self._profiler_params_mgr.original_params,
86
+ **self._profiler_path_mgr.to_dict(),
87
+ "device_id": self._device_id,
88
+ "rank_id": self._rank_id,
89
+ "device_target": self._device_target,
90
+ "dynamic_status": self._dynamic_status,
91
+ "step_list": self._step_list,
92
+ "mode": self._mode,
93
+ "jit_level": self._jit_level,
94
+ "context_mode": self._context_mode
95
+ }
96
+
97
+ def load_offline_profiler_params(self, profiler_parameters: Dict[str, Any]) -> None:
98
+ """
99
+ Update profiler parameters from profiler_info.json
100
+ """
101
+ if not profiler_parameters:
102
+ raise ValueError("Profiler parameters is empty")
103
+
104
+ for param, (_, _) in self._profiler_params_mgr.PARAMS.items():
105
+ if param in profiler_parameters:
106
+ if param == "profiler_level":
107
+ value = ProfilerLevel(profiler_parameters[param])
108
+ elif param == "aicore_metrics":
109
+ value = AicoreMetrics(profiler_parameters[param])
110
+ elif param == "activities":
111
+ value = [ProfilerActivity(activity) for activity in profiler_parameters[param]]
112
+ elif param == "schedule":
113
+ continue
114
+ else:
115
+ value = profiler_parameters[param]
116
+
117
+ setattr(self._profiler_params_mgr, param, value)
118
+ setattr(self._profiler_params_mgr, "is_set_schedule", profiler_parameters["is_set_schedule"])
119
+
120
+ @property
121
+ def device_target_set(self) -> Set[str]:
122
+ """
123
+ Get the device target set for ProfilerInterface initialization.
124
+
125
+ CPU is always included in the list, device_target includes CPU、Ascend、GPU.
126
+ """
127
+ return set([DeviceTarget.CPU.value, self._device_target])
128
+
129
+ @property
130
+ def npu_profiler_params(self) -> Dict[str, Any]:
131
+ """
132
+ Get NPU profiler parameters for Ascend profiler cpp backend.
133
+
134
+ Returns:
135
+ Dict[str, Any]: A dictionary of NPU profiler parameters.
136
+ """
137
+ params = self._profiler_params_mgr.npu_profiler_params
138
+ # update framework_path for profile memory
139
+ params["framework_path"] = self._profiler_path_mgr.framework_path
140
+ params["rank_id"] = int(self._rank_id)
141
+ params["device_id"] = int(self._device_id)
142
+ return params
143
+
144
+ @property
145
+ def original_params(self) -> Dict[str, str]:
146
+ """Get the original parameters from ProfilerParameters."""
147
+ return self._profiler_params_mgr.original_params
148
+
149
+ @property
150
+ def output_path(self) -> str:
151
+ """Get the output path from ProfilerOutputPath."""
152
+ return self._profiler_path_mgr.output_path
153
+
154
+ @property
155
+ def ascend_ms_dir(self) -> str:
156
+ """Get the Ascend MS directory from ProfilerOutputPath."""
157
+ return self._profiler_path_mgr.ascend_ms_dir
158
+
159
+ @ascend_ms_dir.setter
160
+ def ascend_ms_dir(self, value: str):
161
+ """Set the Ascend MS directory to ProfilerOutputPath."""
162
+ self._profiler_path_mgr.ascend_ms_dir = value
163
+
164
+ @property
165
+ def ascend_profiler_output_path(self) -> str:
166
+ """Get the Ascend profiler output path from ProfilerOutputPath."""
167
+ return self._profiler_path_mgr.ascend_profiler_output_path
168
+
169
+ @property
170
+ def framework_path(self) -> str:
171
+ """Get the framework path from ProfilerOutputPath."""
172
+ return self._profiler_path_mgr.framework_path
173
+
174
+ @property
175
+ def msprof_profile_path(self) -> str:
176
+ """Get the MSProf profile path from ProfilerOutputPath."""
177
+ return self._profiler_path_mgr.msprof_profile_path
178
+
179
+ @msprof_profile_path.setter
180
+ def msprof_profile_path(self, value: str):
181
+ """Set the MSProf profile path to ProfilerOutputPath."""
182
+ self._profiler_path_mgr.msprof_profile_path = value
183
+
184
+ @property
185
+ def msprof_profile_host_path(self) -> str:
186
+ """Get the MSProf profile host path from ProfilerOutputPath."""
187
+ return self._profiler_path_mgr.msprof_profile_host_path
188
+
189
+ @property
190
+ def msprof_profile_device_path(self) -> str:
191
+ """Get the MSProf profile device path from ProfilerOutputPath."""
192
+ return self._profiler_path_mgr.msprof_profile_device_path
193
+
194
+ @property
195
+ def msprof_profile_log_path(self) -> str:
196
+ """Get the MSProf profile log path from ProfilerOutputPath."""
197
+ return self._profiler_path_mgr.msprof_profile_log_path
198
+
199
+ @property
200
+ def msprof_profile_output_path(self) -> str:
201
+ """Get the MSProf profile output path from ProfilerOutputPath."""
202
+ return self._profiler_path_mgr.msprof_profile_output_path
203
+
204
+ @property
205
+ def profiler_level(self) -> ProfilerLevel:
206
+ """Get the profiler level from ProfilerParameters."""
207
+ return self._profiler_params_mgr.profiler_level
208
+
209
+ @property
210
+ def activities(self) -> List[ProfilerActivity]:
211
+ """Get the activities from ProfilerParameters."""
212
+ return self._profiler_params_mgr.activities
213
+
214
+ @property
215
+ def profile_memory(self) -> bool:
216
+ """Get the profile memory from ProfilerParameters."""
217
+ return self._profiler_params_mgr.profile_memory
218
+
219
+ @property
220
+ def parallel_strategy(self) -> bool:
221
+ """Get the parallel strategy from ProfilerParameters."""
222
+ return self._profiler_params_mgr.parallel_strategy
223
+
224
+ @property
225
+ def start_profile(self) -> bool:
226
+ """Get the start profile from ProfilerParameters."""
227
+ return self._profiler_params_mgr.start_profile
228
+
229
+ @property
230
+ def aicore_metrics(self) -> int:
231
+ """Get the aicore metrics from ProfilerParameters."""
232
+ return self._profiler_params_mgr.aicore_metrics
233
+
234
+ @property
235
+ def l2_cache(self) -> bool:
236
+ """Get the l2 cache from ProfilerParameters."""
237
+ return self._profiler_params_mgr.l2_cache
238
+
239
+ @property
240
+ def hbm_ddr(self) -> bool:
241
+ """Get the hbm ddr from ProfilerParameters."""
242
+ return self._profiler_params_mgr.hbm_ddr
243
+
244
+ @property
245
+ def pcie(self) -> bool:
246
+ """Get the pcie from ProfilerParameters."""
247
+ return self._profiler_params_mgr.pcie
248
+
249
+ @property
250
+ def sync_enable(self) -> bool:
251
+ """Get the sync enable from ProfilerParameters."""
252
+ return self._profiler_params_mgr.sync_enable
253
+
254
+ @property
255
+ def data_process(self) -> bool:
256
+ """Get the data process from ProfilerParameters."""
257
+ return self._profiler_params_mgr.data_process
258
+
259
+ @property
260
+ def with_stack(self) -> bool:
261
+ """Get the with stack from ProfilerParameters."""
262
+ return self._profiler_params_mgr.with_stack
263
+
264
+ @property
265
+ def mstx(self) -> bool:
266
+ """Get the mstx from ProfilerParameters."""
267
+ return self._profiler_params_mgr.mstx
268
+
269
+ @property
270
+ def data_simplification(self) -> bool:
271
+ """Get the data simplification from ProfilerParameters."""
272
+ return self._profiler_params_mgr.data_simplification
273
+
274
+ @data_simplification.setter
275
+ def data_simplification(self, value: bool) -> None:
276
+ """Set data simplification value."""
277
+ if not isinstance(value, bool):
278
+ logger.warning(f"For profiler, the type of data_simplification should be bool, "
279
+ f"but got {type(value)}, reset to True.")
280
+ value = True
281
+ self._profiler_params_mgr.data_simplification = value
282
+
283
+ @property
284
+ def device_target(self) -> str:
285
+ """Get device target."""
286
+ return self._device_target
287
+
288
+ @property
289
+ def rank_id(self) -> str:
290
+ """Get rank id."""
291
+ return self._rank_id
292
+
293
+ @rank_id.setter
294
+ def rank_id(self, value: str) -> None:
295
+ """Set rank id."""
296
+ if not value:
297
+ raise ValueError("Rank id must be a non-empty string")
298
+
299
+ if not value.isdigit():
300
+ raise ValueError("Rank id must be a number")
301
+ self._rank_id = value
302
+
303
+ @property
304
+ def device_id(self) -> str:
305
+ """Get device id."""
306
+ return self._device_id
307
+
308
+ @device_id.setter
309
+ def device_id(self, value) -> None:
310
+ """Set device id."""
311
+ if not value:
312
+ raise ValueError("Device id must be a non-empty string")
313
+
314
+ if not value.isdigit():
315
+ raise ValueError("Device id must be a number")
316
+ self._device_id = value
317
+
318
+ @property
319
+ def dynamic_status(self) -> bool:
320
+ """Get dynamic status."""
321
+ return self._dynamic_status
322
+
323
+ @property
324
+ def step_list(self) -> Optional[List[int]]:
325
+ """Get step list."""
326
+ return self._step_list
327
+
328
+ @step_list.setter
329
+ def step_list(self, value: Optional[List[int]]) -> None:
330
+ """Set step list for profiling."""
331
+ if value is not None and not isinstance(value, list):
332
+ logger.error(f"For profiler, the parameter step_list must be a list, "
333
+ f"but got type {type(value)}, step_list reset to None.")
334
+ return
335
+ if value:
336
+ if not all(isinstance(step_id, int) for step_id in value):
337
+ logger.error(f"For profiler, the elements of the parameter step_list "
338
+ "must be integers, step_list reset to None.")
339
+ return
340
+ value.sort()
341
+ if value[-1] - value[0] != len(value) - 1:
342
+ logger.error(f"For profiler, the elements of the parameter step_list "
343
+ "must be continuous integers, step_list reset to None.")
344
+ return
345
+ self._step_list = value
346
+
347
+ @property
348
+ def pretty(self) -> bool:
349
+ return self._pretty
350
+
351
+ @pretty.setter
352
+ def pretty(self, value: bool) -> None:
353
+ """Set pretty print value."""
354
+ if not isinstance(value, bool):
355
+ logger.warning(f"For profiler, the parameter pretty must be bool, "
356
+ f"but got {type(value)}, reset to False.")
357
+ value = False
358
+ self._pretty = value
359
+
360
+ @property
361
+ def mode(self) -> str:
362
+ """Get the analysis mode."""
363
+ return self._mode
364
+
365
+ @mode.setter
366
+ def mode(self, mode: str) -> None:
367
+ """Set analysis mode value."""
368
+ if not isinstance(mode, str):
369
+ logger.warning(f"For Profiler.analyse(), the parameter mode must be str, "
370
+ f"but got {type(mode)}, reset to {AnalysisMode.SYNC_MODE.value}.")
371
+ self._mode = AnalysisMode.SYNC_MODE.value
372
+ return
373
+
374
+ mode_range = [m.value for m in AnalysisMode]
375
+ if mode not in mode_range:
376
+ logger.warning(f"For Profiler.analyse(), the parameter mode must be one of {mode_range}, "
377
+ f"but got {mode}, reset to {AnalysisMode.SYNC_MODE.value}.")
378
+ self._mode = AnalysisMode.SYNC_MODE.value
379
+ return
380
+
381
+ self._mode = mode
382
+
383
+ @property
384
+ def schedule(self) -> Schedule:
385
+ """Get the schedule from ProfilerParameters."""
386
+ return self._profiler_params_mgr.schedule
387
+
388
+ @property
389
+ def on_trace_ready(self) -> Optional[Callable[..., Any]]:
390
+ """Get the on trace ready from ProfilerParameters."""
391
+ return self._profiler_params_mgr.on_trace_ready
392
+
393
+ @property
394
+ def is_set_schedule(self) -> bool:
395
+ """Get the is set schedule from ProfilerParameters."""
396
+ return self._profiler_params_mgr.is_set_schedule
397
+
398
+ @property
399
+ def context_mode(self) -> int:
400
+ return self._context_mode
401
+
402
+ @context_mode.setter
403
+ def context_mode(self, value: int) -> None:
404
+ """Set context mode value."""
405
+ if not isinstance(value, int):
406
+ logger.warning(f"For profiler, the parameter context_mode must be int, "
407
+ f"but got {type(value)}, reset to -1.")
408
+ value = -1
409
+ self._context_mode = value
410
+
411
+ @property
412
+ def jit_level(self) -> str:
413
+ return self._jit_level
414
+
415
+ @jit_level.setter
416
+ def jit_level(self, value: str) -> None:
417
+ """Set jit level value."""
418
+ if not isinstance(value, str):
419
+ logger.warning(f"For profiler, the parameter jit_level must be str, "
420
+ f"but got {type(value)}, reset to ''.")
421
+ value = ""
422
+ self._jit_level = value
423
+
424
+ def _init_device_target(self) -> None:
425
+ """
426
+ Initialize the device target.
427
+
428
+ Raises:
429
+ RuntimeError: If the device target is not supported.
430
+ """
431
+ self._device_target = context.get_context("device_target")
432
+
433
+ if self._device_target and self._device_target not in (
434
+ member.value for member in DeviceTarget
435
+ ):
436
+ msg = "Profiling: unsupported backend: %s" % self._device_target
437
+ raise RuntimeError(msg)
438
+
439
+ def _init_device_id(self) -> None:
440
+ """
441
+ Initialize the device ID.
442
+ """
443
+ self._device_id = str(context.get_context("device_id"))
444
+
445
+ if not self._device_id or not self._device_id.isdigit():
446
+ if GlobalComm.INITED and self._device_target == DeviceTarget.NPU.value:
447
+ self._device_id = str(get_local_rank())
448
+ else:
449
+ self._device_id = os.getenv("DEVICE_ID")
450
+
451
+ if not self._device_id or not self._device_id.isdigit():
452
+ self._device_id = "0"
453
+ logger.warning("Fail to get DEVICE_ID, use 0 instead.")
454
+
455
+ def _init_rank_id(self) -> None:
456
+ """
457
+ Initialize the rank ID.
458
+ """
459
+ if GlobalComm.INITED and self._device_target == DeviceTarget.NPU.value:
460
+ self._rank_id = str(get_rank())
461
+ else:
462
+ self._rank_id = os.getenv("RANK_ID")
463
+
464
+ if not self._rank_id or not self._rank_id.isdigit():
465
+ self._rank_id = "0"
466
+
467
+ def _init_context_mode(self):
468
+ """
469
+ Initialize the jit level.
470
+ """
471
+ if context.get_context("mode") == context.GRAPH_MODE:
472
+ jit_config = context.get_jit_config()
473
+ self._jit_level = jit_config.get("jit_level", "")
474
+ ProfilerInfo().jit_level = self._jit_level
475
+ ProfilerInfo().context_mode = context.get_context("mode")
476
+ self._context_mode = context.get_context("mode")