mindspore 2.6.0rc1__cp310-cp310-win_amd64.whl → 2.7.0rc1__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 (407) 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.cp310-win_amd64.pyd +0 -0
  6. mindspore/_c_expression.cp310-win_amd64.pyd +0 -0
  7. mindspore/_c_mindrecord.cp310-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 +37 -62
  15. mindspore/_extends/parse/resources.py +39 -0
  16. mindspore/_extends/parse/standard_method.py +43 -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 +77 -16
  37. mindspore/common/api.py +238 -113
  38. mindspore/common/dtype.py +21 -11
  39. mindspore/common/dump.py +10 -15
  40. mindspore/common/generator.py +5 -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 +81 -81
  49. mindspore/communication/_comm_helper.py +46 -4
  50. mindspore/communication/management.py +79 -7
  51. mindspore/context.py +58 -40
  52. mindspore/dataset/core/config.py +3 -3
  53. mindspore/dataset/engine/datasets.py +20 -7
  54. mindspore/dataset/engine/datasets_user_defined.py +33 -3
  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 -7
  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 +27 -7
  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 +6 -46
  116. mindspore/mint/distributed/__init__.py +1 -0
  117. mindspore/mint/distributed/distributed.py +212 -9
  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 +137 -101
  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 +328 -502
  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 +117 -110
  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 +3 -3
  157. mindspore/nn/optim/adasum.py +2 -2
  158. mindspore/nn/optim/asgd.py +2 -0
  159. mindspore/nn/optim/optimizer.py +1 -1
  160. mindspore/nn/optim/thor.py +2 -2
  161. mindspore/nn/probability/distribution/exponential.py +2 -1
  162. mindspore/nn/probability/distribution/poisson.py +2 -1
  163. mindspore/nn/sparse/sparse.py +3 -3
  164. mindspore/nn/wrap/cell_wrapper.py +34 -37
  165. mindspore/nn/wrap/grad_reducer.py +37 -37
  166. mindspore/nn/wrap/loss_scale.py +72 -74
  167. mindspore/numpy/array_creations.py +5 -5
  168. mindspore/numpy/fft.py +1 -1
  169. mindspore/numpy/math_ops.py +5 -5
  170. mindspore/opencv_core452.dll +0 -0
  171. mindspore/opencv_imgcodecs452.dll +0 -0
  172. mindspore/opencv_imgproc452.dll +0 -0
  173. mindspore/ops/_grad_experimental/grad_comm_ops.py +51 -13
  174. mindspore/ops/_grad_experimental/grad_debug_ops.py +14 -0
  175. mindspore/ops/_vmap/vmap_array_ops.py +31 -13
  176. mindspore/ops/_vmap/vmap_nn_ops.py +8 -16
  177. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +42 -11
  178. mindspore/ops/auto_generate/gen_extend_func.py +23 -141
  179. mindspore/ops/auto_generate/gen_ops_def.py +727 -321
  180. mindspore/ops/auto_generate/gen_ops_prim.py +1721 -984
  181. mindspore/ops/auto_generate/pyboost_inner_prim.py +31 -1
  182. mindspore/ops/composite/__init__.py +10 -0
  183. mindspore/ops/composite/base.py +8 -4
  184. mindspore/ops/composite/multitype_ops/__init__.py +12 -1
  185. mindspore/ops/composite/multitype_ops/_compile_utils.py +133 -109
  186. mindspore/ops/composite/multitype_ops/add_impl.py +70 -2
  187. mindspore/ops/composite/multitype_ops/div_impl.py +49 -0
  188. mindspore/ops/composite/multitype_ops/floordiv_impl.py +29 -0
  189. mindspore/ops/composite/multitype_ops/getitem_impl.py +11 -0
  190. mindspore/ops/composite/multitype_ops/mod_impl.py +5 -3
  191. mindspore/ops/composite/multitype_ops/mul_impl.py +49 -0
  192. mindspore/ops/composite/multitype_ops/setitem_impl.py +57 -0
  193. mindspore/ops/composite/multitype_ops/sub_impl.py +34 -0
  194. mindspore/ops/composite/multitype_ops/zeros_like_impl.py +14 -0
  195. mindspore/ops/function/__init__.py +3 -1
  196. mindspore/ops/function/_add_attr_func.py +11 -6
  197. mindspore/ops/function/array_func.py +9 -96
  198. mindspore/ops/function/debug_func.py +4 -3
  199. mindspore/ops/function/grad/grad_func.py +1 -1
  200. mindspore/ops/function/math_func.py +33 -540
  201. mindspore/ops/function/nn_func.py +28 -74
  202. mindspore/ops/function/other_func.py +4 -1
  203. mindspore/ops/function/random_func.py +44 -5
  204. mindspore/ops/function/vmap_func.py +2 -1
  205. mindspore/ops/functional.py +2 -3
  206. mindspore/ops/functional_overload.py +571 -6
  207. mindspore/ops/op_info_register.py +21 -0
  208. mindspore/ops/operations/__init__.py +16 -11
  209. mindspore/ops/operations/_custom_ops_utils.py +689 -34
  210. mindspore/ops/operations/_inner_ops.py +3 -6
  211. mindspore/ops/operations/_sequence_ops.py +1 -1
  212. mindspore/ops/operations/array_ops.py +2 -2
  213. mindspore/ops/operations/comm_ops.py +185 -26
  214. mindspore/ops/operations/custom_ops.py +294 -174
  215. mindspore/ops/operations/debug_ops.py +59 -4
  216. mindspore/ops/operations/image_ops.py +13 -13
  217. mindspore/ops/operations/manually_defined/ops_def.py +15 -16
  218. mindspore/ops/operations/math_ops.py +3 -4
  219. mindspore/ops/operations/nn_ops.py +7 -39
  220. mindspore/ops/primitive.py +6 -10
  221. mindspore/ops/tensor_method.py +47 -8
  222. mindspore/ops_generate/api/cpp_create_prim_instance_helper_generator.py +1 -1
  223. mindspore/ops_generate/api/functional_map_cpp_generator.py +10 -9
  224. mindspore/ops_generate/api/functions_cc_generator.py +58 -10
  225. mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +1 -1
  226. mindspore/ops_generate/common/base_generator.py +14 -0
  227. mindspore/ops_generate/common/gen_constants.py +8 -3
  228. mindspore/ops_generate/common/gen_utils.py +0 -19
  229. mindspore/ops_generate/common/op_proto.py +11 -4
  230. mindspore/ops_generate/common/template.py +88 -11
  231. mindspore/ops_generate/gen_ops.py +1 -1
  232. mindspore/ops_generate/op_def/lite_ops_cpp_generator.py +4 -4
  233. mindspore/ops_generate/op_def/ops_def_cc_generator.py +0 -3
  234. mindspore/ops_generate/op_def/ops_name_h_generator.py +0 -3
  235. mindspore/ops_generate/op_def/ops_primitive_h_generator.py +0 -4
  236. mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -2
  237. mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +49 -8
  238. mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +2 -2
  239. mindspore/ops_generate/pyboost/gen_pyboost_func.py +31 -0
  240. mindspore/ops_generate/pyboost/op_template_parser.py +98 -72
  241. mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +70 -273
  242. mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +14 -6
  243. mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +316 -0
  244. mindspore/ops_generate/pyboost/pyboost_functions_py_generator.py +1 -1
  245. mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +5 -3
  246. mindspore/ops_generate/pyboost/pyboost_inner_prim_generator.py +1 -1
  247. mindspore/ops_generate/pyboost/pyboost_internal_functions_cpp_generator.py +76 -0
  248. mindspore/ops_generate/pyboost/pyboost_internal_functions_h_generator.py +76 -0
  249. mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +125 -0
  250. mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +4 -3
  251. mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +348 -61
  252. mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +1 -1
  253. mindspore/ops_generate/pyboost/pyboost_utils.py +118 -9
  254. mindspore/ops_generate/tensor_py_cc_generator.py +1 -24
  255. mindspore/parallel/_auto_parallel_context.py +11 -8
  256. mindspore/parallel/_cell_wrapper.py +113 -45
  257. mindspore/parallel/_parallel_serialization.py +1 -1
  258. mindspore/parallel/_ps_context.py +4 -6
  259. mindspore/parallel/_tensor.py +167 -12
  260. mindspore/parallel/_transformer/moe.py +1 -1
  261. mindspore/parallel/_transformer/transformer.py +13 -8
  262. mindspore/parallel/auto_parallel.py +14 -7
  263. mindspore/parallel/checkpoint_convert.py +3 -3
  264. mindspore/parallel/checkpoint_transform.py +11 -7
  265. mindspore/parallel/cluster/process_entity/_api.py +84 -48
  266. mindspore/parallel/cluster/process_entity/_utils.py +95 -7
  267. mindspore/parallel/cluster/run.py +43 -4
  268. mindspore/parallel/function/__init__.py +8 -1
  269. mindspore/parallel/function/reshard_func.py +6 -7
  270. mindspore/parallel/nn/__init__.py +15 -2
  271. mindspore/parallel/nn/parallel_cell_wrapper.py +9 -10
  272. mindspore/parallel/nn/parallel_grad_reducer.py +7 -6
  273. mindspore/parallel/shard.py +3 -4
  274. mindspore/parallel/transform_safetensors.py +463 -174
  275. mindspore/pgodb140.dll +0 -0
  276. mindspore/pgort140.dll +0 -0
  277. mindspore/profiler/__init__.py +2 -1
  278. mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +7 -7
  279. mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +3 -0
  280. mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +12 -6
  281. mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +3 -3
  282. mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +3 -3
  283. mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +4 -4
  284. mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +3 -3
  285. mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +4 -1
  286. mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +2 -1
  287. mindspore/profiler/analysis/task_manager.py +1 -1
  288. mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +5 -1
  289. mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +2 -1
  290. mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +42 -22
  291. mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +3 -2
  292. mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +9 -5
  293. mindspore/profiler/analysis/viewer/ms_operator_details_viewer.py +132 -0
  294. mindspore/profiler/common/constant.py +16 -0
  295. mindspore/profiler/common/profiler_context.py +25 -27
  296. mindspore/profiler/common/profiler_info.py +0 -16
  297. mindspore/profiler/common/profiler_op_analyse.py +235 -0
  298. mindspore/profiler/common/profiler_output_path.py +23 -8
  299. mindspore/profiler/common/profiler_parameters.py +128 -35
  300. mindspore/profiler/dynamic_profile/__init__.py +0 -0
  301. mindspore/profiler/dynamic_profile/dynamic_monitor_proxy.py +39 -0
  302. mindspore/profiler/dynamic_profile/dynamic_profiler_config_context.py +666 -0
  303. mindspore/profiler/dynamic_profile/dynamic_profiler_utils.py +62 -0
  304. mindspore/profiler/dynamic_profiler.py +305 -314
  305. mindspore/profiler/envprofiler.py +12 -7
  306. mindspore/profiler/experimental_config.py +96 -6
  307. mindspore/profiler/mstx.py +33 -12
  308. mindspore/profiler/platform/__init__.py +2 -3
  309. mindspore/profiler/platform/npu_profiler.py +29 -19
  310. mindspore/profiler/profiler.py +35 -19
  311. mindspore/profiler/profiler_action_controller.py +64 -76
  312. mindspore/profiler/schedule.py +10 -4
  313. mindspore/rewrite/common/config.py +1 -0
  314. mindspore/rewrite/common/namer.py +1 -0
  315. mindspore/rewrite/common/namespace.py +1 -0
  316. mindspore/rewrite/node/node.py +31 -11
  317. mindspore/rewrite/parsers/assign_parser.py +1 -1
  318. mindspore/rewrite/symbol_tree/symbol_tree.py +1 -1
  319. mindspore/run_check/_check_version.py +7 -10
  320. mindspore/runtime/__init__.py +5 -5
  321. mindspore/runtime/event.py +10 -4
  322. mindspore/runtime/executor.py +60 -45
  323. mindspore/runtime/memory.py +30 -32
  324. mindspore/runtime/thread_bind_core.py +298 -164
  325. mindspore/safeguard/rewrite_obfuscation.py +12 -13
  326. mindspore/swresample-4.dll +0 -0
  327. mindspore/swscale-6.dll +0 -0
  328. mindspore/tbbmalloc.dll +0 -0
  329. mindspore/tinyxml2.dll +0 -0
  330. mindspore/train/_utils.py +14 -4
  331. mindspore/train/amp.py +43 -20
  332. mindspore/train/callback/__init__.py +5 -5
  333. mindspore/train/callback/_checkpoint.py +3 -6
  334. mindspore/train/callback/_flops_collector.py +1 -1
  335. mindspore/train/callback/_landscape.py +0 -1
  336. mindspore/train/callback/_train_fault_tolerance.py +97 -16
  337. mindspore/train/data_sink.py +11 -2
  338. mindspore/train/dataset_helper.py +9 -0
  339. mindspore/train/model.py +135 -55
  340. mindspore/train/serialization.py +133 -111
  341. mindspore/train/summary/summary_record.py +13 -2
  342. mindspore/turbojpeg.dll +0 -0
  343. mindspore/utils/__init__.py +3 -2
  344. mindspore/utils/dryrun.py +0 -6
  345. mindspore/utils/runtime_execution_order_check.py +163 -77
  346. mindspore/utils/sdc_detect.py +68 -0
  347. mindspore/utils/utils.py +6 -9
  348. mindspore/vcmeta.dll +0 -0
  349. mindspore/vcruntime140.dll +0 -0
  350. mindspore/vcruntime140_1.dll +0 -0
  351. mindspore/version.py +1 -1
  352. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/METADATA +5 -4
  353. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/RECORD +356 -394
  354. mindspore/_deprecated/jit.py +0 -198
  355. mindspore/experimental/es/__init__.py +0 -22
  356. mindspore/experimental/es/embedding_service.py +0 -891
  357. mindspore/experimental/es/embedding_service_layer.py +0 -581
  358. mindspore/profiler/parser/__init__.py +0 -14
  359. mindspore/profiler/parser/aicpu_data_parser.py +0 -272
  360. mindspore/profiler/parser/ascend_analysis/__init__.py +0 -14
  361. mindspore/profiler/parser/ascend_analysis/constant.py +0 -71
  362. mindspore/profiler/parser/ascend_analysis/file_manager.py +0 -180
  363. mindspore/profiler/parser/ascend_analysis/function_event.py +0 -185
  364. mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +0 -136
  365. mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +0 -131
  366. mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +0 -104
  367. mindspore/profiler/parser/ascend_analysis/path_manager.py +0 -313
  368. mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +0 -123
  369. mindspore/profiler/parser/ascend_analysis/tlv_decoder.py +0 -86
  370. mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +0 -75
  371. mindspore/profiler/parser/ascend_cluster_generator.py +0 -116
  372. mindspore/profiler/parser/ascend_communicate_generator.py +0 -314
  373. mindspore/profiler/parser/ascend_flops_generator.py +0 -116
  374. mindspore/profiler/parser/ascend_fpbp_generator.py +0 -82
  375. mindspore/profiler/parser/ascend_hccl_generator.py +0 -271
  376. mindspore/profiler/parser/ascend_integrate_generator.py +0 -42
  377. mindspore/profiler/parser/ascend_memory_generator.py +0 -185
  378. mindspore/profiler/parser/ascend_msprof_exporter.py +0 -282
  379. mindspore/profiler/parser/ascend_msprof_generator.py +0 -187
  380. mindspore/profiler/parser/ascend_op_generator.py +0 -334
  381. mindspore/profiler/parser/ascend_steptrace_generator.py +0 -94
  382. mindspore/profiler/parser/ascend_timeline_generator.py +0 -545
  383. mindspore/profiler/parser/base_timeline_generator.py +0 -483
  384. mindspore/profiler/parser/container.py +0 -229
  385. mindspore/profiler/parser/cpu_gpu_timeline_generator.py +0 -697
  386. mindspore/profiler/parser/flops_parser.py +0 -531
  387. mindspore/profiler/parser/framework_enum.py +0 -111
  388. mindspore/profiler/parser/framework_parser.py +0 -464
  389. mindspore/profiler/parser/framework_struct.py +0 -61
  390. mindspore/profiler/parser/gpu_analysis/__init__.py +0 -14
  391. mindspore/profiler/parser/gpu_analysis/function_event.py +0 -44
  392. mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +0 -89
  393. mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +0 -72
  394. mindspore/profiler/parser/hccl_parser.py +0 -573
  395. mindspore/profiler/parser/hwts_log_parser.py +0 -122
  396. mindspore/profiler/parser/integrator.py +0 -526
  397. mindspore/profiler/parser/memory_usage_parser.py +0 -277
  398. mindspore/profiler/parser/minddata_analyzer.py +0 -800
  399. mindspore/profiler/parser/minddata_parser.py +0 -186
  400. mindspore/profiler/parser/minddata_pipeline_parser.py +0 -299
  401. mindspore/profiler/parser/op_intermediate_parser.py +0 -149
  402. mindspore/profiler/parser/optime_parser.py +0 -250
  403. mindspore/profiler/parser/profiler_info.py +0 -213
  404. mindspore/profiler/parser/step_trace_parser.py +0 -666
  405. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/WHEEL +0 -0
  406. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/entry_points.txt +0 -0
  407. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/top_level.txt +0 -0
