mindspore 2.6.0__cp311-cp311-win_amd64.whl → 2.7.0rc1__cp311-cp311-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mindspore might be problematic. Click here for more details.

Files changed (403) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
  3. mindspore/Newtonsoft.Json.dll +0 -0
  4. mindspore/__init__.py +1 -1
  5. mindspore/_c_dataengine.cp311-win_amd64.pyd +0 -0
  6. mindspore/_c_expression.cp311-win_amd64.pyd +0 -0
  7. mindspore/_c_mindrecord.cp311-win_amd64.pyd +0 -0
  8. mindspore/_checkparam.py +40 -9
  9. mindspore/{_deprecated → _extends/optimize}/__init__.py +9 -3
  10. mindspore/_extends/optimize/cell_utils.py +96 -0
  11. mindspore/_extends/parse/__init__.py +2 -2
  12. mindspore/_extends/parse/compile_config.py +44 -22
  13. mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +1 -1
  14. mindspore/_extends/parse/parser.py +36 -61
  15. mindspore/_extends/parse/resources.py +39 -0
  16. mindspore/_extends/parse/standard_method.py +32 -13
  17. mindspore/_extends/parse/trope.py +8 -1
  18. mindspore/_extends/pijit/__init__.py +1 -2
  19. mindspore/amp.py +4 -4
  20. mindspore/atlprov.dll +0 -0
  21. mindspore/avcodec-59.dll +0 -0
  22. mindspore/avdevice-59.dll +0 -0
  23. mindspore/avfilter-8.dll +0 -0
  24. mindspore/avformat-59.dll +0 -0
  25. mindspore/avutil-57.dll +0 -0
  26. mindspore/boost/adasum.py +1 -1
  27. mindspore/boost/boost_cell_wrapper.py +4 -4
  28. mindspore/c1.dll +0 -0
  29. mindspore/c1xx.dll +0 -0
  30. mindspore/c2.dll +0 -0
  31. mindspore/common/__init__.py +27 -2
  32. mindspore/common/_grad_function.py +2 -1
  33. mindspore/common/_pijit_context.py +28 -7
  34. mindspore/common/_stub_tensor.py +1 -209
  35. mindspore/common/_tensor_cpp_method.py +1 -1
  36. mindspore/common/_tensor_docs.py +76 -15
  37. mindspore/common/api.py +193 -112
  38. mindspore/common/dtype.py +21 -11
  39. mindspore/common/dump.py +10 -15
  40. mindspore/common/generator.py +2 -3
  41. mindspore/common/hook_handle.py +11 -2
  42. mindspore/common/jit_config.py +1 -1
  43. mindspore/common/jit_trace.py +84 -105
  44. mindspore/common/parameter.py +26 -12
  45. mindspore/common/recompute.py +3 -3
  46. mindspore/common/sparse_tensor.py +0 -3
  47. mindspore/common/symbol.py +0 -1
  48. mindspore/common/tensor.py +48 -83
  49. mindspore/communication/_comm_helper.py +46 -4
  50. mindspore/communication/management.py +79 -7
  51. mindspore/context.py +38 -23
  52. mindspore/dataset/core/config.py +3 -3
  53. mindspore/dataset/engine/datasets.py +20 -7
  54. mindspore/dataset/engine/datasets_user_defined.py +32 -2
  55. mindspore/dataset/engine/iterators.py +2 -2
  56. mindspore/dataset/engine/obs/config_loader.py +2 -2
  57. mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +8 -0
  58. mindspore/dataset/transforms/py_transforms.py +7 -3
  59. mindspore/dataset/transforms/transforms.py +7 -3
  60. mindspore/dataset/vision/validators.py +1 -0
  61. mindspore/device_context/ascend/device.py +1 -1
  62. mindspore/device_context/gpu/__init__.py +2 -2
  63. mindspore/device_context/gpu/device.py +1 -1
  64. mindspore/device_context/gpu/op_precision.py +4 -2
  65. mindspore/device_context/gpu/op_tuning.py +6 -3
  66. mindspore/device_manager.py +16 -9
  67. mindspore/dnnl.dll +0 -0
  68. mindspore/dpcmi.dll +0 -0
  69. mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +3 -5
  70. mindspore/experimental/llm_boost/atb/boost_base.py +2 -3
  71. mindspore/experimental/optim/adadelta.py +13 -20
  72. mindspore/experimental/optim/adagrad.py +15 -22
  73. mindspore/experimental/optim/adam.py +17 -24
  74. mindspore/experimental/optim/adamax.py +14 -22
  75. mindspore/experimental/optim/adamw.py +28 -34
  76. mindspore/experimental/optim/asgd.py +15 -25
  77. mindspore/experimental/optim/lr_scheduler.py +27 -45
  78. mindspore/experimental/optim/nadam.py +14 -24
  79. mindspore/experimental/optim/optimizer.py +13 -23
  80. mindspore/experimental/optim/radam.py +18 -24
  81. mindspore/experimental/optim/rmsprop.py +14 -25
  82. mindspore/experimental/optim/rprop.py +15 -26
  83. mindspore/experimental/optim/sgd.py +9 -19
  84. mindspore/hal/__init__.py +4 -4
  85. mindspore/hal/contiguous_tensors_handle.py +2 -2
  86. mindspore/hal/memory.py +1 -0
  87. mindspore/include/api/cell.h +37 -1
  88. mindspore/include/api/delegate.h +10 -0
  89. mindspore/include/api/model.h +3 -0
  90. mindspore/include/api/types.h +2 -2
  91. mindspore/include/c_api/model_c.h +0 -58
  92. mindspore/include/c_api/tensor_c.h +0 -26
  93. mindspore/include/dataset/vision_ascend.h +1 -1
  94. mindspore/jpeg62.dll +0 -0
  95. mindspore/mindrecord/tools/cifar10.py +60 -11
  96. mindspore/mindrecord/tools/cifar10_to_mr.py +5 -0
  97. mindspore/mindspore_backend_common.dll +0 -0
  98. mindspore/mindspore_backend_manager.dll +0 -0
  99. mindspore/mindspore_common.dll +0 -0
  100. mindspore/mindspore_core.dll +0 -0
  101. mindspore/mindspore_cpu_res_manager.dll +0 -0
  102. mindspore/mindspore_dump.dll +0 -0
  103. mindspore/mindspore_frontend.dll +0 -0
  104. mindspore/mindspore_glog.dll +0 -0
  105. mindspore/mindspore_memory_pool.dll +0 -0
  106. mindspore/mindspore_ms_backend.dll +0 -0
  107. mindspore/mindspore_ops.dll +0 -0
  108. mindspore/mindspore_ops_host.dll +0 -0
  109. mindspore/mindspore_ops_kernel_common.dll +0 -0
  110. mindspore/mindspore_profiler.dll +0 -0
  111. mindspore/mindspore_pyboost.dll +0 -0
  112. mindspore/mindspore_pynative.dll +0 -0
  113. mindspore/mindspore_res_manager.dll +0 -0
  114. mindspore/mindspore_runtime_pipeline.dll +0 -0
  115. mindspore/mint/__init__.py +4 -44
  116. mindspore/mint/distributed/__init__.py +1 -0
  117. mindspore/mint/distributed/distributed.py +208 -5
  118. mindspore/mint/nn/__init__.py +1 -1
  119. mindspore/mint/nn/functional.py +53 -6
  120. mindspore/mint/nn/layer/_functions.py +164 -294
  121. mindspore/mint/nn/layer/activation.py +8 -6
  122. mindspore/mint/nn/layer/conv.py +122 -98
  123. mindspore/mint/nn/layer/normalization.py +8 -22
  124. mindspore/mint/optim/adam.py +19 -18
  125. mindspore/mint/optim/adamw.py +14 -8
  126. mindspore/mint/optim/sgd.py +5 -5
  127. mindspore/msobj140.dll +0 -0
  128. mindspore/mspdb140.dll +0 -0
  129. mindspore/mspdbcore.dll +0 -0
  130. mindspore/mspdbst.dll +0 -0
  131. mindspore/mspft140.dll +0 -0
  132. mindspore/msvcdis140.dll +0 -0
  133. mindspore/msvcp140_1.dll +0 -0
  134. mindspore/msvcp140_2.dll +0 -0
  135. mindspore/msvcp140_atomic_wait.dll +0 -0
  136. mindspore/msvcp140_codecvt_ids.dll +0 -0
  137. mindspore/nn/cell.py +325 -499
  138. mindspore/nn/grad/cell_grad.py +11 -12
  139. mindspore/nn/layer/activation.py +32 -34
  140. mindspore/nn/layer/basic.py +67 -64
  141. mindspore/nn/layer/channel_shuffle.py +4 -4
  142. mindspore/nn/layer/combined.py +4 -2
  143. mindspore/nn/layer/conv.py +86 -85
  144. mindspore/nn/layer/dense.py +9 -7
  145. mindspore/nn/layer/embedding.py +50 -52
  146. mindspore/nn/layer/image.py +37 -39
  147. mindspore/nn/layer/math.py +111 -112
  148. mindspore/nn/layer/normalization.py +56 -44
  149. mindspore/nn/layer/pooling.py +58 -63
  150. mindspore/nn/layer/rnn_cells.py +33 -33
  151. mindspore/nn/layer/rnns.py +56 -56
  152. mindspore/nn/layer/thor_layer.py +74 -73
  153. mindspore/nn/layer/transformer.py +11 -1
  154. mindspore/nn/learning_rate_schedule.py +20 -20
  155. mindspore/nn/loss/loss.py +79 -81
  156. mindspore/nn/optim/adam.py +1 -1
  157. mindspore/nn/optim/adasum.py +2 -2
  158. mindspore/nn/optim/optimizer.py +1 -1
  159. mindspore/nn/optim/thor.py +2 -2
  160. mindspore/nn/probability/distribution/exponential.py +2 -1
  161. mindspore/nn/probability/distribution/poisson.py +2 -1
  162. mindspore/nn/sparse/sparse.py +3 -3
  163. mindspore/nn/wrap/cell_wrapper.py +34 -37
  164. mindspore/nn/wrap/grad_reducer.py +37 -37
  165. mindspore/nn/wrap/loss_scale.py +72 -74
  166. mindspore/numpy/array_creations.py +5 -5
  167. mindspore/numpy/fft.py +1 -1
  168. mindspore/numpy/math_ops.py +1 -1
  169. mindspore/opencv_core452.dll +0 -0
  170. mindspore/opencv_imgcodecs452.dll +0 -0
  171. mindspore/opencv_imgproc452.dll +0 -0
  172. mindspore/ops/_grad_experimental/grad_comm_ops.py +51 -13
  173. mindspore/ops/_grad_experimental/grad_debug_ops.py +14 -0
  174. mindspore/ops/_vmap/vmap_array_ops.py +6 -13
  175. mindspore/ops/_vmap/vmap_nn_ops.py +8 -16
  176. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +17 -8
  177. mindspore/ops/auto_generate/gen_extend_func.py +1 -51
  178. mindspore/ops/auto_generate/gen_ops_def.py +463 -257
  179. mindspore/ops/auto_generate/gen_ops_prim.py +1127 -885
  180. mindspore/ops/auto_generate/pyboost_inner_prim.py +31 -1
  181. mindspore/ops/composite/__init__.py +10 -0
  182. mindspore/ops/composite/base.py +8 -4
  183. mindspore/ops/composite/multitype_ops/__init__.py +12 -1
  184. mindspore/ops/composite/multitype_ops/_compile_utils.py +132 -108
  185. mindspore/ops/composite/multitype_ops/add_impl.py +70 -2
  186. mindspore/ops/composite/multitype_ops/div_impl.py +49 -0
  187. mindspore/ops/composite/multitype_ops/floordiv_impl.py +29 -0
  188. mindspore/ops/composite/multitype_ops/getitem_impl.py +11 -0
  189. mindspore/ops/composite/multitype_ops/mod_impl.py +5 -3
  190. mindspore/ops/composite/multitype_ops/mul_impl.py +49 -0
  191. mindspore/ops/composite/multitype_ops/setitem_impl.py +57 -0
  192. mindspore/ops/composite/multitype_ops/sub_impl.py +34 -0
  193. mindspore/ops/composite/multitype_ops/zeros_like_impl.py +14 -0
  194. mindspore/ops/function/__init__.py +3 -1
  195. mindspore/ops/function/_add_attr_func.py +11 -6
  196. mindspore/ops/function/array_func.py +7 -94
  197. mindspore/ops/function/debug_func.py +4 -3
  198. mindspore/ops/function/grad/grad_func.py +1 -1
  199. mindspore/ops/function/math_func.py +21 -367
  200. mindspore/ops/function/nn_func.py +26 -41
  201. mindspore/ops/function/other_func.py +4 -1
  202. mindspore/ops/function/random_func.py +31 -4
  203. mindspore/ops/functional.py +0 -2
  204. mindspore/ops/functional_overload.py +463 -6
  205. mindspore/ops/op_info_register.py +21 -0
  206. mindspore/ops/operations/__init__.py +5 -2
  207. mindspore/ops/operations/_custom_ops_utils.py +675 -8
  208. mindspore/ops/operations/_inner_ops.py +3 -6
  209. mindspore/ops/operations/_sequence_ops.py +1 -1
  210. mindspore/ops/operations/comm_ops.py +185 -26
  211. mindspore/ops/operations/custom_ops.py +235 -172
  212. mindspore/ops/operations/debug_ops.py +55 -4
  213. mindspore/ops/operations/image_ops.py +13 -13
  214. mindspore/ops/operations/manually_defined/ops_def.py +15 -16
  215. mindspore/ops/operations/math_ops.py +3 -4
  216. mindspore/ops/operations/nn_ops.py +5 -6
  217. mindspore/ops/primitive.py +6 -10
  218. mindspore/ops/tensor_method.py +36 -4
  219. mindspore/ops_generate/api/cpp_create_prim_instance_helper_generator.py +1 -1
  220. mindspore/ops_generate/api/functional_map_cpp_generator.py +10 -9
  221. mindspore/ops_generate/api/functions_cc_generator.py +58 -10
  222. mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +1 -1
  223. mindspore/ops_generate/common/base_generator.py +14 -0
  224. mindspore/ops_generate/common/gen_constants.py +7 -2
  225. mindspore/ops_generate/common/gen_utils.py +0 -19
  226. mindspore/ops_generate/common/op_proto.py +11 -4
  227. mindspore/ops_generate/common/template.py +88 -11
  228. mindspore/ops_generate/gen_ops.py +1 -1
  229. mindspore/ops_generate/op_def/lite_ops_cpp_generator.py +4 -4
  230. mindspore/ops_generate/op_def/ops_name_h_generator.py +0 -3
  231. mindspore/ops_generate/op_def/ops_primitive_h_generator.py +0 -4
  232. mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -2
  233. mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +49 -8
  234. mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +2 -2
  235. mindspore/ops_generate/pyboost/gen_pyboost_func.py +31 -0
  236. mindspore/ops_generate/pyboost/op_template_parser.py +98 -72
  237. mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +70 -273
  238. mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +14 -6
  239. mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +316 -0
  240. mindspore/ops_generate/pyboost/pyboost_functions_py_generator.py +1 -1
  241. mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +5 -3
  242. mindspore/ops_generate/pyboost/pyboost_inner_prim_generator.py +1 -1
  243. mindspore/ops_generate/pyboost/pyboost_internal_functions_cpp_generator.py +76 -0
  244. mindspore/ops_generate/pyboost/pyboost_internal_functions_h_generator.py +76 -0
  245. mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +125 -0
  246. mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +4 -3
  247. mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +348 -61
  248. mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +1 -1
  249. mindspore/ops_generate/pyboost/pyboost_utils.py +118 -9
  250. mindspore/ops_generate/tensor_py_cc_generator.py +1 -24
  251. mindspore/parallel/_auto_parallel_context.py +4 -2
  252. mindspore/parallel/_cell_wrapper.py +106 -40
  253. mindspore/parallel/_parallel_serialization.py +1 -1
  254. mindspore/parallel/_ps_context.py +4 -6
  255. mindspore/parallel/_tensor.py +167 -12
  256. mindspore/parallel/_transformer/moe.py +1 -1
  257. mindspore/parallel/_transformer/transformer.py +13 -8
  258. mindspore/parallel/auto_parallel.py +12 -5
  259. mindspore/parallel/checkpoint_convert.py +3 -3
  260. mindspore/parallel/checkpoint_transform.py +3 -1
  261. mindspore/parallel/cluster/process_entity/_api.py +84 -48
  262. mindspore/parallel/cluster/process_entity/_utils.py +95 -7
  263. mindspore/parallel/cluster/run.py +43 -4
  264. mindspore/parallel/function/__init__.py +8 -1
  265. mindspore/parallel/function/reshard_func.py +1 -1
  266. mindspore/parallel/nn/__init__.py +15 -2
  267. mindspore/parallel/nn/parallel_cell_wrapper.py +9 -10
  268. mindspore/parallel/nn/parallel_grad_reducer.py +7 -6
  269. mindspore/parallel/shard.py +2 -2
  270. mindspore/parallel/transform_safetensors.py +462 -174
  271. mindspore/pgodb140.dll +0 -0
  272. mindspore/pgort140.dll +0 -0
  273. mindspore/profiler/__init__.py +2 -1
  274. mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +7 -7
  275. mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +3 -0
  276. mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +3 -0
  277. mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +3 -3
  278. mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +3 -3
  279. mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +4 -4
  280. mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +3 -3
  281. mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +4 -1
  282. mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +2 -1
  283. mindspore/profiler/analysis/task_manager.py +1 -1
  284. mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +5 -1
  285. mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +2 -1
  286. mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +42 -22
  287. mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +3 -2
  288. mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +9 -5
  289. mindspore/profiler/analysis/viewer/ms_operator_details_viewer.py +132 -0
  290. mindspore/profiler/common/constant.py +16 -0
  291. mindspore/profiler/common/profiler_context.py +25 -27
  292. mindspore/profiler/common/profiler_info.py +0 -16
  293. mindspore/profiler/common/profiler_op_analyse.py +235 -0
  294. mindspore/profiler/common/profiler_output_path.py +23 -8
  295. mindspore/profiler/common/profiler_parameters.py +128 -35
  296. mindspore/profiler/dynamic_profile/__init__.py +0 -0
  297. mindspore/profiler/dynamic_profile/dynamic_monitor_proxy.py +39 -0
  298. mindspore/profiler/dynamic_profile/dynamic_profiler_config_context.py +666 -0
  299. mindspore/profiler/dynamic_profile/dynamic_profiler_utils.py +62 -0
  300. mindspore/profiler/dynamic_profiler.py +305 -314
  301. mindspore/profiler/envprofiler.py +12 -7
  302. mindspore/profiler/experimental_config.py +96 -6
  303. mindspore/profiler/mstx.py +33 -12
  304. mindspore/profiler/platform/__init__.py +2 -3
  305. mindspore/profiler/platform/npu_profiler.py +29 -19
  306. mindspore/profiler/profiler.py +35 -19
  307. mindspore/profiler/profiler_action_controller.py +64 -76
  308. mindspore/profiler/schedule.py +10 -4
  309. mindspore/rewrite/common/config.py +1 -0
  310. mindspore/rewrite/common/namer.py +1 -0
  311. mindspore/rewrite/common/namespace.py +1 -0
  312. mindspore/rewrite/node/node.py +31 -11
  313. mindspore/rewrite/parsers/assign_parser.py +1 -1
  314. mindspore/rewrite/symbol_tree/symbol_tree.py +1 -1
  315. mindspore/run_check/_check_version.py +7 -10
  316. mindspore/runtime/__init__.py +5 -5
  317. mindspore/runtime/event.py +10 -4
  318. mindspore/runtime/executor.py +60 -45
  319. mindspore/runtime/memory.py +21 -30
  320. mindspore/runtime/thread_bind_core.py +298 -164
  321. mindspore/safeguard/rewrite_obfuscation.py +12 -13
  322. mindspore/swresample-4.dll +0 -0
  323. mindspore/swscale-6.dll +0 -0
  324. mindspore/tbbmalloc.dll +0 -0
  325. mindspore/tinyxml2.dll +0 -0
  326. mindspore/train/_utils.py +6 -2
  327. mindspore/train/amp.py +43 -20
  328. mindspore/train/callback/__init__.py +5 -5
  329. mindspore/train/callback/_checkpoint.py +3 -6
  330. mindspore/train/callback/_flops_collector.py +1 -1
  331. mindspore/train/callback/_landscape.py +0 -1
  332. mindspore/train/callback/_train_fault_tolerance.py +71 -13
  333. mindspore/train/data_sink.py +11 -2
  334. mindspore/train/dataset_helper.py +9 -0
  335. mindspore/train/model.py +51 -33
  336. mindspore/train/serialization.py +133 -111
  337. mindspore/train/summary/summary_record.py +13 -2
  338. mindspore/turbojpeg.dll +0 -0
  339. mindspore/utils/__init__.py +3 -2
  340. mindspore/utils/dryrun.py +0 -6
  341. mindspore/utils/runtime_execution_order_check.py +162 -78
  342. mindspore/utils/sdc_detect.py +68 -0
  343. mindspore/utils/utils.py +6 -9
  344. mindspore/vcmeta.dll +0 -0
  345. mindspore/vcruntime140.dll +0 -0
  346. mindspore/vcruntime140_1.dll +0 -0
  347. mindspore/version.py +1 -1
  348. {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/METADATA +5 -4
  349. {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/RECORD +352 -390
  350. mindspore/_deprecated/jit.py +0 -198
  351. mindspore/experimental/es/__init__.py +0 -22
  352. mindspore/experimental/es/embedding_service.py +0 -891
  353. mindspore/experimental/es/embedding_service_layer.py +0 -581
  354. mindspore/profiler/parser/__init__.py +0 -14
  355. mindspore/profiler/parser/aicpu_data_parser.py +0 -272
  356. mindspore/profiler/parser/ascend_analysis/__init__.py +0 -14
  357. mindspore/profiler/parser/ascend_analysis/constant.py +0 -71
  358. mindspore/profiler/parser/ascend_analysis/file_manager.py +0 -180
  359. mindspore/profiler/parser/ascend_analysis/function_event.py +0 -185
  360. mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +0 -136
  361. mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +0 -131
  362. mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +0 -104
  363. mindspore/profiler/parser/ascend_analysis/path_manager.py +0 -313
  364. mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +0 -123
  365. mindspore/profiler/parser/ascend_analysis/tlv_decoder.py +0 -86
  366. mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +0 -75
  367. mindspore/profiler/parser/ascend_cluster_generator.py +0 -116
  368. mindspore/profiler/parser/ascend_communicate_generator.py +0 -314
  369. mindspore/profiler/parser/ascend_flops_generator.py +0 -116
  370. mindspore/profiler/parser/ascend_fpbp_generator.py +0 -82
  371. mindspore/profiler/parser/ascend_hccl_generator.py +0 -271
  372. mindspore/profiler/parser/ascend_integrate_generator.py +0 -42
  373. mindspore/profiler/parser/ascend_memory_generator.py +0 -185
  374. mindspore/profiler/parser/ascend_msprof_exporter.py +0 -282
  375. mindspore/profiler/parser/ascend_msprof_generator.py +0 -187
  376. mindspore/profiler/parser/ascend_op_generator.py +0 -334
  377. mindspore/profiler/parser/ascend_steptrace_generator.py +0 -94
  378. mindspore/profiler/parser/ascend_timeline_generator.py +0 -545
  379. mindspore/profiler/parser/base_timeline_generator.py +0 -483
  380. mindspore/profiler/parser/container.py +0 -229
  381. mindspore/profiler/parser/cpu_gpu_timeline_generator.py +0 -697
  382. mindspore/profiler/parser/flops_parser.py +0 -531
  383. mindspore/profiler/parser/framework_enum.py +0 -111
  384. mindspore/profiler/parser/framework_parser.py +0 -464
  385. mindspore/profiler/parser/framework_struct.py +0 -61
  386. mindspore/profiler/parser/gpu_analysis/__init__.py +0 -14
  387. mindspore/profiler/parser/gpu_analysis/function_event.py +0 -44
  388. mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +0 -89
  389. mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +0 -72
  390. mindspore/profiler/parser/hccl_parser.py +0 -573
  391. mindspore/profiler/parser/hwts_log_parser.py +0 -122
  392. mindspore/profiler/parser/integrator.py +0 -526
  393. mindspore/profiler/parser/memory_usage_parser.py +0 -277
  394. mindspore/profiler/parser/minddata_analyzer.py +0 -800
  395. mindspore/profiler/parser/minddata_parser.py +0 -186
  396. mindspore/profiler/parser/minddata_pipeline_parser.py +0 -299
  397. mindspore/profiler/parser/op_intermediate_parser.py +0 -149
  398. mindspore/profiler/parser/optime_parser.py +0 -250
  399. mindspore/profiler/parser/profiler_info.py +0 -213
  400. mindspore/profiler/parser/step_trace_parser.py +0 -666
  401. {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/WHEEL +0 -0
  402. {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/entry_points.txt +0 -0
  403. {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/top_level.txt +0 -0
@@ -40,7 +40,7 @@ from mindspore.communication.management import get_rank, GlobalComm
40
40
  from ._ms_kernel import determine_variable_usage
41
41
  from ._custom_grad import autodiff_bprop
42
42
  from ._pyfunc_registry import add_pyfunc
43
- from ._custom_ops_utils import ExtensionBuilder
43
+ from ._custom_ops_utils import ExtensionBuilder, CustomCodeGenerator, CustomInfoGenerator
44
44
 
45
45
  if platform.system() != "Windows":
46
46
  import fcntl
@@ -73,13 +73,18 @@ def _get_cache_path():
73
73
  """
74
74
  cache_path = os.getenv('MS_COMPILER_CACHE_PATH')
75
75
  if cache_path is None:
76
- cache_path = "./akg_kernel_meta/"
76
+ cache_path = "./custom_kernel_meta/"
77
77
  elif cache_path[-1] != "/":
78
78
  cache_path = cache_path + "/"
79
79
 
80
80
  if not os.path.exists(cache_path):
81
81
  os.makedirs(cache_path, exist_ok=True)
82
82
 
83
+ # for distributed case, we create folders separately to avoid conflict
84
+ if GlobalComm.INITED:
85
+ cache_path = os.path.join(cache_path, "rank_" + str(get_rank()), "")
86
+ os.makedirs(cache_path, exist_ok=True)
87
+
83
88
  return cache_path
84
89
 
85
90
 
@@ -94,10 +99,6 @@ def _compile_aot(file):
94
99
  str, the path to the compiled library.
95
100
  """
96
101
  cache_path = _get_cache_path()
97
- # for distributed case, we create folders separately to avoid conflict
98
- if GlobalComm.INITED:
99
- cache_path = os.path.join(cache_path, "rank_" + str(get_rank()), "")
100
- os.makedirs(cache_path, exist_ok=True)
101
102
 
102
103
  res_path = importlib.util.find_spec("mindspore").origin
103
104
  find_pos = res_path.find("__init__.py")
@@ -233,14 +234,13 @@ class Custom(ops.PrimitiveWithInfer):
233
234
  <https://www.mindspore.cn/tutorials/en/master/custom_program/op_custom.html>`_ .
234
235
 
235
236
  .. warning::
236
- - This is an experimental API that is subject to change.
237
+ This is an experimental API that is subject to change.
237
238
 
238
239
  .. note::
239
240
  The supported platforms are determined by the input `func_type`. The supported platforms are as follows:
240
241
 
241
242
  - "aot": supports ["GPU", "CPU", "Ascend"].
242
243
  - "pyfunc": supports ["CPU"].
243
- - "julia": supports ["CPU"].
244
244
 
245
245
  Args:
246
246
  func (Union[function, str]):
@@ -249,101 +249,84 @@ class Custom(ops.PrimitiveWithInfer):
249
249
  computation logic of a user defined operator.
250
250
 
251
251
  - str: If func is of str type, then str should be a path of file along with a function name.
252
- This could be used when func_type is "aot" or "julia".
253
-
254
- 1. for "aot":
255
-
256
- a) GPU/CPU platform.
257
- "aot" means ahead of time, in which case Custom directly launches user defined "xxx.so" file as an
258
- operator. Users need to compile a handwriting "xxx.cu"/"xxx.cc" file into "xxx.so" ahead of time,
259
- and offer the path of the file along with a function name.
260
-
261
- - "xxx.so" file generation:
252
+ This could be used when func_type is "aot".
262
253
 
263
- 1) GPU Platform: Given user defined "xxx.cu" file (ex. "{path}/add.cu"), use nvcc command to compile
264
- it.(ex. "nvcc --shared -Xcompiler -fPIC -o add.so add.cu")
254
+ for "aot":
265
255
 
266
- 2) CPU Platform: Given user defined "xxx.cc" file (ex. "{path}/add.cc"), use g++/gcc command to
267
- compile it.(ex. "g++ --shared -fPIC -o add.so add.cc")
256
+ a) GPU/CPU platform.
257
+ "aot" means ahead of time, in which case Custom directly launches user defined "xxx.so" file as an
258
+ operator. Users need to compile a handwriting "xxx.cu"/"xxx.cc" file into "xxx.so" ahead of time,
259
+ and offer the path of the file along with a function name.
268
260
 
269
- - Define a "xxx.cc"/"xxx.cu" file:
261
+ - "xxx.so" file generation:
270
262
 
271
- "aot" is a cross-platform identity. The functions defined in "xxx.cc" or "xxx.cu" share
272
- the same args. Typically, the function should be as:
263
+ 1) GPU Platform: Given user defined "xxx.cu" file (ex. "{path}/add.cu"), use nvcc command to compile
264
+ it.(ex. "nvcc --shared -Xcompiler -fPIC -o add.so add.cu")
273
265
 
