mindspore 2.6.0__cp310-cp310-win_amd64.whl → 2.7.0__cp310-cp310-win_amd64.whl

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

Potentially problematic release.


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

Files changed (455) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
  3. mindspore/Newtonsoft.Json.dll +0 -0
  4. mindspore/__init__.py +2 -2
  5. mindspore/_c_dataengine.cp310-win_amd64.pyd +0 -0
  6. mindspore/_c_expression.cp310-win_amd64.pyd +0 -0
  7. mindspore/_c_mindrecord.cp310-win_amd64.pyd +0 -0
  8. mindspore/_checkparam.py +42 -11
  9. mindspore/_extends/builtin_operations.py +3 -3
  10. mindspore/{_deprecated → _extends/optimize}/__init__.py +9 -3
  11. mindspore/_extends/optimize/cell_utils.py +96 -0
  12. mindspore/_extends/parallel_compile/akg_compiler/custom.py +1109 -0
  13. mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
  14. mindspore/_extends/parse/__init__.py +3 -3
  15. mindspore/_extends/parse/compile_config.py +44 -22
  16. mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +1 -2
  17. mindspore/_extends/parse/parser.py +64 -83
  18. mindspore/_extends/parse/resources.py +39 -0
  19. mindspore/_extends/parse/standard_method.py +47 -14
  20. mindspore/_extends/parse/trope.py +8 -1
  21. mindspore/_extends/pijit/__init__.py +1 -2
  22. mindspore/_extends/pijit/pijit_func_white_list.py +2 -5
  23. mindspore/amp.py +4 -22
  24. mindspore/atlprov.dll +0 -0
  25. mindspore/avcodec-59.dll +0 -0
  26. mindspore/avdevice-59.dll +0 -0
  27. mindspore/avfilter-8.dll +0 -0
  28. mindspore/avformat-59.dll +0 -0
  29. mindspore/avutil-57.dll +0 -0
  30. mindspore/boost/adasum.py +1 -1
  31. mindspore/boost/boost_cell_wrapper.py +4 -4
  32. mindspore/c1.dll +0 -0
  33. mindspore/c1xx.dll +0 -0
  34. mindspore/c2.dll +0 -0
  35. mindspore/common/__init__.py +43 -12
  36. mindspore/common/_grad_function.py +2 -1
  37. mindspore/common/_pijit_context.py +28 -7
  38. mindspore/common/_stub_tensor.py +1 -209
  39. mindspore/common/_tensor_cpp_method.py +1 -1
  40. mindspore/common/_tensor_docs.py +177 -52
  41. mindspore/common/_utils.py +9 -1
  42. mindspore/common/api.py +338 -208
  43. mindspore/common/dtype.py +108 -57
  44. mindspore/common/dump.py +11 -16
  45. mindspore/common/dynamic_shape/__init__.py +0 -0
  46. mindspore/common/{auto_dynamic_shape.py → dynamic_shape/auto_dynamic_shape.py} +17 -23
  47. mindspore/common/dynamic_shape/enable_dynamic.py +197 -0
  48. mindspore/common/file_system.py +59 -9
  49. mindspore/common/generator.py +2 -3
  50. mindspore/common/hook_handle.py +33 -5
  51. mindspore/common/jit_config.py +1 -1
  52. mindspore/common/jit_trace.py +84 -105
  53. mindspore/common/np_dtype.py +3 -3
  54. mindspore/common/parameter.py +27 -29
  55. mindspore/common/recompute.py +5 -7
  56. mindspore/common/sparse_tensor.py +0 -3
  57. mindspore/common/symbol.py +0 -1
  58. mindspore/common/tensor.py +84 -133
  59. mindspore/communication/_comm_helper.py +46 -4
  60. mindspore/communication/management.py +79 -7
  61. mindspore/context.py +47 -38
  62. mindspore/dataset/__init__.py +1 -1
  63. mindspore/dataset/audio/transforms.py +1 -1
  64. mindspore/dataset/core/config.py +38 -4
  65. mindspore/dataset/engine/datasets.py +350 -322
  66. mindspore/dataset/engine/datasets_user_defined.py +69 -23
  67. mindspore/dataset/engine/iterators.py +2 -2
  68. mindspore/dataset/engine/obs/config_loader.py +2 -2
  69. mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +8 -0
  70. mindspore/dataset/transforms/c_transforms.py +2 -2
  71. mindspore/dataset/transforms/py_transforms.py +7 -3
  72. mindspore/dataset/transforms/transforms.py +10 -6
  73. mindspore/dataset/vision/__init__.py +1 -1
  74. mindspore/dataset/vision/py_transforms.py +8 -8
  75. mindspore/dataset/vision/transforms.py +17 -5
  76. mindspore/dataset/vision/utils.py +632 -21
  77. mindspore/dataset/vision/validators.py +1 -0
  78. mindspore/device_context/ascend/device.py +1 -1
  79. mindspore/device_context/ascend/op_tuning.py +35 -1
  80. mindspore/device_context/gpu/__init__.py +2 -2
  81. mindspore/device_context/gpu/device.py +1 -1
  82. mindspore/device_context/gpu/op_precision.py +4 -2
  83. mindspore/device_context/gpu/op_tuning.py +6 -3
  84. mindspore/device_manager.py +16 -9
  85. mindspore/dnnl.dll +0 -0
  86. mindspore/dpcmi.dll +0 -0
  87. mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +5 -4
  88. mindspore/experimental/llm_boost/atb/boost_base.py +2 -3
  89. mindspore/experimental/optim/adadelta.py +13 -20
  90. mindspore/experimental/optim/adagrad.py +15 -22
  91. mindspore/experimental/optim/adam.py +17 -24
  92. mindspore/experimental/optim/adamax.py +14 -22
  93. mindspore/experimental/optim/adamw.py +28 -34
  94. mindspore/experimental/optim/asgd.py +15 -25
  95. mindspore/experimental/optim/lr_scheduler.py +27 -45
  96. mindspore/experimental/optim/nadam.py +14 -24
  97. mindspore/experimental/optim/optimizer.py +13 -23
  98. mindspore/experimental/optim/radam.py +18 -24
  99. mindspore/experimental/optim/rmsprop.py +14 -25
  100. mindspore/experimental/optim/rprop.py +15 -26
  101. mindspore/experimental/optim/sgd.py +9 -19
  102. mindspore/hal/__init__.py +4 -4
  103. mindspore/hal/contiguous_tensors_handle.py +2 -2
  104. mindspore/hal/memory.py +1 -0
  105. mindspore/include/api/cell.h +65 -5
  106. mindspore/include/api/cfg.h +24 -7
  107. mindspore/include/api/context.h +1 -0
  108. mindspore/include/api/delegate.h +10 -2
  109. mindspore/include/api/dual_abi_helper.h +100 -19
  110. mindspore/include/api/graph.h +14 -1
  111. mindspore/include/api/kernel.h +16 -3
  112. mindspore/include/api/kernel_api.h +9 -1
  113. mindspore/include/api/metrics/accuracy.h +9 -0
  114. mindspore/include/api/model.h +8 -1
  115. mindspore/include/api/model_group.h +4 -0
  116. mindspore/include/api/model_parallel_runner.h +2 -0
  117. mindspore/include/api/status.h +48 -10
  118. mindspore/include/api/types.h +8 -3
  119. mindspore/include/c_api/model_c.h +0 -58
  120. mindspore/include/c_api/tensor_c.h +0 -26
  121. mindspore/include/dataset/constants.h +9 -0
  122. mindspore/include/dataset/vision_ascend.h +1 -1
  123. mindspore/jpeg62.dll +0 -0
  124. mindspore/mindrecord/tools/cifar10.py +61 -11
  125. mindspore/mindrecord/tools/cifar10_to_mr.py +5 -0
  126. mindspore/mindspore_backend_common.dll +0 -0
  127. mindspore/mindspore_backend_manager.dll +0 -0
  128. mindspore/mindspore_common.dll +0 -0
  129. mindspore/mindspore_core.dll +0 -0
  130. mindspore/mindspore_cpu_res_manager.dll +0 -0
  131. mindspore/mindspore_dump.dll +0 -0
  132. mindspore/mindspore_frontend.dll +0 -0
  133. mindspore/mindspore_glog.dll +0 -0
  134. mindspore/mindspore_memory_pool.dll +0 -0
  135. mindspore/mindspore_ms_backend.dll +0 -0
  136. mindspore/mindspore_ops.dll +0 -0
  137. mindspore/mindspore_ops_host.dll +0 -0
  138. mindspore/mindspore_ops_kernel_common.dll +0 -0
  139. mindspore/mindspore_profiler.dll +0 -0
  140. mindspore/mindspore_pyboost.dll +0 -0
  141. mindspore/mindspore_pynative.dll +0 -0
  142. mindspore/mindspore_res_manager.dll +0 -0
  143. mindspore/mindspore_runtime_pipeline.dll +0 -0
  144. mindspore/mint/__init__.py +4 -44
  145. mindspore/mint/distributed/__init__.py +5 -0
  146. mindspore/mint/distributed/distributed.py +425 -19
  147. mindspore/mint/nn/__init__.py +1 -1
  148. mindspore/mint/nn/functional.py +53 -6
  149. mindspore/mint/nn/layer/_functions.py +163 -294
  150. mindspore/mint/nn/layer/activation.py +8 -6
  151. mindspore/mint/nn/layer/conv.py +125 -101
  152. mindspore/mint/nn/layer/normalization.py +11 -25
  153. mindspore/mint/optim/adam.py +19 -18
  154. mindspore/mint/optim/adamw.py +14 -8
  155. mindspore/mint/optim/sgd.py +5 -5
  156. mindspore/msobj140.dll +0 -0
  157. mindspore/mspdb140.dll +0 -0
  158. mindspore/mspdbcore.dll +0 -0
  159. mindspore/mspdbst.dll +0 -0
  160. mindspore/mspft140.dll +0 -0
  161. mindspore/msvcdis140.dll +0 -0
  162. mindspore/msvcp140_1.dll +0 -0
  163. mindspore/msvcp140_2.dll +0 -0
  164. mindspore/msvcp140_atomic_wait.dll +0 -0
  165. mindspore/msvcp140_codecvt_ids.dll +0 -0
  166. mindspore/nn/cell.py +488 -620
  167. mindspore/nn/grad/cell_grad.py +11 -12
  168. mindspore/nn/layer/activation.py +36 -36
  169. mindspore/nn/layer/basic.py +74 -77
  170. mindspore/nn/layer/channel_shuffle.py +4 -4
  171. mindspore/nn/layer/combined.py +4 -2
  172. mindspore/nn/layer/conv.py +86 -85
  173. mindspore/nn/layer/dense.py +9 -7
  174. mindspore/nn/layer/embedding.py +50 -52
  175. mindspore/nn/layer/image.py +38 -40
  176. mindspore/nn/layer/math.py +111 -112
  177. mindspore/nn/layer/normalization.py +56 -44
  178. mindspore/nn/layer/pooling.py +58 -63
  179. mindspore/nn/layer/rnn_cells.py +33 -33
  180. mindspore/nn/layer/rnns.py +56 -56
  181. mindspore/nn/layer/thor_layer.py +74 -73
  182. mindspore/nn/layer/transformer.py +11 -1
  183. mindspore/nn/learning_rate_schedule.py +20 -20
  184. mindspore/nn/loss/loss.py +79 -81
  185. mindspore/nn/optim/adam.py +2 -4
  186. mindspore/nn/optim/adasum.py +2 -2
  187. mindspore/nn/optim/lamb.py +1 -3
  188. mindspore/nn/optim/optimizer.py +1 -1
  189. mindspore/nn/optim/tft_wrapper.py +2 -3
  190. mindspore/nn/optim/thor.py +2 -2
  191. mindspore/nn/probability/distribution/_utils/utils.py +2 -2
  192. mindspore/nn/probability/distribution/exponential.py +2 -1
  193. mindspore/nn/probability/distribution/poisson.py +2 -1
  194. mindspore/nn/sparse/sparse.py +3 -3
  195. mindspore/nn/wrap/cell_wrapper.py +73 -42
  196. mindspore/nn/wrap/grad_reducer.py +37 -52
  197. mindspore/nn/wrap/loss_scale.py +72 -74
  198. mindspore/numpy/array_creations.py +7 -7
  199. mindspore/numpy/fft.py +1 -1
  200. mindspore/numpy/math_ops.py +1 -1
  201. mindspore/numpy/utils_const.py +1 -1
  202. mindspore/opencv_core452.dll +0 -0
  203. mindspore/opencv_imgcodecs452.dll +0 -0
  204. mindspore/opencv_imgproc452.dll +0 -0
  205. mindspore/ops/_grad_experimental/grad_comm_ops.py +51 -13
  206. mindspore/ops/_grad_experimental/grad_debug_ops.py +14 -0
  207. mindspore/ops/_grad_experimental/grad_inner_ops.py +0 -9
  208. mindspore/ops/_op_impl/cpu/__init__.py +1 -0
  209. mindspore/{experimental/es/__init__.py → ops/_op_impl/cpu/joinedstr_op.py} +12 -6
  210. mindspore/ops/_vmap/vmap_array_ops.py +6 -13
  211. mindspore/ops/_vmap/vmap_nn_ops.py +8 -16
  212. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +29 -10
  213. mindspore/ops/auto_generate/gen_extend_func.py +5 -55
  214. mindspore/ops/auto_generate/gen_ops_def.py +753 -273
  215. mindspore/ops/auto_generate/gen_ops_prim.py +1687 -958
  216. mindspore/ops/auto_generate/pyboost_inner_prim.py +31 -1
  217. mindspore/ops/composite/__init__.py +10 -0
  218. mindspore/ops/composite/base.py +9 -5
  219. mindspore/ops/composite/multitype_ops/__init__.py +12 -1
  220. mindspore/ops/composite/multitype_ops/_compile_utils.py +132 -108
  221. mindspore/ops/composite/multitype_ops/_constexpr_utils.py +1 -1
  222. mindspore/ops/composite/multitype_ops/add_impl.py +70 -2
  223. mindspore/ops/composite/multitype_ops/div_impl.py +49 -0
  224. mindspore/ops/composite/multitype_ops/floordiv_impl.py +29 -0
  225. mindspore/ops/composite/multitype_ops/getitem_impl.py +11 -0
  226. mindspore/ops/composite/multitype_ops/mod_impl.py +5 -3
  227. mindspore/ops/composite/multitype_ops/mul_impl.py +49 -0
  228. mindspore/ops/composite/multitype_ops/setitem_impl.py +57 -0
  229. mindspore/ops/composite/multitype_ops/sub_impl.py +34 -0
  230. mindspore/ops/composite/multitype_ops/zeros_like_impl.py +14 -0
  231. mindspore/ops/function/__init__.py +4 -1
  232. mindspore/ops/function/_add_attr_func.py +11 -6
  233. mindspore/ops/function/array_func.py +17 -100
  234. mindspore/ops/function/debug_func.py +8 -5
  235. mindspore/ops/function/grad/grad_func.py +5 -13
  236. mindspore/ops/function/math_func.py +65 -399
  237. mindspore/ops/function/nn_func.py +44 -61
  238. mindspore/ops/function/other_func.py +4 -1
  239. mindspore/ops/function/random_func.py +31 -4
  240. mindspore/ops/functional.py +2 -3
  241. mindspore/ops/functional_overload.py +486 -18
  242. mindspore/ops/op_info_register.py +21 -0
  243. mindspore/ops/operations/__init__.py +5 -2
  244. mindspore/ops/operations/_custom_ops_utils.py +675 -8
  245. mindspore/ops/operations/_inner_ops.py +14 -18
  246. mindspore/ops/operations/_sequence_ops.py +1 -1
  247. mindspore/ops/operations/array_ops.py +4 -50
  248. mindspore/ops/operations/comm_ops.py +186 -41
  249. mindspore/ops/operations/custom_ops.py +244 -175
  250. mindspore/ops/operations/debug_ops.py +55 -4
  251. mindspore/ops/operations/image_ops.py +13 -13
  252. mindspore/ops/operations/manually_defined/ops_def.py +27 -28
  253. mindspore/ops/operations/math_ops.py +8 -9
  254. mindspore/ops/operations/nn_ops.py +6 -7
  255. mindspore/ops/primitive.py +9 -20
  256. mindspore/ops/tensor_method.py +52 -11
  257. mindspore/ops_generate/api/cpp_create_prim_instance_helper_generator.py +1 -1
  258. mindspore/ops_generate/api/functional_map_cpp_generator.py +10 -9
  259. mindspore/ops_generate/api/functions_cc_generator.py +58 -10
  260. mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +1 -1
  261. mindspore/ops_generate/common/base_generator.py +14 -0
  262. mindspore/ops_generate/common/gen_constants.py +7 -2
  263. mindspore/ops_generate/common/gen_utils.py +0 -19
  264. mindspore/ops_generate/common/op_proto.py +11 -4
  265. mindspore/ops_generate/common/template.py +88 -11
  266. mindspore/ops_generate/gen_ops.py +1 -1
  267. mindspore/ops_generate/op_def/lite_ops_cpp_generator.py +4 -4
  268. mindspore/ops_generate/op_def/ops_name_h_generator.py +0 -3
  269. mindspore/ops_generate/op_def/ops_primitive_h_generator.py +0 -4
  270. mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -2
  271. mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +49 -8
  272. mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +2 -2
  273. mindspore/ops_generate/pyboost/gen_pyboost_func.py +31 -16
  274. mindspore/ops_generate/pyboost/op_template_parser.py +98 -72
  275. mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +70 -273
  276. mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +14 -6
  277. mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +316 -0
  278. mindspore/ops_generate/pyboost/pyboost_functions_py_generator.py +1 -1
  279. mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +5 -3
  280. mindspore/ops_generate/pyboost/pyboost_inner_prim_generator.py +1 -1
  281. mindspore/ops_generate/pyboost/pyboost_internal_functions_cpp_generator.py +76 -0
  282. mindspore/ops_generate/pyboost/pyboost_internal_functions_h_generator.py +76 -0
  283. mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +125 -0
  284. mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +4 -3
  285. mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +348 -61
  286. mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +1 -1
  287. mindspore/ops_generate/pyboost/pyboost_utils.py +118 -9
  288. mindspore/ops_generate/tensor_py_cc_generator.py +1 -24
  289. mindspore/parallel/_auto_parallel_context.py +9 -17
  290. mindspore/parallel/_cell_wrapper.py +106 -40
  291. mindspore/parallel/_parallel_serialization.py +4 -3
  292. mindspore/parallel/_ps_context.py +4 -6
  293. mindspore/parallel/_tensor.py +167 -12
  294. mindspore/parallel/_transformer/moe.py +1 -1
  295. mindspore/parallel/_transformer/transformer.py +17 -12
  296. mindspore/parallel/_utils.py +5 -11
  297. mindspore/parallel/auto_parallel.py +33 -12
  298. mindspore/parallel/checkpoint_convert.py +3 -3
  299. mindspore/parallel/checkpoint_transform.py +5 -1
  300. mindspore/parallel/cluster/process_entity/_api.py +88 -49
  301. mindspore/parallel/cluster/process_entity/_utils.py +95 -7
  302. mindspore/parallel/cluster/run.py +48 -7
  303. mindspore/parallel/function/__init__.py +8 -1
  304. mindspore/parallel/function/reshard_func.py +7 -6
  305. mindspore/parallel/nn/__init__.py +15 -2
  306. mindspore/parallel/nn/parallel_cell_wrapper.py +50 -14
  307. mindspore/parallel/nn/parallel_grad_reducer.py +7 -14
  308. mindspore/parallel/shard.py +9 -23
  309. mindspore/parallel/transform_safetensors.py +468 -174
  310. mindspore/pgodb140.dll +0 -0
  311. mindspore/pgort140.dll +0 -0
  312. mindspore/profiler/__init__.py +2 -1
  313. mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +7 -7
  314. mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +3 -0
  315. mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +3 -0
  316. mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +3 -3
  317. mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +3 -3
  318. mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +4 -4
  319. mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +3 -3
  320. mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +4 -1
  321. mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +2 -1
  322. mindspore/profiler/analysis/task_manager.py +1 -1
  323. mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +5 -1
  324. mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +2 -1
  325. mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +10 -9
  326. mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +43 -23
  327. mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +3 -2
  328. mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +9 -5
  329. mindspore/profiler/analysis/viewer/ms_operator_details_viewer.py +132 -0
  330. mindspore/profiler/common/constant.py +16 -0
  331. mindspore/profiler/common/msprof_cmd_tool.py +2 -2
  332. mindspore/profiler/common/path_manager.py +9 -0
  333. mindspore/profiler/common/profiler_context.py +50 -29
  334. mindspore/profiler/common/profiler_info.py +0 -16
  335. mindspore/profiler/common/profiler_meta_data.py +1 -0
  336. mindspore/profiler/common/profiler_op_analyse.py +239 -0
  337. mindspore/profiler/common/profiler_output_path.py +23 -8
  338. mindspore/profiler/common/profiler_parameters.py +128 -35
  339. mindspore/profiler/dynamic_profile/__init__.py +0 -0
  340. mindspore/profiler/dynamic_profile/dynamic_monitor_proxy.py +39 -0
  341. mindspore/profiler/dynamic_profile/dynamic_profiler_config_context.py +666 -0
  342. mindspore/profiler/dynamic_profile/dynamic_profiler_utils.py +62 -0
  343. mindspore/profiler/dynamic_profiler.py +374 -338
  344. mindspore/profiler/envprofiler.py +42 -12
  345. mindspore/profiler/experimental_config.py +112 -7
  346. mindspore/profiler/mstx.py +33 -12
  347. mindspore/profiler/platform/__init__.py +2 -3
  348. mindspore/profiler/platform/cpu_profiler.py +10 -4
  349. mindspore/profiler/platform/npu_profiler.py +30 -20
  350. mindspore/profiler/profiler.py +218 -154
  351. mindspore/profiler/profiler_action_controller.py +65 -77
  352. mindspore/profiler/profiler_interface.py +2 -2
  353. mindspore/profiler/schedule.py +10 -4
  354. mindspore/rewrite/common/config.py +1 -0
  355. mindspore/rewrite/common/namer.py +1 -0
  356. mindspore/rewrite/common/namespace.py +1 -0
  357. mindspore/rewrite/node/node.py +31 -11
  358. mindspore/rewrite/parsers/assign_parser.py +1 -1
  359. mindspore/rewrite/symbol_tree/symbol_tree.py +2 -2
  360. mindspore/run_check/_check_version.py +7 -10
  361. mindspore/runtime/__init__.py +8 -6
  362. mindspore/runtime/event.py +10 -4
  363. mindspore/runtime/executor.py +87 -45
  364. mindspore/runtime/memory.py +22 -30
  365. mindspore/runtime/thread_bind_core.py +299 -165
  366. mindspore/safeguard/rewrite_obfuscation.py +12 -13
  367. mindspore/swresample-4.dll +0 -0
  368. mindspore/swscale-6.dll +0 -0
  369. mindspore/tbbmalloc.dll +0 -0
  370. mindspore/tinyxml2.dll +0 -0
  371. mindspore/train/_utils.py +9 -5
  372. mindspore/train/amp.py +43 -23
  373. mindspore/train/callback/__init__.py +5 -5
  374. mindspore/train/callback/_callback.py +2 -1
  375. mindspore/train/callback/_checkpoint.py +4 -14
  376. mindspore/train/callback/_flops_collector.py +11 -7
  377. mindspore/train/callback/_landscape.py +0 -1
  378. mindspore/train/callback/_train_fault_tolerance.py +72 -18
  379. mindspore/train/data_sink.py +15 -6
  380. mindspore/train/dataset_helper.py +14 -5
  381. mindspore/train/model.py +49 -47
  382. mindspore/train/serialization.py +168 -126
  383. mindspore/train/summary/summary_record.py +13 -2
  384. mindspore/train/train_thor/model_thor.py +2 -2
  385. mindspore/turbojpeg.dll +0 -0
  386. mindspore/utils/__init__.py +3 -2
  387. mindspore/utils/dryrun.py +0 -6
  388. mindspore/utils/runtime_execution_order_check.py +162 -78
  389. mindspore/utils/sdc_detect.py +68 -0
  390. mindspore/utils/utils.py +14 -17
  391. mindspore/vcmeta.dll +0 -0
  392. mindspore/vcruntime140.dll +0 -0
  393. mindspore/vcruntime140_1.dll +0 -0
  394. mindspore/version.py +1 -1
  395. {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/METADATA +5 -4
  396. {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/RECORD +400 -439
  397. mindspore/_deprecated/jit.py +0 -198
  398. mindspore/_extends/remote/kernel_build_server_ascend.py +0 -75
  399. mindspore/communication/_hccl_management.py +0 -297
  400. mindspore/experimental/es/embedding_service.py +0 -891
  401. mindspore/experimental/es/embedding_service_layer.py +0 -581
  402. mindspore/profiler/common/validator/__init__.py +0 -14
  403. mindspore/profiler/common/validator/validate_path.py +0 -84
  404. mindspore/profiler/parser/__init__.py +0 -14
  405. mindspore/profiler/parser/aicpu_data_parser.py +0 -272
  406. mindspore/profiler/parser/ascend_analysis/__init__.py +0 -14
  407. mindspore/profiler/parser/ascend_analysis/constant.py +0 -71
  408. mindspore/profiler/parser/ascend_analysis/file_manager.py +0 -180
  409. mindspore/profiler/parser/ascend_analysis/function_event.py +0 -185
  410. mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +0 -136
  411. mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +0 -131
  412. mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +0 -104
  413. mindspore/profiler/parser/ascend_analysis/path_manager.py +0 -313
  414. mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +0 -123
  415. mindspore/profiler/parser/ascend_analysis/tlv_decoder.py +0 -86
  416. mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +0 -75
  417. mindspore/profiler/parser/ascend_cluster_generator.py +0 -116
  418. mindspore/profiler/parser/ascend_communicate_generator.py +0 -314
  419. mindspore/profiler/parser/ascend_flops_generator.py +0 -116
  420. mindspore/profiler/parser/ascend_fpbp_generator.py +0 -82
  421. mindspore/profiler/parser/ascend_hccl_generator.py +0 -271
  422. mindspore/profiler/parser/ascend_integrate_generator.py +0 -42
  423. mindspore/profiler/parser/ascend_memory_generator.py +0 -185
  424. mindspore/profiler/parser/ascend_msprof_exporter.py +0 -282
  425. mindspore/profiler/parser/ascend_msprof_generator.py +0 -187
  426. mindspore/profiler/parser/ascend_op_generator.py +0 -334
  427. mindspore/profiler/parser/ascend_steptrace_generator.py +0 -94
  428. mindspore/profiler/parser/ascend_timeline_generator.py +0 -545
  429. mindspore/profiler/parser/base_timeline_generator.py +0 -483
  430. mindspore/profiler/parser/container.py +0 -229
  431. mindspore/profiler/parser/cpu_gpu_timeline_generator.py +0 -697
  432. mindspore/profiler/parser/flops_parser.py +0 -531
  433. mindspore/profiler/parser/framework_enum.py +0 -111
  434. mindspore/profiler/parser/framework_parser.py +0 -464
  435. mindspore/profiler/parser/framework_struct.py +0 -61
  436. mindspore/profiler/parser/gpu_analysis/__init__.py +0 -14
  437. mindspore/profiler/parser/gpu_analysis/function_event.py +0 -44
  438. mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +0 -89
  439. mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +0 -72
  440. mindspore/profiler/parser/hccl_parser.py +0 -573
  441. mindspore/profiler/parser/hwts_log_parser.py +0 -122
  442. mindspore/profiler/parser/integrator.py +0 -526
  443. mindspore/profiler/parser/memory_usage_parser.py +0 -277
  444. mindspore/profiler/parser/minddata_analyzer.py +0 -800
  445. mindspore/profiler/parser/minddata_parser.py +0 -186
  446. mindspore/profiler/parser/minddata_pipeline_parser.py +0 -299
  447. mindspore/profiler/parser/op_intermediate_parser.py +0 -149
  448. mindspore/profiler/parser/optime_parser.py +0 -250
  449. mindspore/profiler/parser/profiler_info.py +0 -213
  450. mindspore/profiler/parser/step_trace_parser.py +0 -666
  451. mindspore/utils/hooks.py +0 -81
  452. /mindspore/common/{_auto_dynamic.py → dynamic_shape/_auto_dynamic.py} +0 -0
  453. {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/WHEEL +0 -0
  454. {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/entry_points.txt +0 -0
  455. {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/top_level.txt +0 -0
@@ -14,9 +14,7 @@
14
14
  # ============================================================================
15
15
 
16
16
  """Inner operators."""
17
- from types import FunctionType, MethodType
18
17
  from collections.abc import Iterable
19
- import os
20
18
  import weakref
21
19
  import numpy as np
22
20
 
@@ -27,18 +25,17 @@ from mindspore.ops.operations._scalar_ops import bit_or, bit_and
27
25
  from mindspore.ops import signature as sig
28
26
  from mindspore.ops.operations.math_ops import _infer_shape_reduce
29
27
  from mindspore.ops.primitive import PrimitiveWithCheck, PrimitiveWithInfer, prim_attr_register, Primitive, \
30
- _run_op, _check_contains_variable
28
+ _check_contains_variable
31
29
  from mindspore._c_expression import TensorPy as Tensor_
32
30
  from mindspore._c_expression import typing, HookType
33
- from mindspore._c_expression import pyboost_generator
31
+ from mindspore._c_expression import pyboost_generator, pyboost_cell_backward_hook
34
32
  from mindspore import _checkparam as validator
35
33
  from mindspore.common import dtype as mstype
36
34
  from mindspore.common.parameter import Parameter
37
- from mindspore.common._stub_tensor import _convert_stub
38
35
  from mindspore.communication.management import GlobalComm, get_rank, _get_group, get_group_size
39
36
  from mindspore.common.api import _pynative_executor
40
- from ..auto_generate import TensorCopySlices, SiLU, Cummin, TopKRouter, ExtractImagePatches, DecoderKVCache, \
41
- PromptKVCache, ApplyCamePart1, ApplyCamePart2, ApplyCamePart3, ApplyCamePart4
37
+ from ..auto_generate import TensorCopySlices, SiLU, Cummin, TopKRouter, TopPRouter, ExtractImagePatches, \
38
+ ApplyCamePart1, ApplyCamePart2, ApplyCamePart3, ApplyCamePart4
42
39
 
43
40
  # Bit operation
44
41
  bit_and = bit_and()
@@ -78,7 +75,7 @@ class Generator(Primitive):
78
75
  def __call__(self, cmd, inputs):
79
76
  if cmd == 0: # step cmd
80
77
  return inputs[0], inputs[1]
81
- return _convert_stub(pyboost_generator(self, [cmd, inputs]))
78
+ return pyboost_generator(self, [cmd, inputs])
82
79
 
83
80
 
84
81
  class Quant(PrimitiveWithInfer):
@@ -1568,10 +1565,11 @@ class CellBackwardHook(PrimitiveWithInfer):
1568
1565
  self.add_prim_attr("cell_id", cell_id)
1569
1566
  self.grad_output = None
1570
1567
 
1571
- def __call__(self, *args):
1572
- # If args is empty, just return.
1573
- if not args:
1574
- return args
1568
+ def __call__(self, args):
1569
+ is_tuple = True
1570
+ if not isinstance(args, tuple):
1571
+ args = (args,)
1572
+ is_tuple = False
1575
1573
 
1576
1574
  # Collect the indices and values of arguments that are instances of Tensor
1577
1575
  tensors_idx = []
@@ -1581,20 +1579,18 @@ class CellBackwardHook(PrimitiveWithInfer):
1581
1579
  tensors_idx.append(i)
1582
1580
  tensors.append(arg)
1583
1581
 
1584
- # If there are no Tensor arguments, return the single argument or the original tuple
1582
+ # If there are no Tensor arguments, return original args
1585
1583
  if not tensors:
1586
- return args[0] if len(args) == 1 else args
1584
+ return args if is_tuple else args[0]
1587
1585
 
1588
- new_tensors = _run_op(self, self.name, tensors)
1589
- if not isinstance(new_tensors, tuple):
1590
- new_tensors = (new_tensors,)
1586
+ new_tensors = pyboost_cell_backward_hook(self, (tensors,))
1591
1587
 
1592
1588
  # Replace the original Tensor arguments with the processed ones
1593
1589
  arg_list = list(args)
1594
1590
  for idx, val in zip(tensors_idx, new_tensors):
1595
1591
  arg_list[idx] = val
1596
1592
 
1597
- return arg_list[0] if len(arg_list) == 1 else tuple(arg_list)
1593
+ return tuple(arg_list) if is_tuple else arg_list[0]
1598
1594
 
1599
1595
  def infer_shape(self, *inputs_shape):
1600
1596
  if len(inputs_shape) == 1:
@@ -515,7 +515,7 @@ class TensorToScalar(PrimitiveWithCheck):
515
515
  """infer_value TensorToScalar"""
516
516
  if isinstance(x, (Tensor_, Tensor)):
517
517
  if not x.shape or x.shape == (1,) or x.shape == [1,]:
518
- return x.asnumpy().item()
518
+ return x.item()
519
519
  return None
520
520
 
521
521
 
@@ -42,7 +42,7 @@ from ..auto_generate import (
42
42
  NonZero, ResizeNearestNeighbor, Identity, Split, CumSum, CumProd,
43
43
  MaskedSelect, Cummax, Cummin, Argmin, Concat, UnsortedSegmentSum, UniqueConsecutive,
44
44
  ScalarToTensor, Triu, BroadcastTo, StridedSlice, Select, TopkExt,
45
- SearchSorted, Meshgrid, Squeeze, Slice, TransposeExtView)
45
+ SearchSorted, Meshgrid, Squeeze, Slice, TransposeExtView, MaskedScatter)
46
46
  from .manually_defined import Rank, Shape, Tile, Cast, Ones, Zeros, TypeAs
47
47
  from ..auto_generate import ArgMaxWithValue, ArgMinWithValue
48
48
  from ..auto_generate import TensorScatterElements as TensorScatterElementsExt
@@ -1048,11 +1048,11 @@ class Fill(PrimitiveWithCheck):
1048
1048
  self.init_prim_io_names(inputs=['type', 'shape', 'value'], outputs=['y'])
1049
1049
 
1050
1050
  def __call__(self, dtype, dims, x):
1051
- if dtype not in mstype.all_types and dtype not in [mstype.uint16, mstype.uint32, mstype.uint64]:
1051
+ if dtype not in mstype.all_types:
1052
1052
  raise TypeError(
1053
1053
  f"For \'{self.name}\', the supported data type is ['bool', 'int8', 'int16', 'int32', 'int64', 'uint8', "
1054
1054
  "'uint16', 'uint32', 'uint64','float16', 'float32', 'float64'], but got an invalid dtype!.")
1055
- x_nptype = mstype.dtype_to_nptype(dtype)
1055
+ x_nptype = mstype._dtype_to_nptype(dtype) # pylint:disable=protected-access
1056
1056
  if not isinstance(dims, Tensor) and not isinstance(dims, tuple):
1057
1057
  raise TypeError(f"For \'{self.name}\', input[1] must be tensor.")
1058
1058
  if not isinstance(x, Tensor) and not isinstance(x, float) and not isinstance(x, int):
@@ -1065,7 +1065,7 @@ class Fill(PrimitiveWithCheck):
1065
1065
  return Tensor(ret, dtype=dtype)
1066
1066
 
1067
1067
  def infer_value(self, dtype, dims, x):
1068
- x_nptype = mstype.dtype_to_nptype(dtype)
1068
+ x_nptype = mstype._dtype_to_nptype(dtype) # pylint:disable=protected-access
1069
1069
  if dims is not None and None not in dims and x is not None:
1070
1070
  if isinstance(dims, Tensor):
1071
1071
  dims = dims.asnumpy()
@@ -3974,52 +3974,6 @@ class RangeV2(Primitive):
3974
3974
  validator.check_positive_int(maxlen, "maxlen", self.name)
3975
3975
 
3976
3976
 
3977
- class MaskedScatter(Primitive):
3978
- """
3979
- Updates the value in the input with value in `updates` according to the `mask`.
3980
-
3981
- .. warning::
3982
- This is an experimental API that is subject to change or deletion.
3983
-
3984
- Inputs:
3985
- - **x** (Tensor): The input Tensor to be updated.
3986
- - **mask** (Tensor[bool]): The mask Tensor indicating which elements should be modified or replaced.
3987
- The shapes of `mask` and `x` must be the same or broadcastable.
3988
- - **updates** (Tensor): The values to scatter into the target tensor `x`. It has the same data type as `x`. The
3989
- number of elements must be greater than or equal to the number of True's in `mask`.
3990
-
3991
- Outputs:
3992
- Tensor, with the same type and shape as `x`.
3993
-
3994
- Raises:
3995
- TypeError: If `x`, `mask` or `updates` is not a Tensor.
3996
- TypeError: If data type of `x` is not be supported.
3997
- TypeError: If dtype of `mask` is not bool.
3998
- TypeError: If the dim of `x` less than the dim of `mask`.
3999
- ValueError: If `mask` can not be broadcastable to `x`.
4000
- ValueError: If the number of elements in `updates` is less than number of True's in `mask`.
4001
-
4002
- Supported Platforms:
4003
- ``Ascend`` ``CPU``
4004
-
4005
- Examples:
4006
- >>> import mindspore
4007
- >>> import numpy as np
4008
- >>> from mindspore import Tensor, ops
4009
- >>> input_x = Tensor(np.array([1., 2., 3., 4.]), mindspore.float32)
4010
- >>> mask = Tensor(np.array([True, True, False, True]), mindspore.bool_)
4011
- >>> updates = Tensor(np.array([5., 6., 7.]), mindspore.float32)
4012
- >>> output = ops.MaskedScatter()(input_x, mask, updates)
4013
- >>> print(output)
4014
- [5. 6. 3. 7.]
4015
- """
4016
-
4017
- @prim_attr_register
4018
- def __init__(self):
4019
- """Initialize MaskedScatter"""
4020
- self.init_prim_io_names(inputs=['x', 'mask', 'updates'], outputs=['y'])
4021
-
4022
-
4023
3977
  class _TensorScatterOp(PrimitiveWithInfer):
4024
3978
  """
4025
3979
  Defines TensorScatter Base Operators
@@ -18,10 +18,9 @@
18
18
  from __future__ import absolute_import
19
19
  from __future__ import division
20
20
 
21
- import os
22
21
  from mindspore.common import Tensor
23
22
  from mindspore import _checkparam as validator
24
- from mindspore.communication.management import get_rank, get_group_size, GlobalComm, _get_group, _host_distribute
23
+ from mindspore.communication.management import get_rank, get_group_size, GlobalComm, _get_group
25
24
  from mindspore.common import dtype as mstype
26
25
  from mindspore.ops.primitive import PrimitiveWithInfer, PrimitiveWithCheck, Primitive, prim_attr_register
27
26
  from mindspore.common.api import context
@@ -98,17 +97,6 @@ def check_collective_target_dtype(data_name, data_dtype, prim_name):
98
97
  validator.check_tensor_dtype_valid(data_name, data_dtype, valid_dtype, prim_name)
99
98
 
100
99
 
101
- def check_hcom_group_valid(group, prim_name=None):
102
- """Check if hcom group is valid."""
103
- msg_prefix = f"For '{prim_name}', the" if prim_name else "The"
104
- sim_level = os.getenv("MS_SIMULATION_LEVEL")
105
- no_sim = (sim_level is None or sim_level.strip() == '')
106
- if no_sim and (not _host_distribute()) and context.get_context("mode") == context.PYNATIVE_MODE and \
107
- group != GlobalComm.WORLD_COMM_GROUP:
108
- raise RuntimeError(f"{msg_prefix} 'group' only support 'hccl_world_group' in pynative mode, but got "
109
- f"'group': {group}. Please start by using mpi-run.")
110
-
111
-
112
100
  class AllReduce(Primitive):
113
101
  """
114
102
  Reduces tensors across all devices in such a way that all devices will get the same final result,
@@ -187,7 +175,6 @@ class AllReduce(Primitive):
187
175
  if not isinstance(self.group, str):
188
176
  raise TypeError(f"For '{self.name}', the 'group' must be str, "
189
177
  f"but got {type(self.group).__name__}.")
190
- check_hcom_group_valid(self.group, prim_name=self.name)
191
178
  self.op = op
192
179
  self.add_prim_attr('group', self.group)
193
180
  self.add_prim_attr('fusion', 0)
@@ -300,7 +287,7 @@ class AllGather(PrimitiveWithInfer):
300
287
 
301
288
  Outputs:
302
289
  Tensor. If the number of devices in the group is N,
303
- then the shape of output is :math:`(N, x_1, x_2, ..., x_R)`.
290
+ then the shape of output is :math:`(N*x_1, x_2, ..., x_R)`.
304
291
 
305
292
  Raises:
306
293
  TypeError: If `group` is not a str.
@@ -720,7 +707,6 @@ class Broadcast(PrimitiveWithInfer):
720
707
  """Initialize Broadcast."""
721
708
  validator.check_value_type('root_rank', root_rank, (int,), self.name)
722
709
  validator.check_value_type('group', _get_group(group), (str,), self.name)
723
- check_hcom_group_valid(group, prim_name=self.name)
724
710
  self.add_prim_attr('group', _get_group(group))
725
711
  self.add_prim_attr('no_eliminate', True)
726
712
 
@@ -957,25 +943,8 @@ class AlltoAll(PrimitiveWithInfer):
957
943
  self.concat_dim = concat_dim
958
944
  self.add_prim_attr('group', _get_group(group))
959
945
  self.add_prim_attr('no_eliminate', True)
960
-
961
- def infer_shape(self, x_shape):
962
- rank_size = get_group_size(_get_group(self.group))
963
- if self.split_count != rank_size:
964
- raise ValueError(f"For '{self.name}', the 'split_count' must be equal to 'rank_size', "
965
- f"but got 'split_count': {self.split_count}, 'rank_size': {rank_size}.")
966
- if x_shape[self.split_dim] >= 0 and x_shape[self.split_dim] % self.split_count != 0:
967
- raise ValueError(f"For '{self.name}', the 'x_shape[self.split_dim]' must be divisible by 'split_count', "
968
- f"but got 'x_shape[self.split_dim]' {x_shape[self.split_dim]}, "
969
- f"'split_count' {self.split_count}.")
970
- if x_shape[self.concat_dim] >= 0:
971
- x_shape[self.concat_dim] = x_shape[self.concat_dim] * self.split_count
972
- if x_shape[self.split_dim] >= 0:
973
- x_shape[self.split_dim] = int(x_shape[self.split_dim] / self.split_count)
974
- return x_shape
975
-
976
- def infer_dtype(self, x_dtype):
977
- check_collective_target_dtype('x', x_dtype, self.name)
978
- return x_dtype
946
+ self.rank_size = get_group_size(_get_group(group))
947
+ self.add_prim_attr('rank_size', self.rank_size)
979
948
 
980
949
 
981
950
  class NeighborExchangeV2(Primitive):
@@ -1749,10 +1718,10 @@ class _VirtualAssignKvCache(PrimitiveWithInfer):
1749
1718
  self.add_prim_attr('order_enforce_skip', True)
1750
1719
  self.add_prim_attr('side_effect_backprop_mem', True)
1751
1720
 
1752
- def infer_shape(self, x_shape, y_shape, kv_equal_shape):
1721
+ def infer_shape(self, x_shape, y_shape, kv_equal_shape=None):
1753
1722
  return x_shape
1754
1723
 
1755
- def infer_dtype(self, x_dtype, y_dtype, kv_equal_dtype):
1724
+ def infer_dtype(self, x_dtype, y_dtype, kv_equal_dtype=None):
1756
1725
  return x_dtype
1757
1726
  virtual_assign_kv_cache = _VirtualAssignKvCache()
1758
1727
 
@@ -1975,8 +1944,8 @@ class AlltoAllV(PrimitiveWithInfer):
1975
1944
  AllToAllV which support uneven scatter and gather compared with AllToAll.
1976
1945
 
1977
1946
  Note:
1978
- - Only support flatten tensor as input. input tensor should be flattened and
1979
- concatenated before call this primitive.
1947
+ Only support flatten tensor as input. input tensor should be flattened and
1948
+ concatenated before call this primitive.
1980
1949
 
1981
1950
  Args:
1982
1951
  group (str, optional): The communication group to work on. Default: ``GlobalComm.WORLD_COMM_GROUP``, which
@@ -2012,9 +1981,9 @@ class AlltoAllV(PrimitiveWithInfer):
2012
1981
 
2013
1982
  This example should be run with 2 devices.
2014
1983
 
2015
- >>> from mindspore import ops
2016
1984
  >>> import mindspore.nn as nn
2017
1985
  >>> from mindspore.communication import init, get_rank
1986
+ >>> from mindspore.ops import AlltoAllV
2018
1987
  >>> from mindspore import Tensor
2019
1988
  >>>
2020
1989
  >>> init()
@@ -2022,7 +1991,7 @@ class AlltoAllV(PrimitiveWithInfer):
2022
1991
  >>> class Net(nn.Cell):
2023
1992
  ... def __init__(self):
2024
1993
  ... super(Net, self).__init__()
2025
- ... self.all_to_all = ops.AlltoAllV()
1994
+ ... self.all_to_all = AlltoAllV()
2026
1995
  ...
2027
1996
  ... def construct(self, x, send_numel_list, recv_numel_list):
2028
1997
  ... return self.all_to_all(x, send_numel_list, recv_numel_list)
@@ -2053,3 +2022,179 @@ class AlltoAllV(PrimitiveWithInfer):
2053
2022
  self.add_prim_attr('group', self.group)
2054
2023
  validator.check_value_type("block_size", block_size, [int], self.name)
2055
2024
  self.add_prim_attr('block_size', self.block_size)
2025
+
2026
+
2027
+ class AllGatherV(PrimitiveWithInfer):
2028
+ """
2029
+ Gathers uneven tensors from the specified communication group and returns the tensor which is all gathered.
2030
+
2031
+ Note:
2032
+ Only support flatten tensor as input. input tensor should be flattened and
2033
+ concatenated before call this primitive.
2034
+
2035
+ Args:
2036
+ group (str, optional): The communication group to work on. Default: ``GlobalComm.WORLD_COMM_GROUP`` , which
2037
+ means ``"hccl_world_group"`` in Ascend, and ``"nccl_world_group"`` in GPU.
2038
+
2039
+ Inputs:
2040
+ - **input_x** (Tensor) - One-dimensional tensor to be gathered, with the shape :math:`(x_1)`.
2041
+ - **output_split_sizes** (Union[tuple[int], list[int], Tensor]) - One-dimensional tensor, a list of the
2042
+ amount of data gathered by all ranks. The basic unit is the data type of Tensor.
2043
+
2044
+ Outputs:
2045
+ Tensor. flattened and concatenated tensor gather from remote ranks.
2046
+ If gather result is empty, it will return a Tensor with shape `()`, and value has no actual meaning.
2047
+
2048
+ Raises:
2049
+ RuntimeError: Device target is invalid, backend is invalid, or distributed initialization fails.
2050
+
2051
+ Supported Platforms:
2052
+ ``Ascend`` ``GPU``
2053
+
2054
+ Examples:
2055
+ .. note::
2056
+ Before running the following examples, you need to configure the communication environment variables.
2057
+
2058
+ For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
2059
+ without any third-party or configuration file dependencies.
2060
+ Please see the `msrun start up
2061
+ <https://www.mindspore.cn/tutorials/en/master/parallel/msrun_launcher.html>`_
2062
+ for more details.
2063
+
2064
+ This example should be run with 2 devices.
2065
+
2066
+ >>> import mindspore as ms
2067
+ >>> from mindspore.ops import AllGatherV
2068
+ >>> import mindspore.nn as nn
2069
+ >>> from mindspore.communication import init, get_rank
2070
+ >>> from mindspore import Tensor
2071
+ >>>
2072
+ >>> ms.set_context(mode=ms.GRAPH_MODE)
2073
+ >>> init()
2074
+ >>> class Net(nn.Cell):
2075
+ ... def __init__(self):
2076
+ ... super(Net, self).__init__()
2077
+ ... self.allgatherv = AllGatherV()
2078
+ ...
2079
+ ... def construct(self, x, output_split_sizes):
2080
+ ... return self.allgatherv(x, output_split_sizes)
2081
+ ...
2082
+ >>> rank = get_rank()
2083
+ >>> data = [i for i in range(rank + 3)]
2084
+ >>> input_x = Tensor(data)
2085
+ >>> output_split_sizes = [3, 4]
2086
+ >>> net = Net()
2087
+ >>> output = net(input_x, output_split_sizes)
2088
+ >>> print(output)
2089
+ [0 1 2 0 1 2 3]
2090
+
2091
+ Tutorial Examples:
2092
+ - `Distributed Set Communication Primitives - AllGatherV
2093
+ <https://www.mindspore.cn/docs/en/master/api_python/samples/ops/communicate_ops.html#allgatherv>`_
2094
+
2095
+ """
2096
+
2097
+ @prim_attr_register
2098
+ def __init__(self, group=GlobalComm.WORLD_COMM_GROUP):
2099
+ """Initialize AllGatherV."""
2100
+ self.group = _get_group(group)
2101
+ validator.check_value_type('group', self.group, (str,), self.name)
2102
+ self.rank = get_rank(self.group)
2103
+ self.rank_size = get_group_size(self.group)
2104
+ validator.check('rank', self.rank, 'rank_size', self.rank_size, validator.LT, self.name)
2105
+ self.add_prim_attr('rank_size', self.rank_size)
2106
+ self.add_prim_attr('group', self.group)
2107
+ self.add_prim_attr('mean_flag', False)
2108
+ self.rank_id = get_rank(_get_group(self.group))
2109
+ self.add_prim_attr('rank_id', self.rank_id)
2110
+
2111
+
2112
+ class ReduceScatterV(PrimitiveWithInfer):
2113
+ r"""
2114
+ Reduces and scatters uneven tensors from the specified communication group
2115
+ and returns the tensor which is reduced and scattered.
2116
+
2117
+ Note:
2118
+ Only support flatten tensor as input. The input tensor should be flattened and
2119
+ concatenated before call this primitive.
2120
+
2121
+ Args:
2122
+ op (str, optional): Specifies an operation used for element-wise reductions,
2123
+ like SUM, MIN and MAX, currently PROD is not supported. Default: ``ReduceOp.SUM`` .
2124
+ group (str, optional): The communication group to work on. Default: ``GlobalComm.WORLD_COMM_GROUP`` , which
2125
+ means ``"hccl_world_group"`` in Ascend, and ``"nccl_world_group"`` in GPU.
2126
+
2127
+ Inputs:
2128
+ - **input_x** (Tensor) - One-dimensional tensor to be distributed, with the shape :math:`(x_1)`.
2129
+ - **input_split_sizes** (Union[tuple[int], list[int], Tensor]) - One-dimensional tensor, a list of
2130
+ received data volumes for all ranks. The basic unit is the data type of Tensor. The value is not
2131
+ verified, and the user guarantees its correctness.
2132
+
2133
+ Outputs:
2134
+ Tensor. Reduces and scatters tensor from remote ranks.
2135
+ If the result is empty, it will return a Tensor with shape `()`, and value has no actual meaning.
2136
+
2137
+ Raises:
2138
+ RuntimeError: Device target is invalid, backend is invalid, or distributed initialization fails.
2139
+
2140
+ Supported Platforms:
2141
+ ``Ascend`` ``GPU``
2142
+
2143
+ Examples:
2144
+ .. note::
2145
+ Before running the following examples, you need to configure the communication environment variables.
2146
+
2147
+ For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
2148
+ without any third-party or configuration file dependencies.
2149
+ Please see the `msrun start up
2150
+ <https://www.mindspore.cn/tutorials/en/master/parallel/msrun_launcher.html>`_
2151
+ for more details.
2152
+
2153
+ This example should be run with 2 devices.
2154
+
2155
+ >>> import mindspore as ms
2156
+ >>> from mindspore import Tensor
2157
+ >>> from mindspore.communication import init, get_rank
2158
+ >>> from mindspore.ops import ReduceOp
2159
+ >>> import mindspore.nn as nn
2160
+ >>> from mindspore.ops.operations.comm_ops import ReduceScatterV
2161
+ >>>
2162
+ >>> ms.set_context(mode=ms.GRAPH_MODE)
2163
+ >>> init()
2164
+ >>> class Net(nn.Cell):
2165
+ ... def __init__(self):
2166
+ ... super(Net, self).__init__()
2167
+ ... self.reducescatterv = ReduceScatterV(ReduceOp.SUM)
2168
+ ...
2169
+ ... def construct(self, x, input_split_sizes):
2170
+ ... return self.reducescatterv(x, input_split_sizes)
2171
+ ...
2172
+ >>> rank = get_rank()
2173
+ >>> input_x = Tensor([0, 1, 2.0])
2174
+ >>> input_split_sizes = [2, 1]
2175
+ >>> net = Net()
2176
+ >>> output = net(input_x, input_split_sizes)
2177
+ >>> print(output)
2178
+ rank 0:
2179
+ [0. 2.]
2180
+ rank 1:
2181
+ [4.]
2182
+
2183
+ Tutorial Examples:
2184
+ - `Distributed Set Communication Primitives - ReduceScatterV
2185
+ <https://www.mindspore.cn/docs/en/master/api_python/samples/ops/communicate_ops.html#reducescatterv>`_
2186
+
2187
+ """
2188
+
2189
+ @prim_attr_register
2190
+ def __init__(self, op=ReduceOp.SUM, group=GlobalComm.WORLD_COMM_GROUP):
2191
+ """Initialize ReduceScatterV."""
2192
+ validator.check_value_type('op', op, (type(ReduceOp.SUM),), self.name)
2193
+ self.group = _get_group(group)
2194
+ validator.check_value_type('group', self.group, (str,), self.name)
2195
+ self.op = op
2196
+ self.rank_size = get_group_size(self.group)
2197
+ self.add_prim_attr('rank_size', self.rank_size)
2198
+ self.add_prim_attr('group', self.group)
2199
+ self.rank_id = get_rank(_get_group(self.group))
2200
+ self.add_prim_attr('rank_id', self.rank_id)