@@ -23,6 +23,7 @@ import re
23
23
 
24
24
  import common.template as template
25
25
  import common.gen_constants as K
26
+ from common.template import Template
26
27
  from common.gen_utils import save_file
27
28
  from common.op_proto import OpProto
28
29
  from common.base_generator import BaseGenerator
@@ -32,6 +33,13 @@ from .pyboost_utils import is_cube, AclnnUtils, get_return_type, merge_strings_b
32
33
  from .op_template_parser import OpTemplateParser
33
34
 
34
35
 
36
+ def check_no_basic_int_type(op_args):
37
+ for arg in op_args:
38
+ if arg.arg_dtype in ["tuple[int]", "list[int]", "int"]:
39
+ return False
40
+ return True
41
+
42
+
35
43
  class PyboostCommonOpHeaderGenerator(BaseGenerator):
36
44
  """
37
45
  Generates common C++ headers for PyBoost operations.
@@ -42,6 +50,11 @@ class PyboostCommonOpHeaderGenerator(BaseGenerator):
42
50
 
43
51
  def __init__(self):
44
52
  self.pyboost_op_header_str = template.PYBOOST_BASE_OP_DEFINE_TEMPLATE
53
+ self.pyboost_basic_type_func_template = Template(
54
+ 'virtual ${return_type} Call(${call_args_with_type}) {' \
55
+ '\n MS_EXCEPTION(NotImplementedError) << "Basic type func not implemented";' \
56
+ '\n};'
57
+ )
45
58
 
46
59
  def generate(self, work_path, op_protos):
47
60
  """
