mindspore 2.4.1__cp310-cp310-win_amd64.whl → 2.5.0__cp310-cp310-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 (372) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/__init__.py +8 -3
  3. mindspore/_c_dataengine.cp310-win_amd64.pyd +0 -0
  4. mindspore/_c_expression.cp310-win_amd64.pyd +0 -0
  5. mindspore/_c_mindrecord.cp310-win_amd64.pyd +0 -0
  6. mindspore/_checkparam.py +0 -5
  7. mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
  8. mindspore/_extends/parse/compile_config.py +64 -0
  9. mindspore/_extends/parse/deprecated/__init__.py +0 -0
  10. mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +375 -0
  11. mindspore/_extends/parse/parser.py +23 -5
  12. mindspore/_extends/parse/standard_method.py +123 -27
  13. mindspore/_extends/pijit/pijit_func_white_list.py +1 -1
  14. mindspore/amp.py +7 -1
  15. mindspore/avcodec-59.dll +0 -0
  16. mindspore/avdevice-59.dll +0 -0
  17. mindspore/avfilter-8.dll +0 -0
  18. mindspore/avformat-59.dll +0 -0
  19. mindspore/avutil-57.dll +0 -0
  20. mindspore/boost/boost_cell_wrapper.py +136 -41
  21. mindspore/common/__init__.py +3 -1
  22. mindspore/common/_register_for_tensor.py +0 -1
  23. mindspore/common/_stub_tensor.py +25 -4
  24. mindspore/common/_tensor_cpp_method.py +17 -0
  25. mindspore/common/_tensor_docs.py +6132 -0
  26. mindspore/common/api.py +99 -25
  27. mindspore/common/dtype.py +34 -34
  28. mindspore/common/dump.py +2 -1
  29. mindspore/common/file_system.py +8 -1
  30. mindspore/common/generator.py +2 -0
  31. mindspore/common/hook_handle.py +3 -1
  32. mindspore/common/initializer.py +3 -4
  33. mindspore/common/lazy_inline.py +8 -2
  34. mindspore/common/mindir_util.py +10 -2
  35. mindspore/common/parameter.py +30 -27
  36. mindspore/common/tensor.py +713 -1337
  37. mindspore/communication/__init__.py +1 -1
  38. mindspore/communication/_comm_helper.py +10 -0
  39. mindspore/communication/comm_func.py +215 -173
  40. mindspore/communication/management.py +23 -20
  41. mindspore/context.py +292 -193
  42. mindspore/dataset/__init__.py +23 -19
  43. mindspore/dataset/callback/ds_callback.py +2 -1
  44. mindspore/dataset/core/config.py +84 -3
  45. mindspore/dataset/engine/cache_admin.py +3 -3
  46. mindspore/dataset/engine/cache_client.py +5 -4
  47. mindspore/dataset/engine/datasets.py +192 -149
  48. mindspore/dataset/engine/datasets_audio.py +14 -0
  49. mindspore/dataset/engine/datasets_standard_format.py +28 -11
  50. mindspore/dataset/engine/datasets_text.py +38 -1
  51. mindspore/dataset/engine/datasets_user_defined.py +125 -65
  52. mindspore/dataset/engine/datasets_vision.py +81 -8
  53. mindspore/dataset/engine/iterators.py +281 -63
  54. mindspore/dataset/engine/obs/util.py +8 -0
  55. mindspore/dataset/engine/queue.py +40 -0
  56. mindspore/dataset/engine/samplers.py +26 -2
  57. mindspore/dataset/engine/serializer_deserializer.py +1 -1
  58. mindspore/dataset/engine/validators.py +43 -11
  59. mindspore/dataset/transforms/py_transforms_util.py +17 -0
  60. mindspore/dataset/transforms/transforms.py +29 -12
  61. mindspore/dataset/vision/validators.py +1 -2
  62. mindspore/device_context/__init__.py +21 -0
  63. mindspore/device_context/ascend/__init__.py +25 -0
  64. mindspore/device_context/ascend/device.py +72 -0
  65. mindspore/device_context/ascend/op_debug.py +94 -0
  66. mindspore/device_context/ascend/op_precision.py +193 -0
  67. mindspore/device_context/ascend/op_tuning.py +127 -0
  68. mindspore/device_context/cpu/__init__.py +25 -0
  69. mindspore/device_context/cpu/device.py +62 -0
  70. mindspore/device_context/cpu/op_tuning.py +43 -0
  71. mindspore/device_context/gpu/__init__.py +21 -0
  72. mindspore/device_context/gpu/device.py +70 -0
  73. mindspore/device_context/gpu/op_precision.py +67 -0
  74. mindspore/device_context/gpu/op_tuning.py +175 -0
  75. mindspore/device_manager.py +134 -0
  76. mindspore/dnnl.dll +0 -0
  77. mindspore/experimental/llm_boost/__init__.py +3 -2
  78. mindspore/experimental/llm_boost/ascend_native/__init__.py +22 -0
  79. mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +211 -0
  80. mindspore/experimental/llm_boost/ascend_native/llm_boost.py +52 -0
  81. mindspore/experimental/llm_boost/atb/boost_base.py +239 -64
  82. mindspore/experimental/llm_boost/atb/llama_boost.py +52 -30
  83. mindspore/experimental/llm_boost/atb/qwen_boost.py +47 -24
  84. mindspore/experimental/llm_boost/register.py +1 -0
  85. mindspore/experimental/optim/adadelta.py +26 -22
  86. mindspore/experimental/optim/adam.py +3 -0
  87. mindspore/experimental/optim/lr_scheduler.py +33 -24
  88. mindspore/experimental/optim/radam.py +33 -30
  89. mindspore/hal/device.py +28 -0
  90. mindspore/hal/event.py +17 -0
  91. mindspore/hal/memory.py +94 -3
  92. mindspore/hal/stream.py +91 -6
  93. mindspore/include/api/context.h +1 -2
  94. mindspore/include/dataset/constants.h +2 -2
  95. mindspore/jpeg62.dll +0 -0
  96. mindspore/log.py +12 -0
  97. mindspore/mindrecord/__init__.py +1 -1
  98. mindspore/mindrecord/config.py +17 -316
  99. mindspore/mindrecord/filereader.py +1 -9
  100. mindspore/mindrecord/filewriter.py +5 -15
  101. mindspore/mindrecord/mindpage.py +1 -9
  102. mindspore/mindspore_backend.dll +0 -0
  103. mindspore/mindspore_common.dll +0 -0
  104. mindspore/mindspore_core.dll +0 -0
  105. mindspore/mindspore_glog.dll +0 -0
  106. mindspore/mindspore_ops.dll +0 -0
  107. mindspore/mint/__init__.py +824 -218
  108. mindspore/mint/distributed/__init__.py +66 -4
  109. mindspore/mint/distributed/distributed.py +2594 -44
  110. mindspore/mint/linalg/__init__.py +6 -0
  111. mindspore/mint/nn/__init__.py +473 -14
  112. mindspore/mint/nn/functional.py +486 -11
  113. mindspore/mint/nn/layer/__init__.py +17 -4
  114. mindspore/mint/nn/layer/_functions.py +330 -0
  115. mindspore/mint/nn/layer/activation.py +169 -1
  116. mindspore/mint/nn/layer/basic.py +123 -0
  117. mindspore/mint/nn/layer/conv.py +727 -0
  118. mindspore/mint/nn/layer/normalization.py +215 -19
  119. mindspore/mint/nn/layer/padding.py +797 -0
  120. mindspore/mint/nn/layer/pooling.py +170 -0
  121. mindspore/mint/optim/__init__.py +2 -1
  122. mindspore/mint/optim/adam.py +223 -0
  123. mindspore/mint/optim/adamw.py +26 -19
  124. mindspore/mint/special/__init__.py +2 -1
  125. mindspore/multiprocessing/__init__.py +5 -0
  126. mindspore/nn/__init__.py +2 -0
  127. mindspore/nn/cell.py +142 -21
  128. mindspore/nn/dynamic_lr.py +2 -1
  129. mindspore/nn/layer/activation.py +6 -6
  130. mindspore/nn/layer/basic.py +35 -25
  131. mindspore/nn/layer/channel_shuffle.py +3 -3
  132. mindspore/nn/layer/conv.py +3 -0
  133. mindspore/nn/layer/embedding.py +3 -3
  134. mindspore/nn/layer/normalization.py +8 -7
  135. mindspore/nn/layer/padding.py +4 -3
  136. mindspore/nn/layer/pooling.py +55 -23
  137. mindspore/nn/layer/rnn_cells.py +1 -1
  138. mindspore/nn/layer/rnns.py +2 -1
  139. mindspore/nn/layer/timedistributed.py +5 -5
  140. mindspore/nn/layer/transformer.py +48 -26
  141. mindspore/nn/learning_rate_schedule.py +5 -3
  142. mindspore/nn/loss/loss.py +31 -36
  143. mindspore/nn/optim/ada_grad.py +1 -0
  144. mindspore/nn/optim/adadelta.py +2 -2
  145. mindspore/nn/optim/adam.py +1 -1
  146. mindspore/nn/optim/lars.py +1 -4
  147. mindspore/nn/optim/optimizer.py +1 -1
  148. mindspore/nn/optim/rprop.py +2 -2
  149. mindspore/nn/optim/thor.py +2 -1
  150. mindspore/nn/utils/__init__.py +22 -0
  151. mindspore/nn/utils/init.py +73 -0
  152. mindspore/nn/wrap/cell_wrapper.py +4 -6
  153. mindspore/nn/wrap/loss_scale.py +3 -4
  154. mindspore/numpy/array_creations.py +60 -62
  155. mindspore/numpy/array_ops.py +148 -143
  156. mindspore/numpy/logic_ops.py +41 -42
  157. mindspore/numpy/math_ops.py +361 -359
  158. mindspore/numpy/utils.py +16 -16
  159. mindspore/numpy/utils_const.py +4 -4
  160. mindspore/opencv_core452.dll +0 -0
  161. mindspore/opencv_imgcodecs452.dll +0 -0
  162. mindspore/opencv_imgproc452.dll +0 -0
  163. mindspore/ops/__init__.py +2 -1
  164. mindspore/ops/_grad_experimental/grad_comm_ops.py +107 -8
  165. mindspore/ops/_grad_experimental/grad_debug_ops.py +6 -1
  166. mindspore/ops/_grad_experimental/grad_inner_ops.py +9 -0
  167. mindspore/ops/_grad_experimental/grad_math_ops.py +2 -1
  168. mindspore/ops/_op_impl/cpu/__init__.py +1 -0
  169. mindspore/ops/_op_impl/cpu/raise_op.py +28 -0
  170. mindspore/ops/_vmap/vmap_array_ops.py +20 -19
  171. mindspore/ops/_vmap/vmap_base.py +0 -2
  172. mindspore/ops/_vmap/vmap_grad_nn_ops.py +19 -13
  173. mindspore/ops/_vmap/vmap_math_ops.py +11 -9
  174. mindspore/ops/_vmap/vmap_nn_ops.py +20 -34
  175. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +149 -12
  176. mindspore/ops/auto_generate/gen_arg_handler.py +0 -61
  177. mindspore/ops/auto_generate/gen_extend_func.py +554 -60
  178. mindspore/ops/auto_generate/gen_ops_def.py +1621 -115
  179. mindspore/ops/auto_generate/gen_ops_prim.py +8027 -3411
  180. mindspore/ops/auto_generate/pyboost_inner_prim.py +183 -79
  181. mindspore/ops/composite/base.py +1 -1
  182. mindspore/ops/composite/multitype_ops/_compile_utils.py +229 -30
  183. mindspore/ops/composite/multitype_ops/pow_impl.py +0 -29
  184. mindspore/ops/function/__init__.py +12 -0
  185. mindspore/ops/function/array_func.py +561 -159
  186. mindspore/ops/function/clip_func.py +64 -0
  187. mindspore/ops/function/debug_func.py +28 -20
  188. mindspore/ops/function/image_func.py +1 -1
  189. mindspore/ops/function/linalg_func.py +5 -4
  190. mindspore/ops/function/math_func.py +1664 -294
  191. mindspore/ops/function/nn_func.py +988 -317
  192. mindspore/ops/function/parameter_func.py +3 -56
  193. mindspore/ops/function/random_func.py +243 -33
  194. mindspore/ops/function/sparse_unary_func.py +1 -1
  195. mindspore/ops/functional.py +18 -5
  196. mindspore/ops/functional_overload.py +897 -0
  197. mindspore/ops/operations/__init__.py +3 -2
  198. mindspore/ops/operations/_embedding_cache_ops.py +4 -4
  199. mindspore/ops/operations/_grad_ops.py +2 -34
  200. mindspore/ops/operations/_infer_ops.py +2 -1
  201. mindspore/ops/operations/_inner_ops.py +38 -8
  202. mindspore/ops/operations/array_ops.py +45 -303
  203. mindspore/ops/operations/comm_ops.py +23 -17
  204. mindspore/ops/operations/custom_ops.py +7 -49
  205. mindspore/ops/operations/debug_ops.py +42 -47
  206. mindspore/ops/operations/inner_ops.py +6 -4
  207. mindspore/ops/operations/linalg_ops.py +3 -2
  208. mindspore/ops/operations/manually_defined/ops_def.py +185 -104
  209. mindspore/ops/operations/math_ops.py +11 -216
  210. mindspore/ops/operations/nn_ops.py +153 -310
  211. mindspore/ops/primitive.py +23 -21
  212. mindspore/ops/tensor_method.py +1669 -0
  213. mindspore/ops_generate/aclnn_kernel_register_auto_cc_generator.py +110 -0
  214. mindspore/ops_generate/add_tensor_docs_generator.py +54 -0
  215. mindspore/ops_generate/arg_handler.py +0 -61
  216. mindspore/ops_generate/auto_grad_impl_cc_generator.py +135 -0
  217. mindspore/ops_generate/auto_grad_reg_cc_generator.py +93 -0
  218. mindspore/ops_generate/base_generator.py +11 -0
  219. mindspore/ops_generate/cpp_create_prim_instance_helper_generator.py +108 -0
  220. mindspore/ops_generate/functional_map_cpp_generator.py +491 -0
  221. mindspore/ops_generate/functional_overload_py_generator.py +110 -0
  222. mindspore/ops_generate/functions_cc_generator.py +233 -0
  223. mindspore/ops_generate/gen_aclnn_implement.py +110 -114
  224. mindspore/ops_generate/gen_constants.py +157 -3
  225. mindspore/ops_generate/gen_ops.py +245 -990
  226. mindspore/ops_generate/gen_pyboost_func.py +97 -998
  227. mindspore/ops_generate/gen_utils.py +119 -33
  228. mindspore/ops_generate/lite_ops_cpp_generator.py +155 -0
  229. mindspore/ops_generate/op_api_proto.py +206 -0
  230. mindspore/ops_generate/op_def_py_generator.py +131 -0
  231. mindspore/ops_generate/op_prim_py_generator.py +480 -0
  232. mindspore/ops_generate/op_proto.py +373 -108
  233. mindspore/ops_generate/op_template_parser.py +436 -0
  234. mindspore/ops_generate/ops_def_cc_generator.py +288 -0
  235. mindspore/ops_generate/ops_def_h_generator.py +74 -0
  236. mindspore/ops_generate/ops_name_h_generator.py +68 -0
  237. mindspore/ops_generate/ops_primitive_h_generator.py +81 -0
  238. mindspore/ops_generate/pyboost_functions_cpp_generator.py +370 -0
  239. mindspore/ops_generate/pyboost_functions_h_generator.py +68 -0
  240. mindspore/ops_generate/pyboost_functions_py_generator.py +148 -0
  241. mindspore/ops_generate/pyboost_grad_function_cpp_generator.py +154 -0
  242. mindspore/ops_generate/pyboost_inner_prim_generator.py +131 -0
  243. mindspore/ops_generate/pyboost_native_grad_functions_generator.py +268 -0
  244. mindspore/ops_generate/pyboost_op_cpp_code_generator.py +851 -0
  245. mindspore/ops_generate/pyboost_overload_functions_cpp_generator.py +344 -0
  246. mindspore/ops_generate/pyboost_utils.py +92 -33
  247. mindspore/ops_generate/template.py +294 -44
  248. mindspore/ops_generate/tensor_func_reg_cpp_generator.py +422 -0
  249. mindspore/parallel/__init__.py +3 -3
  250. mindspore/parallel/_auto_parallel_context.py +44 -34
  251. mindspore/parallel/_cell_wrapper.py +22 -3
  252. mindspore/parallel/_parallel_serialization.py +13 -2
  253. mindspore/parallel/_utils.py +4 -2
  254. mindspore/parallel/algo_parameter_config.py +1 -1
  255. mindspore/parallel/checkpoint_transform.py +44 -0
  256. mindspore/parallel/cluster/process_entity/_api.py +131 -37
  257. mindspore/parallel/cluster/process_entity/_utils.py +41 -6
  258. mindspore/parallel/cluster/run.py +20 -3
  259. mindspore/parallel/parameter_broadcast.py +1 -1
  260. mindspore/parallel/shard.py +3 -0
  261. mindspore/parallel/transform_safetensors.py +119 -253
  262. mindspore/profiler/__init__.py +17 -4
  263. mindspore/profiler/analysis/__init__.py +0 -0
  264. mindspore/profiler/analysis/parser/__init__.py +0 -0
  265. mindspore/profiler/analysis/parser/ascend_cann_parser.py +166 -0
  266. mindspore/profiler/analysis/parser/base_parser.py +158 -0
  267. mindspore/profiler/analysis/parser/framework_cann_relation_parser.py +45 -0
  268. mindspore/profiler/analysis/parser/ms_framework_parser.py +142 -0
  269. mindspore/profiler/analysis/parser/ms_minddata_parser.py +145 -0
  270. mindspore/profiler/analysis/parser/timeline_assembly_factory/__init__.py +0 -0
  271. mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +261 -0
  272. mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +40 -0
  273. mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +84 -0
  274. mindspore/profiler/analysis/parser/timeline_creator/__init__.py +0 -0
  275. mindspore/profiler/analysis/parser/timeline_creator/base_timeline_creator.py +44 -0
  276. mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +90 -0
  277. mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +76 -0
  278. mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +103 -0
  279. mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +134 -0
  280. mindspore/profiler/analysis/parser/timeline_event/__init__.py +0 -0
  281. mindspore/profiler/analysis/parser/timeline_event/base_event.py +233 -0
  282. mindspore/profiler/analysis/parser/timeline_event/cpu_op_event.py +47 -0
  283. mindspore/profiler/analysis/parser/timeline_event/flow_event.py +36 -0
  284. mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +260 -0
  285. mindspore/profiler/analysis/parser/timeline_event/msprof_event.py +73 -0
  286. mindspore/profiler/analysis/parser/timeline_event/scope_layer_event.py +53 -0
  287. mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +146 -0
  288. mindspore/profiler/analysis/task_manager.py +131 -0
  289. mindspore/profiler/analysis/time_converter.py +84 -0
  290. mindspore/profiler/analysis/viewer/__init__.py +0 -0
  291. mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +333 -0
  292. mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +87 -0
  293. mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +252 -0
  294. mindspore/profiler/analysis/viewer/ascend_memory_viewer.py +313 -0
  295. mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +322 -0
  296. mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +265 -0
  297. mindspore/profiler/analysis/viewer/ascend_timeline_viewer.py +58 -0
  298. mindspore/profiler/analysis/viewer/base_viewer.py +26 -0
  299. mindspore/profiler/analysis/viewer/ms_dataset_viewer.py +97 -0
  300. mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +581 -0
  301. mindspore/profiler/analysis/work_flow.py +73 -0
  302. mindspore/profiler/common/ascend_msprof_exporter.py +138 -0
  303. mindspore/profiler/common/command_executor.py +90 -0
  304. mindspore/profiler/common/constant.py +174 -3
  305. mindspore/profiler/common/file_manager.py +208 -0
  306. mindspore/profiler/common/log.py +130 -0
  307. mindspore/profiler/common/msprof_cmd_tool.py +202 -0
  308. mindspore/profiler/common/path_manager.py +371 -0
  309. mindspore/profiler/common/process_bar.py +168 -0
  310. mindspore/profiler/common/process_pool.py +9 -3
  311. mindspore/profiler/common/profiler_context.py +476 -0
  312. mindspore/profiler/common/profiler_info.py +304 -0
  313. mindspore/profiler/common/profiler_output_path.py +284 -0
  314. mindspore/profiler/common/profiler_parameters.py +210 -0
  315. mindspore/profiler/common/profiler_path_manager.py +120 -0
  316. mindspore/profiler/common/record_function.py +76 -0
  317. mindspore/profiler/common/tlv_decoder.py +76 -0
  318. mindspore/profiler/common/util.py +75 -2
  319. mindspore/profiler/dynamic_profiler.py +270 -37
  320. mindspore/profiler/envprofiler.py +138 -0
  321. mindspore/profiler/mstx.py +199 -0
  322. mindspore/profiler/platform/__init__.py +21 -0
  323. mindspore/profiler/platform/base_profiler.py +40 -0
  324. mindspore/profiler/platform/cpu_profiler.py +124 -0
  325. mindspore/profiler/platform/gpu_profiler.py +74 -0
  326. mindspore/profiler/platform/npu_profiler.py +309 -0
  327. mindspore/profiler/profiler.py +580 -93
  328. mindspore/profiler/profiler_action_controller.py +187 -0
  329. mindspore/profiler/profiler_interface.py +114 -0
  330. mindspore/profiler/schedule.py +208 -0
  331. mindspore/rewrite/api/symbol_tree.py +1 -2
  332. mindspore/run_check/_check_version.py +18 -13
  333. mindspore/runtime/__init__.py +37 -0
  334. mindspore/runtime/device.py +27 -0
  335. mindspore/runtime/event.py +209 -0
  336. mindspore/runtime/executor.py +148 -0
  337. mindspore/runtime/memory.py +392 -0
  338. mindspore/runtime/stream.py +460 -0
  339. mindspore/runtime/thread_bind_core.py +401 -0
  340. mindspore/swresample-4.dll +0 -0
  341. mindspore/swscale-6.dll +0 -0
  342. mindspore/tinyxml2.dll +0 -0
  343. mindspore/train/__init__.py +2 -2
  344. mindspore/train/_utils.py +53 -18
  345. mindspore/train/amp.py +8 -4
  346. mindspore/train/callback/_checkpoint.py +32 -18
  347. mindspore/train/callback/_early_stop.py +1 -1
  348. mindspore/train/callback/_flops_collector.py +105 -69
  349. mindspore/train/callback/_history.py +1 -1
  350. mindspore/train/callback/_summary_collector.py +44 -6
  351. mindspore/train/callback/_tft_register.py +37 -15
  352. mindspore/train/dataset_helper.py +11 -11
  353. mindspore/train/metrics/precision.py +4 -5
  354. mindspore/train/mind_ir_pb2.py +167 -46
  355. mindspore/train/model.py +13 -14
  356. mindspore/train/serialization.py +461 -72
  357. mindspore/train/summary/summary_record.py +1 -2
  358. mindspore/train/train_thor/model_thor.py +1 -1
  359. mindspore/turbojpeg.dll +0 -0
  360. mindspore/utils/__init__.py +4 -2
  361. mindspore/utils/dryrun.py +138 -0
  362. mindspore/utils/runtime_execution_order_check.py +550 -0
  363. mindspore/version.py +1 -1
  364. {mindspore-2.4.1.dist-info → mindspore-2.5.0.dist-info}/METADATA +3 -4
  365. {mindspore-2.4.1.dist-info → mindspore-2.5.0.dist-info}/RECORD +368 -242
  366. {mindspore-2.4.1.dist-info → mindspore-2.5.0.dist-info}/entry_points.txt +1 -1
  367. mindspore/common/_tensor_overload.py +0 -139
  368. mindspore/mindspore_np_dtype.dll +0 -0
  369. mindspore/profiler/envprofiling.py +0 -254
  370. mindspore/profiler/profiling.py +0 -1926
  371. {mindspore-2.4.1.dist-info → mindspore-2.5.0.dist-info}/WHEEL +0 -0
  372. {mindspore-2.4.1.dist-info → mindspore-2.5.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,436 @@
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
+ """
16
+ This module defines the OpTemplateParser class for parsing operator prototypes.
17
+
18
+ The OpTemplateParser class is responsible for converting attributes of OpProto instances into strings
19
+ that can be directly used to fill in code templates. It handles the parsing of argument types,
20
+ function signatures, and generates conversion stubs for PyBoost operations.
21
+ """
22
+
23
+ import re
24
+
25
+ import pyboost_utils
26
+ from pyboost_utils import get_input_dtype, tuple_input_to_cpp_type, get_return_type, \
27
+ number_input_to_cpp_type, get_const_number_convert, get_tuple_input_convert, is_optional_param
28
+ import gen_constants as K
29
+ from template import Template
30
+ from op_proto import OpProto
31
+
32
+
33
+ class OpTemplateParser:
34
+ """
35
+ Parses operator prototypes and generates template-compatible strings.
36
+
37
+ This class converts the attributes of an OpProto instance into the strings needed for code generation
38
+ in PyBoost operations.
39
+
40
+ Attributes:
41
+ op_proto (OpProto): The operator prototype containing the relevant information.
42
+ """
43
+
44
+ def __init__(self, op_proto: OpProto):
45
+ self.op_proto = op_proto
46
+
47
+ def _parse_call_args_types(self, op_args):
48
+ """
49
+ Parses the data types of the call arguments for the operator.
50
+
51
+ Args:
52
+ op_args (list): A list of operator arguments.
53
+
54
+ Returns:
55
+ list: A list of data types for the call arguments.
56
+ """
57
+ call_args_types = []
58
+ for op_arg in op_args:
59
+ is_optional = is_optional_param(op_arg)
60
+ call_args_types.append(get_input_dtype(op_arg.arg_dtype, is_optional))
61
+ return call_args_types
62
+
63
+ def parse_call_args_with_types(self):
64
+ """
65
+ Parses the original call arguments and their types for the operator.
66
+
67
+ Returns:
68
+ list: A list of formatted strings representing the call arguments with their types.
69
+ """
70
+ call_args = self.parse_original_call_args(self.op_proto.op_args)
71
+ call_args_types = self._parse_call_args_types(self.op_proto.op_args)
72
+ call_args_with_types = []
73
+ for type_name, arg_name in zip(call_args_types, call_args):
74
+ call_args_with_types.append("const " + type_name + " &" + arg_name)
75
+ return call_args_with_types
76
+
77
+ def parse_need_malloc_tensors(self):
78
+ """
79
+ Parses the operator arguments to identify which tensors require memory allocation.
80
+
81
+ Returns:
82
+ tuple: A tuple containing:
83
+ - need_malloc_tensors (list): Arguments that need memory allocation.
84
+ - tensor_list_convert (list): Conversions needed for tensor lists.
85
+ - call_args_with_tensor (list): The call arguments formatted for tensors.
86
+ """
87
+ need_malloc_tensors = []
88
+ tensor_list_convert = []
89
+ call_args_with_tensor = []
90
+ call_args = self.parse_original_call_args(self.op_proto.op_args)
91
+ for op_arg, call_arg in zip(self.op_proto.op_args, call_args):
92
+ if pyboost_utils.is_tensor(op_arg):
93
+ call_arg = op_arg.arg_name + "_tensor"
94
+ need_malloc_tensors.append(call_arg)
95
+ call_args_with_tensor.append(call_arg)
96
+ elif tuple_input_to_cpp_type(op_arg.arg_dtype) and pyboost_utils.is_tensor_list(op_arg):
97
+ need_malloc_tensors.append(call_arg + "_vector")
98
+ tensor_list_convert.append(get_tuple_input_convert(call_arg, op_arg.arg_dtype))
99
+ call_args_with_tensor.append(call_arg + "_vector")
100
+ else:
101
+ call_args_with_tensor.append(call_arg)
102
+ return need_malloc_tensors, tensor_list_convert, call_args_with_tensor
103
+
104
+ def parse_original_call_args(self, op_args):
105
+ """
106
+ Parses the original call arguments from the operator prototype.
107
+
108
+ Args:
109
+ op_args (list): A list of operator arguments.
110
+
111
+ Returns:
112
+ list: A list of formatted strings representing the original call arguments.
113
+ """
114
+ call_args = []
115
+ for op_arg in op_args:
116
+ if pyboost_utils.is_tensor(op_arg):
117
+ call_arg = op_arg.arg_name + "_tensor"
118
+ elif pyboost_utils.is_tensor_list(op_arg):
119
+ call_arg = op_arg.arg_name + "_tensor_list"
120
+ else:
121
+ call_arg = op_arg.arg_name
122
+ call_args.append(call_arg)
123
+ return call_args
124
+
125
+ def op_args_converter(self):
126
+ """
127
+ Converts operator arguments to the corresponding C++ data types.
128
+
129
+ Returns:
130
+ tuple: A tuple containing:
131
+ - call_args_after_convert (list): The converted call arguments.
132
+ - value_tuple_convert (list): Conversions needed for value tuples.
133
+ - const_number_convert (list): Conversions needed for constant numbers.
134
+ """
135
+ call_args_after_convert = []
136
+ value_tuple_convert = []
137
+ const_number_convert = []
138
+ call_args = self.parse_original_call_args(self.op_proto.op_args)
139
+ for op_arg, call_arg in zip(self.op_proto.op_args, call_args):
140
+ if number_input_to_cpp_type(op_arg.arg_dtype):
141
+ call_args_after_convert.append(call_arg + "_imm")
142
+ const_number_convert.append(get_const_number_convert(call_arg, op_arg))
143
+ elif tuple_input_to_cpp_type(op_arg.arg_dtype):
144
+ call_args_after_convert.append(call_arg + "_vector")
145
+ value_tuple_convert.append(get_tuple_input_convert(call_arg, op_arg.arg_dtype))
146
+ else:
147
+ call_args_after_convert.append(call_arg)
148
+ if const_number_convert:
149
+ const_number_convert.insert(0, '// Convert ValuePtr to c++ scalar\n')
150
+ if value_tuple_convert:
151
+ value_tuple_convert.insert(0, '// ValueTuple to std::vector\n')
152
+ return call_args_after_convert, value_tuple_convert, const_number_convert
153
+
154
+ def get_pyboost_func_name(self):
155
+ """
156
+ Gets the PyBoost function name based on the operator's class name.
157
+
158
+ Returns:
159
+ str: The generated PyBoost function name.
160
+ """
161
+ return "Pyboost_" + self.op_proto.op_class.name
162
+
163
+ def get_pyboost_name(self):
164
+ """
165
+ Gets the PyBoost name for the operator.
166
+
167
+ Returns:
168
+ str: The generated PyBoost name for the operator.
169
+ """
170
+ return "pyboost_" + self.op_proto.op_name
171
+
172
+ def get_op_def_name_str(self):
173
+ """
174
+ Gets the operator definition name string.
175
+
176
+ Returns:
177
+ str: The generated operator definition name string.
178
+ """
179
+ return "g" + self.op_proto.op_class.name
180
+
181
+ def gen_signature_same_type_table(self):
182
+ """
183
+ Generates a signature table for arguments of the same type.
184
+
185
+ Returns:
186
+ tuple: A tuple containing:
187
+ - type_num (int): The number of argument types.
188
+ - signature_table (str): The generated signature table as a string.
189
+ """
190
+ signature_table = ''
191
+ type_num = 0
192
+ args_signature = self.op_proto.op_args_signature
193
+ if args_signature is not None:
194
+ dtype_group = args_signature.dtype_group
195
+ indexes = {arg.arg_name: index for index, arg in enumerate(self.op_proto.op_args)}
196
+ if dtype_group is not None:
197
+ match = re.findall(r'\((.*?)\)', dtype_group)
198
+ for item in match:
199
+ name_args = item.replace(' ', '').split(",")
200
+ signature_table += '{'
201
+ for arg in name_args:
202
+ arg_index = indexes[arg]
203
+ signature_table += f"""{arg_index}, """
204
+ signature_table = signature_table[:-2]
205
+ signature_table += '}, '
206
+ type_num += 1
207
+ signature_table = signature_table[:-2]
208
+ return type_num, signature_table
209
+
210
+ def get_call_args_tensor(self):
211
+ """
212
+ Retrieves the call arguments that are of tensor type.
213
+
214
+ Returns:
215
+ list: A list of call arguments that are tensors.
216
+ """
217
+ call_args_tensor = []
218
+ call_args_types = self._parse_call_args_types(self.op_proto.op_args)
219
+ call_args = self.parse_original_call_args(self.op_proto.op_args)
220
+ for _type, arg_name in zip(call_args_types, call_args):
221
+ if _type in ("mindspore::tensor::BaseTensorPtr", "std::optional<mindspore::tensor::BaseTensorPtr>"):
222
+ call_args_tensor.append(arg_name)
223
+ return call_args_tensor
224
+
225
+ def has_prim_init(self):
226
+ """
227
+ Checks if any arguments require primitive initialization.
228
+
229
+ Returns:
230
+ bool: True if any argument requires primitive initialization, otherwise False.
231
+ """
232
+ op_args = self.op_proto.op_args
233
+ has_prim_init = False
234
+ for op_arg in op_args:
235
+ prim_init = op_arg.is_prim_init
236
+ if prim_init:
237
+ has_prim_init = True
238
+ break
239
+ return has_prim_init
240
+
241
+ def generate_pyboost_op_func_return_type(self):
242
+ """
243
+ Generates the C++ return type for the PyBoost operator function.
244
+
245
+ Returns:
246
+ str: The generated C++ return type for the function.
247
+
248
+ Raises:
249
+ Exception: If no valid return type is found.
250
+ """
251
+ returns_type = []
252
+ type_convert_to_base = {
253
+ 'std::vector<mindspore::tensor::TensorPtr>': 'std::vector<mindspore::tensor::BaseTensorPtr>',
254
+ 'mindspore::tensor::TensorPtr': 'mindspore::tensor::BaseTensorPtr'
255
+ }
256
+ for return_obj in self.op_proto.op_returns:
257
+ temp_return = get_return_type(return_obj.arg_dtype)
258
+ if temp_return in type_convert_to_base:
259
+ returns_type.append(type_convert_to_base[temp_return])
260
+ else:
261
+ raise Exception("Not return found")
262
+ if len(returns_type) == 1:
263
+ cpp_func_return = returns_type[0]
264
+ elif len(returns_type) > 1:
265
+ cpp_func_return = "std::tuple<"
266
+ cpp_func_return += ','.join(s for s in returns_type)
267
+ cpp_func_return += ">"
268
+ else:
269
+ raise Exception("Not return found")
270
+ return cpp_func_return
271
+
272
+ def generate_pyboost_outputs(self):
273
+ """
274
+ Generates the output variables for the PyBoost operator function.
275
+
276
+ Returns:
277
+ tuple: A tuple containing:
278
+ - op_outputs (str): The output variable representation for the operator.
279
+ - call_outputs (str): The call output variable representation for the operator.
280
+ """
281
+ op_outputs = ''
282
+ call_outputs = ''
283
+ returns_type = []
284
+ for return_obj in self.op_proto.op_returns:
285
+ returns_type.append(get_return_type(return_obj.arg_dtype))
286
+
287
+ if len(returns_type) == 1:
288
+ if returns_type[0] == 'mindspore::tensor::TensorPtr':
289
+ op_outputs = 'outputs[0]'
290
+ call_outputs = 'outputs_[0]'
291
+ elif returns_type[0] == "std::vector<mindspore::tensor::TensorPtr>":
292
+ op_outputs = 'outputs'
293
+ call_outputs = 'outputs_'
294
+ else:
295
+ raise Exception("Not support return type {}".format(returns_type[0]))
296
+ elif len(returns_type) > 1:
297
+ outputs_str = ''
298
+ for i in range(len(returns_type)):
299
+ outputs_str += 'outputs[{}],'.format(i)
300
+ op_outputs = outputs_str[:-1]
301
+
302
+ outputs_str = ''
303
+ for i in range(len(returns_type)):
304
+ outputs_str += 'outputs_[{}],'.format(i)
305
+ outputs_str = outputs_str[:-1]
306
+ call_outputs = "std::make_tuple(" + outputs_str + ")"
307
+
308
+ return op_outputs, call_outputs
309
+
310
+ def _is_input_arg(self, arg_name, op_name):
311
+ res = False
312
+ if op_name in K.INPUT_NAME_MAP and arg_name == K.INPUT_NAME_MAP[op_name]:
313
+ res = True
314
+ elif op_name not in K.INPUT_NAME_MAP and arg_name in K.INPUT_ARGS_NAME:
315
+ res = True
316
+ return res
317
+
318
+ def generate_signature_str(self, kw_only_args=None, varargs=None, *, is_tensor_api: bool) -> str:
319
+ """
320
+ Generates a single function signature string for the given operation prototype.
321
+
322
+ Args:
323
+ kw_only_args (list[str]): List of keyword-only argument names.
324
+ varargs (list[str]): List of variable args names.
325
+
326
+ Kwargs:
327
+ is_tensor_api (bool): Whether this function is used in the Tensor API scenario.
328
+
329
+ Returns:
330
+ str: Generated function signature string.
331
+ """
332
+
333
+ op_name = self.op_proto.op_class.name
334
+ args_str = f'"{op_name}('
335
+ first_arg = True
336
+ kw_args_init_flag = False
337
+
338
+ arg_index = 0
339
+ for arg in self.op_proto.op_args:
340
+ arg_name = arg.arg_name
341
+
342
+ if is_tensor_api and self._is_input_arg(arg_name, op_name):
343
+ continue
344
+
345
+ single_arg = ''
346
+ if not first_arg:
347
+ single_arg = ', '
348
+
349
+ arg_handler = arg.arg_handler
350
+ if arg_handler:
351
+ if arg_handler in K.ARG_HANDLER_MAP:
352
+ arg_dtype = K.ARG_HANDLER_MAP[arg_handler]
353
+ else:
354
+ raise ValueError(
355
+ f"Generate failed. Check if {arg_handler} is registered in TensorFuncRegCppGenerator.")
356
+ else:
357
+ arg_dtype = arg.arg_dtype
358
+ for cast_type in arg.type_cast:
359
+ arg_dtype += f'|{cast_type}'
360
+
361
+ # handle varargs params
362
+ if varargs and arg_name in varargs and arg_index == 0:
363
+ single_arg += f"{arg_dtype} *{arg_name}"
364
+ else:
365
+ single_arg += f"{arg_dtype} {arg_name}"
366
+
367
+ if arg.as_init_arg:
368
+ single_arg += f"={arg.default}"
369
+
370
+ # handle keyword-only params
371
+ if kw_only_args and not kw_args_init_flag and arg_name == kw_only_args[0]:
372
+ single_arg = ("*, " if first_arg else ", *") + single_arg
373
+ kw_args_init_flag = True
374
+
375
+ args_str += single_arg
376
+ first_arg = False
377
+ arg_index += 1
378
+
379
+ return args_str + ')"'
380
+
381
+ def get_arg_handler_processor(self, func_name, op_proto, *, is_tensor_api):
382
+ """
383
+ Generates argument handler processing code for the given function prototype.
384
+
385
+ Args:
386
+ func_name (str): The name of the function.
387
+ op_proto (OpProto): Operator prototype instance to generate argument processing for.
388
+
389
+ Returns:
390
+ str: Generated argument handler processing code.
391
+ """
392
+ tensor_arg_handler_prt_template = Template(
393
+ "arg_list[${idx}] = "
394
+ "(*pynative::${func_str}(\"${func_name}\", \"${op_arg_name}\", arg_list[${idx}]))->value();\n"
395
+ )
396
+ function_arg_handler_prt_template = Template(
397
+ "arg_list[${idx}] = "
398
+ "(*${func_str}(\"${func_name}\", \"${op_arg_name}\", arg_list[${idx}]))->value();\n"
399
+ )
400
+ arg_handler_prt_template = (
401
+ tensor_arg_handler_prt_template) if is_tensor_api else function_arg_handler_prt_template
402
+
403
+ arg_handler_template = Template(
404
+ "arg_list[${idx}] = "
405
+ "pynative::${func_str}(\"${func_name}\", \"${op_arg_name}\", arg_list[${idx}]);\n"
406
+ )
407
+ arg_handler_optional_template = Template(
408
+ 'if (!py::isinstance<py::none>(arg_list[${idx}])) {\n'
409
+ ' ${arg_handler_str}\n'
410
+ '}\n'
411
+ )
412
+
413
+ arg_handler_processor = []
414
+ op_args = op_proto.op_args
415
+ for idx, op_arg in enumerate(op_args):
416
+ arg_handler = op_arg.arg_handler
417
+ func_str = ''.join(word.capitalize() for word in arg_handler.split('_'))
418
+ if arg_handler:
419
+ op_arg_name = op_arg.arg_name
420
+ if func_str in ("StrToEnum", "DtypeToTypeId"):
421
+ arg_handler_str = arg_handler_prt_template.replace(func_str=func_str,
422
+ func_name=func_name,
423
+ op_arg_name=op_arg_name,
424
+ idx=idx)
425
+ else:
426
+ arg_handler_str = arg_handler_template.replace(func_str=func_str,
427
+ func_name=func_name,
428
+ op_arg_name=op_arg_name,
429
+ idx=idx)
430
+
431
+ if op_arg.default == "None":
432
+ arg_handler_str = arg_handler_optional_template.replace(idx=idx,
433
+ arg_handler_str=arg_handler_str)
434
+ arg_handler_processor.append(arg_handler_str)
435
+
436
+ return arg_handler_processor