mindspore 2.4.10__cp39-none-any.whl → 2.5.0__cp39-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 (689) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/Third_Party_Open_Source_Software_Notice +39 -0
  3. mindspore/__init__.py +8 -3
  4. mindspore/_akg/akg/composite/build_module.py +6 -2
  5. mindspore/_akg/akg/utils/kernel_exec.py +2 -2
  6. mindspore/_c_dataengine.cpython-39-aarch64-linux-gnu.so +0 -0
  7. mindspore/_c_expression.cpython-39-aarch64-linux-gnu.so +0 -0
  8. mindspore/_c_mindrecord.cpython-39-aarch64-linux-gnu.so +0 -0
  9. mindspore/_checkparam.py +0 -5
  10. mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
  11. mindspore/_extends/parse/compile_config.py +64 -0
  12. mindspore/_extends/parse/deprecated/__init__.py +0 -0
  13. mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +375 -0
  14. mindspore/_extends/parse/parser.py +23 -5
  15. mindspore/_extends/parse/standard_method.py +123 -27
  16. mindspore/_extends/pijit/pijit_func_white_list.py +1 -1
  17. mindspore/amp.py +7 -1
  18. mindspore/boost/boost_cell_wrapper.py +136 -41
  19. mindspore/common/__init__.py +3 -1
  20. mindspore/common/_register_for_tensor.py +0 -1
  21. mindspore/common/_stub_tensor.py +25 -4
  22. mindspore/common/_tensor_cpp_method.py +17 -0
  23. mindspore/common/_tensor_docs.py +6132 -0
  24. mindspore/common/api.py +98 -21
  25. mindspore/common/dtype.py +34 -34
  26. mindspore/common/dump.py +2 -1
  27. mindspore/common/file_system.py +8 -3
  28. mindspore/common/generator.py +2 -0
  29. mindspore/common/hook_handle.py +3 -1
  30. mindspore/common/initializer.py +3 -4
  31. mindspore/common/lazy_inline.py +8 -2
  32. mindspore/common/mindir_util.py +10 -2
  33. mindspore/common/parameter.py +31 -15
  34. mindspore/common/tensor.py +713 -1337
  35. mindspore/communication/__init__.py +1 -1
  36. mindspore/communication/_comm_helper.py +5 -0
  37. mindspore/communication/comm_func.py +215 -173
  38. mindspore/communication/management.py +23 -20
  39. mindspore/context.py +285 -191
  40. mindspore/dataset/__init__.py +23 -19
  41. mindspore/dataset/callback/ds_callback.py +2 -1
  42. mindspore/dataset/core/config.py +84 -3
  43. mindspore/dataset/engine/cache_admin.py +3 -3
  44. mindspore/dataset/engine/cache_client.py +5 -4
  45. mindspore/dataset/engine/datasets.py +192 -149
  46. mindspore/dataset/engine/datasets_audio.py +14 -0
  47. mindspore/dataset/engine/datasets_standard_format.py +11 -11
  48. mindspore/dataset/engine/datasets_text.py +38 -1
  49. mindspore/dataset/engine/datasets_user_defined.py +100 -66
  50. mindspore/dataset/engine/datasets_vision.py +81 -8
  51. mindspore/dataset/engine/iterators.py +281 -63
  52. mindspore/dataset/engine/obs/util.py +8 -0
  53. mindspore/dataset/engine/queue.py +40 -0
  54. mindspore/dataset/engine/samplers.py +26 -2
  55. mindspore/dataset/engine/serializer_deserializer.py +1 -1
  56. mindspore/dataset/engine/validators.py +43 -11
  57. mindspore/dataset/transforms/py_transforms_util.py +17 -0
  58. mindspore/dataset/transforms/transforms.py +29 -12
  59. mindspore/dataset/vision/validators.py +1 -2
  60. mindspore/device_context/__init__.py +21 -0
  61. mindspore/device_context/ascend/__init__.py +25 -0
  62. mindspore/device_context/ascend/device.py +72 -0
  63. mindspore/device_context/ascend/op_debug.py +94 -0
  64. mindspore/device_context/ascend/op_precision.py +193 -0
  65. mindspore/device_context/ascend/op_tuning.py +127 -0
  66. mindspore/device_context/cpu/__init__.py +25 -0
  67. mindspore/device_context/cpu/device.py +62 -0
  68. mindspore/device_context/cpu/op_tuning.py +43 -0
  69. mindspore/device_context/gpu/__init__.py +21 -0
  70. mindspore/device_context/gpu/device.py +70 -0
  71. mindspore/device_context/gpu/op_precision.py +67 -0
  72. mindspore/device_context/gpu/op_tuning.py +175 -0
  73. mindspore/device_manager.py +134 -0
  74. mindspore/experimental/llm_boost/__init__.py +1 -0
  75. mindspore/experimental/llm_boost/ascend_native/__init__.py +22 -0
  76. mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +211 -0
  77. mindspore/experimental/llm_boost/ascend_native/llm_boost.py +52 -0
  78. mindspore/experimental/llm_boost/atb/boost_base.py +2 -3
  79. mindspore/experimental/llm_boost/atb/llama_boost.py +6 -1
  80. mindspore/experimental/llm_boost/register.py +1 -0
  81. mindspore/experimental/optim/adadelta.py +26 -22
  82. mindspore/experimental/optim/adam.py +3 -0
  83. mindspore/experimental/optim/lr_scheduler.py +33 -24
  84. mindspore/experimental/optim/radam.py +33 -30
  85. mindspore/hal/device.py +28 -0
  86. mindspore/hal/event.py +17 -0
  87. mindspore/hal/memory.py +94 -3
  88. mindspore/hal/stream.py +91 -6
  89. mindspore/include/api/context.h +0 -1
  90. mindspore/lib/libavcodec.so.59 +0 -0
  91. mindspore/lib/libavdevice.so.59 +0 -0
  92. mindspore/lib/libavfilter.so.8 +0 -0
  93. mindspore/lib/libavformat.so.59 +0 -0
  94. mindspore/lib/libavutil.so.57 +0 -0
  95. mindspore/lib/libdnnl.so.2 +0 -0
  96. mindspore/lib/libmindspore_backend.so +0 -0
  97. mindspore/lib/libmindspore_common.so +0 -0
  98. mindspore/lib/libmindspore_core.so +0 -0
  99. mindspore/lib/libmindspore_gpr.so.15 +0 -0
  100. mindspore/lib/libmindspore_grpc++.so.1 +0 -0
  101. mindspore/lib/libmindspore_grpc.so.15 +0 -0
  102. mindspore/lib/libmindspore_ops.so +0 -0
  103. mindspore/lib/libmpi_adapter.so +0 -0
  104. mindspore/lib/libmpi_collective.so +0 -0
  105. mindspore/lib/libnnacl.so +0 -0
  106. mindspore/lib/libopencv_core.so.4.5 +0 -0
  107. mindspore/lib/libopencv_imgcodecs.so.4.5 +0 -0
  108. mindspore/lib/libopencv_imgproc.so.4.5 +0 -0
  109. mindspore/lib/libps_cache.so +0 -0
  110. mindspore/lib/libswresample.so.4 +0 -0
  111. mindspore/lib/libswscale.so.6 +0 -0
  112. mindspore/lib/plugin/ascend/custom_aicore_ops/op_impl/ai_core/tbe/config/ascend910_93/aic-ascend910_93-ops-info.json +2048 -0
  113. mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/aicpu_kernel/impl/libcust_cpu_kernels.so +0 -0
  114. mindspore/lib/plugin/ascend/custom_aicpu_ops/op_proto/libcust_op_proto.so +0 -0
  115. mindspore/lib/plugin/ascend/custom_ascendc_910/op_api/lib/libcust_opapi.so +0 -0
  116. mindspore/lib/plugin/ascend/custom_ascendc_910/op_impl/ai_core/tbe/custom_ascendc_910_impl/dynamic/decoder_kv_cache.py +1 -1
  117. mindspore/lib/plugin/ascend/custom_ascendc_910/op_impl/ai_core/tbe/custom_ascendc_910_impl/dynamic/prompt_kv_cache.py +1 -1
  118. mindspore/lib/plugin/ascend/custom_ascendc_910/op_impl/ai_core/tbe/op_tiling/lib/linux/aarch64/libcust_opmaster_rt2.0.so +0 -0
  119. mindspore/lib/plugin/ascend/custom_ascendc_910/op_impl/ai_core/tbe/op_tiling/liboptiling.so +0 -0
  120. mindspore/lib/plugin/ascend/custom_ascendc_910/op_proto/lib/linux/aarch64/libcust_opsproto_rt2.0.so +0 -0
  121. mindspore/lib/plugin/ascend/custom_ascendc_910/version.info +1 -1
  122. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_api/lib/libcust_opapi.so +0 -0
  123. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/config/ascend910_93/aic-ascend910_93-ops-info.json +224 -0
  124. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/custom_ascendc_910b_impl/dynamic/all_finite.py +1 -1
  125. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/custom_ascendc_910b_impl/dynamic/decoder_kv_cache.py +1 -1
  126. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/custom_ascendc_910b_impl/dynamic/prompt_kv_cache.py +1 -1
  127. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/all_finite/AllFinite_52f59e2a65d9b1bb002de35c2819754a.json +78 -0
  128. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/all_finite/AllFinite_52f59e2a65d9b1bb002de35c2819754a.o +0 -0
  129. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/all_finite/AllFinite_6b5e50e30256d85838d6ce83514df20f.json +78 -0
  130. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/all_finite/AllFinite_6b5e50e30256d85838d6ce83514df20f.o +0 -0
  131. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/all_finite/AllFinite_74e4ac02880d452e3308c94af273562e.json +78 -0
  132. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/all_finite/AllFinite_74e4ac02880d452e3308c94af273562e.o +0 -0
  133. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/decoder_kv_cache/DecoderKvCache_0d5520cc587ad44ce634bf3fbcffc272.json +156 -0
  134. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/decoder_kv_cache/DecoderKvCache_0d5520cc587ad44ce634bf3fbcffc272.o +0 -0
  135. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/decoder_kv_cache/DecoderKvCache_20390d30b3c4c0d23167ccca6c030c2b.json +156 -0
  136. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/decoder_kv_cache/DecoderKvCache_20390d30b3c4c0d23167ccca6c030c2b.o +0 -0
  137. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/decoder_kv_cache/DecoderKvCache_2d151f0b1d2db51faa2968d5b67544e2.json +156 -0
  138. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/decoder_kv_cache/DecoderKvCache_2d151f0b1d2db51faa2968d5b67544e2.o +0 -0
  139. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/decoder_kv_cache/DecoderKvCache_561690ec17cc1def3d2fcf68c1b07b56.json +156 -0
  140. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/decoder_kv_cache/DecoderKvCache_561690ec17cc1def3d2fcf68c1b07b56.o +0 -0
  141. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/decoder_kv_cache/DecoderKvCache_570f9aaa99e5e773b3dd0a33784363f4.json +156 -0
  142. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/decoder_kv_cache/DecoderKvCache_570f9aaa99e5e773b3dd0a33784363f4.o +0 -0
  143. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/decoder_kv_cache/DecoderKvCache_59668a0f0764afb98fda8ab9e84126f1.json +156 -0
  144. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/decoder_kv_cache/DecoderKvCache_59668a0f0764afb98fda8ab9e84126f1.o +0 -0
  145. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/decoder_kv_cache/DecoderKvCache_91d9833e4792b70b670e4e2b916abd86.json +156 -0
  146. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/decoder_kv_cache/DecoderKvCache_91d9833e4792b70b670e4e2b916abd86.o +0 -0
  147. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/decoder_kv_cache/DecoderKvCache_c74cdc5fef094383401856f8519504af.json +156 -0
  148. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/decoder_kv_cache/DecoderKvCache_c74cdc5fef094383401856f8519504af.o +0 -0
  149. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/prompt_kv_cache/PromptKvCache_0515c7b1a4cd614449e38c5e9a7e3f8d.json +165 -0
  150. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/prompt_kv_cache/PromptKvCache_0515c7b1a4cd614449e38c5e9a7e3f8d.o +0 -0
  151. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/prompt_kv_cache/PromptKvCache_09f22d898d6358c91e7c4fc48bac48e7.json +165 -0
  152. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/prompt_kv_cache/PromptKvCache_09f22d898d6358c91e7c4fc48bac48e7.o +0 -0
  153. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/prompt_kv_cache/PromptKvCache_0cb9a6f894b925250227136e5aab7061.json +165 -0
  154. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/prompt_kv_cache/PromptKvCache_0cb9a6f894b925250227136e5aab7061.o +0 -0
  155. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/prompt_kv_cache/PromptKvCache_2fa8702ffd7ca85e9e194f62644415d5.json +165 -0
  156. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/prompt_kv_cache/PromptKvCache_2fa8702ffd7ca85e9e194f62644415d5.o +0 -0
  157. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/prompt_kv_cache/PromptKvCache_570b62f187dfd439b64613d881deedb7.json +165 -0
  158. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/prompt_kv_cache/PromptKvCache_570b62f187dfd439b64613d881deedb7.o +0 -0
  159. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/prompt_kv_cache/PromptKvCache_585218c11411ff84709b9e725b66c435.json +165 -0
  160. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/prompt_kv_cache/PromptKvCache_585218c11411ff84709b9e725b66c435.o +0 -0
  161. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/prompt_kv_cache/PromptKvCache_5c9365ccde170b358c5b126d69dae13e.json +165 -0
  162. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/prompt_kv_cache/PromptKvCache_5c9365ccde170b358c5b126d69dae13e.o +0 -0
  163. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/prompt_kv_cache/PromptKvCache_6d97c45b7c43bc16fcff8baa5dacac4e.json +165 -0
  164. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/ascend910_93/prompt_kv_cache/PromptKvCache_6d97c45b7c43bc16fcff8baa5dacac4e.o +0 -0
  165. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/config/ascend910_93/all_finite.json +139 -0
  166. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/config/ascend910_93/binary_info_config.json +361 -0
  167. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/config/ascend910_93/decoder_kv_cache.json +892 -0
  168. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/kernel/config/ascend910_93/prompt_kv_cache.json +892 -0
  169. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/op_tiling/lib/linux/aarch64/libcust_opmaster_rt2.0.so +0 -0
  170. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_impl/ai_core/tbe/op_tiling/liboptiling.so +0 -0
  171. mindspore/lib/plugin/ascend/custom_ascendc_910b/op_proto/lib/linux/aarch64/libcust_opsproto_rt2.0.so +0 -0
  172. mindspore/lib/plugin/ascend/custom_ascendc_910b/version.info +1 -1
  173. mindspore/lib/plugin/ascend/custom_compiler/setup.py +1 -1
  174. mindspore/lib/plugin/ascend/libascend_collective.so +0 -0
  175. mindspore/lib/plugin/ascend/libdvpp_utils.so +0 -0
  176. mindspore/lib/plugin/ascend/liblowlatency_collective.so +0 -0
  177. mindspore/lib/plugin/ascend/libmindspore_cpu_kernels.so +0 -0
  178. mindspore/lib/plugin/ascend/libmindspore_internal_kernels.so +0 -0
  179. mindspore/lib/plugin/ascend/libms_ascend_native_boost.so +0 -0
  180. mindspore/lib/plugin/ascend/libms_atb_boost.so +0 -0
  181. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/device/ascend910b/bin/ascend910b.bin +957 -955
  182. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/lib/libasdops_static.a +0 -0
  183. mindspore/lib/plugin/ascend/ms_kernels_internal/asdops/lib/liblcal_static.a +0 -0
  184. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/{acme/include/base_type.h → base_type.h} +25 -20
  185. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/{cast/cast_tiling.h → internal.h} +6 -4
  186. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/internal_op.h +114 -0
  187. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/llm/boost_kernel.h +70 -0
  188. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/llm/llama_impl.h +85 -0
  189. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/llm/model_interface.h +52 -0
  190. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/llm/tensor.h +81 -0
  191. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/op_creator.h +123 -0
  192. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/op_param.h +155 -110
  193. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/{acme/include/tiling_info.h → tiling_info.h} +12 -9
  194. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/tiling_utils.h +178 -0
  195. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libadd_layer_norm_op.so +0 -0
  196. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libadd_rms_norm_op.so +0 -0
  197. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libadd_rms_norm_quant_op.so +0 -0
  198. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libapply_rotary_pos_emb_310p_op.so +0 -0
  199. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libapply_rotary_pos_emb_op.so +0 -0
  200. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libcast_op.so +0 -0
  201. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libcompare_op.so +0 -0
  202. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libgelu_op.so +0 -0
  203. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libllama_op.so +0 -0
  204. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libmatmul_op.so +0 -0
  205. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libms_kernels_internal.so +0 -0
  206. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libms_optiling.so +0 -0
  207. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libmulti_weight_matmul_kernel_op.so +0 -0
  208. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libreshape_and_cache_nz_op.so +0 -0
  209. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libreshape_and_cache_op.so +0 -0
  210. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/librms_norm_op.so +0 -0
  211. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend310p/object_kernels/internal_pp_matmul_f16_nz/internal_pp_matmul_f16_nz.o +0 -0
  212. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend310p/object_kernels/internal_pp_matmul_f16_nz/internal_pp_matmul_f16_nz_0.o +0 -0
  213. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend310p/object_kernels/internal_pp_matmul_i8_nz_compress/internal_pp_matmul_i8_nz_compress.o +0 -0
  214. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend310p/object_kernels/internal_pp_matmul_i8_nz_compress/internal_pp_matmul_i8_nz_compress_0.o +0 -0
  215. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend310p/object_kernels/internal_pp_matmul_int8_nz/internal_pp_matmul_int8_nz.o +0 -0
  216. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend310p/object_kernels/internal_pp_matmul_int8_nz/internal_pp_matmul_int8_nz_0.o +0 -0
  217. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend310p/so_kernels/libadd_rms_norm_quant_ascend310p.so +0 -0
  218. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/{lib/libapply_rotary_pos_emb_310p_impl.so → op_kernels/ascend310p/so_kernels/libapply_rotary_pos_emb_310p_ascend310p.so} +0 -0
  219. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend310p/so_kernels/libcast_ascend310p.so +0 -0
  220. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend310p/so_kernels/libcompare_ascend310p.so +0 -0
  221. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend310p/so_kernels/libgelu_ascend310p.so +0 -0
  222. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend310p/so_kernels/libmatmul_ascend310p.so +0 -0
  223. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend310p/so_kernels/libreshape_and_cache_nz_ascend310p.so +0 -0
  224. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/hphol_kernels/add_rms_norm_dynamic_quant/AddRmsNormDynamicQuant_4b60f88cdc28b25a36bad2d8b0a88092.json +163 -0
  225. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/hphol_kernels/add_rms_norm_dynamic_quant/AddRmsNormDynamicQuant_4b60f88cdc28b25a36bad2d8b0a88092.o +0 -0
  226. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/hphol_kernels/add_rms_norm_dynamic_quant/AddRmsNormDynamicQuant_cde61da2bd6fededcb1ba310a6ad16ee.json +163 -0
  227. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/hphol_kernels/add_rms_norm_dynamic_quant/AddRmsNormDynamicQuant_cde61da2bd6fededcb1ba310a6ad16ee.o +0 -0
  228. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/object_kernels/flash_attention_score/flash_attention_score_bf16_bnsd_full_mix.o +0 -0
  229. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/object_kernels/flash_attention_score/flash_attention_score_bf16_bnsd_tri_mix.o +0 -0
  230. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/object_kernels/flash_attention_score/flash_attention_score_bf16_bsh_full_mix.o +0 -0
  231. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/object_kernels/flash_attention_score/flash_attention_score_bf16_bsh_tri_mix.o +0 -0
  232. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/object_kernels/flash_attention_score/flash_attention_score_fp16_bnsd_full_mix.o +0 -0
  233. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/object_kernels/flash_attention_score/flash_attention_score_fp16_bnsd_tri_mix.o +0 -0
  234. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/object_kernels/flash_attention_score/flash_attention_score_fp16_bsh_full_mix.o +0 -0
  235. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/object_kernels/flash_attention_score/flash_attention_score_fp16_bsh_tri_mix.o +0 -0
  236. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/object_kernels/internal_matmul_postfusion_mix/internal_matmul_postfusion_mix.o +0 -0
  237. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/object_kernels/internal_matmul_postfusion_mix/internal_matmul_postfusion_mix_mix_aic_0.o +0 -0
  238. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/object_kernels/internal_matmul_postfusion_mix/internal_matmul_postfusion_mix_mix_aiv_0.o +0 -0
  239. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/object_kernels/internal_multi_weight_matmul_postfusion_mix/internal_multi_weight_matmul_postfusion_mix.o +0 -0
  240. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/object_kernels/internal_multi_weight_matmul_postfusion_mix/internal_multi_weight_matmul_postfusion_mix_mix_aic_0.o +0 -0
  241. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/object_kernels/internal_multi_weight_matmul_postfusion_mix/internal_multi_weight_matmul_postfusion_mix_mix_aiv_0.o +0 -0
  242. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/{matmul_add_rmsnorm → object_kernels/matmul_add_rmsnorm}/matmul_add_rmsnorm_bf16_bf16.o +0 -0
  243. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/{matmul_add_rmsnorm → object_kernels/matmul_add_rmsnorm}/matmul_add_rmsnorm_bf16_fp16.o +0 -0
  244. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/{matmul_add_rmsnorm → object_kernels/matmul_add_rmsnorm}/matmul_add_rmsnorm_bf16_fp32.o +0 -0
  245. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/{matmul_add_rmsnorm → object_kernels/matmul_add_rmsnorm}/matmul_add_rmsnorm_fp16_bf16.o +0 -0
  246. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/{matmul_add_rmsnorm → object_kernels/matmul_add_rmsnorm}/matmul_add_rmsnorm_fp16_fp16.o +0 -0
  247. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/{matmul_add_rmsnorm → object_kernels/matmul_add_rmsnorm}/matmul_add_rmsnorm_fp16_fp32.o +0 -0
  248. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/object_kernels/paged_attention_v2/paged_attention_v2.o +0 -0
  249. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/object_kernels/paged_attention_v2/paged_attention_v2_mix_aic_0.o +0 -0
  250. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/object_kernels/paged_attention_v2/paged_attention_v2_mix_aiv_0.o +0 -0
  251. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/{lib/libadd_layer_norm_impl.so → op_kernels/ascend910b/so_kernels/libadd_layer_norm_ascend910b.so} +0 -0
  252. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/{lib/libadd_rms_norm_impl.so → op_kernels/ascend910b/so_kernels/libadd_rms_norm_ascend910b.so} +0 -0
  253. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/so_kernels/libadd_rms_norm_quant_ascend910b.so +0 -0
  254. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/{lib/libapply_rotary_pos_emb_impl.so → op_kernels/ascend910b/so_kernels/libapply_rotary_pos_emb_ascend910b.so} +0 -0
  255. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/{lib/libcast_impl.so → op_kernels/ascend910b/so_kernels/libcast_ascend910b.so} +0 -0
  256. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/{lib/libnot_equal_impl.so → op_kernels/ascend910b/so_kernels/libcompare_ascend910b.so} +0 -0
  257. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/{lib/libgelu_impl.so → op_kernels/ascend910b/so_kernels/libgelu_ascend910b.so} +0 -0
  258. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/so_kernels/libllama_ascend910b.so +0 -0
  259. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/{lib/libmatmul_impl.so → op_kernels/ascend910b/so_kernels/libmatmul_ascend910b.so} +0 -0
  260. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/{lib/libmulti_weight_matmul_kernel_impl.so → op_kernels/ascend910b/so_kernels/libmulti_weight_matmul_kernel_ascend910b.so} +0 -0
  261. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/{lib/libreshape_and_cache_impl.so → op_kernels/ascend910b/so_kernels/libreshape_and_cache_ascend910b.so} +0 -0
  262. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/{lib/librms_norm_impl.so → op_kernels/ascend910b/so_kernels/librms_norm_ascend910b.so} +0 -0
  263. mindspore/lib/plugin/ascend/ms_kernels_internal/lccl/lib/liblccl_wrapper.so +0 -0
  264. mindspore/lib/plugin/libmindspore_ascend.so.2 +0 -0
  265. mindspore/log.py +12 -0
  266. mindspore/mindrecord/__init__.py +1 -1
  267. mindspore/mindrecord/config.py +17 -316
  268. mindspore/mindrecord/filereader.py +1 -9
  269. mindspore/mindrecord/filewriter.py +5 -15
  270. mindspore/mindrecord/mindpage.py +1 -9
  271. mindspore/mint/__init__.py +824 -218
  272. mindspore/mint/distributed/__init__.py +66 -4
  273. mindspore/mint/distributed/distributed.py +2594 -44
  274. mindspore/mint/linalg/__init__.py +6 -0
  275. mindspore/mint/nn/__init__.py +473 -14
  276. mindspore/mint/nn/functional.py +486 -11
  277. mindspore/mint/nn/layer/__init__.py +17 -4
  278. mindspore/mint/nn/layer/_functions.py +330 -0
  279. mindspore/mint/nn/layer/activation.py +169 -1
  280. mindspore/mint/nn/layer/basic.py +123 -0
  281. mindspore/mint/nn/layer/conv.py +727 -0
  282. mindspore/mint/nn/layer/normalization.py +215 -19
  283. mindspore/mint/nn/layer/padding.py +797 -0
  284. mindspore/mint/nn/layer/pooling.py +170 -0
  285. mindspore/mint/optim/__init__.py +2 -1
  286. mindspore/mint/optim/adam.py +223 -0
  287. mindspore/mint/optim/adamw.py +26 -19
  288. mindspore/mint/special/__init__.py +2 -1
  289. mindspore/multiprocessing/__init__.py +5 -0
  290. mindspore/nn/cell.py +126 -19
  291. mindspore/nn/dynamic_lr.py +2 -1
  292. mindspore/nn/layer/activation.py +6 -6
  293. mindspore/nn/layer/basic.py +35 -25
  294. mindspore/nn/layer/channel_shuffle.py +3 -3
  295. mindspore/nn/layer/embedding.py +3 -3
  296. mindspore/nn/layer/normalization.py +8 -7
  297. mindspore/nn/layer/padding.py +4 -3
  298. mindspore/nn/layer/pooling.py +47 -13
  299. mindspore/nn/layer/rnn_cells.py +1 -1
  300. mindspore/nn/layer/rnns.py +2 -1
  301. mindspore/nn/layer/timedistributed.py +5 -5
  302. mindspore/nn/layer/transformer.py +48 -26
  303. mindspore/nn/learning_rate_schedule.py +5 -3
  304. mindspore/nn/loss/loss.py +31 -36
  305. mindspore/nn/optim/ada_grad.py +1 -0
  306. mindspore/nn/optim/adadelta.py +2 -2
  307. mindspore/nn/optim/adam.py +1 -1
  308. mindspore/nn/optim/lars.py +1 -4
  309. mindspore/nn/optim/optimizer.py +1 -1
  310. mindspore/nn/optim/rprop.py +2 -2
  311. mindspore/nn/optim/thor.py +2 -1
  312. mindspore/nn/utils/init.py +13 -11
  313. mindspore/nn/wrap/cell_wrapper.py +4 -6
  314. mindspore/nn/wrap/loss_scale.py +3 -4
  315. mindspore/numpy/array_creations.py +60 -62
  316. mindspore/numpy/array_ops.py +148 -143
  317. mindspore/numpy/logic_ops.py +41 -42
  318. mindspore/numpy/math_ops.py +361 -359
  319. mindspore/numpy/utils.py +16 -16
  320. mindspore/numpy/utils_const.py +4 -4
  321. mindspore/ops/__init__.py +2 -1
  322. mindspore/ops/_grad_experimental/grad_comm_ops.py +94 -13
  323. mindspore/ops/_grad_experimental/grad_debug_ops.py +6 -1
  324. mindspore/ops/_grad_experimental/grad_inner_ops.py +9 -0
  325. mindspore/ops/_grad_experimental/grad_math_ops.py +2 -1
  326. mindspore/ops/_op_impl/cpu/__init__.py +1 -0
  327. mindspore/ops/_op_impl/cpu/raise_op.py +28 -0
  328. mindspore/ops/_vmap/vmap_array_ops.py +20 -19
  329. mindspore/ops/_vmap/vmap_base.py +0 -2
  330. mindspore/ops/_vmap/vmap_grad_nn_ops.py +19 -13
  331. mindspore/ops/_vmap/vmap_math_ops.py +11 -9
  332. mindspore/ops/_vmap/vmap_nn_ops.py +20 -34
  333. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +149 -12
  334. mindspore/ops/auto_generate/gen_arg_handler.py +0 -61
  335. mindspore/ops/auto_generate/gen_extend_func.py +554 -60
  336. mindspore/ops/auto_generate/gen_ops_def.py +1621 -115
  337. mindspore/ops/auto_generate/gen_ops_prim.py +8024 -3409
  338. mindspore/ops/auto_generate/pyboost_inner_prim.py +183 -79
  339. mindspore/ops/composite/base.py +1 -1
  340. mindspore/ops/composite/multitype_ops/_compile_utils.py +229 -30
  341. mindspore/ops/composite/multitype_ops/pow_impl.py +0 -29
  342. mindspore/ops/function/__init__.py +12 -0
  343. mindspore/ops/function/array_func.py +561 -159
  344. mindspore/ops/function/clip_func.py +64 -0
  345. mindspore/ops/function/debug_func.py +28 -20
  346. mindspore/ops/function/image_func.py +1 -1
  347. mindspore/ops/function/linalg_func.py +5 -4
  348. mindspore/ops/function/math_func.py +1659 -290
  349. mindspore/ops/function/nn_func.py +988 -317
  350. mindspore/ops/function/parameter_func.py +3 -56
  351. mindspore/ops/function/random_func.py +243 -33
  352. mindspore/ops/function/sparse_unary_func.py +1 -1
  353. mindspore/ops/functional.py +18 -5
  354. mindspore/ops/functional_overload.py +897 -0
  355. mindspore/ops/operations/__init__.py +3 -2
  356. mindspore/ops/operations/_embedding_cache_ops.py +4 -4
  357. mindspore/ops/operations/_grad_ops.py +2 -34
  358. mindspore/ops/operations/_infer_ops.py +2 -1
  359. mindspore/ops/operations/_inner_ops.py +38 -8
  360. mindspore/ops/operations/array_ops.py +45 -303
  361. mindspore/ops/operations/comm_ops.py +19 -16
  362. mindspore/ops/operations/custom_ops.py +11 -55
  363. mindspore/ops/operations/debug_ops.py +42 -47
  364. mindspore/ops/operations/inner_ops.py +6 -4
  365. mindspore/ops/operations/linalg_ops.py +3 -2
  366. mindspore/ops/operations/manually_defined/ops_def.py +185 -104
  367. mindspore/ops/operations/math_ops.py +11 -216
  368. mindspore/ops/operations/nn_ops.py +146 -308
  369. mindspore/ops/primitive.py +23 -21
  370. mindspore/ops/tensor_method.py +1669 -0
  371. mindspore/ops_generate/aclnn_kernel_register_auto_cc_generator.py +110 -0
  372. mindspore/ops_generate/add_tensor_docs_generator.py +54 -0
  373. mindspore/ops_generate/arg_handler.py +0 -61
  374. mindspore/ops_generate/auto_grad_impl_cc_generator.py +135 -0
  375. mindspore/ops_generate/auto_grad_reg_cc_generator.py +93 -0
  376. mindspore/ops_generate/base_generator.py +11 -0
  377. mindspore/ops_generate/cpp_create_prim_instance_helper_generator.py +108 -0
  378. mindspore/ops_generate/functional_map_cpp_generator.py +491 -0
  379. mindspore/ops_generate/functional_overload_py_generator.py +110 -0
  380. mindspore/ops_generate/functions_cc_generator.py +233 -0
  381. mindspore/ops_generate/gen_aclnn_implement.py +110 -114
  382. mindspore/ops_generate/gen_constants.py +157 -3
  383. mindspore/ops_generate/gen_ops.py +245 -990
  384. mindspore/ops_generate/gen_pyboost_func.py +97 -998
  385. mindspore/ops_generate/gen_utils.py +119 -33
  386. mindspore/ops_generate/lite_ops_cpp_generator.py +155 -0
  387. mindspore/ops_generate/op_api_proto.py +206 -0
  388. mindspore/ops_generate/op_def_py_generator.py +131 -0
  389. mindspore/ops_generate/op_prim_py_generator.py +480 -0
  390. mindspore/ops_generate/op_proto.py +373 -108
  391. mindspore/ops_generate/op_template_parser.py +436 -0
  392. mindspore/ops_generate/ops_def_cc_generator.py +288 -0
  393. mindspore/ops_generate/ops_def_h_generator.py +74 -0
  394. mindspore/ops_generate/ops_name_h_generator.py +68 -0
  395. mindspore/ops_generate/ops_primitive_h_generator.py +81 -0
  396. mindspore/ops_generate/pyboost_functions_cpp_generator.py +370 -0
  397. mindspore/ops_generate/pyboost_functions_h_generator.py +68 -0
  398. mindspore/ops_generate/pyboost_functions_py_generator.py +148 -0
  399. mindspore/ops_generate/pyboost_grad_function_cpp_generator.py +154 -0
  400. mindspore/ops_generate/pyboost_inner_prim_generator.py +131 -0
  401. mindspore/ops_generate/pyboost_native_grad_functions_generator.py +268 -0
  402. mindspore/ops_generate/pyboost_op_cpp_code_generator.py +851 -0
  403. mindspore/ops_generate/pyboost_overload_functions_cpp_generator.py +344 -0
  404. mindspore/ops_generate/pyboost_utils.py +92 -33
  405. mindspore/ops_generate/template.py +294 -44
  406. mindspore/ops_generate/tensor_func_reg_cpp_generator.py +422 -0
  407. mindspore/parallel/__init__.py +3 -3
  408. mindspore/parallel/_auto_parallel_context.py +24 -33
  409. mindspore/parallel/_parallel_serialization.py +13 -2
  410. mindspore/parallel/_utils.py +4 -1
  411. mindspore/parallel/algo_parameter_config.py +1 -1
  412. mindspore/parallel/checkpoint_transform.py +44 -0
  413. mindspore/parallel/cluster/process_entity/_api.py +131 -37
  414. mindspore/parallel/cluster/process_entity/_utils.py +41 -6
  415. mindspore/parallel/cluster/run.py +20 -3
  416. mindspore/parallel/parameter_broadcast.py +1 -1
  417. mindspore/parallel/shard.py +3 -0
  418. mindspore/parallel/transform_safetensors.py +119 -253
  419. mindspore/profiler/__init__.py +17 -4
  420. mindspore/profiler/analysis/__init__.py +0 -0
  421. mindspore/profiler/analysis/parser/__init__.py +0 -0
  422. mindspore/profiler/analysis/parser/ascend_cann_parser.py +166 -0
  423. mindspore/profiler/analysis/parser/base_parser.py +158 -0
  424. mindspore/profiler/analysis/parser/framework_cann_relation_parser.py +45 -0
  425. mindspore/profiler/analysis/parser/ms_framework_parser.py +142 -0
  426. mindspore/profiler/analysis/parser/ms_minddata_parser.py +145 -0
  427. mindspore/profiler/analysis/parser/timeline_assembly_factory/__init__.py +0 -0
  428. mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +261 -0
  429. mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +40 -0
  430. mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +84 -0
  431. mindspore/profiler/analysis/parser/timeline_creator/__init__.py +0 -0
  432. mindspore/profiler/analysis/parser/timeline_creator/base_timeline_creator.py +44 -0
  433. mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +90 -0
  434. mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +76 -0
  435. mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +103 -0
  436. mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +134 -0
  437. mindspore/profiler/analysis/parser/timeline_event/__init__.py +0 -0
  438. mindspore/profiler/analysis/parser/timeline_event/base_event.py +233 -0
  439. mindspore/profiler/analysis/parser/timeline_event/cpu_op_event.py +47 -0
  440. mindspore/profiler/analysis/parser/timeline_event/flow_event.py +36 -0
  441. mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +260 -0
  442. mindspore/profiler/analysis/parser/timeline_event/msprof_event.py +73 -0
  443. mindspore/profiler/analysis/parser/timeline_event/scope_layer_event.py +53 -0
  444. mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +146 -0
  445. mindspore/profiler/analysis/task_manager.py +131 -0
  446. mindspore/profiler/analysis/time_converter.py +84 -0
  447. mindspore/profiler/analysis/viewer/__init__.py +0 -0
  448. mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +333 -0
  449. mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +87 -0
  450. mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +252 -0
  451. mindspore/profiler/analysis/viewer/ascend_memory_viewer.py +313 -0
  452. mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +322 -0
  453. mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +265 -0
  454. mindspore/profiler/analysis/viewer/ascend_timeline_viewer.py +58 -0
  455. mindspore/profiler/analysis/viewer/base_viewer.py +26 -0
  456. mindspore/profiler/analysis/viewer/ms_dataset_viewer.py +97 -0
  457. mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +581 -0
  458. mindspore/profiler/analysis/work_flow.py +73 -0
  459. mindspore/profiler/common/ascend_msprof_exporter.py +138 -0
  460. mindspore/profiler/common/command_executor.py +90 -0
  461. mindspore/profiler/common/constant.py +174 -3
  462. mindspore/profiler/common/file_manager.py +208 -0
  463. mindspore/profiler/common/log.py +130 -0
  464. mindspore/profiler/common/msprof_cmd_tool.py +202 -0
  465. mindspore/profiler/common/path_manager.py +371 -0
  466. mindspore/profiler/common/process_bar.py +168 -0
  467. mindspore/profiler/common/process_pool.py +9 -3
  468. mindspore/profiler/common/profiler_context.py +476 -0
  469. mindspore/profiler/common/profiler_info.py +304 -0
  470. mindspore/profiler/common/profiler_output_path.py +284 -0
  471. mindspore/profiler/common/profiler_parameters.py +210 -0
  472. mindspore/profiler/common/profiler_path_manager.py +120 -0
  473. mindspore/profiler/common/record_function.py +76 -0
  474. mindspore/profiler/common/tlv_decoder.py +76 -0
  475. mindspore/profiler/common/util.py +75 -2
  476. mindspore/profiler/dynamic_profiler.py +270 -37
  477. mindspore/profiler/envprofiler.py +138 -0
  478. mindspore/profiler/mstx.py +199 -0
  479. mindspore/profiler/platform/__init__.py +21 -0
  480. mindspore/profiler/platform/base_profiler.py +40 -0
  481. mindspore/profiler/platform/cpu_profiler.py +124 -0
  482. mindspore/profiler/platform/gpu_profiler.py +74 -0
  483. mindspore/profiler/platform/npu_profiler.py +309 -0
  484. mindspore/profiler/profiler.py +580 -93
  485. mindspore/profiler/profiler_action_controller.py +187 -0
  486. mindspore/profiler/profiler_interface.py +114 -0
  487. mindspore/profiler/schedule.py +208 -0
  488. mindspore/rewrite/api/symbol_tree.py +1 -2
  489. mindspore/run_check/_check_version.py +2 -6
  490. mindspore/runtime/__init__.py +37 -0
  491. mindspore/runtime/device.py +27 -0
  492. mindspore/runtime/event.py +209 -0
  493. mindspore/runtime/executor.py +148 -0
  494. mindspore/runtime/memory.py +392 -0
  495. mindspore/runtime/stream.py +460 -0
  496. mindspore/runtime/thread_bind_core.py +401 -0
  497. mindspore/train/__init__.py +2 -2
  498. mindspore/train/_utils.py +53 -18
  499. mindspore/train/amp.py +8 -4
  500. mindspore/train/callback/_checkpoint.py +32 -18
  501. mindspore/train/callback/_early_stop.py +1 -1
  502. mindspore/train/callback/_flops_collector.py +105 -69
  503. mindspore/train/callback/_history.py +1 -1
  504. mindspore/train/callback/_summary_collector.py +44 -6
  505. mindspore/train/callback/_tft_register.py +31 -10
  506. mindspore/train/dataset_helper.py +11 -11
  507. mindspore/train/metrics/precision.py +4 -5
  508. mindspore/train/mind_ir_pb2.py +167 -46
  509. mindspore/train/model.py +13 -15
  510. mindspore/train/serialization.py +462 -76
  511. mindspore/train/summary/summary_record.py +1 -2
  512. mindspore/train/train_thor/model_thor.py +1 -1
  513. mindspore/utils/__init__.py +4 -2
  514. mindspore/utils/bin/dataset-cache +0 -0
  515. mindspore/utils/bin/dataset-cache-server +0 -0
  516. mindspore/utils/dryrun.py +138 -0
  517. mindspore/utils/runtime_execution_order_check.py +550 -0
  518. mindspore/version.py +1 -1
  519. {mindspore-2.4.10.dist-info → mindspore-2.5.0.dist-info}/METADATA +2 -3
  520. {mindspore-2.4.10.dist-info → mindspore-2.5.0.dist-info}/RECORD +523 -457
  521. {mindspore-2.4.10.dist-info → mindspore-2.5.0.dist-info}/entry_points.txt +1 -1
  522. mindspore/_data_dump.cpython-39-aarch64-linux-gnu.so +0 -0
  523. mindspore/bin/cache_admin +0 -0
  524. mindspore/bin/cache_server +0 -0
  525. mindspore/common/_tensor_overload.py +0 -139
  526. mindspore/lib/libmindspore_np_dtype.so +0 -0
  527. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/include/acme.h +0 -24
  528. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/include/acme_op.h +0 -82
  529. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/include/op_creator.h +0 -113
  530. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/include/op_param.h +0 -193
  531. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/core/dtype_registry.h +0 -90
  532. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/core/kernel_register.h +0 -46
  533. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/core/platform/platform_configs.h +0 -89
  534. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/core/platform/rt_funcs.h +0 -135
  535. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/add_layer_norm_op.h +0 -60
  536. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/add_rms_norm_op.h +0 -50
  537. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/add_rms_norm_quant_op.h +0 -50
  538. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/apply_rotary_pos_emb_nz_op.h +0 -42
  539. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/apply_rotary_pos_emb_op.h +0 -55
  540. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/asd_elewise_op.h +0 -34
  541. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/asd_only_ops.h +0 -94
  542. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/asd_op_base.h +0 -97
  543. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/cast_op.h +0 -52
  544. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/flash_attention_score_op.h +0 -97
  545. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/gelu_op.h +0 -44
  546. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/matmul_add_rmsnorm_op.h +0 -73
  547. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/matmul_op.h +0 -108
  548. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/multi_impls_op.h +0 -64
  549. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/multi_weight_matmul_op.h +0 -91
  550. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/paged_attention_op.h +0 -99
  551. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/reshape_and_cache_nz_op.h +0 -44
  552. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/reshape_and_cache_op.h +0 -44
  553. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/ops/host_src/rms_norm_op.h +0 -64
  554. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/utils/asd_utils.h +0 -179
  555. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/utils/comm_utils.h +0 -69
  556. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/acme/src/utils/profiling_util.h +0 -366
  557. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/add/add_impl.h +0 -56
  558. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/add/kernel/add.h +0 -21
  559. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/add/tiling/add_tiling.h +0 -43
  560. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/apply_rotary_pos_emb_impl.h +0 -46
  561. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/kernel/apply_rotary_pos_emb.h +0 -23
  562. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/kernel/apply_rotary_pos_emb_base.h +0 -456
  563. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/kernel/apply_rotary_pos_emb_bf16.h +0 -217
  564. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/kernel/apply_rotary_pos_emb_fp.h +0 -391
  565. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/kernel/apply_rotary_pos_emb_fp16.h +0 -126
  566. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/kernel/apply_rotary_pos_emb_fp32.h +0 -230
  567. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/kernel/apply_rotary_pos_emb_tiling.h +0 -43
  568. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb/kernel/apply_rotary_pos_emb_value.h +0 -27
  569. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb_nz/apply_rotary_pos_emb_nz_impl.h +0 -34
  570. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb_nz/kernel/apply_rotary_pos_emb_nz.h +0 -23
  571. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb_nz/kernel/apply_rotary_pos_emb_nz_base.h +0 -460
  572. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb_nz/kernel/apply_rotary_pos_emb_nz_fp16.h +0 -116
  573. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb_nz/kernel/apply_rotary_pos_emb_nz_fp32.h +0 -230
  574. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb_nz/kernel/apply_rotary_pos_emb_nz_tiling.h +0 -43
  575. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/apply_rotary_pos_emb_nz/kernel/apply_rotary_pos_emb_nz_value.h +0 -27
  576. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/asdop/asd_op_impl.h +0 -74
  577. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/backend_param.h +0 -74
  578. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/cast/cast_impl.h +0 -48
  579. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/cast/kernel/cast_kernel.h +0 -21
  580. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/compare/compare_impl.h +0 -55
  581. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/compare/compare_tiling.h +0 -27
  582. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/compare/kernel/compare_kernel.h +0 -23
  583. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/and_impl.h +0 -29
  584. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/div_impl.h +0 -29
  585. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/elewise_binary_impl.h +0 -48
  586. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/elewise_binary_tiling.h +0 -25
  587. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/kernel/and_kernel.h +0 -46
  588. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/kernel/div_kernel.h +0 -46
  589. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/kernel/elewise_binary_base.h +0 -260
  590. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/kernel/elewise_binary_kernel.h +0 -35
  591. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/kernel/max_kernel.h +0 -66
  592. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/kernel/min_kernel.h +0 -66
  593. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/kernel/mul_kernel.h +0 -66
  594. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/kernel/or_kernel.h +0 -46
  595. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/max_impl.h +0 -29
  596. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/min_impl.h +0 -29
  597. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/mul_impl.h +0 -29
  598. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_binary/or_impl.h +0 -29
  599. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/abs_impl.h +0 -29
  600. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/elewise_unary_impl.h +0 -47
  601. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/elewise_unary_tiling.h +0 -24
  602. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/exp_impl.h +0 -29
  603. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/abs_kernel.h +0 -45
  604. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/elewise_unary_base.h +0 -148
  605. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/elewise_unary_kernel.h +0 -31
  606. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/exp_kernel.h +0 -45
  607. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/ln_kernel.h +0 -45
  608. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/not_kernel.h +0 -45
  609. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/reciprocal_kernel.h +0 -45
  610. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/relu_kernel.h +0 -55
  611. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/rsqrt_kernel.h +0 -45
  612. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/kernel/sqrt_kernel.h +0 -45
  613. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/ln_impl.h +0 -29
  614. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/not_impl.h +0 -29
  615. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/reciprocal_impl.h +0 -29
  616. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/relu_impl.h +0 -29
  617. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/rsqrt_impl.h +0 -29
  618. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/elewise_unary/sqrt_impl.h +0 -29
  619. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/flash_attention_score/flash_attention_score_impl.h +0 -68
  620. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/internal_kernel.h +0 -99
  621. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/internal_rtbackend.h +0 -21
  622. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/lccl/lccl_wrapper.h +0 -58
  623. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/ms_int_types.h +0 -91
  624. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/ms_int_utils.h +0 -108
  625. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/paged_attention/paged_attention_impl.h +0 -64
  626. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/add_param.h +0 -68
  627. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/attention_param.h +0 -40
  628. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/cast_param.h +0 -30
  629. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/compare_param.h +0 -31
  630. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/elewise_param.h +0 -41
  631. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/grouped_matmul_param.h +0 -40
  632. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/matmul_ext_param.h +0 -38
  633. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/matmul_qkv_param.h +0 -42
  634. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/param/sub_param.h +0 -33
  635. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/profiling_util.h +0 -377
  636. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/reshape_and_cache_nz/kernel/reshape_and_cache_nz.h +0 -24
  637. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/reshape_and_cache_nz/reshape_and_cache_nz_impl.h +0 -42
  638. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/reshape_and_cache_nz/reshape_and_cache_nz_tiling.h +0 -27
  639. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/rms_norm/rms_norm_impl.h +0 -46
  640. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/sub/kernel/sub_kernel.h +0 -20
  641. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/sub/sub_impl.h +0 -48
  642. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/sub/sub_tiling.h +0 -25
  643. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/tune_repo/matmul_table.h +0 -399
  644. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/tune_repo/utils.h +0 -41
  645. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/backend.h +0 -45
  646. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/elewise_tiling.h +0 -29
  647. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/elewise_utils.h +0 -30
  648. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/log/log.h +0 -69
  649. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/log/log_core.h +0 -43
  650. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/log/log_entity.h +0 -38
  651. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/log/log_sink.h +0 -69
  652. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/log/log_stream.h +0 -41
  653. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/log/log_tiling.h +0 -71
  654. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/log/log_utils.h +0 -165
  655. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/math.h +0 -20
  656. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/register/kernel_creator.h +0 -39
  657. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/register/kernel_registry.h +0 -121
  658. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/include/utils/utils.h +0 -106
  659. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libAdd_impl.so +0 -0
  660. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libSub_impl.so +0 -0
  661. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libadd_rms_norm_quant_acme_impl.so +0 -0
  662. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libapply_rotary_pos_emb_310p_old_impl.so +0 -0
  663. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libapply_rotary_pos_emb_old_impl.so +0 -0
  664. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libreshape_and_cache_nz_impl.so +0 -0
  665. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/lib/libreshape_and_cache_nz_old_impl.so +0 -0
  666. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/AcmeMatMulPostFusionMixTactic/acme_matmul_postfusion_mix.json +0 -19
  667. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/AcmeMatMulPostFusionMixTactic/acme_matmul_postfusion_mix.o +0 -0
  668. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/AcmeMatMulPostFusionMixTactic/acme_matmul_postfusion_mix_mix_aic_0.o +0 -0
  669. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/AcmeMatMulPostFusionMixTactic/acme_matmul_postfusion_mix_mix_aiv_0.o +0 -0
  670. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/AcmeMultiWeightMatMulPostFusionMixTactic/acme_multi_weight_matmul_postfusion_mix.json +0 -19
  671. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/AcmeMultiWeightMatMulPostFusionMixTactic/acme_multi_weight_matmul_postfusion_mix.o +0 -0
  672. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/AcmeMultiWeightMatMulPostFusionMixTactic/acme_multi_weight_matmul_postfusion_mix_mix_aic_0.o +0 -0
  673. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/AcmeMultiWeightMatMulPostFusionMixTactic/acme_multi_weight_matmul_postfusion_mix_mix_aiv_0.o +0 -0
  674. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/flash_attention_score/flash_attention_score_bf16_bnsd_full_mix.o +0 -0
  675. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/flash_attention_score/flash_attention_score_bf16_bnsd_tri_mix.o +0 -0
  676. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/flash_attention_score/flash_attention_score_bf16_bsh_full_mix.o +0 -0
  677. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/flash_attention_score/flash_attention_score_bf16_bsh_tri_mix.o +0 -0
  678. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/flash_attention_score/flash_attention_score_fp16_bnsd_full_mix.o +0 -0
  679. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/flash_attention_score/flash_attention_score_fp16_bnsd_tri_mix.o +0 -0
  680. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/flash_attention_score/flash_attention_score_fp16_bsh_full_mix.o +0 -0
  681. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/flash_attention_score/flash_attention_score_fp16_bsh_tri_mix.o +0 -0
  682. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/paged_attention/paged_attention_bf16_bnsd_mix.o +0 -0
  683. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/paged_attention/paged_attention_bf16_bsh_mix.o +0 -0
  684. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/paged_attention/paged_attention_fp16_bnsd_mix.o +0 -0
  685. mindspore/lib/plugin/ascend/ms_kernels_internal/internal_kernel/op_kernels/ascend910b/paged_attention/paged_attention_fp16_bsh_mix.o +0 -0
  686. mindspore/profiler/envprofiling.py +0 -254
  687. mindspore/profiler/profiling.py +0 -1926
  688. {mindspore-2.4.10.dist-info → mindspore-2.5.0.dist-info}/WHEEL +0 -0
  689. {mindspore-2.4.10.dist-info → mindspore-2.5.0.dist-info}/top_level.txt +0 -0