@@ -59,7 +72,10 @@ class PyboostCommonOpHeaderGenerator(BaseGenerator):
59
72
  continue
60
73
  op_parser = OpTemplateParser(op_proto)
61
74
  op_name_str = op_proto.op_class.name
62
- call_args_with_type = op_parser.parse_call_args_with_types()
75
+ if op_proto.op_view and not check_no_basic_int_type(op_proto.op_args):
76
+ call_args_with_type = op_parser.parse_call_args_with_types(basic_type=True)
77
+ else:
78
+ call_args_with_type = op_parser.parse_call_args_with_types(basic_type=False)
63
79
  cpp_func_return = _generate_cpp_func_return(op_proto)
64
80
  output_is_tuple = "bool output_is_tuple() const override { return true; }" \
65
81
  if is_op_multi_output(op_proto.op_returns) else ''
@@ -121,16 +137,77 @@ class PyboostOpHeaderGenerator(BaseGenerator):
121
137
  is_ascend_comm_op = op_proto.op_dispatch.is_comm_op and self.device == 'ascend'
122
138
  op_parser = OpTemplateParser(op_proto)
123
139
  op_name_str = op_proto.op_class.name
124
- call_args_with_type = op_parser.parse_call_args_with_types()
140
+ if op_proto.op_view and not check_no_basic_int_type(op_proto.op_args):
141
+ call_args_with_type = op_parser.parse_call_args_with_types(basic_type=True)
142
+ else:
143
+ call_args_with_type = op_parser.parse_call_args_with_types(basic_type=False)
125
144
  cpp_func_return = _generate_cpp_func_return(op_proto)
126
-
127
145
  pyboost_op_str = self.PYBOOST_OP_HEADER_TEMPLATE.replace(op_name=op_name_str,
128
146
  op_name_upper=op_name_str.upper(),
129
147
  operator_name=op_proto.op_name,
130
148
  call_args_with_type=call_args_with_type,
131
149
  return_type=cpp_func_return)
150
+ save_path = os.path.join(work_path, self.code_generate_path if not is_ascend_comm_op \
151
+ else self.hccl_code_generate_path)
152
+ file_name = f"{op_proto.op_name}.h"
153
+ save_file(save_path, file_name, pyboost_op_str)
154
+
155
+
156
+ class PyboostInternalOpHeaderGenerator(BaseGenerator):
157
+ """
158
+ Generates C++ headers for PyBoost internal operations.
132
159
 
133
- save_path = os.path.join(work_path, self.code_generate_path if not is_ascend_comm_op else self.hccl_code_generate_path)
160
+ This class generates header files for Ascend and defines the operation functions accordingly.
161
+ """
162
+
163
+ def __init__(self, device):
164
+ """
165
+ Initializes the PyboostOpHeaderGenerator with the appropriate templates for the specified device.
166
+
167
+ Args:
168
+ device (str): The target device (ascend, gpu, or cpu), currently only support ascend.
169
+
170
+ Raises:
171
+ ValueError: If the device is not supported.
172
+ """
173
+ if device != 'ascend':
174
+ raise ValueError(
175
+ f"Currently, only support 'ascend' for internal operations, {device} is not supported.")
176
+ self.pyboost_internal_op_header_template = template.PYBOOST_ASCEND_INTERNAL_OP_HEADER_TEMPLATE
177
+ self.code_generate_path = f"{K.MS_OPS_KERNEL_PATH}/{device}/pyboost/internal/auto_generate/"
178
+ self.device = device
179
+
180
+ def generate(self, work_path, op_protos):
181
+ """
182
+ Generates header files for the provided operator prototypes based on the device.
183
+
184
+ Args:
185
+ work_path (str): The directory path where the header files will be saved.
186
+ op_protos (list): A list of operator prototypes containing information about the operators.
187
+
188
+ Returns:
189
+ None
190
+ """
191
+ for op_proto in op_protos:
192
+ if op_proto.op_dispatch is None:
193
+ continue
194
+ if getattr(op_proto.op_dispatch, self.device) == 'None':
195
+ continue
196
+ if getattr(op_proto.op_dispatch, 'internal_op_ascend') == 'None':
197
+ continue
198
+ op_parser = OpTemplateParser(op_proto)
199
+ op_name_str = op_proto.op_class.name
200
+ call_args_with_type = op_parser.parse_call_args_with_types()
201
+ cpp_func_return = _generate_cpp_func_return(op_proto)
202
+
203
+ pyboost_op_str = self.pyboost_internal_op_header_template.replace(
204
+ op_name=op_name_str,
205
+ op_name_upper=op_name_str.upper(),
206
+ operator_name=op_proto.op_name,
207
+ call_args_with_type=call_args_with_type,
208
+ return_type=cpp_func_return)
209
+
210
+ save_path = os.path.join(work_path, self.code_generate_path)
134
211
  file_name = f"{op_proto.op_name}.h"