274
- .. code-block::
266
+ 2) CPU Platform: Given user defined "xxx.cc" file (ex. "{path}/add.cc"), use g++/gcc command to
267
+ compile it.(ex. "g++ --shared -fPIC -o add.so add.cc")
275
268
 
276
- int func(int nparam, void **params, int *ndims, int64_t **shapes, const char **dtypes,
277
- void *stream, void *extra)
269
+ - Define a "xxx.cc"/"xxx.cu" file:
278
270
 
279
- Parameters:
271
+ "aot" is a cross-platform identity. The functions defined in "xxx.cc" or "xxx.cu" share
272
+ the same args. Typically, the function should be as:
280
273
 
281
- - nparam(int): total number of inputs plus outputs; suppose the operator has 2 inputs and 3 outputs,
282
- then nparam=5
283
- - params(void \*\*): a pointer to the array of inputs and outputs' pointer; the pointer type of
284
- inputs and outputs is void \* ; suppose the operator has 2 inputs and 3 outputs, then the first
285
- input's pointer is params[0] and the second output's pointer is params[3]
286
- - ndims(int \*): a pointer to the array of inputs and outputs' dimension num; suppose params[i] is a
287
- 1024x1024 tensor and params[j] is a 77x83x4 tensor, then ndims[i]=2, ndims[j]=3.
288
- - shapes(int64_t \*\*): a pointer to the array of inputs and outputs' shapes(int64_t \*); the ith
289
- input's jth dimension's size is shapes[i][j](0<=j<ndims[i]); suppose params[i] is a 2x3 tensor and
290
- params[j] is a 3x3x4 tensor, then shapes[i][0]=2, shapes[j][2]=4.
291
- - dtypes(const char \*\*): a pointer to the array of inputs and outputs' types(const char \*);
292
- (ex. "float32", "float16", "float", "float64", "int", "int8", "int16", "int32", "int64", "uint",
293
- "uint8", "uint16", "uint32", "uint64", "bool")
294
- - stream(void \*): stream pointer, only used in cuda file
295
- - extra(void \*): used for further extension
274
+ .. code-block::
296
275
 
