mindspore 2.7.0rc1__cp310-cp310-win_amd64.whl → 2.7.1__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 (370) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/__init__.py +5 -2
  3. mindspore/_c_dataengine.cp310-win_amd64.pyd +0 -0
  4. mindspore/_c_expression.cp310-win_amd64.pyd +0 -0
  5. mindspore/_c_mindrecord.cp310-win_amd64.pyd +0 -0
  6. mindspore/_checkparam.py +2 -2
  7. mindspore/_extends/builtin_operations.py +3 -3
  8. mindspore/_extends/parallel_compile/akg_compiler/custom.py +1109 -0
  9. mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
  10. mindspore/_extends/parse/__init__.py +3 -3
  11. mindspore/_extends/parse/compile_config.py +24 -1
  12. mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +6 -3
  13. mindspore/_extends/parse/parser.py +28 -22
  14. mindspore/_extends/parse/resources.py +1 -1
  15. mindspore/_extends/parse/standard_method.py +23 -2
  16. mindspore/_extends/parse/trope.py +2 -1
  17. mindspore/_extends/pijit/pijit_func_white_list.py +9 -27
  18. mindspore/amp.py +0 -18
  19. mindspore/avcodec-59.dll +0 -0
  20. mindspore/avdevice-59.dll +0 -0
  21. mindspore/avfilter-8.dll +0 -0
  22. mindspore/avformat-59.dll +0 -0
  23. mindspore/avutil-57.dll +0 -0
  24. mindspore/boost/base.py +29 -2
  25. mindspore/common/__init__.py +18 -12
  26. mindspore/common/_decorator.py +3 -2
  27. mindspore/common/_grad_function.py +3 -1
  28. mindspore/common/_tensor_cpp_method.py +1 -1
  29. mindspore/common/_tensor_docs.py +371 -96
  30. mindspore/common/_utils.py +7 -43
  31. mindspore/common/api.py +434 -135
  32. mindspore/common/dtype.py +98 -57
  33. mindspore/common/dump.py +7 -108
  34. mindspore/common/dynamic_shape/__init__.py +0 -0
  35. mindspore/common/{auto_dynamic_shape.py → dynamic_shape/auto_dynamic_shape.py} +15 -23
  36. mindspore/common/dynamic_shape/enable_dynamic.py +197 -0
  37. mindspore/common/file_system.py +59 -9
  38. mindspore/common/hook_handle.py +82 -3
  39. mindspore/common/jit_config.py +5 -1
  40. mindspore/common/jit_trace.py +27 -12
  41. mindspore/common/lazy_inline.py +5 -3
  42. mindspore/common/np_dtype.py +3 -3
  43. mindspore/common/parameter.py +17 -127
  44. mindspore/common/recompute.py +4 -13
  45. mindspore/common/tensor.py +50 -217
  46. mindspore/communication/_comm_helper.py +11 -1
  47. mindspore/communication/comm_func.py +138 -4
  48. mindspore/communication/management.py +85 -1
  49. mindspore/config/op_info.config +0 -15
  50. mindspore/context.py +20 -106
  51. mindspore/dataset/__init__.py +1 -1
  52. mindspore/dataset/audio/transforms.py +1 -1
  53. mindspore/dataset/core/config.py +35 -1
  54. mindspore/dataset/engine/datasets.py +338 -319
  55. mindspore/dataset/engine/datasets_user_defined.py +38 -22
  56. mindspore/dataset/engine/datasets_vision.py +1 -1
  57. mindspore/dataset/engine/validators.py +1 -15
  58. mindspore/dataset/transforms/c_transforms.py +2 -2
  59. mindspore/dataset/transforms/transforms.py +3 -3
  60. mindspore/dataset/vision/__init__.py +1 -1
  61. mindspore/dataset/vision/py_transforms.py +8 -8
  62. mindspore/dataset/vision/transforms.py +17 -5
  63. mindspore/dataset/vision/utils.py +632 -21
  64. mindspore/device_context/ascend/op_tuning.py +35 -1
  65. mindspore/dnnl.dll +0 -0
  66. mindspore/{profiler/common/validator → graph}/__init__.py +9 -1
  67. mindspore/graph/custom_pass.py +55 -0
  68. mindspore/include/api/cell.h +28 -4
  69. mindspore/include/api/cfg.h +24 -7
  70. mindspore/include/api/context.h +1 -0
  71. mindspore/include/api/delegate.h +0 -2
  72. mindspore/include/api/dual_abi_helper.h +100 -19
  73. mindspore/include/api/graph.h +14 -1
  74. mindspore/include/api/kernel.h +16 -3
  75. mindspore/include/api/kernel_api.h +9 -1
  76. mindspore/include/api/metrics/accuracy.h +9 -0
  77. mindspore/include/api/model.h +5 -1
  78. mindspore/include/api/model_group.h +4 -0
  79. mindspore/include/api/model_parallel_runner.h +2 -0
  80. mindspore/include/api/status.h +48 -10
  81. mindspore/include/api/types.h +6 -1
  82. mindspore/include/dataset/constants.h +9 -0
  83. mindspore/include/dataset/execute.h +2 -2
  84. mindspore/jpeg62.dll +0 -0
  85. mindspore/mindrecord/__init__.py +3 -3
  86. mindspore/mindrecord/common/exceptions.py +1 -0
  87. mindspore/mindrecord/config.py +1 -1
  88. mindspore/{parallel/mpi → mindrecord/core}/__init__.py +4 -1
  89. mindspore/mindrecord/{shardheader.py → core/shardheader.py} +2 -1
  90. mindspore/mindrecord/{shardindexgenerator.py → core/shardindexgenerator.py} +1 -1
  91. mindspore/mindrecord/{shardreader.py → core/shardreader.py} +2 -1
  92. mindspore/mindrecord/{shardsegment.py → core/shardsegment.py} +2 -2
  93. mindspore/mindrecord/{shardutils.py → core/shardutils.py} +1 -1
  94. mindspore/mindrecord/{shardwriter.py → core/shardwriter.py} +1 -1
  95. mindspore/mindrecord/filereader.py +4 -4
  96. mindspore/mindrecord/filewriter.py +5 -5
  97. mindspore/mindrecord/mindpage.py +2 -2
  98. mindspore/mindrecord/tools/cifar10.py +4 -3
  99. mindspore/mindrecord/tools/cifar100.py +1 -1
  100. mindspore/mindrecord/tools/cifar100_to_mr.py +1 -1
  101. mindspore/mindrecord/tools/cifar10_to_mr.py +6 -6
  102. mindspore/mindrecord/tools/csv_to_mr.py +1 -1
  103. mindspore/mindrecord/tools/imagenet_to_mr.py +1 -1
  104. mindspore/mindrecord/tools/mnist_to_mr.py +1 -1
  105. mindspore/mindrecord/tools/tfrecord_to_mr.py +1 -1
  106. mindspore/mindspore_backend_common.dll +0 -0
  107. mindspore/mindspore_backend_manager.dll +0 -0
  108. mindspore/mindspore_cluster.dll +0 -0
  109. mindspore/mindspore_common.dll +0 -0
  110. mindspore/mindspore_core.dll +0 -0
  111. mindspore/mindspore_cpu.dll +0 -0
  112. mindspore/mindspore_dump.dll +0 -0
  113. mindspore/mindspore_frontend.dll +0 -0
  114. mindspore/mindspore_glog.dll +0 -0
  115. mindspore/mindspore_hardware_abstract.dll +0 -0
  116. mindspore/mindspore_memory_pool.dll +0 -0
  117. mindspore/mindspore_ms_backend.dll +0 -0
  118. mindspore/mindspore_ops.dll +0 -0
  119. mindspore/{mindspore_ops_host.dll → mindspore_ops_cpu.dll} +0 -0
  120. mindspore/mindspore_profiler.dll +0 -0
  121. mindspore/mindspore_pyboost.dll +0 -0
  122. mindspore/mindspore_pynative.dll +0 -0
  123. mindspore/mindspore_runtime_pipeline.dll +0 -0
  124. mindspore/mindspore_runtime_utils.dll +0 -0
  125. mindspore/mindspore_tools.dll +0 -0
  126. mindspore/mint/__init__.py +15 -10
  127. mindspore/mint/distributed/__init__.py +4 -0
  128. mindspore/mint/distributed/distributed.py +392 -69
  129. mindspore/mint/nn/__init__.py +2 -16
  130. mindspore/mint/nn/functional.py +4 -110
  131. mindspore/mint/nn/layer/__init__.py +0 -2
  132. mindspore/mint/nn/layer/_functions.py +1 -2
  133. mindspore/mint/nn/layer/activation.py +0 -6
  134. mindspore/mint/nn/layer/basic.py +0 -47
  135. mindspore/mint/nn/layer/conv.py +10 -10
  136. mindspore/mint/nn/layer/normalization.py +11 -16
  137. mindspore/mint/nn/layer/pooling.py +0 -4
  138. mindspore/nn/__init__.py +1 -3
  139. mindspore/nn/cell.py +231 -239
  140. mindspore/nn/layer/activation.py +4 -2
  141. mindspore/nn/layer/basic.py +56 -14
  142. mindspore/nn/layer/container.py +16 -0
  143. mindspore/nn/layer/embedding.py +4 -169
  144. mindspore/nn/layer/image.py +1 -1
  145. mindspore/nn/layer/normalization.py +2 -1
  146. mindspore/nn/layer/thor_layer.py +4 -85
  147. mindspore/nn/optim/ada_grad.py +0 -1
  148. mindspore/nn/optim/adafactor.py +0 -1
  149. mindspore/nn/optim/adam.py +32 -127
  150. mindspore/nn/optim/adamax.py +0 -1
  151. mindspore/nn/optim/asgd.py +0 -1
  152. mindspore/nn/optim/ftrl.py +8 -102
  153. mindspore/nn/optim/lamb.py +1 -4
  154. mindspore/nn/optim/lars.py +0 -3
  155. mindspore/nn/optim/lazyadam.py +25 -218
  156. mindspore/nn/optim/momentum.py +5 -43
  157. mindspore/nn/optim/optimizer.py +6 -55
  158. mindspore/nn/optim/proximal_ada_grad.py +0 -1
  159. mindspore/nn/optim/rmsprop.py +0 -1
  160. mindspore/nn/optim/rprop.py +0 -1
  161. mindspore/nn/optim/sgd.py +0 -1
  162. mindspore/nn/optim/tft_wrapper.py +2 -4
  163. mindspore/nn/optim/thor.py +0 -2
  164. mindspore/nn/probability/bijector/bijector.py +7 -8
  165. mindspore/nn/probability/bijector/gumbel_cdf.py +2 -2
  166. mindspore/nn/probability/bijector/power_transform.py +20 -21
  167. mindspore/nn/probability/bijector/scalar_affine.py +5 -5
  168. mindspore/nn/probability/bijector/softplus.py +13 -14
  169. mindspore/nn/probability/distribution/_utils/utils.py +2 -2
  170. mindspore/nn/wrap/cell_wrapper.py +39 -5
  171. mindspore/nn/wrap/grad_reducer.py +4 -89
  172. mindspore/numpy/array_creations.py +4 -4
  173. mindspore/numpy/fft.py +9 -9
  174. mindspore/numpy/utils_const.py +1 -1
  175. mindspore/{nn/reinforcement → onnx}/__init__.py +5 -8
  176. mindspore/onnx/onnx_export.py +137 -0
  177. mindspore/opencv_core4110.dll +0 -0
  178. mindspore/opencv_imgcodecs4110.dll +0 -0
  179. mindspore/{opencv_imgproc452.dll → opencv_imgproc4110.dll} +0 -0
  180. mindspore/ops/__init__.py +2 -0
  181. mindspore/ops/_grad_experimental/grad_comm_ops.py +38 -2
  182. mindspore/ops/_grad_experimental/grad_inner_ops.py +0 -9
  183. mindspore/ops/_op_impl/aicpu/__init__.py +0 -10
  184. mindspore/ops/_op_impl/cpu/__init__.py +1 -5
  185. mindspore/ops/_op_impl/cpu/{buffer_append.py → joinedstr_op.py} +8 -8
  186. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +28 -24
  187. mindspore/ops/auto_generate/gen_extend_func.py +6 -11
  188. mindspore/ops/auto_generate/gen_ops_def.py +385 -154
  189. mindspore/ops/auto_generate/gen_ops_prim.py +5676 -5167
  190. mindspore/ops/communication.py +97 -0
  191. mindspore/ops/composite/__init__.py +5 -2
  192. mindspore/ops/composite/base.py +16 -2
  193. mindspore/ops/composite/multitype_ops/__init__.py +3 -1
  194. mindspore/ops/composite/multitype_ops/_compile_utils.py +150 -8
  195. mindspore/ops/composite/multitype_ops/_constexpr_utils.py +1 -1
  196. mindspore/ops/composite/multitype_ops/add_impl.py +7 -0
  197. mindspore/ops/composite/multitype_ops/mod_impl.py +27 -0
  198. mindspore/ops/function/__init__.py +2 -0
  199. mindspore/ops/function/array_func.py +24 -18
  200. mindspore/ops/function/comm_func.py +3883 -0
  201. mindspore/ops/function/debug_func.py +7 -6
  202. mindspore/ops/function/grad/grad_func.py +4 -12
  203. mindspore/ops/function/math_func.py +89 -86
  204. mindspore/ops/function/nn_func.py +92 -313
  205. mindspore/ops/function/random_func.py +9 -18
  206. mindspore/ops/functional.py +4 -1
  207. mindspore/ops/functional_overload.py +377 -30
  208. mindspore/ops/operations/__init__.py +2 -5
  209. mindspore/ops/operations/_custom_ops_utils.py +7 -9
  210. mindspore/ops/operations/_inner_ops.py +12 -50
  211. mindspore/ops/operations/_rl_inner_ops.py +0 -933
  212. mindspore/ops/operations/array_ops.py +5 -50
  213. mindspore/ops/operations/comm_ops.py +95 -17
  214. mindspore/ops/operations/custom_ops.py +237 -22
  215. mindspore/ops/operations/debug_ops.py +33 -35
  216. mindspore/ops/operations/manually_defined/ops_def.py +39 -318
  217. mindspore/ops/operations/math_ops.py +5 -5
  218. mindspore/ops/operations/nn_ops.py +3 -3
  219. mindspore/ops/operations/sparse_ops.py +0 -83
  220. mindspore/ops/primitive.py +4 -27
  221. mindspore/ops/tensor_method.py +88 -10
  222. mindspore/ops_generate/aclnn/aclnn_kernel_register_auto_cc_generator.py +5 -5
  223. mindspore/ops_generate/aclnn/gen_aclnn_implement.py +8 -8
  224. mindspore/ops_generate/api/functions_cc_generator.py +53 -4
  225. mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +25 -11
  226. mindspore/ops_generate/common/gen_constants.py +11 -10
  227. mindspore/ops_generate/common/op_proto.py +18 -1
  228. mindspore/ops_generate/common/template.py +102 -245
  229. mindspore/ops_generate/common/template_utils.py +212 -0
  230. mindspore/ops_generate/gen_custom_ops.py +69 -0
  231. mindspore/ops_generate/op_def/ops_def_cc_generator.py +78 -7
  232. mindspore/ops_generate/op_def_py/base_op_prim_py_generator.py +360 -0
  233. mindspore/ops_generate/op_def_py/custom_op_prim_py_generator.py +140 -0
  234. mindspore/ops_generate/op_def_py/op_def_py_generator.py +54 -7
  235. mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -312
  236. mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +74 -17
  237. mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +22 -5
  238. mindspore/ops_generate/pyboost/gen_pyboost_func.py +0 -16
  239. mindspore/ops_generate/pyboost/op_template_parser.py +3 -2
  240. mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +21 -5
  241. mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +2 -2
  242. mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +30 -10
  243. mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +10 -3
  244. mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +1 -1
  245. mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +19 -9
  246. mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +71 -28
  247. mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +10 -9
  248. mindspore/ops_generate/pyboost/pyboost_utils.py +27 -16
  249. mindspore/ops_generate/resources/yaml_loader.py +13 -0
  250. mindspore/ops_generate/tensor_py_cc_generator.py +2 -2
  251. mindspore/parallel/_auto_parallel_context.py +5 -15
  252. mindspore/parallel/_cell_wrapper.py +1 -1
  253. mindspore/parallel/_parallel_serialization.py +4 -6
  254. mindspore/parallel/_ps_context.py +2 -2
  255. mindspore/parallel/_utils.py +34 -17
  256. mindspore/parallel/auto_parallel.py +23 -9
  257. mindspore/parallel/checkpoint_transform.py +20 -2
  258. mindspore/parallel/cluster/process_entity/_api.py +28 -33
  259. mindspore/parallel/cluster/process_entity/_utils.py +9 -5
  260. mindspore/parallel/cluster/run.py +5 -3
  261. mindspore/{experimental/llm_boost/ascend_native → parallel/distributed}/__init__.py +21 -22
  262. mindspore/parallel/distributed/distributed_data_parallel.py +393 -0
  263. mindspore/parallel/distributed/flatten_grad_buffer.py +295 -0
  264. mindspore/parallel/function/reshard_func.py +6 -5
  265. mindspore/parallel/nn/parallel_cell_wrapper.py +40 -3
  266. mindspore/parallel/nn/parallel_grad_reducer.py +0 -8
  267. mindspore/parallel/shard.py +7 -21
  268. mindspore/parallel/strategy.py +336 -0
  269. mindspore/parallel/transform_safetensors.py +127 -20
  270. mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +13 -9
  271. mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +1 -1
  272. mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +1 -1
  273. mindspore/profiler/common/constant.py +5 -0
  274. mindspore/profiler/common/file_manager.py +9 -0
  275. mindspore/profiler/common/msprof_cmd_tool.py +40 -4
  276. mindspore/profiler/common/path_manager.py +65 -24
  277. mindspore/profiler/common/profiler_context.py +27 -14
  278. mindspore/profiler/common/profiler_info.py +3 -3
  279. mindspore/profiler/common/profiler_meta_data.py +1 -0
  280. mindspore/profiler/common/profiler_op_analyse.py +10 -6
  281. mindspore/profiler/common/profiler_path_manager.py +13 -0
  282. mindspore/profiler/common/util.py +30 -3
  283. mindspore/profiler/dynamic_profiler.py +91 -46
  284. mindspore/profiler/envprofiler.py +30 -5
  285. mindspore/profiler/experimental_config.py +18 -2
  286. mindspore/profiler/platform/cpu_profiler.py +10 -4
  287. mindspore/profiler/platform/npu_profiler.py +34 -7
  288. mindspore/profiler/profiler.py +193 -145
  289. mindspore/profiler/profiler_action_controller.py +1 -1
  290. mindspore/profiler/profiler_interface.py +2 -2
  291. mindspore/rewrite/symbol_tree/symbol_tree.py +1 -1
  292. mindspore/run_check/_check_version.py +108 -24
  293. mindspore/runtime/__init__.py +9 -6
  294. mindspore/runtime/executor.py +35 -0
  295. mindspore/runtime/memory.py +113 -0
  296. mindspore/runtime/thread_bind_core.py +1 -1
  297. mindspore/swresample-4.dll +0 -0
  298. mindspore/swscale-6.dll +0 -0
  299. mindspore/tinyxml2.dll +0 -0
  300. mindspore/{experimental/llm_boost → tools}/__init__.py +5 -5
  301. mindspore/tools/data_dump.py +130 -0
  302. mindspore/tools/sdc_detect.py +91 -0
  303. mindspore/tools/stress_detect.py +63 -0
  304. mindspore/train/__init__.py +6 -6
  305. mindspore/train/_utils.py +8 -21
  306. mindspore/train/amp.py +6 -7
  307. mindspore/train/callback/_callback.py +2 -1
  308. mindspore/train/callback/_checkpoint.py +1 -17
  309. mindspore/train/callback/_flops_collector.py +10 -6
  310. mindspore/train/callback/_train_fault_tolerance.py +72 -25
  311. mindspore/train/data_sink.py +5 -9
  312. mindspore/train/dataset_helper.py +5 -5
  313. mindspore/train/model.py +41 -230
  314. mindspore/train/serialization.py +160 -401
  315. mindspore/train/train_thor/model_thor.py +2 -2
  316. mindspore/turbojpeg.dll +0 -0
  317. mindspore/utils/__init__.py +6 -3
  318. mindspore/utils/dlpack.py +92 -0
  319. mindspore/utils/dryrun.py +1 -1
  320. mindspore/utils/runtime_execution_order_check.py +10 -0
  321. mindspore/utils/sdc_detect.py +14 -12
  322. mindspore/utils/stress_detect.py +43 -0
  323. mindspore/utils/utils.py +152 -16
  324. mindspore/version.py +1 -1
  325. {mindspore-2.7.0rc1.dist-info → mindspore-2.7.1.dist-info}/METADATA +3 -2
  326. {mindspore-2.7.0rc1.dist-info → mindspore-2.7.1.dist-info}/RECORD +330 -344
  327. mindspore/_extends/remote/kernel_build_server_ascend.py +0 -75
  328. mindspore/communication/_hccl_management.py +0 -297
  329. mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +0 -207
  330. mindspore/experimental/llm_boost/ascend_native/llm_boost.py +0 -52
  331. mindspore/experimental/llm_boost/atb/__init__.py +0 -23
  332. mindspore/experimental/llm_boost/atb/boost_base.py +0 -385
  333. mindspore/experimental/llm_boost/atb/llama_boost.py +0 -137
  334. mindspore/experimental/llm_boost/atb/qwen_boost.py +0 -124
  335. mindspore/experimental/llm_boost/register.py +0 -130
  336. mindspore/experimental/llm_boost/utils.py +0 -31
  337. mindspore/include/OWNERS +0 -7
  338. mindspore/mindspore_cpu_res_manager.dll +0 -0
  339. mindspore/mindspore_ops_kernel_common.dll +0 -0
  340. mindspore/mindspore_res_manager.dll +0 -0
  341. mindspore/nn/optim/_dist_optimizer_registry.py +0 -111
  342. mindspore/nn/reinforcement/_batch_read_write.py +0 -142
  343. mindspore/nn/reinforcement/_tensors_queue.py +0 -152
  344. mindspore/nn/reinforcement/tensor_array.py +0 -145
  345. mindspore/opencv_core452.dll +0 -0
  346. mindspore/opencv_imgcodecs452.dll +0 -0
  347. mindspore/ops/_op_impl/aicpu/priority_replay_buffer.py +0 -113
  348. mindspore/ops/_op_impl/aicpu/reservoir_replay_buffer.py +0 -96
  349. mindspore/ops/_op_impl/aicpu/sparse_cross.py +0 -42
  350. mindspore/ops/_op_impl/cpu/buffer_get.py +0 -28
  351. mindspore/ops/_op_impl/cpu/buffer_sample.py +0 -28
  352. mindspore/ops/_op_impl/cpu/priority_replay_buffer.py +0 -42
  353. mindspore/ops/operations/_tensor_array.py +0 -359
  354. mindspore/ops/operations/rl_ops.py +0 -288
  355. mindspore/parallel/_offload_context.py +0 -275
  356. mindspore/parallel/_recovery_context.py +0 -115
  357. mindspore/parallel/_transformer/__init__.py +0 -35
  358. mindspore/parallel/_transformer/layers.py +0 -765
  359. mindspore/parallel/_transformer/loss.py +0 -251
  360. mindspore/parallel/_transformer/moe.py +0 -693
  361. mindspore/parallel/_transformer/op_parallel_config.py +0 -222
  362. mindspore/parallel/_transformer/transformer.py +0 -3124
  363. mindspore/parallel/mpi/_mpi_config.py +0 -116
  364. mindspore/profiler/common/validator/validate_path.py +0 -84
  365. mindspore/train/memory_profiling_pb2.py +0 -298
  366. mindspore/utils/hooks.py +0 -81
  367. /mindspore/common/{_auto_dynamic.py → dynamic_shape/_auto_dynamic.py} +0 -0
  368. {mindspore-2.7.0rc1.dist-info → mindspore-2.7.1.dist-info}/WHEEL +0 -0
  369. {mindspore-2.7.0rc1.dist-info → mindspore-2.7.1.dist-info}/entry_points.txt +0 -0
  370. {mindspore-2.7.0rc1.dist-info → mindspore-2.7.1.dist-info}/top_level.txt +0 -0