135
212
  save_file(save_path, file_name, pyboost_op_str)
136
213
 
@@ -158,19 +235,24 @@ class PyboostOpCppGenerator:
158
235
  PYBOOST_SINGLE_OP_HEADER_TEMPLATE = template.PYBOOST_ASCEND_SINGLE_OP_HEADER_TEMPLATE
159
236
  PYBOOST_SINGLE_OP_SOURCE_TEMPLATE = template.PYBOOST_ASCEND_SINGLE_OP_SOURCE_TEMPLATE
160
237
  gen_path = f"{K.MS_OPS_KERNEL_PATH}/ascend/pyboost/auto_generate/"
238
+ self.device_reg_str = "Ascend"
161
239
  elif device == 'cpu':
162
240
  PYBOOST_CUSTOMIZE_CALL_TEMPLATE = template.PYBOOST_CPU_CUSTOMIZE_CALL_TEMPLATE
163
241
  PYBOOST_SINGLE_OP_HEADER_TEMPLATE = template.PYBOOST_CPU_SINGLE_OP_HEADER_TEMPLATE
164
- PYBOOST_SINGLE_OP_SOURCE_TEMPLATE = template.PYBOOST_CPU_SINGLE_OP_SOURCE_TEMPLATE
242
+ PYBOOST_SINGLE_OP_SOURCE_TEMPLATE = template.PYBOOST_ASCEND_SINGLE_OP_SOURCE_TEMPLATE
165
243
  gen_path = f"{K.MS_OPS_KERNEL_PATH}/cpu/pyboost/auto_generate/"
244
+ self.device_reg_str = "CPU"
166
245
  elif device == 'gpu':
167
246
  PYBOOST_CUSTOMIZE_CALL_TEMPLATE = template.PYBOOST_GPU_CUSTOMIZE_CALL_TEMPLATE
168
247
  PYBOOST_SINGLE_OP_HEADER_TEMPLATE = template.PYBOOST_GPU_SINGLE_OP_HEADER_TEMPLATE
169
- PYBOOST_SINGLE_OP_SOURCE_TEMPLATE = template.PYBOOST_GPU_SINGLE_OP_SOURCE_TEMPLATE
248
+ PYBOOST_SINGLE_OP_SOURCE_TEMPLATE = template.PYBOOST_ASCEND_SINGLE_OP_SOURCE_TEMPLATE
170
249
  gen_path = f"{K.MS_OPS_KERNEL_PATH}/gpu/pyboost/auto_generate/"
250
+ self.device_reg_str = "GPU"
171
251
  else:
172
252
  raise ValueError(
173
253
  f"Device must be ascend, gpu, or cpu, {device} is not supported")
254
+ self.PYBOOST_REG_OP_TEMPLATE = Template('MS_REG_PYBOOST_OP(${device}, ${op_name});' \
255
+ '${register_custom_kernel}')
174
256
  self.PYBOOST_CUSTOMIZE_CALL_TEMPLATE = PYBOOST_CUSTOMIZE_CALL_TEMPLATE
175
257
  self.PYBOOST_SINGLE_OP_HEADER_TEMPLATE = PYBOOST_SINGLE_OP_HEADER_TEMPLATE
176
258
  self.PYBOOST_SINGLE_OP_SOURCE_TEMPLATE = PYBOOST_SINGLE_OP_SOURCE_TEMPLATE
@@ -201,8 +283,11 @@ class PyboostOpCppGenerator:
201
283
  continue
202
284
  is_ascend_comm_op = op_proto.op_dispatch.is_comm_op and self.device == 'ascend'
203
285
  op_parser = OpTemplateParser(op_proto)
204
- call_args = op_parser.parse_original_call_args(op_proto.op_args)
205
- call_args_with_type = op_parser.parse_call_args_with_types()
286
+ call_args = OpTemplateParser.parse_original_call_args(op_proto.op_args)
287
+ if op_proto.op_view and not check_no_basic_int_type(op_proto.op_args):
288
+ call_args_with_type = op_parser.parse_call_args_with_types(True)
289
+ else:
290
+ call_args_with_type = op_parser.parse_call_args_with_types()
206
291
  _, call_func_outputs = op_parser.generate_pyboost_outputs()
207
292
  operator_name = op_proto.op_name
208
293
  op_name_str = op_proto.op_class.name
@@ -219,7 +304,8 @@ class PyboostOpCppGenerator:
219
304
  check_expression=check_inplace_func,
220
305
  )
221
306
  if is_ascend_comm_op and ((merge_op_hccl_header is None) or (merge_op_hccl_function is None)):
222
- raise ValueError(f"merge_op_hccl_header and merge_op_hccl_function must be provided for comm op {operator_name}")
307
+ raise ValueError(f"merge_op_hccl_header and merge_op_hccl_function \
308
+ must be provided for comm op {operator_name}")
223
309
 
224
310
  if is_ascend_comm_op:
225
311
  customize_include = \
@@ -230,23 +316,30 @@ class PyboostOpCppGenerator:
230
316
 
231
317
  register_custom = self._get_register_custom_kernel(op_proto)
232
318
  cpp_func_return = _generate_cpp_func_return(op_proto)
319
+ op_register = self.PYBOOST_REG_OP_TEMPLATE.replace(op_name=op_name_str,
320
+ device=self.device_reg_str,
321
+ register_custom_kernel=register_custom)
233
322
  if is_ascend_comm_op:
234
- merge_op_hccl_header.append(self.PYBOOST_SINGLE_HCLL_OP_HEADER_TEMPLATE.replace(operator_name=operator_name,
235
- customize_include=customize_include))
323
+ merge_op_hccl_header.append(
324
+ self.PYBOOST_SINGLE_HCLL_OP_HEADER_TEMPLATE.replace(operator_name=operator_name,
325
+ customize_include=customize_include))
236
326
  merge_op_hccl_function.append(
237
327
  self.PYBOOST_SINGLE_OP_SOURCE_TEMPLATE.replace(op_name=op_name_str,
238
- call_args_with_type=call_args_with_type,
239
- return_type=cpp_func_return, call_impl=call_impl,
240
- register_custom_kernel=register_custom))
328
+ call_args_with_type=call_args_with_type,
329
+ return_type=cpp_func_return, call_impl=call_impl,
330
+ op_register=op_register,
331
+ device=self.device_reg_str))
241
332
  merge_op_hccl_inc.append(op_name_str)
242
333
  else:
243
- merge_op_header.append(self.PYBOOST_SINGLE_OP_HEADER_TEMPLATE.replace(operator_name=operator_name,
244
- customize_include=customize_include))
334
+ merge_op_header.append(
335
+ self.PYBOOST_SINGLE_OP_HEADER_TEMPLATE.replace(operator_name=operator_name,
336
+ customize_include=customize_include))
245
337
  merge_op_function.append(
246
338
  self.PYBOOST_SINGLE_OP_SOURCE_TEMPLATE.replace(op_name=op_name_str,
247
- call_args_with_type=call_args_with_type,
248
- return_type=cpp_func_return, call_impl=call_impl,
249
- register_custom_kernel=register_custom))
339
+ call_args_with_type=call_args_with_type,
340
+ return_type=cpp_func_return, call_impl=call_impl,
341
+ op_register=op_register,
342
+ device=self.device_reg_str))
250
343
  merge_op_inc.append(op_name_str)
