mindspore 2.4.1__cp39-cp39-win_amd64.whl → 2.5.0__cp39-cp39-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.
- mindspore/.commit_id +1 -1
- mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
- mindspore/Newtonsoft.Json.dll +0 -0
- mindspore/__init__.py +8 -3
- mindspore/_c_dataengine.cp39-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp39-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp39-win_amd64.pyd +0 -0
- mindspore/_checkparam.py +0 -5
- mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
- mindspore/_extends/parse/compile_config.py +64 -0
- mindspore/_extends/parse/deprecated/__init__.py +0 -0
- mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +375 -0
- mindspore/_extends/parse/parser.py +23 -5
- mindspore/_extends/parse/standard_method.py +123 -27
- mindspore/_extends/pijit/pijit_func_white_list.py +1 -1
- mindspore/amp.py +7 -1
- mindspore/atlprov.dll +0 -0
- mindspore/avcodec-59.dll +0 -0
- mindspore/avdevice-59.dll +0 -0
- mindspore/avfilter-8.dll +0 -0
- mindspore/avformat-59.dll +0 -0
- mindspore/avutil-57.dll +0 -0
- mindspore/boost/boost_cell_wrapper.py +136 -41
- mindspore/c1.dll +0 -0
- mindspore/c1xx.dll +0 -0
- mindspore/c2.dll +0 -0
- mindspore/common/__init__.py +3 -1
- mindspore/common/_register_for_tensor.py +0 -1
- mindspore/common/_stub_tensor.py +25 -4
- mindspore/common/_tensor_cpp_method.py +17 -0
- mindspore/common/_tensor_docs.py +6132 -0
- mindspore/common/api.py +99 -25
- mindspore/common/dtype.py +34 -34
- mindspore/common/dump.py +2 -1
- mindspore/common/file_system.py +8 -1
- mindspore/common/generator.py +2 -0
- mindspore/common/hook_handle.py +3 -1
- mindspore/common/initializer.py +3 -4
- mindspore/common/lazy_inline.py +8 -2
- mindspore/common/mindir_util.py +10 -2
- mindspore/common/parameter.py +30 -27
- mindspore/common/tensor.py +713 -1337
- mindspore/communication/__init__.py +1 -1
- mindspore/communication/_comm_helper.py +10 -0
- mindspore/communication/comm_func.py +215 -173
- mindspore/communication/management.py +23 -20
- mindspore/context.py +292 -193
- mindspore/dataset/__init__.py +23 -19
- mindspore/dataset/callback/ds_callback.py +2 -1
- mindspore/dataset/core/config.py +84 -3
- mindspore/dataset/engine/cache_admin.py +3 -3
- mindspore/dataset/engine/cache_client.py +5 -4
- mindspore/dataset/engine/datasets.py +192 -149
- mindspore/dataset/engine/datasets_audio.py +14 -0
- mindspore/dataset/engine/datasets_standard_format.py +28 -11
- mindspore/dataset/engine/datasets_text.py +38 -1
- mindspore/dataset/engine/datasets_user_defined.py +125 -65
- mindspore/dataset/engine/datasets_vision.py +81 -8
- mindspore/dataset/engine/iterators.py +281 -63
- mindspore/dataset/engine/obs/util.py +8 -0
- mindspore/dataset/engine/queue.py +40 -0
- mindspore/dataset/engine/samplers.py +26 -2
- mindspore/dataset/engine/serializer_deserializer.py +1 -1
- mindspore/dataset/engine/validators.py +43 -11
- mindspore/dataset/transforms/py_transforms_util.py +17 -0
- mindspore/dataset/transforms/transforms.py +29 -12
- mindspore/dataset/vision/validators.py +1 -2
- mindspore/device_context/__init__.py +21 -0
- mindspore/device_context/ascend/__init__.py +25 -0
- mindspore/device_context/ascend/device.py +72 -0
- mindspore/device_context/ascend/op_debug.py +94 -0
- mindspore/device_context/ascend/op_precision.py +193 -0
- mindspore/device_context/ascend/op_tuning.py +127 -0
- mindspore/device_context/cpu/__init__.py +25 -0
- mindspore/device_context/cpu/device.py +62 -0
- mindspore/device_context/cpu/op_tuning.py +43 -0
- mindspore/device_context/gpu/__init__.py +21 -0
- mindspore/device_context/gpu/device.py +70 -0
- mindspore/device_context/gpu/op_precision.py +67 -0
- mindspore/device_context/gpu/op_tuning.py +175 -0
- mindspore/device_manager.py +134 -0
- mindspore/dnnl.dll +0 -0
- mindspore/dpcmi.dll +0 -0
- mindspore/experimental/llm_boost/__init__.py +3 -2
- mindspore/experimental/llm_boost/ascend_native/__init__.py +22 -0
- mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +211 -0
- mindspore/experimental/llm_boost/ascend_native/llm_boost.py +52 -0
- mindspore/experimental/llm_boost/atb/boost_base.py +239 -64
- mindspore/experimental/llm_boost/atb/llama_boost.py +52 -30
- mindspore/experimental/llm_boost/atb/qwen_boost.py +47 -24
- mindspore/experimental/llm_boost/register.py +1 -0
- mindspore/experimental/optim/adadelta.py +26 -22
- mindspore/experimental/optim/adam.py +3 -0
- mindspore/experimental/optim/lr_scheduler.py +33 -24
- mindspore/experimental/optim/radam.py +33 -30
- mindspore/hal/device.py +28 -0
- mindspore/hal/event.py +17 -0
- mindspore/hal/memory.py +94 -3
- mindspore/hal/stream.py +91 -6
- mindspore/include/api/context.h +1 -2
- mindspore/include/dataset/constants.h +2 -2
- mindspore/jpeg62.dll +0 -0
- mindspore/log.py +12 -0
- mindspore/mindrecord/__init__.py +1 -1
- mindspore/mindrecord/config.py +17 -316
- mindspore/mindrecord/filereader.py +1 -9
- mindspore/mindrecord/filewriter.py +5 -15
- mindspore/mindrecord/mindpage.py +1 -9
- mindspore/mindspore_backend.dll +0 -0
- mindspore/mindspore_common.dll +0 -0
- mindspore/mindspore_core.dll +0 -0
- mindspore/mindspore_glog.dll +0 -0
- mindspore/mindspore_ops.dll +0 -0
- mindspore/mint/__init__.py +824 -218
- mindspore/mint/distributed/__init__.py +66 -4
- mindspore/mint/distributed/distributed.py +2594 -44
- mindspore/mint/linalg/__init__.py +6 -0
- mindspore/mint/nn/__init__.py +473 -14
- mindspore/mint/nn/functional.py +486 -11
- mindspore/mint/nn/layer/__init__.py +17 -4
- mindspore/mint/nn/layer/_functions.py +330 -0
- mindspore/mint/nn/layer/activation.py +169 -1
- mindspore/mint/nn/layer/basic.py +123 -0
- mindspore/mint/nn/layer/conv.py +727 -0
- mindspore/mint/nn/layer/normalization.py +215 -19
- mindspore/mint/nn/layer/padding.py +797 -0
- mindspore/mint/nn/layer/pooling.py +170 -0
- mindspore/mint/optim/__init__.py +2 -1
- mindspore/mint/optim/adam.py +223 -0
- mindspore/mint/optim/adamw.py +26 -19
- mindspore/mint/special/__init__.py +2 -1
- mindspore/msobj140.dll +0 -0
- mindspore/mspdb140.dll +0 -0
- mindspore/mspdbcore.dll +0 -0
- mindspore/mspdbst.dll +0 -0
- mindspore/mspft140.dll +0 -0
- mindspore/msvcdis140.dll +0 -0
- mindspore/msvcp140_1.dll +0 -0
- mindspore/msvcp140_2.dll +0 -0
- mindspore/msvcp140_atomic_wait.dll +0 -0
- mindspore/msvcp140_codecvt_ids.dll +0 -0
- mindspore/multiprocessing/__init__.py +5 -0
- mindspore/nn/__init__.py +2 -0
- mindspore/nn/cell.py +142 -21
- mindspore/nn/dynamic_lr.py +2 -1
- mindspore/nn/layer/activation.py +6 -6
- mindspore/nn/layer/basic.py +35 -25
- mindspore/nn/layer/channel_shuffle.py +3 -3
- mindspore/nn/layer/conv.py +3 -0
- mindspore/nn/layer/embedding.py +3 -3
- mindspore/nn/layer/normalization.py +8 -7
- mindspore/nn/layer/padding.py +4 -3
- mindspore/nn/layer/pooling.py +55 -23
- mindspore/nn/layer/rnn_cells.py +1 -1
- mindspore/nn/layer/rnns.py +2 -1
- mindspore/nn/layer/timedistributed.py +5 -5
- mindspore/nn/layer/transformer.py +48 -26
- mindspore/nn/learning_rate_schedule.py +5 -3
- mindspore/nn/loss/loss.py +31 -36
- mindspore/nn/optim/ada_grad.py +1 -0
- mindspore/nn/optim/adadelta.py +2 -2
- mindspore/nn/optim/adam.py +1 -1
- mindspore/nn/optim/lars.py +1 -4
- mindspore/nn/optim/optimizer.py +1 -1
- mindspore/nn/optim/rprop.py +2 -2
- mindspore/nn/optim/thor.py +2 -1
- mindspore/nn/utils/__init__.py +22 -0
- mindspore/nn/utils/init.py +73 -0
- mindspore/nn/wrap/cell_wrapper.py +4 -6
- mindspore/nn/wrap/loss_scale.py +3 -4
- mindspore/numpy/array_creations.py +60 -62
- mindspore/numpy/array_ops.py +148 -143
- mindspore/numpy/logic_ops.py +41 -42
- mindspore/numpy/math_ops.py +361 -359
- mindspore/numpy/utils.py +16 -16
- mindspore/numpy/utils_const.py +4 -4
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/opencv_imgproc452.dll +0 -0
- mindspore/ops/__init__.py +2 -1
- mindspore/ops/_grad_experimental/grad_comm_ops.py +107 -8
- mindspore/ops/_grad_experimental/grad_debug_ops.py +6 -1
- mindspore/ops/_grad_experimental/grad_inner_ops.py +9 -0
- mindspore/ops/_grad_experimental/grad_math_ops.py +2 -1
- mindspore/ops/_op_impl/cpu/__init__.py +1 -0
- mindspore/ops/_op_impl/cpu/raise_op.py +28 -0
- mindspore/ops/_vmap/vmap_array_ops.py +20 -19
- mindspore/ops/_vmap/vmap_base.py +0 -2
- mindspore/ops/_vmap/vmap_grad_nn_ops.py +19 -13
- mindspore/ops/_vmap/vmap_math_ops.py +11 -9
- mindspore/ops/_vmap/vmap_nn_ops.py +20 -34
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +149 -12
- mindspore/ops/auto_generate/gen_arg_handler.py +0 -61
- mindspore/ops/auto_generate/gen_extend_func.py +554 -60
- mindspore/ops/auto_generate/gen_ops_def.py +1621 -115
- mindspore/ops/auto_generate/gen_ops_prim.py +8027 -3411
- mindspore/ops/auto_generate/pyboost_inner_prim.py +183 -79
- mindspore/ops/composite/base.py +1 -1
- mindspore/ops/composite/multitype_ops/_compile_utils.py +229 -30
- mindspore/ops/composite/multitype_ops/pow_impl.py +0 -29
- mindspore/ops/function/__init__.py +12 -0
- mindspore/ops/function/array_func.py +561 -159
- mindspore/ops/function/clip_func.py +64 -0
- mindspore/ops/function/debug_func.py +28 -20
- mindspore/ops/function/image_func.py +1 -1
- mindspore/ops/function/linalg_func.py +5 -4
- mindspore/ops/function/math_func.py +1664 -294
- mindspore/ops/function/nn_func.py +988 -317
- mindspore/ops/function/parameter_func.py +3 -56
- mindspore/ops/function/random_func.py +243 -33
- mindspore/ops/function/sparse_unary_func.py +1 -1
- mindspore/ops/functional.py +18 -5
- mindspore/ops/functional_overload.py +897 -0
- mindspore/ops/operations/__init__.py +3 -2
- mindspore/ops/operations/_embedding_cache_ops.py +4 -4
- mindspore/ops/operations/_grad_ops.py +2 -34
- mindspore/ops/operations/_infer_ops.py +2 -1
- mindspore/ops/operations/_inner_ops.py +38 -8
- mindspore/ops/operations/array_ops.py +45 -303
- mindspore/ops/operations/comm_ops.py +23 -17
- mindspore/ops/operations/custom_ops.py +7 -49
- mindspore/ops/operations/debug_ops.py +42 -47
- mindspore/ops/operations/inner_ops.py +6 -4
- mindspore/ops/operations/linalg_ops.py +3 -2
- mindspore/ops/operations/manually_defined/ops_def.py +185 -104
- mindspore/ops/operations/math_ops.py +11 -216
- mindspore/ops/operations/nn_ops.py +153 -310
- mindspore/ops/primitive.py +23 -21
- mindspore/ops/tensor_method.py +1669 -0
- mindspore/ops_generate/aclnn_kernel_register_auto_cc_generator.py +110 -0
- mindspore/ops_generate/add_tensor_docs_generator.py +54 -0
- mindspore/ops_generate/arg_handler.py +0 -61
- mindspore/ops_generate/auto_grad_impl_cc_generator.py +135 -0
- mindspore/ops_generate/auto_grad_reg_cc_generator.py +93 -0
- mindspore/ops_generate/base_generator.py +11 -0
- mindspore/ops_generate/cpp_create_prim_instance_helper_generator.py +108 -0
- mindspore/ops_generate/functional_map_cpp_generator.py +491 -0
- mindspore/ops_generate/functional_overload_py_generator.py +110 -0
- mindspore/ops_generate/functions_cc_generator.py +233 -0
- mindspore/ops_generate/gen_aclnn_implement.py +110 -114
- mindspore/ops_generate/gen_constants.py +157 -3
- mindspore/ops_generate/gen_ops.py +245 -990
- mindspore/ops_generate/gen_pyboost_func.py +97 -998
- mindspore/ops_generate/gen_utils.py +119 -33
- mindspore/ops_generate/lite_ops_cpp_generator.py +155 -0
- mindspore/ops_generate/op_api_proto.py +206 -0
- mindspore/ops_generate/op_def_py_generator.py +131 -0
- mindspore/ops_generate/op_prim_py_generator.py +480 -0
- mindspore/ops_generate/op_proto.py +373 -108
- mindspore/ops_generate/op_template_parser.py +436 -0
- mindspore/ops_generate/ops_def_cc_generator.py +288 -0
- mindspore/ops_generate/ops_def_h_generator.py +74 -0
- mindspore/ops_generate/ops_name_h_generator.py +68 -0
- mindspore/ops_generate/ops_primitive_h_generator.py +81 -0
- mindspore/ops_generate/pyboost_functions_cpp_generator.py +370 -0
- mindspore/ops_generate/pyboost_functions_h_generator.py +68 -0
- mindspore/ops_generate/pyboost_functions_py_generator.py +148 -0
- mindspore/ops_generate/pyboost_grad_function_cpp_generator.py +154 -0
- mindspore/ops_generate/pyboost_inner_prim_generator.py +131 -0
- mindspore/ops_generate/pyboost_native_grad_functions_generator.py +268 -0
- mindspore/ops_generate/pyboost_op_cpp_code_generator.py +851 -0
- mindspore/ops_generate/pyboost_overload_functions_cpp_generator.py +344 -0
- mindspore/ops_generate/pyboost_utils.py +92 -33
- mindspore/ops_generate/template.py +294 -44
- mindspore/ops_generate/tensor_func_reg_cpp_generator.py +422 -0
- mindspore/parallel/__init__.py +3 -3
- mindspore/parallel/_auto_parallel_context.py +44 -34
- mindspore/parallel/_cell_wrapper.py +22 -3
- mindspore/parallel/_parallel_serialization.py +13 -2
- mindspore/parallel/_utils.py +4 -2
- mindspore/parallel/algo_parameter_config.py +1 -1
- mindspore/parallel/checkpoint_transform.py +44 -0
- mindspore/parallel/cluster/process_entity/_api.py +131 -37
- mindspore/parallel/cluster/process_entity/_utils.py +41 -6
- mindspore/parallel/cluster/run.py +20 -3
- mindspore/parallel/parameter_broadcast.py +1 -1
- mindspore/parallel/shard.py +3 -0
- mindspore/parallel/transform_safetensors.py +119 -253
- mindspore/pgodb140.dll +0 -0
- mindspore/pgort140.dll +0 -0
- mindspore/profiler/__init__.py +17 -4
- mindspore/profiler/analysis/__init__.py +0 -0
- mindspore/profiler/analysis/parser/__init__.py +0 -0
- mindspore/profiler/analysis/parser/ascend_cann_parser.py +166 -0
- mindspore/profiler/analysis/parser/base_parser.py +158 -0
- mindspore/profiler/analysis/parser/framework_cann_relation_parser.py +45 -0
- mindspore/profiler/analysis/parser/ms_framework_parser.py +142 -0
- mindspore/profiler/analysis/parser/ms_minddata_parser.py +145 -0
- mindspore/profiler/analysis/parser/timeline_assembly_factory/__init__.py +0 -0
- mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +261 -0
- mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +40 -0
- mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +84 -0
- mindspore/profiler/analysis/parser/timeline_creator/__init__.py +0 -0
- mindspore/profiler/analysis/parser/timeline_creator/base_timeline_creator.py +44 -0
- mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +90 -0
- mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +76 -0
- mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +103 -0
- mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +134 -0
- mindspore/profiler/analysis/parser/timeline_event/__init__.py +0 -0
- mindspore/profiler/analysis/parser/timeline_event/base_event.py +233 -0
- mindspore/profiler/analysis/parser/timeline_event/cpu_op_event.py +47 -0
- mindspore/profiler/analysis/parser/timeline_event/flow_event.py +36 -0
- mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +260 -0
- mindspore/profiler/analysis/parser/timeline_event/msprof_event.py +73 -0
- mindspore/profiler/analysis/parser/timeline_event/scope_layer_event.py +53 -0
- mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +146 -0
- mindspore/profiler/analysis/task_manager.py +131 -0
- mindspore/profiler/analysis/time_converter.py +84 -0
- mindspore/profiler/analysis/viewer/__init__.py +0 -0
- mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +333 -0
- mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +87 -0
- mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +252 -0
- mindspore/profiler/analysis/viewer/ascend_memory_viewer.py +313 -0
- mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +322 -0
- mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +265 -0
- mindspore/profiler/analysis/viewer/ascend_timeline_viewer.py +58 -0
- mindspore/profiler/analysis/viewer/base_viewer.py +26 -0
- mindspore/profiler/analysis/viewer/ms_dataset_viewer.py +97 -0
- mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +581 -0
- mindspore/profiler/analysis/work_flow.py +73 -0
- mindspore/profiler/common/ascend_msprof_exporter.py +138 -0
- mindspore/profiler/common/command_executor.py +90 -0
- mindspore/profiler/common/constant.py +174 -3
- mindspore/profiler/common/file_manager.py +208 -0
- mindspore/profiler/common/log.py +130 -0
- mindspore/profiler/common/msprof_cmd_tool.py +202 -0
- mindspore/profiler/common/path_manager.py +371 -0
- mindspore/profiler/common/process_bar.py +168 -0
- mindspore/profiler/common/process_pool.py +9 -3
- mindspore/profiler/common/profiler_context.py +476 -0
- mindspore/profiler/common/profiler_info.py +304 -0
- mindspore/profiler/common/profiler_output_path.py +284 -0
- mindspore/profiler/common/profiler_parameters.py +210 -0
- mindspore/profiler/common/profiler_path_manager.py +120 -0
- mindspore/profiler/common/record_function.py +76 -0
- mindspore/profiler/common/tlv_decoder.py +76 -0
- mindspore/profiler/common/util.py +75 -2
- mindspore/profiler/dynamic_profiler.py +270 -37
- mindspore/profiler/envprofiler.py +138 -0
- mindspore/profiler/mstx.py +199 -0
- mindspore/profiler/platform/__init__.py +21 -0
- mindspore/profiler/platform/base_profiler.py +40 -0
- mindspore/profiler/platform/cpu_profiler.py +124 -0
- mindspore/profiler/platform/gpu_profiler.py +74 -0
- mindspore/profiler/platform/npu_profiler.py +309 -0
- mindspore/profiler/profiler.py +580 -93
- mindspore/profiler/profiler_action_controller.py +187 -0
- mindspore/profiler/profiler_interface.py +114 -0
- mindspore/profiler/schedule.py +208 -0
- mindspore/rewrite/api/symbol_tree.py +1 -2
- mindspore/run_check/_check_version.py +18 -13
- mindspore/runtime/__init__.py +37 -0
- mindspore/runtime/device.py +27 -0
- mindspore/runtime/event.py +209 -0
- mindspore/runtime/executor.py +148 -0
- mindspore/runtime/memory.py +392 -0
- mindspore/runtime/stream.py +460 -0
- mindspore/runtime/thread_bind_core.py +401 -0
- mindspore/swresample-4.dll +0 -0
- mindspore/swscale-6.dll +0 -0
- mindspore/tbbmalloc.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/__init__.py +2 -2
- mindspore/train/_utils.py +53 -18
- mindspore/train/amp.py +8 -4
- mindspore/train/callback/_checkpoint.py +32 -18
- mindspore/train/callback/_early_stop.py +1 -1
- mindspore/train/callback/_flops_collector.py +105 -69
- mindspore/train/callback/_history.py +1 -1
- mindspore/train/callback/_summary_collector.py +44 -6
- mindspore/train/callback/_tft_register.py +37 -15
- mindspore/train/dataset_helper.py +11 -11
- mindspore/train/metrics/precision.py +4 -5
- mindspore/train/mind_ir_pb2.py +167 -46
- mindspore/train/model.py +13 -14
- mindspore/train/serialization.py +461 -72
- mindspore/train/summary/summary_record.py +1 -2
- mindspore/train/train_thor/model_thor.py +1 -1
- mindspore/turbojpeg.dll +0 -0
- mindspore/utils/__init__.py +4 -2
- mindspore/utils/dryrun.py +138 -0
- mindspore/utils/runtime_execution_order_check.py +550 -0
- mindspore/vcmeta.dll +0 -0
- mindspore/vcruntime140.dll +0 -0
- mindspore/vcruntime140_1.dll +0 -0
- mindspore/version.py +1 -1
- {mindspore-2.4.1.dist-info → mindspore-2.5.0.dist-info}/METADATA +3 -4
- {mindspore-2.4.1.dist-info → mindspore-2.5.0.dist-info}/RECORD +391 -265
- {mindspore-2.4.1.dist-info → mindspore-2.5.0.dist-info}/entry_points.txt +1 -1
- mindspore/common/_tensor_overload.py +0 -139
- mindspore/mindspore_np_dtype.dll +0 -0
- mindspore/profiler/envprofiling.py +0 -254
- mindspore/profiler/profiling.py +0 -1926
- {mindspore-2.4.1.dist-info → mindspore-2.5.0.dist-info}/WHEEL +0 -0
- {mindspore-2.4.1.dist-info → mindspore-2.5.0.dist-info}/top_level.txt +0 -0
|
@@ -28,7 +28,9 @@ from mindspore.ops.auto_generate.gen_ops_prim import (inner_comm_all_reduce_op,
|
|
|
28
28
|
inner_comm_all_to_all_v_op, inner_comm_irecv_op,
|
|
29
29
|
inner_comm_isend_op, inner_comm_reduce_scatter_op)
|
|
30
30
|
from mindspore._c_expression import CommHandle as CommHandle_
|
|
31
|
+
from mindspore._c_expression.typing import Type
|
|
31
32
|
from mindspore import jit_class
|
|
33
|
+
from mindspore.common.api import _pynative_executor
|
|
32
34
|
|
|
33
35
|
__all__ = [
|
|
34
36
|
'all_reduce',
|
|
@@ -218,19 +220,18 @@ def all_reduce(tensor, op=ReduceOp.SUM, group=GlobalComm.WORLD_COMM_GROUP, async
|
|
|
218
220
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
219
221
|
without any third-party or configuration file dependencies.
|
|
220
222
|
Please see the `msrun start up
|
|
221
|
-
<https://www.mindspore.cn/docs/
|
|
223
|
+
<https://www.mindspore.cn/docs/en/master/model_train/parallel/msrun_launcher.html>`_
|
|
222
224
|
for more details.
|
|
223
225
|
|
|
224
226
|
This example should be run with 2 devices.
|
|
225
227
|
|
|
226
228
|
>>> import numpy as np
|
|
227
|
-
>>>
|
|
228
|
-
>>>
|
|
229
|
-
>>> from mindspore import Tensor
|
|
229
|
+
>>> import mindspore as ms
|
|
230
|
+
>>> import mindspore.communication as comm
|
|
230
231
|
>>>
|
|
231
|
-
>>> init()
|
|
232
|
-
>>> input_tensor = Tensor(np.ones([2, 8]).astype(np.float32))
|
|
233
|
-
>>> output = all_reduce(input_tensor)
|
|
232
|
+
>>> comm.init()
|
|
233
|
+
>>> input_tensor = ms.Tensor(np.ones([2, 8]).astype(np.float32))
|
|
234
|
+
>>> output, _ = comm.comm_func.all_reduce(input_tensor)
|
|
234
235
|
>>> print(output)
|
|
235
236
|
[[2. 2. 2. 2. 2. 2. 2. 2.]
|
|
236
237
|
[2. 2. 2. 2. 2. 2. 2. 2.]]
|
|
@@ -284,22 +285,18 @@ def all_gather_into_tensor(tensor, group=GlobalComm.WORLD_COMM_GROUP, async_op=F
|
|
|
284
285
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
285
286
|
without any third-party or configuration file dependencies.
|
|
286
287
|
Please see the `msrun start up
|
|
287
|
-
<https://www.mindspore.cn/docs/
|
|
288
|
+
<https://www.mindspore.cn/docs/en/master/model_train/parallel/msrun_launcher.html>`_
|
|
288
289
|
for more details.
|
|
289
290
|
|
|
290
291
|
This example should be run with 2 devices.
|
|
291
292
|
|
|
292
293
|
>>> import numpy as np
|
|
293
294
|
>>> import mindspore as ms
|
|
294
|
-
>>>
|
|
295
|
-
>>> from mindspore.communication import init
|
|
296
|
-
>>> from mindspore.communication.comm_func import all_gather_into_tensor
|
|
297
|
-
>>> from mindspore import Tensor
|
|
295
|
+
>>> import mindspore.communication as comm
|
|
298
296
|
>>>
|
|
299
|
-
>>>
|
|
300
|
-
>>>
|
|
301
|
-
>>>
|
|
302
|
-
>>> output = all_gather_into_tensor(input_tensor)
|
|
297
|
+
>>> comm.init()
|
|
298
|
+
>>> input_tensor = ms.Tensor(np.ones([2, 8]).astype(np.float32))
|
|
299
|
+
>>> output, _ = comm.comm_func.all_gather_into_tensor(input_tensor)
|
|
303
300
|
>>> print(output)
|
|
304
301
|
[[1. 1. 1. 1. 1. 1. 1. 1.]
|
|
305
302
|
[1. 1. 1. 1. 1. 1. 1. 1.]
|
|
@@ -358,21 +355,18 @@ def reduce_scatter_tensor(tensor, op=ReduceOp.SUM, group=GlobalComm.WORLD_COMM_G
|
|
|
358
355
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
359
356
|
without any third-party or configuration file dependencies.
|
|
360
357
|
Please see the `msrun start up
|
|
361
|
-
<https://www.mindspore.cn/docs/
|
|
358
|
+
<https://www.mindspore.cn/docs/en/master/model_train/parallel/msrun_launcher.html>`_
|
|
362
359
|
for more details.
|
|
363
360
|
|
|
364
361
|
This example should be run with 2 devices.
|
|
365
362
|
|
|
366
|
-
>>> import mindspore as ms
|
|
367
|
-
>>> from mindspore import Tensor
|
|
368
|
-
>>> from mindspore.communication import init
|
|
369
|
-
>>> from mindspore.communication.comm_func import reduce_scatter_tensor
|
|
370
363
|
>>> import numpy as np
|
|
364
|
+
>>> import mindspore as ms
|
|
365
|
+
>>> import mindspore.communication as comm
|
|
371
366
|
>>>
|
|
372
|
-
>>>
|
|
373
|
-
>>>
|
|
374
|
-
>>>
|
|
375
|
-
>>> output = reduce_scatter_tensor(input_tensor)
|
|
367
|
+
>>> comm.init()
|
|
368
|
+
>>> input_tensor = ms.Tensor(np.ones([8, 8]).astype(np.float32))
|
|
369
|
+
>>> output, _ = comm.comm_func.reduce_scatter_tensor(input_tensor)
|
|
376
370
|
>>> print(output)
|
|
377
371
|
[[2. 2. 2. 2. 2. 2. 2. 2.]
|
|
378
372
|
[2. 2. 2. 2. 2. 2. 2. 2.]
|
|
@@ -430,22 +424,20 @@ def reduce(tensor, dst, op=ReduceOp.SUM, group=GlobalComm.WORLD_COMM_GROUP):
|
|
|
430
424
|
without any third-party or configuration file dependencies.
|
|
431
425
|
|
|
432
426
|
Please see the `msrun start up
|
|
433
|
-
<https://www.mindspore.cn/docs/
|
|
427
|
+
<https://www.mindspore.cn/docs/en/master/model_train/parallel/msrun_launcher.html>`_
|
|
434
428
|
for more details.
|
|
435
429
|
|
|
436
430
|
This example should be run with 4 devices.
|
|
437
431
|
|
|
438
|
-
>>> from mindspore import ops
|
|
439
|
-
>>> import mindspore.nn as nn
|
|
440
|
-
>>> from mindspore.communication import init
|
|
441
|
-
>>> from mindspore.communication.comm_func import reduce
|
|
442
|
-
>>> from mindspore import Tensor
|
|
443
432
|
>>> import numpy as np
|
|
433
|
+
>>> import mindspore as ms
|
|
434
|
+
>>> import mindspore.communication as comm
|
|
435
|
+
>>>
|
|
444
436
|
>>> # Launch 4 processes.
|
|
445
|
-
>>> init()
|
|
437
|
+
>>> comm.init()
|
|
446
438
|
>>> dest_rank=1
|
|
447
|
-
>>> input_tensor = Tensor(np.ones([2, 8]).astype(np.float32))
|
|
448
|
-
>>> output = reduce(input_tensor)
|
|
439
|
+
>>> input_tensor = ms.Tensor(np.ones([2, 8]).astype(np.float32))
|
|
440
|
+
>>> output = comm.comm_func.reduce(input_tensor, dst=dest_rank)
|
|
449
441
|
>>> print(output)
|
|
450
442
|
Process with rank 1: [[4. 4. 4. 4. 4. 4. 4. 4.]
|
|
451
443
|
[4. 4. 4. 4. 4. 4. 4. 4.]],
|
|
@@ -494,27 +486,36 @@ class P2POp:
|
|
|
494
486
|
|
|
495
487
|
Examples:
|
|
496
488
|
>>> import numpy as np
|
|
497
|
-
>>> import mindspore
|
|
498
|
-
>>>
|
|
499
|
-
>>>
|
|
500
|
-
>>> send_tensor = Tensor(1.)
|
|
501
|
-
>>> send_op = P2POp('isend', send_tensor, 1)
|
|
502
|
-
>>> send_op = P2POp(isend, send_tensor, 1)
|
|
503
|
-
>>> recv_tensor = Tensor(0.)
|
|
504
|
-
>>> recv_op = P2POp('irecv', recv_tensor, 0)
|
|
505
|
-
>>> recv_op = P2POp(irecv, recv_tensor, 0)
|
|
506
|
-
>>> recv_op = P2POp('irecv', (), 0, recv_dtype=
|
|
489
|
+
>>> import mindspore as ms
|
|
490
|
+
>>> import mindspore.communication as comm
|
|
491
|
+
>>>
|
|
492
|
+
>>> send_tensor = ms.Tensor(1.)
|
|
493
|
+
>>> send_op = comm.comm_func.P2POp('isend', send_tensor, 1)
|
|
494
|
+
>>> send_op = comm.comm_func.P2POp(comm.comm_func.isend, send_tensor, 1)
|
|
495
|
+
>>> recv_tensor = ms.Tensor(0.)
|
|
496
|
+
>>> recv_op = comm.comm_func.P2POp('irecv', recv_tensor, 0)
|
|
497
|
+
>>> recv_op = comm.comm_func.P2POp(comm.comm_func.irecv, recv_tensor, 0)
|
|
498
|
+
>>> recv_op = comm.comm_func.P2POp('irecv', (), 0, recv_dtype=ms.float32)
|
|
507
499
|
"""
|
|
508
500
|
|
|
509
501
|
def __init__(self, op, tensor, peer, group=None, tag=0, *, recv_dtype=None):
|
|
510
502
|
self.op = op
|
|
511
503
|
self.tensor = tensor
|
|
504
|
+
if not isinstance(peer, int):
|
|
505
|
+
raise TypeError(f"peer must be type of int, but got type of {type(peer)}")
|
|
506
|
+
|
|
507
|
+
if recv_dtype and not isinstance(recv_dtype, Type):
|
|
508
|
+
raise TypeError(f"recv_dtype must be type of mindspore dtype, but got type of {type(recv_dtype)}")
|
|
509
|
+
|
|
512
510
|
self.peer = peer
|
|
513
511
|
self.group = group
|
|
514
512
|
self.tag = tag
|
|
515
513
|
self.recv_dtype = recv_dtype
|
|
516
514
|
|
|
517
515
|
def __new__(cls, op, tensor, peer, group=None, tag=0, recv_dtype=None):
|
|
516
|
+
if not (isinstance(op, str) or callable(op)):
|
|
517
|
+
raise TypeError(f"op must be type of string or function, but got type of {type(op)}")
|
|
518
|
+
|
|
518
519
|
if isinstance(op, str):
|
|
519
520
|
op_name = op
|
|
520
521
|
else:
|
|
@@ -560,31 +561,29 @@ def batch_isend_irecv(p2p_op_list):
|
|
|
560
561
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
561
562
|
without any third-party or configuration file dependencies.
|
|
562
563
|
Please see the `msrun start up
|
|
563
|
-
<https://www.mindspore.cn/docs/
|
|
564
|
+
<https://www.mindspore.cn/docs/en/master/model_train/parallel/msrun_launcher.html>`_
|
|
564
565
|
for more details.
|
|
565
566
|
|
|
566
567
|
This example should be run with 2 devices.
|
|
567
568
|
|
|
568
569
|
>>> import numpy as np
|
|
569
|
-
>>> import mindspore
|
|
570
|
-
>>>
|
|
571
|
-
>>> from mindspore.communication.comm_func import batch_isend_irecv, P2POp
|
|
572
|
-
>>> from mindspore import Tensor
|
|
570
|
+
>>> import mindspore as ms
|
|
571
|
+
>>> import mindspore.communication as comm
|
|
573
572
|
>>>
|
|
574
|
-
>>> init()
|
|
575
|
-
>>> this_rank = get_rank()
|
|
576
|
-
>>> world_size = get_group_size()
|
|
573
|
+
>>> comm.init()
|
|
574
|
+
>>> this_rank = comm.get_rank()
|
|
575
|
+
>>> world_size = comm.get_group_size()
|
|
577
576
|
>>> next_rank = (this_rank + 1) % world_size
|
|
578
577
|
>>> prev_rank = (this_rank + world_size - 1) % world_size
|
|
579
578
|
>>>
|
|
580
|
-
>>> send_tensor = Tensor(this_rank + 1, dtype=
|
|
581
|
-
>>> recv_tensor = Tensor(0., dtype=
|
|
579
|
+
>>> send_tensor = ms.Tensor(this_rank + 1, dtype=ms.float32)
|
|
580
|
+
>>> recv_tensor = ms.Tensor(0., dtype=ms.float32)
|
|
582
581
|
>>>
|
|
583
|
-
>>> send_op = P2POp('isend', send_tensor, next_rank)
|
|
584
|
-
>>> recv_op = P2POp('irecv', recv_tensor, prev_rank)
|
|
582
|
+
>>> send_op = comm.comm_func.P2POp('isend', send_tensor, next_rank)
|
|
583
|
+
>>> recv_op = comm.comm_func.P2POp('irecv', recv_tensor, prev_rank)
|
|
585
584
|
>>>
|
|
586
585
|
>>> p2p_op_list = [send_op, recv_op]
|
|
587
|
-
>>> output = batch_isend_irecv(p2p_op_list)
|
|
586
|
+
>>> output = comm.comm_func.batch_isend_irecv(p2p_op_list)
|
|
588
587
|
>>> print(output)
|
|
589
588
|
rank 0:
|
|
590
589
|
(Tensor(shape=[], dtype=Float32, value= 0), Tensor(shape=[], dtype=Float32, value= 2))
|
|
@@ -597,6 +596,10 @@ def batch_isend_irecv(p2p_op_list):
|
|
|
597
596
|
receive_shapes = []
|
|
598
597
|
receive_dtypes = []
|
|
599
598
|
tags = []
|
|
599
|
+
|
|
600
|
+
if not isinstance(p2p_op_list, list):
|
|
601
|
+
raise TypeError(f"p2p_op_list must be type of list, but got type of {p2p_op_list}.")
|
|
602
|
+
|
|
600
603
|
if not p2p_op_list:
|
|
601
604
|
raise TypeError(f"p2p_op_list can not be empty list.")
|
|
602
605
|
group = p2p_op_list[0].group
|
|
@@ -676,20 +679,20 @@ def scatter_tensor(tensor, src=0, group=GlobalComm.WORLD_COMM_GROUP):
|
|
|
676
679
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
677
680
|
without any third-party or configuration file dependencies.
|
|
678
681
|
Please see the `msrun start up
|
|
679
|
-
<https://www.mindspore.cn/docs/
|
|
682
|
+
<https://www.mindspore.cn/docs/en/master/model_train/parallel/msrun_launcher.html>`_
|
|
680
683
|
for more details.
|
|
681
684
|
|
|
682
685
|
This example should be run with 2 devices.
|
|
683
686
|
|
|
684
|
-
>>> import mindspore as ms
|
|
685
|
-
>>> from mindspore.communication import init
|
|
686
|
-
>>> from mindspore.communication.comm_func import scatter_tensor
|
|
687
687
|
>>> import numpy as np
|
|
688
|
+
>>> import mindspore as ms
|
|
689
|
+
>>> import mindspore.communication as comm
|
|
690
|
+
>>>
|
|
688
691
|
>>> # Launch 2 processes.
|
|
689
692
|
>>>
|
|
690
|
-
>>> init()
|
|
693
|
+
>>> comm.init()
|
|
691
694
|
>>> input = ms.Tensor(np.arange(8).reshape([4, 2]).astype(np.float32))
|
|
692
|
-
>>> out = scatter_tensor(tensor=
|
|
695
|
+
>>> out = comm.comm_func.scatter_tensor(tensor=input, src=0)
|
|
693
696
|
>>> print(out)
|
|
694
697
|
# rank_0
|
|
695
698
|
[[0. 1.]
|
|
@@ -741,22 +744,20 @@ def gather_into_tensor(tensor, dst=0, group=GlobalComm.WORLD_COMM_GROUP):
|
|
|
741
744
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
742
745
|
without any third-party or configuration file dependencies.
|
|
743
746
|
Please see the `msrun start up
|
|
744
|
-
<https://www.mindspore.cn/docs/
|
|
747
|
+
<https://www.mindspore.cn/docs/en/master/model_train/parallel/msrun_launcher.html>`_
|
|
745
748
|
for more details.
|
|
746
749
|
|
|
747
750
|
This example should be run with 2 devices.
|
|
748
751
|
|
|
749
752
|
>>> import numpy as np
|
|
750
753
|
>>> import mindspore as ms
|
|
751
|
-
>>> import mindspore.
|
|
752
|
-
>>>
|
|
753
|
-
>>> from mindspore import Tensor
|
|
754
|
-
>>> from mindspore.communication.comm_func import gather_into_tensor
|
|
754
|
+
>>> import mindspore.communication as comm
|
|
755
|
+
>>>
|
|
755
756
|
>>> # Launch 2 processes.
|
|
756
757
|
>>>
|
|
757
|
-
>>> init()
|
|
758
|
-
>>> input = Tensor(np.arange(4).reshape([2, 2]).astype(np.float32))
|
|
759
|
-
>>> output = gather_into_tensor(tensor=
|
|
758
|
+
>>> comm.init()
|
|
759
|
+
>>> input = ms.Tensor(np.arange(4).reshape([2, 2]).astype(np.float32))
|
|
760
|
+
>>> output = comm.comm_func.gather_into_tensor(tensor=input, dst=0)
|
|
760
761
|
>>> print(output)
|
|
761
762
|
Process with rank 0: [[0. 1.],
|
|
762
763
|
[2. 3.],
|
|
@@ -804,21 +805,20 @@ def broadcast(tensor, src=0, group=GlobalComm.WORLD_COMM_GROUP):
|
|
|
804
805
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
805
806
|
without any third-party or configuration file dependencies.
|
|
806
807
|
Please see the `msrun start up
|
|
807
|
-
<https://www.mindspore.cn/docs/
|
|
808
|
+
<https://www.mindspore.cn/docs/en/master/model_train/parallel/msrun_launcher.html>`_
|
|
808
809
|
for more details.
|
|
809
810
|
|
|
810
811
|
This example should be run with 2 devices.
|
|
811
812
|
|
|
812
|
-
>>> import mindspore as ms
|
|
813
|
-
>>> from mindspore import Tensor
|
|
814
|
-
>>> from mindspore.communication import init
|
|
815
|
-
>>> from mindspore.communication.comm_func import broadcast
|
|
816
813
|
>>> import numpy as np
|
|
814
|
+
>>> import mindspore as ms
|
|
815
|
+
>>> import mindspore.communication as comm
|
|
816
|
+
>>>
|
|
817
817
|
>>> # Launch 2 processes.
|
|
818
818
|
>>>
|
|
819
|
-
>>> init()
|
|
819
|
+
>>> comm.init()
|
|
820
820
|
>>> data = ms.Tensor(np.arange(8).reshape([2, 4]).astype(np.float32))
|
|
821
|
-
>>> out = broadcast(tensor=data, src=0)
|
|
821
|
+
>>> out = comm.comm_func.broadcast(tensor=data, src=0)
|
|
822
822
|
[[0. 1. 2. 3.]
|
|
823
823
|
[4. 5. 6. 7.]]
|
|
824
824
|
|
|
@@ -858,29 +858,37 @@ def barrier(group=GlobalComm.WORLD_COMM_GROUP):
|
|
|
858
858
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
859
859
|
without any third-party or configuration file dependencies.
|
|
860
860
|
Please see the `msrun start up
|
|
861
|
-
<https://www.mindspore.cn/docs/
|
|
861
|
+
<https://www.mindspore.cn/docs/en/master/model_train/parallel/msrun_launcher.html>`_
|
|
862
862
|
for more details.
|
|
863
863
|
|
|
864
864
|
This example should be run with 2 devices.
|
|
865
865
|
|
|
866
|
-
>>>
|
|
867
|
-
>>>
|
|
866
|
+
>>> import mindspore as ms
|
|
867
|
+
>>> import mindspore.communication as comm
|
|
868
|
+
>>>
|
|
868
869
|
>>> # Launch 2 processes.
|
|
869
|
-
>>> init()
|
|
870
|
-
>>> barrier()
|
|
870
|
+
>>> comm.init()
|
|
871
|
+
>>> comm.comm_func.barrier()
|
|
871
872
|
|
|
872
873
|
Tutorial Examples:
|
|
873
874
|
- `Distributed Set Communication Primitives - Barrier
|
|
874
875
|
<https://www.mindspore.cn/docs/en/master/api_python/samples/ops/communicate_ops.html#barrier>`_
|
|
875
876
|
"""
|
|
877
|
+
if not isinstance(group, str):
|
|
878
|
+
raise TypeError(f"group must be type of string, but got {type(group)}")
|
|
876
879
|
_op = _get_cache_prim(P.Barrier)(group)
|
|
877
880
|
return _op()
|
|
878
881
|
|
|
879
882
|
|
|
880
|
-
def _deal_comm_outputs(output, async_op):
|
|
883
|
+
def _deal_comm_outputs(output, async_op, exec_sync=False):
|
|
884
|
+
"""
|
|
885
|
+
deal with comm ops outputs.
|
|
886
|
+
"""
|
|
881
887
|
if isinstance(output, tuple):
|
|
882
888
|
if not async_op:
|
|
883
889
|
output[1].wait()
|
|
890
|
+
if exec_sync:
|
|
891
|
+
_pynative_executor.sync()
|
|
884
892
|
return (output[0], None)
|
|
885
893
|
return output
|
|
886
894
|
|
|
@@ -918,21 +926,34 @@ def send(tensor, dst=0, group=GlobalComm.WORLD_COMM_GROUP, tag=0):
|
|
|
918
926
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
919
927
|
without any third-party or configuration file dependencies.
|
|
920
928
|
Please see the `msrun start up
|
|
921
|
-
<https://www.mindspore.cn/docs/
|
|
929
|
+
<https://www.mindspore.cn/docs/en/master/model_train/parallel/msrun_launcher.html>`_
|
|
922
930
|
for more details.
|
|
923
931
|
|
|
924
932
|
This example should be run with 2 devices.
|
|
925
933
|
|
|
926
|
-
>>> from mindspore import ops
|
|
927
|
-
>>> import mindspore.nn as nn
|
|
928
|
-
>>> from mindspore.communication import init
|
|
929
|
-
>>> from mindspore.communication.comm_func import send
|
|
930
|
-
>>> from mindspore import Tensor
|
|
931
934
|
>>> import numpy as np
|
|
935
|
+
>>> import mindspore as ms
|
|
936
|
+
>>> from mindspore.communication import init
|
|
937
|
+
>>> from mindspore.communication.comm_func import send, recv
|
|
938
|
+
>>> from mindspore.communication import get_rank, get_group_size
|
|
932
939
|
>>>
|
|
940
|
+
>>> np.random.seed(1)
|
|
933
941
|
>>> init()
|
|
934
|
-
>>>
|
|
935
|
-
>>>
|
|
942
|
+
>>> rank = get_rank()
|
|
943
|
+
>>> size = get_group_size()
|
|
944
|
+
>>> x = np.ones([2, 2]).astype(np.float32) * 0.01 * (rank + 1)
|
|
945
|
+
>>> x2 = np.ones([2, 2]).astype(np.float32)
|
|
946
|
+
>>>
|
|
947
|
+
>>>
|
|
948
|
+
>>> if rank < size / 2:
|
|
949
|
+
>>> _x = ms.Tensor(x)
|
|
950
|
+
>>> send(_x, rank + size // 2)
|
|
951
|
+
>>> else:
|
|
952
|
+
>>> _x2 = ms.Tensor(x2)
|
|
953
|
+
>>> output = recv(_x2, rank - size // 2)
|
|
954
|
+
>>> print(output)
|
|
955
|
+
[[0.01 0.01]
|
|
956
|
+
[0.01 0.01]]
|
|
936
957
|
"""
|
|
937
958
|
if not isinstance(tensor, (Tensor, Tensor_)):
|
|
938
959
|
raise TypeError("For send, the input tensor must be tensor")
|
|
@@ -979,29 +1000,34 @@ def recv(tensor, src=0, group=GlobalComm.WORLD_COMM_GROUP, tag=0):
|
|
|
979
1000
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
980
1001
|
without any third-party or configuration file dependencies.
|
|
981
1002
|
Please see the `msrun start up
|
|
982
|
-
<https://www.mindspore.cn/docs/
|
|
1003
|
+
<https://www.mindspore.cn/docs/en/master/model_train/parallel/msrun_launcher.html>`_
|
|
983
1004
|
for more details.
|
|
984
1005
|
|
|
985
1006
|
This example should be run with 2 devices.
|
|
986
1007
|
|
|
987
|
-
>>> from mindspore import ops
|
|
988
|
-
>>> import mindspore.nn as nn
|
|
989
|
-
>>> from mindspore.communication import init
|
|
990
|
-
>>> from mindspore.communication.comm_func import recv
|
|
991
|
-
>>> from mindspore import Tensor
|
|
992
1008
|
>>> import numpy as np
|
|
1009
|
+
>>> import mindspore as ms
|
|
1010
|
+
>>> from mindspore.communication import init
|
|
1011
|
+
>>> from mindspore.communication.comm_func import send, recv
|
|
1012
|
+
>>> from mindspore.communication import get_rank, get_group_size
|
|
993
1013
|
>>>
|
|
994
|
-
|
|
995
|
-
Process 0 send the following array to Process 1
|
|
996
|
-
[[ 0. 1.]
|
|
997
|
-
[ 2. 3.]]
|
|
1014
|
+
>>> np.random.seed(1)
|
|
998
1015
|
>>> init()
|
|
999
|
-
>>>
|
|
1000
|
-
|
|
1001
|
-
>>>
|
|
1002
|
-
>>>
|
|
1003
|
-
|
|
1004
|
-
|
|
1016
|
+
>>> rank = get_rank()
|
|
1017
|
+
>>> size = get_group_size()
|
|
1018
|
+
>>> x = np.ones([2, 2]).astype(np.float32) * 0.01 * (rank + 1)
|
|
1019
|
+
>>> x2 = np.ones([2, 2]).astype(np.float32)
|
|
1020
|
+
>>>
|
|
1021
|
+
>>>
|
|
1022
|
+
>>> if rank < size / 2:
|
|
1023
|
+
>>> _x = ms.Tensor(x)
|
|
1024
|
+
>>> send(_x, rank + size // 2)
|
|
1025
|
+
>>> else:
|
|
1026
|
+
>>> _x2 = ms.Tensor(x2)
|
|
1027
|
+
>>> output = recv(_x2, rank - size // 2)
|
|
1028
|
+
>>> print(output)
|
|
1029
|
+
[[0.01 0.01]
|
|
1030
|
+
[0.01 0.01]]
|
|
1005
1031
|
"""
|
|
1006
1032
|
if not isinstance(tensor, (Tensor, Tensor_)):
|
|
1007
1033
|
raise TypeError("For recv, the input tensor must be tensor")
|
|
@@ -1049,22 +1075,35 @@ def isend(tensor, dst=0, group=GlobalComm.WORLD_COMM_GROUP, tag=0):
|
|
|
1049
1075
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
1050
1076
|
without any third-party or configuration file dependencies.
|
|
1051
1077
|
Please see the `msrun start up
|
|
1052
|
-
<https://www.mindspore.cn/docs/
|
|
1078
|
+
<https://www.mindspore.cn/docs/en/master/model_train/parallel/msrun_launcher.html>`_
|
|
1053
1079
|
for more details.
|
|
1054
1080
|
|
|
1055
1081
|
This example should be run with 2 devices.
|
|
1056
1082
|
|
|
1057
|
-
>>> from mindspore import ops
|
|
1058
|
-
>>> import mindspore.nn as nn
|
|
1059
|
-
>>> from mindspore.communication import init
|
|
1060
|
-
>>> from mindspore.communication.comm_func import isend
|
|
1061
|
-
>>> from mindspore import Tensor
|
|
1062
1083
|
>>> import numpy as np
|
|
1084
|
+
>>> import mindspore as ms
|
|
1085
|
+
>>> from mindspore.communication import init
|
|
1086
|
+
>>> from mindspore.communication.comm_func import isend, irecv
|
|
1087
|
+
>>> from mindspore.communication import get_rank, get_group_size
|
|
1063
1088
|
>>>
|
|
1089
|
+
>>> np.random.seed(1)
|
|
1064
1090
|
>>> init()
|
|
1065
|
-
>>>
|
|
1066
|
-
>>>
|
|
1067
|
-
>>>
|
|
1091
|
+
>>> rank = get_rank()
|
|
1092
|
+
>>> size = get_group_size()
|
|
1093
|
+
>>> x = np.ones([2, 2]).astype(np.float32) * 0.01 * (rank + 1)
|
|
1094
|
+
>>> x2 = np.ones([2, 2]).astype(np.float32)
|
|
1095
|
+
>>>
|
|
1096
|
+
>>>
|
|
1097
|
+
>>> if rank < size / 2:
|
|
1098
|
+
>>> _x = ms.Tensor(x)
|
|
1099
|
+
>>> isend(_x, rank + size // 2)
|
|
1100
|
+
>>> else:
|
|
1101
|
+
>>> _x2 = ms.Tensor(x2)
|
|
1102
|
+
>>> output, handle = irecv(_x2, rank - size // 2)
|
|
1103
|
+
>>> handle.wait()
|
|
1104
|
+
>>> print(output)
|
|
1105
|
+
[[0.01 0.01]
|
|
1106
|
+
[0.01 0.01]]
|
|
1068
1107
|
"""
|
|
1069
1108
|
if not isinstance(tensor, (Tensor, Tensor_)):
|
|
1070
1109
|
raise TypeError("For isend, the input tensor must be tensor")
|
|
@@ -1114,30 +1153,35 @@ def irecv(tensor, src=0, group=GlobalComm.WORLD_COMM_GROUP, tag=0):
|
|
|
1114
1153
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
1115
1154
|
without any third-party or configuration file dependencies.
|
|
1116
1155
|
Please see the `msrun start up
|
|
1117
|
-
<https://www.mindspore.cn/docs/
|
|
1156
|
+
<https://www.mindspore.cn/docs/en/master/model_train/parallel/msrun_launcher.html>`_
|
|
1118
1157
|
for more details.
|
|
1119
1158
|
|
|
1120
1159
|
This example should be run with 2 devices.
|
|
1121
1160
|
|
|
1122
|
-
>>> from mindspore import ops
|
|
1123
|
-
>>> import mindspore.nn as nn
|
|
1124
|
-
>>> from mindspore.communication import init
|
|
1125
|
-
>>> from mindspore.communication.comm_func import irecv
|
|
1126
|
-
>>> from mindspore import Tensor
|
|
1127
1161
|
>>> import numpy as np
|
|
1162
|
+
>>> import mindspore as ms
|
|
1163
|
+
>>> from mindspore.communication import init
|
|
1164
|
+
>>> from mindspore.communication.comm_func import isend, irecv
|
|
1165
|
+
>>> from mindspore.communication import get_rank, get_group_size
|
|
1128
1166
|
>>>
|
|
1129
|
-
|
|
1130
|
-
Process 0 send the following array to Process 1
|
|
1131
|
-
[[ 0. 1.]
|
|
1132
|
-
[ 2. 3.]]
|
|
1167
|
+
>>> np.random.seed(1)
|
|
1133
1168
|
>>> init()
|
|
1134
|
-
>>>
|
|
1135
|
-
|
|
1136
|
-
>>>
|
|
1137
|
-
>>>
|
|
1138
|
-
>>>
|
|
1139
|
-
|
|
1140
|
-
|
|
1169
|
+
>>> rank = get_rank()
|
|
1170
|
+
>>> size = get_group_size()
|
|
1171
|
+
>>> x = np.ones([2, 2]).astype(np.float32) * 0.01 * (rank + 1)
|
|
1172
|
+
>>> x2 = np.ones([2, 2]).astype(np.float32)
|
|
1173
|
+
>>>
|
|
1174
|
+
>>>
|
|
1175
|
+
>>> if rank < size / 2:
|
|
1176
|
+
>>> _x = ms.Tensor(x)
|
|
1177
|
+
>>> isend(_x, rank + size // 2)
|
|
1178
|
+
>>> else:
|
|
1179
|
+
>>> _x2 = ms.Tensor(x2)
|
|
1180
|
+
>>> output, handle = irecv(_x2, rank - size // 2)
|
|
1181
|
+
>>> handle.wait()
|
|
1182
|
+
>>> print(output)
|
|
1183
|
+
[[0.01 0.01]
|
|
1184
|
+
[0.01 0.01]]
|
|
1141
1185
|
"""
|
|
1142
1186
|
group = _get_group(group)
|
|
1143
1187
|
_src = _get_group_rank_from_world_rank_from_cache_helper(src, group)
|
|
@@ -1185,27 +1229,24 @@ def all_to_all_with_output_shape(output_shape_list, input_tensor_list, group=Non
|
|
|
1185
1229
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
1186
1230
|
without any third-party or configuration file dependencies.
|
|
1187
1231
|
Please see the `msrun start up
|
|
1188
|
-
<https://www.mindspore.cn/docs/
|
|
1232
|
+
<https://www.mindspore.cn/docs/en/master/model_train/parallel/msrun_launcher.html>`_
|
|
1189
1233
|
for more details.
|
|
1190
1234
|
|
|
1191
1235
|
This example should be run with 2 devices.
|
|
1192
1236
|
|
|
1193
1237
|
>>> import numpy as np
|
|
1194
|
-
>>> import mindspore
|
|
1195
|
-
>>>
|
|
1196
|
-
>>> from mindspore.communication.comm_func import all_to_all_with_output_shape
|
|
1197
|
-
>>> from mindspore import Tensor
|
|
1198
|
-
>>> from mindspore.ops import zeros
|
|
1238
|
+
>>> import mindspore as ms
|
|
1239
|
+
>>> import mindspore.communication as comm
|
|
1199
1240
|
>>>
|
|
1200
|
-
>>> init()
|
|
1201
|
-
>>> this_rank = get_rank()
|
|
1241
|
+
>>> comm.init()
|
|
1242
|
+
>>> this_rank = comm.get_rank()
|
|
1202
1243
|
>>> if this_rank == 0:
|
|
1203
|
-
>>> send_tensor_list = [Tensor(1.), Tensor([[2, 3], [4, 5.]])]
|
|
1244
|
+
>>> send_tensor_list = [ms.Tensor(1.), ms.Tensor([[2, 3], [4, 5.]])]
|
|
1204
1245
|
>>> recv_tensor_list = [(), (2,)]
|
|
1205
1246
|
>>> if this_rank == 1:
|
|
1206
|
-
>>> send_tensor_list = [Tensor([2, 2.]), Tensor([4, 5, 6, 7.])]
|
|
1247
|
+
>>> send_tensor_list = [ms.Tensor([2, 2.]), ms.Tensor([4, 5, 6, 7.])]
|
|
1207
1248
|
>>> recv_tensor_list = [(2, 2), (4,)]
|
|
1208
|
-
>>> output = all_to_all_with_output_shape(recv_tensor_list, send_tensor_list)
|
|
1249
|
+
>>> output, _ = comm.comm_func.all_to_all_with_output_shape(recv_tensor_list, send_tensor_list)
|
|
1209
1250
|
>>> print(output)
|
|
1210
1251
|
rank 0:
|
|
1211
1252
|
(Tensor(shape=[], dtype=Float32, value= 1),
|
|
@@ -1256,17 +1297,17 @@ def all_to_all_with_output_shape(output_shape_list, input_tensor_list, group=Non
|
|
|
1256
1297
|
return (tuple(result), handle)
|
|
1257
1298
|
|
|
1258
1299
|
|
|
1259
|
-
def _get_all_to_all_single_numel_list(
|
|
1300
|
+
def _get_all_to_all_single_numel_list(tensor_shape, output_shape, output_split_sizes, input_split_sizes, group):
|
|
1260
1301
|
"""get numel list for all_to_all_single."""
|
|
1261
1302
|
global _GROPU_SIZE_CACHE
|
|
1262
1303
|
if _is_split_sizes_empty(input_split_sizes):
|
|
1263
1304
|
if group not in _GROPU_SIZE_CACHE:
|
|
1264
1305
|
_GROPU_SIZE_CACHE[group] = get_group_size(group)
|
|
1265
1306
|
_world_size = _GROPU_SIZE_CACHE[group]
|
|
1266
|
-
if
|
|
1307
|
+
if tensor_shape[0] % _world_size != 0:
|
|
1267
1308
|
raise ValueError("input shape at dim 0 must be divided by world_size, "
|
|
1268
|
-
f"but got {
|
|
1269
|
-
_split_size =
|
|
1309
|
+
f"but got {tensor_shape[0]} and {_world_size}.")
|
|
1310
|
+
_split_size = tensor_shape[0] // _world_size
|
|
1270
1311
|
input_split_sizes = (_split_size,) * _world_size
|
|
1271
1312
|
if _is_split_sizes_empty(output_split_sizes):
|
|
1272
1313
|
if group not in _GROPU_SIZE_CACHE:
|
|
@@ -1283,7 +1324,7 @@ def _get_all_to_all_single_numel_list(tensor, output_shape, output_split_sizes,
|
|
|
1283
1324
|
_split_size = shape_dim_0 // _world_size
|
|
1284
1325
|
output_split_sizes = (_split_size,) * _world_size
|
|
1285
1326
|
|
|
1286
|
-
send_size_without_first_dim = _get_size(
|
|
1327
|
+
send_size_without_first_dim = _get_size(tensor_shape[1:])
|
|
1287
1328
|
send_numel_list = [size * send_size_without_first_dim for size in input_split_sizes]
|
|
1288
1329
|
|
|
1289
1330
|
recv_size_without_first_dim = None
|
|
@@ -1298,6 +1339,9 @@ def _get_all_to_all_single_numel_list(tensor, output_shape, output_split_sizes,
|
|
|
1298
1339
|
return send_numel_list, recv_numel_list, recv_shape_without_first_dim
|
|
1299
1340
|
|
|
1300
1341
|
|
|
1342
|
+
_ALL_TO_ALL_CACHE = {}
|
|
1343
|
+
|
|
1344
|
+
|
|
1301
1345
|
def all_to_all_single_with_output_shape(output_shape, tensor, output_split_sizes=None,
|
|
1302
1346
|
input_split_sizes=None, group=None, async_op=False):
|
|
1303
1347
|
"""
|
|
@@ -1339,36 +1383,25 @@ def all_to_all_single_with_output_shape(output_shape, tensor, output_split_sizes
|
|
|
1339
1383
|
For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
|
|
1340
1384
|
without any third-party or configuration file dependencies.
|
|
1341
1385
|
Please see the `msrun start up
|
|
1342
|
-
<https://www.mindspore.cn/docs/
|
|
1386
|
+
<https://www.mindspore.cn/docs/en/master/model_train/parallel/msrun_launcher.html>`_
|
|
1343
1387
|
for more details.
|
|
1344
1388
|
|
|
1345
1389
|
This example should be run with 2 devices.
|
|
1346
1390
|
|
|
1347
1391
|
>>> import numpy as np
|
|
1348
|
-
>>> import mindspore
|
|
1349
|
-
>>>
|
|
1350
|
-
>>> from mindspore.communication.comm_func import all_to_all_single_with_output_shape
|
|
1351
|
-
>>> from mindspore import Tensor
|
|
1352
|
-
>>> from mindspore.ops import zeros
|
|
1392
|
+
>>> import mindspore as ms
|
|
1393
|
+
>>> import mindspore.communication as comm
|
|
1353
1394
|
>>>
|
|
1354
|
-
>>> init()
|
|
1355
|
-
>>>
|
|
1356
|
-
>>>
|
|
1357
|
-
>>>
|
|
1358
|
-
>>>
|
|
1359
|
-
>>> result = all_to_all_single_with_output_shape(output_shape, tensor, [2, 1], [2, 1])
|
|
1360
|
-
>>> if this_rank == 1:
|
|
1361
|
-
>>> output_shape = (2, 3)
|
|
1362
|
-
>>> tensor = Tensor([[9, 10., 11], [12, 13, 14]])
|
|
1363
|
-
>>> result = all_to_all_single_with_output_shape(output_shape, tensor)
|
|
1395
|
+
>>> comm.init()
|
|
1396
|
+
>>> rank = comm.get_rank()
|
|
1397
|
+
>>> input = ms.Tensor([0, 1]) + rank * 2
|
|
1398
|
+
>>> output_shape = (2,)
|
|
1399
|
+
>>> result, _ = comm.comm_func.all_to_all_single_with_output_shape(output_shape, input)
|
|
1364
1400
|
>>> print(result)
|
|
1365
1401
|
rank 0:
|
|
1366
|
-
[
|
|
1367
|
-
[ 3. 4. 5.]
|
|
1368
|
-
[ 9. 10. 11.]]
|
|
1402
|
+
[ 0. 2.]
|
|
1369
1403
|
rank 1:
|
|
1370
|
-
[
|
|
1371
|
-
[12. 13. 14.]]
|
|
1404
|
+
[ 1. 3.]
|
|
1372
1405
|
|
|
1373
1406
|
"""
|
|
1374
1407
|
|
|
@@ -1378,8 +1411,17 @@ def all_to_all_single_with_output_shape(output_shape, tensor, output_split_sizes
|
|
|
1378
1411
|
group = GlobalComm.WORLD_COMM_GROUP
|
|
1379
1412
|
|
|
1380
1413
|
split_sizes_empty = _is_split_sizes_empty(output_split_sizes) and _is_split_sizes_empty(input_split_sizes)
|
|
1381
|
-
|
|
1382
|
-
|
|
1414
|
+
if isinstance(output_split_sizes, list):
|
|
1415
|
+
output_split_sizes = tuple(output_split_sizes)
|
|
1416
|
+
if isinstance(input_split_sizes, list):
|
|
1417
|
+
input_split_sizes = tuple(input_split_sizes)
|
|
1418
|
+
global _ALL_TO_ALL_CACHE
|
|
1419
|
+
tensor_shape = output_shape
|
|
1420
|
+
cache_key = (tensor_shape, output_shape, output_split_sizes, input_split_sizes, group)
|
|
1421
|
+
if cache_key not in _ALL_TO_ALL_CACHE:
|
|
1422
|
+
_ALL_TO_ALL_CACHE[cache_key] = _get_all_to_all_single_numel_list(*cache_key)
|
|
1423
|
+
send_numel_list, recv_numel_list, recv_shape_without_first_dim = _ALL_TO_ALL_CACHE[cache_key]
|
|
1424
|
+
|
|
1383
1425
|
tensor = _contiguous(tensor)
|
|
1384
1426
|
_input = tensor.reshape(-1)
|
|
1385
1427
|
group = GlobalComm.WORLD_COMM_GROUP if group is None else _get_group(group)
|