@@ -17,7 +17,6 @@
17
17
  __all__ = ['Tensor']
18
18
 
19
19
  import abc
20
- import math
21
20
  import numbers
22
21
  import numpy as np
23
22
 
@@ -29,7 +28,6 @@ from mindspore import log as logger
29
28
  from mindspore.common import dtype as mstype
30
29
  from mindspore.common.hook_handle import _TensorHookHandle
31
30
 
32
- from mindspore.common._utils import get_slice_num
33
31
  from mindspore.common._register_for_tensor import tensor_operator_registry
34
32
  from mindspore._c_expression import TensorPy as TensorPy_
35
33
  from mindspore._c_expression import _rmod_instance
@@ -296,6 +294,7 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
296
294
  ...
297
295
  >>> # initialize a tensor with init
298
296
  >>> t4 = Tensor(shape = (1, 3), dtype=ms.float32, init=One())
297
+ >>> t4.init_data()
299
298
  >>> print(t4)
300
299
  [[1. 1. 1.]]
301
300
  >>> print(type(t4))
@@ -326,7 +325,6 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
326
325
 
327
326
  def __repr__(self):
328
327
  if self.init_finished:
329
- TensorPy_.data_sync(self, True)
330
328
  return TensorPy_.__repr__(self)
331
329
  return ''