251
344
 
252
345
  def _get_register_custom_kernel(self, op_proto: OpProto):
@@ -294,19 +387,24 @@ class PyboostViewOpCppGenerator:
294
387
  PYBOOST_SINGLE_OP_HEADER_TEMPLATE = template.PYBOOST_ASCEND_SINGLE_OP_HEADER_TEMPLATE
295
388
  PYBOOST_SINGLE_OP_SOURCE_TEMPLATE = template.PYBOOST_ASCEND_SINGLE_OP_SOURCE_TEMPLATE
296
389
  gen_path = f"{K.MS_OPS_KERNEL_PATH}/ascend/pyboost/auto_generate/"
390
+ self.device_reg_str = "Ascend"
297
391
  elif device == 'cpu':
298
392
  PYBOOST_VIEW_CALL_TEMPLATE = template.PYBOOST_CPU_VIEW_CALL_TEMPLATE
299
393
  PYBOOST_SINGLE_OP_HEADER_TEMPLATE = template.PYBOOST_CPU_SINGLE_OP_HEADER_TEMPLATE
300
- PYBOOST_SINGLE_OP_SOURCE_TEMPLATE = template.PYBOOST_CPU_SINGLE_OP_SOURCE_TEMPLATE
394
+ PYBOOST_SINGLE_OP_SOURCE_TEMPLATE = template.PYBOOST_ASCEND_SINGLE_OP_SOURCE_TEMPLATE
301
395
  gen_path = f"{K.MS_OPS_KERNEL_PATH}/cpu/pyboost/auto_generate/"
396
+ self.device_reg_str = "CPU"
302
397
  elif device == 'gpu':
303
398
  PYBOOST_VIEW_CALL_TEMPLATE = template.PYBOOST_GPU_VIEW_CALL_TEMPLATE
304
399
  PYBOOST_SINGLE_OP_HEADER_TEMPLATE = template.PYBOOST_GPU_SINGLE_OP_HEADER_TEMPLATE
305
- PYBOOST_SINGLE_OP_SOURCE_TEMPLATE = template.PYBOOST_GPU_SINGLE_OP_SOURCE_TEMPLATE
400
+ PYBOOST_SINGLE_OP_SOURCE_TEMPLATE = template.PYBOOST_ASCEND_SINGLE_OP_SOURCE_TEMPLATE
306
401
  gen_path = f"{K.MS_OPS_KERNEL_PATH}/gpu/pyboost/auto_generate/"
402
+ self.device_reg_str = "GPU"
307
403
  else:
308
404
  raise ValueError(
309
405
  f"Device must be ascend, gpu, or cpu, {device} is not supported")
406
+ self.PYBOOST_REG_OP_TEMPLATE = Template('MS_REG_PYBOOST_OP(${device}, ${op_name});' \
407
+ '${register_custom_kernel}')
310
408
  self.PYBOOST_VIEW_CALL_TEMPLATE = PYBOOST_VIEW_CALL_TEMPLATE
311
409
  self.PYBOOST_SINGLE_OP_HEADER_TEMPLATE = PYBOOST_SINGLE_OP_HEADER_TEMPLATE
312
410
  self.PYBOOST_SINGLE_OP_SOURCE_TEMPLATE = PYBOOST_SINGLE_OP_SOURCE_TEMPLATE
@@ -327,6 +425,7 @@ class PyboostViewOpCppGenerator:
327
425
  merge_op_header (list): A list to store the generated C++ header code for view operations.
328
426
  merge_op_function (list): A list to store the generated C++ source code for view operations.