297
- Return Value(int):
276
+ int func(int nparam, void **params, int *ndims, int64_t **shapes, const char **dtypes,
277
+ void *stream, void *extra)
298
278
 
299
- - 0: MindSpore will continue to run if this aot kernel is successfully executed
300
- - others: MindSpore will raise exception and exit
279
+ Parameters:
301
280
 
302
- Examples: see details in tests/st/ops/graph_kernel/custom/aot_test_files/
281
+ - nparam(int): total number of inputs plus outputs; suppose the operator has 2 inputs and 3 outputs,
282
+ then nparam=5
283
+ - params(void \*\*): a pointer to the array of inputs and outputs' pointer; the pointer type of
284
+ inputs and outputs is void \* ; suppose the operator has 2 inputs and 3 outputs, then the first
285
+ input's pointer is params[0] and the second output's pointer is params[3]
286
+ - ndims(int \*): a pointer to the array of inputs and outputs' dimension num; suppose params[i] is a
287
+ 1024x1024 tensor and params[j] is a 77x83x4 tensor, then ndims[i]=2, ndims[j]=3.
288
+ - shapes(int64_t \*\*): a pointer to the array of inputs and outputs' shapes(int64_t \*); the ith
289
+ input's jth dimension's size is shapes[i][j](0<=j<ndims[i]); suppose params[i] is a 2x3 tensor and
290
+ params[j] is a 3x3x4 tensor, then shapes[i][0]=2, shapes[j][2]=4.
291
+ - dtypes(const char \*\*): a pointer to the array of inputs and outputs' types(const char \*);
292
+ (ex. "float32", "float16", "float", "float64", "int", "int8", "int16", "int32", "int64", "uint",
293
+ "uint8", "uint16", "uint32", "uint64", "bool")
294
+ - stream(void \*): stream pointer, only used in cuda file
295
+ - extra(void \*): used for further extension
303
296
 
