mindspore 2.4.10__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 (366) 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 +98 -21
  27. mindspore/common/dtype.py +34 -34
  28. mindspore/common/dump.py +2 -1
  29. mindspore/common/file_system.py +8 -3
  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 +31 -15
  36. mindspore/common/tensor.py +713 -1337
  37. mindspore/communication/__init__.py +1 -1
  38. mindspore/communication/_comm_helper.py +5 -0
  39. mindspore/communication/comm_func.py +215 -173
  40. mindspore/communication/management.py +23 -20
  41. mindspore/context.py +285 -191
  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 +11 -11
  50. mindspore/dataset/engine/datasets_text.py +38 -1
  51. mindspore/dataset/engine/datasets_user_defined.py +100 -66
  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 +1 -0
  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 +2 -3
  82. mindspore/experimental/llm_boost/atb/llama_boost.py +6 -1
  83. mindspore/experimental/llm_boost/register.py +1 -0
  84. mindspore/experimental/optim/adadelta.py +26 -22
  85. mindspore/experimental/optim/adam.py +3 -0
  86. mindspore/experimental/optim/lr_scheduler.py +33 -24
  87. mindspore/experimental/optim/radam.py +33 -30
  88. mindspore/hal/device.py +28 -0
  89. mindspore/hal/event.py +17 -0
  90. mindspore/hal/memory.py +94 -3
  91. mindspore/hal/stream.py +91 -6
  92. mindspore/include/api/context.h +0 -1
  93. mindspore/jpeg62.dll +0 -0
  94. mindspore/log.py +12 -0
  95. mindspore/mindrecord/__init__.py +1 -1
  96. mindspore/mindrecord/config.py +17 -316
  97. mindspore/mindrecord/filereader.py +1 -9
  98. mindspore/mindrecord/filewriter.py +5 -15
  99. mindspore/mindrecord/mindpage.py +1 -9
  100. mindspore/mindspore_backend.dll +0 -0
  101. mindspore/mindspore_common.dll +0 -0
  102. mindspore/mindspore_core.dll +0 -0
  103. mindspore/mindspore_glog.dll +0 -0
  104. mindspore/mindspore_ops.dll +0 -0
  105. mindspore/mint/__init__.py +824 -218
  106. mindspore/mint/distributed/__init__.py +66 -4
  107. mindspore/mint/distributed/distributed.py +2594 -44
  108. mindspore/mint/linalg/__init__.py +6 -0
  109. mindspore/mint/nn/__init__.py +473 -14
  110. mindspore/mint/nn/functional.py +486 -11
  111. mindspore/mint/nn/layer/__init__.py +17 -4
  112. mindspore/mint/nn/layer/_functions.py +330 -0
  113. mindspore/mint/nn/layer/activation.py +169 -1
  114. mindspore/mint/nn/layer/basic.py +123 -0
  115. mindspore/mint/nn/layer/conv.py +727 -0
  116. mindspore/mint/nn/layer/normalization.py +215 -19
  117. mindspore/mint/nn/layer/padding.py +797 -0
  118. mindspore/mint/nn/layer/pooling.py +170 -0
  119. mindspore/mint/optim/__init__.py +2 -1
  120. mindspore/mint/optim/adam.py +223 -0
  121. mindspore/mint/optim/adamw.py +26 -19
  122. mindspore/mint/special/__init__.py +2 -1
  123. mindspore/multiprocessing/__init__.py +5 -0
  124. mindspore/nn/cell.py +126 -19
  125. mindspore/nn/dynamic_lr.py +2 -1
  126. mindspore/nn/layer/activation.py +6 -6
  127. mindspore/nn/layer/basic.py +35 -25
  128. mindspore/nn/layer/channel_shuffle.py +3 -3
  129. mindspore/nn/layer/embedding.py +3 -3
  130. mindspore/nn/layer/normalization.py +8 -7
  131. mindspore/nn/layer/padding.py +4 -3
  132. mindspore/nn/layer/pooling.py +47 -13
  133. mindspore/nn/layer/rnn_cells.py +1 -1
  134. mindspore/nn/layer/rnns.py +2 -1
  135. mindspore/nn/layer/timedistributed.py +5 -5
  136. mindspore/nn/layer/transformer.py +48 -26
  137. mindspore/nn/learning_rate_schedule.py +5 -3
  138. mindspore/nn/loss/loss.py +31 -36
  139. mindspore/nn/optim/ada_grad.py +1 -0
  140. mindspore/nn/optim/adadelta.py +2 -2
  141. mindspore/nn/optim/adam.py +1 -1
  142. mindspore/nn/optim/lars.py +1 -4
  143. mindspore/nn/optim/optimizer.py +1 -1
  144. mindspore/nn/optim/rprop.py +2 -2
  145. mindspore/nn/optim/thor.py +2 -1
  146. mindspore/nn/utils/init.py +13 -11
  147. mindspore/nn/wrap/cell_wrapper.py +4 -6
  148. mindspore/nn/wrap/loss_scale.py +3 -4
  149. mindspore/numpy/array_creations.py +60 -62
  150. mindspore/numpy/array_ops.py +148 -143
  151. mindspore/numpy/logic_ops.py +41 -42
  152. mindspore/numpy/math_ops.py +361 -359
  153. mindspore/numpy/utils.py +16 -16
  154. mindspore/numpy/utils_const.py +4 -4
  155. mindspore/opencv_core452.dll +0 -0
  156. mindspore/opencv_imgcodecs452.dll +0 -0
  157. mindspore/opencv_imgproc452.dll +0 -0
  158. mindspore/ops/__init__.py +2 -1
  159. mindspore/ops/_grad_experimental/grad_comm_ops.py +94 -13
  160. mindspore/ops/_grad_experimental/grad_debug_ops.py +6 -1
  161. mindspore/ops/_grad_experimental/grad_inner_ops.py +9 -0
  162. mindspore/ops/_grad_experimental/grad_math_ops.py +2 -1
  163. mindspore/ops/_op_impl/cpu/__init__.py +1 -0
  164. mindspore/ops/_op_impl/cpu/raise_op.py +28 -0
  165. mindspore/ops/_vmap/vmap_array_ops.py +20 -19
  166. mindspore/ops/_vmap/vmap_base.py +0 -2
  167. mindspore/ops/_vmap/vmap_grad_nn_ops.py +19 -13
  168. mindspore/ops/_vmap/vmap_math_ops.py +11 -9
  169. mindspore/ops/_vmap/vmap_nn_ops.py +20 -34
  170. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +149 -12
  171. mindspore/ops/auto_generate/gen_arg_handler.py +0 -61
  172. mindspore/ops/auto_generate/gen_extend_func.py +554 -60
  173. mindspore/ops/auto_generate/gen_ops_def.py +1621 -115
  174. mindspore/ops/auto_generate/gen_ops_prim.py +8024 -3409
  175. mindspore/ops/auto_generate/pyboost_inner_prim.py +183 -79
  176. mindspore/ops/composite/base.py +1 -1
  177. mindspore/ops/composite/multitype_ops/_compile_utils.py +229 -30
  178. mindspore/ops/composite/multitype_ops/pow_impl.py +0 -29
  179. mindspore/ops/function/__init__.py +12 -0
  180. mindspore/ops/function/array_func.py +561 -159
  181. mindspore/ops/function/clip_func.py +64 -0
  182. mindspore/ops/function/debug_func.py +28 -20
  183. mindspore/ops/function/image_func.py +1 -1
  184. mindspore/ops/function/linalg_func.py +5 -4
  185. mindspore/ops/function/math_func.py +1659 -290
  186. mindspore/ops/function/nn_func.py +988 -317
  187. mindspore/ops/function/parameter_func.py +3 -56
  188. mindspore/ops/function/random_func.py +243 -33
  189. mindspore/ops/function/sparse_unary_func.py +1 -1
  190. mindspore/ops/functional.py +18 -5
  191. mindspore/ops/functional_overload.py +897 -0
  192. mindspore/ops/operations/__init__.py +3 -2
  193. mindspore/ops/operations/_embedding_cache_ops.py +4 -4
  194. mindspore/ops/operations/_grad_ops.py +2 -34
  195. mindspore/ops/operations/_infer_ops.py +2 -1
  196. mindspore/ops/operations/_inner_ops.py +38 -8
  197. mindspore/ops/operations/array_ops.py +45 -303
  198. mindspore/ops/operations/comm_ops.py +19 -16
  199. mindspore/ops/operations/custom_ops.py +11 -55
  200. mindspore/ops/operations/debug_ops.py +42 -47
  201. mindspore/ops/operations/inner_ops.py +6 -4
  202. mindspore/ops/operations/linalg_ops.py +3 -2
  203. mindspore/ops/operations/manually_defined/ops_def.py +185 -104
  204. mindspore/ops/operations/math_ops.py +11 -216
  205. mindspore/ops/operations/nn_ops.py +146 -308
  206. mindspore/ops/primitive.py +23 -21
  207. mindspore/ops/tensor_method.py +1669 -0
  208. mindspore/ops_generate/aclnn_kernel_register_auto_cc_generator.py +110 -0
  209. mindspore/ops_generate/add_tensor_docs_generator.py +54 -0
  210. mindspore/ops_generate/arg_handler.py +0 -61
  211. mindspore/ops_generate/auto_grad_impl_cc_generator.py +135 -0
  212. mindspore/ops_generate/auto_grad_reg_cc_generator.py +93 -0
  213. mindspore/ops_generate/base_generator.py +11 -0
  214. mindspore/ops_generate/cpp_create_prim_instance_helper_generator.py +108 -0
  215. mindspore/ops_generate/functional_map_cpp_generator.py +491 -0
  216. mindspore/ops_generate/functional_overload_py_generator.py +110 -0
  217. mindspore/ops_generate/functions_cc_generator.py +233 -0
  218. mindspore/ops_generate/gen_aclnn_implement.py +110 -114
  219. mindspore/ops_generate/gen_constants.py +157 -3
  220. mindspore/ops_generate/gen_ops.py +245 -990
  221. mindspore/ops_generate/gen_pyboost_func.py +97 -998
  222. mindspore/ops_generate/gen_utils.py +119 -33
  223. mindspore/ops_generate/lite_ops_cpp_generator.py +155 -0
  224. mindspore/ops_generate/op_api_proto.py +206 -0
  225. mindspore/ops_generate/op_def_py_generator.py +131 -0
  226. mindspore/ops_generate/op_prim_py_generator.py +480 -0
  227. mindspore/ops_generate/op_proto.py +373 -108
  228. mindspore/ops_generate/op_template_parser.py +436 -0
  229. mindspore/ops_generate/ops_def_cc_generator.py +288 -0
  230. mindspore/ops_generate/ops_def_h_generator.py +74 -0
  231. mindspore/ops_generate/ops_name_h_generator.py +68 -0
  232. mindspore/ops_generate/ops_primitive_h_generator.py +81 -0
  233. mindspore/ops_generate/pyboost_functions_cpp_generator.py +370 -0
  234. mindspore/ops_generate/pyboost_functions_h_generator.py +68 -0
  235. mindspore/ops_generate/pyboost_functions_py_generator.py +148 -0
  236. mindspore/ops_generate/pyboost_grad_function_cpp_generator.py +154 -0
  237. mindspore/ops_generate/pyboost_inner_prim_generator.py +131 -0
  238. mindspore/ops_generate/pyboost_native_grad_functions_generator.py +268 -0
  239. mindspore/ops_generate/pyboost_op_cpp_code_generator.py +851 -0
  240. mindspore/ops_generate/pyboost_overload_functions_cpp_generator.py +344 -0
  241. mindspore/ops_generate/pyboost_utils.py +92 -33
  242. mindspore/ops_generate/template.py +294 -44
  243. mindspore/ops_generate/tensor_func_reg_cpp_generator.py +422 -0
  244. mindspore/parallel/__init__.py +3 -3
  245. mindspore/parallel/_auto_parallel_context.py +24 -33
  246. mindspore/parallel/_parallel_serialization.py +13 -2
  247. mindspore/parallel/_utils.py +4 -1
  248. mindspore/parallel/algo_parameter_config.py +1 -1
  249. mindspore/parallel/checkpoint_transform.py +44 -0
  250. mindspore/parallel/cluster/process_entity/_api.py +131 -37
  251. mindspore/parallel/cluster/process_entity/_utils.py +41 -6
  252. mindspore/parallel/cluster/run.py +20 -3
  253. mindspore/parallel/parameter_broadcast.py +1 -1
  254. mindspore/parallel/shard.py +3 -0
  255. mindspore/parallel/transform_safetensors.py +119 -253
  256. mindspore/profiler/__init__.py +17 -4
  257. mindspore/profiler/analysis/__init__.py +0 -0
  258. mindspore/profiler/analysis/parser/__init__.py +0 -0
  259. mindspore/profiler/analysis/parser/ascend_cann_parser.py +166 -0
  260. mindspore/profiler/analysis/parser/base_parser.py +158 -0
  261. mindspore/profiler/analysis/parser/framework_cann_relation_parser.py +45 -0
  262. mindspore/profiler/analysis/parser/ms_framework_parser.py +142 -0
  263. mindspore/profiler/analysis/parser/ms_minddata_parser.py +145 -0
  264. mindspore/profiler/analysis/parser/timeline_assembly_factory/__init__.py +0 -0
  265. mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +261 -0
  266. mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +40 -0
  267. mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +84 -0
  268. mindspore/profiler/analysis/parser/timeline_creator/__init__.py +0 -0
  269. mindspore/profiler/analysis/parser/timeline_creator/base_timeline_creator.py +44 -0
  270. mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +90 -0
  271. mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +76 -0
  272. mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +103 -0
  273. mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +134 -0
  274. mindspore/profiler/analysis/parser/timeline_event/__init__.py +0 -0
  275. mindspore/profiler/analysis/parser/timeline_event/base_event.py +233 -0
  276. mindspore/profiler/analysis/parser/timeline_event/cpu_op_event.py +47 -0
  277. mindspore/profiler/analysis/parser/timeline_event/flow_event.py +36 -0
  278. mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +260 -0
  279. mindspore/profiler/analysis/parser/timeline_event/msprof_event.py +73 -0
  280. mindspore/profiler/analysis/parser/timeline_event/scope_layer_event.py +53 -0
  281. mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +146 -0
  282. mindspore/profiler/analysis/task_manager.py +131 -0
  283. mindspore/profiler/analysis/time_converter.py +84 -0
  284. mindspore/profiler/analysis/viewer/__init__.py +0 -0
  285. mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +333 -0
  286. mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +87 -0
  287. mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +252 -0
  288. mindspore/profiler/analysis/viewer/ascend_memory_viewer.py +313 -0
  289. mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +322 -0
  290. mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +265 -0
  291. mindspore/profiler/analysis/viewer/ascend_timeline_viewer.py +58 -0
  292. mindspore/profiler/analysis/viewer/base_viewer.py +26 -0
  293. mindspore/profiler/analysis/viewer/ms_dataset_viewer.py +97 -0
  294. mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +581 -0
  295. mindspore/profiler/analysis/work_flow.py +73 -0
  296. mindspore/profiler/common/ascend_msprof_exporter.py +138 -0
  297. mindspore/profiler/common/command_executor.py +90 -0
  298. mindspore/profiler/common/constant.py +174 -3
  299. mindspore/profiler/common/file_manager.py +208 -0
  300. mindspore/profiler/common/log.py +130 -0
  301. mindspore/profiler/common/msprof_cmd_tool.py +202 -0
  302. mindspore/profiler/common/path_manager.py +371 -0
  303. mindspore/profiler/common/process_bar.py +168 -0
  304. mindspore/profiler/common/process_pool.py +9 -3
  305. mindspore/profiler/common/profiler_context.py +476 -0
  306. mindspore/profiler/common/profiler_info.py +304 -0
  307. mindspore/profiler/common/profiler_output_path.py +284 -0
  308. mindspore/profiler/common/profiler_parameters.py +210 -0
  309. mindspore/profiler/common/profiler_path_manager.py +120 -0
  310. mindspore/profiler/common/record_function.py +76 -0
  311. mindspore/profiler/common/tlv_decoder.py +76 -0
  312. mindspore/profiler/common/util.py +75 -2
  313. mindspore/profiler/dynamic_profiler.py +270 -37
  314. mindspore/profiler/envprofiler.py +138 -0
  315. mindspore/profiler/mstx.py +199 -0
  316. mindspore/profiler/platform/__init__.py +21 -0
  317. mindspore/profiler/platform/base_profiler.py +40 -0
  318. mindspore/profiler/platform/cpu_profiler.py +124 -0
  319. mindspore/profiler/platform/gpu_profiler.py +74 -0
  320. mindspore/profiler/platform/npu_profiler.py +309 -0
  321. mindspore/profiler/profiler.py +580 -93
  322. mindspore/profiler/profiler_action_controller.py +187 -0
  323. mindspore/profiler/profiler_interface.py +114 -0
  324. mindspore/profiler/schedule.py +208 -0
  325. mindspore/rewrite/api/symbol_tree.py +1 -2
  326. mindspore/run_check/_check_version.py +2 -6
  327. mindspore/runtime/__init__.py +37 -0
  328. mindspore/runtime/device.py +27 -0
  329. mindspore/runtime/event.py +209 -0
  330. mindspore/runtime/executor.py +148 -0
  331. mindspore/runtime/memory.py +392 -0
  332. mindspore/runtime/stream.py +460 -0
  333. mindspore/runtime/thread_bind_core.py +401 -0
  334. mindspore/swresample-4.dll +0 -0
  335. mindspore/swscale-6.dll +0 -0
  336. mindspore/tinyxml2.dll +0 -0
  337. mindspore/train/__init__.py +2 -2
  338. mindspore/train/_utils.py +53 -18
  339. mindspore/train/amp.py +8 -4
  340. mindspore/train/callback/_checkpoint.py +32 -18
  341. mindspore/train/callback/_early_stop.py +1 -1
  342. mindspore/train/callback/_flops_collector.py +105 -69
  343. mindspore/train/callback/_history.py +1 -1
  344. mindspore/train/callback/_summary_collector.py +44 -6
  345. mindspore/train/callback/_tft_register.py +31 -10
  346. mindspore/train/dataset_helper.py +11 -11
  347. mindspore/train/metrics/precision.py +4 -5
  348. mindspore/train/mind_ir_pb2.py +167 -46
  349. mindspore/train/model.py +13 -15
  350. mindspore/train/serialization.py +462 -76
  351. mindspore/train/summary/summary_record.py +1 -2
  352. mindspore/train/train_thor/model_thor.py +1 -1
  353. mindspore/turbojpeg.dll +0 -0
  354. mindspore/utils/__init__.py +4 -2
  355. mindspore/utils/dryrun.py +138 -0
  356. mindspore/utils/runtime_execution_order_check.py +550 -0
  357. mindspore/version.py +1 -1
  358. {mindspore-2.4.10.dist-info → mindspore-2.5.0.dist-info}/METADATA +2 -3
  359. {mindspore-2.4.10.dist-info → mindspore-2.5.0.dist-info}/RECORD +362 -238
  360. {mindspore-2.4.10.dist-info → mindspore-2.5.0.dist-info}/entry_points.txt +1 -1
  361. mindspore/common/_tensor_overload.py +0 -139
  362. mindspore/mindspore_np_dtype.dll +0 -0
  363. mindspore/profiler/envprofiling.py +0 -254
  364. mindspore/profiler/profiling.py +0 -1926
  365. {mindspore-2.4.10.dist-info → mindspore-2.5.0.dist-info}/WHEEL +0 -0
  366. {mindspore-2.4.10.dist-info → mindspore-2.5.0.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,4 @@
1
- # Copyright 2023 Huawei Technologies Co., Ltd
1
+ # Copyright 2024 Huawei Technologies Co., Ltd
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -12,15 +12,15 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  # ============================================================================
15
- """Template."""
15
+ """Templates for code auto generation."""
16
16
  import re
17
17
  import os
18
18
  import gen_constants as K
19
19
 
20
20
 
21
- class CppTemplate:
21
+ class Template:
22
22
  """
23
- template for generate c++ code
23
+ template for generate c++/python code
24
24
  """
25
25
  regular_str = r"(^[^\n\S]*)?\$([^\d\W]\w*|\{,?[^\d\W]\w*\,?})"
26
26
  regular_match = re.compile(regular_str, re.MULTILINE)
@@ -31,7 +31,7 @@ class CppTemplate:
31
31
  @staticmethod
32
32
  def load_from_file(file_path):
33
33
  with open(file_path, "r") as f:
34
- return CppTemplate(f.read())
34
+ return Template(f.read())
35
35
 
36
36
  def replace(self, **kwargs):
37
37
  """
@@ -82,12 +82,12 @@ class CppTemplate:
82
82
  NEW_LINE = "\n"
83
83
  WORK_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../../../")
84
84
 
85
- PYTHON_PRIM_TEMPLATE = CppTemplate("""
85
+ PYTHON_PRIM_TEMPLATE = Template("""
86
86
 
87
87
  class _Pyboost${class_name}Prim(${class_name}Prim_):
88
88
  def __call__(self, ${input_args}):
89
89
  ${process_func}
90
- return _convert_stub(super().__call__(${processed_args}))
90
+ return _convert_stub(super().__call__([${processed_args}]))
91
91
 
92
92
 
93
93
  ${func_impl_name}_impl = _Pyboost${class_name}Prim()
@@ -104,134 +104,214 @@ from mindspore.ops.auto_generate.pyboost_inner_prim import *
104
104
 
105
105
  """
106
106
 
107
- REGISTER_DEFINE_TEMPLATE = CppTemplate(
107
+ REGISTER_DEFINE_TEMPLATE = Template(
108
108
  """
109
109
  (void)py::class_<${class_name}PrimAdapter, PrimitiveFunctionAdapter, std::shared_ptr<${class_name}PrimAdapter>>(
110
110
  *m, "${class_name}Prim_")
111
111
  .def(py::init<>())
112
112
  .def("__call__", &${class_name}PrimAdapter::Call, "Call ${class_name} op.");
113
113
  m->def(\"${pyboost_op_name}\", &mindspore::pynative::${pyboost_cfunc_name}, \"Encrypt the data.\");""")
114
- REGISTER_TEMPLATE = CppTemplate("void RegisterPyBoostFunction(py::module *m) {${register_func}\n}")
114
+ REGISTER_TEMPLATE = Template("void RegisterPyBoostFunction(py::module *m) {${register_func}\n}")
115
115
 
116
- REGISTER_PYBOOST_GRAD_DEFINE_TEMPLATE = CppTemplate(
116
+ REGISTER_PYBOOST_GRAD_DEFINE_TEMPLATE = Template(
117
117
  "MS_REG_PYBOOST_GRAD_OP(${pyboost_op_name}, mindspore::runtime::${pyboost_cfunc_name});\n")
118
- REGISTER_PYBOOST_GRAD_TEMPLATE = CppTemplate("${register_func}")
118
+ REGISTER_PYBOOST_GRAD_TEMPLATE = Template("${register_func}")
119
119
 
120
- PYBOOST_FUNCTION_TEMPLATE = CppTemplate.load_from_file(
120
+ PYBOOST_FUNCTION_HEADER_TEMPLATE = Template.load_from_file(
121
+ os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/pyboost_functions_h.tpl'))
122
+
123
+ PYBOOST_FUNCTION_TEMPLATE = Template.load_from_file(
121
124
  os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/pyboost_function.tpl'))
122
125
 
123
- PYBOOS_COMM_FUNCTION_TEMPLATE = CppTemplate.load_from_file(
126
+ PYBOOST_COMM_FUNCTION_TEMPLATE = Template.load_from_file(
124
127
  os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/pyboost_comm_function.tpl'))
125
128
 
126
- PYBOOST_HEADER_TEMPLATE = CppTemplate.load_from_file(
127
- os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/pyboost_function_header.tpl'))
129
+ PYBOOST_FUNCTIONS_CC_TEMPLATE = Template.load_from_file(
130
+ os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/pyboost_functions_cc.tpl'))
131
+
132
+ PYBOOST_OVERLOAD_FUNCTIONS_CC_TEMPLATE = Template.load_from_file(
133
+ os.path.join(
134
+ WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/pyboost_overload_functions_cc.tpl'))
135
+
136
+ PYBOOST_MINT_CLASS_DEF = Template.load_from_file(
137
+ os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/pyboost_mint_class_def.tpl'))
138
+
139
+ PYBOOST_OVERLOAD_MINT_CLASS_DEF = Template.load_from_file(
140
+ os.path.join(
141
+ WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/pyboost_overload_mint_class_def.tpl'))
142
+
143
+ # template path need to be moved
144
+ FUNCTIONAL_OVERLOAD_PY_TEMPLATE = Template.load_from_file(
145
+ os.path.join(
146
+ WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/functional_overload_py.tpl')
147
+ )
148
+
149
+ TENSOR_FUNC_CC_REG = Template.load_from_file(
150
+ os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/tensor_func_cc_reg.tpl'))
151
+
152
+ TENSOR_API_HEADER = Template.load_from_file(
153
+ os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/tensor_api_header.tpl'))
154
+
155
+ TENSOR_API_SOURCE = Template.load_from_file(
156
+ os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/tensor_api_source.tpl'))
157
+
158
+ TENSOR_FUNC_UTILS = Template.load_from_file(
159
+ os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/tensor_func_utils_header.tpl'))
160
+
161
+
162
+ TENSOR_FUNC_CALL_BODY = Template.load_from_file(
163
+ os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/tensor_func_call_body.tpl'))
164
+
165
+ TENSOR_FUNC_OVERLOAD_CALL_BODY = Template.load_from_file(
166
+ os.path.join(WORK_PATH,
167
+ './mindspore/ccsrc/pipeline/pynative/op_function/template/tensor_func_overload_call_body.tpl'))
128
168
 
129
- PYBOOST_GRAD_FUNCTION_TEMPLATE = CppTemplate.load_from_file(
169
+ TENSOR_FUNC_UT_BODY = Template.load_from_file(
170
+ os.path.join(WORK_PATH,
171
+ './mindspore/ccsrc/pipeline/pynative/op_function/template/tensor_func_ut_body.tpl'))
172
+
173
+ TENSOR_FUNC_UT_OVERLOAD_BODY = Template.load_from_file(
174
+ os.path.join(WORK_PATH,
175
+ './mindspore/ccsrc/pipeline/pynative/op_function/template/tensor_func_ut_overload_body.tpl'))
176
+
177
+ TENSOR_CPP_METHOD = Template.load_from_file(
178
+ os.path.join(WORK_PATH,
179
+ './mindspore/ccsrc/pipeline/pynative/op_function/template/tensor_cpp_method.tpl'))
180
+
181
+ TENSOR_FUNC_CLASS_REG = Template.load_from_file(
182
+ os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/tensor_func_class_reg.tpl'))
183
+
184
+
185
+ PYBOOST_GRAD_FUNCTION_TEMPLATE = Template.load_from_file(
130
186
  os.path.join(WORK_PATH, './mindspore/ccsrc/runtime/pynative/op_function/template/pyboost_grad_function.tpl'))
131
187
 
132
- PYBOOST_GRAD_HEADER_TEMPLATE = CppTemplate.load_from_file(
188
+ PYBOOST_GRAD_HEADER_TEMPLATE = Template.load_from_file(
133
189
  os.path.join(WORK_PATH, './mindspore/ccsrc/runtime/pynative/op_function/template/pyboost_grad_function_header.tpl'))
134
190
 
135
- PYBOOST_NATIVE_GRAD_FUNCTION_TEMPLATE = CppTemplate.load_from_file(
191
+ PYBOOST_NATIVE_GRAD_FUNCTION_TEMPLATE = Template.load_from_file(
136
192
  os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/grad/function/template/native_grad_function.tpl'))
137
193
 
138
- PYBOOST_NATIVE_GRAD_FUNCTIONS_TEMPLATE = CppTemplate.load_from_file(
194
+ PYBOOST_NATIVE_GRAD_FUNCTIONS_TEMPLATE = Template.load_from_file(
139
195
  os.path.join(WORK_PATH,
140
196
  './mindspore/ccsrc/pipeline/pynative/grad/function/template/pyboost_native_grad_functions.tpl'))
141
197
 
142
- PYBOOST_NATIVE_GRAD_FUNCTIONS_HEADER_TEMPLATE = CppTemplate.load_from_file(
198
+ PYBOOST_NATIVE_GRAD_FUNCTIONS_HEADER_TEMPLATE = Template.load_from_file(
143
199
  os.path.join(WORK_PATH,
144
200
  './mindspore/ccsrc/pipeline/pynative/grad/function/template/pyboost_native_grad_functions_header.tpl'))
145
201
 
146
- GEN_OPS_DEF_HEADER_TEMPLATE = CppTemplate.load_from_file(
202
+ GEN_OPS_DEF_HEADER_TEMPLATE = Template.load_from_file(
147
203
  os.path.join(WORK_PATH, './mindspore/python/mindspore/ops_generate/gen_ops_def_header.tpl'))
148
204
 
149
- PYBOOST_BASE_OP_DEFINE_TEMPLATE = CppTemplate.load_from_file(
205
+ PYBOOST_BASE_OP_DEFINE_TEMPLATE = Template.load_from_file(
150
206
  os.path.join(WORK_PATH, f'./{K.MS_COMMON_PYBOOST_KERNEL_PATH}/template/pyboost_op_header.tpl'))
151
207
 
152
- PYBOOST_OP_REGISTER_TEMPLATE = CppTemplate.load_from_file(
208
+ PYBOOST_OP_REGISTER_TEMPLATE = Template.load_from_file(
153
209
  os.path.join(WORK_PATH, f'./{K.MS_COMMON_PYBOOST_KERNEL_PATH}/template/pyboost_op_register.tpl'))
154
210
 
155
211
  # Ascend op generate
156
- PYBOOST_ASCEND_OP_HEADER_TEMPLATE = CppTemplate.load_from_file(
212
+ PYBOOST_ASCEND_OP_HEADER_TEMPLATE = Template.load_from_file(
157
213
  os.path.join(WORK_PATH,
158
214
  f'./{K.MS_OPS_KERNEL_PATH}/ascend/pyboost/template/pyboost_aclnn_header_template.tpl'))
159
215
 
160
- PYBOOST_ASCEND_OP_SOURCE_TEMPLATE = CppTemplate.load_from_file(
216
+ PYBOOST_ASCEND_OP_SOURCE_TEMPLATE = Template.load_from_file(
161
217
  os.path.join(WORK_PATH,
162
218
  f'./{K.MS_OPS_KERNEL_PATH}/ascend/pyboost/template/pyboost_aclnn_source_template.tpl'))
163
219
 
164
- PYBOOST_ASCEND_CALL_TEMPLATE = CppTemplate.load_from_file(
220
+ PYBOOST_ASCEND_SINGLE_OP_HEADER_TEMPLATE = Template.load_from_file(
221
+ os.path.join(WORK_PATH,
222
+ f'./{K.MS_OPS_KERNEL_PATH}/ascend/pyboost/template/pyboost_aclnn_single_op_header_template.tpl'))
223
+
224
+ PYBOOST_ASCEND_SINGLE_OP_SOURCE_TEMPLATE = Template.load_from_file(
225
+ os.path.join(WORK_PATH,
226
+ f'./{K.MS_OPS_KERNEL_PATH}/ascend/pyboost/template/pyboost_aclnn_single_op_source_template.tpl'))
227
+
228
+ PYBOOST_ASCEND_CALL_TEMPLATE = Template.load_from_file(
165
229
  os.path.join(WORK_PATH,
166
230
  f'./{K.MS_OPS_KERNEL_PATH}/ascend/pyboost/template/pyboost_ascend_call_template.tpl'))
167
231
 
168
- PYBOOST_ASCEND_VIEW_CALL_TEMPLATE = CppTemplate.load_from_file(
232
+ PYBOOST_ASCEND_VIEW_CALL_TEMPLATE = Template.load_from_file(
169
233
  os.path.join(WORK_PATH,
170
234
  f'./{K.MS_COMMON_PYBOOST_KERNEL_PATH}/template/'
171
235
  'pyboost_view_template.tpl'))
172
236
 
173
- PYBOOST_ASCEND_CUSTOMIZE_CALL_TEMPLATE = CppTemplate.load_from_file(
237
+ PYBOOST_ASCEND_CUSTOMIZE_CALL_TEMPLATE = Template.load_from_file(
174
238
  os.path.join(WORK_PATH,
175
239
  f'./{K.MS_OPS_KERNEL_PATH}/ascend/pyboost/template'
176
240
  '/pyboost_ascend_customize_call_template.tpl'))
177
241
 
178
242
  # GPU op generate
179
- PYBOOST_GPU_OP_HEADER_TEMPLATE = CppTemplate.load_from_file(
243
+ PYBOOST_GPU_OP_HEADER_TEMPLATE = Template.load_from_file(
180
244
  os.path.join(WORK_PATH,
181
245
  './mindspore/ops/kernel/gpu/pyboost/template/pyboost_gpu_header_template.tpl'))
182
246
 
183
- PYBOOST_GPU_OP_SOURCE_TEMPLATE = CppTemplate.load_from_file(
247
+ PYBOOST_GPU_OP_SOURCE_TEMPLATE = Template.load_from_file(
184
248
  os.path.join(WORK_PATH,
185
249
  './mindspore/ops/kernel/gpu/pyboost/template/pyboost_gpu_source_template.tpl'))
186
250
 
187
- PYBOOST_GPU_CALL_TEMPLATE = CppTemplate.load_from_file(
251
+ PYBOOST_GPU_SINGLE_OP_HEADER_TEMPLATE = Template.load_from_file(
252
+ os.path.join(WORK_PATH,
253
+ './mindspore/ops/kernel/gpu/pyboost/template/pyboost_gpu_single_op_header_template.tpl'))
254
+
255
+ PYBOOST_GPU_SINGLE_OP_SOURCE_TEMPLATE = Template.load_from_file(
256
+ os.path.join(WORK_PATH,
257
+ './mindspore/ops/kernel/gpu/pyboost/template/pyboost_gpu_single_op_source_template.tpl'))
258
+
259
+ PYBOOST_GPU_CALL_TEMPLATE = Template.load_from_file(
188
260
  os.path.join(WORK_PATH,
189
261
  './mindspore/ops/kernel/gpu/pyboost/template/pyboost_gpu_call_template.tpl'))
190
262
 
191
- PYBOOST_GPU_VIEW_CALL_TEMPLATE = CppTemplate.load_from_file(
263
+ PYBOOST_GPU_VIEW_CALL_TEMPLATE = Template.load_from_file(
192
264
  os.path.join(WORK_PATH,
193
265
  f'./{K.MS_COMMON_PYBOOST_KERNEL_PATH}/template/pyboost_view_template.tpl'))
194
266
 
195
- PYBOOST_GPU_CUSTOMIZE_CALL_TEMPLATE = CppTemplate.load_from_file(
267
+ PYBOOST_GPU_CUSTOMIZE_CALL_TEMPLATE = Template.load_from_file(
196
268
  os.path.join(WORK_PATH,
197
269
  './mindspore/ops/kernel/gpu/pyboost/template'
198
270
  '/pyboost_gpu_customize_call_template.tpl'))
199
271
 
200
272
  # CPU op generate
201
- PYBOOST_CPU_OP_HEADER_TEMPLATE = CppTemplate.load_from_file(
273
+ PYBOOST_CPU_OP_HEADER_TEMPLATE = Template.load_from_file(
202
274
  os.path.join(WORK_PATH,
203
275
  f'./{K.MS_OPS_KERNEL_PATH}/cpu/pyboost/template/pyboost_cpu_header_template.tpl'))
204
276
 
205
- PYBOOST_CPU_OP_SOURCE_TEMPLATE = CppTemplate.load_from_file(
277
+ PYBOOST_CPU_OP_SOURCE_TEMPLATE = Template.load_from_file(
206
278
  os.path.join(WORK_PATH,
207
279
  f'./{K.MS_OPS_KERNEL_PATH}/cpu/pyboost/template/pyboost_cpu_source_template.tpl'))
208
280
 
209
- PYBOOST_CPU_CALL_TEMPLATE = CppTemplate.load_from_file(
281
+ PYBOOST_CPU_SINGLE_OP_HEADER_TEMPLATE = Template.load_from_file(
282
+ os.path.join(WORK_PATH,
283
+ f'./{K.MS_OPS_KERNEL_PATH}/cpu/pyboost/template/pyboost_cpu_single_op_header_template.tpl'))
284
+
285
+ PYBOOST_CPU_SINGLE_OP_SOURCE_TEMPLATE = Template.load_from_file(
286
+ os.path.join(WORK_PATH,
287
+ f'./{K.MS_OPS_KERNEL_PATH}/cpu/pyboost/template/pyboost_cpu_single_op_source_template.tpl'))
288
+
289
+ PYBOOST_CPU_CALL_TEMPLATE = Template.load_from_file(
210
290
  os.path.join(WORK_PATH,
211
291
  f'./{K.MS_OPS_KERNEL_PATH}/cpu/pyboost/template/pyboost_cpu_call_template.tpl'))
212
292
 
213
- PYBOOST_CPU_VIEW_CALL_TEMPLATE = CppTemplate.load_from_file(
293
+ PYBOOST_CPU_VIEW_CALL_TEMPLATE = Template.load_from_file(
214
294
  os.path.join(WORK_PATH,
215
295
  f'./{K.MS_COMMON_PYBOOST_KERNEL_PATH}/template/pyboost_view_template.tpl'))
216
296
 
217
- PYBOOST_CPU_CUSTOMIZE_CALL_TEMPLATE = CppTemplate.load_from_file(
297
+ PYBOOST_CPU_CUSTOMIZE_CALL_TEMPLATE = Template.load_from_file(
218
298
  os.path.join(WORK_PATH,
219
299
  f'./{K.MS_OPS_KERNEL_PATH}/cpu/pyboost/template'
220
300
  '/pyboost_cpu_customize_call_template.tpl'))
221
301
 
222
- PYBOOST_PY_FUNC_IMPORT_HEADEAR = CppTemplate(
302
+ PYBOOST_PY_FUNC_IMPORT_HEADEAR = Template(
223
303
  """from mindspore._c_expression import ${class_name}Prim_\n"""
224
304
  )
225
305
 
226
- PYBOOST_PY_FUNC_TEMPLATE = CppTemplate("""
306
+ PYBOOST_PY_FUNC_TEMPLATE = Template("""
227
307
  def ${func_name}(${func_args}):
228
308
  r\"\"\"
229
309
  ${description}
230
310
  \"\"\"
231
311
  return ${func_impl_name}_impl(${input_args})\n\n""")
232
312
 
233
- OP_PROTO_TEMPLATE = CppTemplate("""
234
- ${class_name}FuncImpl g${class_name}FuncImpl;
313
+ OP_PROTO_TEMPLATE = Template("""
314
+ ${func_impl_declaration}
235
315
  OpDef g${class_name} = {
236
316
  /*.name_=*/"${class_name}",
237
317
  /*.args_=*/ {
@@ -246,9 +326,10 @@ OpDef g${class_name} = {
246
326
  /*.indexes_ =*/ {
247
327
  ${indexes}
248
328
  },
249
- /*.func_impl_=*/g${class_name}FuncImpl,
329
+ /*.func_impl_=*/${func_impl_define},
250
330
  /*.enable_dispatch_ =*/${enable_dispatch},
251
331
  /*.is_view_ =*/${is_view},
332
+ /*.is_graph_view_ =*/${is_graph_view},
252
333
  };
253
334
  REGISTER_PRIMITIVE_OP_DEF(${class_name}, &g${class_name});
254
335
  """)
@@ -258,4 +339,173 @@ ValuePtrList values;
258
339
  (void)std::transform(op->outputs().begin(), op->outputs().end(), std::back_inserter(values),
259
340
  [](const auto &value){ return value;});
260
341
  auto output_value = std::make_shared<ValueTuple>(values);
261
- """
342
+ """
343
+
344
+ PY_LICENCE_STR = f"""# Copyright 2023 Huawei Technologies Co., Ltd
345
+ #
346
+ # Licensed under the Apache License, Version 2.0 (the "License");
347
+ # you may not use this file except in compliance with the License.
348
+ # You may obtain a copy of the License at
349
+ #
350
+ # http://www.apache.org/licenses/LICENSE-2.0
351
+ #
352
+ # Unless required by applicable law or agreed to in writing, software
353
+ # distributed under the License is distributed on an "AS IS" BASIS,
354
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
355
+ # See the License for the specific language governing permissions and
356
+ # limitations under the License.
357
+ # ============================================================================
358
+ """
359
+
360
+ OPS_PY_PRIM_HEADER = f"""
361
+ \"\"\"Operators definition generated by gen_ops.py, includes primitive classes.\"\"\"
362
+
363
+ from mindspore.ops.primitive import Primitive, prim_arg_register
364
+ from mindspore.ops import signature as sig
365
+ from mindspore.common import dtype as mstype
366
+ from mindspore.common._decorator import deprecated
367
+ from mindspore.ops._primitive_cache import _get_cache_prim
368
+ from mindspore.ops.auto_generate.gen_arg_dtype_cast import type_it
369
+ from mindspore.ops.auto_generate.gen_arg_handler import *
370
+ from mindspore._c_expression import OpDtype
371
+ from mindspore.common._stub_tensor import _convert_stub
372
+ """
373
+
374
+ OP_PRIM_CLASS_DEFINE_TEMPLATE = Template("""
375
+
376
+ class ${class_name}(Primitive):
377
+ ${class_desc}${signature_code}${deprecated_code}
378
+ ${init_method}
379
+
380
+ ${call_method}""")
381
+
382
+ OPS_PY_DEF_HEADER = f"""
383
+ \"\"\"Operators definition generated by gen_ops.py, includes functions.\"\"\"
384
+
385
+ from .gen_ops_prim import *
386
+ from .pyboost_inner_prim import *
387
+ from mindspore.ops.operations.manually_defined.ops_def import *
388
+ from mindspore.ops._primitive_cache import _get_cache_prim
389
+ """
390
+
391
+ PRIMITIVE_CLASS_DESC = """ r\"\"\"
392
+ .. code-block::
393
+
394
+ prim = ops.$class_name($init_args_str)
395
+ out = prim($input_args_str)
396
+
397
+ is equivalent to
398
+
399
+ .. code-block::
400
+
401
+ ops.$func_name($args_str)
402
+
403
+ Refer to :func:`mindspore.ops.$func_name` for more details.
404
+ \"\"\"
405
+ """
406
+
407
+ CC_LICENSE_STR = f"""/**
408
+ * Copyright 2023 Huawei Technologies Co., Ltd
409
+ *
410
+ * Licensed under the Apache License, Version 2.0 (the "License");
411
+ * you may not use this file except in compliance with the License.
412
+ * You may obtain a copy of the License at
413
+ *
414
+ * http://www.apache.org/licenses/LICENSE-2.0
415
+ *
416
+ * Unless required by applicable law or agreed to in writing, software
417
+ * distributed under the License is distributed on an "AS IS" BASIS,
418
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
419
+ * See the License for the specific language governing permissions and
420
+ * limitations under the License.
421
+ */"""
422
+
423
+ arg_default_value = Template("""
424
+ \"\"\"Operator labels and args default value.\"\"\"
425
+ from mindspore.common import dtype as mstype
426
+
427
+ op_args_default_value = {
428
+ $gen_default_py
429
+ }
430
+ """)
431
+
432
+
433
+ op_labels_template = Template("""
434
+ op_labels = {
435
+ $gen_label_py
436
+ }
437
+ """)
438
+
439
+
440
+ lite_ops_h_class_template = Template("""class OPS_API ${op_name} : public BaseOperator {
441
+ public:
442
+ MIND_API_BASE_MEMBER(${op_name});
443
+ ${op_name}() : BaseOperator(kName${op_name}) {}${lite_ops_h_code}
444
+ };
445
+
446
+ """)
447
+
448
+ op_cc_template = Template("""class OPS_API ${op_name} : public BaseOperator {
449
+ public:
450
+ MIND_API_BASE_MEMBER(${op_name});
451
+ ${op_name}() : BaseOperator(kName${op_name}) {}${arg_prim_init_list}
452
+ };
453
+
454
+ """)
455
+
456
+ op_template = Template("""void ${op_name}::set_${arg_name}(const ${dtype} &${arg_name})"""
457
+ """ { (void)this->AddAttr("${arg_name}", api::MakeValue(${arg_name})); }\n\n"""
458
+ """${dtype} ${op_name}::get_${arg_name}() const"""
459
+ """ { return GetValue<${dtype}>(GetAttr("${arg_name}")); }\n\n""")
460
+
461
+ ACLNN_KERNEL_CC_TEMPLATE = Template.load_from_file(
462
+ os.path.join(WORK_PATH, f'./{K.MS_OPS_KERNEL_PATH}/ascend/opapi/template/aclnn_kernel_cc.tpl'))
463
+
464
+ ACLNN_KERNEL_H_TEMPLATE = Template.load_from_file(
465
+ os.path.join(WORK_PATH, f'./{K.MS_OPS_KERNEL_PATH}/ascend/opapi/template/aclnn_kernel_h.tpl'))
466
+
467
+ update_output_shape_and_size_template = Template("""
468
+ void ${kernelmod_name}::UpdateOutputShapeAndSize(const std::vector<KernelTensor *> &,
469
+ const std::vector<KernelTensor *> &outputs) {
470
+ // Delete these comment and complete the function:
471
+ // Using outputs[index_x]->SetShapeVector(update_shape) and outputs[index_x]->set_size(update_size)
472
+ }
473
+ """)
474
+
475
+
476
+ UPDATE_OUTPUT_SHAPE_AND_SIZE = """
477
+ bool IsNeedUpdateOutputShapeAndSize() override { return true; }
478
+ void UpdateOutputShapeAndSize(const std::vector<KernelTensor *> &inputs, const std::vector<KernelTensor *> &outputs);
479
+ """
480
+ TUPLE_TENSOR_NOT_SUPPORTED = Template("""
481
+ It is not supported for ${op_name} with tuple[tensor] inputs when using auto generate.
482
+ Please provide a KernelMod name in yaml and using python gen_aclnn_implement.py -n xx manually.""")
483
+
484
+ FUNCTIONAL_MAP_CC_TEMPLATE = Template.load_from_file(
485
+ os.path.join(WORK_PATH,
486
+ f'./mindspore/ccsrc/pipeline/pynative/op_function/template/functional_map_cc.tpl'))
487
+
488
+ FUNCTIONAL_MAP_H_TEMPLATE = Template.load_from_file(
489
+ os.path.join(WORK_PATH,
490
+ f'./mindspore/ccsrc/pipeline/pynative/op_function/template/functional_map_h.tpl'))
491
+
492
+ ADD_TENSOR_DOCS_TEMPLATE = Template.load_from_file(
493
+ os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/tensor_docs_py.tpl'))
494
+
495
+ AUTO_GRAD_IMPL_CC_TEMPLATE = Template.load_from_file(
496
+ os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/auto_grad_impl_cc.tpl'))
497
+
498
+ AUTO_GRAD_REG_H_TEMPLATE = Template.load_from_file(
499
+ os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/auto_grad_reg_h.tpl'))
500
+
501
+ FUNCTIONS_CC_TEMPLATE = Template.load_from_file(
502
+ os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/functions_cc.tpl'))
503
+
504
+ FUNCTION_BODY_TEMPLATE = Template.load_from_file(
505
+ os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/function_body.tpl'))
506
+
507
+ FUNCTIONS_H_TEMPLATE = Template.load_from_file(
508
+ os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/functions_h.tpl'))
509
+
510
+ DO_GRAD_FUNCTION_BODY_TEMPLATE = Template.load_from_file(
511
+ os.path.join(WORK_PATH, './mindspore/ccsrc/pipeline/pynative/op_function/template/do_grad_function.tpl'))