329
427
  """
428
+ calc_args_temp = Template("{${call_args}}")
330
429
  for op_proto in op_protos:
331
430
  if op_proto.op_dispatch is None:
332
431
  continue
@@ -339,10 +438,19 @@ class PyboostViewOpCppGenerator:
339
438
 
340
439
  op_parser = OpTemplateParser(op_proto)
341
440
  call_args_tensor = op_parser.get_call_args_tensor()
342
- call_args = op_parser.parse_original_call_args(op_proto.op_args)
343
- call_args_with_type = op_parser.parse_call_args_with_types()
441
+ call_args = OpTemplateParser.parse_original_call_args(op_proto.op_args)
442
+ if op_proto.op_view and not check_no_basic_int_type(op_proto.op_args):
443
+ call_args_with_type = op_parser.parse_call_args_with_types(True)
444
+ storage_calc_str = op_proto.op_class.name + "BasicType"
445
+ calc_func_args_str = call_args
446
+ else:
447
+ call_args_with_type = op_parser.parse_call_args_with_types()
448
+ storage_calc_str = op_proto.op_class.name
449
+ calc_func_args_str = calc_args_temp.replace(call_args=call_args)
344
450
  _, call_func_outputs = op_parser.generate_pyboost_outputs()
345
451
  call_impl = self.PYBOOST_VIEW_CALL_TEMPLATE.replace(op_name=op_proto.op_class.name,
452
+ storage_calc=storage_calc_str,
453
+ calc_func_args=calc_func_args_str,
346
454
  call_args=call_args,
347
455
  call_tensors=call_args_tensor,
348
456
  return_values=call_func_outputs,
@@ -351,13 +459,16 @@ class PyboostViewOpCppGenerator:
351
459
  cpp_func_return = _generate_cpp_func_return(op_proto)
352
460
  merge_op_header.append(self.PYBOOST_SINGLE_OP_HEADER_TEMPLATE.replace(operator_name=op_proto.op_name,
353
461
  customize_include=customize_include))
354
-
462
+ op_register = self.PYBOOST_REG_OP_TEMPLATE.replace(op_name=op_proto.op_class.name,
463
+ device=self.device_reg_str,
464
+ register_custom_kernel="")
355
465
  merge_op_function.append(
356
466
  self.PYBOOST_SINGLE_OP_SOURCE_TEMPLATE.replace(op_name=op_proto.op_class.name,
357
467
  call_args_with_type=call_args_with_type,
358
468
  return_type=cpp_func_return,
359
469
  call_impl=call_impl,
360
- register_custom_kernel=""))
470
+ op_register=op_register,
471
+ device=self.device_reg_str))
361
472
  ascend_merge_op_inc.append(op_proto.op_class.name)
362
473
 
363
474
 
@@ -389,17 +500,22 @@ class AclnnOpCppCodeGenerator:
389
500
  PYBOOST_CALL_TEMPLATE = template.PYBOOST_ASCEND_CALL_TEMPLATE
390
501
  PYBOOST_SINGLE_OP_SOURCE_TEMPLATE = template.PYBOOST_ASCEND_SINGLE_OP_SOURCE_TEMPLATE
391
502
  gen_path = f"{K.MS_OPS_KERNEL_PATH}/ascend/pyboost/auto_generate/"
503
+ self.device_reg_str = "Ascend"
392
504
  elif device == 'cpu':
393
505
  PYBOOST_CALL_TEMPLATE = template.PYBOOST_CPU_CALL_TEMPLATE
394
- PYBOOST_SINGLE_OP_SOURCE_TEMPLATE = template.PYBOOST_CPU_SINGLE_OP_SOURCE_TEMPLATE
506
+ PYBOOST_SINGLE_OP_SOURCE_TEMPLATE = template.PYBOOST_ASCEND_SINGLE_OP_SOURCE_TEMPLATE
395
507
  gen_path = f"{K.MS_OPS_KERNEL_PATH}/cpu/pyboost/auto_generate/"
508
+ self.device_reg_str = "CPU"
396
509
  elif device == 'gpu':
397
510
  PYBOOST_CALL_TEMPLATE = template.PYBOOST_GPU_CALL_TEMPLATE
398
- PYBOOST_SINGLE_OP_SOURCE_TEMPLATE = template.PYBOOST_GPU_SINGLE_OP_SOURCE_TEMPLATE
511
+ PYBOOST_SINGLE_OP_SOURCE_TEMPLATE = template.PYBOOST_ASCEND_SINGLE_OP_SOURCE_TEMPLATE
399
512
  gen_path = f"{K.MS_OPS_KERNEL_PATH}/gpu/pyboost/auto_generate/"
513
+ self.device_reg_str = "GPU"
400
514
  else:
401
515
  raise ValueError(
402
516
  f"Device must be ascend, gpu, or cpu, {device} is not supported")
517
+ self.PYBOOST_REG_OP_TEMPLATE = Template('MS_REG_PYBOOST_OP(${device}, ${op_name});' \
518
+ '${register_custom_kernel}')
403
519
  self.PYBOOST_CALL_TEMPLATE = PYBOOST_CALL_TEMPLATE
404
520
  self.PYBOOST_SINGLE_OP_HEADER_TEMPLATE = template.Template(
405
521
  '#include "kernel/${device}/pyboost/auto_generate/${operator_name}.h"\n'
@@ -438,11 +554,11 @@ class AclnnOpCppCodeGenerator:
438
554
  aclnn_name = AclnnUtils.get_aclnn_interface(op_proto.op_class.name)
439
555
 
440
556
  call_args_tensor = op_parser.get_call_args_tensor()
441
- create_input_address = self._generate_create_input_address(
557
+ create_input_address = AclnnOpCppCodeGenerator._generate_create_input_address(
442
558
  op_parser)
443
- malloc_inputs = self._generate_malloc_input(op_parser)
559
+ malloc_inputs = AclnnOpCppCodeGenerator._generate_malloc_input(op_parser)
444
560
  op_outputs, call_func_outputs = op_parser.generate_pyboost_outputs()
445
- get_inputs_kernel_tensors = self._generate_get_inputs_kernel_tensors(
561
+ get_inputs_kernel_tensors = AclnnOpCppCodeGenerator._generate_get_inputs_kernel_tensors(
446
562
  op_parser)
447
563
 
448
564
  cube_math_type, get_cube_math_type = '', ''
@@ -454,13 +570,16 @@ class AclnnOpCppCodeGenerator:
454
570
  real_output = ', ' + op_outputs \
455
571
  if _generate_inplace_process_cpp_code(op_proto) == '' else ''
456
572
 
457
- cast_input_code, real_call_args_tensor = self._generate_tensor_cpu_cast_input_code(
573
+ cast_input_code, real_call_args_tensor = AclnnOpCppCodeGenerator._generate_tensor_cpu_cast_input_code(
458
574
  op_parser)
459
575
  cpp_func_return = _generate_cpp_func_return(op_proto)
460
576
  _, tensor_list_convert, call_args_with_tensor = op_parser.parse_need_malloc_tensors()
461
577
  call_args_after_convert, value_tuple_convert, const_number_convert = op_parser.op_args_converter()
462
- call_args = op_parser.parse_original_call_args(op_proto.op_args)
463
- call_args_with_type = op_parser.parse_call_args_with_types()
578
+ call_args = OpTemplateParser.parse_original_call_args(op_proto.op_args)
579
+ if op_proto.op_view and not check_no_basic_int_type(op_proto.op_args):
580
+ call_args_with_type = op_parser.parse_call_args_with_types(True)
581
+ else:
582
+ call_args_with_type = op_parser.parse_call_args_with_types()
464
583
  inplace_process = _generate_inplace_process_cpp_code(op_proto)
465
584
  call_impl = self.PYBOOST_CALL_TEMPLATE.replace(aclnn_name=aclnn_name,
466
585
  call_args=call_args,
@@ -485,16 +604,20 @@ class AclnnOpCppCodeGenerator:
485
604
 
486
605
  merge_op_header.append(self.PYBOOST_SINGLE_OP_HEADER_TEMPLATE.replace(operator_name=op_proto.op_name,
487
606
  device=self.device))
488
-
607
+ op_register = self.PYBOOST_REG_OP_TEMPLATE.replace(op_name=op_proto.op_class.name,
608
+ device=self.device_reg_str,
609
+ register_custom_kernel="")
489
610
  merge_op_function.append(
490
611
  self.PYBOOST_SINGLE_OP_SOURCE_TEMPLATE.replace(op_name=op_proto.op_class.name,
491
612
  call_args_with_type=call_args_with_type,
492
613
  return_type=cpp_func_return,
493
614
  call_impl=call_impl,
494
- register_custom_kernel=''))
615
+ op_register=op_register,
616
+ device=self.device_reg_str))
495
617
  ascend_merge_op_inc.append(op_proto.op_class.name)
496
618
 
497
- def _generate_tensor_cpu_cast_input_code(self, op_parser: OpTemplateParser):
619
+ @staticmethod
620
+ def _generate_tensor_cpu_cast_input_code(op_parser: OpTemplateParser):
498
621
  """
499
622
  Generates the input casting code for CPU tensor operations.
500
623
 
@@ -524,18 +647,17 @@ class AclnnOpCppCodeGenerator:
524
647
  cast_input = "auto &select_kernel = kernel_attr_pair.second;\n" + cast_input
525
648
  return cast_input, real_call_args_tensor
526
649
 
527
- def _generate_create_input_address(self, op_parser: OpTemplateParser):
650
+ @staticmethod
651
+ def _generate_create_input_address(op_parser: OpTemplateParser):
528
652
  need_malloc_tensors, _, _ = op_parser.parse_need_malloc_tensors()
529
653
  create_input_address = ''
530
- args_list = ''
531
- for item in need_malloc_tensors:
532
- args_list += f'{item}, '
533
- args_list = args_list[:-2]
654
+ args_list = ', '.join(str(item) for item in need_malloc_tensors)
534
655
  if args_list:
535
656
  create_input_address = f'PyBoostUtils::PrepareOpInputs(device_context_, op->stream_id(), {args_list});\n'
536
657
  return create_input_address
537
658
 
538
- def _generate_malloc_input(self, op_parser: OpTemplateParser):
659
+ @staticmethod
660
+ def _generate_malloc_input(op_parser: OpTemplateParser):
539
661
  """
540
662
  Generates the code for creating input addresses for tensors that need to be allocated.
541
663
 
@@ -547,15 +669,13 @@ class AclnnOpCppCodeGenerator:
547
669
  """
548
670
  need_malloc_tensors, _, _ = op_parser.parse_need_malloc_tensors()
549
671
  malloc_inputs = ''
550
- args_list = ''
551
- for item in need_malloc_tensors:
552
- args_list += f'{item}, '
553
- args_list = args_list[:-2]
672
+ args_list = ', '.join(str(item) for item in need_malloc_tensors)
554
673
  if args_list:
555
674
  malloc_inputs += f'PyBoostUtils::MallocOpInputs(device_context, {args_list});\n'
556
675
  return malloc_inputs
557
676
 
558
- def _generate_get_inputs_kernel_tensors(self, op_parser: OpTemplateParser):
677
+ @staticmethod
678
+ def _generate_get_inputs_kernel_tensors(op_parser: OpTemplateParser):
559
679
  """
560
680
  Generates the code for retrieving input kernel tensors.
561
681
 
@@ -567,16 +687,178 @@ class AclnnOpCppCodeGenerator:
567
687
  """
568
688
  _, _, call_args_with_tensor = op_parser.parse_need_malloc_tensors()
569
689
  inputs_kernel_tensors = ''