304
- - Use it in Custom:
297
+ Return Value(int):
305
298
 
306
- .. code-block::
299
+ - 0: MindSpore will continue to run if this aot kernel is successfully executed
300
+ - others: MindSpore will raise exception and exit
307
301
 
308
- Custom(func="{dir_path}/{file_name}:{func_name}",...)
309
- (ex. Custom(func="./reorganize.so:CustomReorganize", out_shape=[1], out_dtype=mstype.float32,
310
- "aot"))
302
+ Examples: see details in tests/st/ops/graph_kernel/custom/aot_test_files/
311
303
 
312
- b) Ascend platform.
313
- Before using Custom operators on the Ascend platform, users must first develop custom operators
314
- based on Ascend C and compile them. The complete development and usage process can refer to the
315
- tutorial `AOT-Type Custom Operators(Ascend)
316
- <https://www.mindspore.cn/tutorials/en/master/custom_program/operation/op_custom_ascendc.html>`_.
317
- By passing the name of the operator through the input parameter `func`, there are two usage methods
318
- based on the implementation of the infer function:
304
+ - Use it in Custom:
319
305
 
320
- - Python infer: If the operator's infer function is implemented in Python, that is, the infer shape
321
- function is passed through the `out_shape` parameter, and the infer type is passed throuht the
322
- `out_dtype`, then the `func` should be specified as the operator name, for example,
323
- `func="CustomName"`.
324
- - C++ infer: If the operator's infer function is implemented through C++, then pass the path of the
325
- infer function implementation file in `func` and separate the operator name with `:`,
326
- for example: `func="add_custom_infer.cc:AddCustom"` .
306
+ .. code-block::
327
307
 
