mindspore 2.6.0__cp310-cp310-win_amd64.whl → 2.7.0__cp310-cp310-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mindspore might be problematic. Click here for more details.
- mindspore/.commit_id +1 -1
- mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
- mindspore/Newtonsoft.Json.dll +0 -0
- mindspore/__init__.py +2 -2
- mindspore/_c_dataengine.cp310-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp310-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp310-win_amd64.pyd +0 -0
- mindspore/_checkparam.py +42 -11
- mindspore/_extends/builtin_operations.py +3 -3
- mindspore/{_deprecated → _extends/optimize}/__init__.py +9 -3
- mindspore/_extends/optimize/cell_utils.py +96 -0
- mindspore/_extends/parallel_compile/akg_compiler/custom.py +1109 -0
- mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
- mindspore/_extends/parse/__init__.py +3 -3
- mindspore/_extends/parse/compile_config.py +44 -22
- mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +1 -2
- mindspore/_extends/parse/parser.py +64 -83
- mindspore/_extends/parse/resources.py +39 -0
- mindspore/_extends/parse/standard_method.py +47 -14
- mindspore/_extends/parse/trope.py +8 -1
- mindspore/_extends/pijit/__init__.py +1 -2
- mindspore/_extends/pijit/pijit_func_white_list.py +2 -5
- mindspore/amp.py +4 -22
- 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/adasum.py +1 -1
- mindspore/boost/boost_cell_wrapper.py +4 -4
- mindspore/c1.dll +0 -0
- mindspore/c1xx.dll +0 -0
- mindspore/c2.dll +0 -0
- mindspore/common/__init__.py +43 -12
- mindspore/common/_grad_function.py +2 -1
- mindspore/common/_pijit_context.py +28 -7
- mindspore/common/_stub_tensor.py +1 -209
- mindspore/common/_tensor_cpp_method.py +1 -1
- mindspore/common/_tensor_docs.py +177 -52
- mindspore/common/_utils.py +9 -1
- mindspore/common/api.py +338 -208
- mindspore/common/dtype.py +108 -57
- mindspore/common/dump.py +11 -16
- mindspore/common/dynamic_shape/__init__.py +0 -0
- mindspore/common/{auto_dynamic_shape.py → dynamic_shape/auto_dynamic_shape.py} +17 -23
- mindspore/common/dynamic_shape/enable_dynamic.py +197 -0
- mindspore/common/file_system.py +59 -9
- mindspore/common/generator.py +2 -3
- mindspore/common/hook_handle.py +33 -5
- mindspore/common/jit_config.py +1 -1
- mindspore/common/jit_trace.py +84 -105
- mindspore/common/np_dtype.py +3 -3
- mindspore/common/parameter.py +27 -29
- mindspore/common/recompute.py +5 -7
- mindspore/common/sparse_tensor.py +0 -3
- mindspore/common/symbol.py +0 -1
- mindspore/common/tensor.py +84 -133
- mindspore/communication/_comm_helper.py +46 -4
- mindspore/communication/management.py +79 -7
- mindspore/context.py +47 -38
- mindspore/dataset/__init__.py +1 -1
- mindspore/dataset/audio/transforms.py +1 -1
- mindspore/dataset/core/config.py +38 -4
- mindspore/dataset/engine/datasets.py +350 -322
- mindspore/dataset/engine/datasets_user_defined.py +69 -23
- mindspore/dataset/engine/iterators.py +2 -2
- mindspore/dataset/engine/obs/config_loader.py +2 -2
- mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +8 -0
- mindspore/dataset/transforms/c_transforms.py +2 -2
- mindspore/dataset/transforms/py_transforms.py +7 -3
- mindspore/dataset/transforms/transforms.py +10 -6
- mindspore/dataset/vision/__init__.py +1 -1
- mindspore/dataset/vision/py_transforms.py +8 -8
- mindspore/dataset/vision/transforms.py +17 -5
- mindspore/dataset/vision/utils.py +632 -21
- mindspore/dataset/vision/validators.py +1 -0
- mindspore/device_context/ascend/device.py +1 -1
- mindspore/device_context/ascend/op_tuning.py +35 -1
- mindspore/device_context/gpu/__init__.py +2 -2
- mindspore/device_context/gpu/device.py +1 -1
- mindspore/device_context/gpu/op_precision.py +4 -2
- mindspore/device_context/gpu/op_tuning.py +6 -3
- mindspore/device_manager.py +16 -9
- mindspore/dnnl.dll +0 -0
- mindspore/dpcmi.dll +0 -0
- mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +5 -4
- mindspore/experimental/llm_boost/atb/boost_base.py +2 -3
- mindspore/experimental/optim/adadelta.py +13 -20
- mindspore/experimental/optim/adagrad.py +15 -22
- mindspore/experimental/optim/adam.py +17 -24
- mindspore/experimental/optim/adamax.py +14 -22
- mindspore/experimental/optim/adamw.py +28 -34
- mindspore/experimental/optim/asgd.py +15 -25
- mindspore/experimental/optim/lr_scheduler.py +27 -45
- mindspore/experimental/optim/nadam.py +14 -24
- mindspore/experimental/optim/optimizer.py +13 -23
- mindspore/experimental/optim/radam.py +18 -24
- mindspore/experimental/optim/rmsprop.py +14 -25
- mindspore/experimental/optim/rprop.py +15 -26
- mindspore/experimental/optim/sgd.py +9 -19
- mindspore/hal/__init__.py +4 -4
- mindspore/hal/contiguous_tensors_handle.py +2 -2
- mindspore/hal/memory.py +1 -0
- mindspore/include/api/cell.h +65 -5
- mindspore/include/api/cfg.h +24 -7
- mindspore/include/api/context.h +1 -0
- mindspore/include/api/delegate.h +10 -2
- mindspore/include/api/dual_abi_helper.h +100 -19
- mindspore/include/api/graph.h +14 -1
- mindspore/include/api/kernel.h +16 -3
- mindspore/include/api/kernel_api.h +9 -1
- mindspore/include/api/metrics/accuracy.h +9 -0
- mindspore/include/api/model.h +8 -1
- mindspore/include/api/model_group.h +4 -0
- mindspore/include/api/model_parallel_runner.h +2 -0
- mindspore/include/api/status.h +48 -10
- mindspore/include/api/types.h +8 -3
- mindspore/include/c_api/model_c.h +0 -58
- mindspore/include/c_api/tensor_c.h +0 -26
- mindspore/include/dataset/constants.h +9 -0
- mindspore/include/dataset/vision_ascend.h +1 -1
- mindspore/jpeg62.dll +0 -0
- mindspore/mindrecord/tools/cifar10.py +61 -11
- mindspore/mindrecord/tools/cifar10_to_mr.py +5 -0
- mindspore/mindspore_backend_common.dll +0 -0
- mindspore/mindspore_backend_manager.dll +0 -0
- mindspore/mindspore_common.dll +0 -0
- mindspore/mindspore_core.dll +0 -0
- mindspore/mindspore_cpu_res_manager.dll +0 -0
- mindspore/mindspore_dump.dll +0 -0
- mindspore/mindspore_frontend.dll +0 -0
- mindspore/mindspore_glog.dll +0 -0
- mindspore/mindspore_memory_pool.dll +0 -0
- mindspore/mindspore_ms_backend.dll +0 -0
- mindspore/mindspore_ops.dll +0 -0
- mindspore/mindspore_ops_host.dll +0 -0
- mindspore/mindspore_ops_kernel_common.dll +0 -0
- mindspore/mindspore_profiler.dll +0 -0
- mindspore/mindspore_pyboost.dll +0 -0
- mindspore/mindspore_pynative.dll +0 -0
- mindspore/mindspore_res_manager.dll +0 -0
- mindspore/mindspore_runtime_pipeline.dll +0 -0
- mindspore/mint/__init__.py +4 -44
- mindspore/mint/distributed/__init__.py +5 -0
- mindspore/mint/distributed/distributed.py +425 -19
- mindspore/mint/nn/__init__.py +1 -1
- mindspore/mint/nn/functional.py +53 -6
- mindspore/mint/nn/layer/_functions.py +163 -294
- mindspore/mint/nn/layer/activation.py +8 -6
- mindspore/mint/nn/layer/conv.py +125 -101
- mindspore/mint/nn/layer/normalization.py +11 -25
- mindspore/mint/optim/adam.py +19 -18
- mindspore/mint/optim/adamw.py +14 -8
- mindspore/mint/optim/sgd.py +5 -5
- 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/nn/cell.py +488 -620
- mindspore/nn/grad/cell_grad.py +11 -12
- mindspore/nn/layer/activation.py +36 -36
- mindspore/nn/layer/basic.py +74 -77
- mindspore/nn/layer/channel_shuffle.py +4 -4
- mindspore/nn/layer/combined.py +4 -2
- mindspore/nn/layer/conv.py +86 -85
- mindspore/nn/layer/dense.py +9 -7
- mindspore/nn/layer/embedding.py +50 -52
- mindspore/nn/layer/image.py +38 -40
- mindspore/nn/layer/math.py +111 -112
- mindspore/nn/layer/normalization.py +56 -44
- mindspore/nn/layer/pooling.py +58 -63
- mindspore/nn/layer/rnn_cells.py +33 -33
- mindspore/nn/layer/rnns.py +56 -56
- mindspore/nn/layer/thor_layer.py +74 -73
- mindspore/nn/layer/transformer.py +11 -1
- mindspore/nn/learning_rate_schedule.py +20 -20
- mindspore/nn/loss/loss.py +79 -81
- mindspore/nn/optim/adam.py +2 -4
- mindspore/nn/optim/adasum.py +2 -2
- mindspore/nn/optim/lamb.py +1 -3
- mindspore/nn/optim/optimizer.py +1 -1
- mindspore/nn/optim/tft_wrapper.py +2 -3
- mindspore/nn/optim/thor.py +2 -2
- mindspore/nn/probability/distribution/_utils/utils.py +2 -2
- mindspore/nn/probability/distribution/exponential.py +2 -1
- mindspore/nn/probability/distribution/poisson.py +2 -1
- mindspore/nn/sparse/sparse.py +3 -3
- mindspore/nn/wrap/cell_wrapper.py +73 -42
- mindspore/nn/wrap/grad_reducer.py +37 -52
- mindspore/nn/wrap/loss_scale.py +72 -74
- mindspore/numpy/array_creations.py +7 -7
- mindspore/numpy/fft.py +1 -1
- mindspore/numpy/math_ops.py +1 -1
- mindspore/numpy/utils_const.py +1 -1
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/opencv_imgproc452.dll +0 -0
- mindspore/ops/_grad_experimental/grad_comm_ops.py +51 -13
- mindspore/ops/_grad_experimental/grad_debug_ops.py +14 -0
- mindspore/ops/_grad_experimental/grad_inner_ops.py +0 -9
- mindspore/ops/_op_impl/cpu/__init__.py +1 -0
- mindspore/{experimental/es/__init__.py → ops/_op_impl/cpu/joinedstr_op.py} +12 -6
- mindspore/ops/_vmap/vmap_array_ops.py +6 -13
- mindspore/ops/_vmap/vmap_nn_ops.py +8 -16
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +29 -10
- mindspore/ops/auto_generate/gen_extend_func.py +5 -55
- mindspore/ops/auto_generate/gen_ops_def.py +753 -273
- mindspore/ops/auto_generate/gen_ops_prim.py +1687 -958
- mindspore/ops/auto_generate/pyboost_inner_prim.py +31 -1
- mindspore/ops/composite/__init__.py +10 -0
- mindspore/ops/composite/base.py +9 -5
- mindspore/ops/composite/multitype_ops/__init__.py +12 -1
- mindspore/ops/composite/multitype_ops/_compile_utils.py +132 -108
- mindspore/ops/composite/multitype_ops/_constexpr_utils.py +1 -1
- mindspore/ops/composite/multitype_ops/add_impl.py +70 -2
- mindspore/ops/composite/multitype_ops/div_impl.py +49 -0
- mindspore/ops/composite/multitype_ops/floordiv_impl.py +29 -0
- mindspore/ops/composite/multitype_ops/getitem_impl.py +11 -0
- mindspore/ops/composite/multitype_ops/mod_impl.py +5 -3
- mindspore/ops/composite/multitype_ops/mul_impl.py +49 -0
- mindspore/ops/composite/multitype_ops/setitem_impl.py +57 -0
- mindspore/ops/composite/multitype_ops/sub_impl.py +34 -0
- mindspore/ops/composite/multitype_ops/zeros_like_impl.py +14 -0
- mindspore/ops/function/__init__.py +4 -1
- mindspore/ops/function/_add_attr_func.py +11 -6
- mindspore/ops/function/array_func.py +17 -100
- mindspore/ops/function/debug_func.py +8 -5
- mindspore/ops/function/grad/grad_func.py +5 -13
- mindspore/ops/function/math_func.py +65 -399
- mindspore/ops/function/nn_func.py +44 -61
- mindspore/ops/function/other_func.py +4 -1
- mindspore/ops/function/random_func.py +31 -4
- mindspore/ops/functional.py +2 -3
- mindspore/ops/functional_overload.py +486 -18
- mindspore/ops/op_info_register.py +21 -0
- mindspore/ops/operations/__init__.py +5 -2
- mindspore/ops/operations/_custom_ops_utils.py +675 -8
- mindspore/ops/operations/_inner_ops.py +14 -18
- mindspore/ops/operations/_sequence_ops.py +1 -1
- mindspore/ops/operations/array_ops.py +4 -50
- mindspore/ops/operations/comm_ops.py +186 -41
- mindspore/ops/operations/custom_ops.py +244 -175
- mindspore/ops/operations/debug_ops.py +55 -4
- mindspore/ops/operations/image_ops.py +13 -13
- mindspore/ops/operations/manually_defined/ops_def.py +27 -28
- mindspore/ops/operations/math_ops.py +8 -9
- mindspore/ops/operations/nn_ops.py +6 -7
- mindspore/ops/primitive.py +9 -20
- mindspore/ops/tensor_method.py +52 -11
- mindspore/ops_generate/api/cpp_create_prim_instance_helper_generator.py +1 -1
- mindspore/ops_generate/api/functional_map_cpp_generator.py +10 -9
- mindspore/ops_generate/api/functions_cc_generator.py +58 -10
- mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +1 -1
- mindspore/ops_generate/common/base_generator.py +14 -0
- mindspore/ops_generate/common/gen_constants.py +7 -2
- mindspore/ops_generate/common/gen_utils.py +0 -19
- mindspore/ops_generate/common/op_proto.py +11 -4
- mindspore/ops_generate/common/template.py +88 -11
- mindspore/ops_generate/gen_ops.py +1 -1
- mindspore/ops_generate/op_def/lite_ops_cpp_generator.py +4 -4
- mindspore/ops_generate/op_def/ops_name_h_generator.py +0 -3
- mindspore/ops_generate/op_def/ops_primitive_h_generator.py +0 -4
- mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -2
- mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +49 -8
- mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +2 -2
- mindspore/ops_generate/pyboost/gen_pyboost_func.py +31 -16
- mindspore/ops_generate/pyboost/op_template_parser.py +98 -72
- mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +70 -273
- mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +14 -6
- mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +316 -0
- mindspore/ops_generate/pyboost/pyboost_functions_py_generator.py +1 -1
- mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +5 -3
- mindspore/ops_generate/pyboost/pyboost_inner_prim_generator.py +1 -1
- mindspore/ops_generate/pyboost/pyboost_internal_functions_cpp_generator.py +76 -0
- mindspore/ops_generate/pyboost/pyboost_internal_functions_h_generator.py +76 -0
- mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +125 -0
- mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +4 -3
- mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +348 -61
- mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +1 -1
- mindspore/ops_generate/pyboost/pyboost_utils.py +118 -9
- mindspore/ops_generate/tensor_py_cc_generator.py +1 -24
- mindspore/parallel/_auto_parallel_context.py +9 -17
- mindspore/parallel/_cell_wrapper.py +106 -40
- mindspore/parallel/_parallel_serialization.py +4 -3
- mindspore/parallel/_ps_context.py +4 -6
- mindspore/parallel/_tensor.py +167 -12
- mindspore/parallel/_transformer/moe.py +1 -1
- mindspore/parallel/_transformer/transformer.py +17 -12
- mindspore/parallel/_utils.py +5 -11
- mindspore/parallel/auto_parallel.py +33 -12
- mindspore/parallel/checkpoint_convert.py +3 -3
- mindspore/parallel/checkpoint_transform.py +5 -1
- mindspore/parallel/cluster/process_entity/_api.py +88 -49
- mindspore/parallel/cluster/process_entity/_utils.py +95 -7
- mindspore/parallel/cluster/run.py +48 -7
- mindspore/parallel/function/__init__.py +8 -1
- mindspore/parallel/function/reshard_func.py +7 -6
- mindspore/parallel/nn/__init__.py +15 -2
- mindspore/parallel/nn/parallel_cell_wrapper.py +50 -14
- mindspore/parallel/nn/parallel_grad_reducer.py +7 -14
- mindspore/parallel/shard.py +9 -23
- mindspore/parallel/transform_safetensors.py +468 -174
- mindspore/pgodb140.dll +0 -0
- mindspore/pgort140.dll +0 -0
- mindspore/profiler/__init__.py +2 -1
- mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +7 -7
- mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +3 -0
- mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +3 -0
- mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +3 -3
- mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +3 -3
- mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +4 -4
- mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +3 -3
- mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +4 -1
- mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +2 -1
- mindspore/profiler/analysis/task_manager.py +1 -1
- mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +5 -1
- mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +2 -1
- mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +10 -9
- mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +43 -23
- mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +3 -2
- mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +9 -5
- mindspore/profiler/analysis/viewer/ms_operator_details_viewer.py +132 -0
- mindspore/profiler/common/constant.py +16 -0
- mindspore/profiler/common/msprof_cmd_tool.py +2 -2
- mindspore/profiler/common/path_manager.py +9 -0
- mindspore/profiler/common/profiler_context.py +50 -29
- mindspore/profiler/common/profiler_info.py +0 -16
- mindspore/profiler/common/profiler_meta_data.py +1 -0
- mindspore/profiler/common/profiler_op_analyse.py +239 -0
- mindspore/profiler/common/profiler_output_path.py +23 -8
- mindspore/profiler/common/profiler_parameters.py +128 -35
- mindspore/profiler/dynamic_profile/__init__.py +0 -0
- mindspore/profiler/dynamic_profile/dynamic_monitor_proxy.py +39 -0
- mindspore/profiler/dynamic_profile/dynamic_profiler_config_context.py +666 -0
- mindspore/profiler/dynamic_profile/dynamic_profiler_utils.py +62 -0
- mindspore/profiler/dynamic_profiler.py +374 -338
- mindspore/profiler/envprofiler.py +42 -12
- mindspore/profiler/experimental_config.py +112 -7
- mindspore/profiler/mstx.py +33 -12
- mindspore/profiler/platform/__init__.py +2 -3
- mindspore/profiler/platform/cpu_profiler.py +10 -4
- mindspore/profiler/platform/npu_profiler.py +30 -20
- mindspore/profiler/profiler.py +218 -154
- mindspore/profiler/profiler_action_controller.py +65 -77
- mindspore/profiler/profiler_interface.py +2 -2
- mindspore/profiler/schedule.py +10 -4
- mindspore/rewrite/common/config.py +1 -0
- mindspore/rewrite/common/namer.py +1 -0
- mindspore/rewrite/common/namespace.py +1 -0
- mindspore/rewrite/node/node.py +31 -11
- mindspore/rewrite/parsers/assign_parser.py +1 -1
- mindspore/rewrite/symbol_tree/symbol_tree.py +2 -2
- mindspore/run_check/_check_version.py +7 -10
- mindspore/runtime/__init__.py +8 -6
- mindspore/runtime/event.py +10 -4
- mindspore/runtime/executor.py +87 -45
- mindspore/runtime/memory.py +22 -30
- mindspore/runtime/thread_bind_core.py +299 -165
- mindspore/safeguard/rewrite_obfuscation.py +12 -13
- mindspore/swresample-4.dll +0 -0
- mindspore/swscale-6.dll +0 -0
- mindspore/tbbmalloc.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/_utils.py +9 -5
- mindspore/train/amp.py +43 -23
- mindspore/train/callback/__init__.py +5 -5
- mindspore/train/callback/_callback.py +2 -1
- mindspore/train/callback/_checkpoint.py +4 -14
- mindspore/train/callback/_flops_collector.py +11 -7
- mindspore/train/callback/_landscape.py +0 -1
- mindspore/train/callback/_train_fault_tolerance.py +72 -18
- mindspore/train/data_sink.py +15 -6
- mindspore/train/dataset_helper.py +14 -5
- mindspore/train/model.py +49 -47
- mindspore/train/serialization.py +168 -126
- mindspore/train/summary/summary_record.py +13 -2
- mindspore/train/train_thor/model_thor.py +2 -2
- mindspore/turbojpeg.dll +0 -0
- mindspore/utils/__init__.py +3 -2
- mindspore/utils/dryrun.py +0 -6
- mindspore/utils/runtime_execution_order_check.py +162 -78
- mindspore/utils/sdc_detect.py +68 -0
- mindspore/utils/utils.py +14 -17
- mindspore/vcmeta.dll +0 -0
- mindspore/vcruntime140.dll +0 -0
- mindspore/vcruntime140_1.dll +0 -0
- mindspore/version.py +1 -1
- {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/METADATA +5 -4
- {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/RECORD +400 -439
- mindspore/_deprecated/jit.py +0 -198
- mindspore/_extends/remote/kernel_build_server_ascend.py +0 -75
- mindspore/communication/_hccl_management.py +0 -297
- mindspore/experimental/es/embedding_service.py +0 -891
- mindspore/experimental/es/embedding_service_layer.py +0 -581
- mindspore/profiler/common/validator/__init__.py +0 -14
- mindspore/profiler/common/validator/validate_path.py +0 -84
- mindspore/profiler/parser/__init__.py +0 -14
- mindspore/profiler/parser/aicpu_data_parser.py +0 -272
- mindspore/profiler/parser/ascend_analysis/__init__.py +0 -14
- mindspore/profiler/parser/ascend_analysis/constant.py +0 -71
- mindspore/profiler/parser/ascend_analysis/file_manager.py +0 -180
- mindspore/profiler/parser/ascend_analysis/function_event.py +0 -185
- mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +0 -136
- mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +0 -131
- mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +0 -104
- mindspore/profiler/parser/ascend_analysis/path_manager.py +0 -313
- mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +0 -123
- mindspore/profiler/parser/ascend_analysis/tlv_decoder.py +0 -86
- mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +0 -75
- mindspore/profiler/parser/ascend_cluster_generator.py +0 -116
- mindspore/profiler/parser/ascend_communicate_generator.py +0 -314
- mindspore/profiler/parser/ascend_flops_generator.py +0 -116
- mindspore/profiler/parser/ascend_fpbp_generator.py +0 -82
- mindspore/profiler/parser/ascend_hccl_generator.py +0 -271
- mindspore/profiler/parser/ascend_integrate_generator.py +0 -42
- mindspore/profiler/parser/ascend_memory_generator.py +0 -185
- mindspore/profiler/parser/ascend_msprof_exporter.py +0 -282
- mindspore/profiler/parser/ascend_msprof_generator.py +0 -187
- mindspore/profiler/parser/ascend_op_generator.py +0 -334
- mindspore/profiler/parser/ascend_steptrace_generator.py +0 -94
- mindspore/profiler/parser/ascend_timeline_generator.py +0 -545
- mindspore/profiler/parser/base_timeline_generator.py +0 -483
- mindspore/profiler/parser/container.py +0 -229
- mindspore/profiler/parser/cpu_gpu_timeline_generator.py +0 -697
- mindspore/profiler/parser/flops_parser.py +0 -531
- mindspore/profiler/parser/framework_enum.py +0 -111
- mindspore/profiler/parser/framework_parser.py +0 -464
- mindspore/profiler/parser/framework_struct.py +0 -61
- mindspore/profiler/parser/gpu_analysis/__init__.py +0 -14
- mindspore/profiler/parser/gpu_analysis/function_event.py +0 -44
- mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +0 -89
- mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +0 -72
- mindspore/profiler/parser/hccl_parser.py +0 -573
- mindspore/profiler/parser/hwts_log_parser.py +0 -122
- mindspore/profiler/parser/integrator.py +0 -526
- mindspore/profiler/parser/memory_usage_parser.py +0 -277
- mindspore/profiler/parser/minddata_analyzer.py +0 -800
- mindspore/profiler/parser/minddata_parser.py +0 -186
- mindspore/profiler/parser/minddata_pipeline_parser.py +0 -299
- mindspore/profiler/parser/op_intermediate_parser.py +0 -149
- mindspore/profiler/parser/optime_parser.py +0 -250
- mindspore/profiler/parser/profiler_info.py +0 -213
- mindspore/profiler/parser/step_trace_parser.py +0 -666
- mindspore/utils/hooks.py +0 -81
- /mindspore/common/{_auto_dynamic.py → dynamic_shape/_auto_dynamic.py} +0 -0
- {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/WHEEL +0 -0
- {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/entry_points.txt +0 -0
- {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/top_level.txt +0 -0
|
@@ -40,7 +40,7 @@ from mindspore.communication.management import get_rank, GlobalComm
|
|
|
40
40
|
from ._ms_kernel import determine_variable_usage
|
|
41
41
|
from ._custom_grad import autodiff_bprop
|
|
42
42
|
from ._pyfunc_registry import add_pyfunc
|
|
43
|
-
from ._custom_ops_utils import ExtensionBuilder
|
|
43
|
+
from ._custom_ops_utils import ExtensionBuilder, CustomCodeGenerator, CustomInfoGenerator
|
|
44
44
|
|
|
45
45
|
if platform.system() != "Windows":
|
|
46
46
|
import fcntl
|
|
@@ -73,13 +73,18 @@ def _get_cache_path():
|
|
|
73
73
|
"""
|
|
74
74
|
cache_path = os.getenv('MS_COMPILER_CACHE_PATH')
|
|
75
75
|
if cache_path is None:
|
|
76
|
-
cache_path = "./
|
|
76
|
+
cache_path = "./custom_kernel_meta/"
|
|
77
77
|
elif cache_path[-1] != "/":
|
|
78
78
|
cache_path = cache_path + "/"
|
|
79
79
|
|
|
80
80
|
if not os.path.exists(cache_path):
|
|
81
81
|
os.makedirs(cache_path, exist_ok=True)
|
|
82
82
|
|
|
83
|
+
# for distributed case, we create folders separately to avoid conflict
|
|
84
|
+
if GlobalComm.INITED:
|
|
85
|
+
cache_path = os.path.join(cache_path, "rank_" + str(get_rank()), "")
|
|
86
|
+
os.makedirs(cache_path, exist_ok=True)
|
|
87
|
+
|
|
83
88
|
return cache_path
|
|
84
89
|
|
|
85
90
|
|
|
@@ -94,10 +99,6 @@ def _compile_aot(file):
|
|
|
94
99
|
str, the path to the compiled library.
|
|
95
100
|
"""
|
|
96
101
|
cache_path = _get_cache_path()
|
|
97
|
-
# for distributed case, we create folders separately to avoid conflict
|
|
98
|
-
if GlobalComm.INITED:
|
|
99
|
-
cache_path = os.path.join(cache_path, "rank_" + str(get_rank()), "")
|
|
100
|
-
os.makedirs(cache_path, exist_ok=True)
|
|
101
102
|
|
|
102
103
|
res_path = importlib.util.find_spec("mindspore").origin
|
|
103
104
|
find_pos = res_path.find("__init__.py")
|
|
@@ -233,14 +234,13 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
233
234
|
<https://www.mindspore.cn/tutorials/en/master/custom_program/op_custom.html>`_ .
|
|
234
235
|
|
|
235
236
|
.. warning::
|
|
236
|
-
|
|
237
|
+
This is an experimental API that is subject to change.
|
|
237
238
|
|
|
238
239
|
.. note::
|
|
239
240
|
The supported platforms are determined by the input `func_type`. The supported platforms are as follows:
|
|
240
241
|
|
|
241
242
|
- "aot": supports ["GPU", "CPU", "Ascend"].
|
|
242
243
|
- "pyfunc": supports ["CPU"].
|
|
243
|
-
- "julia": supports ["CPU"].
|
|
244
244
|
|
|
245
245
|
Args:
|
|
246
246
|
func (Union[function, str]):
|
|
@@ -249,101 +249,84 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
249
249
|
computation logic of a user defined operator.
|
|
250
250
|
|
|
251
251
|
- str: If func is of str type, then str should be a path of file along with a function name.
|
|
252
|
-
This could be used when func_type is "aot"
|
|
253
|
-
|
|
254
|
-
1. for "aot":
|
|
255
|
-
|
|
256
|
-
a) GPU/CPU platform.
|
|
257
|
-
"aot" means ahead of time, in which case Custom directly launches user defined "xxx.so" file as an
|
|
258
|
-
operator. Users need to compile a handwriting "xxx.cu"/"xxx.cc" file into "xxx.so" ahead of time,
|
|
259
|
-
and offer the path of the file along with a function name.
|
|
260
|
-
|
|
261
|
-
- "xxx.so" file generation:
|
|
252
|
+
This could be used when func_type is "aot".
|
|
262
253
|
|
|
263
|
-
|
|
264
|
-
it.(ex. "nvcc --shared -Xcompiler -fPIC -o add.so add.cu")
|
|
254
|
+
for "aot":
|
|
265
255
|
|
|
266
|
-
|
|
267
|
-
|
|
256
|
+
a) GPU/CPU platform.
|
|
257
|
+
"aot" means ahead of time, in which case Custom directly launches user defined "xxx.so" file as an
|
|
258
|
+
operator. Users need to compile a handwriting "xxx.cu"/"xxx.cc" file into "xxx.so" ahead of time,
|
|
259
|
+
and offer the path of the file along with a function name.
|
|
268
260
|
|
|
269
|
-
|
|
261
|
+
- "xxx.so" file generation:
|
|
270
262
|
|
|
271
|
-
|
|
272
|
-
|
|
263
|
+
1) GPU Platform: Given user defined "xxx.cu" file (ex. "{path}/add.cu"), use nvcc command to compile
|
|
264
|
+
it.(ex. "nvcc --shared -Xcompiler -fPIC -o add.so add.cu")
|
|
273
265
|
|
|
274
|
-
|
|
266
|
+
2) CPU Platform: Given user defined "xxx.cc" file (ex. "{path}/add.cc"), use g++/gcc command to
|
|
267
|
+
compile it.(ex. "g++ --shared -fPIC -o add.so add.cc")
|
|
275
268
|
|
|
276
|
-
|
|
277
|
-
void *stream, void *extra)
|
|
269
|
+
- Define a "xxx.cc"/"xxx.cu" file:
|
|
278
270
|
|
|
279
|
-
|
|
271
|
+
"aot" is a cross-platform identity. The functions defined in "xxx.cc" or "xxx.cu" share
|
|
272
|
+
the same args. Typically, the function should be as:
|
|
280
273
|
|
|
281
|
-
|
|
282
|
-
then nparam=5
|
|
283
|
-
- params(void \*\*): a pointer to the array of inputs and outputs' pointer; the pointer type of
|
|
284
|
-
inputs and outputs is void \* ; suppose the operator has 2 inputs and 3 outputs, then the first
|
|
285
|
-
input's pointer is params[0] and the second output's pointer is params[3]
|
|
286
|
-
- ndims(int \*): a pointer to the array of inputs and outputs' dimension num; suppose params[i] is a
|
|
287
|
-
1024x1024 tensor and params[j] is a 77x83x4 tensor, then ndims[i]=2, ndims[j]=3.
|
|
288
|
-
- shapes(int64_t \*\*): a pointer to the array of inputs and outputs' shapes(int64_t \*); the ith
|
|
289
|
-
input's jth dimension's size is shapes[i][j](0<=j<ndims[i]); suppose params[i] is a 2x3 tensor and
|
|
290
|
-
params[j] is a 3x3x4 tensor, then shapes[i][0]=2, shapes[j][2]=4.
|
|
291
|
-
- dtypes(const char \*\*): a pointer to the array of inputs and outputs' types(const char \*);
|
|
292
|
-
(ex. "float32", "float16", "float", "float64", "int", "int8", "int16", "int32", "int64", "uint",
|
|
293
|
-
"uint8", "uint16", "uint32", "uint64", "bool")
|
|
294
|
-
- stream(void \*): stream pointer, only used in cuda file
|
|
295
|
-
- extra(void \*): used for further extension
|
|
274
|
+
.. code-block::
|
|
296
275
|
|
|
297
|
-
|
|
276
|
+
int func(int nparam, void **params, int *ndims, int64_t **shapes, const char **dtypes,
|
|
277
|
+
void *stream, void *extra)
|
|
298
278
|
|
|
299
|
-
|
|
300
|
-
- others: MindSpore will raise exception and exit
|
|
279
|
+
Parameters:
|
|
301
280
|
|
|
302
|
-
|
|
281
|
+
- nparam(int): total number of inputs plus outputs; suppose the operator has 2 inputs and 3 outputs,
|
|
282
|
+
then nparam=5
|
|
283
|
+
- params(void \*\*): a pointer to the array of inputs and outputs' pointer; the pointer type of
|
|
284
|
+
inputs and outputs is void \* ; suppose the operator has 2 inputs and 3 outputs, then the first
|
|
285
|
+
input's pointer is params[0] and the second output's pointer is params[3]
|
|
286
|
+
- ndims(int \*): a pointer to the array of inputs and outputs' dimension num; suppose params[i] is a
|
|
287
|
+
1024x1024 tensor and params[j] is a 77x83x4 tensor, then ndims[i]=2, ndims[j]=3.
|
|
288
|
+
- shapes(int64_t \*\*): a pointer to the array of inputs and outputs' shapes(int64_t \*); the ith
|
|
289
|
+
input's jth dimension's size is shapes[i][j](0<=j<ndims[i]); suppose params[i] is a 2x3 tensor and
|
|
290
|
+
params[j] is a 3x3x4 tensor, then shapes[i][0]=2, shapes[j][2]=4.
|
|
291
|
+
- dtypes(const char \*\*): a pointer to the array of inputs and outputs' types(const char \*);
|
|
292
|
+
(ex. "float32", "float16", "float", "float64", "int", "int8", "int16", "int32", "int64", "uint",
|
|
293
|
+
"uint8", "uint16", "uint32", "uint64", "bool")
|
|
294
|
+
- stream(void \*): stream pointer, only used in cuda file
|
|
295
|
+
- extra(void \*): used for further extension
|
|
303
296
|
|
|
304
|
-
|
|
297
|
+
Return Value(int):
|
|
305
298
|
|
|
306
|
-
|
|
299
|
+
- 0: MindSpore will continue to run if this aot kernel is successfully executed
|
|
300
|
+
- others: MindSpore will raise exception and exit
|
|
307
301
|
|
|
308
|
-
|
|
309
|
-
(ex. Custom(func="./reorganize.so:CustomReorganize", out_shape=[1], out_dtype=mstype.float32,
|
|
310
|
-
"aot"))
|
|
302
|
+
Examples: see details in tests/st/ops/graph_kernel/custom/aot_test_files/
|
|
311
303
|
|
|
312
|
-
|
|
313
|
-
Before using Custom operators on the Ascend platform, users must first develop custom operators
|
|
314
|
-
based on Ascend C and compile them. The complete development and usage process can refer to the
|
|
315
|
-
tutorial `AOT-Type Custom Operators(Ascend)
|
|
316
|
-
<https://www.mindspore.cn/tutorials/en/master/custom_program/operation/op_custom_ascendc.html>`_.
|
|
317
|
-
By passing the name of the operator through the input parameter `func`, there are two usage methods
|
|
318
|
-
based on the implementation of the infer function:
|
|
304
|
+
- Use it in Custom:
|
|
319
305
|
|
|
320
|
-
|
|
321
|
-
function is passed through the `out_shape` parameter, and the infer type is passed throuht the
|
|
322
|
-
`out_dtype`, then the `func` should be specified as the operator name, for example,
|
|
323
|
-
`func="CustomName"`.
|
|
324
|
-
- C++ infer: If the operator's infer function is implemented through C++, then pass the path of the
|
|
325
|
-
infer function implementation file in `func` and separate the operator name with `:`,
|
|
326
|
-
for example: `func="add_custom_infer.cc:AddCustom"` .
|
|
306
|
+
.. code-block::
|
|
327
307
|
|
|
328
|
-
|
|
308
|
+
Custom(func="{dir_path}/{file_name}:{func_name}",...)
|
|
309
|
+
(ex. Custom(func="./reorganize.so:CustomReorganize", out_shape=[1], out_dtype=mstype.float32,
|
|
310
|
+
"aot"))
|
|
329
311
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
312
|
+
b) Ascend platform.
|
|
313
|
+
Before using Custom operators on the Ascend platform, users must first develop custom operators
|
|
314
|
+
based on Ascend C and compile them. The complete development and usage process can refer to the
|
|
315
|
+
tutorial `AOT-Type Custom Operators(Ascend)
|
|
316
|
+
<https://www.mindspore.cn/tutorials/en/master/custom_program/operation/op_custom_ascendc.html>`_.
|
|
317
|
+
By passing the name of the operator through the input parameter `func`, there are two usage methods
|
|
318
|
+
based on the implementation of the infer function:
|
|
335
319
|
|
|
336
|
-
|
|
320
|
+
- Python infer: If the operator's infer function is implemented in Python, that is, the infer shape
|
|
321
|
+
function is passed through the `out_shape` parameter, and the infer type is passed throuht the
|
|
322
|
+
`out_dtype`, then the `func` should be specified as the operator name, for example,
|
|
323
|
+
`func="CustomName"`.
|
|
324
|
+
- C++ infer: If the operator's infer function is implemented through C++, then pass the path of the
|
|
325
|
+
infer function implementation file in `func` and separate the operator name with `:`,
|
|
326
|
+
for example: `func="add_custom_infer.cc:AddCustom"` .
|
|
337
327
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
.. code-block::
|
|
341
|
-
|
|
342
|
-
Custom(func="{dir_path}/{file_name}:{module_name}:{func_name}",...)
|
|
343
|
-
(ex. Custom(func="./add.jl:Add:add", out_shape=[1], out_dtype=mstype.float32, "julia"))
|
|
344
|
-
|
|
345
|
-
out_shape (Union[function, list, tuple]): The output shape infer function or the value of output shape of
|
|
346
|
-
`func`. Default: ``None`` .
|
|
328
|
+
out_shape (Union[function, list, tuple], optional): The output shape infer function or the value of output
|
|
329
|
+
shape of `func`. Default: ``None`` .
|
|
347
330
|
|
|
348
331
|
If func has single output, then the value of output shape is a list or tuple of int.
|
|
349
332
|
|
|
@@ -353,8 +336,8 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
353
336
|
The input can be None only when the func_type input is "hybrid". In this case, the automatic infer
|
|
354
337
|
shape mechanic will be enabled.
|
|
355
338
|
|
|
356
|
-
out_dtype (Union[function, :class:`mindspore.dtype`, tuple[:class:`mindspore.dtype`]]): The output
|
|
357
|
-
infer function or the value of output data type of `func`. Default: ``None`` .
|
|
339
|
+
out_dtype (Union[function, :class:`mindspore.dtype`, tuple[:class:`mindspore.dtype`]], optional): The output
|
|
340
|
+
data type infer function or the value of output data type of `func`. Default: ``None`` .
|
|
358
341
|
|
|
359
342
|
If func has single output, then the value of output shape is a `mindspore.dtype`.
|
|
360
343
|
|
|
@@ -364,13 +347,12 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
364
347
|
The input can be None only when the func_type input is "hybrid". In this case, the automatic infer
|
|
365
348
|
value mechanic will be enabled.
|
|
366
349
|
|
|
367
|
-
func_type (str): The implementation type of `func`, should be one of
|
|
350
|
+
func_type (str, optional): The implementation type of `func`, should be one of
|
|
351
|
+
[ ``"aot"`` , ``"pyfunc"``]. Default: ``"pyfunc"``.
|
|
368
352
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
reg_info (Union[str, dict, list, tuple]): Represents the registration information(reg info) of `func` with
|
|
373
|
-
json format of type str or dict. The reg info specifies supported data types and formats of inputs and
|
|
353
|
+
bprop (function, optional): The back propagation function of `func`. Default: ``None`` .
|
|
354
|
+
reg_info (Union[str, dict, list, tuple], optional): Represents the registration information(reg info) of `func`
|
|
355
|
+
with json format of type str or dict. The reg info specifies supported data types and formats of inputs and
|
|
374
356
|
outputs, attributes and target of `func`. Default: ``None`` .
|
|
375
357
|
|
|
376
358
|
If reg info is a list or tuple, then each item should be with json format of type str or dict, which
|
|
@@ -428,11 +410,11 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
428
410
|
op_path_in_cache = [] # Save paths for op functions created in the cached.
|
|
429
411
|
custom_aot_warning = True # Flag to enable warnings about custom aot path white list
|
|
430
412
|
|
|
431
|
-
def __init__(self, func, out_shape=None, out_dtype=None, func_type="
|
|
413
|
+
def __init__(self, func, out_shape=None, out_dtype=None, func_type="pyfunc", bprop=None, reg_info=None):
|
|
432
414
|
super().__init__("Custom")
|
|
433
415
|
|
|
434
416
|
self.supported_targets = [ASCEND, GPU, CPU]
|
|
435
|
-
self.supported_func_type = ["hybrid", "akg", "tbe", "aicpu", "aot", "pyfunc"
|
|
417
|
+
self.supported_func_type = ["hybrid", "akg", "tbe", "aicpu", "aot", "pyfunc"]
|
|
436
418
|
self.log_prefix = "For '{}', 'func_type': {}, 'func': {}".format(self.name, func_type, func)
|
|
437
419
|
self.func = func
|
|
438
420
|
self.func_type = func_type
|
|
@@ -444,11 +426,13 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
444
426
|
self._is_ms_kernel = False
|
|
445
427
|
self.out_shape = out_shape
|
|
446
428
|
self.out_dtype = out_dtype
|
|
447
|
-
self.
|
|
429
|
+
self.reg_info = reg_info
|
|
430
|
+
self.is_ascend_c = (context.get_context("device_target") == "Ascend" and self.func_type == "aot")
|
|
448
431
|
|
|
449
432
|
self._check_platform()
|
|
450
433
|
self._check_func()
|
|
451
|
-
self.
|
|
434
|
+
self._generate_reg_info()
|
|
435
|
+
self._update_func_info(self.reg_info)
|
|
452
436
|
self.add_prim_attr("func_name", self.func_name)
|
|
453
437
|
self.add_prim_attr("uniq_name", self.uniq_name)
|
|
454
438
|
if self.func_type == HYBRID_TYPE:
|
|
@@ -460,23 +444,22 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
460
444
|
add_pyfunc(func_id, self.func)
|
|
461
445
|
self.add_prim_attr("fn_id", func_id)
|
|
462
446
|
|
|
463
|
-
self.
|
|
464
|
-
|
|
465
|
-
self.multi_output = (reg_info is not None and (len(reg_info.get("outputs", [])) > 1))
|
|
466
|
-
self.add_prim_attr("multi_output", self.multi_output)
|
|
447
|
+
self._set_infer_flag()
|
|
448
|
+
self._set_multi_output_flag()
|
|
467
449
|
|
|
468
450
|
self.bprop = bprop
|
|
469
451
|
self.fake_output = False
|
|
470
452
|
self.single_scalar_output = False
|
|
471
|
-
if
|
|
472
|
-
self.
|
|
473
|
-
|
|
474
|
-
self.
|
|
475
|
-
|
|
476
|
-
|
|
453
|
+
if self.func_type == "pyfunc":
|
|
454
|
+
if not self.out_dtype:
|
|
455
|
+
self.fake_output = True
|
|
456
|
+
elif not self.out_shape:
|
|
457
|
+
self.single_scalar_output = True
|
|
458
|
+
self.add_prim_attr("fake_output", self.fake_output)
|
|
459
|
+
self.add_prim_attr("single_scalar_output", self.single_scalar_output)
|
|
477
460
|
|
|
478
461
|
# Register info
|
|
479
|
-
self._register_info(reg_info)
|
|
462
|
+
self._register_info(self.reg_info)
|
|
480
463
|
|
|
481
464
|
if func_type == "akg":
|
|
482
465
|
self._set_akg_kernel_type()
|
|
@@ -488,25 +471,22 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
488
471
|
self._update_attr()
|
|
489
472
|
|
|
490
473
|
if self.is_ascend_c:
|
|
491
|
-
self.set_inputs_type(reg_info)
|
|
492
474
|
self.custom_pyboost = _CustomExt(self.func, self.out_shape, self.out_dtype, self.bprop)
|
|
493
475
|
for key, value in super().get_attr_dict().items():
|
|
494
476
|
self.custom_pyboost.add_prim_attr(key, value)
|
|
477
|
+
self._generate_get_workspace_size_func()
|
|
495
478
|
|
|
496
|
-
def
|
|
479
|
+
def _set_infer_flag(self):
|
|
497
480
|
"""set cpp infer attr"""
|
|
498
481
|
if self.out_shape is None and self.func_type == "aot":
|
|
499
482
|
self.add_prim_attr("cpp_infer_shape", True)
|
|
500
483
|
if self.out_dtype is None and self.func_type == "aot":
|
|
501
484
|
self.add_prim_attr("cpp_infer_type", True)
|
|
502
485
|
|
|
503
|
-
def
|
|
504
|
-
""
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
inputs_type = ["tensor"] * len(reg_info.get("inputs", [])) + \
|
|
508
|
-
[attr.get("type") for attr in reg_info.get("attr", [])]
|
|
509
|
-
self.add_prim_attr("custom_inputs_type", inputs_type)
|
|
486
|
+
def _set_multi_output_flag(self):
|
|
487
|
+
outputs = self.reg_info.get("outputs", []) if self.reg_info else []
|
|
488
|
+
self.multi_output = len(outputs) > 1 or (len(outputs) == 1 and outputs[0].get("paramType") == "dynamic")
|
|
489
|
+
self.add_prim_attr("multi_output", self.multi_output)
|
|
510
490
|
|
|
511
491
|
def __infer__(self, *args):
|
|
512
492
|
if callable(self.out_shape):
|
|
@@ -586,22 +566,6 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
586
566
|
self.func_type = HYBRID_TYPE
|
|
587
567
|
self._hybrid_func_analyser()
|
|
588
568
|
|
|
589
|
-
def _check_julia_func(self):
|
|
590
|
-
"""Check the validity of julia func"""
|
|
591
|
-
if not isinstance(self.func, str):
|
|
592
|
-
raise TypeError("{}, 'func' must be of type str, but got {}".format(self.log_prefix, type(self.func)))
|
|
593
|
-
if self.func.count(':') != 2:
|
|
594
|
-
raise ValueError("{}, the format of 'func' must be file:module:func".format(self.log_prefix))
|
|
595
|
-
source_file, module, func = self.func.split(':')
|
|
596
|
-
with open(source_file, 'r') as f:
|
|
597
|
-
jl = f.read()
|
|
598
|
-
if 'module ' + module not in jl:
|
|
599
|
-
raise Exception("{}, module {} is not found in source file {}!"
|
|
600
|
-
.format(self.log_prefix, module, source_file))
|
|
601
|
-
if 'function ' + func not in jl:
|
|
602
|
-
raise Exception("{}, function {} is not found in source file {}!"
|
|
603
|
-
.format(self.log_prefix, func, source_file))
|
|
604
|
-
|
|
605
569
|
def _check_aot_func(self):
|
|
606
570
|
"""Check the source code and bin lib for aot type custom op"""
|
|
607
571
|
if not isinstance(self.func, str):
|
|
@@ -644,8 +608,6 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
644
608
|
if self.func_type == "aot":
|
|
645
609
|
self._check_aot_func()
|
|
646
610
|
|
|
647
|
-
elif self.func_type == "julia":
|
|
648
|
-
self._check_julia_func()
|
|
649
611
|
elif self.func_type == HYBRID_TYPE:
|
|
650
612
|
if not hasattr(self.func, MS_KERNEL_FLAG):
|
|
651
613
|
raise TypeError("{}, 'func' must be a function decorated by kernel".format(self.log_prefix))
|
|
@@ -962,7 +924,7 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
962
924
|
return reg_info[IMPLY_TYPE]
|
|
963
925
|
# Infer imply_type from func_type
|
|
964
926
|
func_type_to_imply_type = {"hybrid": AKG, "akg": AKG, "tbe": TBE, "aicpu": "AiCPU", "pyfunc": target,
|
|
965
|
-
"
|
|
927
|
+
"aot": "BiSheng" if target == ASCEND else target}
|
|
966
928
|
return func_type_to_imply_type.get(self.func_type, AKG)
|
|
967
929
|
|
|
968
930
|
def _save_attr(self, reg_info):
|
|
@@ -1034,17 +996,6 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
1034
996
|
self.set_device(GPU)
|
|
1035
997
|
elif registered_targets == [CPU]:
|
|
1036
998
|
self.set_device(CPU)
|
|
1037
|
-
elif self.func_type == "julia":
|
|
1038
|
-
self.set_device(CPU)
|
|
1039
|
-
device_target = context.get_context('device_target')
|
|
1040
|
-
if device_target == CPU:
|
|
1041
|
-
pass
|
|
1042
|
-
elif device_target == GPU and registered_targets and registered_targets == [CPU]:
|
|
1043
|
-
logger.warning("{}, only supports CPU platform, but got registered target {}. "
|
|
1044
|
-
"We will run it on CPU".format(self.log_prefix, registered_targets))
|
|
1045
|
-
else:
|
|
1046
|
-
raise ValueError("{}, only supports CPU platform, but got target {}."
|
|
1047
|
-
.format(self.log_prefix, device_target))
|
|
1048
999
|
|
|
1049
1000
|
def _update_attr(self):
|
|
1050
1001
|
"""Add input_names, attr_names, primitive_target to primitive's attr."""
|
|
@@ -1124,22 +1075,105 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
1124
1075
|
if isinstance(arg_dtype, mstype.TensorType):
|
|
1125
1076
|
arg_dtype = arg_dtype.element_type()
|
|
1126
1077
|
fake_arg = np.zeros(arg["shape"]).astype(
|
|
1127
|
-
mstype.
|
|
1078
|
+
mstype._dtype_to_nptype(arg_dtype)) # pylint:disable=protected-access
|
|
1128
1079
|
fake_input.append(fake_arg)
|
|
1129
1080
|
|
|
1130
1081
|
fake_output = self.func(*fake_input)
|
|
1131
1082
|
|
|
1132
1083
|
if hasattr(fake_output, 'shape'):
|
|
1133
1084
|
infer_shape = fake_output.shape
|
|
1134
|
-
|
|
1085
|
+
# pylint:disable=protected-access
|
|
1086
|
+
infer_dtype = mstype.TensorType(mstype._pytype_to_dtype(fake_output.dtype))
|
|
1135
1087
|
else:
|
|
1136
1088
|
infer_shape = (1,)
|
|
1137
|
-
infer_dtype = mstype.
|
|
1089
|
+
infer_dtype = mstype._pytype_to_dtype(fake_output.dtype) # pylint:disable=protected-access
|
|
1138
1090
|
|
|
1139
1091
|
infer_value = Tensor(fake_output) if enable_infer_value else None
|
|
1140
1092
|
|
|
1141
1093
|
return infer_shape, infer_dtype, infer_value
|
|
1142
1094
|
|
|
1095
|
+
def _generate_reg_info(self):
|
|
1096
|
+
if not self.is_ascend_c:
|
|
1097
|
+
return
|
|
1098
|
+
if self.reg_info is None:
|
|
1099
|
+
func_name, _ = self._split_func()
|
|
1100
|
+
if func_name.startswith("aclnn"):
|
|
1101
|
+
func_name = func_name[len("aclnn"):]
|
|
1102
|
+
reg_info_generator = CustomInfoGenerator(func_name)
|
|
1103
|
+
self.reg_info = reg_info_generator.generate_custom_reg_op()
|
|
1104
|
+
|
|
1105
|
+
def _split_func(self):
|
|
1106
|
+
func_list = self.func.split(":")
|
|
1107
|
+
func_path = ""
|
|
1108
|
+
if len(func_list) == 2:
|
|
1109
|
+
func_path = func_list[0]
|
|
1110
|
+
func_name = func_list[1]
|
|
1111
|
+
else:
|
|
1112
|
+
func_name = self.func
|
|
1113
|
+
return func_name, func_path
|
|
1114
|
+
|
|
1115
|
+
def _generate_get_worspace_size_func_by_types(self, aclnn_api_types):
|
|
1116
|
+
"""generate custom GetWorkSpaceSize func by aclnn api types"""
|
|
1117
|
+
if not self.is_ascend_c:
|
|
1118
|
+
return
|
|
1119
|
+
|
|
1120
|
+
input_output_types = []
|
|
1121
|
+
if isinstance(aclnn_api_types, str):
|
|
1122
|
+
params = re.split(r',\s*', aclnn_api_types)
|
|
1123
|
+
for param in params:
|
|
1124
|
+
param = param.replace('const ', '')
|
|
1125
|
+
type_part = re.search(r'^\s*(\w+\s*\*+|\w+)', param).group(1)
|
|
1126
|
+
type_part = type_part.replace(' ', '')
|
|
1127
|
+
input_output_types.append(type_part)
|
|
1128
|
+
elif isinstance(aclnn_api_types, list):
|
|
1129
|
+
input_output_types = aclnn_api_types
|
|
1130
|
+
else:
|
|
1131
|
+
raise RuntimeError(f"Unsupported type: {type(aclnn_api_types)}, support type is list or string.")
|
|
1132
|
+
|
|
1133
|
+
func_name, _ = self._split_func()
|
|
1134
|
+
file_path = os.path.join(_get_cache_path(), func_name, func_name + "_callback.cc")
|
|
1135
|
+
|
|
1136
|
+
file_path = os.path.abspath(file_path)
|
|
1137
|
+
dir_path = os.path.dirname(file_path)
|
|
1138
|
+
os.makedirs(dir_path, exist_ok=True)
|
|
1139
|
+
|
|
1140
|
+
custom_builder = CustomCodeGenerator()
|
|
1141
|
+
callback_func = custom_builder.generate_callback_by_types(func_name, self.reg_info, input_output_types)
|
|
1142
|
+
|
|
1143
|
+
with open(file_path, 'w') as f:
|
|
1144
|
+
f.write(callback_func)
|
|
1145
|
+
|
|
1146
|
+
custom_callback_func_path = _compile_aot(file_path)
|
|
1147
|
+
custom_callback_func = custom_callback_func_path + ":" + func_name
|
|
1148
|
+
self.add_prim_attr("custom_callback_func", custom_callback_func)
|
|
1149
|
+
self.add_prim_attr("custom_inputs_type", input_output_types[:-2])
|
|
1150
|
+
|
|
1151
|
+
def _generate_get_workspace_size_func(self):
|
|
1152
|
+
"""generate custom GetWorkSpaceSize func"""
|
|
1153
|
+
if not self.is_ascend_c:
|
|
1154
|
+
return
|
|
1155
|
+
func_name, _ = self._split_func()
|
|
1156
|
+
file_path = os.path.join(_get_cache_path(), func_name, func_name + "_callback.cc")
|
|
1157
|
+
|
|
1158
|
+
file_path = os.path.abspath(file_path)
|
|
1159
|
+
dir_path = os.path.dirname(file_path)
|
|
1160
|
+
os.makedirs(dir_path, exist_ok=True)
|
|
1161
|
+
|
|
1162
|
+
custom_info_generator = CustomInfoGenerator(func_name)
|
|
1163
|
+
api_types = custom_info_generator.get_aclnn_api_types()
|
|
1164
|
+
custom_builder = CustomCodeGenerator()
|
|
1165
|
+
if api_types == []:
|
|
1166
|
+
api_types = custom_builder.get_api_types_by_reg_info(self.reg_info)
|
|
1167
|
+
|
|
1168
|
+
callback_func = custom_builder.generate_callback_by_types(func_name, self.reg_info, api_types)
|
|
1169
|
+
with open(file_path, 'w') as f:
|
|
1170
|
+
f.write(callback_func)
|
|
1171
|
+
|
|
1172
|
+
custom_callback_func_path = _compile_aot(file_path)
|
|
1173
|
+
custom_callback_func = custom_callback_func_path + ":" + func_name
|
|
1174
|
+
self.add_prim_attr("custom_callback_func", custom_callback_func)
|
|
1175
|
+
self.add_prim_attr("custom_inputs_type", api_types[:-2])
|
|
1176
|
+
|
|
1143
1177
|
def __call__(self, *args):
|
|
1144
1178
|
if self.is_ascend_c:
|
|
1145
1179
|
res = pyboost_custom_ext(self.custom_pyboost, [args])
|
|
@@ -1174,6 +1208,15 @@ class CustomOpBuilder:
|
|
|
1174
1208
|
ldflags (str, optional): Extra linker flags to be used during linking. Default: ``None``.
|
|
1175
1209
|
kwargs (dict, optional): Additional keyword arguments for future extensions or specific custom requirements.
|
|
1176
1210
|
|
|
1211
|
+
- build_dir (str, optional): The directory used to generate the operator build files.
|
|
1212
|
+
If this argument is set, the provided path will be used directly.
|
|
1213
|
+
If not set, a subdirectory named after the operator's name will be created under the path specified by
|
|
1214
|
+
the environment variable `MS_COMPILER_CACHE_PATH` (defaulting to "./kernel_meta"), and the files will
|
|
1215
|
+
be placed in this subdirectory. Default: ``None``.
|
|
1216
|
+
|
|
1217
|
+
- enable_atb (bool, optional): Whether to call ATB (Ascend Transformer Boost) operator. If set to ``True``,
|
|
1218
|
+
the `backend` must be ``Ascend`` or left empty. Default: ``False``.
|
|
1219
|
+
|
|
1177
1220
|
.. note::
|
|
1178
1221
|
- If the `backend` argument is provided, additional default flags will be automatically added to
|
|
1179
1222
|
the compilation and linking steps to support the operator's target backend. The default options
|
|
@@ -1193,9 +1236,7 @@ class CustomOpBuilder:
|
|
|
1193
1236
|
... )
|
|
1194
1237
|
>>> my_ops = builder.load()
|
|
1195
1238
|
"""
|
|
1196
|
-
_mindspore_path = None
|
|
1197
1239
|
_loaded_ops = {}
|
|
1198
|
-
_ms_code_base = None
|
|
1199
1240
|
|
|
1200
1241
|
def __init__(self, name, sources, backend=None, include_paths=None, cflags=None, ldflags=None, **kwargs):
|
|
1201
1242
|
self.name = name
|
|
@@ -1205,11 +1246,24 @@ class CustomOpBuilder:
|
|
|
1205
1246
|
self.cflags = cflags
|
|
1206
1247
|
self.ldflags = ldflags
|
|
1207
1248
|
self.build_dir = kwargs.get("build_dir")
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1249
|
+
self.enable_atb = kwargs.get("enable_atb", False)
|
|
1250
|
+
self.debug_mode = kwargs.get("debug_mode", False)
|
|
1251
|
+
self._ms_path = os.path.dirname(os.path.abspath(ms.__file__))
|
|
1252
|
+
if self.enable_atb:
|
|
1253
|
+
if backend is not None and backend != "Ascend":
|
|
1254
|
+
raise ValueError("For 'CustomOpBuilder', when 'enable_atb' is set to True, the 'backend' must be "
|
|
1255
|
+
f"'Ascend' (or left implicit), but got '{backend}'")
|
|
1256
|
+
self.backend = "Ascend"
|
|
1211
1257
|
if self.backend == "Ascend":
|
|
1212
|
-
|
|
1258
|
+
ascend_opp_path = os.getenv("ASCEND_OPP_PATH")
|
|
1259
|
+
if not ascend_opp_path:
|
|
1260
|
+
raise ValueError("Environment variable 'ASCEND_OPP_PATH' must be set for Ascend backend.")
|
|
1261
|
+
self.ascend_cann_path = ascend_opp_path.split('opp')[0]
|
|
1262
|
+
|
|
1263
|
+
if self.enable_atb:
|
|
1264
|
+
self.atb_home_path = os.getenv("ATB_HOME_PATH")
|
|
1265
|
+
if not self.atb_home_path:
|
|
1266
|
+
raise ValueError("Environment variable 'ATB_HOME_PATH' must be set when 'enable_atb' is True.")
|
|
1213
1267
|
|
|
1214
1268
|
def get_sources(self):
|
|
1215
1269
|
"""
|
|
@@ -1228,29 +1282,31 @@ class CustomOpBuilder:
|
|
|
1228
1282
|
list[str], A list of include paths.
|
|
1229
1283
|
"""
|
|
1230
1284
|
include_list = self.include_paths if self.include_paths is not None else []
|
|
1231
|
-
include_list.append(
|
|
1232
|
-
include_list.append(os.path.join(
|
|
1233
|
-
include_list.append(os.path.join(
|
|
1234
|
-
include_list.append(os.path.join(
|
|
1235
|
-
include_list.append(os.path.join(
|
|
1285
|
+
include_list.append(self._ms_path)
|
|
1286
|
+
include_list.append(os.path.join(self._ms_path, "include"))
|
|
1287
|
+
include_list.append(os.path.join(self._ms_path, "include", "third_party"))
|
|
1288
|
+
include_list.append(os.path.join(self._ms_path, "include", "third_party", "robin_hood_hashing"))
|
|
1289
|
+
include_list.append(os.path.join(self._ms_path, "include", "third_party", "securec", "include"))
|
|
1236
1290
|
|
|
1237
1291
|
if self.backend == "Ascend":
|
|
1238
1292
|
include_list.append(os.path.join(self.ascend_cann_path, "include"))
|
|
1293
|
+
if self.enable_atb:
|
|
1294
|
+
include_list.append(os.path.join(self.atb_home_path, "include"))
|
|
1239
1295
|
include_list += self._get_ms_inner_includes()
|
|
1240
1296
|
return include_list
|
|
1241
1297
|
|
|
1242
1298
|
def _get_ms_inner_includes(self):
|
|
1243
1299
|
"""include paths for inner module interface."""
|
|
1244
|
-
|
|
1300
|
+
ms_inner_path = os.path.join(self._ms_path, "include", "mindspore")
|
|
1245
1301
|
include_list = []
|
|
1246
|
-
include_list.append(
|
|
1247
|
-
include_list.append(
|
|
1248
|
-
include_list.append(
|
|
1249
|
-
include_list.append(
|
|
1250
|
-
include_list.append(
|
|
1251
|
-
include_list.append(
|
|
1252
|
-
include_list.append(
|
|
1253
|
-
include_list.append(
|
|
1302
|
+
include_list.append(os.path.join(ms_inner_path, "core", "include"))
|
|
1303
|
+
include_list.append(os.path.join(ms_inner_path, "core", "mindrt", "include"))
|
|
1304
|
+
include_list.append(os.path.join(ms_inner_path, "core", "mindrt"))
|
|
1305
|
+
include_list.append(os.path.join(ms_inner_path, "ops"))
|
|
1306
|
+
include_list.append(os.path.join(ms_inner_path, "ops", "kernel", "include"))
|
|
1307
|
+
include_list.append(os.path.join(ms_inner_path, "ccsrc"))
|
|
1308
|
+
include_list.append(os.path.join(ms_inner_path, "ccsrc", "include"))
|
|
1309
|
+
include_list.append(os.path.join(ms_inner_path, "ccsrc", "minddata", "mindrecord", "include"))
|
|
1254
1310
|
return include_list
|
|
1255
1311
|
|
|
1256
1312
|
def get_cflags(self):
|
|
@@ -1260,10 +1316,14 @@ class CustomOpBuilder:
|
|
|
1260
1316
|
Returns:
|
|
1261
1317
|
list[str], A list of C++ compiler flags.
|
|
1262
1318
|
"""
|
|
1263
|
-
flags = ['-
|
|
1264
|
-
flags += ['-
|
|
1319
|
+
flags = [f'-DMS_EXTENSION_NAME={self.name}', '-D_GLIBCXX_USE_CXX11_ABI=0', '-DENABLE_FAST_HASH_TABLE=1']
|
|
1320
|
+
flags += ['-std=c++17', '-fstack-protector-all', '-fPIC', '-pie']
|
|
1321
|
+
if self.debug_mode:
|
|
1322
|
+
flags.append('-g')
|
|
1265
1323
|
if self.backend == "Ascend":
|
|
1266
1324
|
flags.append('-DCUSTOM_ASCEND_OP')
|
|
1325
|
+
if self.enable_atb:
|
|
1326
|
+
flags.append('-DCUSTOM_ENABLE_ATB')
|
|
1267
1327
|
if self.cflags is not None:
|
|
1268
1328
|
flags.append(self.cflags)
|
|
1269
1329
|
return flags
|
|
@@ -1275,18 +1335,27 @@ class CustomOpBuilder:
|
|
|
1275
1335
|
Returns:
|
|
1276
1336
|
list[str], A list of linker flags.
|
|
1277
1337
|
"""
|
|
1278
|
-
flags = ['-
|
|
1338
|
+
flags = ['-shared']
|
|
1339
|
+
flags += ['-Wl,-z,relro,-z,now,-z,noexecstack', '-Wl,--disable-new-dtags,--rpath']
|
|
1340
|
+
if not self.debug_mode:
|
|
1341
|
+
flags.append('-s') # strip
|
|
1279
1342
|
flags += [
|
|
1280
|
-
|
|
1343
|
+
f"-L{os.path.abspath(os.path.join(self._ms_path, 'lib'))}",
|
|
1281
1344
|
'-lmindspore_core',
|
|
1282
1345
|
'-lmindspore_ms_backend',
|
|
1283
|
-
'-lmindspore_pynative'
|
|
1346
|
+
'-lmindspore_pynative',
|
|
1347
|
+
'-lmindspore_extension'
|
|
1284
1348
|
]
|
|
1285
1349
|
if self.backend == "Ascend":
|
|
1286
|
-
flags.append(
|
|
1287
|
-
flags.append(
|
|
1350
|
+
flags.append(f"-L{os.path.abspath(os.path.join(self._ms_path, 'lib', 'plugin'))}")
|
|
1351
|
+
flags.append(f"-L{os.path.abspath(os.path.join(self.ascend_cann_path, 'lib64'))}")
|
|
1288
1352
|
flags.append('-lascendcl')
|
|
1289
1353
|
flags.append('-l:libmindspore_ascend.so.2')
|
|
1354
|
+
if self.enable_atb:
|
|
1355
|
+
flags.append(f"-L{os.path.abspath(os.path.join(self._ms_path, 'lib', 'plugin', 'ascend'))}")
|
|
1356
|
+
flags.append('-lmindspore_extension_ascend_atb')
|
|
1357
|
+
flags.append(f"-L{os.path.abspath(os.path.join(self.atb_home_path, 'lib'))}")
|
|
1358
|
+
flags.append('-latb')
|
|
1290
1359
|
if self.ldflags is not None:
|
|
1291
1360
|
flags.append(self.ldflags)
|
|
1292
1361
|
return flags
|