570
- args_list = ''
571
- for item in call_args_with_tensor:
572
- args_list += f'{item}, '
573
- args_list = args_list[:-2]
690
+ args_list = ', '.join(str(item) for item in call_args_with_tensor)
574
691
  if args_list:
575
692
  inputs_kernel_tensors += f'const auto &input_address_info = PyBoostUtils::GetAddressInfo(' \
576
693
  f'device_context, op->stream_id(), op->input_abs(), {args_list});\n'
577
694
  return inputs_kernel_tensors
578
695
 
579
696
 
697
+ class InternalOpCppCodeGenerator:
698
+ """
699
+ Generates C++ code files for internal operations in PyBoost.
700
+ """
701
+
702
+ def __init__(self, device):
703
+ """
704
+ Initializes the InternalOpCppCodeGenerator with the appropriate templates.
705
+ """
706
+ self.device = device
707
+ self.internal_op_header_template = template.PYBOOST_INTERNAL_OP_HEADER_TEMPLATE
708
+ self.internal_single_op_header_template = template.PYBOOST_INTERNAL_SINGLE_OP_HEADER_TEMPLATE
709
+ self.internal_op_source_template = template.PYBOOST_INTERNAL_OP_SOURCE_TEMPLATE
710
+ self.internal_single_op_source_template = template.PYBOOST_INTERNAL_SINGLE_OP_SOURCE_TEMPLATE
711
+ self.internal_single_op_customize_source_template = template.PYBOOST_INTERNAL_SINGLE_OP_CUSTOMIZE_TEMPLATE
712
+ self.customize_inc_template = Template(
713
+ '#include "{ms_ops_kernel_path}/ascend/pyboost/internal/customize/${operator_name}.h"\n'
714
+ )
715
+ self.gen_path = f"{K.MS_OPS_KERNEL_PATH}/ascend/pyboost/internal/auto_generate/"
716
+
717
+ def generate_internal_op_cpp_code(self, work_path, op_protos):
718
+ """
719
+ Generate internal op cpp code in pyboost.
720
+ """
721
+ merge_op_header = []
722
+ merge_op_function = []
723
+ ascend_merge_op_inc = []
724
+ for op_proto in op_protos:
725
+ if op_proto.op_dispatch is None or not op_proto.op_dispatch.enable:
726
+ continue
727
+ if getattr(op_proto.op_dispatch, 'internal_op_ascend') == 'None':
728
+ continue
729
+ internal_op_ascend = op_proto.op_dispatch.internal_op_ascend
730
+ op_name = op_proto.op_class.name
731
+ if internal_op_ascend == 'AutoGen':
732
+ self.generate_default_call(work_path, op_proto, merge_op_header,
733
+ merge_op_function, ascend_merge_op_inc)
734
+ elif internal_op_ascend == 'Internal' + op_name + 'AscendCustomize':
735
+ self.generate_customize_call(work_path, op_proto, merge_op_header,
736
+ merge_op_function, ascend_merge_op_inc)
737
+
738
+ if not ascend_merge_op_inc:
739
+ return
740
+ ops_inc_head_set = set()
741
+ for op_name_inc in ascend_merge_op_inc:
742
+ ops_inc_head_set.add(template.OP_DEF_INC_HEAD_TEMPLATE.replace(prefix_char=op_name_inc[0].lower()))
743
+
744
+ internal_op_source_str = self.internal_op_source_template.replace(ops_prim_inc=list(sorted(ops_inc_head_set)),
745
+ merge_op_header=merge_op_header,
746
+ merge_op_function=merge_op_function)
747
+ save_path = os.path.join(work_path, self.gen_path)
748
+ file_name = "pyboost_ascend_internal_ops.cc"
749
+ save_file(save_path, file_name, internal_op_source_str)
750
+
751
+ def generate_default_op_function(self, op_parser, op_proto):
752
+ """
753
+ Generate default op call function.
754
+ """
755
+ call_args_with_type = op_parser.parse_call_args_with_types()
756
+ cpp_func_return = _generate_cpp_func_return(op_proto)
757
+ _, call_func_outputs = op_parser.generate_pyboost_outputs()
758
+ call_args = OpTemplateParser.parse_original_call_args(op_proto.op_args)
759
+ call_args_after_convert, value_tuple_convert, const_number_convert = op_parser.op_args_converter()
760
+ create_input_address, create_output_address = self._create_input_and_output_address(op_parser, op_proto)
761
+ internal_op_source_str = self.internal_single_op_source_template.replace(
762
+ op_name=op_proto.op_class.name,
763
+ operator_name=op_proto.op_name,
764
+ call_args_with_type=call_args_with_type,
765
+ internal_call_args=call_args,
766
+ internal_real_call_args=call_args_after_convert,
767
+ create_input_address=create_input_address,
768
+ create_output_address=create_output_address,
769
+ value_tuple_convert=value_tuple_convert,
770
+ const_number_convert=const_number_convert,
771
+ return_type=cpp_func_return,
772
+ return_values=call_func_outputs)
773
+ return internal_op_source_str
774
+
775
+ def generate_default_call(self, work_path, op_proto, merge_op_header,
776
+ merge_op_function, ascend_merge_op_inc):
777
+ """
778
+ Generate internal op default call function in pyboost.
779
+ """
780
+ op_parser = OpTemplateParser(op_proto)
781
+ call_args_with_type = op_parser.parse_call_args_with_types()
782
+ cpp_func_return = _generate_cpp_func_return(op_proto)
783
+
784
+ # generate op header
785
+ internal_op_header_str = self.internal_op_header_template.replace(
786
+ operator_name=op_proto.op_name,
787
+ op_name=op_proto.op_class.name,
788
+ op_name_upper=op_proto.op_class.name.upper(),
789
+ call_args_with_type=call_args_with_type,
790
+ return_type=cpp_func_return)
791
+ save_path = os.path.join(work_path, self.gen_path)
792
+ save_file(save_path, f"{op_proto.op_name}.h", internal_op_header_str)
793
+ merge_op_header.append(
794
+ self.internal_single_op_header_template.replace(
795
+ operator_name=op_proto.op_name,
796
+ customize_inc=''))
797
+
798
+ # generate op function
799
+ internal_op_source_str = self.generate_default_op_function(op_parser, op_proto)
800
+ merge_op_function.append(internal_op_source_str)
801
+
802
+ ascend_merge_op_inc.append(op_proto.op_class.name)
803
+
804
+ def generate_customize_call(self, work_path, op_proto, merge_op_header,
805
+ merge_op_function, ascend_merge_op_inc):
806
+ """
807
+ Generate internal op customize call function in pyboost.
808
+ """
809
+ op_parser = OpTemplateParser(op_proto)
810
+ call_args_with_type = op_parser.parse_call_args_with_types()
811
+ cpp_func_return = _generate_cpp_func_return(op_proto)
812
+
813
+ # generate op header
814
+ internal_op_header_str = self.internal_op_header_template.replace(
815
+ operator_name=op_proto.op_name,
816
+ op_name=op_proto.op_class.name,
817
+ op_name_upper=op_proto.op_class.name.upper(),
818
+ call_args_with_type=call_args_with_type,
819
+ return_type=cpp_func_return)
820
+ save_path = os.path.join(work_path, self.gen_path)
821
+ save_file(save_path, f"{op_proto.op_name}.h", internal_op_header_str)
822
+ self.customize_inc_template.replace(
823
+ ms_ops_kernel_path=K.MS_OPS_KERNEL_PATH,
824
+ operator_name=op_proto.op_name)
825
+ merge_op_header.append(
826
+ self.internal_single_op_header_template.replace(
827
+ operator_name=op_proto.op_name,
828
+ customize_inc=self.customize_inc_template))
829
+
830
+ # generate op function
831
+ _, call_func_outputs = op_parser.generate_pyboost_outputs()
832
+ call_args = OpTemplateParser.parse_original_call_args(op_proto.op_args)
833
+ internal_op_source_str = self.internal_single_op_customize_source_template.replace(
834
+ op_name=op_proto.op_class.name,
835
+ call_args=call_args,
836
+ call_args_with_type=call_args_with_type,
837
+ return_type=cpp_func_return,
838
+ return_values=call_func_outputs)
839
+ merge_op_function.append(internal_op_source_str)
840
+ ascend_merge_op_inc.append(op_proto.op_class.name)
841
+
842
+ @staticmethod
843
+ def _create_input_and_output_address(op_parser: OpTemplateParser, op_proto):
844
+ """
845
+ Create input and output address.
846
+ """
847
+ need_malloc_tensors, _, _ = op_parser.parse_need_malloc_tensors()
848
+ create_input_address = ''
849
+ create_output_address = ''
850
+ args_list = ''.join(f'{arg}, ' for arg in need_malloc_tensors)
851
+ args_list = args_list[:-2]
852
+ if args_list:
853
+ create_input_address = f'PyBoostUtils::PrepareOpInputs(device_context_, op->stream_id(), {args_list});\n'
854
+ if op_proto.op_args_signature and op_proto.op_args_signature.rw_write:
855
+ create_output_address = ''
856
+ else:
857
+ create_output_address = 'PyBoostUtils::PrepareOpOutputs(device_context_, op->stream_id(), outputs_);\n'
858
+
859
+ return create_input_address, create_output_address
860
+
861
+
580
862
  class PyboostOpFunctionGenerator(BaseGenerator):