328
- 2. for "julia":
308
+ Custom(func="{dir_path}/{file_name}:{func_name}",...)
309
+ (ex. Custom(func="./reorganize.so:CustomReorganize", out_shape=[1], out_dtype=mstype.float32,
310
+ "aot"))
329
311
 
330
- Currently "julia" supports CPU(linux only) platform.
331
- For julia use JIT compiler, and julia support c api to call julia code.
332
- The Custom can directly launches user defined "xxx.jl" file as an operator.
333
- Users need to write a "xxx.jl" file which include modules and functions,
334
- and offer the path of the file along with a module name and function name.
312
+ b) Ascend platform.
313
+ Before using Custom operators on the Ascend platform, users must first develop custom operators
314
+ based on Ascend C and compile them. The complete development and usage process can refer to the
315
+ tutorial `AOT-Type Custom Operators(Ascend)
316
+ <https://www.mindspore.cn/tutorials/en/master/custom_program/operation/op_custom_ascendc.html>`_.
317
+ By passing the name of the operator through the input parameter `func`, there are two usage methods
318
+ based on the implementation of the infer function:
335
319
 
336
- Examples: see details in tests/st/ops/graph_kernel/custom/julia_test_files/
320
+ - Python infer: If the operator's infer function is implemented in Python, that is, the infer shape
321
+ function is passed through the `out_shape` parameter, and the infer type is passed throuht the
322
+ `out_dtype`, then the `func` should be specified as the operator name, for example,
323
+ `func="CustomName"`.
324
+ - C++ infer: If the operator's infer function is implemented through C++, then pass the path of the
325
+ infer function implementation file in `func` and separate the operator name with `:`,
326
+ for example: `func="add_custom_infer.cc:AddCustom"` .
337
327
 
338
- - Use it in Custom:
339
-
340
- .. code-block::
341
-
342
- Custom(func="{dir_path}/{file_name}:{module_name}:{func_name}",...)
343
- (ex. Custom(func="./add.jl:Add:add", out_shape=[1], out_dtype=mstype.float32, "julia"))
344
-
345
- out_shape (Union[function, list, tuple]): The output shape infer function or the value of output shape of
346
- `func`. Default: ``None`` .
328
+ out_shape (Union[function, list, tuple], optional): The output shape infer function or the value of output
329
+ shape of `func`. Default: ``None`` .
347
330
 
348
331
  If func has single output, then the value of output shape is a list or tuple of int.
349
332
 
@@ -353,8 +336,8 @@ class Custom(ops.PrimitiveWithInfer):
353
336
  The input can be None only when the func_type input is "hybrid". In this case, the automatic infer
354
337
  shape mechanic will be enabled.
355
338
 
356
- out_dtype (Union[function, :class:`mindspore.dtype`, tuple[:class:`mindspore.dtype`]]): The output data type
357
- infer function or the value of output data type of `func`. Default: ``None`` .
339
+ out_dtype (Union[function, :class:`mindspore.dtype`, tuple[:class:`mindspore.dtype`]], optional): The output
340
+ data type infer function or the value of output data type of `func`. Default: ``None`` .
358
341
 
359
342
  If func has single output, then the value of output shape is a `mindspore.dtype`.
360
343
 
@@ -364,13 +347,12 @@ class Custom(ops.PrimitiveWithInfer):
364
347
  The input can be None only when the func_type input is "hybrid". In this case, the automatic infer
365
348
  value mechanic will be enabled.
366
349
 
367
- func_type (str): The implementation type of `func`, should be one of
350
+ func_type (str, optional): The implementation type of `func`, should be one of
351
+ [ ``"aot"`` , ``"pyfunc"``]. Default: ``"pyfunc"``.
368
352
 