@@ -26,7 +26,7 @@ from mindspore.ops import functional as F
26
26
  from mindspore.ops.operations import nn_ops as NN_OPS
27
27
  from mindspore.ops.operations import _sequence_ops as seq
28
28
  import mindspore.common.dtype as mstype
29
- from mindspore.ops.function.math_func import logsumexp
29
+ from mindspore.ops.function.math_func import logsumexp, div
30
30
  from mindspore.ops.function.random_func import _get_seed, _set_prim_op_user_data
31
31
  from mindspore.common.tensor import Tensor
32
32
  from mindspore._c_expression import Tensor as Tensor_
@@ -40,22 +40,29 @@ from mindspore.ops.operations.nn_ops import ChannelShuffle
40
40
  from mindspore.ops.operations.nn_ops import TripletMarginLoss
41
41
  from mindspore.ops.operations._sequence_ops import TupleToTensor, TensorToTuple, ListToTensor
42
42
  from mindspore.common.api import _function_forbid_reuse
43
- from mindspore.ops.auto_generate import log_softmax, dense, prelu, celu, relu, fast_gelu, silu, elu, sigmoid, relu6, \
43
+ from mindspore.ops.auto_generate import log_softmax, dense, prelu, celu, fast_gelu, silu, elu, sigmoid, relu6, \
44
44
  softmax_impl, swiglu, logsigmoid_op
