mindspore 2.3.0rc1__cp38-none-any.whl → 2.3.0rc2__cp38-none-any.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 (318) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/__init__.py +1 -1
  3. mindspore/_akg/akg/utils/tbe_codegen_utils.py +13 -3
  4. mindspore/_c_dataengine.cpython-38-aarch64-linux-gnu.so +0 -0
  5. mindspore/_c_expression.cpython-38-aarch64-linux-gnu.so +0 -0
  6. mindspore/_checkparam.py +20 -0
  7. mindspore/_extends/parse/parser.py +1 -1
  8. mindspore/_extends/parse/standard_method.py +6 -5
  9. mindspore/_mindspore_offline_debug.cpython-38-aarch64-linux-gnu.so +0 -0
  10. mindspore/amp.py +5 -5
  11. mindspore/bin/cache_admin +0 -0
  12. mindspore/bin/cache_server +0 -0
  13. mindspore/boost/boost_cell_wrapper.py +1 -1
  14. mindspore/boost/group_loss_scale_manager.py +1 -1
  15. mindspore/common/__init__.py +4 -2
  16. mindspore/common/_register_for_recompute.py +48 -0
  17. mindspore/common/_stub_tensor.py +1 -0
  18. mindspore/common/api.py +56 -4
  19. mindspore/common/dtype.py +5 -3
  20. mindspore/common/dump.py +2 -2
  21. mindspore/common/hook_handle.py +51 -4
  22. mindspore/common/initializer.py +1 -1
  23. mindspore/common/jit_config.py +17 -6
  24. mindspore/common/parameter.py +7 -2
  25. mindspore/common/recompute.py +247 -0
  26. mindspore/common/sparse_tensor.py +2 -2
  27. mindspore/common/symbol.py +1 -1
  28. mindspore/common/tensor.py +74 -36
  29. mindspore/communication/__init__.py +3 -3
  30. mindspore/communication/management.py +30 -30
  31. mindspore/context.py +28 -15
  32. mindspore/dataset/__init__.py +5 -5
  33. mindspore/dataset/audio/__init__.py +2 -2
  34. mindspore/dataset/audio/transforms.py +51 -51
  35. mindspore/dataset/callback/ds_callback.py +2 -2
  36. mindspore/dataset/engine/cache_client.py +1 -1
  37. mindspore/dataset/engine/datasets.py +3 -3
  38. mindspore/dataset/engine/datasets_audio.py +14 -14
  39. mindspore/dataset/engine/datasets_standard_format.py +3 -3
  40. mindspore/dataset/engine/datasets_text.py +38 -38
  41. mindspore/dataset/engine/datasets_user_defined.py +3 -3
  42. mindspore/dataset/engine/datasets_vision.py +68 -68
  43. mindspore/dataset/text/__init__.py +3 -3
  44. mindspore/dataset/text/transforms.py +26 -26
  45. mindspore/dataset/transforms/__init__.py +1 -1
  46. mindspore/dataset/vision/__init__.py +3 -3
  47. mindspore/dataset/vision/transforms.py +92 -92
  48. mindspore/dataset/vision/utils.py +1 -1
  49. mindspore/experimental/optim/adadelta.py +2 -2
  50. mindspore/experimental/optim/adagrad.py +2 -2
  51. mindspore/experimental/optim/adam.py +2 -2
  52. mindspore/experimental/optim/adamax.py +2 -2
  53. mindspore/experimental/optim/adamw.py +2 -2
  54. mindspore/experimental/optim/asgd.py +2 -2
  55. mindspore/experimental/optim/lr_scheduler.py +24 -20
  56. mindspore/experimental/optim/nadam.py +2 -2
  57. mindspore/experimental/optim/optimizer.py +1 -1
  58. mindspore/experimental/optim/radam.py +2 -2
  59. mindspore/experimental/optim/rmsprop.py +2 -2
  60. mindspore/experimental/optim/rprop.py +2 -2
  61. mindspore/experimental/optim/sgd.py +2 -2
  62. mindspore/hal/stream.py +2 -0
  63. mindspore/include/mindapi/base/types.h +5 -0
  64. mindspore/lib/libdnnl.so.2 +0 -0
  65. mindspore/lib/libmindspore.so +0 -0
  66. mindspore/lib/libmindspore_backend.so +0 -0
  67. mindspore/lib/libmindspore_common.so +0 -0
  68. mindspore/lib/libmindspore_core.so +0 -0
  69. mindspore/lib/libmindspore_glog.so.0 +0 -0
  70. mindspore/lib/libmindspore_gpr.so.15 +0 -0
  71. mindspore/lib/libmindspore_grpc.so.15 +0 -0
  72. mindspore/lib/libmindspore_shared_lib.so +0 -0
  73. mindspore/lib/libopencv_core.so.4.5 +0 -0
  74. mindspore/lib/libopencv_imgcodecs.so.4.5 +0 -0
  75. mindspore/lib/libopencv_imgproc.so.4.5 +0 -0
  76. mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/aicpu_kernel/impl/libcust_cpu_kernels.so +0 -0
  77. mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/config/cust_aicpu_kernel.json +6 -6
  78. mindspore/lib/plugin/ascend/custom_aicpu_ops/op_proto/libcust_op_proto.so +0 -0
  79. mindspore/lib/plugin/ascend/libdvpp_utils.so +0 -0
  80. mindspore/lib/plugin/ascend/liblowlatency_collective.so +0 -0
  81. mindspore/lib/plugin/ascend/libmindspore_cpu_kernels.so +0 -0
  82. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/bin/DeviceBin +0 -0
  83. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/bin/PkgInspect +0 -0
  84. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/bin/op_man +0 -0
  85. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/device/ascend910b/bin/ascend910b.bin +101787 -98559
  86. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/host/libasdops_cann_host.so +0 -0
  87. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/host/libasdops_host.so +0 -0
  88. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/include/asdops/base/op_register.h +2 -2
  89. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/include/asdops/params/mix.h +8 -1
  90. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/include/asdops/params/norm.h +5 -3
  91. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/include/asdops/params/reduce.h +2 -2
  92. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/include/asdops/utils/rt/backend/backend.h +3 -3
  93. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/include/asdops/utils/rt/backend/rtbackend.h +3 -3
  94. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/include/asdops/utils/rt/base/types.h +0 -1
  95. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/include/asdops/utils/rt/module/module.h +3 -3
  96. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/include/asdops/utils/svector/svector.h +3 -2
  97. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/lib/libasdops.so +0 -0
  98. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/lib/libasdops_static.a +0 -0
  99. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/add/tiling/add_tiling.h +9 -9
  100. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/apply_rotary_pos_emb_impl.h +2 -6
  101. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/kernel/apply_rotary_pos_emb.h +2 -2
  102. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/kernel/apply_rotary_pos_emb_base.h +460 -0
  103. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/kernel/apply_rotary_pos_emb_bf16.h +217 -0
  104. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/kernel/apply_rotary_pos_emb_fp16.h +116 -0
  105. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/kernel/apply_rotary_pos_emb_tiling.h +16 -24
  106. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/kernel/apply_rotary_pos_emb_value.h +27 -0
  107. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/asdop/asd_op_impl.h +0 -4
  108. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/{attention/FlashAttentionScore_impl.h → flash_attention_score/flash_attention_score_impl.h} +2 -1
  109. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/{attention/bs_attention_tiling.h → flash_attention_score/flash_attention_score_tiling.h} +15 -19
  110. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/gelu/tiling/gelu_tiling.h +7 -9
  111. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/lccl/lccl_wrapper.h +58 -0
  112. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/matmul/matmul_impl.h +19 -8
  113. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/{matmul → matmul_common}/pp_matmul_common_tiling.h +18 -8
  114. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/{matmul → matmul_common}/pp_matmul_info.h +7 -4
  115. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/{matmul → matmul_common}/tiling_data.h +44 -6
  116. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/matmul_common/tiling_utils.h +65 -0
  117. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/matmul_stridedslice/matmul_stridedslice_fusion_impl.h +10 -6
  118. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/op_param.h +4 -1
  119. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/paged_attention/kernel/paged_attention_mix_hwsync.h +41 -0
  120. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/{attention/PagedAttention_impl.h → paged_attention/paged_attention_impl.h} +1 -1
  121. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/paged_attention/paged_attention_tiling.h +63 -0
  122. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/add_param.h +2 -2
  123. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/{attention_param.h → param/attention_param.h} +11 -2
  124. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/matmul_ext_param.h +37 -0
  125. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/sub_param.h +45 -0
  126. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/reshape_and_cache/reshape_and_cache_tiling.h +1 -2
  127. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/rms_norm/kernel/rms_norm.h +23 -0
  128. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/rms_norm/kernel/rms_norm_base.h +175 -0
  129. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/rms_norm/kernel/rms_norm_normal.h +276 -0
  130. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/rms_norm/kernel/rms_norm_split_d.h +280 -0
  131. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/rms_norm/kernel/tiling_data.h +35 -0
  132. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/rms_norm/rms_norm_impl.h +45 -0
  133. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/sub/kernel/sub_kernel.h +20 -0
  134. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/sub/sub_impl.h +47 -0
  135. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/sub/sub_tiling.h +25 -0
  136. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/tune_repo/matmul_table.h +323 -23
  137. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/types.h +15 -4
  138. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/log/log_tiling.h +8 -0
  139. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libAdd_impl.so +0 -0
  140. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libSub_impl.so +0 -0
  141. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libadd_layernorm_impl.so +0 -0
  142. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libadd_rms_norm_impl.so +0 -0
  143. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libapply_rotary_pos_emb_impl.so +0 -0
  144. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libcast_impl.so +0 -0
  145. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libgelu_impl.so +0 -0
  146. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libmatmul_impl.so +0 -0
  147. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libmatmul_stridedslice_fusion_impl.so +0 -0
  148. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libms_kernels_internal.so +0 -0
  149. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libnot_equal_impl.so +0 -0
  150. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libreshape_and_cache_impl.so +0 -0
  151. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/librms_norm_impl.so +0 -0
  152. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/flash_attention_score_bf16_bnsd_full_mix.o +0 -0
  153. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/flash_attention_score_bf16_bnsd_tri_mix.o +0 -0
  154. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/flash_attention_score_bf16_bsh_full_mix.o +0 -0
  155. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/flash_attention_score_bf16_bsh_tri_mix.o +0 -0
  156. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/flash_attention_score_fp16_bnsd_full_mix.o +0 -0
  157. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/flash_attention_score_fp16_bnsd_tri_mix.o +0 -0
  158. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/flash_attention_score_fp16_bsh_full_mix.o +0 -0
  159. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/flash_attention_score_fp16_bsh_tri_mix.o +0 -0
  160. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/paged_attention_bf16_bnsd_full_mix.o +0 -0
  161. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/paged_attention_bf16_bsh_full_mix.o +0 -0
  162. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/paged_attention_fp16_bnsd_full_mix.o +0 -0
  163. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/paged_attention_fp16_bsh_full_mix.o +0 -0
  164. mindspore/lib/plugin/ascend/ms_kernels_internal/lccl/include/lcal.h +22 -0
  165. mindspore/lib/plugin/ascend/ms_kernels_internal/lccl/include/lcal_comm.h +70 -0
  166. mindspore/lib/plugin/ascend/ms_kernels_internal/lccl/include/lcal_types.h +103 -0
  167. mindspore/lib/plugin/ascend/ms_kernels_internal/lccl/include/lccl.h +47 -0
  168. mindspore/lib/plugin/ascend/ms_kernels_internal/lccl/include/lccl_wrapper.h +58 -0
  169. mindspore/lib/plugin/ascend/ms_kernels_internal/lccl/include/lcoc.h +154 -0
  170. mindspore/lib/plugin/ascend/ms_kernels_internal/lccl/lib/liblcal.so +0 -0
  171. mindspore/lib/plugin/ascend/ms_kernels_internal/lccl/lib/liblccl_wrapper.so +0 -0
  172. mindspore/lib/plugin/libmindspore_ascend.so.2 +0 -0
  173. mindspore/log.py +2 -2
  174. mindspore/mint/__init__.py +457 -0
  175. mindspore/mint/nn/__init__.py +430 -0
  176. mindspore/mint/nn/functional.py +424 -0
  177. mindspore/mint/optim/__init__.py +24 -0
  178. mindspore/mint/optim/adamw.py +186 -0
  179. mindspore/multiprocessing/__init__.py +4 -0
  180. mindspore/nn/__init__.py +3 -0
  181. mindspore/nn/cell.py +51 -47
  182. mindspore/nn/extend/__init__.py +29 -0
  183. mindspore/nn/extend/basic.py +140 -0
  184. mindspore/nn/extend/embedding.py +143 -0
  185. mindspore/nn/extend/layer/__init__.py +27 -0
  186. mindspore/nn/extend/layer/normalization.py +107 -0
  187. mindspore/nn/extend/pooling.py +117 -0
  188. mindspore/nn/generator.py +297 -0
  189. mindspore/nn/layer/basic.py +109 -1
  190. mindspore/nn/layer/container.py +2 -2
  191. mindspore/nn/layer/conv.py +6 -6
  192. mindspore/nn/layer/embedding.py +1 -1
  193. mindspore/nn/layer/normalization.py +21 -43
  194. mindspore/nn/layer/padding.py +4 -0
  195. mindspore/nn/optim/ada_grad.py +2 -2
  196. mindspore/nn/optim/adadelta.py +1 -1
  197. mindspore/nn/optim/adafactor.py +1 -1
  198. mindspore/nn/optim/adam.py +7 -7
  199. mindspore/nn/optim/adamax.py +2 -2
  200. mindspore/nn/optim/adasum.py +2 -2
  201. mindspore/nn/optim/asgd.py +2 -2
  202. mindspore/nn/optim/ftrl.py +1 -1
  203. mindspore/nn/optim/lamb.py +3 -3
  204. mindspore/nn/optim/lars.py +1 -1
  205. mindspore/nn/optim/lazyadam.py +2 -2
  206. mindspore/nn/optim/momentum.py +2 -2
  207. mindspore/nn/optim/optimizer.py +2 -2
  208. mindspore/nn/optim/proximal_ada_grad.py +2 -2
  209. mindspore/nn/optim/rmsprop.py +2 -2
  210. mindspore/nn/optim/rprop.py +2 -2
  211. mindspore/nn/optim/sgd.py +2 -2
  212. mindspore/nn/optim/thor.py +2 -2
  213. mindspore/nn/wrap/cell_wrapper.py +9 -9
  214. mindspore/nn/wrap/grad_reducer.py +5 -5
  215. mindspore/ops/_grad_experimental/grad_comm_ops.py +4 -2
  216. mindspore/ops/_vmap/vmap_grad_nn_ops.py +41 -2
  217. mindspore/ops/_vmap/vmap_math_ops.py +27 -8
  218. mindspore/ops/_vmap/vmap_nn_ops.py +66 -8
  219. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +73 -1
  220. mindspore/ops/auto_generate/gen_arg_dtype_cast.py +12 -3
  221. mindspore/ops/auto_generate/gen_arg_handler.py +24 -0
  222. mindspore/ops/auto_generate/gen_extend_func.py +274 -0
  223. mindspore/ops/auto_generate/gen_ops_def.py +889 -22
  224. mindspore/ops/auto_generate/gen_ops_prim.py +3541 -253
  225. mindspore/ops/auto_generate/pyboost_inner_prim.py +282 -0
  226. mindspore/ops/composite/multitype_ops/_compile_utils.py +2 -1
  227. mindspore/ops/composite/multitype_ops/_constexpr_utils.py +9 -0
  228. mindspore/ops/extend/__init__.py +9 -1
  229. mindspore/ops/extend/array_func.py +134 -27
  230. mindspore/ops/extend/math_func.py +3 -3
  231. mindspore/ops/extend/nn_func.py +363 -2
  232. mindspore/ops/function/__init__.py +19 -2
  233. mindspore/ops/function/array_func.py +463 -439
  234. mindspore/ops/function/clip_func.py +7 -18
  235. mindspore/ops/function/grad/grad_func.py +5 -5
  236. mindspore/ops/function/linalg_func.py +4 -4
  237. mindspore/ops/function/math_func.py +260 -243
  238. mindspore/ops/function/nn_func.py +825 -62
  239. mindspore/ops/function/random_func.py +73 -4
  240. mindspore/ops/function/sparse_unary_func.py +1 -1
  241. mindspore/ops/function/vmap_func.py +1 -1
  242. mindspore/ops/functional.py +2 -2
  243. mindspore/ops/op_info_register.py +1 -31
  244. mindspore/ops/operations/__init__.py +2 -3
  245. mindspore/ops/operations/_grad_ops.py +2 -107
  246. mindspore/ops/operations/_inner_ops.py +5 -5
  247. mindspore/ops/operations/_sequence_ops.py +2 -2
  248. mindspore/ops/operations/array_ops.py +11 -233
  249. mindspore/ops/operations/comm_ops.py +32 -32
  250. mindspore/ops/operations/custom_ops.py +7 -89
  251. mindspore/ops/operations/manually_defined/ops_def.py +329 -4
  252. mindspore/ops/operations/math_ops.py +13 -163
  253. mindspore/ops/operations/nn_ops.py +9 -316
  254. mindspore/ops/operations/random_ops.py +1 -1
  255. mindspore/ops/operations/sparse_ops.py +3 -3
  256. mindspore/ops/primitive.py +2 -2
  257. mindspore/ops_generate/arg_dtype_cast.py +12 -3
  258. mindspore/ops_generate/arg_handler.py +24 -0
  259. mindspore/ops_generate/gen_ops_inner_prim.py +2 -0
  260. mindspore/ops_generate/gen_pyboost_func.py +13 -6
  261. mindspore/ops_generate/pyboost_utils.py +2 -17
  262. mindspore/parallel/__init__.py +3 -2
  263. mindspore/parallel/_auto_parallel_context.py +106 -1
  264. mindspore/parallel/_parallel_serialization.py +34 -2
  265. mindspore/parallel/_utils.py +16 -0
  266. mindspore/parallel/algo_parameter_config.py +4 -4
  267. mindspore/parallel/checkpoint_transform.py +249 -77
  268. mindspore/parallel/cluster/process_entity/_api.py +1 -1
  269. mindspore/parallel/parameter_broadcast.py +1 -1
  270. mindspore/parallel/shard.py +1 -1
  271. mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +1 -0
  272. mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +17 -5
  273. mindspore/profiler/parser/ascend_msprof_exporter.py +3 -3
  274. mindspore/profiler/parser/ascend_msprof_generator.py +10 -3
  275. mindspore/profiler/parser/ascend_op_generator.py +26 -9
  276. mindspore/profiler/parser/ascend_timeline_generator.py +7 -4
  277. mindspore/profiler/parser/profiler_info.py +11 -1
  278. mindspore/profiler/profiling.py +13 -5
  279. mindspore/rewrite/api/node.py +12 -12
  280. mindspore/rewrite/api/symbol_tree.py +11 -11
  281. mindspore/run_check/_check_version.py +1 -1
  282. mindspore/safeguard/rewrite_obfuscation.py +2 -2
  283. mindspore/train/amp.py +4 -4
  284. mindspore/train/anf_ir_pb2.py +8 -2
  285. mindspore/train/callback/_backup_and_restore.py +2 -2
  286. mindspore/train/callback/_callback.py +4 -4
  287. mindspore/train/callback/_checkpoint.py +2 -2
  288. mindspore/train/callback/_early_stop.py +2 -2
  289. mindspore/train/callback/_landscape.py +4 -4
  290. mindspore/train/callback/_loss_monitor.py +2 -2
  291. mindspore/train/callback/_on_request_exit.py +2 -2
  292. mindspore/train/callback/_reduce_lr_on_plateau.py +2 -2
  293. mindspore/train/callback/_summary_collector.py +2 -2
  294. mindspore/train/callback/_time_monitor.py +2 -2
  295. mindspore/train/dataset_helper.py +8 -3
  296. mindspore/train/loss_scale_manager.py +2 -2
  297. mindspore/train/metrics/metric.py +3 -3
  298. mindspore/train/mind_ir_pb2.py +22 -17
  299. mindspore/train/model.py +15 -15
  300. mindspore/train/serialization.py +18 -18
  301. mindspore/train/summary/summary_record.py +7 -7
  302. mindspore/train/train_thor/convert_utils.py +3 -3
  303. mindspore/version.py +1 -1
  304. {mindspore-2.3.0rc1.dist-info → mindspore-2.3.0rc2.dist-info}/METADATA +1 -1
  305. {mindspore-2.3.0rc1.dist-info → mindspore-2.3.0rc2.dist-info}/RECORD +309 -262
  306. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/matmul_stridedslice/tiling_data.h +0 -59
  307. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/FlashAttentionScore_bf16_BNSD_mix.o +0 -0
  308. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/FlashAttentionScore_bf16_BSH_mix.o +0 -0
  309. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/FlashAttentionScore_fp16_BNSD_mix.o +0 -0
  310. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/FlashAttentionScore_fp16_BSH_mix.o +0 -0
  311. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/PagedAttention_bf16_BNSD_mix.o +0 -0
  312. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/PagedAttention_bf16_BSH_mix.o +0 -0
  313. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/PagedAttention_fp16_BNSD_mix.o +0 -0
  314. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/BSAttention/PagedAttention_fp16_BSH_mix.o +0 -0
  315. /mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/{attention/bs_attention_mix_hwsync.h → flash_attention_score/kernel/flash_attention_score_mix_hwsync.h} +0 -0
  316. {mindspore-2.3.0rc1.dist-info → mindspore-2.3.0rc2.dist-info}/WHEEL +0 -0
  317. {mindspore-2.3.0rc1.dist-info → mindspore-2.3.0rc2.dist-info}/entry_points.txt +0 -0
  318. {mindspore-2.3.0rc1.dist-info → mindspore-2.3.0rc2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,276 @@
1
+ /**
2
+ * Copyright 2024 Huawei Technologies Co., Ltd
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /*!
18
+ * \file rms_norm.h
19
+ * \brief
20
+ */
21
+ #ifndef _RMS_NORM_NORMAL_H_
22
+ #define _RMS_NORM_NORMAL_H_
23
+ #include "rms_norm_base.h"
24
+
25
+ using namespace AscendC;
26
+
27
+ template <typename T>
28
+ class KernelRmsNorm {
29
+ public:
30
+ __aicore__ inline KernelRmsNorm() {}
31
+ __aicore__ inline void Init(GM_ADDR x, GM_ADDR gamma, GM_ADDR y, GM_ADDR rstd, uint32_t num_row_, uint32_t num_col_,
32
+ uint32_t block_factor_, uint32_t row_factor_, uint32_t ub_factor_, float epsilon_,
33
+ float avg_factor_) {
34
+ ASSERT(GetBlockNum() != 0 && "block dim can not be zero!");
35
+ this->num_row = num_row_;
36
+ this->num_col = num_col_;
37
+ this->block_factor = block_factor_;
38
+ this->row_factor = row_factor_;
39
+ this->ub_factor = ub_factor_;
40
+ this->epsilon = epsilon_;
41
+ this->avg_factor = (float)1.0 / num_col;
42
+
43
+ if (GetBlockIdx() < GetBlockNum() - 1) {
44
+ this->row_work = block_factor;
45
+ } else if (GetBlockIdx() == GetBlockNum() - 1) {
46
+ this->row_work = num_row - (GetBlockNum() - 1) * block_factor;
47
+ } else {
48
+ }
49
+ // get start index for current core, core parallel
50
+ xGm.SetGlobalBuffer((__gm__ T *)x + GetBlockIdx() * block_factor * num_col, row_work * num_col);
51
+ gammaGm.SetGlobalBuffer((__gm__ T *)gamma, num_col);
52
+ yGm.SetGlobalBuffer((__gm__ T *)y + GetBlockIdx() * block_factor * num_col, row_work * num_col);
53
+ rstdGm.SetGlobalBuffer((__gm__ float *)rstd + GetBlockIdx() * block_factor, block_factor);
54
+
55
+ // pipe alloc memory to queue, the unit is Bytes
56
+ pipe.InitBuffer(inQueueX, BUFFER_NUM, ub_factor * sizeof(T));
57
+ pipe.InitBuffer(inQueueGamma, BUFFER_NUM, ub_factor * sizeof(T));
58
+ pipe.InitBuffer(outQueueY, BUFFER_NUM, ub_factor * sizeof(T));
59
+ pipe.InitBuffer(outQueueRstd, BUFFER_NUM, row_factor * sizeof(float));
60
+
61
+ if constexpr (is_same<T, half>::value || is_same<T, bfloat16_t>::value) {
62
+ pipe.InitBuffer(x_fp32_buf, ub_factor * sizeof(float));
63
+ }
64
+ pipe.InitBuffer(sqx_buf, ub_factor * sizeof(float));
65
+ pipe.InitBuffer(reduce_fp32_buf, NUM_PER_REP_FP32 * sizeof(float));
66
+ }
67
+
68
+ __aicore__ inline void Process() {
69
+ CopyInGamma();
70
+ LocalTensor<T> gammaLocal = inQueueGamma.DeQue<T>();
71
+
72
+ uint32_t i_o_max = CeilDiv(row_work, row_factor);
73
+ uint32_t row_tail = row_work - (i_o_max - 1) * row_factor;
74
+
75
+ for (uint32_t i_o = 0; i_o < i_o_max - 1; i_o++) {
76
+ SubProcess(i_o, row_factor, gammaLocal);
77
+ }
78
+ SubProcess(i_o_max - 1, row_tail, gammaLocal);
79
+ inQueueGamma.FreeTensor(gammaLocal);
80
+ }
81
+
82
+ __aicore__ inline void SubProcess(uint32_t i_o, uint32_t calc_row_num, LocalTensor<T> &gammaLocal) {
83
+ LocalTensor<float> rstdLocal = outQueueRstd.AllocTensor<float>();
84
+ for (uint32_t i_i = 0; i_i < calc_row_num; i_i++) {
85
+ uint32_t gm_bias = (i_o * row_factor + i_i) * num_col;
86
+ CopyIn(gm_bias);
87
+ Compute(i_i, gammaLocal, rstdLocal);
88
+ CopyOutY(gm_bias);
89
+ }
90
+ outQueueRstd.EnQue<float>(rstdLocal);
91
+ CopyOutRstd(i_o, calc_row_num);
92
+ }
93
+
94
+ private:
95
+ __aicore__ inline void CopyIn(uint32_t gm_bias) {
96
+ LocalTensor<T> xLocal = inQueueX.AllocTensor<T>();
97
+ DataCopyCustom<T>(xLocal, xGm[gm_bias], num_col);
98
+ inQueueX.EnQue(xLocal);
99
+ }
100
+
101
+ __aicore__ inline void CopyInGamma() {
102
+ LocalTensor<T> gammaLocal = inQueueGamma.AllocTensor<T>();
103
+ DataCopyCustom<T>(gammaLocal, gammaGm, num_col);
104
+ inQueueGamma.EnQue(gammaLocal);
105
+ }
106
+
107
+ __aicore__ inline void Compute(uint32_t inner_progress, LocalTensor<half> gammaLocal, LocalTensor<float> rstdLocal) {
108
+ LocalTensor<half> xLocal = inQueueX.DeQue<half>();
109
+ LocalTensor<float> x_fp32 = x_fp32_buf.Get<float>();
110
+ LocalTensor<float> sqx = sqx_buf.Get<float>();
111
+ LocalTensor<float> reduce_buf_local = reduce_fp32_buf.Get<float>();
112
+
113
+ Cast(x_fp32, xLocal, RoundMode::CAST_NONE, num_col);
114
+ inQueueX.FreeTensor(xLocal);
115
+ pipe_barrier(PIPE_V);
116
+
117
+ Mul(sqx, x_fp32, x_fp32, num_col);
118
+ pipe_barrier(PIPE_V);
119
+
120
+ Muls(sqx, sqx, avg_factor, num_col);
121
+ pipe_barrier(PIPE_V);
122
+
123
+ ReduceSumCustom(sqx, sqx, reduce_buf_local, num_col);
124
+ pipe_barrier(PIPE_V);
125
+
126
+ Adds(sqx, sqx, epsilon, 1);
127
+ pipe_barrier(PIPE_V);
128
+
129
+ Sqrt(sqx, sqx, 1);
130
+ Duplicate(reduce_buf_local, ONE, 1);
131
+ pipe_barrier(PIPE_V);
132
+ Div(sqx, reduce_buf_local, sqx, 1);
133
+ pipe_barrier(PIPE_V);
134
+ set_flag(PIPE_V, PIPE_S, EVENT_ID0);
135
+ wait_flag(PIPE_V, PIPE_S, EVENT_ID0);
136
+ float rstd_value = sqx.GetValue(0);
137
+ set_flag(PIPE_S, PIPE_V, EVENT_ID0);
138
+ wait_flag(PIPE_S, PIPE_V, EVENT_ID0);
139
+ rstdLocal.SetValue(inner_progress, rstd_value);
140
+ pipe_barrier(PIPE_V);
141
+ Muls(x_fp32, x_fp32, rstd_value, num_col);
142
+ pipe_barrier(PIPE_V);
143
+ LocalTensor<half> yLocal = outQueueY.AllocTensor<half>();
144
+ Cast(yLocal, x_fp32, RoundMode::CAST_NONE, num_col);
145
+ pipe_barrier(PIPE_V);
146
+ Mul(yLocal, gammaLocal, yLocal, num_col);
147
+ pipe_barrier(PIPE_V);
148
+ outQueueY.EnQue<half>(yLocal);
149
+ }
150
+
151
+ __aicore__ inline void Compute(uint32_t inner_progress, LocalTensor<float> gammaLocal, LocalTensor<float> rstdLocal) {
152
+ LocalTensor<float> xLocal = inQueueX.DeQue<float>();
153
+ LocalTensor<float> sqx = sqx_buf.Get<float>();
154
+ LocalTensor<float> reduce_buf_local = reduce_fp32_buf.Get<float>();
155
+ Mul(sqx, xLocal, xLocal, num_col);
156
+ pipe_barrier(PIPE_V);
157
+
158
+ Muls(sqx, sqx, avg_factor, num_col);
159
+ pipe_barrier(PIPE_V);
160
+
161
+ ReduceSumCustom(sqx, sqx, reduce_buf_local, num_col);
162
+ pipe_barrier(PIPE_V);
163
+ Adds(sqx, sqx, epsilon, 1);
164
+ pipe_barrier(PIPE_V);
165
+
166
+ Sqrt(sqx, sqx, 1);
167
+ Duplicate(reduce_buf_local, ONE, 1);
168
+ pipe_barrier(PIPE_V);
169
+ Div(sqx, reduce_buf_local, sqx, 1);
170
+ pipe_barrier(PIPE_V);
171
+ set_flag(PIPE_V, PIPE_S, EVENT_ID0);
172
+ wait_flag(PIPE_V, PIPE_S, EVENT_ID0);
173
+ float rstd_value = sqx.GetValue(0);
174
+ set_flag(PIPE_S, PIPE_V, EVENT_ID0);
175
+ wait_flag(PIPE_S, PIPE_V, EVENT_ID0);
176
+ rstdLocal.SetValue(inner_progress, rstd_value);
177
+ pipe_barrier(PIPE_V);
178
+ LocalTensor<float> yLocal = outQueueY.AllocTensor<float>();
179
+ Muls(yLocal, xLocal, rstd_value, num_col);
180
+ inQueueX.FreeTensor(xLocal);
181
+ pipe_barrier(PIPE_V);
182
+ Mul(yLocal, gammaLocal, yLocal, num_col);
183
+ pipe_barrier(PIPE_V);
184
+ outQueueY.EnQue<float>(yLocal);
185
+ }
186
+
187
+ __aicore__ inline void Compute(uint32_t inner_progress, LocalTensor<bfloat16_t> gammaLocal,
188
+ LocalTensor<float> rstdLocal) {
189
+ LocalTensor<bfloat16_t> xLocal = inQueueX.DeQue<bfloat16_t>();
190
+ LocalTensor<float> x_fp32 = x_fp32_buf.Get<float>();
191
+ LocalTensor<float> sqx = sqx_buf.Get<float>();
192
+ LocalTensor<float> reduce_buf_local = reduce_fp32_buf.Get<float>();
193
+
194
+ Cast(x_fp32, xLocal, RoundMode::CAST_NONE, num_col);
195
+ inQueueX.FreeTensor(xLocal);
196
+ pipe_barrier(PIPE_V);
197
+
198
+ Mul(sqx, x_fp32, x_fp32, num_col);
199
+ pipe_barrier(PIPE_V);
200
+
201
+ Muls(sqx, sqx, avg_factor, num_col);
202
+ pipe_barrier(PIPE_V);
203
+ ReduceSumCustom(sqx, sqx, reduce_buf_local, num_col);
204
+ pipe_barrier(PIPE_V);
205
+
206
+ Adds(sqx, sqx, epsilon, 1);
207
+ pipe_barrier(PIPE_V);
208
+
209
+ Sqrt(sqx, sqx, 1);
210
+ Duplicate(reduce_buf_local, ONE, 1);
211
+ pipe_barrier(PIPE_V);
212
+ Div(sqx, reduce_buf_local, sqx, 1);
213
+ pipe_barrier(PIPE_V);
214
+ set_flag(PIPE_V, PIPE_S, EVENT_ID0);
215
+ wait_flag(PIPE_V, PIPE_S, EVENT_ID0);
216
+ float rstd_value = sqx.GetValue(0);
217
+ set_flag(PIPE_S, PIPE_V, EVENT_ID0);
218
+ wait_flag(PIPE_S, PIPE_V, EVENT_ID0);
219
+ rstdLocal.SetValue(inner_progress, rstd_value);
220
+ pipe_barrier(PIPE_V);
221
+ Muls(x_fp32, x_fp32, rstd_value, num_col);
222
+ pipe_barrier(PIPE_V);
223
+ LocalTensor<bfloat16_t> yLocal = outQueueY.AllocTensor<bfloat16_t>();
224
+ Cast(yLocal, x_fp32, RoundMode::CAST_RINT, num_col);
225
+ pipe_barrier(PIPE_V);
226
+ Cast(x_fp32, yLocal, RoundMode::CAST_NONE, num_col);
227
+ pipe_barrier(PIPE_V);
228
+ Cast(sqx, gammaLocal, RoundMode::CAST_NONE, num_col); // gamma_fp32 reuse sqx
229
+ pipe_barrier(PIPE_V);
230
+ Mul(x_fp32, x_fp32, sqx, num_col);
231
+ pipe_barrier(PIPE_V);
232
+ Cast(yLocal, x_fp32, RoundMode::CAST_RINT, num_col);
233
+ pipe_barrier(PIPE_V);
234
+ outQueueY.EnQue<bfloat16_t>(yLocal);
235
+ }
236
+
237
+ __aicore__ inline void CopyOutY(uint32_t progress) {
238
+ LocalTensor<T> yLocal = outQueueY.DeQue<T>();
239
+ DataCopyCustom<T>(yGm[progress], yLocal, num_col);
240
+ outQueueY.FreeTensor(yLocal);
241
+ }
242
+
243
+ __aicore__ inline void CopyOutRstd(uint32_t outer_progress, uint32_t num) {
244
+ LocalTensor<float> rstdLocal = outQueueRstd.DeQue<float>();
245
+ #if __CCE_AICORE__ == 220
246
+ DataCopyCustom<float>(rstdGm[outer_progress * row_factor], rstdLocal, num);
247
+ #endif
248
+ outQueueRstd.FreeTensor(rstdLocal);
249
+ }
250
+
251
+ private:
252
+ TPipe pipe;
253
+ // create queues for input, in this case depth is equal to buffer num
254
+ TQue<QuePosition::VECIN, BUFFER_NUM> inQueueX, inQueueGamma;
255
+ // create queues for output, in this case depth is equal to buffer num
256
+ TQue<QuePosition::VECOUT, BUFFER_NUM> outQueueY, outQueueRstd;
257
+
258
+ TBuf<TPosition::VECCALC> x_fp32_buf;
259
+ TBuf<TPosition::VECCALC> sqx_buf;
260
+ TBuf<TPosition::VECCALC> reduce_fp32_buf;
261
+ GlobalTensor<T> xGm;
262
+ GlobalTensor<T> gammaGm;
263
+ GlobalTensor<T> yGm;
264
+ GlobalTensor<float> rstdGm;
265
+
266
+ uint32_t num_row;
267
+ uint32_t num_col;
268
+ uint32_t block_factor; // number of calculations rows on each core
269
+ uint32_t row_factor;
270
+ uint32_t ub_factor;
271
+ float epsilon;
272
+ float avg_factor;
273
+
274
+ uint32_t row_work = 1;
275
+ };
276
+ #endif // RMS_NORM_H_
@@ -0,0 +1,280 @@
1
+ /**
2
+ * Copyright 2024 Huawei Technologies Co., Ltd
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /*!
18
+ * \file rms_norm_split_d.h
19
+ * \brief
20
+ */
21
+ #ifndef _RMS_NORM_SPLIT_D_H_
22
+ #define _RMS_NORM_SPLIT_D_H_
23
+ #include "rms_norm_base.h"
24
+
25
+ using namespace AscendC;
26
+
27
+ template <typename T>
28
+ class KernelRmsNormSplitD {
29
+ public:
30
+ __aicore__ inline KernelRmsNormSplitD() {}
31
+ __aicore__ inline void Init(GM_ADDR x, GM_ADDR gamma, GM_ADDR y, GM_ADDR rstd, uint32_t num_row_, uint32_t num_col_,
32
+ uint32_t block_factor_, uint32_t row_factor_, uint32_t ub_factor_, float epsilon_,
33
+ float avg_factor_) {
34
+ ASSERT(GetBlockNum() != 0 && "block dim can not be zero!");
35
+ this->num_row = num_row_;
36
+ this->num_col = num_col_;
37
+ this->block_factor = block_factor_;
38
+ this->row_factor = row_factor_;
39
+ this->ub_factor = ub_factor_;
40
+ this->epsilon = epsilon_;
41
+ this->avg_factor = (float)1.0 / num_col;
42
+
43
+ if (GetBlockIdx() < GetBlockNum() - 1) {
44
+ this->row_work = block_factor;
45
+ } else if (GetBlockIdx() == GetBlockNum() - 1) {
46
+ this->row_work = num_row - (GetBlockNum() - 1) * block_factor;
47
+ } else {
48
+ }
49
+ // get start index for current core, core parallel
50
+ xGm.SetGlobalBuffer((__gm__ T *)x + GetBlockIdx() * block_factor * num_col, row_work * num_col);
51
+ gammaGm.SetGlobalBuffer((__gm__ T *)gamma, num_col);
52
+ yGm.SetGlobalBuffer((__gm__ T *)y + GetBlockIdx() * block_factor * num_col, row_work * num_col);
53
+ rstdGm.SetGlobalBuffer((__gm__ float *)rstd + GetBlockIdx() * block_factor, block_factor);
54
+
55
+ // pipe alloc memory to queue, the unit is Bytes
56
+ pipe.InitBuffer(inQueueX, BUFFER_NUM, ub_factor * sizeof(T));
57
+ pipe.InitBuffer(inQueueGamma, BUFFER_NUM, ub_factor * sizeof(T));
58
+ pipe.InitBuffer(outQueueY, BUFFER_NUM, ub_factor * sizeof(T));
59
+ pipe.InitBuffer(outQueueRstd, BUFFER_NUM, row_factor * sizeof(float));
60
+
61
+ if constexpr (is_same<T, half>::value || is_same<T, bfloat16_t>::value) {
62
+ pipe.InitBuffer(x_fp32_buf, ub_factor * sizeof(float));
63
+ }
64
+ pipe.InitBuffer(sqx_buf, ub_factor * sizeof(float));
65
+ pipe.InitBuffer(sum_buf, row_factor * NUM_PER_BLK_FP32 * sizeof(float));
66
+ pipe.InitBuffer(reduce_fp32_buf, NUM_PER_REP_FP32 * sizeof(float));
67
+ }
68
+
69
+ __aicore__ inline void Process() {
70
+ uint32_t i_o_max = CeilDiv(row_work, row_factor);
71
+ uint32_t row_tail = row_work - (i_o_max - 1) * row_factor;
72
+ uint32_t j_max = CeilDiv(num_col, ub_factor);
73
+ uint32_t col_tail = num_col - (j_max - 1) * ub_factor;
74
+ for (uint32_t i_o = 0; i_o < i_o_max - 1; i_o++) {
75
+ SubProcess(i_o, row_factor, j_max, col_tail);
76
+ }
77
+ SubProcess(i_o_max - 1, row_tail, j_max, col_tail);
78
+ }
79
+
80
+ __aicore__ inline void SubProcess(uint32_t i_o, uint32_t calc_row_num, uint32_t j_max, uint32_t col_tail) {
81
+ LocalTensor<float> sumLocal = sum_buf.Get<float>();
82
+
83
+ LocalTensor<float> rstdLocal = outQueueRstd.AllocTensor<float>();
84
+ Duplicate(rstdLocal, (float)0.0, calc_row_num);
85
+ pipe_barrier(PIPE_V);
86
+ for (uint32_t j = 0; j < j_max - 1; j++) {
87
+ ComputeFormer(i_o, calc_row_num, j, rstdLocal, sumLocal, ub_factor);
88
+ }
89
+ // do tail
90
+ ComputeFormer(i_o, calc_row_num, j_max - 1, rstdLocal, sumLocal, col_tail);
91
+ ComputeRstd(rstdLocal, calc_row_num);
92
+
93
+ for (uint32_t j = 0; j < j_max - 1; j++) {
94
+ ComputeLatter(i_o, calc_row_num, j, rstdLocal, ub_factor);
95
+ }
96
+ ComputeLatter(i_o, calc_row_num, j_max - 1, rstdLocal, col_tail);
97
+ outQueueRstd.EnQue<float>(rstdLocal);
98
+ CopyOutRstd(i_o, calc_row_num);
99
+ }
100
+
101
+ private:
102
+ __aicore__ inline void CopyIn(uint32_t i_idx, uint32_t j_idx, uint32_t num) {
103
+ LocalTensor<T> xLocal = inQueueX.AllocTensor<T>();
104
+ DataCopyCustom<T>(xLocal, xGm[i_idx * num_col + j_idx * ub_factor], num);
105
+ inQueueX.EnQue(xLocal);
106
+ }
107
+
108
+ __aicore__ inline void ComputeFormer(uint32_t i_o_idx, uint32_t calc_row_num, uint32_t j_idx,
109
+ LocalTensor<float> &rstdLocal, LocalTensor<float> &sumLocal, uint32_t num) {
110
+ for (uint32_t i_i = 0; i_i < calc_row_num; i_i++) {
111
+ CopyIn(i_o_idx * row_factor + i_i, j_idx, num);
112
+ ComputeSum(i_i, sumLocal, num);
113
+ }
114
+ BlockReduceSumFP32(sumLocal, sumLocal, calc_row_num * NUM_PER_BLK_FP32);
115
+ Add(rstdLocal, rstdLocal, sumLocal, calc_row_num);
116
+ pipe_barrier(PIPE_V);
117
+ }
118
+
119
+ __aicore__ inline void ComputeSum(uint32_t i_i_idx, LocalTensor<float> &sumLocal, uint32_t num) {
120
+ LocalTensor<T> xLocal = inQueueX.DeQue<T>();
121
+ LocalTensor<float> sqx = sqx_buf.Get<float>();
122
+ LocalTensor<float> reduce_buf_local = reduce_fp32_buf.Get<float>();
123
+ if constexpr (is_same<T, half>::value || is_same<T, bfloat16_t>::value) {
124
+ LocalTensor<float> x_fp32 = x_fp32_buf.Get<float>();
125
+ Cast(x_fp32, xLocal, RoundMode::CAST_NONE, num);
126
+ inQueueX.FreeTensor(xLocal);
127
+ pipe_barrier(PIPE_V);
128
+ Mul(sqx, x_fp32, x_fp32, num);
129
+ } else {
130
+ Mul(sqx, xLocal, xLocal, num);
131
+ inQueueX.FreeTensor(xLocal);
132
+ }
133
+ pipe_barrier(PIPE_V);
134
+ Muls(sqx, sqx, avg_factor, num);
135
+ pipe_barrier(PIPE_V);
136
+ ReduceSumFP32ToBlock(sumLocal[i_i_idx * 8], sqx, reduce_buf_local, num);
137
+ }
138
+
139
+ __aicore__ inline void ComputeRstd(LocalTensor<float> rstdLocal, uint32_t num) {
140
+ LocalTensor<float> reduce_buf_local = reduce_fp32_buf.Get<float>();
141
+ Adds(rstdLocal, rstdLocal, epsilon, num);
142
+ pipe_barrier(PIPE_V);
143
+ Sqrt(rstdLocal, rstdLocal, num);
144
+ Duplicate(reduce_buf_local, ONE, num);
145
+ pipe_barrier(PIPE_V);
146
+ Div(rstdLocal, reduce_buf_local, rstdLocal, num);
147
+ pipe_barrier(PIPE_V);
148
+ }
149
+
150
+ __aicore__ inline void ComputeLatter(uint32_t i_o_idx, uint32_t calc_row_num, uint32_t j_idx,
151
+ LocalTensor<float> &rstdLocal, uint32_t num) {
152
+ CopyInGamma(j_idx, num);
153
+ LocalTensor<T> gammaLocal = inQueueGamma.DeQue<T>();
154
+ for (uint32_t i_i = 0; i_i < calc_row_num; i_i++) {
155
+ CopyIn(i_o_idx * row_factor + i_i, j_idx, num);
156
+ ComputeY(i_i, gammaLocal, rstdLocal, num);
157
+ CopyOutY(i_o_idx * row_factor + i_i, j_idx, num);
158
+ }
159
+ inQueueGamma.FreeTensor(gammaLocal);
160
+ }
161
+
162
+ __aicore__ inline void CopyInGamma(uint32_t j_idx, uint32_t num) {
163
+ LocalTensor<T> gammaLocal = inQueueGamma.AllocTensor<T>();
164
+ DataCopyCustom<T>(gammaLocal, gammaGm[j_idx * ub_factor], num);
165
+ inQueueGamma.EnQue(gammaLocal);
166
+ }
167
+
168
+ __aicore__ inline void ComputeY(uint32_t i_i_idx, LocalTensor<half> &gammaLocal, LocalTensor<float> &rstdLocal,
169
+ uint32_t num) {
170
+ LocalTensor<half> xLocal = inQueueX.DeQue<half>();
171
+ LocalTensor<float> x_fp32 = x_fp32_buf.Get<float>();
172
+ LocalTensor<float> sqx = sqx_buf.Get<float>();
173
+ set_flag(PIPE_V, PIPE_S, EVENT_ID0);
174
+ wait_flag(PIPE_V, PIPE_S, EVENT_ID0);
175
+ float rstd_value = rstdLocal.GetValue(i_i_idx);
176
+ set_flag(PIPE_S, PIPE_V, EVENT_ID0);
177
+ wait_flag(PIPE_S, PIPE_V, EVENT_ID0);
178
+ Cast(x_fp32, xLocal, RoundMode::CAST_NONE, num);
179
+ inQueueX.FreeTensor(xLocal);
180
+ pipe_barrier(PIPE_V);
181
+ Muls(x_fp32, x_fp32, rstd_value, num);
182
+ pipe_barrier(PIPE_V);
183
+ LocalTensor<half> yLocal = outQueueY.AllocTensor<half>();
184
+ Cast(yLocal, x_fp32, RoundMode::CAST_NONE, num);
185
+ pipe_barrier(PIPE_V);
186
+ Mul(yLocal, gammaLocal, yLocal, num);
187
+ pipe_barrier(PIPE_V);
188
+ outQueueY.EnQue<half>(yLocal);
189
+ }
190
+
191
+ __aicore__ inline void ComputeY(uint32_t i_i_idx, LocalTensor<float> &gammaLocal, LocalTensor<float> &rstdLocal,
192
+ uint32_t num) {
193
+ LocalTensor<float> xLocal = inQueueX.DeQue<float>();
194
+ LocalTensor<float> sqx = sqx_buf.Get<float>();
195
+ set_flag(PIPE_V, PIPE_S, EVENT_ID0);
196
+ wait_flag(PIPE_V, PIPE_S, EVENT_ID0);
197
+ float rstd_value = rstdLocal.GetValue(i_i_idx);
198
+ set_flag(PIPE_S, PIPE_V, EVENT_ID0);
199
+ wait_flag(PIPE_S, PIPE_V, EVENT_ID0);
200
+ LocalTensor<float> yLocal = outQueueY.AllocTensor<float>();
201
+ Muls(yLocal, xLocal, rstd_value, num);
202
+ inQueueX.FreeTensor(xLocal);
203
+ pipe_barrier(PIPE_V);
204
+ Mul(yLocal, gammaLocal, yLocal, num);
205
+ pipe_barrier(PIPE_V);
206
+ outQueueY.EnQue<float>(yLocal);
207
+ }
208
+
209
+ __aicore__ inline void ComputeY(uint32_t i_i_idx, LocalTensor<bfloat16_t> &gammaLocal, LocalTensor<float> &rstdLocal,
210
+ uint32_t num) {
211
+ LocalTensor<bfloat16_t> xLocal = inQueueX.DeQue<bfloat16_t>();
212
+ LocalTensor<float> x_fp32 = x_fp32_buf.Get<float>();
213
+ LocalTensor<float> sqx = sqx_buf.Get<float>();
214
+ set_flag(PIPE_V, PIPE_S, EVENT_ID0);
215
+ wait_flag(PIPE_V, PIPE_S, EVENT_ID0);
216
+ float rstd_value = rstdLocal.GetValue(i_i_idx);
217
+ set_flag(PIPE_S, PIPE_V, EVENT_ID0);
218
+ wait_flag(PIPE_S, PIPE_V, EVENT_ID0);
219
+ Cast(x_fp32, xLocal, RoundMode::CAST_NONE, num);
220
+ inQueueX.FreeTensor(xLocal);
221
+ pipe_barrier(PIPE_V);
222
+ Muls(x_fp32, x_fp32, rstd_value, num);
223
+ pipe_barrier(PIPE_V);
224
+ LocalTensor<bfloat16_t> yLocal = outQueueY.AllocTensor<bfloat16_t>();
225
+ Cast(yLocal, x_fp32, RoundMode::CAST_RINT, num);
226
+ pipe_barrier(PIPE_V);
227
+ Cast(x_fp32, yLocal, RoundMode::CAST_NONE, num);
228
+ pipe_barrier(PIPE_V);
229
+ Cast(sqx, gammaLocal, RoundMode::CAST_NONE, num);
230
+ pipe_barrier(PIPE_V);
231
+ Mul(x_fp32, x_fp32, sqx, num);
232
+ pipe_barrier(PIPE_V);
233
+ Cast(yLocal, x_fp32, RoundMode::CAST_RINT, num);
234
+ pipe_barrier(PIPE_V);
235
+ outQueueY.EnQue<bfloat16_t>(yLocal);
236
+ }
237
+
238
+ __aicore__ inline void CopyOutY(uint32_t i_idx, uint32_t j_idx, uint32_t num) {
239
+ LocalTensor<T> yLocal = outQueueY.DeQue<T>();
240
+ DataCopyCustom<T>(yGm[i_idx * num_col + j_idx * ub_factor], yLocal, num);
241
+ outQueueY.FreeTensor(yLocal);
242
+ }
243
+
244
+ __aicore__ inline void CopyOutRstd(uint32_t i_o_idx, uint32_t num) {
245
+ LocalTensor<float> rstdLocal = outQueueRstd.DeQue<float>();
246
+ #if __CCE_AICORE__ == 220
247
+ DataCopyCustom<float>(rstdGm[i_o_idx * row_factor], rstdLocal, num);
248
+ #endif
249
+ outQueueRstd.FreeTensor(rstdLocal);
250
+ }
251
+
252
+ private:
253
+ TPipe pipe;
254
+ // create queues for input, in this case depth is equal to buffer num
255
+ TQue<QuePosition::VECIN, BUFFER_NUM> inQueueX, inQueueGamma;
256
+ // create queues for output, in this case depth is equal to buffer num
257
+ TQue<QuePosition::VECOUT, BUFFER_NUM> outQueueY, outQueueRstd;
258
+ TBuf<TPosition::VECCALC> x_fp32_buf;
259
+ TBuf<TPosition::VECCALC> sqx_buf;
260
+ TBuf<TPosition::VECCALC> sum_buf;
261
+ TBuf<TPosition::VECCALC> reduce_fp32_buf;
262
+
263
+ GlobalTensor<T> xGm;
264
+ GlobalTensor<T> gammaGm;
265
+ GlobalTensor<T> yGm;
266
+ GlobalTensor<float> rstdGm;
267
+
268
+ uint32_t num_row;
269
+ uint32_t num_col;
270
+ uint32_t block_factor; // number of calculations rows on each core
271
+ uint32_t row_factor;
272
+ uint32_t ub_factor;
273
+ float epsilon;
274
+ float avg_factor;
275
+
276
+ uint32_t row_work = 1;
277
+
278
+ int tempbuf_num;
279
+ };
280
+ #endif // _RMS_NORM_SPLIT_D_H_
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright 2024 Huawei Technologies Co., Ltd
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #ifndef MS_KERNELS_INTERNAL_KERNEL_ASCENDC_RMSNORM_TILING_DATA_H_
18
+ #define MS_KERNELS_INTERNAL_KERNEL_ASCENDC_RMSNORM_TILING_DATA_H_
19
+
20
+ #pragma pack(1)
21
+
22
+ struct RmsNormTilingData {
23
+ uint32_t num_row = 0;
24
+ uint32_t num_col = 0;
25
+ uint32_t block_factor = 0;
26
+ uint32_t row_factor = 0;
27
+ uint32_t ub_factor = 0;
28
+ float epsilon = 0;
29
+ float avg_factor = 0;
30
+ uint32_t tiling_key = 0;
31
+ };
32
+
33
+ #pragma pack()
34
+
35
+ #endif
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Copyright 2024 Huawei Technologies Co., Ltd
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ #ifndef MS_KERNELS_INTERNAL_KERNEL_RMS_NORM_H_
17
+ #define MS_KERNELS_INTERNAL_KERNEL_RMS_NORM_H_
18
+
19
+ #include "include/internal_kernel.h"
20
+ #include <vector>
21
+
22
+ namespace mindspore {
23
+ namespace internal {
24
+ class RmsNormImpl : public InternelKernelImpl {
25
+ public:
26
+ RmsNormImpl(const OpParamPtr &param) : InternelKernelImpl(param) {}
27
+ virtual ~RmsNormImpl() {}
28
+ bool Init(const ValidateInfo &info) override;
29
+ void SetWorkSpace(const std::vector<DeviceRawBuf> &workspace) override;
30
+ void SetDeviceTilingBuf(const DeviceRawBuf &tilingBuf) override;
31
+ int Launch() override;
32
+ uint64_t GetTilingBufSize() override;
33
+ int Tiling(HostRawBuf &tilingBuf) override;
34
+ std::vector<uint64_t> GetWorkSpaceSize() override;
35
+ int InferShape(const std::vector<DIMS> &input_shapes, std::vector<DIMS> &output_shapes) override;
36
+
37
+ private:
38
+ std::vector<DeviceRawBuf> inputs_device_buf_;
39
+ std::vector<DeviceRawBuf> outputs_device_buf_;
40
+ void *workspace_addr = nullptr;
41
+ DeviceRawBuf tiling_buf_;
42
+ };
43
+ } // namespace internal
44
+ } // namespace mindspore
45
+ #endif
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2024 Huawei Technologies Co., Ltd
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #ifndef MS_KERNELS_INTERNAL_KERNEL_ASCENDC_SUB_KERNEL_H_
18
+ #define MS_KERNELS_INTERNAL_KERNEL_ASCENDC_SUB_KERNEL_H_
19
+ void sub_op(uint32_t blockDim, void *l2ctrl, void *stream, uint8_t *in1, uint8_t *in2, uint8_t *out, uint8_t *tiling);
20
+ #endif // MS_KERNELS_INTERNAL_KERNEL_ASCENDC_SUB_KERNEL_H_