mindspore 2.6.0__cp311-cp311-win_amd64.whl → 2.7.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.

Files changed (403) 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 +1 -1
  5. mindspore/_c_dataengine.cp311-win_amd64.pyd +0 -0
  6. mindspore/_c_expression.cp311-win_amd64.pyd +0 -0
  7. mindspore/_c_mindrecord.cp311-win_amd64.pyd +0 -0
  8. mindspore/_checkparam.py +40 -9
  9. mindspore/{_deprecated → _extends/optimize}/__init__.py +9 -3
  10. mindspore/_extends/optimize/cell_utils.py +96 -0
  11. mindspore/_extends/parse/__init__.py +2 -2
  12. mindspore/_extends/parse/compile_config.py +44 -22
  13. mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +1 -1
  14. mindspore/_extends/parse/parser.py +36 -61
  15. mindspore/_extends/parse/resources.py +39 -0
  16. mindspore/_extends/parse/standard_method.py +32 -13
  17. mindspore/_extends/parse/trope.py +8 -1
  18. mindspore/_extends/pijit/__init__.py +1 -2
  19. mindspore/amp.py +4 -4
  20. mindspore/atlprov.dll +0 -0
  21. mindspore/avcodec-59.dll +0 -0
  22. mindspore/avdevice-59.dll +0 -0
  23. mindspore/avfilter-8.dll +0 -0
  24. mindspore/avformat-59.dll +0 -0
  25. mindspore/avutil-57.dll +0 -0
  26. mindspore/boost/adasum.py +1 -1
  27. mindspore/boost/boost_cell_wrapper.py +4 -4
  28. mindspore/c1.dll +0 -0
  29. mindspore/c1xx.dll +0 -0
  30. mindspore/c2.dll +0 -0
  31. mindspore/common/__init__.py +27 -2
  32. mindspore/common/_grad_function.py +2 -1
  33. mindspore/common/_pijit_context.py +28 -7
  34. mindspore/common/_stub_tensor.py +1 -209
  35. mindspore/common/_tensor_cpp_method.py +1 -1
  36. mindspore/common/_tensor_docs.py +76 -15
  37. mindspore/common/api.py +193 -112
  38. mindspore/common/dtype.py +21 -11
  39. mindspore/common/dump.py +10 -15
  40. mindspore/common/generator.py +2 -3
  41. mindspore/common/hook_handle.py +11 -2
  42. mindspore/common/jit_config.py +1 -1
  43. mindspore/common/jit_trace.py +84 -105
  44. mindspore/common/parameter.py +26 -12
  45. mindspore/common/recompute.py +3 -3
  46. mindspore/common/sparse_tensor.py +0 -3
  47. mindspore/common/symbol.py +0 -1
  48. mindspore/common/tensor.py +48 -83
  49. mindspore/communication/_comm_helper.py +46 -4
  50. mindspore/communication/management.py +79 -7
  51. mindspore/context.py +38 -23
  52. mindspore/dataset/core/config.py +3 -3
  53. mindspore/dataset/engine/datasets.py +20 -7
  54. mindspore/dataset/engine/datasets_user_defined.py +32 -2
  55. mindspore/dataset/engine/iterators.py +2 -2
  56. mindspore/dataset/engine/obs/config_loader.py +2 -2
  57. mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +8 -0
  58. mindspore/dataset/transforms/py_transforms.py +7 -3
  59. mindspore/dataset/transforms/transforms.py +7 -3
  60. mindspore/dataset/vision/validators.py +1 -0
  61. mindspore/device_context/ascend/device.py +1 -1
  62. mindspore/device_context/gpu/__init__.py +2 -2
  63. mindspore/device_context/gpu/device.py +1 -1
  64. mindspore/device_context/gpu/op_precision.py +4 -2
  65. mindspore/device_context/gpu/op_tuning.py +6 -3
  66. mindspore/device_manager.py +16 -9
  67. mindspore/dnnl.dll +0 -0
  68. mindspore/dpcmi.dll +0 -0
  69. mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +3 -5
  70. mindspore/experimental/llm_boost/atb/boost_base.py +2 -3
  71. mindspore/experimental/optim/adadelta.py +13 -20
  72. mindspore/experimental/optim/adagrad.py +15 -22
  73. mindspore/experimental/optim/adam.py +17 -24
  74. mindspore/experimental/optim/adamax.py +14 -22
  75. mindspore/experimental/optim/adamw.py +28 -34
  76. mindspore/experimental/optim/asgd.py +15 -25
  77. mindspore/experimental/optim/lr_scheduler.py +27 -45
  78. mindspore/experimental/optim/nadam.py +14 -24
  79. mindspore/experimental/optim/optimizer.py +13 -23
  80. mindspore/experimental/optim/radam.py +18 -24
  81. mindspore/experimental/optim/rmsprop.py +14 -25
  82. mindspore/experimental/optim/rprop.py +15 -26
  83. mindspore/experimental/optim/sgd.py +9 -19
  84. mindspore/hal/__init__.py +4 -4
  85. mindspore/hal/contiguous_tensors_handle.py +2 -2
  86. mindspore/hal/memory.py +1 -0
  87. mindspore/include/api/cell.h +37 -1
  88. mindspore/include/api/delegate.h +10 -0
  89. mindspore/include/api/model.h +3 -0
  90. mindspore/include/api/types.h +2 -2
  91. mindspore/include/c_api/model_c.h +0 -58
  92. mindspore/include/c_api/tensor_c.h +0 -26
  93. mindspore/include/dataset/vision_ascend.h +1 -1
  94. mindspore/jpeg62.dll +0 -0
  95. mindspore/mindrecord/tools/cifar10.py +60 -11
  96. mindspore/mindrecord/tools/cifar10_to_mr.py +5 -0
  97. mindspore/mindspore_backend_common.dll +0 -0
  98. mindspore/mindspore_backend_manager.dll +0 -0
  99. mindspore/mindspore_common.dll +0 -0
  100. mindspore/mindspore_core.dll +0 -0
  101. mindspore/mindspore_cpu_res_manager.dll +0 -0
  102. mindspore/mindspore_dump.dll +0 -0
  103. mindspore/mindspore_frontend.dll +0 -0
  104. mindspore/mindspore_glog.dll +0 -0
  105. mindspore/mindspore_memory_pool.dll +0 -0
  106. mindspore/mindspore_ms_backend.dll +0 -0
  107. mindspore/mindspore_ops.dll +0 -0
  108. mindspore/mindspore_ops_host.dll +0 -0
  109. mindspore/mindspore_ops_kernel_common.dll +0 -0
  110. mindspore/mindspore_profiler.dll +0 -0
  111. mindspore/mindspore_pyboost.dll +0 -0
  112. mindspore/mindspore_pynative.dll +0 -0
  113. mindspore/mindspore_res_manager.dll +0 -0
  114. mindspore/mindspore_runtime_pipeline.dll +0 -0
  115. mindspore/mint/__init__.py +4 -44
  116. mindspore/mint/distributed/__init__.py +1 -0
  117. mindspore/mint/distributed/distributed.py +208 -5
  118. mindspore/mint/nn/__init__.py +1 -1
  119. mindspore/mint/nn/functional.py +53 -6
  120. mindspore/mint/nn/layer/_functions.py +164 -294
  121. mindspore/mint/nn/layer/activation.py +8 -6
  122. mindspore/mint/nn/layer/conv.py +122 -98
  123. mindspore/mint/nn/layer/normalization.py +8 -22
  124. mindspore/mint/optim/adam.py +19 -18
  125. mindspore/mint/optim/adamw.py +14 -8
  126. mindspore/mint/optim/sgd.py +5 -5
  127. mindspore/msobj140.dll +0 -0
  128. mindspore/mspdb140.dll +0 -0
  129. mindspore/mspdbcore.dll +0 -0
  130. mindspore/mspdbst.dll +0 -0
  131. mindspore/mspft140.dll +0 -0
  132. mindspore/msvcdis140.dll +0 -0
  133. mindspore/msvcp140_1.dll +0 -0
  134. mindspore/msvcp140_2.dll +0 -0
  135. mindspore/msvcp140_atomic_wait.dll +0 -0
  136. mindspore/msvcp140_codecvt_ids.dll +0 -0
  137. mindspore/nn/cell.py +325 -499
  138. mindspore/nn/grad/cell_grad.py +11 -12
  139. mindspore/nn/layer/activation.py +32 -34
  140. mindspore/nn/layer/basic.py +67 -64
  141. mindspore/nn/layer/channel_shuffle.py +4 -4
  142. mindspore/nn/layer/combined.py +4 -2
  143. mindspore/nn/layer/conv.py +86 -85
  144. mindspore/nn/layer/dense.py +9 -7
  145. mindspore/nn/layer/embedding.py +50 -52
  146. mindspore/nn/layer/image.py +37 -39
  147. mindspore/nn/layer/math.py +111 -112
  148. mindspore/nn/layer/normalization.py +56 -44
  149. mindspore/nn/layer/pooling.py +58 -63
  150. mindspore/nn/layer/rnn_cells.py +33 -33
  151. mindspore/nn/layer/rnns.py +56 -56
  152. mindspore/nn/layer/thor_layer.py +74 -73
  153. mindspore/nn/layer/transformer.py +11 -1
  154. mindspore/nn/learning_rate_schedule.py +20 -20
  155. mindspore/nn/loss/loss.py +79 -81
  156. mindspore/nn/optim/adam.py +1 -1
  157. mindspore/nn/optim/adasum.py +2 -2
  158. mindspore/nn/optim/optimizer.py +1 -1
  159. mindspore/nn/optim/thor.py +2 -2
  160. mindspore/nn/probability/distribution/exponential.py +2 -1
  161. mindspore/nn/probability/distribution/poisson.py +2 -1
  162. mindspore/nn/sparse/sparse.py +3 -3
  163. mindspore/nn/wrap/cell_wrapper.py +34 -37
  164. mindspore/nn/wrap/grad_reducer.py +37 -37
  165. mindspore/nn/wrap/loss_scale.py +72 -74
  166. mindspore/numpy/array_creations.py +5 -5
  167. mindspore/numpy/fft.py +1 -1
  168. mindspore/numpy/math_ops.py +1 -1
  169. mindspore/opencv_core452.dll +0 -0
  170. mindspore/opencv_imgcodecs452.dll +0 -0
  171. mindspore/opencv_imgproc452.dll +0 -0
  172. mindspore/ops/_grad_experimental/grad_comm_ops.py +51 -13
  173. mindspore/ops/_grad_experimental/grad_debug_ops.py +14 -0
  174. mindspore/ops/_vmap/vmap_array_ops.py +6 -13
  175. mindspore/ops/_vmap/vmap_nn_ops.py +8 -16
  176. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +17 -8
  177. mindspore/ops/auto_generate/gen_extend_func.py +1 -51
  178. mindspore/ops/auto_generate/gen_ops_def.py +463 -257
  179. mindspore/ops/auto_generate/gen_ops_prim.py +1127 -885
  180. mindspore/ops/auto_generate/pyboost_inner_prim.py +31 -1
  181. mindspore/ops/composite/__init__.py +10 -0
  182. mindspore/ops/composite/base.py +8 -4
  183. mindspore/ops/composite/multitype_ops/__init__.py +12 -1
  184. mindspore/ops/composite/multitype_ops/_compile_utils.py +132 -108
  185. mindspore/ops/composite/multitype_ops/add_impl.py +70 -2
  186. mindspore/ops/composite/multitype_ops/div_impl.py +49 -0
  187. mindspore/ops/composite/multitype_ops/floordiv_impl.py +29 -0
  188. mindspore/ops/composite/multitype_ops/getitem_impl.py +11 -0
  189. mindspore/ops/composite/multitype_ops/mod_impl.py +5 -3
  190. mindspore/ops/composite/multitype_ops/mul_impl.py +49 -0
  191. mindspore/ops/composite/multitype_ops/setitem_impl.py +57 -0
  192. mindspore/ops/composite/multitype_ops/sub_impl.py +34 -0
  193. mindspore/ops/composite/multitype_ops/zeros_like_impl.py +14 -0
  194. mindspore/ops/function/__init__.py +3 -1
  195. mindspore/ops/function/_add_attr_func.py +11 -6
  196. mindspore/ops/function/array_func.py +7 -94
  197. mindspore/ops/function/debug_func.py +4 -3
  198. mindspore/ops/function/grad/grad_func.py +1 -1
  199. mindspore/ops/function/math_func.py +21 -367
  200. mindspore/ops/function/nn_func.py +26 -41
  201. mindspore/ops/function/other_func.py +4 -1
  202. mindspore/ops/function/random_func.py +31 -4
  203. mindspore/ops/functional.py +0 -2
  204. mindspore/ops/functional_overload.py +463 -6
  205. mindspore/ops/op_info_register.py +21 -0
  206. mindspore/ops/operations/__init__.py +5 -2
  207. mindspore/ops/operations/_custom_ops_utils.py +675 -8
  208. mindspore/ops/operations/_inner_ops.py +3 -6
  209. mindspore/ops/operations/_sequence_ops.py +1 -1
  210. mindspore/ops/operations/comm_ops.py +185 -26
  211. mindspore/ops/operations/custom_ops.py +235 -172
  212. mindspore/ops/operations/debug_ops.py +55 -4
  213. mindspore/ops/operations/image_ops.py +13 -13
  214. mindspore/ops/operations/manually_defined/ops_def.py +15 -16
  215. mindspore/ops/operations/math_ops.py +3 -4
  216. mindspore/ops/operations/nn_ops.py +5 -6
  217. mindspore/ops/primitive.py +6 -10
  218. mindspore/ops/tensor_method.py +36 -4
  219. mindspore/ops_generate/api/cpp_create_prim_instance_helper_generator.py +1 -1
  220. mindspore/ops_generate/api/functional_map_cpp_generator.py +10 -9
  221. mindspore/ops_generate/api/functions_cc_generator.py +58 -10
  222. mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +1 -1
  223. mindspore/ops_generate/common/base_generator.py +14 -0
  224. mindspore/ops_generate/common/gen_constants.py +7 -2
  225. mindspore/ops_generate/common/gen_utils.py +0 -19
  226. mindspore/ops_generate/common/op_proto.py +11 -4
  227. mindspore/ops_generate/common/template.py +88 -11
  228. mindspore/ops_generate/gen_ops.py +1 -1
  229. mindspore/ops_generate/op_def/lite_ops_cpp_generator.py +4 -4
  230. mindspore/ops_generate/op_def/ops_name_h_generator.py +0 -3
  231. mindspore/ops_generate/op_def/ops_primitive_h_generator.py +0 -4
  232. mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -2
  233. mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +49 -8
  234. mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +2 -2
  235. mindspore/ops_generate/pyboost/gen_pyboost_func.py +31 -0
  236. mindspore/ops_generate/pyboost/op_template_parser.py +98 -72
  237. mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +70 -273
  238. mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +14 -6
  239. mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +316 -0
  240. mindspore/ops_generate/pyboost/pyboost_functions_py_generator.py +1 -1
  241. mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +5 -3
  242. mindspore/ops_generate/pyboost/pyboost_inner_prim_generator.py +1 -1
  243. mindspore/ops_generate/pyboost/pyboost_internal_functions_cpp_generator.py +76 -0
  244. mindspore/ops_generate/pyboost/pyboost_internal_functions_h_generator.py +76 -0
  245. mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +125 -0
  246. mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +4 -3
  247. mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +348 -61
  248. mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +1 -1
  249. mindspore/ops_generate/pyboost/pyboost_utils.py +118 -9
  250. mindspore/ops_generate/tensor_py_cc_generator.py +1 -24
  251. mindspore/parallel/_auto_parallel_context.py +4 -2
  252. mindspore/parallel/_cell_wrapper.py +106 -40
  253. mindspore/parallel/_parallel_serialization.py +1 -1
  254. mindspore/parallel/_ps_context.py +4 -6
  255. mindspore/parallel/_tensor.py +167 -12
  256. mindspore/parallel/_transformer/moe.py +1 -1
  257. mindspore/parallel/_transformer/transformer.py +13 -8
  258. mindspore/parallel/auto_parallel.py +12 -5
  259. mindspore/parallel/checkpoint_convert.py +3 -3
  260. mindspore/parallel/checkpoint_transform.py +3 -1
  261. mindspore/parallel/cluster/process_entity/_api.py +84 -48
  262. mindspore/parallel/cluster/process_entity/_utils.py +95 -7
  263. mindspore/parallel/cluster/run.py +43 -4
  264. mindspore/parallel/function/__init__.py +8 -1
  265. mindspore/parallel/function/reshard_func.py +1 -1
  266. mindspore/parallel/nn/__init__.py +15 -2
  267. mindspore/parallel/nn/parallel_cell_wrapper.py +9 -10
  268. mindspore/parallel/nn/parallel_grad_reducer.py +7 -6
  269. mindspore/parallel/shard.py +2 -2
  270. mindspore/parallel/transform_safetensors.py +462 -174
  271. mindspore/pgodb140.dll +0 -0
  272. mindspore/pgort140.dll +0 -0
  273. mindspore/profiler/__init__.py +2 -1
  274. mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +7 -7
  275. mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +3 -0
  276. mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +3 -0
  277. mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +3 -3
  278. mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +3 -3
  279. mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +4 -4
  280. mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +3 -3
  281. mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +4 -1
  282. mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +2 -1
  283. mindspore/profiler/analysis/task_manager.py +1 -1
  284. mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +5 -1
  285. mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +2 -1
  286. mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +42 -22
  287. mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +3 -2
  288. mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +9 -5
  289. mindspore/profiler/analysis/viewer/ms_operator_details_viewer.py +132 -0
  290. mindspore/profiler/common/constant.py +16 -0
  291. mindspore/profiler/common/profiler_context.py +25 -27
  292. mindspore/profiler/common/profiler_info.py +0 -16
  293. mindspore/profiler/common/profiler_op_analyse.py +235 -0
  294. mindspore/profiler/common/profiler_output_path.py +23 -8
  295. mindspore/profiler/common/profiler_parameters.py +128 -35
  296. mindspore/profiler/dynamic_profile/__init__.py +0 -0
  297. mindspore/profiler/dynamic_profile/dynamic_monitor_proxy.py +39 -0
  298. mindspore/profiler/dynamic_profile/dynamic_profiler_config_context.py +666 -0
  299. mindspore/profiler/dynamic_profile/dynamic_profiler_utils.py +62 -0
  300. mindspore/profiler/dynamic_profiler.py +305 -314
  301. mindspore/profiler/envprofiler.py +12 -7
  302. mindspore/profiler/experimental_config.py +96 -6
  303. mindspore/profiler/mstx.py +33 -12
  304. mindspore/profiler/platform/__init__.py +2 -3
  305. mindspore/profiler/platform/npu_profiler.py +29 -19
  306. mindspore/profiler/profiler.py +35 -19
  307. mindspore/profiler/profiler_action_controller.py +64 -76
  308. mindspore/profiler/schedule.py +10 -4
  309. mindspore/rewrite/common/config.py +1 -0
  310. mindspore/rewrite/common/namer.py +1 -0
  311. mindspore/rewrite/common/namespace.py +1 -0
  312. mindspore/rewrite/node/node.py +31 -11
  313. mindspore/rewrite/parsers/assign_parser.py +1 -1
  314. mindspore/rewrite/symbol_tree/symbol_tree.py +1 -1
  315. mindspore/run_check/_check_version.py +7 -10
  316. mindspore/runtime/__init__.py +5 -5
  317. mindspore/runtime/event.py +10 -4
  318. mindspore/runtime/executor.py +60 -45
  319. mindspore/runtime/memory.py +21 -30
  320. mindspore/runtime/thread_bind_core.py +298 -164
  321. mindspore/safeguard/rewrite_obfuscation.py +12 -13
  322. mindspore/swresample-4.dll +0 -0
  323. mindspore/swscale-6.dll +0 -0
  324. mindspore/tbbmalloc.dll +0 -0
  325. mindspore/tinyxml2.dll +0 -0
  326. mindspore/train/_utils.py +6 -2
  327. mindspore/train/amp.py +43 -20
  328. mindspore/train/callback/__init__.py +5 -5
  329. mindspore/train/callback/_checkpoint.py +3 -6
  330. mindspore/train/callback/_flops_collector.py +1 -1
  331. mindspore/train/callback/_landscape.py +0 -1
  332. mindspore/train/callback/_train_fault_tolerance.py +71 -13
  333. mindspore/train/data_sink.py +11 -2
  334. mindspore/train/dataset_helper.py +9 -0
  335. mindspore/train/model.py +51 -33
  336. mindspore/train/serialization.py +133 -111
  337. mindspore/train/summary/summary_record.py +13 -2
  338. mindspore/turbojpeg.dll +0 -0
  339. mindspore/utils/__init__.py +3 -2
  340. mindspore/utils/dryrun.py +0 -6
  341. mindspore/utils/runtime_execution_order_check.py +162 -78
  342. mindspore/utils/sdc_detect.py +68 -0
  343. mindspore/utils/utils.py +6 -9
  344. mindspore/vcmeta.dll +0 -0
  345. mindspore/vcruntime140.dll +0 -0
  346. mindspore/vcruntime140_1.dll +0 -0
  347. mindspore/version.py +1 -1
  348. {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/METADATA +5 -4
  349. {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/RECORD +352 -390
  350. mindspore/_deprecated/jit.py +0 -198
  351. mindspore/experimental/es/__init__.py +0 -22
  352. mindspore/experimental/es/embedding_service.py +0 -891
  353. mindspore/experimental/es/embedding_service_layer.py +0 -581
  354. mindspore/profiler/parser/__init__.py +0 -14
  355. mindspore/profiler/parser/aicpu_data_parser.py +0 -272
  356. mindspore/profiler/parser/ascend_analysis/__init__.py +0 -14
  357. mindspore/profiler/parser/ascend_analysis/constant.py +0 -71
  358. mindspore/profiler/parser/ascend_analysis/file_manager.py +0 -180
  359. mindspore/profiler/parser/ascend_analysis/function_event.py +0 -185
  360. mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +0 -136
  361. mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +0 -131
  362. mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +0 -104
  363. mindspore/profiler/parser/ascend_analysis/path_manager.py +0 -313
  364. mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +0 -123
  365. mindspore/profiler/parser/ascend_analysis/tlv_decoder.py +0 -86
  366. mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +0 -75
  367. mindspore/profiler/parser/ascend_cluster_generator.py +0 -116
  368. mindspore/profiler/parser/ascend_communicate_generator.py +0 -314
  369. mindspore/profiler/parser/ascend_flops_generator.py +0 -116
  370. mindspore/profiler/parser/ascend_fpbp_generator.py +0 -82
  371. mindspore/profiler/parser/ascend_hccl_generator.py +0 -271
  372. mindspore/profiler/parser/ascend_integrate_generator.py +0 -42
  373. mindspore/profiler/parser/ascend_memory_generator.py +0 -185
  374. mindspore/profiler/parser/ascend_msprof_exporter.py +0 -282
  375. mindspore/profiler/parser/ascend_msprof_generator.py +0 -187
  376. mindspore/profiler/parser/ascend_op_generator.py +0 -334
  377. mindspore/profiler/parser/ascend_steptrace_generator.py +0 -94
  378. mindspore/profiler/parser/ascend_timeline_generator.py +0 -545
  379. mindspore/profiler/parser/base_timeline_generator.py +0 -483
  380. mindspore/profiler/parser/container.py +0 -229
  381. mindspore/profiler/parser/cpu_gpu_timeline_generator.py +0 -697
  382. mindspore/profiler/parser/flops_parser.py +0 -531
  383. mindspore/profiler/parser/framework_enum.py +0 -111
  384. mindspore/profiler/parser/framework_parser.py +0 -464
  385. mindspore/profiler/parser/framework_struct.py +0 -61
  386. mindspore/profiler/parser/gpu_analysis/__init__.py +0 -14
  387. mindspore/profiler/parser/gpu_analysis/function_event.py +0 -44
  388. mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +0 -89
  389. mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +0 -72
  390. mindspore/profiler/parser/hccl_parser.py +0 -573
  391. mindspore/profiler/parser/hwts_log_parser.py +0 -122
  392. mindspore/profiler/parser/integrator.py +0 -526
  393. mindspore/profiler/parser/memory_usage_parser.py +0 -277
  394. mindspore/profiler/parser/minddata_analyzer.py +0 -800
  395. mindspore/profiler/parser/minddata_parser.py +0 -186
  396. mindspore/profiler/parser/minddata_pipeline_parser.py +0 -299
  397. mindspore/profiler/parser/op_intermediate_parser.py +0 -149
  398. mindspore/profiler/parser/optime_parser.py +0 -250
  399. mindspore/profiler/parser/profiler_info.py +0 -213
  400. mindspore/profiler/parser/step_trace_parser.py +0 -666
  401. {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/WHEEL +0 -0
  402. {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/entry_points.txt +0 -0
  403. {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/top_level.txt +0 -0
@@ -13,45 +13,41 @@
13
13
  # limitations under the License.
14
14
  # ============================================================================
15
15
  """Profiler Action Controller"""
16
+ __all__ = []
17
+
16
18
  from functools import partial
17
- from typing import Dict, Optional, Callable, Any
19
+ from typing import Optional, Callable, Any, Dict
18
20
 
19
21
  from mindspore.profiler.profiler_interface import ProfilerInterface
20
22
  from mindspore.profiler.schedule import ProfilerAction
21
-
22
23
  from mindspore import log as logger
23
24
 
24
- __all__ = []
25
-
26
25
 
27
26
  class ProfilerActionController:
28
27
  """
29
28
  A controller class for managing profiler actions and transitions.
30
29
 
31
30
  This class handles the actions and transitions between different profiler states.
32
- It uses two maps, abnormal_action_map and normal_action_map, to determine the actions
33
- to take based on the previous and current profiler actions.
31
+ It uses an action_map to determine the actions to take based on the previous and
32
+ current profiler actions.
34
33
 
35
34
  Attributes:
36
- profiler: The profiler instance associated with this controller.
37
35
  prof_interface (ProfilerInterface): The profiler interface instance.
38
36
  on_trace_ready (Optional[Callable[..., Any]]): A callback function to be called when the trace is ready.
39
- abnormal_action_map (Dict): A map of abnormal transitions and their corresponding actions.
40
- normal_action_map (Dict): A map of normal transitions and their corresponding actions.
37
+ action_map (Dict): A map of state transitions and their corresponding actions.
41
38
  """
42
39
 
43
40
  def __init__(self, prof_interface: ProfilerInterface, on_trace_ready: Optional[Callable[..., Any]] = None) -> None:
44
41
  """
45
- Initializes a new instance of ProfActionController.
42
+ Initializes a new instance of ProfilerActionController.
46
43
 
47
44
  Args:
48
45
  prof_interface (ProfilerInterface): The profiler interface instance.
49
46
  on_trace_ready (Optional[Callable[..., Any]]): A callback function to be called when the trace is ready.
50
47
  """
51
48
  self.prof_interface = prof_interface
52
- self.abnormal_action_map: Dict = self.init_abnormal_action_map()
53
- self.normal_action_map: Dict = self.init_normal_action_map()
54
49
  self.on_trace_ready = on_trace_ready
50
+ self.action_map = self._init_action_map()
55
51
 
56
52
  def _trace_ready(self):
57
53
  """
@@ -64,80 +60,34 @@ class ProfilerActionController:
64
60
 
65
61
  def transit_action(self, prev_action: ProfilerAction, current_action: ProfilerAction) -> None:
66
62
  """
67
- Handles actions between previous action and latter action
63
+ Handles actions between previous action and current action
68
64
 
69
65
  Args:
70
66
  prev_action: The previous state
71
- current_action: the latter state
72
- """
73
- # Check whether the action is in the abnormal map
74
- action_list = self.abnormal_action_map.get((prev_action, current_action), [])
75
- if not action_list:
76
- if isinstance(prev_action, ProfilerAction) and isinstance(current_action, ProfilerAction):
77
- # Check whether the action is in the normal map
78
- action_list = self.handle_normal_action(prev_action, current_action)
79
- if not action_list:
80
- return
81
- for action in action_list:
82
- action()
83
-
84
- def handle_normal_action(self, start_state: ProfilerAction, end_state: ProfilerAction) -> list:
67
+ current_action: the current state
85
68
  """
86
- Obtain the action in the normal state
69
+ # Get the action list for this state transition
70
+ action_list = self.action_map.get((prev_action, current_action))
87
71
 
88
- Args:
89
- start_state: The previous state
90
- end_state: the latter state
72
+ if action_list:
73
+ logger.info(f"ProfilerAction transition: {prev_action} -> {current_action}")
74
+ for action in action_list:
75
+ action()
91
76
 
92
- Returns:
93
- process_action list
94
- """
95
- process_action = []
96
- initial_state = start_state
97
-
98
- # Handle special case for ProfilerAction.RECORD_AND_SAVE to ProfilerAction.RECORD_AND_SAVE transition
99
- if start_state == ProfilerAction.RECORD_AND_SAVE and end_state == ProfilerAction.RECORD_AND_SAVE:
100
- process_action = [self.prof_interface.stop, self.prof_interface.finalize,
101
- self._trace_ready, self.prof_interface.clear, self.prof_interface.init,
102
- self.prof_interface.start]
103
- else:
104
- while start_state != end_state:
105
- process_action.extend(self.normal_action_map[start_state])
106
- start_state = ProfilerAction.get_by_value((start_state.value + 1) % len(ProfilerAction))
107
-
108
- # Handle special cases for NONE to NONE, WARM_UP to WARM_UP, RECORD to RECORD transitions
109
- if initial_state == start_state and initial_state != ProfilerAction.RECORD_AND_SAVE:
110
- process_action = []
111
-
112
- return process_action
113
-
114
- def init_normal_action_map(self) -> dict:
77
+ def _init_action_map(self) -> Dict:
115
78
  """
116
- Generate a normal action map
79
+ Initialize the action map for state transitions.
117
80
 
118
81
  Returns:
119
- normal_action_map map
82
+ Dict: A map of state transitions and their corresponding actions.
120
83
  """
121
- return {
122
- ProfilerAction.NONE: [self.prof_interface.init],
123
- ProfilerAction.WARM_UP: [self.prof_interface.start],
124
- ProfilerAction.RECORD: [],
125
- ProfilerAction.RECORD_AND_SAVE: [
126
- self.prof_interface.stop,
127
- self.prof_interface.finalize,
128
- self._trace_ready,
129
- self.prof_interface.clear
130
- ]
131
- }
132
-
133
- def init_abnormal_action_map(self) -> dict:
134
- """
135
- Generate a abnormal action map
84
+ action_map = {
85
+ (ProfilerAction.NONE, ProfilerAction.NONE): [],
86
+ (ProfilerAction.NONE, ProfilerAction.WARM_UP): [self.prof_interface.init],
87
+ (ProfilerAction.NONE, ProfilerAction.RECORD): [self.prof_interface.init, self.prof_interface.start],
88
+ (ProfilerAction.NONE, ProfilerAction.RECORD_AND_SAVE): [self.prof_interface.init,
89
+ self.prof_interface.start],
136
90
 
137
- Returns:
138
- abnormal_action_map map
139
- """
140
- return {
141
91
  (ProfilerAction.WARM_UP, ProfilerAction.NONE): [
142
92
  partial(logger.warning, "Incorrect schedule: WARMUP followed by NONE"),
143
93
  self.prof_interface.start,
@@ -145,6 +95,10 @@ class ProfilerActionController:
145
95
  self.prof_interface.finalize,
146
96
  self.prof_interface.clear
147
97
  ],
98
+ (ProfilerAction.WARM_UP, ProfilerAction.WARM_UP): [],
99
+ (ProfilerAction.WARM_UP, ProfilerAction.RECORD): [self.prof_interface.start],
100
+ (ProfilerAction.WARM_UP, ProfilerAction.RECORD_AND_SAVE): [self.prof_interface.start],
101
+
148
102
  (ProfilerAction.RECORD, ProfilerAction.NONE): [
149
103
  partial(logger.warning, "Incorrect schedule: RECORD followed by NONE"),
150
104
  self.prof_interface.stop,
@@ -157,7 +111,40 @@ class ProfilerActionController:
157
111
  self.prof_interface.finalize,
158
112
  self.prof_interface.clear
159
113
  ],
160
- # used for exit action
114
+ (ProfilerAction.RECORD, ProfilerAction.RECORD): [],
115
+ (ProfilerAction.RECORD, ProfilerAction.RECORD_AND_SAVE): [],
116
+
117
+ (ProfilerAction.RECORD_AND_SAVE, ProfilerAction.NONE): [
118
+ self.prof_interface.stop,
119
+ self.prof_interface.finalize,
120
+ self._trace_ready,
121
+ self.prof_interface.clear
122
+ ],
123
+ (ProfilerAction.RECORD_AND_SAVE, ProfilerAction.WARM_UP): [
124
+ self.prof_interface.stop,
125
+ self.prof_interface.finalize,
126
+ self._trace_ready,
127
+ self.prof_interface.clear,
128
+ self.prof_interface.init,
129
+ ],
130
+ (ProfilerAction.RECORD_AND_SAVE, ProfilerAction.RECORD): [
131
+ self.prof_interface.stop,
132
+ self.prof_interface.finalize,
133
+ self._trace_ready,
134
+ self.prof_interface.clear,
135
+ self.prof_interface.init,
136
+ self.prof_interface.start
137
+ ],
138
+ (ProfilerAction.RECORD_AND_SAVE, ProfilerAction.RECORD_AND_SAVE): [
139
+ self.prof_interface.stop,
140
+ self.prof_interface.finalize,
141
+ self._trace_ready,
142
+ self.prof_interface.clear,
143
+ self.prof_interface.init,
144
+ self.prof_interface.start
145
+ ],
146
+
147
+ # Used for exit action
161
148
  (ProfilerAction.WARM_UP, None): [
162
149
  partial(logger.warning,
163
150
  "Incorrect schedule: Stop profiler while current state is WARMUP "
@@ -185,3 +172,4 @@ class ProfilerActionController:
185
172
  self.prof_interface.clear
186
173
  ]
187
174
  }
175
+ return action_map
@@ -13,12 +13,12 @@
13
13
  # limitations under the License.
14
14
  # ============================================================================
15
15
  """Profiler Schedule"""
16
+ __all__ = ["ProfilerAction", "Schedule"]
17
+
16
18
  from enum import Enum
17
19
 
18
20
  from mindspore import log as logger
19
21
 
20
- __all__ = ["ProfilerAction", "Schedule"]
21
-
22
22
 
23
23
  class ProfilerAction(Enum):
24
24
  """
@@ -83,8 +83,14 @@ class Schedule:
83
83
  must be greater than or equal to 0. Default value: ``0``.
84
84
  repeat (int, optional): The number of times to repeat the cycle.
85
85
  If repeat is set to 0, the Profiler will determine the repeat value based on the number of times the model
86
- is trained, which will generate one more performance data with incomplete collection. The data in the last
87
- step is abnormal data that users do not need to pay attention to. Default value: ``0``.
86
+ is trained, for example, if the total training steps are 100, wait+active+warmup=10, skip_first=10,
87
+ Then repeat=(100-10)/10=9, indicating that the execution is repeated 9 timeswhich will
88
+ generate one more performance data with incomplete collection. The data in the last step is abnormal data
89
+ that users do not need to pay attention to. Suggest configuring integers greater than 0. When using
90
+ cluster analysis tools or MindStudio Insight to view, it is recommended to configure it as 1;
91
+ If the setting is greater than 1, the collected performance data folder needs to be divided into repeat and
92
+ other parts, placed in different folders for re-parsing, and classified according to the timestamp order in
93
+ the folder name. Default value: ``0``.
88
94
  skip_first (int, optional): The number of steps to skip at the beginning. Must be greater than or equal to 0.
89
95
  Default value: ``0``
90
96
 
@@ -16,6 +16,7 @@
16
16
  MindSpore rewrite configurations.
17
17
  """
18
18
 
19
+
19
20
  def clear_caches():
20
21
  """clear rewrite caches"""
21
22
  from ..parsers import AssignParser
@@ -222,6 +222,7 @@ class ClassNamer(Namer):
222
222
 
223
223
  super(ClassNamer, self).add_name(name + self._prefix)
224
224
 
225
+
225
226
  class FunctionNamer(Namer):
226
227
  """
227
228
  Used for unique-ing function name in a network.
@@ -34,6 +34,7 @@ _ms_cells_to_subtree = False
34
34
  # Paths of modules which will not be considered as third party module
35
35
  _ignore_third_party_paths = []
36
36
 
37
+
37
38
  def is_subtree(cls_inst):
38
39
  """Determine whether 'cls_inst' is a subtree."""
39
40
  cls_name = type(cls_inst).__name__
@@ -124,9 +124,14 @@ class Node:
124
124
  self._init_cls = None
125
125
 
126
126
  @classmethod
127
- def create_call_method(cls, ast_node: Optional[ast.AST], targets: [Union[ScopedValue, str]],
128
- func_name: Union[ScopedValue, str], args: [ScopedValue] = None,
129
- kwargs: {str: ScopedValue}=None, name: str = ""):
127
+ def create_call_method(
128
+ cls,
129
+ ast_node: Optional[ast.AST],
130
+ targets: [Union[ScopedValue, str]],
131
+ func_name: Union[ScopedValue, str],
132
+ args: [ScopedValue] = None,
133
+ kwargs: {str: ScopedValue} = None, # pylint: disable=bad-whitespace
134
+ name: str = ""):
130
135
  """
131
136
  Class method of Node. Instantiate an instance of node whose type is CallCell. A CallCell node represents an
132
137
  invoking to cell-op.
@@ -227,8 +232,12 @@ class Node:
227
232
  return cls(NodeType.MathOps, ast_node, targets, op_type, args, None, name, None)
228
233
 
229
234
  @staticmethod
230
- def _create_call_function(function: FunctionType, targets: [Union[ScopedValue, str]], args: [ScopedValue] = None,
231
- kwargs: {str: ScopedValue}=None):
235
+ def _create_call_function(
236
+ function: FunctionType,
237
+ targets: [Union[ScopedValue, str]],
238
+ args: [ScopedValue] = None,
239
+ kwargs: {str: ScopedValue} = None # pylint: disable=bad-whitespace
240
+ ):
232
241
  """
233
242
  Create a node that corresponds to a function call.
234
243
 
@@ -275,9 +284,14 @@ class Node:
275
284
  return CallFunction(targets, func_name, args, kwargs, node_name, ast_node, None, None, func_obj, False)
276
285
 
277
286
  @staticmethod
278
- def create_call_op(op: Union[Cell, Primitive], ast_node: Optional[ast.AST], targets: [Union[ScopedValue, str]],
279
- args: [ScopedValue] = None, kwargs: {str: ScopedValue}=None, node_name: str = "",
280
- is_sub_net: bool = False):
287
+ def create_call_op(
288
+ op: Union[Cell, Primitive],
289
+ ast_node: Optional[ast.AST],
290
+ targets: [Union[ScopedValue, str]],
291
+ args: [ScopedValue] = None,
292
+ kwargs: {str: ScopedValue} = None, # pylint: disable=bad-whitespace
293
+ node_name: str = "",
294
+ is_sub_net: bool = False):
281
295
  """
282
296
  Static method of Node. Instantiate an instance of node whose type is `CallCell` or `CallPrimitive`.
283
297
  If op is custom defined, it is treated by TreeNode.
@@ -325,9 +339,15 @@ class Node:
325
339
  return Node.create_call_buildin_op(op, ast_node, new_targets, func_name, args, kwargs, node_name)
326
340
 
327
341
  @classmethod
328
- def create_call_buildin_op(cls, op: Union[Cell, Primitive], ast_node: Optional[ast.AST], targets: [ScopedValue],
329
- func_name: ScopedValue, args: [ScopedValue] = None, kwargs: {str: ScopedValue}=None,
330
- node_name: str = ""):
342
+ def create_call_buildin_op(
343
+ cls,
344
+ op: Union[Cell, Primitive],
345
+ ast_node: Optional[ast.AST],
346
+ targets: [ScopedValue],
347
+ func_name: ScopedValue,
348
+ args: [ScopedValue] = None,
349
+ kwargs: {str: ScopedValue} = None, # pylint: disable=bad-whitespace
350
+ node_name: str = ""):
331
351
  """
332
352
  Class method of Node. Instantiate an instance of node whose type is `CallCell` or `CallPrimitive`.
333
353
  A `CallCell` node represents an invoking to cell-op.
@@ -46,7 +46,7 @@ class AssignParser(Parser):
46
46
  """Parse ast.Assign in construct function to node of SymbolTree."""
47
47
 
48
48
  # Types for creating Cell Container node
49
- types_for_cell_container = [SequentialCell,]
49
+ types_for_cell_container = [SequentialCell]
50
50
  # If mindspore built-in function to be parsered or skipped
51
51
  _skip_ms_function = False
52
52
  # Functions in black list will not be parsed
@@ -1790,7 +1790,7 @@ class SymbolTree(Observer, Observable, NodeManager):
1790
1790
  if idx > 0:
1791
1791
  name_need_suffix[name] = suffix_alias(alias, idx)
1792
1792
  break
1793
- elif ast_node.module.startswith(path):
1793
+ if ast_node.module.startswith(path):
1794
1794
  # e.g. origin code is 'from a.b import A' and new code is 'from a.b.c import A'
1795
1795
  # then we just need to update name to A_{idx}
1796
1796
  if idx > 0:
@@ -124,9 +124,9 @@ class GPUEnvChecker(EnvChecker):
124
124
  for path in self.cuda_lib_path:
125
125
  real_path = glob.glob(path + "/lib*/libcudart.so.*.*.*")
126
126
  # /usr/lib/x86_64-linux-gnu is a default dir for cuda10.1 on ubuntu.
127
- if real_path == []:
127
+ if not real_path:
128
128
  real_path = glob.glob(path + "/x86_64-linux-gnu/libcudart.so.*.*.*")
129
- if real_path == []:
129
+ if not real_path:
130
130
  continue
131
131
  ls_cudart = subprocess.run(["ls", real_path[0]], timeout=10, text=True,
132
132
  capture_output=True, check=False)
@@ -258,7 +258,7 @@ class AscendEnvChecker(EnvChecker):
258
258
 
259
259
  def __init__(self, library_path):
260
260
  self.library_path = library_path
261
- self.version = ["7.6", "7.7"]
261
+ self.version = ["7.7", "7.8", "8.2"]
262
262
 
263
263
  # env
264
264
  self.path = os.getenv("PATH")
@@ -293,7 +293,7 @@ class AscendEnvChecker(EnvChecker):
293
293
 
294
294
  cur_version = self._read_version(self.compiler_version)
295
295
  custom_version_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
296
- "../lib/plugin/ascend/custom_ascendc_910/version.info")
296
+ "../lib/plugin/ascend/custom_ascendc_910b/version.info")
297
297
  with open(custom_version_path, 'r') as f:
298
298
  all_info = f.readlines()
299
299
  for line in all_info:
@@ -375,18 +375,15 @@ class AscendEnvChecker(EnvChecker):
375
375
  curr_path = os.path.realpath(os.path.dirname(__file__))
376
376
  cust_aicpu_path = os.path.realpath(os.path.join(curr_path, "../lib/plugin/ascend/custom_aicpu_ops"))
377
377
  cust_aicore_path = os.path.realpath(os.path.join(curr_path, "../lib/plugin/ascend/custom_aicore_ops"))
378
- cust_ascendc_ascend910_path = os.path.realpath(
379
- os.path.join(curr_path, "../lib/plugin/ascend/custom_ascendc_910"))
380
378
  cust_ascendc_ascend910b_path = os.path.realpath(
381
379
  os.path.join(curr_path, "../lib/plugin/ascend/custom_ascendc_910b"))
382
380
  if os.getenv('ASCEND_CUSTOM_OPP_PATH'):
383
381
  os.environ['ASCEND_CUSTOM_OPP_PATH'] = os.environ['ASCEND_CUSTOM_OPP_PATH'] + ":" + \
384
- cust_ascendc_ascend910_path + ":" + cust_ascendc_ascend910b_path + \
385
- ":" + cust_aicore_path + ":" + cust_aicpu_path
386
- else:
387
- os.environ['ASCEND_CUSTOM_OPP_PATH'] = cust_ascendc_ascend910_path + ":" + \
388
382
  cust_ascendc_ascend910b_path + ":" + cust_aicore_path + ":" + \
389
383
  cust_aicpu_path
384
+ else:
385
+ os.environ['ASCEND_CUSTOM_OPP_PATH'] = cust_ascendc_ascend910b_path + ":" + cust_aicore_path + ":" + \
386
+ cust_aicpu_path
390
387
  # Ignore ge infer missing error. To be removed after infers are completed.
391
388
  os.environ['FAST_IGNORE_INFER_ERROR'] = "1"
392
389
  os.environ['IGNORE_INFER_ERROR'] = "1"
@@ -18,8 +18,8 @@ The runtime interface.
18
18
  """
19
19
 
20
20
  from mindspore.runtime.executor import launch_blocking, dispatch_threads_num, set_cpu_affinity, set_kernel_launch_group
21
- from mindspore.runtime.memory import set_memory, memory_stats, memory_reserved, max_memory_reserved, empty_cache,\
22
- reset_peak_memory_stats, memory_summary, memory_allocated,\
21
+ from mindspore.runtime.memory import set_memory, memory_stats, memory_reserved, max_memory_reserved, empty_cache, \
22
+ memory_replay, reset_peak_memory_stats, memory_summary, memory_allocated, \
23
23
  max_memory_allocated, reset_max_memory_reserved, reset_max_memory_allocated
24
24
  from mindspore.runtime.stream import Stream, synchronize, set_cur_stream, current_stream, \
25
25
  default_stream, communication_stream, StreamCtx
@@ -29,9 +29,9 @@ from .executor import launch_blocking
29
29
  __all__ = [
30
30
  "launch_blocking", "dispatch_threads_num", "set_cpu_affinity", "set_kernel_launch_group",
31
31
  "Stream", "communication_stream", "synchronize", "set_cur_stream", "current_stream", "default_stream", "StreamCtx",
32
- "set_memory", "memory_stats", "memory_reserved", "max_memory_reserved", "empty_cache", "reset_peak_memory_stats",
33
- "memory_summary", "memory_allocated", "max_memory_allocated", "reset_max_memory_reserved",
34
- "reset_max_memory_allocated", "Event"
32
+ "set_memory", "memory_stats", "memory_reserved", "max_memory_reserved", "empty_cache", "memory_replay",
33
+ "reset_peak_memory_stats", "memory_summary", "memory_allocated", "max_memory_allocated",
34
+ "reset_max_memory_reserved", "reset_max_memory_allocated", "Event"
35
35
  ]
36
36
 
37
37
  __all__.sort()
@@ -16,7 +16,6 @@
16
16
  from mindspore._c_expression import Event as Event_
17
17
  from mindspore._c_expression import Stream as Stream_
18
18
  from mindspore._c_expression import current_stream as current_stream_
19
- from mindspore import _checkparam as Validator
20
19
  from .device import _is_supported
21
20
 
22
21
  function_event_status = {'Event': False, 'wait': False}
@@ -71,9 +70,16 @@ class Event(Event_):
71
70
  function_event_status['Event'] = True
72
71
  if not _is_supported():
73
72
  return
74
- # pylint: disable=useless-super-delegation
75
- Validator.check_bool(enable_timing, "enable_timing", "Event")
76
- Validator.check_bool(blocking, "blocking", "Event")
73
+ if not isinstance(enable_timing, bool):
74
+ raise TypeError(
75
+ f"For 'Event', the 'enable_timing' must be a bool,"
76
+ f" but got {type(enable_timing).__name__}."
77
+ )
78
+ if not isinstance(blocking, bool):
79
+ raise TypeError(
80
+ f"For 'Event', the 'blocking' must be a bool,"
81
+ f" but got {type(blocking).__name__}."
82
+ )
77
83
  super().__init__(enable_timing, blocking)
78
84
 
79
85
  def record(self, stream=None):
@@ -15,7 +15,8 @@
15
15
 
16
16
  """Executor manager interfaces."""
17
17
  from mindspore._c_expression import RuntimeConf
18
- from mindspore.runtime.thread_bind_core import _get_cpu_affinity_policy
18
+ from mindspore.runtime.thread_bind_core import _get_cpu_affinity_strategy, _validate_affinity_cpu_list, \
19
+ _validate_module_cpu_index, _adapt_to_dict
19
20
  from mindspore._checkparam import args_type_check
20
21
  from mindspore import _checkparam as Validator
21
22
  from mindspore import log as logger
@@ -64,57 +65,64 @@ def dispatch_threads_num(threads_num):
64
65
  return RuntimeConf.get_instance().set_dispatch_threads_num(threads_num)
65
66
 
66
67
 
67
- @args_type_check(enable_affinity=bool, affinity_cpu_list=dict)
68
- def set_cpu_affinity(enable_affinity, affinity_cpu_list=None):
68
+ def set_cpu_affinity(enable_affinity, affinity_cpu_list=None, module_to_cpu_dict=None):
69
69
  """
70
- Enable thread-level core binding to assign specific CPU cores to MindSpore's main modules (main thread, pynative,
71
- runtime, minddata), to prevent unstable performance caused by MindSpore's threads seizing CPU.
70
+ Enable thread-level core binding to allocate specific CPU cores for key MindSpore modules (main thread, pynative,
71
+ runtime, and minddata), preventing performance instability caused by CPU core contention among MindSpore threads.
72
72
 
73
73
  Note:
74
- - Provides two binding modes: 1. Automatically generates binding policies based on available CPUs, NUMA nodes,
75
- and device resources in the environment to bind cores at thread level. 2. Thread-level bonding based on
76
- customized bonding policies passed in by `affinity_cpu_list`.
77
-
78
- - The automated bind-core policy generation scenario invokes system commands to obtain CPU, NUMA node, and
74
+ - Flexible Core Binding Configuration:
75
+
76
+ 1. When `affinity_cpu_list` is not specified, the process automatically determines the CPU affinity range
77
+ based on available CPU cores, NUMA nodes, and device resources in the environment.
78
+ 2. When `affinity_cpu_list` is specified, the process manually binds to the CPU range defined in
79
+ `affinity_cpu_list`.
80
+ 3. When `module_to_cpu_dict` is not specified, the default bind-core strategy assigns the CPU
81
+ cores to the `"main"` module.
82
+ 4. When `module_to_cpu_dict` is specified, the process manually binds each module to CPU ranges as
83
+ defined in `module_to_cpu_dict`.
84
+ - The automated bind-core strategy generation scenario invokes system commands to obtain CPU, NUMA node, and
79
85
  device resources on the environment, and some commands cannot be executed successfully due to environment
80
- differences; the automated bind-core policy generated will vary according to the resources available on the
86
+ differences; the automated bind-core strategy generated will vary according to the resources available on the
81
87
  environment:
82
88
 
83
89
  1. `cat /sys/fs/cgroup/cpuset/cpuset.cpus`, to obtain the available CPU resources on the environment; if the
84
90
  execution of this command fails, the bind-core function will not take effect.
85
91
  2. `npu-smi info -m`, get the available NPU resources on the environment; if the execution of this command
86
- fails, the bind-core policy will be generated only based on the available CPU resources,
92
+ fails, the bind-core strategy will be generated only based on the available CPU resources,
87
93
  without considering the device affinity.
88
94
  3. `npu-smi info -t board -i {NPU_ID} -c {CHIP_ID}`, get NPU details based on the logical ID of the device;
89
- if the execution of this command fails, the bind-core policy is generated based on the available CPU
95
+ if the execution of this command fails, the bind-core strategy is generated based on the available CPU
90
96
  resources only, regardless of device affinity.
91
97
  4. `lspci -s {PCIe_No} -vvv`, get the hardware information of the device on the environment; if the execution
92
- of this command fails, the bind-core policy is generated only based on the available CPU resources,
98
+ of this command fails, the bind-core strategy is generated only based on the available CPU resources,
93
99
  without considering the device affinity.
94
100
  5. `lscpu`, get information about CPUs and NUMA nodes on the environment; if the execution of this command
95
- fails, only the available CPU resources are used to generate the bind-core policy, without considering
101
+ fails, only the available CPU resources are used to generate the bind-core strategy, without considering
96
102
  the device affinity.
97
103
 
98
104
  Args:
99
- enable_affinity (bool): Switches on/off thread-level core binding.
100
- affinity_cpu_list (dict, optional): Specifies a customized bind-core policy. The key to be passed
101
- into the dict needs to be in string ``"deviceX"`` format, and the value needs to be in list
102
- ``["cpuidX-cpuidY"]`` format. Default: ``None``, i.e., use the bind-core policy generated automatically
103
- based on the environment. It is allowed to pass the empty dict ``{}``, in which case the bind-core
104
- policy generated automatically based on the environment will be used.
105
+ enable_affinity (bool): Enables/disables thread-level core binding.
106
+ affinity_cpu_list (list, optional): Manually specifies the CPU affinity range for the process. Format:
107
+ `["cpuidX-cpuidY"]` (e.g., ``["0-3", "8-11"]``). Default: ``None`` (uses auto-generated binding strategy
108
+ based on system resources). Passing an empty list `[]` behaves the same as ``None``.
109
+ module_to_cpu_dict (dict, optional): Customizes core binding for specific modules. Valid keys
110
+ (module names) are ``"main"``, ``"runtime"``, ``"pynative"``, ``"minddata"``. Valid value is a list
111
+ of ``int`` indices representing CPU cores (e.g., ``{"main": [0,1], "minddata": [6,7]}``).
112
+ Default: ``None`` (automatically binds core for module `"main"`). Passing an empty dict `{}`
113
+ behaves the same as ``None``.
105
114
 
106
115
  Raises:
107
- TypeError: The parameter `enable_affinity` is not a boolean.
108
- TypeError: The parameter `affinity_cpu_list` is neither a dictionary nor a ``None``.
109
- ValueError: The key of parameter `affinity_cpu_list` is not a string.
110
- ValueError: The key of parameter `affinity_cpu_list` is not in ``"deviceX"`` format.
111
- ValueError: The parameter `affinity_cpu_list` has a value that is not a list.
112
- ValueError: The element in value of parameter `affinity_cpu_list` is not a string.
113
- ValueError: The element in value for parameter `affinity_cpu_list` does not match ``["cpuidX-cpuidY"]``.
114
- RuntimeError: Automatically generated binding policy or customized binding policy scenario where the number
115
- of CPU cores assigned to each device is less than 7.
116
- RuntimeError: A custom-specified binding policy scenario where the CPU assigned to a device is not
117
- available in the environment.
116
+ TypeError: The `enable_affinity` parameter is not a boolean.
117
+ TypeError: The `affinity_cpu_list` parameter is neither a list nor ``None``.
118
+ TypeError: An element in `affinity_cpu_list` is not a string.
119
+ ValueError: An element in `affinity_cpu_list` does not follow the ``["cpuidX-cpuidY"]`` format.
120
+ TypeError: The `module_to_cpu_dict` parameter is neither a dictionary nor ``None``.
121
+ TypeError: A key in `module_to_cpu_dict` is not a string.
122
+ TypeError: A value in `module_to_cpu_dict` is not a list.
123
+ ValueError: An element in `module_to_cpu_dict` values is not a non-negative integer.
124
+ RuntimeError: In custom core binding scenarios, the specified CPU cores for a device are unavailable
125
+ in the environment.
118
126
  RuntimeError: The `mindspore.runtime.set_cpu_affinity` API is called repeatedly.
119
127
 
120
128
  Examples:
@@ -124,24 +132,31 @@ def set_cpu_affinity(enable_affinity, affinity_cpu_list=None):
124
132
  >>>
125
133
  >>> import mindspore as ms
126
134
  >>> ms.set_device("Ascend", 1)
127
- >>> ms.runtime.set_cpu_affinity(True, {"device0":["0-9"],"device1":["10-15","20-29"],"device2":["35-45"]})
135
+ >>> ms.runtime.set_cpu_affinity(True, ["10-19", "23-40"])
136
+ >>>
137
+ >>> import mindspore as ms
138
+ >>> ms.set_device("Ascend", 1)
139
+ >>> ms.runtime.set_cpu_affinity(True, ["10-19", "23-40"], {"main": [0,1,2,3], "runtime": [4,5,6]})
128
140
  """
141
+ affinity_cpu_list = _adapt_to_dict(affinity_cpu_list)
142
+ if affinity_cpu_list is False:
143
+ return
144
+
145
+ _validate_affinity_cpu_list(affinity_cpu_list)
146
+ _validate_module_cpu_index(module_to_cpu_dict)
147
+
129
148
  if RuntimeConf.get_instance().is_thread_bind_core_configured():
130
149
  raise RuntimeError("The 'mindspore.runtime.set_cpu_affinity' cannot be set repeatedly.")
131
- if enable_affinity:
132
- module_bind_core_policy, bind_policy_flag = _get_cpu_affinity_policy(affinity_cpu_list)
133
- if not module_bind_core_policy:
134
- logger.warning("set_cpu_affinity is not enabled because the environment does not meet the "
135
- "basic conditions for binding core.")
136
- RuntimeConf.get_instance().set_thread_bind_core_configured()
137
- return
138
- if bind_policy_flag:
139
- RuntimeConf.get_instance().thread_bind_core_with_policy(module_bind_core_policy)
140
- else:
141
- RuntimeConf.get_instance().thread_bind_core(module_bind_core_policy)
142
- else:
150
+ if not enable_affinity:
151
+ RuntimeConf.get_instance().set_thread_bind_core_configured()
152
+ return
153
+ module_bind_core_strategy = _get_cpu_affinity_strategy(affinity_cpu_list, module_to_cpu_dict)
154
+ if not module_bind_core_strategy:
155
+ logger.warning("set_cpu_affinity is not enabled because the environment does not meet the "
156
+ "basic conditions for binding core.")
143
157
  RuntimeConf.get_instance().set_thread_bind_core_configured()
144
158
  return
159
+ RuntimeConf.get_instance().thread_bind_core(module_bind_core_strategy)
145
160
 
146
161
 
147
162
  @args_type_check(thread_num=int, kernel_group_num=int)