45
- from mindspore.ops.auto_generate import group_norm_op, rms_norm, layer_norm_ext_op, batch_norm_ext_op, mse_loss_ext
45
+ from mindspore.ops.auto_generate import relu_op, inplace_relu_op
46
+ from mindspore.ops.auto_generate import group_norm_op, rms_norm, add_rms_norm, layer_norm_ext_op, batch_norm_ext_op,\
47
+ mse_loss_ext
46
48
  from mindspore.ops.auto_generate import (reflection_pad_1d_op, reflection_pad_2d_op, add_layernorm_v2_op,
47
49
  reflection_pad_3d_op, # pylint: disable=W0611
48
50
  replication_pad_1d_op, replication_pad_2d_op, replication_pad_3d_op,
49
51
  constant_pad_nd_op, dropout_ext_op, reverse_v2_impl, avg_pool2d_op,
50
52
  upsample_nearest1d_op, upsample_nearest2d_op, upsample_nearest3d_op,
51
53
  upsample_linear1d_op, upsample_bilinear2d_op, upsample_bicubic2d_op,
52
- upsample_trilinear3d_impl, fill_scalar_op, floor_op)
53
- from mindspore.ops.auto_generate.gen_ops_prim import embedding_op, Convolution, ConstantPadND, MaxPoolWithIndices, \
54
- MaxPoolWithMask
54
+ upsample_trilinear3d_impl, fill_scalar_op, floor_op, nllloss_2d_op,
55
+ masked_fill_op, masked_select, ones, flatten_ext, conv_transpose2d)
56
+ from mindspore.ops.auto_generate.gen_ops_prim import embedding_op, MaxPoolWithIndices, \
57
+ PromptFlashAttention, MaxPoolWithMask
58
+ from mindspore.ops.auto_generate.gen_ops_prim import conv3d_ext_op, conv3d_padding_op, conv2d_ext_op, conv2d_padding_op
55
59
  from mindspore.common.generator import default_generator
56
60
  from mindspore.ops.auto_generate import hardshrink, hardsigmoid, hardswish
57
61
  from mindspore.ops.auto_generate import softshrink
58
62
  from mindspore.ops.auto_generate import adaptive_avg_pool2d_ext_op
63
+ from mindspore.ops.auto_generate.pyboost_inner_prim import nllloss_impl
64
+ from mindspore.ops.function.array_func import gather_ext
65
+ from mindspore.ops.operations.manually_defined import flash_attention_score
59
66
 
60
67
  abs_ = P.Abs()
61
68
  add_ = P.Add()
@@ -111,7 +118,7 @@ check_int_const = validator.check_is_int
111
118
  check_non_negative_float_const = validator.check_non_negative_float
112
119
  check_string_const = constexpr(validator.check_string)
113
120
 
114
- generator_step_ = Tensor(1, mstype.int64)
121
+ generator_step_ = Tensor(12, mstype.int64)
115
122
 
116
123
 
117
124
  def adaptive_avg_pool2d(input, output_size):
@@ -247,11 +254,11 @@ def adaptive_avg_pool2d_ext(input, output_size):
247
254
  .. math::
248
255
 
249
256
  out\_shape = \begin{cases}
250
- input\_shape[-2] + output\_size[1], & \text{if } output\_size text{ is (None, w);}\\
251
- output\_size[0] + input\_shape[-1], & \text{if } output\_size text{ is (h, None);}\\
252
- input\_shape[-2:], & \text{if } output\_size text{ is (None, None);}\\
253
- (h, h), & \text{if } output\_size text{ is h;}\\
254
- (h, w), & \text{if } output\_size text{ is (h, w)}
257
+ input\_shape[-2] + output\_size[1], & \text{if } output\_size \text{ is (None, w);}\\
258
+ output\_size[0] + input\_shape[-1], & \text{if } output\_size \text{ is (h, None);}\\
259
+ input\_shape[-2:], & \text{if } output\_size \text{ is (None, None);}\\
260
+ (h, h), & \text{if } output\_size \text{ is h;}\\
261
+ (h, w), & \text{if } output\_size \text{ is (h, w)}
255
262
  \end{cases}
256
263
 
257
264
  Raises:
@@ -620,13 +627,13 @@ def avg_pool2d_ext(input, kernel_size, stride=None, padding=0, ceil_mode=False,
620
627
  outputs regional average in the :math:`(H_{in}, W_{in})` -dimension.
621
628
  Given kernel size :math:`(kH, kW)` and `stride` , the operation is as follows.
622
629
 
623
- .. note::
624
- On the Atlas platform, when calculating the input, the precision is degraded from float32 to float16.
625
-
626
630
  .. math::
627
631
  \text{output}(N_i, C_j, h, w) = \frac{1}{kH * kW} \sum_{m=0}^{kH-1} \sum_{n=0}^{kW-1}
628
632
  \text{input}(N_i, C_j, stride[0] \times h + m, stride[1] \times w + n)
629
633
 
634
+ .. note::
635
+ On the Atlas platform, when calculating the input, the precision is degraded from float32 to float16.
636
+
630
637
  Args:
631
638
  input (Tensor): Tensor of shape :math:`(N, C, H_{in}, W_{in})` or :math:`(C, H_{in}, W_{in})`.
632
639
  kernel_size (Union[int, tuple[int], list[int]]): The size of kernel used to take the average value.
@@ -1473,7 +1480,7 @@ def dropout(input, p=0.5, training=True, seed=None):
1473
1480
 
1474
1481
 
1475
1482
  @_function_forbid_reuse
1476
- def dropout_ext(input, p=0.5, training=True):
1483
+ def dropout_ext(input, p=0.5, training=True, inplace=False):
1477
1484
  r"""
1478
1485
  During training, randomly zeroes some of the elements of the input tensor
1479
1486
  with probability `p` from a Bernoulli distribution. It plays the role of reducing neuron correlation and
@@ -1482,10 +1489,12 @@ def dropout_ext(input, p=0.5, training=True):
1482
1489
 
1483
1490
  Args:
1484
1491
  input (Tensor): The input Tensor of shape :math:`(*, N)`.
1485
- p (float): The dropping rate of input neurons, between 0 and 1, e.g. `p` = 0.1,
1492
+ p (float, optional): The dropping rate of input neurons, between 0 and 1, e.g. `p` = 0.1,
1486
1493
  means dropping out 10% of input neurons. Default: ``0.5`` .
1487
- training (bool): Apply dropout if it is ``True`` , if it is ``False`` , the input is returned directly,
1488
- and `p` is invalid. Default: ``True``.
1494
+ training (bool, optional): Apply dropout if it is ``True`` ,
1495
+ if it is ``False`` , the input is returned directly,
1496
+ and `p` is invalid. Default: ``True`` .
1497
+ inplace (bool, optional): If set to ``True`` , will do this operation in-place. Default: ``False`` .
1489
1498
 
1490
1499
  Returns:
1491
1500
  - **output** (Tensor) - Zeroed tensor, with the same shape and data type as `input`.
@@ -1506,10 +1515,14 @@ def dropout_ext(input, p=0.5, training=True):
1506
1515
  (2, 2)
1507
1516
  """
1508
1517
  check_bool_const(training, "training", "dropout_ext")
1509
- if training is False:
1518
+ check_bool_const(inplace, "inplace", "dropout_ext")
1519
+ if not training:
1510
1520
  return input
1511
1521
  seed, offset = default_generator._step(generator_step_) # pylint: disable=protected-access
1512
1522
  out, _ = dropout_ext_op(input, p, seed, offset)
1523
+ if inplace:
1524
+ input.copy_(out)
1525
+ return input
1513
1526
  return out
1514
1527
 
1515
1528
 
@@ -2415,8 +2428,8 @@ def interpolate(input,
2415
2428
  >>> input = Tensor([[[1, 2, 3], [4, 5, 6]]], mindspore.float32)
2416
2429
  >>> output = ops.interpolate(input, size=(6,), mode='nearest')
2417
2430
  >>> print(output)
2418
- [[[1. 1. 2. 2. 3. 3.]
2419
- [4. 4. 5. 5. 6. 6.]]]
2431
+ [[[1. 1. 2. 2. 3. 3.]
2432
+ [4. 4. 5. 5. 6. 6.]]]
2420
2433
  """
2421
2434
 
2422
2435
  def run_nearest(x, size, align_corners=None, scale_factor=None):
@@ -2667,7 +2680,7 @@ def interpolate_ext(input,
2667
2680
  r"""
2668
2681
  Samples the input Tensor to the given size or scale_factor by using one of the interpolate algorithms.
2669
2682
 
2670
- .. warnings:
2683
+ .. warning::
2671
2684
  This is an experimental API that is subject to change or deletion.
2672
2685
 
2673
2686
  .. note::
@@ -2675,7 +2688,7 @@ def interpolate_ext(input,
2675
2688
  is not supported.
2676
2689
  - In 'nearest' mode, there may exist precision problem in the scenarios, where input is 3-D/4-D Tensor
2677
2690
  and the image is scaled by scale_factor.
2678
- - `mode` and `scale_factor` should be constants.
2691
+ - `mode` and `recompute_scale_factor` should be constants.
2679
2692
 
2680
2693
  Args:
2681
2694
  input (Tensor): Tensor to be resized.
@@ -2690,9 +2703,11 @@ def interpolate_ext(input,
2690
2703
  after removing the first two dimensions N, C.
2691
2704
  One and only one of size and scale_factor can be set to None. Default: ``None`` .
2692
2705
  mode (str): The sampling algorithm.
2693
- One of 'nearest', 'linear' (3D only), 'bilinear' (4D only), 'trilinear' (5D only), and 'bicubic' (4D only).
2706
+ One of 'nearest', 'linear' (3D only),
2707
+ 'bilinear' (4D only), 'trilinear' (5D only), and 'bicubic' (4D only).
2694
2708
  Default: ``"nearest"`` .
2695
- align_corners (bool): Whether to use corner alignment for coordinate mapping. Assuming a transformation is
2709
+ align_corners (bool, optional): Whether to use corner alignment for coordinate mapping.
2710
+ Assuming a transformation is
2696
2711
  applied to the input Tensor along the x-axis, the specific calculation formula is as follows:
2697
2712
 
2698
2713
  .. code-block::
@@ -2771,12 +2786,12 @@ def interpolate_ext(input,
2771
2786
 
2772
2787
  Examples:
2773
2788
  >>> import mindspore
2774
- >>> from mindspore import Tensor, mint
2789
+ >>> from mindspore import Tensor, ops
2775
2790
  >>> input = Tensor([[[1, 2, 3], [4, 5, 6]]], mindspore.float32)
2776
- >>> output = mint.interpolate(input, size=(6,), mode='nearest')
2791
+ >>> output = ops.interpolate_ext(input, size=(6,), mode='nearest')
2777
2792
  >>> print(output)
2778
- [[[1. 1. 2. 2. 3. 3.]
2779
- [4. 4. 5. 5. 6. 6.]]]
2793
+ [[[1. 1. 2. 2. 3. 3.]
2794
+ [4. 4. 5. 5. 6. 6.]]]
2780
2795
  """
2781
2796
 
2782
2797
  def run_nearest(x, size, align_corners=None, scale_factor=None):
@@ -3030,8 +3045,6 @@ def softmax_ext(input, dim=None, dtype=None):
3030
3045
  input (Tensor): Tensor of shape :math:`(N, *)`, where :math:`*` means, any number of
3031
3046
  additional dimensions.
3032
3047
  dim (int, optional): The dim to perform the Softmax operation. Default: ``None`` .
3033
-
3034
- Keyword Args:
3035
3048
  dtype (:class:`mindspore.dtype`, optional): When set, `input` will be converted to the specified type,
3036
3049
  `dtype`, before execution, and dtype of returned Tensor will also be `dtype`. Default: ``None`` .
3037
3050
 
@@ -3631,7 +3644,7 @@ def _replication_pad(input, pad):
3631
3644
  return out
3632
3645
 
3633
3646
 
3634
- def pad_ext(input, pad, mode='constant', value=0.0):
3647
+ def pad_ext(input, pad, mode='constant', value=None):
3635
3648
  r"""
3636
3649
  Pads the input tensor according to the pad.
3637
3650
 
@@ -3679,7 +3692,7 @@ def pad_ext(input, pad, mode='constant', value=0.0):
3679
3692
 
3680
3693
  value (Union[int, float, None], optional): Valid only in ``'constant'`` mode.
3681
3694
  Set the padding value in ``'constant'`` mode. If the value is None, 0 is used as the default padding value.
3682
- Default: ``0.0`` .
3695
+ Default: ``None`` .
3683
3696
 
3684
3697
  Returns:
3685
3698
  Tensor, the tensor after padding.
@@ -3689,7 +3702,7 @@ def pad_ext(input, pad, mode='constant', value=0.0):
3689
3702
  TypeError: If `input` is not a Tensor.
3690
3703
  ValueError: If length of `pad` is not even.
3691
3704
  ValueError: If length of `pad` is greater than 6.
3692
- ValueError: If `mode` is not ``'constant'`` and `value` not ``None``.
3705
+ ValueError: If `mode` is not ``'constant'`` and `value` is neither ``None`` nor 0.
3693
3706
 
3694
3707
  Supported Platforms:
3695
3708
  ``Ascend``
@@ -3717,7 +3730,7 @@ def pad_ext(input, pad, mode='constant', value=0.0):
3717
3730
  value = 0 if value is None else value
3718
3731
  out = constant_pad_nd_op(input, pad, value)
3719
3732
  else:
3720
- if value != 0.0:
3733
+ if value is not None and value != 0:
3721
3734
  raise ValueError(f"Padding mode {mode} doesn\'t take in value argument.")
3722
3735
  if mode == "circular":
3723
3736
  out = _circular_pad(input, pad)
@@ -3897,9 +3910,9 @@ def rrelu(input, lower=1.0 / 8, upper=1.0 / 3):
3897
3910
  `Empirical Evaluation of Rectified Activations in Convolution Network <https://arxiv.org/pdf/1505.00853.pdf>`_ .
3898
3911
 
3899
3912
  Args:
3900
- input (Tensor): The input of rrelu is a Tensor of any dimension.
3901
- lower (Union[int, float]): Slope of the activation function at x < 0. Default: ``1.0 / 8`` .
3902
- upper (Union[int, float]): Slope of the activation function at x < 0. Default: ``1.0 / 3`` .
3913
+ input (Tensor): The input of rrelu is a Tensor of any dimension.
3914
+ lower (Union[int, float]): Slope of the activation function at data of `input` < 0. Default: ``1.0 / 8`` .
3915
+ upper (Union[int, float]): Slope of the activation function at data of `input` < 0. Default: ``1.0 / 3`` .
3903
3916
 
3904
3917
  Returns:
3905
3918
  Tensor, after rrelu, has the same type and shape as the `input`.
@@ -4271,6 +4284,303 @@ def _nll_loss(inputs, target, target_dim=-1, weight=None, ignore_index=None, red
4271
4284
  return loss
4272
4285
 
4273
4286
 
4287
+ def nll_loss_ext(input, target, weight=None, ignore_index=-100, reduction='mean'):
4288
+ r"""
4289
+ Gets the negative log likelihood loss between input and target.
4290
+
4291
+ The nll loss with reduction=none can be described as:
4292
+
4293
+ .. math::
4294
+
4295
+ \ell(x, t)=L=\left\{l_{1}, \ldots, l_{N}\right\}^{\top},
4296
+ \quad l_{n}=-w_{t_{n}} x_{n, t_{n}},
4297
+ \quad w_{c}=\text { weight }[c] \cdot \mathbb{1}
4298
+ \{c \not= \text{ignore_index}\},
4299
+
4300
+ where :math:`x` is the input, :math:`t` is the target, :math:`w` is the weight,
4301
+ :math:`N` is the batch size, :math:`c` belonging to :math:`[0, C-1]` is class index,
4302
+ where :math:`C` is the number of classes.
4303
+
4304
+ If `reduction` is not ``None`` (default ``'mean'``), then
4305
+
4306
+ .. math::
4307
+
4308
+ \ell(x, t)=\left\{\begin{array}{ll}
4309
+ \sum_{n=1}^{N} \frac{1}{\sum_{n=1}^{N} w_{t n}} l_{n}, & \text { if reduction }=\text { 'mean', } \\
4310
+ \sum_{n=1}^{N} l_{n}, & \text { if reduction }=\text { 'sum' }
4311
+ \end{array}\right.
4312
+
4313
+ .. warning::
4314
+ This is an experimental API that is subject to change or deletion.
4315
+
4316
+ Args:
4317
+ input (Tensor): :math:`(N)` or :math:`(N, C)` where `C = number of classes` , `N = batch size` ,
4318
+ or :math:`(N, C, d_1, d_2, ..., d_K)` (for high-dimensional data).
4319
+ `input` is expected to be log-probabilities.
4320
+ Data type only supports float32 or float16 or bfloat16(only supported by
4321
+ Atlas A2 training series products).
4322
+ target (Tensor): :math:`()` or :math:`(N)` ,
4323
+ where the value range is :math:`[0, C-1]`, or :math:`(N, d_1, d_2, ..., d_K)` for
4324
+ high-dimensional loss, data type must be int32 or int64 or uint8.
4325
+ weight (Tensor, optional): A rescaling weight applied to the loss of each batch element.
4326
+ If not None, the shape is :math:`(C,)`.
4327
+ The data type must be float16 or float32 or bfloat16(only supported by Atlas A2 training series products).
4328
+ It should have the same data type as `input` . Default: ``'None'`` .
4329
+ ignore_index (int, optional): Specifies a target value that is ignored
4330
+ and does not contribute to the input gradient. Default: ``-100`` .
4331
+ reduction (str, optional): Apply specific reduction method to the output: ``'none'`` , ``'mean'`` ,
4332
+ ``'sum'`` . Default: ``'mean'`` .
4333
+
4334
+ - ``'none'``: no reduction will be applied.
4335
+ - ``'mean'``: compute and return the weighted mean of elements in the output.
4336
+ - ``'sum'``: the output elements will be summed.
4337
+
4338
+ Returns:
4339
+ Tensor. The data type is the same as that of `input`.
4340
+
4341
+ Supported Platforms:
4342
+ ``Ascend``
4343
+
4344
+ Examples:
4345
+ >>> import mindspore
4346
+ >>> import numpy as np
4347
+ >>> from mindspore import Tensor, mint
4348
+ >>> input = mindspore.Tensor(np.random.randn(3, 5), mindspore.float32)
4349
+ >>> target = mindspore.Tensor(np.array([1, 0, 4]), mindspore.int32)
4350
+ >>> output = mint.nn.functional.nll_loss(input, target)
4351
+
4352
+ """
4353
+ return _nllloss_nd(input, target, weight, ignore_index, reduction)
4354
+
4355
+
4356
+ def _nllloss_nd(input, target, weight=None, ingore_index=-100, reduction='mean'):
4357
+ """nllloss_nd inner function"""
4358
+ input_dim = input.ndim
4359
+ class_dim = 0 if input_dim == 1 else 1
4360
+ n_classes = input.shape[class_dim]
4361
+ if weight is None:
4362
+ weight = ones(n_classes, input.dtype)
4363
+ if input_dim < 1:
4364
+ raise ValueError(f"input dim should be less than 1, but got {input_dim}")
4365
+ if input_dim != 1 and input.shape[0] != target.shape[0]:
4366
+ raise ValueError(f"input bacth_size should be equal to target batch_size, but got {input.shape[0]} and "
4367
+ f"{target.shape[0]}")
4368
+ if input_dim == 1 or input_dim == 2:
4369
+ return nllloss_impl(input, target, weight, reduction, ingore_index)[0]
4370
+ if input_dim == 4:
4371
+ return nllloss_2d_op(input, target, weight, reduction, ingore_index)[0]
4372
+ # input_dim==3 or input_dim>4
4373
+ n = input.shape[0]
4374
+ c = input.shape[1]
4375
+ out_size = (n,) + input.shape[2:]
4376
+ if input.size > 0:
4377
+ input = input.view((n, c, 1, -1))
4378
+ else:
4379
+ input = input.view((n, c, 0, 0))
4380
+ if target.size > 0:
4381
+ target = target.view((n, 1, -1))
4382
+ else:
4383
+ target = target.view((n, 0, 0))
4384
+ if reduction != 'none':
4385
+ return nllloss_2d_op(input, target, weight, reduction, ingore_index)[0]
4386
+ ret = nllloss_2d_op(input, target, weight, reduction, ingore_index)[0]
4387
+ return ret.view(out_size)
4388
+
4389
+
4390
+ def _cross_entropy_for_probabilities(input, target, weight, reduction, label_smoothing, class_dim, n_classes):
4391
+ """cross_entropy inner function for class probabilities"""
4392
+ if input.shape != target.shape:
4393
+ raise ValueError("For cross_entropy that target is probabilities, input shape should equal to target shape.")
4394
+ if label_smoothing > 0.0:
4395
+ target = target * (1 - label_smoothing) + label_smoothing / n_classes
4396
+ loss = input * target
4397
+ if weight is not None:
4398
+ weight_ = weight
4399
+ ori_shape = loss.shape
4400
+ if input.ndim > 2:
4401
+ loss = loss.view(ori_shape[:2] + (-1,))
4402
+ weight_ = weight_.view(1, -1, 1)
4403
+ loss = loss * weight_
4404
+ loss = loss.view(ori_shape)
4405
+ if reduction == "mean":
4406
+ return -div(loss.sum(), (input.size / n_classes))
4407
+ if reduction == "sum":
4408
+ return -loss.sum()
4409
+ if reduction == "none":
4410
+ return -loss.sum(class_dim)
4411
+ raise ValueError(f"redution value {reduction} not valid.")
4412
+
4413
+
4414
+ def _cross_entropy_for_class_indices(input, target, weight, ingore_index, reduction, label_smoothing, class_dim,
4415
+ n_classes):
4416
+ """cross_entropy inner function for class indices"""
4417
+ nllloss = _nllloss_nd(input, target, weight, ingore_index, reduction)
4418
+ if label_smoothing > 0.0:
4419
+ if weight is not None:
4420
+ weight_ = weight
4421
+ input_ = input
4422
+ ori_shape = input.shape
4423
+ if input.ndim > 2:
4424
+ input_ = input.view(ori_shape[:2] + (-1,))
4425
+ weight_ = weight_.view(1, -1, 1)
4426
+ loss = input_ * weight_
4427
+ loss = loss.view(ori_shape)
4428
+ smooth_loss = -loss.sum(class_dim)
4429
+ else:
4430
+ smooth_loss = -input.sum(class_dim)
4431
+ ignore_mask = ops.eq(target, ingore_index)
4432
+ smooth_loss = masked_fill_op(smooth_loss, ignore_mask, 0)
4433
+ if reduction == "mean":
4434
+ true_mask = ~ignore_mask
4435
+ if weight is not None:
4436
+ weight_sum = gather_ext(weight, 0, flatten_ext(masked_select(target, true_mask))).sum()
4437
+ if weight_sum == 0:
4438
+ ret = smooth_loss.sum()
4439
+ else:
4440
+ ret = smooth_loss.sum() / weight_sum
4441
+ else:
4442
+ weight_sum = true_mask.sum()
4443
+ if weight_sum == 0:
4444
+ ret = smooth_loss.sum()
4445
+ else:
4446
+ ret = smooth_loss.sum() / weight_sum
4447
+ elif reduction == "sum":
4448
+ ret = smooth_loss.sum()
4449
+ elif reduction == "none":
4450
+ ret = smooth_loss
4451
+ else:
4452
+ raise ValueError(f"redution value {reduction} not valid.")
4453
+ return (1 - label_smoothing) * nllloss + ret * (label_smoothing / n_classes)
4454
+ return nllloss
4455
+
4456
+
4457
+ def cross_entropy_ext(input, target, weight=None, ingore_index=-100, reduction='mean', label_smoothing=0.0):
4458
+ r"""
4459
+ The cross entropy loss between input and target.
4460
+
4461
+ The cross entropy supports two kind of targets:
4462
+
4463
+ - Class indices (int) in the range :math:`[0, C)` where :math:`C` is the number of classes,
4464
+ the loss with reduction=none can be described as:
4465
+
4466
+ .. math::
4467
+
4468
+ \ell(x, y) = L = \{l_1,\dots,l_N\}^\top, \quad
4469
+ l_n = - w_{y_n} \log \frac{\exp(x_{n,y_n})}{\sum_{c=1}^C \exp(x_{n,c})}
4470
+ \cdot \mathbb{1}\{y_n \not= \text{ignore_index}\}
4471
+
4472
+ where :math:`x` is the inputs, :math:`y` is the target, :math:`w` is the weight, :math:`N` is the batch size,
4473
+ :math:`c` belonging to :math:`[0, C-1]` is class index, where :math:`C` is the number of classes.
4474
+
4475
+ If `reduction` is not ``None`` (default ``'mean'`` ), then
4476
+
4477
+ .. math::
4478
+
4479
+ \ell(x, y) = \begin{cases}
4480
+ \sum_{n=1}^N \frac{1}{\sum_{n=1}^N w_{y_n} \cdot \mathbb{1}\{y_n \not= \text{ignore_index}\}} l_n, &
4481
+ \text{if reduction} = \text{'mean',}\\
4482
+ \sum_{n=1}^N l_n, &
4483
+ \text{if reduction} = \text{'sum'.}
4484
+ \end{cases}
4485
+
4486
+ - Probabilities (float) for each class, useful when labels beyond a single class per minibatch item
4487
+ are required, the loss with reduction=none can be described as:
4488
+
4489
+ .. math::
4490
+
4491
+ \ell(x, y) = L = \{l_1,\dots,l_N\}^\top, \quad
4492
+ l_n = - \sum_{c=1}^C w_c \log \frac{\exp(x_{n,c})}{\sum_{i=1}^C \exp(x_{n,i})} y_{n,c}
4493
+
4494
+ where :math:`x` is the inputs, :math:`y` is the target, :math:`w` is the weight, N is the batch size,
4495
+ :math:`c` belonging to :math:`[0, C-1]` is class index, where :math:`C` is the number of classes.
4496
+
4497
+ If `reduction` is not ``None`` (default ``'mean'`` ), then
4498
+
4499
+ .. math::
4500
+
4501
+ \ell(x, y) = \begin{cases}
4502
+ \frac{\sum_{n=1}^N l_n}{N}, &
4503
+ \text{if reduction} = \text{'mean',}\\
4504
+ \sum_{n=1}^N l_n, &
4505
+ \text{if reduction} = \text{'sum'.}
4506
+ \end{cases}
4507
+
4508
+ .. warning::
4509
+ This is an experimental API that is subject to change or deletion.
4510
+
4511
+ Note:
4512
+ Dynamic shape, dynamic rank and variable constant input are not supported in `strict graph mode
4513
+ (jit_syntax_level=mindspore.STRICT)
4514
+ <https://www.mindspore.cn/docs/en/master/model_train/program_form/static_graph.html>`_.
4515
+
4516
+ Args:
4517
+ input (Tensor): :math:`(N)` or :math:`(N, C)` where `C = number of classes` or :math:`(N, C, H, W)`
4518
+ in case of 2D Loss, or :math:`(N, C, d_1, d_2, ..., d_K)`.
4519
+ `input` is expected to be log-probabilities, data type must be float16 or float32 or bfloat16(only supported
4520
+ by Atlas A2 training series products).
4521
+ target (Tensor): For class indices, tensor of shape :math:`()`, :math:`(N)` or
4522
+ :math:`(N, d_1, d_2, ..., d_K)` , data type must be int32 or int64. For probabilities, tensor of shape
4523
+ :math:`(N,)` , :math:`(N, C)` or :math:`(N, C, d_1, d_2, ..., d_K)` , data type must be float16 or float32
4524
+ or bfloat16(only supported by Atlas A2 training series products).
4525
+ weight (Tensor, optional): A rescaling weight applied to the loss of each batch element.
4526
+ If not None, the shape is :math:`(C,)`, data type must be float16 or float32 or bfloat16(only supported by
4527
+ Atlas A2 training series products). Default: ``None`` .
4528
+ ignore_index (int, optional): Specifies a target value that is ignored and does not contribute to the input
4529
+ gradient. Only valid in class indices, please set it to a negative number in probabilities.
4530
+ Default: ``-100`` .
4531
+ reduction (str, optional): Apply specific reduction method to the output: ``'none'`` , ``'mean'`` ,
4532
+ ``'sum'`` . Default: ``'mean'`` .
4533
+
4534
+ - ``'none'``: no reduction will be applied.
4535
+ - ``'mean'``: compute and return the weighted mean of elements in the output.
4536
+ - ``'sum'``: the output elements will be summed.
4537
+
4538
+ label_smoothing (float, optional): Label smoothing values, a regularization tool used to prevent the model
4539
+ from overfitting when calculating Loss. The value range is [0.0, 1.0]. Default: ``0.0`` .
4540
+
4541
+ Returns:
4542
+ Tensor, the data type is the same as `input` .
4543
+
4544
+ Supported Platforms:
4545
+ ``Ascend``
4546
+
4547
+ Examples:
4548
+ >>> import mindspore as ms
4549
+ >>> from mindspore import ops, Tensor
4550
+ >>> import numpy as np
4551
+ >>> # Case 1: Indices labels
4552
+ >>> inputs = Tensor(np.random.randn(3, 5), ms.float32)
4553
+ >>> target = Tensor(np.array([1, 0, 4]), ms.int32)
4554
+ >>> output = ops.cross_entropy_ext(inputs, target)
4555
+ >>> # Case 2: Probability labels
4556
+ >>> inputs = Tensor(np.random.randn(3, 5), ms.float32)
4557
+ >>> target = Tensor(np.random.randn(3, 5), ms.float32)
4558
+ >>> output = ops.cross_entropy_ext(inputs, target)
4559
+ """
4560
+ if not isinstance(input, Tensor) or not isinstance(target, Tensor):
4561
+ raise TypeError(
4562
+ f"For cross_entropy, input and target must be Tensor, but got input:{type(input)}, target:{type(target)}.")
4563
+ if weight is not None and not isinstance(weight, Tensor):
4564
+ raise TypeError(f"For cross_entropy, weight must be Tensor or None, but got {type(weight)}.")
4565
+ if label_smoothing < 0.0 or label_smoothing > 1.0:
4566
+ raise ValueError(f"For cross_entropy, label_smoothing must in [0, 1]")
4567
+ if input.ndim == 0 or input.shape[0] == 0:
4568
+ raise ValueError(f"For cross_entropy, input don't support 0-dim and shape[0].")
4569
+ class_dim = 0 if input.ndim == 1 else 1
4570
+ n_classes = input.shape[class_dim]
4571
+ input = log_softmax_ext(input, class_dim, dtype=input.dtype)
4572
+ # for probabilities
4573
+ target_dtype = target.dtype
4574
+ if isinstance(target_dtype, type(mstype.tensor_type)):
4575
+ target_dtype = target_dtype.element_type()
4576
+ if target_dtype in mstype.float_type:
4577
+ return _cross_entropy_for_probabilities(input, target, weight, reduction, label_smoothing, class_dim,
4578
+ n_classes)
4579
+ # for class indices
4580
+ return _cross_entropy_for_class_indices(input, target, weight, ingore_index, reduction, label_smoothing,
4581
+ class_dim, n_classes)
4582
+
4583
+
4274
4584
  def l1_loss(input, target, reduction='mean'):
4275
4585
  r"""
4276
4586
  Calculate the mean absolute error between the `input` value and the `target` value.
@@ -4348,8 +4658,8 @@ def smooth_l1_loss(input, target, beta=1.0, reduction='none'):
4348
4658
  .. math::
4349
4659
  L_{i} =
4350
4660
  \begin{cases}
4351
- \frac{0.5 (x_i - y_i)^{2}}{\beta}, & \text{if } |x_i - y_i| < \beta \\
4352
- |x_i - y_i| - 0.5 * \beta, & \text{otherwise. }
4661
+ \frac{0.5 (x_i - y_i)^{2}}{\text{beta}}, & \text{if } |x_i - y_i| < \text{beta} \\
4662
+ |x_i - y_i| - 0.5 * \text{beta}, & \text{otherwise. }
4353
4663
  \end{cases}
4354
4664
 
4355
4665
  If `reduction` is not `none`, then:
@@ -4364,12 +4674,26 @@ def smooth_l1_loss(input, target, beta=1.0, reduction='none'):
4364
4674
  Here :math:`\text{beta}` controls the point where the loss function changes from quadratic to linear.
4365
4675
  :math:`\text{beta}>0` , its default value is ``1.0`` . :math:`N` is the batch size.
4366
4676
 
4677
+ .. warning::
4678
+ This API has poor performance on CPU and it is recommended to run it on the Ascend/GPU.
4679
+
4367
4680
  Args:
4368
- input (Tensor): Tensor of shape :math:`(N, *)` where :math:`*` means, any number of additional dimensions.
4369
- Data type is float16, float32 or float64.
4370
- target (Tensor): Ground truth data, tensor of shape :math:`(N, *)`, same shape and dtype as the `input`.
4371
- beta (float): A parameter used to control the point where the function will change between
4372
- L1 to L2 loss. The value should be greater than zero. Default: ``1.0`` .
4681
+ input (Tensor): Tensor of shape :math:`(N, *)` where :math:`*` means,
4682
+ any number of additional dimensions.Supported dtypes:
4683
+
4684
+ - Ascend: float16, float32, bfloat16.
4685
+ - CPU/GPU: float16, float32, float64.
4686
+ target (Tensor): Ground truth data, tensor of shape :math:`(N, *)`.
4687
+
4688
+ - CPU/Ascend: has the same shape as the `input`, `target` and `input`
4689
+ comply with the implicit type conversion rules to make the data types consistent.
4690
+ - GPU: has the same shape and dtype as the `input`.
4691
+
4692
+ beta (number, optional): A parameter used to control the point where the function will change between
4693
+ L1 to L2 loss. Default: ``1.0`` .
4694
+
4695
+ - Ascend: The value should be equal to or greater than zero.
4696
+ - CPU/GPU: The value should be greater than zero.
4373
4697
  reduction (str, optional): Apply specific reduction method to the output: ``'none'`` , ``'mean'`` ,
4374
4698
  ``'sum'`` . Default: ``'none'`` .
4375
4699
 
@@ -4379,14 +4703,15 @@ def smooth_l1_loss(input, target, beta=1.0, reduction='none'):
4379
4703
 
4380
4704
  Returns:
4381
4705
  Tensor, if `reduction` is ``'none'``, then output is a tensor with the same shape as `input`.
4382
- Otherwise, the shape of output tensor is :math:`(1,)`.
4706
+ Otherwise, the shape of output tensor is :math:`()`.
4383
4707
 
4384
4708
  Raises:
4385
- TypeError: If `beta` is not a float.
4386
- ValueError: If `reduction` is not one of ``'none'``, ``'mean'``, ``'sum'``.
4387
- TypeError: If dtype of `input` or `target` is not one of float16, float32, float64.
4388
- ValueError: If `beta` is less than or equal to 0.
4709
+ TypeError: If input `input`, `target` is not Tensor.
4710
+ RuntimeError: If dtype of `input` or `target` is not one of float16, float32, float64, bfloat16.
4389
4711
  ValueError: If shape of `input` is not the same as `target`.
4712
+ ValueError: If `reduction` is not one of ``'none'``, ``'mean'``, ``'sum'``.
4713
+ TypeError: If `beta` is not a float, int or bool.
4714
+ RuntimeError: If `beta` is less than or equal to 0.
4390
4715
 
4391
4716
  Supported Platforms:
4392
4717
  ``Ascend`` ``GPU`` ``CPU``
@@ -4961,7 +5286,7 @@ def grid_sample(input, grid, mode='bilinear', padding_mode='zeros', align_corner
4961
5286
  H_{in}, W_{in})` (5-D case) and dtype of float32 or float64.
4962
5287
  grid (Tensor): flow-field with shape of :math:`(N, H_{out}, W_{out}, 2)` (4-D case) or :math:`(N, D_{out},
4963
5288
  H_{out}, W_{out}, 3)` (5-D case) and same dtype as `input`.
4964
- mode (str): An optional string specifying the interpolation method. The optional values are
5289
+ mode (str, optional): An optional string specifying the interpolation method. The optional values are
4965
5290
  ``'bilinear'``, ``'nearest'``. Default: ``'bilinear'`` . Note: `bicubic` is not supported yet. When
4966
5291
  `mode="bilinear"` and the input is 5-D, the interpolation mode used internally will actually
4967
5292
  be trilinear. However, when the input is 4-D, the interpolation mode will legistimately be bilinear.
@@ -4976,9 +5301,10 @@ def grid_sample(input, grid, mode='bilinear', padding_mode='zeros', align_corner
4976
5301
  It performs bilinear interpolation in the two spatial dimensions and linear interpolation along
4977
5302
  the third dimension. It is commonly used for volume or 3D image interpolation.
4978
5303
 
4979
- padding_mode (str): An optional string specifying the pad method. The optional values are "zeros", "border" or
5304
+ padding_mode (str, optional): An optional string specifying the pad method.
5305
+ The optional values are "zeros", "border" or
4980
5306
  "reflection". Default: ``'zeros'`` .
4981
- align_corners (bool): If set to `True`, the extrema (-1 and 1) are considered as referring to
5307
+ align_corners (bool, optional): If set to `True`, the extrema (-1 and 1) are considered as referring to
4982
5308
  the center points of the input's corner pixels. If set to `False`, they are instead considered as referring
4983
5309
  to the corner points of the input's corner pixels, making the sampling more resolution agnostic. Default:
4984
5310
  ``False`` .
@@ -5389,12 +5715,15 @@ def conv3d_transpose(inputs, weight, pad_mode='valid', padding=0, stride=1, dila
5389
5715
  Args:
5390
5716
  inputs (Tensor): The gradients with respect to the output of the convolution.
5391
5717
  The shape conforms to the default.
5392
- data_format :math:`(N, C_{in}, D_{out}, H_{out}, W_{out})`. Currently dout data type only supports float16
5393
- and float32.
5718
+ data_format :math:`(N, C_{in}, D_{out}, H_{out}, W_{out})`.
5719
+ Supported dtypes:
5720
+
5721
+ - Ascend: float16.
5722
+ - GPU/CPU: float16, float32.
5394
5723
  weight (Tensor): Set size of kernel is :math:`(K_d, K_h, K_w)`, then the shape is
5395
5724
  :math:`(C_{in}, C_{out}//group, K_d, K_h, K_w)`. Where :math:`group` is the Args parameter,
5396
5725
  :math:`//` is the symbol for integer division.
5397
- Currently weight data type only supports float16 and float32.
5726
+ It has the same dtype as `dout`.
5398
5727
  pad_mode (str): Specifies padding mode. The optional values are
5399
5728
  "same", "valid", "pad". Default: "valid".
5400
5729
 
@@ -5538,9 +5867,9 @@ def conv1d(input, weight, bias=None, stride=1, pad_mode="valid", padding=0, dila
5538
5867
 
5539
5868
  The shape of the convolutional kernel is given by :math:`(\text{kernel_size})`,
5540
5869
  where :math:`\text{kernel_size}` is the width of the kernel.
5541
- If we consider the input and output channels as well as the `group` parameter, the complete kernel shape
5542
- will be :math:`(C_{out}, C_{in} / \text{group}, \text{kernel_size})`,
5543
- where `group` is the number of groups dividing `x`'s input channel when applying group convolution.
5870
+ If we consider the input and output channels as well as the `groups` parameter, the complete kernel shape
5871
+ will be :math:`(C_{out}, C_{in} / \text{groups}, \text{kernel_size})`,
5872
+ where `groups` is the number of groups dividing `x`'s input channel when applying group convolution.
5544
5873
 
5545
5874
  For more details about convolution layer, please refer to `Gradient Based Learning Applied to Document Recognition
5546
5875
  <http://vision.stanford.edu/cs598_spring07/papers/Lecun98.pdf>`_
@@ -5655,7 +5984,7 @@ def conv1d(input, weight, bias=None, stride=1, pad_mode="valid", padding=0, dila
5655
5984
 
5656
5985
  def conv2d(input, weight, bias=None, stride=1, pad_mode="valid", padding=0, dilation=1, groups=1):
5657
5986
  r"""
5658
- Applies a 2D convolution over an input tensor. The input tenor is typically of
5987
+ Applies a 2D convolution over an input tensor. The input tensor is typically of
5659
5988
  shape :math:`(N, C_{in}, H_{in}, W_{in})`, where :math:`N` is batch size, :math:`C` is
5660
5989
  channel number, :math:`H` is feature height, :math:`W` is feature width.
5661
5990
 
@@ -5690,9 +6019,9 @@ def conv2d(input, weight, bias=None, stride=1, pad_mode="valid", padding=0, dila
5690
6019
  The shape of the convolutional kernel is given by :math:`(\text{kernel_size[0]}, \text{kernel_size[1]})`,
5691
6020
  where :math:`\text{kernel_size[0]}` and :math:`\text{kernel_size[1]}` are the height and width of the kernel,
5692
6021
  respectively.
5693
- If we consider the input and output channels as well as the `group` parameter, the complete kernel shape
5694
- will be :math:`(C_{out}, C_{in} / \text{group}, \text{kernel_size[0]}, \text{kernel_size[1]})`,
5695
- where `group` is the number of groups dividing `x`'s input channel when applying group convolution.
6022
+ If we consider the input and output channels as well as the `groups` parameter, the complete kernel shape
6023
+ will be :math:`(C_{out}, C_{in} / \text{groups}, \text{kernel_size[0]}, \text{kernel_size[1]})`,
6024
+ where `groups` is the number of groups dividing `x`'s input channel when applying group convolution.
5696
6025
 
5697
6026
  For more details about convolution layer, please refer to `Gradient Based Learning Applied to Document Recognition
5698
6027
  <http://vision.stanford.edu/cs598_spring07/papers/Lecun98.pdf>`_ and
@@ -5840,9 +6169,9 @@ def _get_pad_nd_info(pad_l, pad_r):
5840
6169
 
5841
6170
  def conv2d_ext(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1):
5842
6171
  r"""
5843
- Applies a 2D convolution over an input tensor. The input tenor is typically of
5844
- shape :math:`(N, C_{in}, H_{in}, W_{in})`, where :math:`N` is batch size, :math:`C` is
5845
- channel number, :math:`H` is feature height, :math:`W` is feature width.
6172
+ Applies a 2D convolution over an input tensor. The input tensor is typically of
6173
+ shape :math:`(N, C_{in}, H_{in}, W_{in})` or :math:`(C_{in}, H_{in}, W_{in})`,
6174
+ where :math:`N` is batch size, :math:`C` is channel number, :math:`H` is feature height, :math:`W` is feature width.
5846
6175
 
5847
6176
  The output is calculated based on formula:
5848
6177
 
@@ -5855,8 +6184,6 @@ def conv2d_ext(input, weight, bias=None, stride=1, padding=0, dilation=1, groups
5855
6184
  the `cross-correlation <https://en.wikipedia.org/wiki/Cross-correlation>`_,
5856
6185
  , :math:`weight` is the convolution kernel value and :math:`X` represents the input feature map.
5857
6186
 
5858
- Here are the indices' meanings:
5859
-
5860
6187
  - :math:`i` corresponds to the batch number, the range is :math:`[0, N-1]`,
5861
6188
  where :math:`N` is the batch size of the input.
5862
6189
 
@@ -5883,12 +6210,11 @@ def conv2d_ext(input, weight, bias=None, stride=1, padding=0, dilation=1, groups
5883
6210
  <http://vision.stanford.edu/cs598_spring07/papers/Lecun98.pdf>`_ and
5884
6211
  `ConvNets <http://cs231n.github.io/convolutional-networks/>`_.
5885
6212
 
5886
- Note:
5887
- On Ascend platform, only group convolution in depthwise convolution scenarios is supported.
5888
- That is, when `groups>1`, condition :math:`C_{in}` = :math:`C_{out}` = `groups` must be satisfied.
6213
+ .. warning::
6214
+ This is an experimental API that is subject to change or deletion.
5889
6215
 
5890
6216
  Args:
5891
- input (Tensor): Tensor of shape :math:`(N, C_{in}, H_{in}, W_{in})`.
6217
+ input (Tensor): Tensor of shape :math:`(N, C_{in}, H_{in}, W_{in})` or :math:`(C_{in}, H_{in}, W_{in})`.
5892
6218
  weight (Tensor): Tensor of shape
5893
6219
  :math:`(N, C_{in} / \text{groups}, \text{kernel_size[0]}, \text{kernel_size[1]})`, then the size of kernel
5894
6220
  is :math:`(\text{kernel_size[0]}, \text{kernel_size[1]})`.
@@ -5897,41 +6223,53 @@ def conv2d_ext(input, weight, bias=None, stride=1, padding=0, dilation=1, groups
5897
6223
  stride (Union(int, tuple[int]), optional): The distance of kernel moving, an int number that represents
5898
6224
  the height and width of movement are both strides, or a tuple of two int numbers that
5899
6225
  represent height and width of movement respectively. Default: ``1`` .
5900
- padding (Union(int, tuple[int], list[int], str), optional): Implicit paddings on both sides of the input `x`.
5901
- Can be a string, one integer or a tuple/list with 2 integers.
5902
- If `padding` is a string, the optional values are ``"same"`` , ``"valid"``.
5903
-
5904
- - same: Adopts the way of completion. The height and width of the output will be equal to
5905
- the input `x` divided by stride. The padding will be evenly calculated in top and bottom,
5906
- left and right possiblily. Otherwise, the last extra padding will be calculated from the bottom
5907
- and the right side. If this mode is set, `padding` must be 0.
5908
-
5909
- - valid: Adopts the way of discarding. The possible largest height and width of output will be returned
5910
- without padding. Extra pixels will be discarded. If this mode is set, `padding` must be 0.
6226
+ padding (Union[int, tuple[int], str], optional): The number of padding
6227
+ on the height and width directions of the input.
6228
+ The data type is an integer or a tuple of two integers or string {`valid`, `same`}. If `padding` is an
6229
+ integer, then `padding_{H}` and `padding_{W}` are all equal to `padding`.
6230
+ If `padding` is a tuple of 2 integers, then `padding_{H}` and `padding_{W}`
6231
+ is equal to `padding[0]` and `padding[1]` respectively.
6232
+ The value should be greater than or equal to 0. Default: ``0`` .
6233
+
6234
+ - ``"same"``: Pad the input around its edges so that the shape of input and output
6235
+ are the same when `stride` is set to ``1``.
6236
+ The amount of padding to is calculated by the operator internally, If the amount is even, it is
6237
+ uniformly distributed around the input, if it is odd, the excess amount goes to the right/bottom side.
6238
+ If this mode is set, `stride` must be 1.
6239
+
6240
+ - ``"valid"``: No padding is applied to the input, and the output returns the maximum
6241
+ possible height and width. Extra pixels that could not complete a full stride will
6242
+ be discarded.
5911
6243
 
5912
- If `padding` is one integer, the paddings of top, bottom, left and right are the same, equal to padding.
5913
- If `padding` is a tuple/list with 2 integers, the padding of top adn bottom is padding[0],
5914
- and the padding of left and right is padding[1]. Default: ``0`` .
5915
6244
  dilation (Union(int, tuple[int]), optional): Gaps between kernel elements.The data type is int or a tuple of
5916
6245
  2 integers. Specifies the dilation rate to use for dilated convolution. If set to be :math:`k > 1`,
5917
6246
  there will be :math:`k - 1` pixels skipped for each sampling location. Its value must
5918
6247
  be greater than or equal to 1 and bounded by the height and width of the input `x`. Default: ``1`` .
5919
6248
  groups (int, optional): Splits `input` into groups. Default: ``1`` .
5920
6249
 
6250
+ - :math:`(C_{in} \text{ % } \text{groups} == 0)` , :math:`(C_{out} \text{ % } \text{groups} == 0)` ,
6251
+ :math:`(C_{out} >= \text{groups})` , :math:`(\text{kernel_size[1]} = C_{in} / \text{groups})`
6252
+
5921
6253
  Returns:
5922
6254
  Tensor, the value that applied 2D convolution. The shape is :math:`(N, C_{out}, H_{out}, W_{out})`.
5923
6255
  To see how different pad modes affect the output shape, please refer to
5924
- :class:`mindspore.nn.Conv2d` for more details.
5925
-
6256
+ :class:`mindspore.mint.nn.Conv2d` for more details.
5926
6257
 
5927
6258
  Raises:
5928
- TypeError: If `stride`, `padding` or `dilation` is neither an int nor a tuple.
5929
- TypeError: `groups` is not an int.
6259
+ ValueError: Args and size of the input feature map should satisfy the output formula to ensure that the size of
6260
+ the output feature map is positive; otherwise, an error will be reported. For more details on the output
6261
+ formula, please refer to :class:`mindspore.mint.nn.Conv2d`.
6262
+ RuntimeError: On Ascend, due to the limitation of the L1 cache size of different NPU chip, if input size or
6263
+ kernel size is too large, it may trigger an error.
6264
+ TypeError: If `in_channels` , `out_channels` or `groups` is not an int.
6265
+ TypeError: If `kernel_size` , `stride` or `dilation` is neither an int nor a tuple.
5930
6266
  TypeError: If `bias` is not a Tensor.
5931
6267
  ValueError: If the shape of `bias` is not :math:`(C_{out})` .
5932
6268
  ValueError: If `stride` or `dilation` is less than 1.
5933
- ValueError: If `pad_mode` is not one of 'same', 'valid' or 'pad'.
5934
- ValueError: If `padding` is a tuple/list whose length is not equal to 2.
6269
+ ValueError: If `padding` is `same` , `stride` is not equal to 1.
6270
+ ValueError: The input parameters do not satisfy the convolution output formula.
6271
+ ValueError: The KernelSize cannot exceed the size of the input feature map.
6272
+ ValueError: The value of padding cannot cause the calculation area to exceed the input size.
5935
6273
 
5936
6274
  Supported Platforms:
5937
6275
  ``Ascend``
@@ -5939,123 +6277,21 @@ def conv2d_ext(input, weight, bias=None, stride=1, padding=0, dilation=1, groups
5939
6277
  Examples:
5940
6278
  >>> import mindspore
5941
6279
  >>> import numpy as np
5942
- >>> from mindspore import Tensor, ops
5943
- >>> from mindspore.ops.function.nn_func import conv2d_ext
6280
+ >>> from mindspore import Tensor, ops, mint
5944
6281
  >>> x = Tensor(np.ones([10, 32, 32, 32]), mindspore.float32)
5945
6282
  >>> weight = Tensor(np.ones([32, 32, 3, 3]), mindspore.float32)
5946
- >>> output = conv2d_ext(x, weight)
6283
+ >>> output = mint.nn.functional.conv2d(x, weight)
5947
6284
  >>> print(output.shape)
5948
6285
  (10, 32, 30, 30)
5949
6286
  """
5950
-
5951
- def _convolution_same(input, weight, bias, dilation, groups):
5952
- """ convolution when mode is 'same' """
5953
- if isinstance(dilation, int):
5954
- dilation = (dilation,) * 2
5955
- validator.check_int(len(weight.shape), 4, validator.EQ, "weight.shape", 'conv2d')
5956
- validator.check_int(len(dilation), 2, validator.EQ, "dilation", 'conv2d')
5957
-
5958
- # Calc padding info
5959
- need_pad_nd, pad_l, pad_r = _get_pad_info(dilation, weight)
5960
- if not need_pad_nd:
5961
- conv = _get_cache_prim(Convolution)(stride, pad_l, dilation, False, (0, 0), groups)
5962
- return conv(input, weight, bias)
5963
-
5964
- # Calc pad nd info
5965
- pad_nd, pad_l = _get_pad_nd_info(pad_l, pad_r)
5966
- pad_nd_op = _get_cache_prim(ConstantPadND)()
5967
- padded_input = pad_nd_op(input, pad_nd, 0)
5968
- conv = _get_cache_prim(Convolution)(stride, pad_l, dilation, False, (0, 0), groups)
5969
- return conv(padded_input, weight, bias)
5970
-
5971
- if isinstance(padding, int):
5972
- padding = (padding,) * 2
5973
-
5974
- if isinstance(padding, (tuple, list)):
5975
- conv = _get_cache_prim(Convolution)(stride, padding, dilation, False, (0, 0), groups)
5976
- return conv(input, weight, bias)
6287
+ if isinstance(padding, (int, tuple, list)):
6288
+ return conv2d_ext_op(input, weight, bias, stride, padding, dilation, groups)
5977
6289
  if isinstance(padding, str):
5978
- if padding == 'valid':
5979
- conv = _get_cache_prim(Convolution)(stride, (0, 0), dilation, False, (0, 0), groups)
5980
- return conv(input, weight, bias)
5981
- if padding == 'same':
5982
- _check_stride_when_same_mode(stride)
5983
- return _convolution_same(input, weight, bias, dilation, groups)
5984
- raise ValueError(f"For conv2d, the parameter 'padding' must be 'same' or 'valid' when " \
5985
- f"the type of 'padding' is string.")
6290
+ return conv2d_padding_op(input, weight, bias, stride, padding, dilation, groups)
5986
6291
  raise TypeError(f"For conv2d, the parameter 'padding' must be a tuple/list " \
5987
6292
  f"or a string, but got {type(padding)}")
5988
6293
 
5989
6294
 
5990
- def conv_transpose2d(input, weight, bias=None, stride=1, padding=0, output_padding=0, groups=1, dilation=1):
5991
- r"""
5992
- Calculates a 2D transposed convolution, which can be regarded as Conv2d for the gradient of the input,
5993
- also called deconvolution (although it is not an actual deconvolution).
5994
-
5995
- The input is typically of shape :math:`(N, C_{in}, H_{in}, W_{in})`,
5996
- where :math:`N` is batch size, :math:`C_{in}` is space dimension,
5997
- :math:`H_{in}, W_{in}` are the height and width of the feature layer respectively.
5998
-
5999
- When Conv2d and Conv2dTranspose are initialized with the same parameters, and `pad_mode` is set to 'pad',
6000
- :math:`dilation * (kernel\_size - 1) - padding` amount of zero will be paded to the height and width
6001
- directions of the input, they are inverses of each other in regard to the input and output shapes in this case.
6002
- However, when `stride` > 1, Conv2d maps multiple input shapes to the same output shape. Deconvolutional network
6003
- can refer to `Deconvolutional Networks <https://www.matthewzeiler.com/mattzeiler/deconvolutionalnetworks.pdf>`_.
6004
-
6005
- Args:
6006
- input (Tensor): Tensor of shape :math:`(N, C_{in}, H_{in}, W_{in})`.
6007
- weight (Tensor): Tensor of shape
6008
- :math:`(N, C_{in} / \text{groups}, \text{kernel_size[0]}, \text{kernel_size[1]})`, then the size of kernel
6009
- is :math:`(\text{kernel_size[0]}, \text{kernel_size[1]})`.
6010
- bias (Tensor, optional): Bias Tensor with shape :math:`(C_{out})`.
6011
- When bias is ``None`` , zeros will be used. Default: ``None`` .
6012
- stride (Union(int, tuple[int]), optional): The distance of kernel moving, an int number that represents
6013
- the height and width of movement are both strides, or a tuple of two int numbers that
6014
- represent height and width of movement respectively. Default: ``1`` .
6015
- padding (Union(int, tuple[int], list[int]), optional): Implicit paddings on both sides of the input `x`.
6016
- Can be an integer or a tuple/list with 2 integers.
6017
- output_padding (Union[int, tuple[int]]): The number of padding on the height and width directions of the output.
6018
- The data type is an integer or a tuple of two integers. If `output_padding` is an integer,
6019
- then the bottom and right padding are all equal to `output_padding`. If `output_padding` is a tuple of
6020
- 2 integers, then the bottom and right padding is equal to `output_padding[0]`, `output_padding[1]`
6021
- respectively.
6022
- groups (int, optional): Splits `input` into groups. Default: ``1`` .
6023
- dilation (Union(int, tuple[int]), optional): Gaps between kernel elements.The data type is int or a tuple of
6024
- 2 integers. Specifies the dilation rate to use for dilated convolution. If set to be :math:`k > 1`,
6025
- there will be :math:`k - 1` pixels skipped for each sampling location. Its value must
6026
- be greater than or equal to 1 and bounded by the height and width of the input `x`. Default: ``1`` .
6027
-
6028
- Returns:
6029
- Tensor, the value that applied 2D convolution. The shape is :math:`(N, C_{out}, H_{out}, W_{out})`.
6030
- To see how different pad modes affect the output shape, please refer to
6031
- :class:`mindspore.nn.Conv2dTranspose` for more details.
6032
-
6033
-
6034
- Raises:
6035
- TypeError: If `stride`, `padding` or `dilation` is neither an int nor a tuple.
6036
- TypeError: `groups` is not an int.
6037
- TypeError: If `bias` is not a Tensor.
6038
- ValueError: If the shape of `bias` is not :math:`(C_{out})` .
6039
- ValueError: If `stride` or `dilation` is less than 1.
6040
- ValueError: If `padding` is a tuple/list whose length is not equal to 2.
6041
-
6042
- Supported Platforms:
6043
- ``Ascend``
6044
-
6045
- Examples:
6046
- >>> import mindspore
6047
- >>> import numpy as np
6048
- >>> from mindspore import Tensor, ops
6049
- >>> x = Tensor(np.ones([1, 6, 32, 32]), mindspore.float32)
6050
- >>> weight = Tensor(np.ones([6, 3, 5, 5]), mindspore.float32)
6051
- >>> output = ops.conv_transpose2d(x, weight)
6052
- >>> print(output.shape)
6053
- (1, 3, 36, 36)
6054
- """
6055
- conv = _get_cache_prim(Convolution)(stride, padding, dilation, True, output_padding, groups)
6056
- return conv(input, weight, bias)
6057
-
6058
-
6059
6295
  def hardtanh(input, min_val=-1.0, max_val=1.0):
6060
6296
  r"""
6061
6297
  Applies the hardtanh activation function element-wise. The activation function is defined as:
@@ -6742,10 +6978,10 @@ def conv3d(input, weight, bias=None, stride=1, pad_mode="valid", padding=0, dila
6742
6978
  :math:`(\text{kernel_size[0]}, \text{kernel_size[1]}, \text{kernel_size[2]})`
6743
6979
  where :math:`\text{kernel_size[0]}` , :math:`\text{kernel_size[1]}` and :math:`\text{kernel_size[2]}` are the depth,
6744
6980
  height and width of the kernel, respectively.
6745
- If we consider the input and output channels as well as the `group` parameter, the complete kernel shape
6746
- will be :math:`(C_{out}, C_{in} / \text{group}, \text{kernel_size[0]},
6981
+ If we consider the input and output channels as well as the `groups` parameter, the complete kernel shape
6982
+ will be :math:`(C_{out}, C_{in} / \text{groups}, \text{kernel_size[0]},
6747
6983
  \text{kernel_size[1]}, \text{kernel_size[2]})`,
6748
- where `group` is the number of groups dividing `x`'s input channel when applying group convolution.
6984
+ where `groups` is the number of groups dividing `x`'s input channel when applying group convolution.
6749
6985
 
6750
6986
  For more details about convolution layer, please refer to `Gradient Based Learning Applied to Document Recognition
6751
6987
  <http://vision.stanford.edu/cs598_spring07/papers/Lecun98.pdf>`_.
@@ -6882,6 +7118,146 @@ def conv3d(input, weight, bias=None, stride=1, pad_mode="valid", padding=0, dila
6882
7118
  return output
6883
7119
 
6884
7120
 
7121
+ def conv3d_ext(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1):
7122
+ r"""
7123
+ Applies a 3D convolution over an input tensor. The input tensor is typically of
7124
+ shape :math:`(N, C_{in}, D_{in}, H_{in}, W_{in})` or :math:`(C_{in}, D_{in}, H_{in}, W_{in})`,
7125
+ where :math:`N` is batch size, :math:`C` is channel number, :math:`D, H, W` are the depth,
7126
+ height and width of the feature graph, respectively.
7127
+
7128
+ The output is calculated based on formula:
7129
+
7130
+ .. math::
7131
+
7132
+ \text{out}(N_i, C_{\text{out}_j}) = \text{bias}(C_{\text{out}_j}) +
7133
+ \sum_{k = 0}^{C_{in} - 1} \text{ccor}({\text{weight}(C_{\text{out}_j}, k), \text{X}(N_i, k)})
7134
+
7135
+ where :math:`bias` is the output channel bias, :math:`ccor` is
7136
+ the `cross-correlation <https://en.wikipedia.org/wiki/Cross-correlation>`_
7137
+ , :math:`weight` is the convolution kernel value and :math:`X` represents the input feature map.
7138
+
7139
+ Here are the indices' meanings:
7140
+
7141
+ - :math:`i` corresponds to the batch number, the range is :math:`[0, N-1]`,
7142
+ where :math:`N` is the batch size of the input.
7143
+
7144
+ - :math:`j` corresponds to the output channel, the range is :math:`[0, C_{out}-1]`,
7145
+ where :math:`C_{out}` is the number of
7146
+ output channels, which is also equal to the number of kernels.
7147
+
7148
+ - :math:`k` corresponds to the input channel, the range is :math:`[0, C_{in}-1]`,
7149
+ where :math:`C_{in}` is the number of
7150
+ input channels, which is also equal to the number of channels in the convolutional kernels.
7151
+
7152
+ Therefore, in the above formula, :math:`{bias}(C_{\text{out}_j})` represents the bias of the :math:`j`-th
7153
+ output channel, :math:`{weight}(C_{\text{out}_j}, k)` represents the slice of the :math:`j`-th convolutional
7154
+ kernel in the :math:`k`-th channel, and :math:`{X}(N_i, k)` represents the slice of the :math:`k`-th input
7155
+ channel in the :math:`i`-th batch of the input feature map.
7156
+
7157
+ The shape of the convolutional kernel is given by :math:`(kd, kh, kw)` where :math:`kd` , :math:`kd` and\
7158
+ :math:`kw` are the depth, height and width of the kernel, respectively.
7159
+ If we consider the input and output channels as well as the `group` parameter, the complete kernel shape
7160
+ will be :math:`(C_{out}, C_{in} / \text{group}, kd, kh, kw)`,
7161
+ where `group` is the number of groups dividing `x`'s input channel when applying group convolution.
7162
+
7163
+ For more details about convolution layer, please refer to `Gradient Based Learning Applied to Document Recognition
7164
+ <http://vision.stanford.edu/cs598_spring07/papers/Lecun98.pdf>`_.
7165
+
7166
+ The following lists some of the limitations of the parameters.
7167
+
7168
+ - input -- The input to the conv3d. The input must have each dimension size within the range [1, int32_max].
7169
+ - weight -- Filters of shape :math:`(C_{out}, C_{in} / groups, kd, kh, kw)`. The value of :math:`kh`
7170
+ and :math:`kw` is in the range [1, 511]. The remaining values are in the range [1, int32_max].
7171
+ And :math:`kh*kw*k0` is less 65536 (k0 is 16. If data type is float32, k0 is 8).
7172
+ - bias -- Bias Tensor with shape :math:`(C_{out})`. The shape must equal the first dimension of the weight.
7173
+ - stride -- The distance of kernel moving. It can be an int number or
7174
+ tuple (noted by :math:`(stride_d, stride_h, stride_w)`). stride_h and stride_w are in the range [1, 63].
7175
+ stride_d is in the range [1, 255].
7176
+ - padding -- If padding is an int number, it is in the range [0, 255].
7177
+ - dilation -- The value is in the range [1, 255].
7178
+ - groups -- The value is in the range [1, 65535].
7179
+ - :math:`C_{in} \% \text{groups} == 0 \quad \text{and} \quad C_{out} \% \text{groups} == 0` .
7180
+ - :math:`weight[1] == C_{in} / groups` .
7181
+ - :math:`H_{in} + PadUp + PadDown >= (kh - 1) * DilationH + 1` .
7182
+ - :math:`W_{in} + PadLeft + PadRight >= (kw - 1) * DilationW + 1` .
7183
+ - :math:`D_{in} + PadFront + PadBack >= (kd - 1) * DilationD + 1` .
7184
+ - :math:`H_{out} = (H_{in} + PadUp + PadDown - ((kh - 1) * DilationH + 1)) / StrideH + 1` .
7185
+ - :math:`W_{out} = (W_{in} + PadLeft + PadRight - ((kw - 1) * DilationW + 1)) / StrideW + 1` .
7186
+ - :math:`D_{out} = (D_{in} + PadFront + PadBack - ((kd - 1) * DilationD + 1)) / StrideD + 1` .
7187
+ - :math:`(D_{in}+PadFront+PadBack - ((kd-1)*DilationD+1)) /% StrideD <= PadBack` .
7188
+ - :math:`(H_{in}+PadUp+PadDown - ((kh-1)*Dilationh+1)) /% StrideH <= PadDown` .
7189
+ - :math:`stride_d <= kernel_d` .
7190
+ - :math:`PadUp < kh` and :math:`PadDown < kh` . When `padding` = ``'valid'``, both PadUp and PadDown are zeros.
7191
+ When `padding` = ``'same'``, pad can be calculated by
7192
+ :math:`floor(((H_{out}-1) * strideH + (kh - 1) * DilationH + 1 - H_{in}) / 2)` for high dimension.
7193
+ It is similar way to calculate the padding for depth and width dimension. And the depth and width
7194
+ dimensions also have the same constraints.
7195
+ - :math:`((kh - 1) * DilationH - PadUp)` should be in [0, 255]. It is the same constraint for depth
7196
+ and width dimension.
7197
+ - If `padding` is ``'same'``, `stride` must be 1.
7198
+
7199
+ .. warning::
7200
+ This API does not support Atlas series products.
7201
+ This is an experimental API that is subject to change or deletion.
7202
+
7203
+ Args:
7204
+ input (Tensor): Tensor of shape :math:`(N, C_{in}, D_{in}, H_{in}, W_{in})`.
7205
+ weight (Tensor): Set size of kernel is :math:`(kd, kh,
7206
+ kw)`, then the shape is :math:`(C_{out}, C_{in} / groups, kd, kh, kw)`.
7207
+ bias (Tensor, optional): Bias Tensor with shape :math:`(C_{out})`.
7208
+ When bias is ``None`` , zeros will be used. Default: ``None`` .
7209
+ stride (Union(int, tuple[int]), optional): The distance of kernel moving, an int number that represents
7210
+ the depth, the height and width of movement are both strides, or a tuple of triple int numbers that
7211
+ represent the depth, height and width of movement respectively. Default: ``1`` .
7212
+ padding (Union(int, tuple[int], str), optional): Implicit paddings on both sides of the input `x`.
7213
+ Can be a string, one integer or a tuple/list with 3 integers.
7214
+ If `padding` is a string, the optional values are ``"same"`` , ``"valid"``.
7215
+
7216
+ - same: Adopts the way of completion. The height and width of the output will be equal to
7217
+ the input `x` divided by stride. The padding will be evenly calculated in top and bottom,
7218
+ left and right possiblily. Otherwise, the last extra padding will be calculated from the bottom
7219
+ and the right side. If this mode is set, `stride` must be 1.
7220
+
7221
+ - valid: Adopts the way of discarding. The possible largest height and width of output will be returned
7222
+ without padding. Extra pixels will be discarded.
7223
+
7224
+ If `padding` is one integer, the paddings of top, bottom, left and right are the same, equal to padding.
7225
+ If `padding` is a tuple/list with 3 integers, the padding of head, tail, top, bottom,
7226
+ left and right equal to pad[0], pad[0], pad[1], pad[1], pad[2] and pad[2] correspondingly. Default: ``0`` .
7227
+ dilation (Union[int, tuple[int]], optional): Controlling the space between the kernel points. Default: ``1`` .
7228
+ groups (int, optional): Splits `input` into groups. Default: ``1`` .
7229
+
7230
+ Returns:
7231
+ Tensor, the same dtype as the `input`, with the shape :math:`(N, C_{out}, D_{out}, H_{out}, W_{out})`
7232
+ or :math:`(C_{out}, D_{out}, H_{out}, W_{out})`.
7233
+
7234
+ Raises:
7235
+ TypeError: If `stride`, `padding` or `dilation` is neither an int nor a tuple.
7236
+ TypeError: `groups` is not an int.
7237
+ TypeError: If `bias` is not a Tensor.
7238
+
7239
+ Supported Platforms:
7240
+ ``Ascend``
7241
+
7242
+ Examples:
7243
+ >>> import mindspore
7244
+ >>> import numpy as np
7245
+ >>> from mindspore import mint
7246
+ >>> x = mindspore.Tensor(np.random.randn(12, 1, 60, 50, 8), mindspore.float16)
7247
+ >>> w = mindspore.Tensor(np.random.randn(26, 1, 2, 4, 4), mindspore.float16)
7248
+ >>> out = mint.nn.functional.conv3d(x, w)
7249
+ >>> print(out.shape)
7250
+ (12, 26, 59, 47, 5)
7251
+ """
7252
+
7253
+ if isinstance(padding, (tuple, list, int)):
7254
+ return conv3d_ext_op(input, weight, bias, stride, padding, dilation, groups)
7255
+ if isinstance(padding, str):
7256
+ return conv3d_padding_op(input, weight, bias, stride, padding, dilation, groups)
7257
+ raise TypeError(f"For conv3d, the parameter 'padding' must be a tuple/list " \
7258
+ f"or a string, but got {type(padding)}")
7259
+
7260
+
6885
7261
  @_primexpr
6886
7262
  def _check_positive_int(arg_value, arg_name=None, prim_name=None):
6887
7263
  validator.check_positive_int(arg_value, arg_name=arg_name, prim_name=prim_name)
@@ -7062,6 +7438,50 @@ def glu(x, axis=-1):
7062
7438
  return x * y
7063
7439
 
7064
7440
 
7441
+ def glu_ext(input, dim=-1):
7442
+ r"""
7443
+ Computes GLU (Gated Linear Unit activation function) of the input tensor.
7444
+
7445
+ .. math::
7446
+ {GLU}(a, b)= a \otimes \sigma(b)
7447
+
7448
+ where :math:`a` is the first half of the `input` Tensor after `input` is split and :math:`b` is the second half.
7449
+
7450
+ Here :math:`\sigma` is the sigmoid function, and :math:`\otimes` is the Hadamard product.
7451
+ See `Language Modeling with Gated Convluational Networks <https://arxiv.org/abs/1612.08083>`_.
7452
+
7453
+ .. warning::
7454
+ This is an experimental API that is subject to change or deletion.
7455
+
7456
+ Args:
7457
+ input (Tensor): Tensor to be calculated. Dtype is floating point and the shape
7458
+ is :math:`(\ast_1, N, \ast_2)` where `*` means, any number of additional dimensions. :math:`N`
7459
+ is required to be an even number, where :math:`N` is the size of `input` on the dimension
7460
+ selected by `dim`.
7461
+ dim (int, optional): The dimension to split the input `input`. The value range is `[-r, r)` where `r`
7462
+ is the number of dimensions of `input`. Default: ``-1`` , the last dimension in `input`.
7463
+
7464
+ Raises:
7465
+ TypeError: If `input` is not a Tensor or `dim` is not an int.
7466
+ IndexError: If the value of `dim` is out of the range of `[-r, r)`, where `r` is the number
7467
+ of dimensions of `input`.
7468
+ RuntimeError: If dtype of `input` is not supported.
7469
+ RuntimeError: If the length of `input` in the dimension selected by `dim` is not even.
7470
+
7471
+ Supported Platforms:
7472
+ ``Ascend`` ``CPU``
7473
+
7474
+ Examples:
7475
+ >>> from mindspore import Tensor, mint
7476
+ >>> input = Tensor([[0.1,0.2,0.3,0.4],[0.5,0.6,0.7,0.8]])
7477
+ >>> output = mint.nn.functional.glu(input)
7478
+ >>> print(output)
7479
+ [[0.05744425 0.11973753]
7480
+ [0.33409387 0.41398472]]
7481
+ """
7482
+ return _get_cache_prim(P.GLU)(axis=dim)(input)
7483
+
7484
+
7065
7485
  def multi_margin_loss(input, target, p=1, margin=1, weight=None, reduction='mean'):
7066
7486
  r"""
7067
7487
  Hinge loss for optimizing a multi-class classification.
@@ -7291,7 +7711,8 @@ def gelu(input, approximate='none'):
7291
7711
 
7292
7712
  Args:
7293
7713
  input (Tensor): The input of the activation function GeLU, the data type is float16, float32 or float64.
7294
- approximate (str): the gelu approximation algorithm to use. Acceptable vaslues are ``'none'`` and ``'tanh'`` .
7714
+ approximate (str, optional): the gelu approximation algorithm to use.
7715
+ Acceptable vaslues are ``'none'`` and ``'tanh'`` .
7295
7716
  Default: ``'none'`` .
7296
7717
 
7297
7718
  Returns:
@@ -7309,7 +7730,7 @@ def gelu(input, approximate='none'):
7309
7730
  >>> import mindspore
7310
7731
  >>> from mindspore import Tensor, ops
7311
7732
  >>> x = Tensor([1.0, 2.0, 3.0], mindspore.float32)
7312
- >>> result = ops.gelu(x)
7733
+ >>> result = ops.gelu(x, approximate='none')
7313
7734
  >>> print(result)
7314
7735
  [0.8413447 1.9544997 2.9959505]
7315
7736
  """
@@ -7334,7 +7755,8 @@ def gelu(input, approximate='none'):
7334
7755
  def channel_shuffle(x, groups):
7335
7756
  r"""
7336
7757
  Divide the channels in a tensor of shape :math:`(*, C, H, W)` into :math:`g` groups and
7337
- rearrange them as :math:`(*, \frac{C}{g}, g, H*W)`, while keeping the original tensor shapes.
7758
+ rearrange them as :math:`(*, \frac{C}{g}, g, H*W)`, while retaining the original tensor
7759
+ shape in the final output.
7338
7760
 
7339
7761
  Args:
7340
7762
  x (Tensor): Tensor to be divided, it has shape :math:`(*, C, H, W)`,
@@ -7550,6 +7972,96 @@ def lp_pool2d(x, norm_type, kernel_size, stride=None, ceil_mode=False):
7550
7972
  return ((sign(out) * ops.relu(ops.abs(out))) * (kernel_size[0] * kernel_size[1])).pow(1.0 / norm_type)
7551
7973
 
7552
7974
 
7975
+ def relu(input, inplace=False):
7976
+ r"""
7977
+ Computes ReLU (Rectified Linear Unit activation function) of input tensors element-wise.
7978
+
7979
+ It returns :math:`\max(input,\ 0)` element-wise. Specially, the neurons with the negative output
7980
+ will be suppressed and the active neurons will stay the same.
7981
+
7982
+ .. math::
7983
+
7984
+ ReLU(input) = (input)^+ = \max(0, input)
7985
+
7986
+ ReLU Activation Function Graph:
7987
+
7988
+ .. image:: ../images/ReLU.png
7989
+ :align: center
7990
+
7991
+ Args:
7992
+ input (Tensor): The input Tensor.
7993
+ inplace (bool, optional): Whether to use inplace mode, Defaults to ``False``.
7994
+
7995
+ Returns:
7996
+ Tensor, with the same dtype and shape as the `input`.
7997
+
7998
+ Raises:
7999
+ TypeError: If dtype of `input` is not Number type.
8000
+ TypeError: If `input` is not a Tensor.
8001
+
8002
+ Supported Platforms:
8003
+ ``Ascend`` ``GPU`` ``CPU``
8004
+
8005
+ Examples:
8006
+ >>> import mindspore
8007
+ >>> import numpy as np
8008
+ >>> from mindspore import Tensor, ops
8009
+ >>> input = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]), mindspore.float32)
8010
+ >>> output = ops.relu(input)
8011
+ >>> print(output)
8012
+ [[0. 4. 0.]
8013
+ [2. 0. 9.]]
8014
+ """
8015
+ if inplace:
8016
+ return inplace_relu_op(input)
8017
+ return relu_op(input)
8018
+
8019
+
8020
+ def relu_(input):
8021
+ r"""
8022
+ ReLuComputes ReLU (Rectified Linear Unit activation function) inplace of input tensors element-wise.
8023
+
8024
+ It returns :math:`\max(input,\ 0)` element-wise. Specially, the neurons with the negative output
8025
+ will be suppressed and the active neurons will stay the same.
8026
+
8027
+ .. math::
8028
+
8029
+ ReLU(input) = (input)^+ = \max(0, input)
8030
+
8031
+ ReLU Activation Function Graph:
8032
+
8033
+ .. image:: ../images/ReLU.png
8034
+ :align: center
8035
+
8036
+ .. warning::
8037
+ This is an experimental API that is subject to change or deletion.
8038
+
8039
+ Args:
8040
+ input (Tensor): The input Tensor.
8041
+
8042
+ Returns:
8043
+ Tensor, with the same dtype and shape as the `input`.
8044
+
8045
+ Raises:
8046
+ TypeError: If dtype of `input` is not Number type.
8047
+ TypeError: If `input` is not a Tensor.
8048
+
8049
+ Supported Platforms:
8050
+ ``Ascend``
8051
+
8052
+ Examples:
8053
+ >>> import mindspore
8054
+ >>> import numpy as np
8055
+ >>> from mindspore import Tensor, ops
8056
+ >>> input = Tensor(np.array([[-1.0, 4.0, -8.0], [2.0, -5.0, 9.0]]), mindspore.float32)
8057
+ >>> ops.relu_(input)
8058
+ >>> print(input)
8059
+ [[0. 4. 0.]
8060
+ [2. 0. 9.]]
8061
+ """
8062
+ return inplace_relu_op(input)
8063
+
8064
+
7553
8065
  def mse_loss(input, target, reduction='mean'):
7554
8066
  r"""
7555
8067
  Calculates the mean squared error between the predicted value and the label value.
@@ -7667,7 +8179,8 @@ def triplet_margin_loss(anchor, positive, negative, margin=1.0, p=2, eps=1e-06,
7667
8179
  as `anchor`.
7668
8180
  negative (Tensor): A sample belonging to the different class from `anchor`, with the same type and shape
7669
8181
  as `anchor`.
7670
- margin (float, optional): Make a margin between the positive pair and the negative pair. Default: ``1.0`` .
8182
+ margin (float, optional): Make a margin between the positive pair and the negative pair. The shape of margin
8183
+ must be 0. Default: ``1.0`` .
7671
8184
  p (int, optional): The degree of norm for pairwise distance. Default: ``2`` .
7672
8185
  eps (float, optional): Add small value to avoid division by zero. Default: ``1e-06``.
7673
8186
  swap (bool, optional): The distance swap change the negative distance to the distance between positive
@@ -8131,7 +8644,7 @@ def max_pool2d(x, kernel_size, stride=None, padding=0, dilation=1, return_indice
8131
8644
  return out
8132
8645
 
8133
8646
 
8134
- def max_pool2d_ext(input, kernel_size, stride=None, padding=0, dilation=1, *, ceil_mode=False, return_indices=False):
8647
+ def max_pool2d_ext(input, kernel_size, stride=None, padding=0, dilation=1, ceil_mode=False, return_indices=False):
8135
8648
  r"""
8136
8649
  Performs a 2D max pooling on the input Tensor.
8137
8650
 
@@ -8153,21 +8666,23 @@ def max_pool2d_ext(input, kernel_size, stride=None, padding=0, dilation=1, *, ce
8153
8666
  kernel_size (Union[int, tuple[int]]): The size of kernel used to take the maximum value and arg
8154
8667
  value, is an int number that represents height and width of the kernel, or a tuple of
8155
8668
  two int numbers that represent height and width respectively.
8156
- stride (Union[int, tuple[int], None]): The distance of kernel moving, an int number that represents
8669
+ stride (Union[int, tuple[int], None], optional): The distance of kernel moving, an int number that represents
8157
8670
  the height and width of movement are both stride, or a tuple of two int numbers that
8158
8671
  represent height and width of movement respectively.
8159
8672
  Default: ``None`` , which indicates the moving step is `kernel_size` .
8160
- padding (Union[int, tuple[int]]): An int number that represents the height and width of movement are both
8673
+ padding (Union[int, tuple[int]], optional):
8674
+ An int number that represents the height and width of movement are both
8161
8675
  strides, or a tuple of two int numbers that represent height and width of movement respectively.
8162
8676
  Default: ``0`` .
8163
- dilation (Union[int, tuple[int]]): Control the stride of elements in the kernel. Default: ``1`` .
8164
- ceil_mode (bool): Whether to use ceil instead of floor to calculate output shape. Default: ``False`` .
8165
- return_indices (bool): Whether to output the indices of max value. Default: ``False`` .
8677
+ dilation (Union[int, tuple[int]], optional): Control the stride of elements in the kernel. Default: ``1`` .
8678
+ ceil_mode (bool, optional): Whether to use ceil instead of floor to calculate output shape. Default: ``False`` .
8679
+ return_indices (bool, optional): Whether to output the indices of max value. Default: ``False`` .
8166
8680
 
8167
8681
  Returns:
8168
8682
  If `return_indices` is ``False`` , return a Tensor `output`, else return a tuple (`output`, `argmax`).
8169
8683
 
8170
- - **output** (Tensor) - Maxpooling result, with shape :math:`(N_{out}, C_{out}, H_{out}, W_{out})`.
8684
+ - **output** (Tensor) - Maxpooling result,
8685
+ with shape :math:`(N_{out}, C_{out}, H_{out}, W_{out})`.
8171
8686
  It has the same data type as `input`.
8172
8687
 
8173
8688
  .. math::
@@ -8198,10 +8713,9 @@ def max_pool2d_ext(input, kernel_size, stride=None, padding=0, dilation=1, *, ce
8198
8713
  >>> import mindspore
8199
8714
  >>> import numpy as np
8200
8715
  >>> from mindspore import Tensor, ops
8201
- >>> from mindspore.ops.function.nn_func import max_pool2d_ext
8202
8716
  >>> input = Tensor(np.arange(20 * 16 * 50 * 32).reshape((20, 16, 50, 32)), mindspore.float32)
8203
- >>> output_tensor, argmax = max_pool2d_ext(input, kernel_size=(3, 2), stride=(2, 1),
8204
- ceil_mode=False, return_indices=True)
8717
+ >>> output_tensor, argmax = ops.function.nn_func.max_pool2d_ext(input, kernel_size=(3, 2), stride=(2, 1),
8718
+ ... ceil_mode=False, return_indices=True)
8205
8719
  >>> print(output_tensor.shape)
8206
8720
  (20, 16, 24, 31)
8207
8721
  >>> print(argmax.shape)
@@ -8219,62 +8733,199 @@ def max_pool2d_ext(input, kernel_size, stride=None, padding=0, dilation=1, *, ce
8219
8733
  return out
8220
8734
 
8221
8735
 
8222
- def prompt_flash_attention(query, key, value, attn_mask, actual_seq_lengths, actual_seq_lengths_kv, pse_shift,
8223
- deq_scale1, quant_scale1, deq_scale2, quant_scale2, quant_offset2, num_heads,
8224
- scale_value=1.0, pre_tokens=2147483547, next_tokens=0, input_layout='BSH',
8225
- num_key_value_heads=0, sparse_mode=0, inner_precise=1):
8736
+ def prompt_flash_attention(query, key, value, attn_mask=None, actual_seq_lengths=None, actual_seq_lengths_kv=None,
8737
+ pse_shift=None, deq_scale1=None, quant_scale1=None, deq_scale2=None, quant_scale2=None,
8738
+ quant_offset2=None, num_heads=1, scale_value=1.0, pre_tokens=2147483647, next_tokens=0,
8739
+ input_layout='BSH', num_key_value_heads=0, sparse_mode=0, inner_precise=1):
8226
8740
  r"""
8227
8741
  The interface for fully inference.
8228
- B -- Batch size
8229
- S -- Sequence length
8230
- H -- Hidden size
8742
+
8743
+ - B: Batch size
8744
+ - N: Num of attention heads
8745
+ - S: Sequence length
8746
+ - D: Head dim
8747
+ - H: Hidden layer size
8748
+
8749
+ Self attention constructs an attention model based on the relationship between input samples themselves. The
8750
+ principle is to assume that there is an input sample sequence :math:`x` of length :math:`n`, and each
8751
+ element of :math:`x` is a :math:`d` dimensional vector, which can be viewed as a token embedding. This sequence
8752
+ can be transformed through 3 weight matrices to obtain 3 matrices with dimensions of :math:`n\times d`.
8753
+
8754
+ The self attention calculation formula is defined as:
8755
+
8756
+ .. math::
8757
+ Attention(Q,K,V)=Softmax(\frac{QK^{T} }{\sqrt{d} } )V
8758
+
8759
+ where the product of :math:`Q` and :math:`K^{T}` represents the attention of input :math:`x`. To avoid the value
8760
+ becoming too large, it is usually scaled by dividing it by the square root of :math:`d` and perform softmax
8761
+ normalization on each row, yields a matrix of :math:`n\times d` after multiplying :math:`V`.
8762
+
8763
+ .. warning::
8764
+ - Support dtype of float16 for `attn_mask` will be deprecated in the future.
8765
+ - When `sparse_mode` is 2, 3 or 4, the shape of `attn_mask` must be :math:`(2048, 2048)` /
8766
+ :math:`(B, 1, 2048, 2048)` / :math:`(1, 1, 2048, 2048)`.
8231
8767
 
8232
8768
  Note:
8233
- experiment ops
8769
+ - Maximum Support for each axis
8770
+
8771
+ - Supports B-axis values less than or equal to 65536 (64k).
8772
+ When the input type includes int8 with D-axis not aligned to 32, or the input type is
8773
+ float16 or bfloat16 with D-axis not aligned to 16, the B-axis supports up to 128 only.
8774
+ - Supports N-axis values less than or equal to 256.
8775
+ - Supports S-axis values less than or equal to 20971520 (20M).
8776
+ - Supports D-axis values less than or equal to 512.
8777
+
8778
+ - Quantization
8779
+
8780
+ - int8 Input, int8 Output: Parameters `deq_scale1`, `quant_scale1`, `deq_scale2`, and `quant_scale2`
8781
+ must all be provided. `quant_offset2` is optional (default is 0 if not provided).
8782
+ - int8 Input, float16 Output: Parameters `deq_scale1`, `quant_scale1`, and `deq_scale2` must all be provided.
8783
+ If `quant_offset2` or `quant_scale2` is provided (i.e., not null), it will result in an error.
8784
+ - float16 or bfloat16 Input, int8 Output: Parameter `quant_scale2` must be provided. `quant_offset2` is
8785
+ optional (default is 0 if not provided). If `deq_scale1`, `quant_scale1`, or `deq_scale2` is
8786
+ provided (i.e., not null), it will result in an error.
8787
+ - int8 Output:
8788
+
8789
+ - `quant_scale2` and `quant_offset2` in per-channel format do not support scenarios with
8790
+ left padding, Ring Attention, or non-32-byte aligned D-axis.
8791
+ - In GE mode: `quant_scale2` and `quant_offset2` in per-tensor format do not support scenarios
8792
+ with non-32-byte aligned D-axis.
8793
+ - Does not support sparse as band and `pre_tokens`/`next_tokens` being negative.
8794
+
8795
+ - `quant_scale2` and `quant_offset2` can be bfloat16 only when `query` is bfloat16.
8796
+
8797
+
8798
+ - Other Usage Caveats:
8799
+
8800
+ - :math:`N` of parameter `query` must be equal to `num_heads`. :math:`N` of parameter `key` and parameter
8801
+ `value` must be equal to `num_key_value_heads`.
8802
+ - `num_heads` must be divisible by `num_key_value_heads` and `num_heads` divided by `num_key_value_heads`
8803
+ can not be greater than 64.
8804
+ - When `query` dtype is bfloat16, D axis should align with 16.
8805
+ - Each element of `actual_seq_lengths` must not exceed q_S and element
8806
+ of `actual_seq_lengths_kv` must not exceed kv_S.
8234
8807
 
8235
8808
  .. warning::
8236
- This is an experimental API that is subject to change or deletion.
8809
+ Only support on Atlas A2 training series.
8237
8810
 
8238
- Inputs:
8239
- query (Tensor) - The query tensor with data type of float16 or float32.
8240
- Input tensor of shape :math:`(B, S, H)` / `(B, N, S, D)`.
8241
- key (Tensor) - The key tensor with data type of float16 or float32.
8242
- Input tensor of shape :math:`(B, S, H)` / `(B, N, S, D)`.
8243
- value (Tensor) - The value tensor with data type of float16 or float32.
8244
- Input tensor of shape :math:`(B, S, H)` / `(B, N, S, D)`.
8245
- attn_mask (Tensor) - The attention mask tensor with data type of float16 or float32.
8246
- For each element, 0 indicates retention and 1 indicates discard. Input tensor of shape :math:`(B, 1, S, S)`.
8247
- actual_seq_lengths (Tensor): Describe actual sequence length of each input with data type of int64.
8248
- actual_seq_lengths_kv (Tensor): Describe actual sequence length of each input with data type of int64.
8249
- pse_shift (Tensor) - The position encoding tensor with data type of float16 or float32.
8250
- dep_scale1 (Tensor)
8251
- quant_scale1 (Tensor)
8252
- deq_scale2 (Tensor)
8253
- quant_scale2 (Tensor)
8254
- quant_offset2 (Tensor)
8255
- num_heads (int): The number of heads.
8256
- scale_value (float): The scale value indicating the scale coefficient, which is used as the scalar of
8257
- Muls in the calculation. Default: 1.0.
8258
- pre_tokens (int): Previous tokens. Default: 2147483547.
8259
- next_tokens (int): next tokens. Default: 0.
8260
- indicate the upper triangle, Indicate the number of data blocks involved in the calculation. The value 0
8261
- indicates that the data blocks in the upper triangle are not involved in the calculation
8262
- input_layout (str): the data layout of the input qkv, support `(BSH)` and `(BNSD)`, Default `BSH`.
8263
- num_key_value_heads (int): head numbers of key/value which are used in GQA algorithm.
8264
- The value o indicates if the key and value have the same head nums, use numHeads. Default: 0.
8265
- sparse_mode (int): Default: 0
8266
- inner_precise (int): 0, float16 high precision. 1, high performance. default 1
8811
+ Args:
8812
+ query (Tensor): The query tensor with data type of int8, float16 or bfloat16.
8813
+ The shape is :math:`(B, q_S, q_H)` / `(B, q_N, q_S, q_D)`.
8814
+ key (Tensor): The key tensor with the same dtype as `query`.
8815
+ The shape is :math:`(B, kv_S, kv_H)` / `(B, kv_N, kv_S, kv_D)`.
8816
+ value (Tensor): The value tensor with the same dtype as `query`.
8817
+ The shape is :math:`(B, kv_S, kv_H)` / `(B, kv_N, kv_S, kv_D)`.
8818
+ attn_mask (Tensor, optional) - The attention mask tensor with data type of bool, int8, uint8 or float16.
8819
+ For each element, 0/False indicates retention and 1/True indicates discard.
8820
+ If `sparse_mode` is 0 or 1: the shape is :math:`(q_S, kv_S)` / :math:`(B, q_S, kv_S)` /
8821
+ :math:`(1, q_S, kv_S)` / :math:`(B, 1, q_S, kv_S)` / :math:`(1, 1, q_S, kv_S)`.
8822
+ If `sparse_mode` is 2, 3 or 4, the shape is :math:`(2048, 2048)` / :math:`(1, 2048, 2048)` /
8823
+ :math:`(1, 1, 2048, 2048)`.
8824
+ Default: ``None``.
8825
+ actual_seq_lengths (Union[Tensor, tuple[int], list[int]], optional): Describe actual sequence length of each
8826
+ batch of `query` with data type of int64. The shape is :math:`(B, )` and every element should be
8827
+ positive integer.
8828
+ Default: ``None``.
8829
+ actual_seq_lengths_kv (Union[Tensor, tuple[int], list[int]], optional): Describe actual sequence length of each
8830
+ batch of `key` or `value` with data type of int64. The shape is :math:`(B, )` and every element should be
8831
+ positive integer.
8832
+ Default: ``None``.
8833
+ pse_shift (Tensor, optional): The position encoding tensor with data type of float16 or bfloat16.
8834
+ Input tensor of shape :math:`(B, N, q_S, kv_S)` / :math:`(1, N, q_S, kv_S)`.
8835
+ Default: ``None``.
8267
8836
 
8837
+ - q_S must be greater than or equal to the query's S length, and kv_S must be greater than or
8838
+ equal to the key's S length.'
8839
+ - If `pse_shift` has dtype float16, `query` should have dtype float16 or int8, in which case high
8840
+ precision mode is enabled automatically.
8841
+ - If `pse_shift` has dtype bfloat16, `query` should have dtype bfloat16.
8268
8842
 
8269
- Outputs:
8270
- attention_out (Tensor) - Input tensor of shape :math:`(B, S, H)` / `(B, N, S, D)`.
8843
+ deq_scale1 (Tensor, optional): Quantitative parametor, the tensor with data type of uint64 or float32.
8844
+ Input Tensor of shape :math:`(1,)`.
8845
+ Default: ``None``.
8846
+ quant_scale1 (Tensor, optional): Quantitative parametor, the tensor with data type of float32.
8847
+ Input Tensor of shape :math:`(1,)`.
8848
+ Default: ``None``.
8849
+ deq_scale2 (Tensor, optional): Quantitative parametor, input Tensor of shape :math:`(1,)` and it has
8850
+ the same dtype as `deq_scale1`.
8851
+ Default: ``None``.
8852
+ quant_scale2 (Tensor, optional): Quantitative parametor, the tensor with data type of float32 or bfloat16.
8853
+ The suggested shape is :math:`(1,)` / :math:`(1, 1, q_H)` / :math:`(q_H, )` when output layout is BSH,
8854
+ :math:`(1,)` / :math:`(1, q_N, 1, D)` / :math:`(q_N, D) when layout is BNSD.
8855
+ Default: ``None``.
8856
+ quant_offset2 (Tensor, optional): Quantitative parametor, the tensor with data type of float32 or bfloat16.
8857
+ It has the same dtype and shape as `quant_scale2`.
8858
+ Default: ``None``.
8859
+ num_heads (int, optional): The number of heads. It is an integer in range [0, 256].
8860
+ Default: ``1``.
8861
+ scale_value (double, optional): The scale value indicating the scale coefficient, which is used as the scalar of
8862
+ Muls in the calculation.
8863
+ Default: ``1.0``.
8864
+ pre_tokens (int, optional): For sparse cumputing, indicating the number of previous tokens Attention needs to
8865
+ associated with.
8866
+ Default: ``2147483647``.
8867
+ next_tokens (int, optional): For sparse cumputing, indicating the number of next tokens Attention needs to
8868
+ associated with.
8869
+ Default: ``0``.
8870
+ input_layout (str, optional): the data layout of the input qkv, support `(BSH)` and `(BNSD)`.
8871
+ Default ``BSH``.
8872
+ num_key_value_heads (int, optional): An int indicates head numbers of ``key``/``value`` which are used
8873
+ in GQA algorithm. The value 0 indicates if the key and value have the same head nums, use `num_heads`.
8874
+ It it is specified(not 0), it must be a factor of `num_heads` and it must be equal to kv_n.
8875
+ Default: ``0``.
8876
+ sparse_mode (int, optional): An int specifies sparse mode, can be int from {0, 1, 2, 3, 4}.
8877
+ Default: ``0``.
8878
+
8879
+ - sparseMode = 0: If `attn_mask` is a null pointer, `pre_tokens` and `next_tokens` inputs are ignored
8880
+ (internally set to INT_MAX).
8881
+ - sparseMode = 2, 3, 4: `attn_mask` shape must be :math:`(S, S)` or :math:`(1, S, S)` or
8882
+ :math:`(1, 1, S, S)`, with S fixed at 2048. User must ensure that `attn_mask` is lower triangular.
8883
+ If not provided or incorrect shape, it will result in an error.
8884
+ - sparseMode = 1, 2, 3: Ignores `pre_tokens`, `next_tokens` inputs and sets values according
8885
+ to specific rules.
8886
+ - sparseMode = 4: `pre_tokens` and `next_tokens` must be non-negative.
8887
+
8888
+ inner_precise (int, optional): An int number from {0, 1} indicates computing mode.
8889
+ ``0`` for high precision mode for float16 dtype. ``1`` for high performance mode.
8890
+ Default: ``1``.
8271
8891
 
8272
- Supported Platforms:
8892
+ Returns:
8893
+ attention_out (Tensor) - Output tensor, has the same shape as `query` of
8894
+ :math:`(B, q_S, q_H)` / :math:`(B, q_N, q_S, q_D)`.
8895
+ Output dtype is determined by multiple factors, please refer to Note above for details.
8896
+
8897
+ Raises:
8898
+ TypeError: Dtype of `query` is not int8, float16 or bfloat16.
8899
+ TypeError: `query`, `key` and `value` don't have the same dtype.
8900
+ TypeError: Dtype of `attn_mask` is not bool, int8 or uint8.
8901
+ TypeError: Dtype of `pse_shift` is not bfloat16 or float16.
8902
+ TypeError: `scale_value` is not a double number.
8903
+ TypeError: `input_layout` is not a string.
8904
+ TypeError: `num_key_value_heads` is not an int.
8905
+ TypeError: `sparse_mode` is not an int.
8906
+ TypeError: `sparse_inner_precisemode` is not an int.
8907
+ TypeError: `quant_scale1` is not Tensor of type float32.
8908
+ TypeError: `deq_scale1` is not Tensor of type uint64 or float32.
8909
+ TypeError: `quant_scale2` is not Tensor of type float32.
8910
+ TypeError: `deq_scale2` is not Tensor of type uint64 or float32.
8911
+ TypeError: `quant_offset2` is not Tensor of type float32.
8912
+ ValueError: `input_layout` is a string but of `(BSH)` or `(BNSD)`.
8913
+ RuntimeError: `num_heads` is not divisible by `num_key_value_heads`.
8914
+ RuntimeError: `num_heads` is not greater than 0.
8915
+ RuntimeError: `num_key_value_heads` is not greater than or equal to 0.
8916
+ RuntimeError: kv_n is not equal to `num_key_value_heads`.
8917
+ RuntimeError: `attn_mask` shape is not valid.
8918
+ RuntimeError: `sparse_mode` is specified but is not 0, 1, 2, 3 or 4.
8919
+ RuntimeError: `query` dtype is bfloat16 and D axis is not aligned with 16.
8920
+ RuntimeError: `input_layout` is BSH and kv_h is not divisible by `num_key_value_heads`.
8921
+ RuntimeError: D-axis of `query`, `key` and `value` is not the same.
8922
+ RuntimeError: In post quant per-channel scenario, D-axis is not 32 Byte aligned.
8923
+
8924
+ Supported Platforms:
8273
8925
  ``Ascend``
8274
8926
 
8275
8927
  Examples:
8276
- >>> from mindspore.ops.function.nn_func import prompt_flash_attention
8277
- >>> from mindspore import Tensor
8928
+ >>> from mindspore import Tensor, ops
8278
8929
  >>> import numpy as np
8279
8930
  >>> B = 1
8280
8931
  >>> N = 16
@@ -8284,13 +8935,13 @@ def prompt_flash_attention(query, key, value, attn_mask, actual_seq_lengths, act
8284
8935
  >>> key = Tensor(np.ones((B, N, S, D), dtype=np.float16))
8285
8936
  >>> value = Tensor(np.ones((B, N, S, D), dtype=np.float16))
8286
8937
  >>> out = ops.prompt_flash_attention(query, key, value, None, None, None, None, None, None, None, None,
8287
- None, N, input_layout='BNSD')
8938
+ ... None, N, input_layout='BNSD')
8288
8939
  >>> print(out.shape)
8289
8940
  (1, 16, 256, 16)
8290
8941
  """
8291
8942
 
8292
- pfa = _get_cache_prim(NN_OPS.PromptFlashAttention)(num_heads, scale_value, pre_tokens, next_tokens, input_layout,
8293
- num_key_value_heads, sparse_mode, inner_precise)
8943
+ pfa = _get_cache_prim(PromptFlashAttention)(num_heads, scale_value, pre_tokens, next_tokens, input_layout,
8944
+ num_key_value_heads, sparse_mode, inner_precise)
8294
8945
  return pfa(query, key, value, attn_mask, actual_seq_lengths, actual_seq_lengths_kv, pse_shift, deq_scale1,
8295
8946
  quant_scale1, deq_scale2, quant_scale2, quant_offset2)
8296
8947
 
@@ -8301,21 +8952,17 @@ def incre_flash_attention(query, key, value, attn_mask=None, actual_seq_lengths=
8301
8952
  num_heads=1, input_layout='BSH', scale_value=1.0, num_key_value_heads=0,
8302
8953
  block_size=0, inner_precise=1, kv_padding_size=None):
8303
8954
  r"""
8304
- B -- Batch size
8305
-
8306
- N -- Num heads
8307
-
8308
- kvN -- Num key value heads
8955
+ The interface for incremental inference.
8309
8956
 
8310
- S -- Sequence length
8957
+ - B: Batch size
8958
+ - N: Num of attention heads
8959
+ - kvN: Num of `key` / `value` heads
8960
+ - S: Sequence length
8961
+ - D: Head dim
8962
+ - H: Hidden layer size
8963
+ - kvH: Hidden size of `key` / `value`
8311
8964
 
8312
- D -- Head dim
8313
-
8314
- H -- Hidden size
8315
-
8316
- kvH -- Hidden size of key value
8317
-
8318
- where :math:`H=N\times D`, :math:`kvH=kvN\times D`
8965
+ where :math:`H=N\times D`, :math:`kvH=kvN\times D`.
8319
8966
 
8320
8967
  Self attention constructs an attention model based on the relationship between input samples themselves. The
8321
8968
  principle is to assume that there is a length of the input sample sequence :math:`x` of :math:`n`, and each
@@ -8330,62 +8977,62 @@ def incre_flash_attention(query, key, value, attn_mask=None, actual_seq_lengths=
8330
8977
  becoming too large, it is usually scaled by dividing it by the square root of :math:`d` and perform softmax
8331
8978
  normalization on each row, yields a matrix of :math:`n\times d` after multiplying :math:`V`.
8332
8979
 
8333
- .. warning::
8334
- This is an experimental API that is subject to change or deletion.
8335
-
8336
8980
  Note:
8337
- - If there is no input parameter and no default value, None needs to be passed.
8338
- - The shape of the tensor corresponding to the key and value parameters needs to be completely consistent.
8339
- - :math:`N` of parameter query is equal with num_heads. :math:`N` of parameter key and parameter value is equal
8340
- with num_key_value_heads. num_heads is a multiple of num_key_value_heads.
8981
+ - If there is no input parameter and no default value, ``None`` needs to be passed.
8982
+ - The shape of the tensor corresponding to the `key` and `value` parameters needs to be completely consistent.
8983
+ - :math:`N` of parameter `query` is equal with `num_heads`. :math:`N` of parameter `key` and parameter `value`
8984
+ is equal with `num_key_value_heads`. `num_heads` is a multiple of `num_key_value_heads`.
8341
8985
  - Quantization
8342
8986
 
8343
- - When the data type of query, key, and value is float16 and the data type of output is int8, the input
8344
- parameter quant_scale2 is required and quant_offset2 is optional.
8345
- - When antiquant_scale exists, key and value need to be passed by int8. antiquant_offset is optional.
8346
- - The data type of antiquant_scale and antiquant_offset should be consistency with that of query.
8347
- - pse_shift
8987
+ - When the data type of `query`, `key`, and `value` is float16 and the data type of output is int8, the input
8988
+ parameter `quant_scale2` is required and `quant_offset2` is optional.
8989
+ - When `antiquant_scale` exists, `key` and `value` need to be passed by int8. `antiquant_offset` is optional.
8990
+ - The data type of `antiquant_scale` and `antiquant_offset` should be consistenct with that of `query`.
8991
+ - `pse_shift`
8348
8992
 
8349
- - The pse_shift data type needs to be consistent with the query data type, and only supports D-axis alignment,
8993
+ - The `pse_shift` data type needs to be consistent with `query`, and only supports D-axis alignment,
8350
8994
  which means that the D-axis can be divided by 16.
8351
8995
  - Page attention:
8352
8996
 
8353
- - The necessary condition for enabling page attention is that the block_table exists, and the key
8354
- and value are arranged in a contiguous memory according to the index in the block_table. The support for
8355
- key and value dtypes is float16/bfloat16/int8.
8356
- - In the enabling scenario of page attention, 16 alignment is required when input types of key and value are
8357
- float16/bfloat16, and 32 alignment is required when input types of key and value are int8. It is
8358
- recommended to use 128.
8997
+ - The necessary condition for enabling page attention is that the `block_table` exists, and the `key`
8998
+ and `value` are arranged in a contiguous memory according to the index in the `block_table`. The support
8999
+ dtype for `key` and `value` is float16/bfloat16/int8.
9000
+ - In the enabling scenario of page attention, 16 alignment is required when input types of `key`
9001
+ and `value` are float16/bfloat16, and 32 alignment is required when input dtype of `key` and `value`
9002
+ is int8. It is recommended to use 128.
8359
9003
  - The maximum max_block_num_per_seq currently supported by blocktable is 16k, and exceeding 16k will result
8360
9004
  in interception and error messages; If you encounter :math:`S` being too large and causing
8361
- max_block_num_per_seq to exceed 16k, you can increase the block_size to solve the problem.
8362
- - The multiplication of all dimensions of the shape of the parameters key and value in the page attention
9005
+ max_block_num_per_seq to exceed 16k, you can increase the `block_size` to solve the problem.
9006
+ - The multiplication of all dimensions of the shape of the parameters `key` and `value` in the page attention
8363
9007
  scenario cannot exceed the representation range of int32.
8364
9008
  - When performing per-channel post quantization, page attention cannot be enabled simultaneously.
8365
- - kv_padding_size:
9009
+ - `kv_padding_size`:
8366
9010
 
8367
9011
  - The calculation formula for the starting point of KV cache transfer is
8368
9012
  :math:`S-kv\_padding\_size-actual\_seq\_lengths`. The calculation formula for the transfer endpoint of KV
8369
9013
  cache is :math:`S-kv\_padding\_size`. When the starting or ending point of the KV cache transfer is less
8370
9014
  than 0, the returned data result is all 0.
8371
- - When kv_padding_size is less than 0, it will be set to 0.
8372
- - kv_padding_size needs to be enabled together with the actual_seq_lengths parameter, otherwise it is
9015
+ - When `kv_padding_size` is less than 0, it will be set to 0.
9016
+ - `kv_padding_size` needs to be enabled together with the `actual_seq_lengths` parameter, otherwise it is
8373
9017
  considered as the KV right padding scene.
8374
9018
  - It needs to be enabled together with the atten_mask parameter and ensure that the meaning of atten_mask is
8375
9019
  correct, that is, it can correctly hide invalid data. Otherwise, it will introduce accuracy issues.
8376
- - kv_padding_size does not support page attention scenarios
9020
+ - `kv_padding_size` does not support page attention scenarios.
9021
+
9022
+ .. warning::
9023
+ Only support on Atlas A2 training series.
8377
9024
 
8378
9025
  Args:
8379
9026
  query (Tensor): The query tensor with data type of float16 or bfloat16.
8380
9027
  The shape is :math:`(B, 1, H)` / :math:`(B, N, 1, D)`.
8381
- key (TensorList): The key tensor with data type of float16 or bfloat16 or int8.
9028
+ key (Union[tuple, list]): The key tensor with data type of float16 or bfloat16 or int8.
8382
9029
  The shape is :math:`(B, S, kvH)` / :math:`(B, kvN, S, D)`.
8383
- value (TensorList): The value tensor with data type of float16 or bfloat16 or int8.
9030
+ value (Union[tuple, list]): The value tensor with data type of float16 or bfloat16 or int8.
8384
9031
  The shape is :math:`(B, S, kvH)` / :math:`(B, kvN, S, D)`.
8385
9032
  attn_mask (Tensor, optional): The attention mask tensor with data type of bool or int8 or uint8.
8386
9033
  The shape is :math:`(B, S)` / :math:`(B, 1, S)` / :math:`(B, 1, 1, S)`. Default: ``None``.
8387
9034
  actual_seq_lengths (Union[Tensor, tuple[int], list[int]], optional): Describe actual sequence length of each
8388
- input with data type of int32 or int64. The shape is :math:`(B, )`. Default: ``None``.
9035
+ input with data type of int64. The shape is :math:`(B, )`. Default: ``None``.
8389
9036
  pse_shift (Tensor, optional): The position encoding tensor with data type of float16 or bfloat16. Input tensor
8390
9037
  of shape :math:`(1, N, 1, S)` / :math:`(B, N, 1, S)`. Default: ``None``.
8391
9038
  dequant_scale1 (Tensor, optional): Quantitative parametor, the tensor with data type of uint64 or float32. It
@@ -8400,22 +9047,25 @@ def incre_flash_attention(query, key, value, attn_mask=None, actual_seq_lengths=
8400
9047
  The shape is :math:`(1,)`. Default: ``None``.
8401
9048
  antiquant_scale (Tensor, optional): Pseudo Quantitative parametor, the tensor with data type of float16 or
8402
9049
  bfloat16. The shape is :math:`(2, kvN, 1, D)` when input_layout is 'BNSD' or :math:`(2, kvH)` when
8403
- input_layout is 'BSH'. Default: ``None``.
9050
+ input_layout is 'BSH'. Default: ``None``.
8404
9051
  antiquant_offset (Tensor, optional): Pseudo Quantitative parametor, the tensor with data type of float16 or
8405
9052
  bfloat16. The shape is :math:`(2, kvN, 1, D)` when input_layout is 'BNSD' or :math:`(2, kvH)` when
8406
- input_layout is 'BSH'. Default: ``None``.
9053
+ input_layout is 'BSH'. Default: ``None``.
8407
9054
  block_table (Tensor, optional): The tensor with data type of int32. The shape is
8408
9055
  :math:`(B, max\_block\_num\_per\_seq)`,
8409
9056
  where :math:`max\_block\_num\_per\_seq = ceil(\frac{max(actual\_seq\_length)}{block\_size} )`.
8410
9057
  Default: ``None``.
8411
- num_heads (int): The number of heads.
8412
- input_layout (str): The data layout of the input qkv, support 'BSH' and 'BNSD'. Default ``'BSH'``.
8413
- scale_value (double): The scale value indicating the scale coefficient, which is used as the scalar of
8414
- Muls in the calculation. Default: ``1.0``.
8415
- num_key_value_heads (int): Head numbers of key/value which are used in GQA algorithm.
8416
- The value 0 indicates if the key and value have the same head nums, use numHeads. Default: ``0``.
8417
- block_size (int): The maximum number of tokens stored in each block of KV in page attention. Default: ``0``.
8418
- inner_precise (int): Default: ``1``.
9058
+ num_heads (int, optional): The number of heads. Default: ``1``.
9059
+ input_layout (str, optional): The data layout of the input qkv, support 'BSH' and 'BNSD'. Default ``'BSH'``.
9060
+ scale_value (double, optional): The scale value indicating the scale coefficient, which is used as
9061
+ the scalar of Muls in the calculation. Default: ``1.0``.
9062
+ num_key_value_heads (int, optional): Head numbers of `key`/`value` which are used in GQA algorithm.
9063
+ The value 0 indicates if the `key` and `value` have the same head nums, use numHeads. Default: ``0``.
9064
+ block_size (int, optional): The maximum number of tokens stored in each block of KV in page attention.
9065
+ Default: ``0``.
9066
+ inner_precise (int, optional): An int number from {0, 1} indicates computing mode.
9067
+ ``0`` for high precision mode for float16 dtype. ``1`` for high performance mode.
9068
+ Default: ``1``.
8419
9069
  kv_padding_size (Tensor, optional): The tensor with data type of int64. The range of values is
8420
9070
  :math:`0\le kv\_padding\_size \le S-max(actual\_seq\_length)`. The shape is :math:`()` or :math:`(1,)`.
8421
9071
  Default: ``None``.
@@ -8423,6 +9073,25 @@ def incre_flash_attention(query, key, value, attn_mask=None, actual_seq_lengths=
8423
9073
  Returns:
8424
9074
  attention_out (Tensor), the shape is :math:`(B, 1, H)` / :math:`(B, N, 1, D)`.
8425
9075
 
9076
+ Raises:
9077
+ TypeError: dtype of `query` is not float16 or bfloat16.
9078
+ TypeError: `key` and `value` don't have the same dtype.
9079
+ TypeError: dtype of `attn_mask` is not bool, int8 or uint8.
9080
+ TypeError: dtype of `pse_shift` is not bfloat16 or float16.
9081
+ TypeError: `scale_value` is not a double number.
9082
+ TypeError: `input_layout` is not a string.
9083
+ TypeError: `num_key_value_heads` or `num_heads` is not an int.
9084
+ TypeError: `inner_precise` is not an int.
9085
+ TypeError: `quant_scale1` is not Tensor of type float32.
9086
+ TypeError: `quant_scale2` is not Tensor of type float32.
9087
+ TypeError: `quant_offset2` is not Tensor of type float32.
9088
+ ValueError: size of `actual_seq_lengths` is not 1 or B.
9089
+ ValueError: `input_layout` is a string but of `(BSH)` or `(BNSD)`.
9090
+ ValueError: `num_heads` is not divisible by Q_H.
9091
+ ValueError: `num_heads` is not divisible by `num_key_value_heads`.
9092
+ RuntimeError: `num_heads` is not greater than 0.
9093
+ RuntimeError: `attn_mask` shape is not valid.
9094
+
8426
9095
  Supported Platforms:
8427
9096
  ``Ascend``
8428
9097
 
@@ -8435,7 +9104,7 @@ def incre_flash_attention(query, key, value, attn_mask=None, actual_seq_lengths=
8435
9104
  >>> query = Tensor(np.random.randn(B, 1, N * D), mstype.float16)
8436
9105
  >>> key = [Tensor(np.random.randn(B, S, kvN * D), mstype.float16)]
8437
9106
  >>> value = [Tensor(np.random.randn(B, S, kvN * D), mstype.float16)]
8438
- >>> ifa_ms = ops.functional.incre_flash_attention
9107
+ >>> ifa_ms = ops.incre_flash_attention
8439
9108
  >>> attn_out = ifa_ms(query, key, value, num_heads=N, num_key_value_heads=kvN)
8440
9109
  >>> attn_out
8441
9110
  Tensor(shape=[1, 1, 512], dtype=Float16, value=
@@ -8458,7 +9127,7 @@ def embedding(input, weight, padding_idx=None, max_norm=None, norm_type=2.0, sca
8458
9127
  Args:
8459
9128
  input (Tensor): The indices used to lookup in the `weight`. The data type must be mindspore.int32 or
8460
9129
  mindspore.int64, and the value should be in range `[0, weight.shape[0])`.
8461
- weight (Parameter): The matrix where to lookup from. The shape must be 2D.
9130
+ weight (Union[Parameter, Tensor]): The matrix where to lookup from. The shape must be 2D.
8462
9131
  padding_idx (int, optional): If the value is not None, the corresponding row of `weight` will not be updated
8463
9132
  in training. The value should be in range `[-weight.shape[0], weight.shape[0])` if it's not ``None``.
8464
9133
  Default ``None``.
@@ -8475,7 +9144,6 @@ def embedding(input, weight, padding_idx=None, max_norm=None, norm_type=2.0, sca
8475
9144
  Raises:
8476
9145
  ValueError: If `padding_idx` is out of valid range.
8477
9146
  ValueError: If the shape of `weight` is invalid.
8478
- TypeError: `weight` is not a :class:`mindspore.Parameter`.
8479
9147
 
8480
9148
  Supported Platforms:
8481
9149
  ``Ascend``
@@ -8535,6 +9203,8 @@ __all__ = [
8535
9203
  'hardshrink',
8536
9204
  'is_floating_point',
8537
9205
  'incre_flash_attention',
9206
+ 'prompt_flash_attention',
9207
+ 'flash_attention_score',
8538
9208
  'flip',
8539
9209
  'fliplr',
8540
9210
  'flipud',
@@ -8605,5 +9275,6 @@ __all__ = [
8605
9275
  'add_layer_norm',
8606
9276
  'group_norm',
8607
9277
  'rms_norm',
9278
+ 'add_rms_norm',
8608
9279
  ]
8609
9280
  __all__.sort()