369
- [ ``"aot"`` , ``"pyfunc"`` , ``"julia"`` ].
370
-
371
- bprop (function): The back propagation function of `func`. Default: ``None`` .
372
- reg_info (Union[str, dict, list, tuple]): Represents the registration information(reg info) of `func` with
373
- json format of type str or dict. The reg info specifies supported data types and formats of inputs and
353
+ bprop (function, optional): The back propagation function of `func`. Default: ``None`` .
354
+ reg_info (Union[str, dict, list, tuple], optional): Represents the registration information(reg info) of `func`
355
+ with json format of type str or dict. The reg info specifies supported data types and formats of inputs and
374
356
  outputs, attributes and target of `func`. Default: ``None`` .
375
357
 
376
358
  If reg info is a list or tuple, then each item should be with json format of type str or dict, which
@@ -428,11 +410,11 @@ class Custom(ops.PrimitiveWithInfer):
428
410
  op_path_in_cache = [] # Save paths for op functions created in the cached.
429
411
  custom_aot_warning = True # Flag to enable warnings about custom aot path white list
430
412
 
431
- def __init__(self, func, out_shape=None, out_dtype=None, func_type="hybrid", bprop=None, reg_info=None):
413
+ def __init__(self, func, out_shape=None, out_dtype=None, func_type="pyfunc", bprop=None, reg_info=None):
432
414
  super().__init__("Custom")
433
415
 
434
416
  self.supported_targets = [ASCEND, GPU, CPU]
435
- self.supported_func_type = ["hybrid", "akg", "tbe", "aicpu", "aot", "pyfunc", "julia"]
417
+ self.supported_func_type = ["hybrid", "akg", "tbe", "aicpu", "aot", "pyfunc"]
436
418
  self.log_prefix = "For '{}', 'func_type': {}, 'func': {}".format(self.name, func_type, func)
437
419
  self.func = func
438
420
  self.func_type = func_type
@@ -444,11 +426,13 @@ class Custom(ops.PrimitiveWithInfer):
444
426
  self._is_ms_kernel = False
445
427
  self.out_shape = out_shape
446
428
  self.out_dtype = out_dtype
447
- self.is_ascend_c = context.get_context("device_target") == "Ascend" and self.func_type == "aot"
429
+ self.reg_info = reg_info
430
+ self.is_ascend_c = (context.get_context("device_target") == "Ascend" and self.func_type == "aot")
448
431
 
449
432
  self._check_platform()
450
433
  self._check_func()
451
- self._update_func_info(reg_info)
434
+ self._generate_reg_info()
435
+ self._update_func_info(self.reg_info)
452
436
  self.add_prim_attr("func_name", self.func_name)
453
437
  self.add_prim_attr("uniq_name", self.uniq_name)
454
438
  if self.func_type == HYBRID_TYPE:
@@ -460,23 +444,22 @@ class Custom(ops.PrimitiveWithInfer):
460
444
  add_pyfunc(func_id, self.func)
461
445
  self.add_prim_attr("fn_id", func_id)
462
446
 
463
- self.set_infer_flag()
464
-
465
- self.multi_output = (reg_info is not None and (len(reg_info.get("outputs", [])) > 1))
466
- self.add_prim_attr("multi_output", self.multi_output)
447
+ self._set_infer_flag()
448
+ self._set_multi_output_flag()
467
449
 
468
450
  self.bprop = bprop
469
451
  self.fake_output = False
470
452
  self.single_scalar_output = False
471
- if not self.out_dtype and not self.func_type == "pyfunc":
472
- self.fake_output = True
473
- elif not self.out_shape and self.func_type == "pyfunc":
474
- self.single_scalar_output = True
475
- self.add_prim_attr("fake_output", self.fake_output)
476
- self.add_prim_attr("single_scalar_output", self.single_scalar_output)
453
+ if self.func_type == "pyfunc":
454
+ if not self.out_dtype:
455
+ self.fake_output = True
456
+ elif not self.out_shape:
457
+ self.single_scalar_output = True
458
+ self.add_prim_attr("fake_output", self.fake_output)
459
+ self.add_prim_attr("single_scalar_output", self.single_scalar_output)
477
460
 
478
461
  # Register info
479
- self._register_info(reg_info)
462
+ self._register_info(self.reg_info)
480
463
 
481
464
  if func_type == "akg":
482
465
  self._set_akg_kernel_type()
@@ -488,25 +471,22 @@ class Custom(ops.PrimitiveWithInfer):
488
471
  self._update_attr()
489
472
 
490
473
  if self.is_ascend_c:
491
- self.set_inputs_type(reg_info)
492
474
  self.custom_pyboost = _CustomExt(self.func, self.out_shape, self.out_dtype, self.bprop)
493
475
  for key, value in super().get_attr_dict().items():
494
476
  self.custom_pyboost.add_prim_attr(key, value)
477
+ self._generate_get_workspace_size_func()
495
478
 
496
- def set_infer_flag(self):
479
+ def _set_infer_flag(self):
497
480
  """set cpp infer attr"""
498
481
  if self.out_shape is None and self.func_type == "aot":
499
482
  self.add_prim_attr("cpp_infer_shape", True)
500
483
  if self.out_dtype is None and self.func_type == "aot":
501
484
  self.add_prim_attr("cpp_infer_type", True)
502
485
 
503
- def set_inputs_type(self, reg_info):
504
- """set custom_inputs_type attr"""
505
- if not self.is_ascend_c or not reg_info.get('attr'):
506
- return
507
- inputs_type = ["tensor"] * len(reg_info.get("inputs", [])) + \
508
- [attr.get("type") for attr in reg_info.get("attr", [])]
509
- self.add_prim_attr("custom_inputs_type", inputs_type)
486
+ def _set_multi_output_flag(self):
487
+ outputs = self.reg_info.get("outputs", []) if self.reg_info else []
488
+ self.multi_output = len(outputs) > 1 or (len(outputs) == 1 and outputs[0].get("paramType") == "dynamic")
489
+ self.add_prim_attr("multi_output", self.multi_output)
510
490
 
511
491
  def __infer__(self, *args):
512
492
  if callable(self.out_shape):
@@ -586,22 +566,6 @@ class Custom(ops.PrimitiveWithInfer):
586
566
  self.func_type = HYBRID_TYPE
587
567
  self._hybrid_func_analyser()
588
568
 
589
- def _check_julia_func(self):
590
- """Check the validity of julia func"""
591
- if not isinstance(self.func, str):
592
- raise TypeError("{}, 'func' must be of type str, but got {}".format(self.log_prefix, type(self.func)))
593
- if self.func.count(':') != 2:
594
- raise ValueError("{}, the format of 'func' must be file:module:func".format(self.log_prefix))
595
- source_file, module, func = self.func.split(':')
596
- with open(source_file, 'r') as f:
597
- jl = f.read()
598
- if 'module ' + module not in jl:
599
- raise Exception("{}, module {} is not found in source file {}!"
600
- .format(self.log_prefix, module, source_file))
601
- if 'function ' + func not in jl:
602
- raise Exception("{}, function {} is not found in source file {}!"
603
- .format(self.log_prefix, func, source_file))
604
-
605
569
  def _check_aot_func(self):
606
570
  """Check the source code and bin lib for aot type custom op"""
607
571
  if not isinstance(self.func, str):
@@ -644,8 +608,6 @@ class Custom(ops.PrimitiveWithInfer):
644
608
  if self.func_type == "aot":
645
609
  self._check_aot_func()
646
610
 
647
- elif self.func_type == "julia":
648
- self._check_julia_func()
649
611
  elif self.func_type == HYBRID_TYPE:
650
612
  if not hasattr(self.func, MS_KERNEL_FLAG):
651
613
  raise TypeError("{}, 'func' must be a function decorated by kernel".format(self.log_prefix))
@@ -962,7 +924,7 @@ class Custom(ops.PrimitiveWithInfer):
962
924
  return reg_info[IMPLY_TYPE]