332
330
 
@@ -419,9 +417,6 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
419
417
  def __rmod__(self, other):
420
418
  return _rmod_instance(other, self)
421
419
 
422
- def __imod__(self, other):
423
- return self.__mod__(other)
424
-
425
420
  def __rpow__(self, other):
426
421
  return tensor_operator_registry.get('__rpow__')(self, other)
427
422
 
@@ -456,6 +451,8 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
456
451
  def __str__(self):
457
452
  if self.dtype == mstype.type_none:
458
453
  return "Unknown Tensor type!"
454
+ if not self._data_ptr():
455
+ return TensorPy_.__str__(self)
459
456
  return str(self.asnumpy())
460
457
 
461
458
  def __getstate__(self):
@@ -986,37 +983,6 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
986
983
  """
987
984
  return self.asnumpy()
988
985
 
989
- def is_persistent_data(self):
990
- """
991
- Check if size of tensor is huge, and need save data to persistent storage.
992
- If size of tensor is bigger then MS_EMBEDDING_REMOTE_CACHE_MEMORY_SIZE, it will
993
- use persistent storage to save tensor data. And will spilt data to some slice.
994
-
995
- Returns:
996
- True or False
997
- """
998
- return TensorPy_.is_persistent_data(self)
999
-
1000
- def asnumpy_of_slice_persistent_data(self, param_key, slice_index):
1001
- """
1002
- Convert a slice of tensor data to numpy array. A slice is part of tensor data.
1003
- Returns as a NumPy ndarray. This slice tensor data and the returned ndarray
1004
- share the same underlying storage. Changes to self tensor will be reflected in the ndarray.
1005
-
1006
- Returns:
1007
- A numpy ndarray which shares the same underlying storage with the slice of tensor data.
1008
- """
1009
- return TensorPy_.asnumpy_of_slice_persistent_data(self, param_key, slice_index)
1010
-
1011
- def slice_num_of_persistent_data(self):
1012
- """
1013
- Get slice num of a tensor which use persistent storage.
1014
-
1015
- Returns:
1016
- Num of slice.
1017
- """
1018
- return self.slice_num_of_persistent_data_
1019
-
1020
986
  def slice_scatter(self, src, axis=0, start=None, end=None, step=1):
1021
987
  """