581
863
  """
582
864
  Generates C++ source files for ACLNN operations in PyBoost.
@@ -595,6 +877,7 @@ class PyboostOpFunctionGenerator(BaseGenerator):
595
877
  self.ascend_op_cpp_generator = PyboostOpCppGenerator('ascend')
596
878
  self.ascend_view_op_cpp_generator = PyboostViewOpCppGenerator('ascend')
597
879
  self.ascend_aclnn_cpp_generator = AclnnOpCppCodeGenerator('ascend')
880
+ self.ascend_internal_op_cpp_generator = InternalOpCppCodeGenerator('ascend')
598
881
 
599
882
  self.cpu_op_cpp_generator = PyboostOpCppGenerator('cpu')
600
883
  self.cpu_view_op_cpp_generator = PyboostViewOpCppGenerator('cpu')
@@ -659,6 +942,7 @@ class PyboostOpFunctionGenerator(BaseGenerator):
659
942
  self.ascend_aclnn_cpp_generator.generate_aclnn_op_cpp_code(op_protos, ascend_merge_op_header,
660
943
  ascend_merge_op_function,
661
944
  ascend_merge_op_inc)
945
+ self.ascend_internal_op_cpp_generator.generate_internal_op_cpp_code(work_path, op_protos)
662
946
 
663
947
  ascend_op_header_merge_by_chunk_size = merge_strings_by_chunk_size(
664
948
  ascend_merge_op_header, chunk_size=120)
@@ -688,8 +972,8 @@ class PyboostOpFunctionGenerator(BaseGenerator):
688
972
  hccl_pyboost_op_source = self.PYBOOST_ASCEND_OP_SOURCE_TEMPLATE.replace(
689
973
  merge_op_header='\n'.join(hccl_merge_op_header), merge_op_function='\n'.join(hccl_merge_op_function),
690
974
  ops_inc=list(sorted(ops_hccl_inc_head_set)))
691
- save_file(os.path.join(work_path, self.hccl_gen_path), f"pyboost_hccl_ops.cc",
692
- hccl_pyboost_op_source)
975
+ save_file(os.path.join(work_path, self.hccl_gen_path), f"pyboost_hccl_ops.cc", \
976
+ hccl_pyboost_op_source)
693
977
 
694
978
  def _generate_pyboost_cpu_ops(self, work_path, op_protos):
695
979
  """
@@ -788,8 +1072,7 @@ class PyboostOpFunctionGenerator(BaseGenerator):
788
1072
  None
789
1073
  """
790
1074
  all_files = os.listdir(files_path)
791
- old_pyboost_ops_files = [file for file in all_files if re.match(
792
- r'pyboost_.*_ops_.*\.cc', file)]
1075
+ old_pyboost_ops_files = [file for file in all_files if re.match(r'pyboost_.*_ops_.*\.cc', file)]
793
1076
  old_files_num = len(old_pyboost_ops_files)
794
1077
  if new_gen_num != old_files_num:
795
1078
  for file in old_pyboost_ops_files:
@@ -810,8 +1093,8 @@ def _generate_cpp_func_return(op_proto):
810
1093
  """
811
1094
  returns_type = []
812
1095
  type_convert_to_base = {
813
- 'std::vector<mindspore::tensor::TensorPtr>': 'std::vector<mindspore::tensor::BaseTensorPtr>',
814
- 'mindspore::tensor::TensorPtr': 'mindspore::tensor::BaseTensorPtr'
1096
+ 'std::vector<mindspore::tensor::TensorPtr>': 'std::vector<mindspore::tensor::TensorPtr>',
1097
+ 'mindspore::tensor::TensorPtr': 'mindspore::tensor::TensorPtr'
815
1098
  }
816
1099
  for return_obj in op_proto.op_returns:
817
1100
  temp_return = get_return_type(return_obj.arg_dtype)
@@ -866,8 +1149,8 @@ def delete_residual_files(work_path, op_protos):
866
1149
  all_operator_name = []
867
1150
  for op_proto in op_protos:
868
1151
  all_operator_name.append(op_proto.op_name)
869
- code_generate_path_list = [f"{K.MS_OPS_KERNEL_PATH}/{device}/pyboost/auto_generate/" for device in
870
- ["ascend", "gpu", "cpu"]]
1152
+ devices = ["ascend", "gpu", "cpu"]
1153
+ code_generate_path_list = [f"{K.MS_OPS_KERNEL_PATH}/{device}/pyboost/auto_generate/" for device in devices]
871
1154
  code_generate_path_list.append(
872
1155
  f"{K.MS_COMMON_PYBOOST_KERNEL_PATH}/auto_generate/")
873
1156
  for code_generate_path in code_generate_path_list:
@@ -916,19 +1199,23 @@ class PyboostOpRegisterCppCodeGenerator:
916
1199
  None
917
1200
  """
918
1201
  all_op_names = []
1202
+ internal_op_names = []
919
1203
  all_functional_names = []
920
1204
  for op_proto in op_protos:
921
1205
  if op_proto.op_dispatch is None:
922
1206
  continue
923
- functional_name = op_proto.op_name
924
1207
  op_name_str = op_proto.op_class.name
1208
+ if getattr(op_proto.op_dispatch, 'internal_op_ascend') != 'None':
1209
+ internal_op_names.append(op_name_str)
925
1210
  all_op_names.append(op_name_str)
926
- all_functional_names.append(functional_name)
1211
+ all_functional_names.append(op_proto.op_name)
927
1212
 
928
1213
  include_str = ''
929
1214
  factory_str = ''
930
1215
  for op_name in all_op_names:
931
1216
  factory_str += "template class OpFactory<{0}>;\n".format(op_name)
1217
+ for op_name in internal_op_names:
1218
+ factory_str += "template class InternalOpFactory<{0}>;\n".format(op_name)
932
1219
  for operator_name in all_functional_names:
933
1220
  include_str += f'#include "{K.MS_PYBOOST_BASE_PATH}/auto_generate/{operator_name}.h"\n'
934
1221
  op_register_file_str = self.PYBOOST_OP_REGISTER_TEMPLATE.replace(op_includes=include_str,