963
925
  # Infer imply_type from func_type
964
926
  func_type_to_imply_type = {"hybrid": AKG, "akg": AKG, "tbe": TBE, "aicpu": "AiCPU", "pyfunc": target,
965
- "julia": target, "aot": "BiSheng" if target == ASCEND else target}
927
+ "aot": "BiSheng" if target == ASCEND else target}
966
928
  return func_type_to_imply_type.get(self.func_type, AKG)
967
929
 
968
930
  def _save_attr(self, reg_info):
@@ -1034,17 +996,6 @@ class Custom(ops.PrimitiveWithInfer):
1034
996
  self.set_device(GPU)
1035
997
  elif registered_targets == [CPU]:
1036
998
  self.set_device(CPU)
1037
- elif self.func_type == "julia":
1038
- self.set_device(CPU)
1039
- device_target = context.get_context('device_target')
1040
- if device_target == CPU:
1041
- pass
1042
- elif device_target == GPU and registered_targets and registered_targets == [CPU]:
1043
- logger.warning("{}, only supports CPU platform, but got registered target {}. "
1044
- "We will run it on CPU".format(self.log_prefix, registered_targets))
1045
- else:
1046
- raise ValueError("{}, only supports CPU platform, but got target {}."
1047
- .format(self.log_prefix, device_target))
1048
999
 
1049
1000
  def _update_attr(self):
1050
1001
  """Add input_names, attr_names, primitive_target to primitive's attr."""
@@ -1140,6 +1091,88 @@ class Custom(ops.PrimitiveWithInfer):
1140
1091
 
1141
1092
  return infer_shape, infer_dtype, infer_value
1142
1093
 
1094
+ def _generate_reg_info(self):
1095
+ if not self.is_ascend_c:
1096
+ return
1097
+ if self.reg_info is None:
1098
+ func_name, _ = self._split_func()
1099
+ if func_name.startswith("aclnn"):
1100
+ func_name = func_name[len("aclnn"):]
1101
+ reg_info_generator = CustomInfoGenerator(func_name)
1102
+ self.reg_info = reg_info_generator.generate_custom_reg_op()
1103
+
1104
+ def _split_func(self):
1105
+ func_list = self.func.split(":")
1106
+ func_path = ""
1107
+ if len(func_list) == 2:
1108
+ func_path = func_list[0]
1109
+ func_name = func_list[1]
1110
+ else:
1111
+ func_name = self.func
1112
+ return func_name, func_path
1113
+
1114
+ def _generate_get_worspace_size_func_by_types(self, aclnn_api_types):
1115
+ """generate custom GetWorkSpaceSize func by aclnn api types"""
1116
+ if not self.is_ascend_c:
1117
+ return
1118
+
1119
+ input_output_types = []
1120
+ if isinstance(aclnn_api_types, str):
1121
+ params = re.split(r',\s*', aclnn_api_types)
1122
+ for param in params:
1123
+ param = param.replace('const ', '')
1124
+ type_part = re.search(r'^\s*(\w+\s*\*+|\w+)', param).group(1)
1125
+ type_part = type_part.replace(' ', '')
1126
+ input_output_types.append(type_part)
1127
+ elif isinstance(aclnn_api_types, list):
1128
+ input_output_types = aclnn_api_types
1129
+ else:
1130
+ raise RuntimeError(f"Unsupported type: {type(aclnn_api_types)}, support type is list or string.")
1131
+
1132
+ func_name, _ = self._split_func()
1133
+ file_path = os.path.join(_get_cache_path(), func_name, func_name + "_callback.cc")
1134
+
1135
+ file_path = os.path.abspath(file_path)
1136
+ dir_path = os.path.dirname(file_path)
1137
+ os.makedirs(dir_path, exist_ok=True)
1138
+
1139
+ custom_builder = CustomCodeGenerator()
1140
+ callback_func = custom_builder.generate_callback_by_types(func_name, self.reg_info, input_output_types)
1141
+
1142
+ with open(file_path, 'w') as f:
1143
+ f.write(callback_func)
1144
+
1145
+ custom_callback_func_path = _compile_aot(file_path)
1146
+ custom_callback_func = custom_callback_func_path + ":" + func_name
1147
+ self.add_prim_attr("custom_callback_func", custom_callback_func)
1148
+ self.add_prim_attr("custom_inputs_type", input_output_types[:-2])
1149
+
1150
+ def _generate_get_workspace_size_func(self):
1151
+ """generate custom GetWorkSpaceSize func"""
1152
+ if not self.is_ascend_c:
1153
+ return
1154
+ func_name, _ = self._split_func()
1155
+ file_path = os.path.join(_get_cache_path(), func_name, func_name + "_callback.cc")
1156
+
1157
+ file_path = os.path.abspath(file_path)
1158
+ dir_path = os.path.dirname(file_path)
1159
+ os.makedirs(dir_path, exist_ok=True)
1160
+
1161
+ custom_info_generator = CustomInfoGenerator(func_name)
1162
+ api_types = custom_info_generator.get_aclnn_api_types()
1163
+ custom_builder = CustomCodeGenerator()
1164
+ if api_types == []:
1165
+ api_types = custom_builder.get_api_types_by_reg_info(self.reg_info)
1166
+
1167
+ callback_func = custom_builder.generate_callback_by_types(func_name, self.reg_info, api_types)
1168
+ with open(file_path, 'w') as f:
1169
+ f.write(callback_func)
1170
+
1171
+ custom_callback_func_path = _compile_aot(file_path)
1172
+ custom_callback_func = custom_callback_func_path + ":" + func_name
1173
+ self.add_prim_attr("custom_callback_func", custom_callback_func)
1174
+ self.add_prim_attr("custom_inputs_type", api_types[:-2])
1175
+
1143
1176
  def __call__(self, *args):
1144
1177
  if self.is_ascend_c:
1145
1178
  res = pyboost_custom_ext(self.custom_pyboost, [args])
@@ -1174,6 +1207,15 @@ class CustomOpBuilder:
1174
1207
  ldflags (str, optional): Extra linker flags to be used during linking. Default: ``None``.
1175
1208
  kwargs (dict, optional): Additional keyword arguments for future extensions or specific custom requirements.
1176
1209
 
1210
+ - build_dir (str, optional): The directory used to generate the operator build files.
1211
+ If this argument is set, the provided path will be used directly.
1212
+ If not set, a subdirectory named after the operator's name will be created under the path specified by
1213
+ the environment variable `MS_COMPILER_CACHE_PATH` (defaulting to "./kernel_meta"), and the files will
1214
+ be placed in this subdirectory. Default: ``None``.
1215
+
1216
+ - enable_atb (bool, optional): Whether to call ATB (Ascend Transformer Boost) operator. If set to ``True``,
1217
+ the `backend` must be ``Ascend`` or left empty. Default: ``False``.
1218
+
1177
1219
  .. note::
1178
1220
  - If the `backend` argument is provided, additional default flags will be automatically added to
1179
1221
  the compilation and linking steps to support the operator's target backend. The default options
@@ -1193,9 +1235,7 @@ class CustomOpBuilder:
1193
1235
  ... )
1194
1236
  >>> my_ops = builder.load()