1022
988
  For details, please refer to :func:`mindspore.ops.slice_scatter`.
@@ -1035,15 +1001,6 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
1035
1001
  """
1036
1002
  return tensor_operator_registry.get('geqrf')(self)
1037
1003
 
1038
- def slice_shape_of_persistent_data(self):
1039
- """
1040
- Get slice shape of tensor after cut to slice size.
1041
-
1042
- Returns:
1043
- The slice shape of tensor.
1044
- """
1045
- return self.slice_shape_of_persistent_data_
1046
-
1047
1004
  def value(self):
1048
1005
  """
1049
1006
  Get the value of the tensor or the parameter.
@@ -1150,7 +1107,6 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
1150
1107
  which may be modified by returning a new output gradient.
1151
1108
  - The `hook` should have the following signature:
1152
1109
  hook(grad) -> New output gradient, but can not return None or not set return value.
1153
- - Higher-order differentiation does not support tensor `register_hook`.
1154
1110
  - The following constraints must be met under graph mode:
1155
1111
 
1156
1112
  - The `hook` must satisfy the syntax constraints of the graph mode.
@@ -1245,35 +1201,6 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
1245
1201
  """
1246
1202
  return tensor_operator_registry.get('angle')(self)
1247
1203
 
1248
- def view(self, *shape):
1249
- """
1250
- Reshape the tensor according to the input shape. It's the same as :func:`mindspore.Tensor.reshape`,
1251
- implemented by the underlying reshape operator.
1252
-
1253
- Args:
1254
- shape (Union[tuple(int), int]): Dimension of the output tensor.
1255
-
1256
- Returns:
1257
- Tensor, which dimension is the input shape's value.
1258
-
1259
- Examples:
1260
- >>> from mindspore import Tensor
1261
- >>> import numpy as np
1262
- >>> a = Tensor(np.array([[1, 2, 3], [2, 3, 4]], dtype=np.float32))
1263
- >>> output = a.view((3, 2))
1264
- >>> print(output)
1265
- [[1. 2.]
1266
- [3. 2.]
1267
- [3. 4.]]
1268
- """
1269
- if not shape:
1270
- raise ValueError("The shape variable should not be empty")
1271
- if isinstance(shape[0], tuple):
1272
- if len(shape) != 1:
1273
- raise ValueError(f"Only one tuple is needed, but got {shape}")
1274
- shape = shape[0]
1275
- return tensor_operator_registry.get('reshape')(self, shape)
1276
-
1277
1204
  def bitwise_left_shift(self, other):
1278
1205
  """
