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
|
@@ -16,12 +16,32 @@
|
|
|
16
16
|
"""compile custom kernel with ninja"""
|
|
17
17
|
|
|
18
18
|
import os
|
|
19
|
+
import re
|
|
19
20
|
import shlex
|
|
20
21
|
import subprocess
|
|
21
22
|
import sysconfig
|
|
22
23
|
import time
|
|
23
24
|
import stat
|
|
25
|
+
import json
|
|
24
26
|
from mindspore import log as logger
|
|
27
|
+
from mindspore.ops import CustomRegOp
|
|
28
|
+
from mindspore._c_expression import MSContext
|
|
29
|
+
|
|
30
|
+
OP_INFO_KEY_INPUT = "input"
|
|
31
|
+
OP_INFO_KEY_OUTPUT = "output"
|
|
32
|
+
OP_INFO_KEY_LIST = "list"
|
|
33
|
+
OP_INFO_KEY_ATTR = "attr"
|
|
34
|
+
OP_INFO_KEY_DTYPE = "dtype"
|
|
35
|
+
OP_INFO_KEY_FORMAT = "format"
|
|
36
|
+
|
|
37
|
+
REG_INFO_KEY_INPUTS = "inputs"
|
|
38
|
+
REG_INFO_KEY_OUTPUTS = "outputs"
|
|
39
|
+
REG_INFO_KEY_ATTRS = "attrs"
|
|
40
|
+
REG_INFO_KEY_ATTR = "attr"
|
|
41
|
+
REG_INFO_KEY_NAME = "name"
|
|
42
|
+
REG_INFO_KEY_PARAM_TYPE = "paramType"
|
|
43
|
+
REG_INFO_KEY_VALUE = "value"
|
|
44
|
+
REG_INFO_KEY_TYPE = "type"
|
|
25
45
|
|
|
26
46
|
|
|
27
47
|
class VersionManager:
|
|
@@ -48,7 +68,8 @@ class VersionManager:
|
|
|
48
68
|
|
|
49
69
|
return entry[0]
|
|
50
70
|
|
|
51
|
-
|
|
71
|
+
@staticmethod
|
|
72
|
+
def _update_hash(seed, value):
|
|
52
73
|
"""update hash value"""
|
|
53
74
|
# Good old boost::hash_combine
|
|
54
75
|
return seed ^ (hash(value) + 0x9e3779b9 + (seed << 6) + (seed >> 2))
|
|
@@ -140,12 +161,14 @@ class ExtensionBuilder:
|
|
|
140
161
|
locker.wait()
|
|
141
162
|
logger.info(f'Loading extension module {name}...')
|
|
142
163
|
|
|
143
|
-
|
|
164
|
+
@staticmethod
|
|
165
|
+
def _verify_ninja_availability():
|
|
144
166
|
"""Check ninja is available."""
|
|
145
167
|
try:
|
|
146
168
|
subprocess.check_output('ninja --version'.split())
|
|
147
|
-
except Exception:
|
|
148
|
-
|
|
169
|
+
except Exception as e:
|
|
170
|
+
logger.error("Ninja is required to load C++ extensions")
|
|
171
|
+
raise RuntimeError("Ninja is required to load C++ extensions") from e
|
|
149
172
|
|
|
150
173
|
def _write_ninja_file_and_build_library(self, module_name, sources, cflags, ldflags, include_paths):
|
|
151
174
|
"""Write ninja file and build library."""
|
|
@@ -158,21 +181,21 @@ class ExtensionBuilder:
|
|
|
158
181
|
logger.info(f'Building extension module {module_name}.')
|
|
159
182
|
self._run_ninja_build(module_name)
|
|
160
183
|
|
|
161
|
-
|
|
184
|
+
@staticmethod
|
|
185
|
+
def _write_ninja_file(fname, name, sources, extra_cflags, extra_ldflags, extra_include_paths):
|
|
162
186
|
"""Write ninja file."""
|
|
163
187
|
python_include_path = sysconfig.get_path('include', scheme='posix_prefix')
|
|
164
188
|
python_includes = [python_include_path] if python_include_path is not None else []
|
|
165
|
-
cflags = [
|
|
189
|
+
cflags = []
|
|
166
190
|
cflags += [f'-I{shlex.quote(os.path.abspath(include.strip()))}' for include in extra_include_paths]
|
|
167
191
|
cflags += [f'-isystem {shlex.quote(include)}' for include in python_includes]
|
|
168
|
-
cflags += ['-fPIC', '-std=c++17']
|
|
169
192
|
cflags += extra_cflags
|
|
170
193
|
cflags = [flag.strip() for flag in cflags]
|
|
171
194
|
|
|
172
195
|
# '/path/to/file.cpp' -> 'file'
|
|
173
196
|
objs = [os.path.splitext(os.path.basename(src))[0] + ".o" for src in sources]
|
|
174
197
|
sources = [os.path.abspath(file) for file in sources]
|
|
175
|
-
ldflags = [
|
|
198
|
+
ldflags = [flag.strip() for flag in extra_ldflags]
|
|
176
199
|
target = name + '.so'
|
|
177
200
|
|
|
178
201
|
config = ['ninja_required_version = 1.3']
|
|
@@ -226,6 +249,7 @@ class ExtensionBuilder:
|
|
|
226
249
|
so_file = os.path.join(self.build_dir, f"{module_name}.so")
|
|
227
250
|
if os.path.exists(so_file):
|
|
228
251
|
os.remove(so_file)
|
|
252
|
+
logger.error(msg)
|
|
229
253
|
raise RuntimeError(msg) from e
|
|
230
254
|
|
|
231
255
|
def build(self, module_name, sources, extra_cflags=None, extra_ldflags=None, extra_include_paths=None):
|
|
@@ -233,3 +257,646 @@ class ExtensionBuilder:
|
|
|
233
257
|
src = [sources] if isinstance(sources, str) else sources
|
|
234
258
|
self._compile(module_name, src, extra_cflags, extra_ldflags, extra_include_paths)
|
|
235
259
|
return os.path.join(self.build_dir, f"{module_name}.so")
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
class CustomCodeGenerator:
|
|
263
|
+
"""A class to generate custom C++ code based on input and output types."""
|
|
264
|
+
|
|
265
|
+
def __init__(self):
|
|
266
|
+
"""Initialize the CustomCodeGenerator with the header content."""
|
|
267
|
+
self.header = """
|
|
268
|
+
#include <vector>
|
|
269
|
+
#include "acl/acl_base.h"
|
|
270
|
+
|
|
271
|
+
typedef struct aclOpExecutor aclOpExecutor;
|
|
272
|
+
typedef struct aclTensor aclTensor;
|
|
273
|
+
typedef struct aclScalar aclScalar;
|
|
274
|
+
typedef struct aclIntArray aclIntArray;
|
|
275
|
+
typedef struct aclFloatArray aclFloatArray;
|
|
276
|
+
typedef struct aclBoolArray aclBoolArray;
|
|
277
|
+
typedef struct aclTensorList aclTensorList;
|
|
278
|
+
typedef struct aclScalarList aclScalarList;
|
|
279
|
+
""".strip()
|
|
280
|
+
|
|
281
|
+
self.supported_input_scalar_type = ['int64_t', 'uint64_t', 'float', 'double', 'bool', 'aclDataType']
|
|
282
|
+
self.supported_input_pointer_type = ['aclTensor*', 'aclScalar*', 'aclIntArray*', 'aclFloatArray*',
|
|
283
|
+
'aclBoolArray*',
|
|
284
|
+
'aclTensorList*']
|
|
285
|
+
self.supported_input_type = self.supported_input_pointer_type + self.supported_input_scalar_type
|
|
286
|
+
self.supported_output_type = ["aclTensor*", "aclTensorList*"]
|
|
287
|
+
|
|
288
|
+
def _get_input_output_types(self, reg_info):
|
|
289
|
+
"""
|
|
290
|
+
Extracts input and output types from registration information.
|
|
291
|
+
|
|
292
|
+
Args:
|
|
293
|
+
reg_info (dict): Registration information containing input, output, and attribute details.
|
|
294
|
+
|
|
295
|
+
Returns:
|
|
296
|
+
tuple: A tuple containing two lists, the first being input types and the second being output types.
|
|
297
|
+
"""
|
|
298
|
+
inputs = reg_info.get(REG_INFO_KEY_INPUTS, [])
|
|
299
|
+
outputs = reg_info.get(REG_INFO_KEY_OUTPUTS, [])
|
|
300
|
+
attrs = reg_info.get(REG_INFO_KEY_ATTR, [])
|
|
301
|
+
|
|
302
|
+
inputs_types = []
|
|
303
|
+
outputs_types = []
|
|
304
|
+
for input in inputs:
|
|
305
|
+
if input.get(REG_INFO_KEY_PARAM_TYPE) == "dynamic":
|
|
306
|
+
inputs_types.append("aclTensorList*")
|
|
307
|
+
else:
|
|
308
|
+
inputs_types.append("aclTensor*")
|
|
309
|
+
for attr in attrs:
|
|
310
|
+
inputs_types.append(CustomCodeGenerator._get_type_declaration(attr.get(REG_INFO_KEY_TYPE)))
|
|
311
|
+
|
|
312
|
+
for output in outputs:
|
|
313
|
+
if output.get(REG_INFO_KEY_PARAM_TYPE) == "dynamic":
|
|
314
|
+
outputs_types.append("aclTensorList*")
|
|
315
|
+
else:
|
|
316
|
+
outputs_types.append("aclTensor*")
|
|
317
|
+
|
|
318
|
+
return inputs_types, outputs_types
|
|
319
|
+
|
|
320
|
+
def get_api_types_by_reg_info(self, reg_info):
|
|
321
|
+
"""
|
|
322
|
+
Retrieves API types based on registration information.
|
|
323
|
+
|
|
324
|
+
Combines input types, output types, and additional parameter types.
|
|
325
|
+
|
|
326
|
+
Args:
|
|
327
|
+
reg_info (dict): Registration information.
|
|
328
|
+
|
|
329
|
+
Returns:
|
|
330
|
+
list: A list of API types.
|
|
331
|
+
"""
|
|
332
|
+
inputs_types, outputs_types = self._get_input_output_types(reg_info)
|
|
333
|
+
return inputs_types + outputs_types + ['int64_t*', 'aclOpExecutor**']
|
|
334
|
+
|
|
335
|
+
def generate_callback_by_reg_info(self, func_name, reg_info):
|
|
336
|
+
"""
|
|
337
|
+
Generates a callback function based on registration information.
|
|
338
|
+
|
|
339
|
+
Args:
|
|
340
|
+
func_name (str): Name of the function.
|
|
341
|
+
reg_info (dict): Registration information.
|
|
342
|
+
|
|
343
|
+
Returns:
|
|
344
|
+
str: Generated callback code.
|
|
345
|
+
"""
|
|
346
|
+
inputs_types, outputs_types = self._get_input_output_types(reg_info)
|
|
347
|
+
return self._generate_callback(func_name, inputs_types, outputs_types)
|
|
348
|
+
|
|
349
|
+
def generate_callback_by_types(self, func_name, reg_info, input_output_types):
|
|
350
|
+
"""
|
|
351
|
+
Generates a callback function based on types and registration information.
|
|
352
|
+
|
|
353
|
+
Validates the consistency between registration info and input/output types.
|
|
354
|
+
|
|
355
|
+
Args:
|
|
356
|
+
func_name (str): Name of the function.
|
|
357
|
+
reg_info (dict): Registration information.
|
|
358
|
+
input_output_types (list): List of input and output types.
|
|
359
|
+
|
|
360
|
+
Returns:
|
|
361
|
+
str: Generated callback code.
|
|
362
|
+
|
|
363
|
+
Raises:
|
|
364
|
+
RuntimeError: If there's inconsistency between reg info and input/output types.
|
|
365
|
+
"""
|
|
366
|
+
inputs_types, outputs_types = self._get_input_output_types(reg_info)
|
|
367
|
+
input_size = len(inputs_types)
|
|
368
|
+
output_size = len(outputs_types)
|
|
369
|
+
aclnn_api_input_size = len(input_output_types)
|
|
370
|
+
func_params_len = input_size + output_size + 2
|
|
371
|
+
if func_params_len != len(input_output_types):
|
|
372
|
+
raise RuntimeError(
|
|
373
|
+
f"Reg info input size: {func_params_len} is not equal to aclnn api input size {aclnn_api_input_size}")
|
|
374
|
+
reg_info_input_output_type = inputs_types + outputs_types
|
|
375
|
+
for i, typ in enumerate(reg_info_input_output_type):
|
|
376
|
+
if typ != input_output_types[i]:
|
|
377
|
+
logger.warning(
|
|
378
|
+
"Reg info type {} is not same with function prototype {}".format(typ,
|
|
379
|
+
input_output_types[i]))
|
|
380
|
+
|
|
381
|
+
return self._generate_callback(func_name, input_output_types[:input_size],
|
|
382
|
+
input_output_types[input_size:output_size + input_size])
|
|
383
|
+
|
|
384
|
+
def _generate_callback_inputs(self, inputs_types):
|
|
385
|
+
"""
|
|
386
|
+
Generates code for callback inputs based on input types.
|
|
387
|
+
|
|
388
|
+
Args:
|
|
389
|
+
inputs_types (list): List of input types.
|
|
390
|
+
|
|
391
|
+
Returns:
|
|
392
|
+
list: List of generated input code strings.
|
|
393
|
+
|
|
394
|
+
Raises:
|
|
395
|
+
RuntimeError: If unsupported input type is encountered.
|
|
396
|
+
"""
|
|
397
|
+
inputs_code = []
|
|
398
|
+
|
|
399
|
+
for i, typ in enumerate(inputs_types):
|
|
400
|
+
if typ not in self.supported_input_type:
|
|
401
|
+
raise RuntimeError(
|
|
402
|
+
f"Unsupported input type: {typ}, supported input types are: {self.supported_input_type}")
|
|
403
|
+
|
|
404
|
+
if typ in self.supported_input_scalar_type:
|
|
405
|
+
typ = typ + "*"
|
|
406
|
+
inputs_code.append(f" {typ} input{i} = static_cast<{typ}>(inputs[{i}])")
|
|
407
|
+
return inputs_code
|
|
408
|
+
|
|
409
|
+
def _generate_callback_outputs(self, outputs_types):
|
|
410
|
+
"""
|
|
411
|
+
Generates code for callback outputs based on output types.
|
|
412
|
+
|
|
413
|
+
Args:
|
|
414
|
+
outputs_types (list): List of output types.
|
|
415
|
+
|
|
416
|
+
Returns:
|
|
417
|
+
list: List of generated output code strings.
|
|
418
|
+
|
|
419
|
+
Raises:
|
|
420
|
+
RuntimeError: If unsupported output type is encountered.
|
|
421
|
+
"""
|
|
422
|
+
outputs_code = []
|
|
423
|
+
for i, typ in enumerate(outputs_types):
|
|
424
|
+
if typ not in self.supported_output_type:
|
|
425
|
+
raise RuntimeError(
|
|
426
|
+
f"Unsupported output type: {typ}, supported output types are: {self.supported_output_type}")
|
|
427
|
+
outputs_code.append(f" {typ} output{i} = static_cast<{typ}>(outputs[{i}])")
|
|
428
|
+
return outputs_code
|
|
429
|
+
|
|
430
|
+
def _generate_callback_func_params(self, inputs_types, outputs_types):
|
|
431
|
+
"""
|
|
432
|
+
Generates function parameters for callback based on input and output types.
|
|
433
|
+
|
|
434
|
+
Args:
|
|
435
|
+
inputs_types (list): List of input types.
|
|
436
|
+
outputs_types (list): List of output types.
|
|
437
|
+
|
|
438
|
+
Returns:
|
|
439
|
+
list: List of generated function parameter strings.
|
|
440
|
+
|
|
441
|
+
Raises:
|
|
442
|
+
RuntimeError: If unsupported input or output type is encountered.
|
|
443
|
+
"""
|
|
444
|
+
func_params = []
|
|
445
|
+
for i, _ in enumerate(inputs_types):
|
|
446
|
+
typ = inputs_types[i]
|
|
447
|
+
if typ in self.supported_input_pointer_type:
|
|
448
|
+
func_params.append(f"input{i}")
|
|
449
|
+
elif typ in self.supported_input_scalar_type:
|
|
450
|
+
func_params.append(f"*input{i}")
|
|
451
|
+
else:
|
|
452
|
+
raise RuntimeError(
|
|
453
|
+
f"Unsupported input type: {typ}, supported input types are: {self.supported_input_type}")
|
|
454
|
+
|
|
455
|
+
for i, _ in enumerate(outputs_types):
|
|
456
|
+
typ = outputs_types[i]
|
|
457
|
+
if typ in self.supported_output_type:
|
|
458
|
+
func_params.append(f"output{i}")
|
|
459
|
+
else:
|
|
460
|
+
raise RuntimeError(
|
|
461
|
+
f"Unsupported output type: {typ}, supported output types are: {self.supported_output_type}")
|
|
462
|
+
|
|
463
|
+
func_params.append("workspace_size")
|
|
464
|
+
func_params.append("executor")
|
|
465
|
+
return func_params
|
|
466
|
+
|
|
467
|
+
def _generate_callback(self, func_name, inputs_types, outputs_types):
|
|
468
|
+
"""Generate C++ code based on the provided function name, input types, and output types.
|
|
469
|
+
|
|
470
|
+
Args:
|
|
471
|
+
func_name (str): The name of the function to generate.
|
|
472
|
+
inputs_types (str): A comma-separated string of input types.
|
|
473
|
+
outputs_types (str): A comma-separated string of output types.
|
|
474
|
+
|
|
475
|
+
Returns:
|
|
476
|
+
str: The generated C++ callback func.
|
|
477
|
+
"""
|
|
478
|
+
|
|
479
|
+
inputs_code = self._generate_callback_inputs(inputs_types)
|
|
480
|
+
outputs_code = self._generate_callback_outputs(outputs_types)
|
|
481
|
+
func_params = self._generate_callback_func_params(inputs_types, outputs_types)
|
|
482
|
+
|
|
483
|
+
input_declarations = ', '.join(inputs_types)
|
|
484
|
+
output_declarations = ', '.join(outputs_types)
|
|
485
|
+
|
|
486
|
+
code = """
|
|
487
|
+
{header}
|
|
488
|
+
|
|
489
|
+
extern "C" int {func_name}GetWorkSpaceSize(void *func_ptr, std::vector<void *> inputs, std::vector<void *> outputs,
|
|
490
|
+
uint64_t *workspace_size, aclOpExecutor **executor) {{
|
|
491
|
+
using FuncType = int (*)({input_declarations}, {output_declarations}, uint64_t *, aclOpExecutor **);
|
|
492
|
+
auto func = reinterpret_cast<FuncType>(func_ptr);
|
|
493
|
+
{inputs_code}
|
|
494
|
+
{outputs_code}
|
|
495
|
+
return func({func_params});
|
|
496
|
+
}}""".format(
|
|
497
|
+
header=self.header, func_name=func_name, input_declarations=input_declarations,
|
|
498
|
+
output_declarations=output_declarations, inputs_code=";\n".join(inputs_code) + ";",
|
|
499
|
+
outputs_code=";\n".join(outputs_code) + ";", func_params=", ".join(func_params))
|
|
500
|
+
return code
|
|
501
|
+
|
|
502
|
+
@staticmethod
|
|
503
|
+
def _get_type_declaration(typ):
|
|
504
|
+
"""Get the C++ type declaration based on the type.
|
|
505
|
+
|
|
506
|
+
Args:
|
|
507
|
+
typ (str): The type for which to get the declaration.
|
|
508
|
+
|
|
509
|
+
Returns:
|
|
510
|
+
str: The C++ type declaration.
|
|
511
|
+
"""
|
|
512
|
+
type_map = {
|
|
513
|
+
"tensor": "aclTensor*",
|
|
514
|
+
"int": "int64_t",
|
|
515
|
+
"float": "float",
|
|
516
|
+
"double": "double",
|
|
517
|
+
"bool": "bool",
|
|
518
|
+
"number": "aclScalar*",
|
|
519
|
+
"listInt": "aclIntArray*",
|
|
520
|
+
"listBool": "aclBoolArray*",
|
|
521
|
+
"listFloat": "aclFloatArray*"
|
|
522
|
+
}
|
|
523
|
+
try:
|
|
524
|
+
return type_map[typ]
|
|
525
|
+
except KeyError as e:
|
|
526
|
+
raise RuntimeError(f"Unsupported type: {typ}") from e
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
class CustomInfoGenerator:
|
|
530
|
+
"""
|
|
531
|
+
A utility class for generating custom operator registration information.
|
|
532
|
+
|
|
533
|
+
This class is designed to parse operator configuration from JSON files and
|
|
534
|
+
generate registration information compatible with the Ascend platform.
|
|
535
|
+
"""
|
|
536
|
+
|
|
537
|
+
def __init__(self, op_name):
|
|
538
|
+
"""
|
|
539
|
+
Initialize a new instance of CustomInfoGenerator.
|
|
540
|
+
|
|
541
|
+
Args:
|
|
542
|
+
op_name (str): Name of the operator to generate registration info for.
|
|
543
|
+
"""
|
|
544
|
+
self.ori_op_name = op_name
|
|
545
|
+
self.prefix = "aclnn"
|
|
546
|
+
self.pure_op_name = self._get_pure_name(op_name)
|
|
547
|
+
self.prefix_op_name = self._get_prefix_name(op_name)
|
|
548
|
+
self.aclnn_api_file_name = CustomInfoGenerator._get_aclnn_api_file_name(self.prefix_op_name)
|
|
549
|
+
|
|
550
|
+
self.env_ascend_opp_path = os.getenv("ASCEND_OPP_PATH")
|
|
551
|
+
self.env_ascend_custom_opp_path = os.getenv("ASCEND_CUSTOM_OPP_PATH")
|
|
552
|
+
|
|
553
|
+
self.op_info_paths = []
|
|
554
|
+
self.target_json_path = ""
|
|
555
|
+
self.op_info = ""
|
|
556
|
+
|
|
557
|
+
self.aclnn_api_paths = []
|
|
558
|
+
self.aclnn_api = ""
|
|
559
|
+
|
|
560
|
+
@staticmethod
|
|
561
|
+
def _get_aclnn_api_file_name(op_name):
|
|
562
|
+
""" Converts a camel-case operation name to an underscore-separated filename with a .h suffix."""
|
|
563
|
+
name = re.sub(r'(.)([A-Z][a-z]+)', r'\1_\2', op_name)
|
|
564
|
+
name = re.sub(r'([a-z0-9])([A-Z])', r'\1_\2', name)
|
|
565
|
+
return name.lower() + ".h"
|
|
566
|
+
|
|
567
|
+
def _get_pure_name(self, op_name):
|
|
568
|
+
"""Remove the "aclnn_" prefix from the operator name if it exists."""
|
|
569
|
+
if not op_name:
|
|
570
|
+
raise ValueError("op_name cannot be None or empty")
|
|
571
|
+
|
|
572
|
+
if op_name.startswith(self.prefix):
|
|
573
|
+
return op_name[len(self.prefix):]
|
|
574
|
+
return op_name
|
|
575
|
+
|
|
576
|
+
def _get_prefix_name(self, op_name):
|
|
577
|
+
"""Add the "aclnn" prefix to the operator name if it doesn't already exist."""
|
|
578
|
+
if not op_name:
|
|
579
|
+
raise ValueError("op_name cannot be None or empty")
|
|
580
|
+
|
|
581
|
+
if op_name.startswith(self.prefix):
|
|
582
|
+
return op_name
|
|
583
|
+
return self.prefix + op_name
|
|
584
|
+
|
|
585
|
+
def _get_aclnn_api_from_file(self, dir_path):
|
|
586
|
+
"""
|
|
587
|
+
Attempts to extract the AclNN API content from a specified directory path.
|
|
588
|
+
|
|
589
|
+
Args:
|
|
590
|
+
dir_path (str): Directory path to search for the AclNN API file.
|
|
591
|
+
|
|
592
|
+
Returns:
|
|
593
|
+
bool: True if the API content is successfully extracted, False otherwise.
|
|
594
|
+
|
|
595
|
+
Raises:
|
|
596
|
+
ValueError: If the start or end marker for the API function is not found.
|
|
597
|
+
"""
|
|
598
|
+
self.aclnn_api_paths.append(dir_path)
|
|
599
|
+
file_path = os.path.join(dir_path, self.aclnn_api_file_name)
|
|
600
|
+
if not os.path.exists(file_path):
|
|
601
|
+
return False
|
|
602
|
+
|
|
603
|
+
with open(file_path, 'r') as file:
|
|
604
|
+
content = file.read()
|
|
605
|
+
|
|
606
|
+
start_marker = "aclnnStatus " + self.prefix_op_name + "GetWorkspaceSize("
|
|
607
|
+
end_marker = ");"
|
|
608
|
+
|
|
609
|
+
start_pos = content.find(start_marker)
|
|
610
|
+
if start_pos == -1:
|
|
611
|
+
raise ValueError(f"Can not find function [{start_marker}] in file [{file_path}]")
|
|
612
|
+
|
|
613
|
+
end_pos = content.find(end_marker, start_pos)
|
|
614
|
+
if end_pos == -1:
|
|
615
|
+
raise ValueError(f"Can not find function [{start_marker}] in file [{file_path}]")
|
|
616
|
+
|
|
617
|
+
self.aclnn_api = content[start_pos:end_pos + len(end_marker)]
|
|
618
|
+
return True
|
|
619
|
+
|
|
620
|
+
def _get_aclnn_api_params(self):
|
|
621
|
+
"""
|
|
622
|
+
Searches for the AaclNN API file in multiple predefined paths and extracts its content.
|
|
623
|
+
|
|
624
|
+
Raises:
|
|
625
|
+
RuntimeError: If the AclNN API file is not found in any of the specified paths.
|
|
626
|
+
"""
|
|
627
|
+
if self.env_ascend_custom_opp_path is not None:
|
|
628
|
+
custom_opp_paths = self.env_ascend_custom_opp_path.split(":")
|
|
629
|
+
for custom_opp_path in custom_opp_paths:
|
|
630
|
+
aclnn_api_file_path = os.path.join(custom_opp_path, "op_api/include/")
|
|
631
|
+
if self._get_aclnn_api_from_file(aclnn_api_file_path):
|
|
632
|
+
return
|
|
633
|
+
|
|
634
|
+
opp_vendors_path = os.path.join(self.env_ascend_opp_path, "vendors")
|
|
635
|
+
opp_vendors_config_path = os.path.join(opp_vendors_path, "config.ini")
|
|
636
|
+
if os.path.exists(opp_vendors_config_path):
|
|
637
|
+
priorities = CustomInfoGenerator._parse_load_priority(opp_vendors_config_path)
|
|
638
|
+
for priority in priorities:
|
|
639
|
+
aclnn_api_file_path = os.path.join(opp_vendors_path, priority.strip(), "op_api/include/")
|
|
640
|
+
if self._get_aclnn_api_from_file(aclnn_api_file_path):
|
|
641
|
+
return
|
|
642
|
+
aclnn_api_file_path = os.path.join(self.env_ascend_opp_path,
|
|
643
|
+
"built-in/op_impl/ai_core/tbe/op_api/include/aclnnop")
|
|
644
|
+
if self._get_aclnn_api_from_file(aclnn_api_file_path):
|
|
645
|
+
return
|
|
646
|
+
|
|
647
|
+
paths = ",".join(str(item) for item in self.aclnn_api_paths)
|
|
648
|
+
logger.warning(f"Cannot find file [{self.aclnn_api_file_name}] in paths [{paths}]")
|
|
649
|
+
|
|
650
|
+
def get_aclnn_api_types(self):
|
|
651
|
+
"""
|
|
652
|
+
Extracts and returns the input types from the AclNN API function declaration.
|
|
653
|
+
|
|
654
|
+
Args:
|
|
655
|
+
None
|
|
656
|
+
|
|
657
|
+
Returns:
|
|
658
|
+
list: A list of input types extracted from the AclNN API function.
|
|
659
|
+
|
|
660
|
+
Raises:
|
|
661
|
+
RuntimeError: If the AclNN API content is empty or if the input types cannot be parsed.
|
|
662
|
+
"""
|
|
663
|
+
self._get_aclnn_api_params()
|
|
664
|
+
param_types = []
|
|
665
|
+
if self.aclnn_api == "":
|
|
666
|
+
return param_types
|
|
667
|
+
|
|
668
|
+
# step1: get string by '()'
|
|
669
|
+
param_section = re.search(r'\((.*?)\)', self.aclnn_api, re.DOTALL).group(1)
|
|
670
|
+
|
|
671
|
+
# step2: split by ','
|
|
672
|
+
params = re.split(r',\s*', param_section)
|
|
673
|
+
|
|
674
|
+
# step3: get type
|
|
675
|
+
for param in params:
|
|
676
|
+
param = param.replace('const ', '')
|
|
677
|
+
type_part = re.search(r'^\s*(\w+\s*\*+|\w+)', param).group(1)
|
|
678
|
+
type_part = type_part.replace(' ', '')
|
|
679
|
+
param_types.append(type_part)
|
|
680
|
+
return param_types
|
|
681
|
+
|
|
682
|
+
@staticmethod
|
|
683
|
+
def _parse_load_priority(config_file_path):
|
|
684
|
+
"""
|
|
685
|
+
Parse the load priority from a configuration file.
|
|
686
|
+
|
|
687
|
+
Extracts the load_priority configuration item from the specified file
|
|
688
|
+
and splits it into a list of priorities.
|
|
689
|
+
|
|
690
|
+
Args:
|
|
691
|
+
config_file_path (str): Path to the configuration file.
|
|
692
|
+
|
|
693
|
+
Returns:
|
|
694
|
+
list: List of load priorities.
|
|
695
|
+
"""
|
|
696
|
+
load_priority = ''
|
|
697
|
+
with open(config_file_path, 'r', encoding='utf-8') as file:
|
|
698
|
+
for line in file:
|
|
699
|
+
line = line.strip()
|
|
700
|
+
if line.startswith('load_priority'):
|
|
701
|
+
# Parse key-value pair from the line
|
|
702
|
+
key, value = line.split('=', 1)
|
|
703
|
+
key = key.strip()
|
|
704
|
+
value = value.strip()
|
|
705
|
+
if key.lower() == 'load_priority':
|
|
706
|
+
load_priority = value
|
|
707
|
+
break
|
|
708
|
+
# Split the priority string into a list
|
|
709
|
+
priorities = [item.strip() for item in load_priority.split(',') if item.strip()]
|
|
710
|
+
return priorities
|
|
711
|
+
|
|
712
|
+
def _get_op_info_from_file(self, op_info_path):
|
|
713
|
+
"""
|
|
714
|
+
Retrieve operator information from a JSON file.
|
|
715
|
+
|
|
716
|
+
Checks if the specified JSON file exists and attempts to extract
|
|
717
|
+
operator information from it. If the operator is found, records
|
|
718
|
+
the file path and operator information.
|
|
719
|
+
|
|
720
|
+
Args:
|
|
721
|
+
op_info_path (str): Path to the JSON file.
|
|
722
|
+
|
|
723
|
+
Returns:
|
|
724
|
+
bool: Whether the operator information was found.
|
|
725
|
+
"""
|
|
726
|
+
self.op_info_paths.append(op_info_path)
|
|
727
|
+
if not os.path.exists(op_info_path):
|
|
728
|
+
logger.debug("Custom config path not found: %s", op_info_path)
|
|
729
|
+
return False
|
|
730
|
+
|
|
731
|
+
with open(op_info_path, 'r', encoding='utf-8') as file:
|
|
732
|
+
op_json_data = json.load(file)
|
|
733
|
+
|
|
734
|
+
if self.pure_op_name in op_json_data:
|
|
735
|
+
self.target_json_path = op_info_path
|
|
736
|
+
self.op_info = op_json_data[self.pure_op_name]
|
|
737
|
+
return True
|
|
738
|
+
return False
|
|
739
|
+
|
|
740
|
+
def _get_op_json(self):
|
|
741
|
+
"""
|
|
742
|
+
Retrieve the JSON configuration for the operator.
|
|
743
|
+
|
|
744
|
+
Searches for the operator's JSON configuration in the following order:
|
|
745
|
+
1. Custom OPP path (from ASCEND_CUSTOM_OPP_PATH environment variable)
|
|
746
|
+
2. Vendor OPP path (from ASCEND_OPP_PATH's vendors directory)
|
|
747
|
+
3. Built-in OPP path (from ASCEND_OPP_PATH's built-in directory)
|
|
748
|
+
|
|
749
|
+
Raises:
|
|
750
|
+
RuntimeError: If the operator is not found in any JSON file.
|
|
751
|
+
"""
|
|
752
|
+
|
|
753
|
+
soc_version = MSContext.get_instance().get_ascend_soc_version()
|
|
754
|
+
op_info_json = f"aic-{soc_version}-ops-info.json"
|
|
755
|
+
op_info_json_path = os.path.join("op_impl/ai_core/tbe/config", soc_version, op_info_json)
|
|
756
|
+
|
|
757
|
+
if self.env_ascend_custom_opp_path is not None:
|
|
758
|
+
custom_opp_paths = self.env_ascend_custom_opp_path.split(":")
|
|
759
|
+
for custom_opp_path in custom_opp_paths:
|
|
760
|
+
op_info_path = os.path.join(custom_opp_path, op_info_json_path)
|
|
761
|
+
if self._get_op_info_from_file(op_info_path):
|
|
762
|
+
return
|
|
763
|
+
|
|
764
|
+
opp_vendors_path = os.path.join(self.env_ascend_opp_path, "vendors")
|
|
765
|
+
opp_vendors_config_path = os.path.join(opp_vendors_path, "config.ini")
|
|
766
|
+
if os.path.exists(opp_vendors_config_path):
|
|
767
|
+
priorities = CustomInfoGenerator._parse_load_priority(opp_vendors_config_path)
|
|
768
|
+
for priority in priorities:
|
|
769
|
+
op_info_path = os.path.join(opp_vendors_path, priority.strip(), op_info_json_path)
|
|
770
|
+
if self._get_op_info_from_file(op_info_path):
|
|
771
|
+
return
|
|
772
|
+
opp_info_path = os.path.join(self.env_ascend_opp_path, "built-in", op_info_json_path)
|
|
773
|
+
if self._get_op_info_from_file(opp_info_path):
|
|
774
|
+
return
|
|
775
|
+
|
|
776
|
+
paths = ",".join(str(item) for item in self.op_info_paths)
|
|
777
|
+
raise RuntimeError(f"Cannot find operator [{self.pure_op_name}] in JSON files [{paths}]")
|
|
778
|
+
|
|
779
|
+
def _generate_reg_info(self):
|
|
780
|
+
"""
|
|
781
|
+
Generate registration information for the operator.
|
|
782
|
+
|
|
783
|
+
Extracts input, output, and attribute information from the parsed
|
|
784
|
+
operator data and constructs a registration information dictionary.
|
|
785
|
+
|
|
786
|
+
Returns:
|
|
787
|
+
dict: Registration information for the operator.
|
|
788
|
+
"""
|
|
789
|
+
self._get_op_json()
|
|
790
|
+
|
|
791
|
+
inputs = []
|
|
792
|
+
outputs = []
|
|
793
|
+
|
|
794
|
+
# Extract input and output information
|
|
795
|
+
for key in sorted(self.op_info.keys()):
|
|
796
|
+
if key.startswith(OP_INFO_KEY_INPUT):
|
|
797
|
+
inputs.append(self.op_info[key])
|
|
798
|
+
elif key.startswith(OP_INFO_KEY_OUTPUT):
|
|
799
|
+
outputs.append(self.op_info[key])
|
|
800
|
+
|
|
801
|
+
attrs = []
|
|
802
|
+
# Process attributes if available
|
|
803
|
+
if (OP_INFO_KEY_ATTR in self.op_info and
|
|
804
|
+
OP_INFO_KEY_LIST in self.op_info[OP_INFO_KEY_ATTR]):
|
|
805
|
+
attr_list = self.op_info[OP_INFO_KEY_ATTR][OP_INFO_KEY_LIST]
|
|
806
|
+
for attr in attr_list.split(","):
|
|
807
|
+
attr_key = f"attr_{attr}"
|
|
808
|
+
if attr_key in self.op_info:
|
|
809
|
+
attr_info = self.op_info[attr_key]
|
|
810
|
+
attr_info[REG_INFO_KEY_NAME] = attr
|
|
811
|
+
attrs.append(attr_info)
|
|
812
|
+
else:
|
|
813
|
+
raise KeyError(
|
|
814
|
+
f"Attr key '{attr_key}' not found in operator '{self.pure_op_name}' "
|
|
815
|
+
f"from JSON file '{self.target_json_path}'")
|
|
816
|
+
|
|
817
|
+
reg_info = {
|
|
818
|
+
REG_INFO_KEY_INPUTS: inputs,
|
|
819
|
+
REG_INFO_KEY_OUTPUTS: outputs,
|
|
820
|
+
REG_INFO_KEY_ATTRS: attrs
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
return reg_info
|
|
824
|
+
|
|
825
|
+
@staticmethod
|
|
826
|
+
def _get_dtype_format(dtype, format_str):
|
|
827
|
+
"""
|
|
828
|
+
Combine data type and format into a tuple.
|
|
829
|
+
|
|
830
|
+
Args:
|
|
831
|
+
dtype (str): Data type string.
|
|
832
|
+
format_str (str): Format string.
|
|
833
|
+
|
|
834
|
+
Returns:
|
|
835
|
+
tuple: (dtype, format) tuple.
|
|
836
|
+
"""
|
|
837
|
+
if dtype == "float":
|
|
838
|
+
dtype = "float32"
|
|
839
|
+
if format_str == "ND":
|
|
840
|
+
format_str = "DefaultFormat"
|
|
841
|
+
return (dtype, format_str)
|
|
842
|
+
|
|
843
|
+
def generate_custom_reg_op(self):
|
|
844
|
+
"""
|
|
845
|
+
Generate a custom registered operator based on the registration info.
|
|
846
|
+
|
|
847
|
+
Constructs a CustomRegOp instance with inputs, outputs, and attributes
|
|
848
|
+
populated from the parsed operator information.
|
|
849
|
+
|
|
850
|
+
Returns:
|
|
851
|
+
dict: Registered operator information.
|
|
852
|
+
"""
|
|
853
|
+
reg_info = self._generate_reg_info()
|
|
854
|
+
custom_reg_op = CustomRegOp(self.ori_op_name)
|
|
855
|
+
|
|
856
|
+
# Process inputs
|
|
857
|
+
inputs_types = []
|
|
858
|
+
inputs_formats = []
|
|
859
|
+
for i, input_data in enumerate(reg_info[REG_INFO_KEY_INPUTS]):
|
|
860
|
+
inputs_types.append(input_data.get(OP_INFO_KEY_DTYPE, "float16").split(","))
|
|
861
|
+
inputs_formats.append(input_data.get(OP_INFO_KEY_FORMAT, "DefaultFormat").split(","))
|
|
862
|
+
custom_reg_op.input(i, input_data[REG_INFO_KEY_NAME], input_data[REG_INFO_KEY_PARAM_TYPE])
|
|
863
|
+
|
|
864
|
+
# Process outputs
|
|
865
|
+
outputs_types = []
|
|
866
|
+
outputs_formats = []
|
|
867
|
+
for i, output_data in enumerate(reg_info[REG_INFO_KEY_OUTPUTS]):
|
|
868
|
+
outputs_types.append(output_data.get(OP_INFO_KEY_DTYPE, "float16").split(","))
|
|
869
|
+
outputs_formats.append(output_data.get(OP_INFO_KEY_FORMAT, "DefaultFormat").split(","))
|
|
870
|
+
custom_reg_op.output(i, output_data[REG_INFO_KEY_NAME], output_data[REG_INFO_KEY_PARAM_TYPE])
|
|
871
|
+
|
|
872
|
+
# Process attributes
|
|
873
|
+
for attr_data in reg_info[REG_INFO_KEY_ATTRS]:
|
|
874
|
+
custom_reg_op.attr(
|
|
875
|
+
attr_data.get(REG_INFO_KEY_NAME, ""),
|
|
876
|
+
attr_data.get(REG_INFO_KEY_PARAM_TYPE, ""),
|
|
877
|
+
attr_data.get(REG_INFO_KEY_TYPE, ""),
|
|
878
|
+
attr_data.get(REG_INFO_KEY_VALUE, "")
|
|
879
|
+
)
|
|
880
|
+
|
|
881
|
+
# Configure data types and formats
|
|
882
|
+
for dtype_format_index in range(len(inputs_types[0])):
|
|
883
|
+
op_dtypes_formats = []
|
|
884
|
+
# Process input data types and formats
|
|
885
|
+
for input_index, _ in enumerate(inputs_types):
|
|
886
|
+
dtype = inputs_types[input_index][dtype_format_index]
|
|
887
|
+
format_str = inputs_formats[input_index][dtype_format_index] if dtype_format_index < len(
|
|
888
|
+
inputs_formats[input_index]) else "DefaultFormat"
|
|
889
|
+
dtype_format = CustomInfoGenerator._get_dtype_format(dtype, format_str)
|
|
890
|
+
op_dtypes_formats.append(dtype_format)
|
|
891
|
+
|
|
892
|
+
# Process output data types and formats
|
|
893
|
+
for output_index, _ in enumerate(outputs_types):
|
|
894
|
+
dtype = outputs_types[output_index][dtype_format_index]
|
|
895
|
+
format_str = outputs_formats[output_index][dtype_format_index] if dtype_format_index < len(
|
|
896
|
+
outputs_formats[output_index]) else "DefaultFormat"
|
|
897
|
+
dtype_format = CustomInfoGenerator._get_dtype_format(dtype, format_str)
|
|
898
|
+
op_dtypes_formats.append(dtype_format)
|
|
899
|
+
|
|
900
|
+
custom_reg_op.dtype_format(*op_dtypes_formats)
|
|
901
|
+
|
|
902
|
+
return custom_reg_op.target("Ascend").get_op_info()
|