1195
1237
  """
1196
- _mindspore_path = None
1197
1238
  _loaded_ops = {}
1198
- _ms_code_base = None
1199
1239
 
1200
1240
  def __init__(self, name, sources, backend=None, include_paths=None, cflags=None, ldflags=None, **kwargs):
1201
1241
  self.name = name
@@ -1205,11 +1245,23 @@ class CustomOpBuilder:
1205
1245
  self.cflags = cflags
1206
1246
  self.ldflags = ldflags
1207
1247
  self.build_dir = kwargs.get("build_dir")
1208
- if CustomOpBuilder._mindspore_path is None:
1209
- CustomOpBuilder._mindspore_path = os.path.dirname(os.path.abspath(ms.__file__))
1210
- CustomOpBuilder._ms_code_base = os.path.join(CustomOpBuilder._mindspore_path, "include")
1248
+ self.enable_atb = kwargs.get("enable_atb", False)
1249
+ self._ms_path = os.path.dirname(os.path.abspath(ms.__file__))
1250
+ if self.enable_atb:
1251
+ if backend is not None and backend != "Ascend":
1252
+ raise ValueError("For 'CustomOpBuilder', when 'enable_atb' is set to True, the 'backend' must be "
1253
+ f"'Ascend' (or left implicit), but got '{backend}'")
1254
+ self.backend = "Ascend"
1211
1255
  if self.backend == "Ascend":
1212
- self.ascend_cann_path = os.getenv("ASCEND_OPP_PATH").split('opp')[0]
1256
+ ascend_opp_path = os.getenv("ASCEND_OPP_PATH")
1257
+ if not ascend_opp_path:
1258
+ raise ValueError("Environment variable 'ASCEND_OPP_PATH' must be set for Ascend backend.")
1259
+ self.ascend_cann_path = ascend_opp_path.split('opp')[0]
1260
+
1261
+ if self.enable_atb:
1262
+ self.atb_home_path = os.getenv("ATB_HOME_PATH")
1263
+ if not self.atb_home_path:
1264
+ raise ValueError("Environment variable 'ATB_HOME_PATH' must be set when 'enable_atb' is True.")
1213
1265
 
1214
1266
  def get_sources(self):
1215
1267
  """
@@ -1228,29 +1280,31 @@ class CustomOpBuilder:
1228
1280
  list[str], A list of include paths.
1229
1281
  """
1230
1282
  include_list = self.include_paths if self.include_paths is not None else []
1231
- include_list.append(CustomOpBuilder._mindspore_path)
1232
- include_list.append(os.path.join(CustomOpBuilder._mindspore_path, "include"))
1233
- include_list.append(os.path.join(CustomOpBuilder._mindspore_path, "include/third_party"))
1234
- include_list.append(os.path.join(CustomOpBuilder._mindspore_path, "include/third_party/robin_hood_hashing"))
1235
- include_list.append(os.path.join(CustomOpBuilder._mindspore_path, "include/third_party/securec/include"))
1283
+ include_list.append(self._ms_path)
1284
+ include_list.append(os.path.join(self._ms_path, "include"))
1285
+ include_list.append(os.path.join(self._ms_path, "include", "third_party"))
1286
+ include_list.append(os.path.join(self._ms_path, "include", "third_party", "robin_hood_hashing"))
1287
+ include_list.append(os.path.join(self._ms_path, "include", "third_party", "securec", "include"))
1236
1288
 
1237
1289
  if self.backend == "Ascend":
1238
1290
  include_list.append(os.path.join(self.ascend_cann_path, "include"))
1291
+ if self.enable_atb:
1292
+ include_list.append(os.path.join(self.atb_home_path, "include"))
1239
1293
  include_list += self._get_ms_inner_includes()
1240
1294
  return include_list
1241
1295
 
1242
1296
  def _get_ms_inner_includes(self):
1243
1297
  """include paths for inner module interface."""
1244
- ms_inner_code_base = os.path.join(CustomOpBuilder._mindspore_path, "include", "mindspore")
1298
+ ms_inner_path = os.path.join(self._ms_path, "include", "mindspore")
1245
1299
  include_list = []
1246
- include_list.append(ms_inner_code_base + "/core/include")
1247
- include_list.append(ms_inner_code_base + "/core/mindrt/include")
1248
- include_list.append(ms_inner_code_base + "/core/mindrt")
1249
- include_list.append(ms_inner_code_base + "/ops")
1250
- include_list.append(ms_inner_code_base + "/ops/kernel/include")
1251
- include_list.append(ms_inner_code_base + "/ccsrc")
1252
- include_list.append(ms_inner_code_base + "/ccsrc/include")
1253
- include_list.append(ms_inner_code_base + "/ccsrc/minddata/mindrecord/include")
1300
+ include_list.append(os.path.join(ms_inner_path, "core", "include"))
1301
+ include_list.append(os.path.join(ms_inner_path, "core", "mindrt", "include"))
1302
+ include_list.append(os.path.join(ms_inner_path, "core", "mindrt"))
1303
+ include_list.append(os.path.join(ms_inner_path, "ops"))
1304
+ include_list.append(os.path.join(ms_inner_path, "ops", "kernel", "include"))
1305
+ include_list.append(os.path.join(ms_inner_path, "ccsrc"))
1306
+ include_list.append(os.path.join(ms_inner_path, "ccsrc", "include"))
1307
+ include_list.append(os.path.join(ms_inner_path, "ccsrc", "minddata", "mindrecord", "include"))
1254
1308
  return include_list
1255
1309
 
1256
1310
  def get_cflags(self):
@@ -1260,10 +1314,12 @@ class CustomOpBuilder:
1260
1314
  Returns:
1261
1315
  list[str], A list of C++ compiler flags.
1262
1316
  """
1263
- flags = ['-fstack-protector-all', '-fPIC', '-pie']
1264
- flags += ['-DENABLE_FAST_HASH_TABLE=1']
1317
+ flags = [f'-DMS_EXTENSION_NAME={self.name}', '-D_GLIBCXX_USE_CXX11_ABI=0', '-DENABLE_FAST_HASH_TABLE=1']
1318
+ flags += ['-std=c++17', '-fstack-protector-all', '-fPIC', '-pie']
1265
1319
  if self.backend == "Ascend":
1266
1320
  flags.append('-DCUSTOM_ASCEND_OP')
1321
+ if self.enable_atb:
1322
+ flags.append('-DCUSTOM_ENABLE_ATB')
1267
1323
  if self.cflags is not None:
1268
1324
  flags.append(self.cflags)
1269
1325
  return flags
@@ -1275,18 +1331,25 @@ class CustomOpBuilder:
1275
1331
  Returns:
1276
1332
  list[str], A list of linker flags.
1277
1333
  """
1278
- flags = ['-Wl,-z,relro,-z,now,-z,noexecstack', '-Wl,--disable-new-dtags,--rpath', '-s']
1334
+ flags = ['-shared']
1335
+ flags += ['-Wl,-z,relro,-z,now,-z,noexecstack', '-Wl,--disable-new-dtags,--rpath', '-s']
1279
1336
  flags += [
1280
- '-L' + os.path.abspath(os.path.join(CustomOpBuilder._mindspore_path, 'lib')),
1337
+ f"-L{os.path.abspath(os.path.join(self._ms_path, 'lib'))}",
1281
1338
  '-lmindspore_core',
1282
1339
  '-lmindspore_ms_backend',
1283
- '-lmindspore_pynative'
1340
+ '-lmindspore_pynative',
1341
+ '-lmindspore_extension'
1284
1342
  ]
1285
1343
  if self.backend == "Ascend":
1286
- flags.append('-L' + os.path.abspath(os.path.join(CustomOpBuilder._mindspore_path, 'lib/plugin')))
1287
- flags.append('-L' + os.path.abspath(os.path.join(self.ascend_cann_path, "lib64")))
1344
+ flags.append(f"-L{os.path.abspath(os.path.join(self._ms_path, 'lib', 'plugin'))}")
1345
+ flags.append(f"-L{os.path.abspath(os.path.join(self.ascend_cann_path, 'lib64'))}")
1288
1346
  flags.append('-lascendcl')
1289
1347
  flags.append('-l:libmindspore_ascend.so.2')
1348
+ if self.enable_atb:
1349
+ flags.append(f"-L{os.path.abspath(os.path.join(self._ms_path, 'lib', 'plugin', 'ascend'))}")
1350
+ flags.append('-lmindspore_extension_ascend_atb')
1351
+ flags.append(f"-L{os.path.abspath(os.path.join(self.atb_home_path, 'lib'))}")
1352
+ flags.append('-latb')
1290
1353
  if self.ldflags is not None:
1291
1354
  flags.append(self.ldflags)
1292
1355
  return flags