1279
1206
  For details, please refer to :func:`mindspore.ops.bitwise_left_shift`.
@@ -1306,18 +1233,6 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
1306
1233
  """
1307
1234
  return tensor_operator_registry.get('ger')(self, vec2)
1308
1235
 
1309
- def broadcast_to(self, shape):
1310
- """
1311
- For details, please refer to :func:`mindspore.ops.broadcast_to`.
1312
- """
1313
- return tensor_operator_registry.get('broadcast_to')(self, shape)
1314
-
1315
- def real(self):
1316
- r"""
1317
- For details, please refer to :func:`mindspore.ops.real`.
1318
- """
1319
- return tensor_operator_registry.get('real')(self)
1320
-
1321
1236
  def tanh_(self):
1322
1237
  r"""
1323
1238
  Computes hyperbolic tangent of self inplace element-wise. The Tanh function is defined as:
@@ -1542,8 +1457,7 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
1542
1457
  >>> print(output.shape)
1543
1458
  (24,)
1544
1459
  """
1545
- reshape_op = tensor_operator_registry.get('reshape')
1546
- return reshape_op(self, (-1,))
1460
+ return self.reshape((-1,))
1547
1461
 
1548
1462
  def rot90(self, k, dims):
1549
1463
  r"""
@@ -1581,15 +1495,6 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
1581
1495
  """
1582
1496
  return self._size
1583
1497
 
1584
- def permute(self, *axis):
1585
- """
1586
- Tensor.permute supports unpacking the `axis` argument automatically when it is passed as an indefinite number of
1587
- positional arguments, which has a slight difference from the input parameter of :func:`mindspore.ops.permute`.
1588
- For details, please refer to :func:`mindspore.ops.permute`.
1589
- """
1590
- perm = validator.check_transpose_axis(axis, self.ndim)
1591
- return tensor_operator_registry.get('permute')(self, perm)
1592
-
1593
1498
  def positive(self):
1594
1499
  """
1595
1500
  For details, please refer to :func:`mindspore.ops.positive`.
@@ -1626,12 +1531,6 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
1626
1531
  """
1627
1532
  return tensor_operator_registry.get('swapdims')(self, dim0, dim1)
1628
1533
 
1629
- def squeeze(self, axis=None):
1630
- """
1631
- For details, please refer to :func:`mindspore.ops.squeeze`.
1632
- """
1633
- return tensor_operator_registry.get('squeeze')(self, axis)
1634
-
1635
1534
  def slogdet(self):
1636
1535
  """
1637
1536
  For details, please refer to :func:`mindspore.ops.slogdet`.
@@ -1855,6 +1754,10 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
1855
1754
 
1856
1755
  self[i][j][index[i][j][k]] += src[i][j][k] # if dim == 2
1857
1756
 
1757
+ .. warning::
1758
+ When deterministic computation is enabled, `index` can not be a non-contiguous Tensor; otherwise,
1759
+ deterministic results can not be guaranteed.
1760
+
1858
1761
  Args:
1859
1762
  dim (int): Which dim to scatter. Accepted range is [-r, r) where r = rank(`self`).
1860
1763
  index (Tensor): The index of `self` to do scatter operation whose data type must
@@ -2085,15 +1988,6 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
2085
1988
 
2086
1989
  if shape is None:
2087
1990
  shape = self.shape
2088
- # At embedding cache scenes, we need limit the size of memory for tensor.
2089
- # And save out of range data to persistent storage to support TB-Level size of tensor.
2090
- data_shape = list(shape)
2091
- slice_num_of_persistent_data = get_slice_num(self.dtype, shape)
2092
- if slice_num_of_persistent_data > 1:
2093
- slice_first_dim = math.ceil(shape[0] / slice_num_of_persistent_data)
2094
- data_shape[0] = slice_first_dim
2095
- self.slice_shape_of_persistent_data_ = data_shape
2096
- self.slice_num_of_persistent_data_ = slice_num_of_persistent_data
2097
1991
 
2098
1992
  from mindspore.common.initializer import Zero as ZeroInitializer
2099
1993
 
@@ -2101,9 +1995,9 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
2101
1995
  try:
2102
1996
  dtype_ = mstype.int8 if is_qint4x2 else self.dtype
2103
1997
  if isinstance(self.init, ZeroInitializer):
2104
- data = np.zeros(data_shape, dtype=mstype.dtype_to_nptype(dtype_))
1998
+ data = np.zeros(shape, dtype=mstype._dtype_to_nptype(dtype_)) # pylint:disable=protected-access
2105
1999
  else:
2106
- data = np.ndarray(data_shape, dtype=mstype.dtype_to_nptype(dtype_))
2000
+ data = np.ndarray(shape, dtype=mstype._dtype_to_nptype(dtype_)) # pylint:disable=protected-access
2107
2001
  except ValueError as e:
2108
2002
  msg = "Error shape={}".format(shape)
2109
2003
  logger.critical(msg)
@@ -2139,16 +2033,12 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
2139
2033
  self.init.seed, _ = self.seed
2140
2034
 
2141
2035
  with seed_context(self.init):
2142
- if (not isinstance(self.init, ZeroInitializer) and slice_num_of_persistent_data == 1) \
2036
+ if (not isinstance(self.init, ZeroInitializer)) \
2143
2037
  and not is_reboot_node():
2144
2038
  self.init(data)
2145
2039
  self.init = None
2146
2040
 
2147
- # At embedding cache scenes. When size of tensor is out of range, we store data to persistent storage
2148
- if slice_num_of_persistent_data > 1:
2149
- self.assign_value(TensorPy_.persistent_data_from_numpy(data, slice_num_of_persistent_data))
2150
- else:
2151
- self.assign_value(TensorPy_.from_numpy(data))
2041
+ self.assign_value(TensorPy_.from_numpy(data))
2152
2042
 
2153
2043
  if is_qint4x2:
2154
2044
  self.set_dtype(mstype.qint4x2)
@@ -2586,6 +2476,34 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
2586
2476
  """
2587
2477
  return tensor_operator_registry.get('bernoulli')(self, generator=generator)
2588
2478
 
2479
+ def bernoulli_(self, p=0.5, *, generator=None):
2480
+ r"""
2481
+ Fills each location of self with an independent sample from Bernoulli(p).
2482
+
2483
+ Args:
2484
+ p (Union[number.Number, Tensor], optional): `p` should either be a scalar or tensor containing
2485
+ probabilities to be used for drawing the binary random number, between ``0`` and ``1`` .
2486
+ If it is a tensor, `p` must be floating point. Default: ``0.5`` .
2487
+
2488
+ Keyword Args:
2489
+ generator (:class:`mindspore.Generator`, optional): a pseudorandom number generator.
2490
+ Default: ``None`` , uses the default pseudorandom number generator.
2491
+
2492
+ Returns:
2493
+ The input tensor.
2494
+
2495
+ Supported Platforms:
2496
+ ``Ascend``
2497
+
2498
+ Examples:
2499
+ >>> from mindspore import Tensor
2500
+ >>> x = Tensor([[2, 3, 4], [1, 2, 3]])
2501
+ >>> p = 0.1
2502
+ >>> print(x.bernoulli_(p).shape)
2503
+ (2, 3)
2504
+ """
2505
+ return tensor_operator_registry.get('bernoulli_')(self, p, generator=generator)
2506
+
2589
2507
  def random_(self, from_=0, to=None, *, generator=None):
2590
2508
  r"""
2591
2509
  Fill the tensor with numbers sampled from a discrete uniform distribution over an
@@ -2928,40 +2846,6 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
2928
2846
  """
2929
2847
  return tensor_operator_registry.get('bmm')(self, mat2)
2930
2848
 
2931
- def to(self, dtype):
2932
- r"""
2933
- Performs tensor dtype conversion.
2934
-
2935
- Note:
2936
- - If the `self` Tensor already has the correct `mindspore.dtype`, then self is returned.
2937
- Otherwise, the returned tensor is a copy of `self` with the desired mindspore.dtype.
2938
- - When converting complex numbers to boolean type, the imaginary part of the complex number is not
2939
- taken into account. As long as the real part is non-zero, it returns True; otherwise, it returns False.
2940
-
2941
- Args:
2942
- dtype (dtype.Number): The valid data type of the output tensor. Only constant value is allowed.
2943
-
2944
- Returns:
2945
- Tensor, converted to the specified `dtype`.
2946
-
2947
- Raises:
2948
- TypeError: If `dtype` is not a Number.
2949
-
2950
- Supported Platforms:
2951
- ``Ascend`` ``GPU`` ``CPU``
2952
-
2953
- Examples:
2954
- >>> import numpy as np
2955
- >>> import mindspore
2956
- >>> from mindspore import Tensor
2957
- >>> input_np = np.random.randn(2, 3, 4, 5).astype(np.float32)
2958
- >>> input_x = Tensor(input_np)
2959
- >>> dtype = mindspore.int32
2960
- >>> output = input_x.to(dtype)
2961
- >>> print(output.dtype)
2962
- Int32
2963
- """
2964
- return self if self.dtype == dtype else self._to(dtype)
2965
2849
 
2966
2850
  def type(self, dtype=None):
2967
2851
  r"""
@@ -2995,9 +2879,6 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
2995
2879
  r"""
2996
2880
  Returns self tensor cast to the type of the with the input other tensor.
2997
2881
 
2998
- .. warning::
2999
- This is an experimental API that is subject to change or deletion.
3000
-
3001
2882
  Note:
3002
2883
  When converting complex numbers to boolean type, the imaginary part of the complex number is not
3003
2884
  taken into account. As long as the real part is non-zero, it returns True; otherwise, it returns False.
@@ -3300,14 +3181,12 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
3300
3181
  """
3301
3182
  return tensor_operator_registry.get('unfold')(self, kernel_size, dilation, padding, stride)
3302
3183
 
3303
- def expand(self, size):
3184
+ def expand(self, *size):
3304
3185
  r"""
3305
3186
  For details, please refer to :func:`mindspore.ops.broadcast_to`.
3306
3187
  The parameter `size` of the current interface is the same as the parameter `shape` of the reference interface.
3307
3188
  """
3308
- if isinstance(size, Tensor):
3309
- size = tensor_operator_registry.get('tensortotuple')()(size)
3310
- return tensor_operator_registry.get('expand')(self, size)
3189
+ return self.broadcast_to(*size)
3311
3190
 
3312
3191
  def cumprod(self, dim, dtype=None):
3313
3192
  r"""
@@ -3508,9 +3387,6 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
3508
3387
  r"""
3509
3388
  Return a tensor filled with zeros.
3510
3389
 
3511
- .. warning::
3512
- This is an experimental API that is subject to change or deletion.
3513
-
3514
3390
  Returns:
3515
3391
  Return a tensor. Fill self tensor with zeros.
3516
3392
 
@@ -3534,6 +3410,12 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
3534
3410
  """
3535
3411
  return tensor_operator_registry.get('sign')(self)
3536
3412
 
3413
+ def sign_(self):
3414
+ """
3415
+ In-place version of :func:`mindspore.mint.sign`.
3416
+ """
3417
+ return tensor_operator_registry.get('sign_')(self)
3418
+
3537
3419
  def signbit(self):
3538
3420
  """
3539
3421
  For details, please refer to :func:`mindspore.ops.signbit`.
@@ -3546,12 +3428,6 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
3546
3428
  """
3547
3429
  return tensor_operator_registry.get('sgn')(self)
3548
3430
 
3549
- def imag(self):
3550
- r"""
3551
- For details, please refer to :func:`mindspore.ops.imag`.
3552
- """
3553
- return tensor_operator_registry.get('imag')(self)
3554
-
3555
3431
  def quantile(self, q, axis=None, keepdims=False):
3556
3432
  r"""
3557
3433
  This interface is deprecated from version 2.4 and will be removed in a future version.
@@ -3599,46 +3475,6 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
3599
3475
  """
3600
3476
  return tensor_operator_registry.get('ormqr')(self, input2, input3, left, transpose)
3601
3477
 
3602
- def masked_scatter(self, mask, x):
3603
- r"""
3604
- Updates the value in the "self Tensor" with the `tensor` value according to the mask, and returns a Tensor.
3605
- The shape of `mask` and the "self Tensor" must be the same or `mask` is broadcastable.
3606
-
3607
- .. warning::
3608
- This is an experimental API that is subject to change or deletion.
3609
-
3610
- Args:
3611
- mask (Tensor[bool]): A bool tensor with a shape broadcastable to the "self Tensor".
3612
- x (Tensor): A tensor with the same data type as the "self Tensor". The number
3613
- of elements must be greater than or equal to the number of True's in `mask`.
3614
-
3615
- Returns:
3616
- Tensor, with the same type and shape as the "self Tensor".
3617
-
3618
- Raises:
3619
- TypeError: If `mask` or `x` is not a Tensor.
3620
- TypeError: If data type of the "self Tensor" is not be supported.
3621
- TypeError: If dtype of `mask` is not bool.
3622
- TypeError: If the dim of the "self Tensor" less than the dim of `mask`.
3623
- ValueError: If `mask` can not be broadcastable to the "self Tensor".
3624
- ValueError: If the number of elements in `x` is less than the number required for the updates.
3625
-
3626
- Supported Platforms:
3627
- ``Ascend`` ``CPU``
3628
-
3629
- Examples:
3630
- >>> import numpy as np
3631
- >>> import mindspore
3632
- >>> from mindspore import Tensor
3633
- >>> x = Tensor(np.array([1., 2., 3., 4.]), mindspore.float32)
3634
- >>> mask = Tensor(np.array([True, True, False, True]), mindspore.bool_)
3635
- >>> tensor = Tensor(np.array([5., 6., 7.]), mindspore.float32)
3636
- >>> output = x.masked_scatter(mask, tensor)
3637
- >>> print(output)
3638
- [5. 6. 3. 7.]
3639
- """
3640
- return tensor_operator_registry.get('masked_scatter')()(self, mask, x)
3641
-
3642
3478
  def index_put(self, indices, values, accumulate=False):
3643
3479
  r"""
3644
3480
  Based on the indices in `indices`, replace the corresponding elements in Tensor `self`
@@ -3779,9 +3615,6 @@ class Tensor(TensorPy_, metaclass=_TensorMeta):
3779
3615
  raise ValueError(f"The type of 'blocking' must be bool, but got {blocking}")
3780
3616
  if to not in ("Ascend", "GPU", "CPU"):
3781
3617
  raise ValueError(f"The value of 'to' must be one of ['Ascend', 'GPU', 'CPU'], but got {to}")
3782
- mode = context.get_context("mode")
3783
- if mode != context.PYNATIVE_MODE:
3784
- raise ValueError(f"The method of 'move_to' only supported in pynative mode, but got: {mode}.")
3785
3618
  return TensorPy_.move_to(self, to, blocking)
3786
3619
 
3787
3620
  def _offload(self):
@@ -3951,9 +3784,9 @@ def _check_astype_and_convert(dtype):
3951
3784
  if dtype.lower() not in all_types:
3952
3785
  raise TypeError(f"For Tensor.astype, the string input type must be one of {all_types}, "
3953
3786
  f"but got '{dtype}'.")
3954
- dtype = mstype.pytype_to_dtype(np.dtype(dtype.lower()))
3787
+ dtype = mstype._pytype_to_dtype(np.dtype(dtype.lower())) # pylint:disable=protected-access
3955
3788
  elif isinstance(dtype, type):
3956
- dtype = mstype.pytype_to_dtype(dtype)
3789
+ dtype = mstype._pytype_to_dtype(dtype) # pylint:disable=protected-access
3957
3790
  elif dtype not in mstype.number_type + (mstype.bool_,):
3958
3791
  raise TypeError(
3959
3792
  f"For Tensor.astype, the input type must be one of {list(mstype.number_type + (mstype.bool_,) + np_types)},"
@@ -25,7 +25,8 @@ from mindspore import context
25
25
  from mindspore.parallel._ps_context import _is_role_sched, _is_ps_mode,\
26
26
  _get_ps_context
27
27
  from mindspore import log as logger
28
- from mindspore._c_expression import CollectiveManager, set_cluster_exit_with_exception, MSContext, GroupOptions
28
+ from mindspore._c_expression import CollectiveManager, set_cluster_exit_with_exception, MSContext, GroupOptions, \
29
+ ParallelCommManager
29
30
  from mindspore.common._utils import load_lib
30
31
 
31
32
  HCCL_LIB = 'libhccl_plugin.so'
@@ -523,6 +524,9 @@ def _create_group_helper(group, rank_ids, options=None):
523
524
  raise RuntimeError("Failed to create communication group for {} with rank ids {}. "
524
525
  "If NCCL is used, 'export NCCL_DEBUG=INFO' "
525
526
  "is suggested before launching jobs.".format(group, rank_ids))
527
+ group_info = ParallelCommManager.get_instance().hccl_groups(rank_ids)
528
+ if group_info is None or not group_info[1]:
529
+ ParallelCommManager.get_instance().set_hccl_groups(rank_ids, group, True)
526
530
 
527
531
  _ExistingGroup.ITEMS[group] = rank_ids
528
532
  sorted_ranks = sorted(rank_ids)
@@ -547,7 +551,13 @@ def _destroy_group_helper(group):
547
551
  if _hccl_test():
548
552
  hccl.create_group(group)
549
553
  else:
554
+ group_ranks_map = CollectiveManager.get_instance().get_group_map()
555
+ ranks = group_ranks_map.get(group)
556
+ if ranks is not None:
557
+ ParallelCommManager.get_instance().set_hccl_groups(ranks, group, False)
550
558
  CollectiveManager.get_instance().destroy_group(group)
559
+ del _ExistingGroup.ITEMS[group]
560
+ del _ExistingGroup.GROUP_RANKS[group]
551
561
 
552
562
 
553
563
  @check_parameter_available
@@ -18,7 +18,7 @@ Defines communication operators with functional form.
18
18
  """
19
19
  from mindspore.communication import GlobalComm, get_group_rank_from_world_rank, get_group_size
20
20
  from mindspore.communication.management import _get_group
21
- from mindspore.communication._comm_helper import _get_group_rank_from_world_rank_from_cache_helper
21
+ from mindspore.communication._comm_helper import _get_group_rank_from_world_rank_from_cache_helper, _get_rank_helper
22
22
  from mindspore.common.tensor import Tensor
23
23
  from mindspore._c_expression import TensorPy as Tensor_
24
24
  from mindspore.ops import ReduceOp, cat
@@ -26,7 +26,8 @@ from mindspore.ops._primitive_cache import _get_cache_prim
26
26
  from mindspore.ops.primitive import _primexpr
27
27
  from mindspore.ops.auto_generate.gen_ops_prim import (inner_comm_all_reduce_op, inner_comm_all_gather_op,
28
28
  inner_comm_all_to_all_v_op, inner_comm_irecv_op,
29
- inner_comm_isend_op, inner_comm_reduce_scatter_op)
29
+ inner_comm_isend_op, inner_comm_reduce_scatter_op,
30
+ dist_comm_all_to_all_v_c_op)
30
31
  from mindspore._c_expression import CommHandle as CommHandle_
31
32
  from mindspore._c_expression.typing import Type
32
33
  from mindspore import jit_class
@@ -49,11 +50,13 @@ __all__ = [
49
50
  'recv',
50
51
  'P2POp',
51
52
  'batch_isend_irecv',
53
+ 'all_to_all_v_c'
52
54
  ]
53
55
 
54
56
  import mindspore.ops.operations as P
55
57
 
56
58
  _GROPU_SIZE_CACHE = {}
59
+ _GROPU_RANK_CACHE = {}
57
60
 
58
61
  @jit_class
59
62
  class CommHandle(CommHandle_):
@@ -733,7 +736,7 @@ def gather_into_tensor(tensor, dst=0, group=GlobalComm.WORLD_COMM_GROUP):
733
736
  Args:
734
737
  tensor (Tensor): The tensor to be gathered. The shape of tensor is :math:`(x_1, x_2, ..., x_R)`.
735
738
  dst(int, optional): Specifies the rank(global rank) of the process that receive the tensor.
736
- And only process `dst` will receive the gathered tensor. Default: 0.
739
+ And only process `dst` will receive the gathered tensor. Default: ``0``.
737
740
  group (str, optional): The communication group to work on. Default: ``GlobalComm.WORLD_COMM_GROUP``.
738
741
 
739
742
  Returns:
@@ -890,7 +893,8 @@ def barrier(group=GlobalComm.WORLD_COMM_GROUP):
890
893
  if not isinstance(group, str):
891
894
  raise TypeError(f"group must be type of string, but got {type(group)}")
892
895
  _op = _get_cache_prim(P.Barrier)(group)
893
- return _op()
896
+ _op()
897
+ ms.runtime.synchronize()
894
898
 
895
899
 
896
900
  def _deal_comm_outputs(output, async_op, exec_sync=False):
@@ -1452,3 +1456,133 @@ def all_to_all_single_with_output_shape(output_shape, tensor, output_split_sizes
1452
1456
  result = result.reshape((-1,) + recv_shape_without_first_dim)
1453
1457
 
1454
1458
  return result, handle
1459
+
1460
+
1461
+ def _get_all_to_all_v_c_numel_list(output, input, send_count_matrix_size):
1462
+ """get numel list for all_to_all_v_c."""
1463
+ send_size_without_first_dim = _get_size(input.shape[1:])
1464
+ recv_size_without_first_dim = _get_size(output.shape[1:])
1465
+ if send_size_without_first_dim != recv_size_without_first_dim:
1466
+ raise ValueError("The input and output dimensions except 0 must be of equal size, "
1467
+ f"but got {send_size_without_first_dim} and {recv_size_without_first_dim}.")
1468
+ send_count_matrix = [size * send_size_without_first_dim for size in send_count_matrix_size]
1469
+ return send_count_matrix
1470
+
1471
+
1472
+ def get_cache_group_size(group=GlobalComm.WORLD_COMM_GROUP):
1473
+ """get cache group size."""
1474
+ global _GROPU_SIZE_CACHE
1475
+ if group not in _GROPU_SIZE_CACHE:
1476
+ _GROPU_SIZE_CACHE[group] = get_group_size(group)
1477
+ group_size = _GROPU_SIZE_CACHE[group]
1478
+ return group_size
1479
+
1480
+
1481
+ def get_cache_group_rank(group=GlobalComm.WORLD_COMM_GROUP):
1482
+ """get cache rank id."""
1483
+ global _GROPU_RANK_CACHE
1484
+ if group not in _GROPU_RANK_CACHE:
1485
+ _GROPU_RANK_CACHE[group] = _get_rank_helper(group)
1486
+ group_rank = _GROPU_RANK_CACHE[group]
1487
+ return group_rank
1488
+
1489
+
1490
+ def all_to_all_v_c(output, input, send_count_matrix, group=None, async_op=False):
1491
+ r"""
1492
+ Based on the user-specified split size, the input tensor is divided and sent to other devices, where split chunks
1493
+ are received and then merged into a single output tensor.
1494
+
1495
+ Note:
1496
+ Only support PyNative mode, Graph mode is not currently supported.
1497
+
1498
+ Args:
1499
+ output (Tensor): the output tensor is gathered concatenated from remote ranks.
1500
+ input (Tensor): tensor to be scattered to remote rank.
1501
+ send_count_matrix (list[int]): The sending and receiving parameters of all ranks,
1502
+ :math:`\text{send_count_matrix}[i*\text{rank_size}+j]` represents the amount of data sent by
1503
+ rank i to rank j, and the basic unit is first dimension sizes. Among them, `rank_size`
1504
+ indicates the size of the communication group.
1505
+ group (str, optional): The communication group to work on. If ``None``, which means ``"hccl_world_group"`` in
1506
+ Ascend. Default: ``None``.
1507
+ async_op (bool, optional): Whether this operator should be an async operator. Default: ``False`` .
1508
+
1509
+ Returns:
1510
+ CommHandle. CommHandle is an async work handle, if `async_op` is set to True.
1511
+ CommHandle will be None, when `async_op` is False.
1512
+
1513
+ Raises:
1514
+ TypeError: If `input` or `output` is not tensor. `group` is not a str, or async_op is not bool.
1515
+
1516
+ Supported Platforms:
1517
+ ``Ascend``
1518
+
1519
+ Examples:
1520
+ .. note::
1521
+ Before running the following examples, you need to configure the communication environment variables.
1522
+
1523
+ For Ascend devices, it is recommended to use the msrun startup method
1524
+ without any third-party or configuration file dependencies.
1525
+ Please see the `msrun start up
1526
+ <https://www.mindspore.cn/tutorials/en/master/parallel/msrun_launcher.html>`_
1527
+ for more details.
1528
+
1529
+ This example should be run with 2 devices.
1530
+
1531
+ >>> import numpy as np
1532
+ >>> import mindspore
1533
+ >>> from mindspore.mint.distributed import init_process_group, get_rank
1534
+ >>> from mindspore.communication.comm_func import all_to_all_v_c
1535
+ >>> from mindspore import Tensor
1536
+ >>> from mindspore.ops import zeros
1537
+ >>>
1538
+ >>> init_process_group()
1539
+ >>> this_rank = get_rank()
1540
+ >>> if this_rank == 0:
1541
+ ... output = Tensor(np.zeros([3]).astype(np.float32))
1542
+ ... tensor = Tensor([0, 1, 2.]) * this_rank
1543
+ ... result = all_to_all_v_c(output, tensor, [0, 3, 3, 0])
1544
+ ... print(output)
1545
+ >>> if this_rank == 1:
1546
+ ... output = Tensor(np.zeros([3]).astype(np.float32))
1547
+ ... tensor = Tensor([0, 1, 2.]) * this_rank
1548
+ ... result = all_to_all_v_c(output, tensor, [0, 3, 3, 0])
1549
+ ... print(output)
1550
+ rank 0:
1551
+ [0. 1. 2]
1552
+ rank 1:
1553
+ [0. 0. 0]
1554
+ """
1555
+
1556
+ _check_all_tensors([input])
1557
+ _check_all_tensors([output])
1558
+ if group is None:
1559
+ group = GlobalComm.WORLD_COMM_GROUP
1560
+ if not isinstance(group, str):
1561
+ raise TypeError(
1562
+ "The argument 'group' must be type of string, "
1563
+ "but got 'group' type : {}.".format(type(group))
1564
+ )
1565
+ if not isinstance(async_op, bool):
1566
+ raise TypeError(
1567
+ f"The argument 'async_op' must be a bool, but got {type(async_op)}."
1568
+ )
1569
+ if not isinstance(send_count_matrix, list):
1570
+ raise TypeError("send_count_matrix must be list, but got {}".format(type(send_count_matrix)))
1571
+ if not all(isinstance(x, int) for x in send_count_matrix):
1572
+ raise TypeError("send_count_matrix elements must be of type int")
1573
+ rank_size = get_cache_group_size(group)
1574
+ if rank_size * rank_size != len(send_count_matrix):
1575
+ raise TypeError(f"send_count_matrix must be square matrix, but got {len(send_count_matrix)}.")
1576
+ _send_count_matrix = _get_all_to_all_v_c_numel_list(output, input, send_count_matrix)
1577
+ _input = input.reshape(-1)
1578
+ rank_id = get_cache_group_rank(group)
1579
+ result = dist_comm_all_to_all_v_c_op(
1580
+ output,
1581
+ _input,
1582
+ group,
1583
+ _send_count_matrix,
1584
+ rank_size,
1585
+ rank_id,
1586
+ )
1587
+ _, handle = _deal_comm_outputs(result, async_op)
1588
+ return handle