mindspore 2.6.0__cp39-cp39-win_amd64.whl → 2.7.0rc1__cp39-cp39-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mindspore might be problematic. Click here for more details.
- mindspore/.commit_id +1 -1
- mindspore/__init__.py +1 -1
- mindspore/_c_dataengine.cp39-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp39-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp39-win_amd64.pyd +0 -0
- mindspore/_checkparam.py +40 -9
- mindspore/{_deprecated → _extends/optimize}/__init__.py +9 -3
- mindspore/_extends/optimize/cell_utils.py +96 -0
- mindspore/_extends/parse/__init__.py +2 -2
- mindspore/_extends/parse/compile_config.py +44 -22
- mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +1 -1
- mindspore/_extends/parse/parser.py +36 -61
- mindspore/_extends/parse/resources.py +39 -0
- mindspore/_extends/parse/standard_method.py +32 -13
- mindspore/_extends/parse/trope.py +8 -1
- mindspore/_extends/pijit/__init__.py +1 -2
- mindspore/amp.py +4 -4
- 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/common/__init__.py +27 -2
- 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 +76 -15
- mindspore/common/api.py +193 -112
- mindspore/common/dtype.py +21 -11
- mindspore/common/dump.py +10 -15
- mindspore/common/generator.py +2 -3
- mindspore/common/hook_handle.py +11 -2
- mindspore/common/jit_config.py +1 -1
- mindspore/common/jit_trace.py +84 -105
- mindspore/common/parameter.py +26 -12
- mindspore/common/recompute.py +3 -3
- mindspore/common/sparse_tensor.py +0 -3
- mindspore/common/symbol.py +0 -1
- mindspore/common/tensor.py +48 -83
- mindspore/communication/_comm_helper.py +46 -4
- mindspore/communication/management.py +79 -7
- mindspore/context.py +38 -23
- mindspore/dataset/core/config.py +3 -3
- mindspore/dataset/engine/datasets.py +20 -7
- mindspore/dataset/engine/datasets_user_defined.py +32 -2
- 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/py_transforms.py +7 -3
- mindspore/dataset/transforms/transforms.py +7 -3
- mindspore/dataset/vision/validators.py +1 -0
- mindspore/device_context/ascend/device.py +1 -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/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +3 -5
- 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 +37 -1
- mindspore/include/api/delegate.h +10 -0
- mindspore/include/api/model.h +3 -0
- mindspore/include/api/types.h +2 -2
- mindspore/include/c_api/model_c.h +0 -58
- mindspore/include/c_api/tensor_c.h +0 -26
- mindspore/include/dataset/vision_ascend.h +1 -1
- mindspore/jpeg62.dll +0 -0
- mindspore/mindrecord/tools/cifar10.py +60 -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 +1 -0
- mindspore/mint/distributed/distributed.py +208 -5
- mindspore/mint/nn/__init__.py +1 -1
- mindspore/mint/nn/functional.py +53 -6
- mindspore/mint/nn/layer/_functions.py +164 -294
- mindspore/mint/nn/layer/activation.py +8 -6
- mindspore/mint/nn/layer/conv.py +122 -98
- mindspore/mint/nn/layer/normalization.py +8 -22
- mindspore/mint/optim/adam.py +19 -18
- mindspore/mint/optim/adamw.py +14 -8
- mindspore/mint/optim/sgd.py +5 -5
- mindspore/nn/cell.py +325 -499
- mindspore/nn/grad/cell_grad.py +11 -12
- mindspore/nn/layer/activation.py +32 -34
- mindspore/nn/layer/basic.py +67 -64
- 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 +37 -39
- 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 +1 -1
- mindspore/nn/optim/adasum.py +2 -2
- mindspore/nn/optim/optimizer.py +1 -1
- mindspore/nn/optim/thor.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 +34 -37
- mindspore/nn/wrap/grad_reducer.py +37 -37
- mindspore/nn/wrap/loss_scale.py +72 -74
- mindspore/numpy/array_creations.py +5 -5
- mindspore/numpy/fft.py +1 -1
- mindspore/numpy/math_ops.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/_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 +17 -8
- mindspore/ops/auto_generate/gen_extend_func.py +1 -51
- mindspore/ops/auto_generate/gen_ops_def.py +463 -257
- mindspore/ops/auto_generate/gen_ops_prim.py +1127 -885
- mindspore/ops/auto_generate/pyboost_inner_prim.py +31 -1
- mindspore/ops/composite/__init__.py +10 -0
- mindspore/ops/composite/base.py +8 -4
- mindspore/ops/composite/multitype_ops/__init__.py +12 -1
- mindspore/ops/composite/multitype_ops/_compile_utils.py +132 -108
- 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 +3 -1
- mindspore/ops/function/_add_attr_func.py +11 -6
- mindspore/ops/function/array_func.py +7 -94
- mindspore/ops/function/debug_func.py +4 -3
- mindspore/ops/function/grad/grad_func.py +1 -1
- mindspore/ops/function/math_func.py +21 -367
- mindspore/ops/function/nn_func.py +26 -41
- mindspore/ops/function/other_func.py +4 -1
- mindspore/ops/function/random_func.py +31 -4
- mindspore/ops/functional.py +0 -2
- mindspore/ops/functional_overload.py +463 -6
- 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 +3 -6
- mindspore/ops/operations/_sequence_ops.py +1 -1
- mindspore/ops/operations/comm_ops.py +185 -26
- mindspore/ops/operations/custom_ops.py +235 -172
- mindspore/ops/operations/debug_ops.py +55 -4
- mindspore/ops/operations/image_ops.py +13 -13
- mindspore/ops/operations/manually_defined/ops_def.py +15 -16
- mindspore/ops/operations/math_ops.py +3 -4
- mindspore/ops/operations/nn_ops.py +5 -6
- mindspore/ops/primitive.py +6 -10
- mindspore/ops/tensor_method.py +36 -4
- 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 -0
- 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 +4 -2
- mindspore/parallel/_cell_wrapper.py +106 -40
- mindspore/parallel/_parallel_serialization.py +1 -1
- 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 +13 -8
- mindspore/parallel/auto_parallel.py +12 -5
- mindspore/parallel/checkpoint_convert.py +3 -3
- mindspore/parallel/checkpoint_transform.py +3 -1
- mindspore/parallel/cluster/process_entity/_api.py +84 -48
- mindspore/parallel/cluster/process_entity/_utils.py +95 -7
- mindspore/parallel/cluster/run.py +43 -4
- mindspore/parallel/function/__init__.py +8 -1
- mindspore/parallel/function/reshard_func.py +1 -1
- mindspore/parallel/nn/__init__.py +15 -2
- mindspore/parallel/nn/parallel_cell_wrapper.py +9 -10
- mindspore/parallel/nn/parallel_grad_reducer.py +7 -6
- mindspore/parallel/shard.py +2 -2
- mindspore/parallel/transform_safetensors.py +462 -174
- 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_op_memory_viewer.py +42 -22
- 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/profiler_context.py +25 -27
- mindspore/profiler/common/profiler_info.py +0 -16
- mindspore/profiler/common/profiler_op_analyse.py +235 -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 +305 -314
- mindspore/profiler/envprofiler.py +12 -7
- mindspore/profiler/experimental_config.py +96 -6
- mindspore/profiler/mstx.py +33 -12
- mindspore/profiler/platform/__init__.py +2 -3
- mindspore/profiler/platform/npu_profiler.py +29 -19
- mindspore/profiler/profiler.py +35 -19
- mindspore/profiler/profiler_action_controller.py +64 -76
- 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 +1 -1
- mindspore/run_check/_check_version.py +7 -10
- mindspore/runtime/__init__.py +5 -5
- mindspore/runtime/event.py +10 -4
- mindspore/runtime/executor.py +60 -45
- mindspore/runtime/memory.py +21 -30
- mindspore/runtime/thread_bind_core.py +298 -164
- mindspore/safeguard/rewrite_obfuscation.py +12 -13
- mindspore/swresample-4.dll +0 -0
- mindspore/swscale-6.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/_utils.py +6 -2
- mindspore/train/amp.py +43 -20
- mindspore/train/callback/__init__.py +5 -5
- mindspore/train/callback/_checkpoint.py +3 -6
- mindspore/train/callback/_flops_collector.py +1 -1
- mindspore/train/callback/_landscape.py +0 -1
- mindspore/train/callback/_train_fault_tolerance.py +71 -13
- mindspore/train/data_sink.py +11 -2
- mindspore/train/dataset_helper.py +9 -0
- mindspore/train/model.py +51 -33
- mindspore/train/serialization.py +133 -111
- mindspore/train/summary/summary_record.py +13 -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 +6 -9
- mindspore/version.py +1 -1
- {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/METADATA +5 -4
- {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/RECORD +329 -367
- mindspore/_deprecated/jit.py +0 -198
- mindspore/experimental/es/__init__.py +0 -22
- mindspore/experimental/es/embedding_service.py +0 -891
- mindspore/experimental/es/embedding_service_layer.py +0 -581
- 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-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/WHEEL +0 -0
- {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/entry_points.txt +0 -0
- {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/top_level.txt +0 -0
|
@@ -55,13 +55,13 @@ TENSOR_PY_CC_PATH = "mindspore/ccsrc/pybind_api/ir/tensor_register/auto_generate
|
|
|
55
55
|
|
|
56
56
|
# yaml keys def
|
|
57
57
|
OP_KEYS = {'args', 'args_signature', 'returns', 'function', 'class', 'view', 'graph_view', 'dispatch', 'labels',
|
|
58
|
-
'bprop_expander'}
|
|
58
|
+
'bprop_expander', 'non-differentiable'}
|
|
59
59
|
ARG_KEYS = {'dtype', 'default', 'prim_init', 'type_cast', 'arg_handler'}
|
|
60
60
|
RETURN_KEYS = {'dtype', 'inplace', 'type_cast'}
|
|
61
61
|
ARG_SIGNATURE_KEYS = {'rw_write', 'rw_read', 'rw_ref', 'dtype_group'}
|
|
62
62
|
CLASS_KEYS = {'name', 'disable'}
|
|
63
63
|
FUNCTION_KEYS = {'name', 'disable'}
|
|
64
|
-
DISPATCH_KEYS = {'enable', 'is_comm_op', 'Ascend', 'GPU', 'CPU'}
|
|
64
|
+
DISPATCH_KEYS = {'enable', 'is_comm_op', 'Ascend', 'InternalOpAscend', 'GPU', 'CPU'}
|
|
65
65
|
TENSOR_FUNC_KEYS = {'op_yaml', 'py_method', 'kwonlyargs',
|
|
66
66
|
'varargs', 'alias', 'Ascend', 'GPU', 'CPU', 'interface'}
|
|
67
67
|
|
|
@@ -89,3 +89,8 @@ MS_OPS_KERNEL_PATH = "mindspore/ops/kernel"
|
|
|
89
89
|
MS_PYBOOST_FUNCTIONS_AUTO_GEN_PATH = "mindspore/ccsrc/pyboost/functions/auto_generate"
|
|
90
90
|
MS_COMMON_PYBOOST_KERNEL_PATH = os.path.join(MS_OPS_KERNEL_PATH, "common/pyboost")
|
|
91
91
|
MS_PYBOOST_BASE_PATH = "mindspore/ccsrc/pyboost"
|
|
92
|
+
MS_PYBOOST_INTERNAL_FUNCTIONS_AUTO_GEN_PATH = os.path.join(MS_OPS_KERNEL_PATH,
|
|
93
|
+
"ascend/pyboost/internal/functions")
|
|
94
|
+
MS_INTERNAL_PYBOOST_GEN_PATH = "mindspore/ccsrc/plugin/device/ascend/kernel/internal/pyboost/auto_gen"
|
|
95
|
+
MS_PLUGIN_INTERNAL_PATH = "mindspore/ccsrc/plugin/device/ascend/kernel/internal"
|
|
96
|
+
MS_OPS_PYBOOST_INTERNAL = "mindspore/ops/kernel/ascend/pyboost/internal"
|
|
@@ -121,25 +121,6 @@ def merge_files(origin_dir, merged_file_path, file_format):
|
|
|
121
121
|
merge_files_to_one_file(op_yaml_file_names, merged_file_path)
|
|
122
122
|
|
|
123
123
|
|
|
124
|
-
def merge_files_append(origin_dir, merged_file_path, file_format):
|
|
125
|
-
"""
|
|
126
|
-
Merge multiple files into one file.
|
|
127
|
-
origin_dir: indicates the origin file directory.
|
|
128
|
-
merged_file_path: indicates the merged file path.
|
|
129
|
-
file_format: indicates the format of regular matching.
|
|
130
|
-
Files whose names meet the regular matching in 'origin_dir' directory will be merged into one file.
|
|
131
|
-
"""
|
|
132
|
-
file_paths = glob.glob(os.path.join(origin_dir, file_format))
|
|
133
|
-
merged_content = ''
|
|
134
|
-
file_paths.sort()
|
|
135
|
-
for file_path in file_paths:
|
|
136
|
-
with open(file_path, 'r') as file:
|
|
137
|
-
merged_content += file.read()
|
|
138
|
-
merged_content += '\n'
|
|
139
|
-
with open(merged_file_path, 'a') as file:
|
|
140
|
-
file.write(merged_content)
|
|
141
|
-
|
|
142
|
-
|
|
143
124
|
def safe_load_yaml(yaml_file_path):
|
|
144
125
|
"""
|
|
145
126
|
Load yaml dictionary from file.
|
|
@@ -112,10 +112,12 @@ class OpDispatch:
|
|
|
112
112
|
gpu (str): The dispatch type for the GPU.
|
|
113
113
|
"""
|
|
114
114
|
|
|
115
|
-
def __init__(self, enable=False, is_comm_op=False, ascend='default',
|
|
115
|
+
def __init__(self, enable=False, is_comm_op=False, ascend='default',
|
|
116
|
+
internal_op_ascend='None', cpu='default', gpu='default'):
|
|
116
117
|
self.enable = enable
|
|
117
118
|
self.is_comm_op = is_comm_op
|
|
118
119
|
self.ascend = ascend
|
|
120
|
+
self.internal_op_ascend = internal_op_ascend
|
|
119
121
|
self.cpu = cpu
|
|
120
122
|
self.gpu = gpu
|
|
121
123
|
|
|
@@ -151,7 +153,8 @@ class OpProto:
|
|
|
151
153
|
op_inplace=False,
|
|
152
154
|
op_labels=None,
|
|
153
155
|
op_deprecated=None,
|
|
154
|
-
bprop_expander=True
|
|
156
|
+
bprop_expander=True,
|
|
157
|
+
non_differentiable=False):
|
|
155
158
|
self.op_name = op_name
|
|
156
159
|
self.op_args = op_args
|
|
157
160
|
self.op_function = op_function
|
|
@@ -165,6 +168,7 @@ class OpProto:
|
|
|
165
168
|
self.op_labels = op_labels
|
|
166
169
|
self.op_deprecated = op_deprecated
|
|
167
170
|
self.bprop_expander = bprop_expander
|
|
171
|
+
self.non_differentiable = non_differentiable
|
|
168
172
|
|
|
169
173
|
@staticmethod
|
|
170
174
|
def load_from_yaml(op_name, op_data):
|
|
@@ -208,10 +212,12 @@ class OpProto:
|
|
|
208
212
|
# get op deprecated
|
|
209
213
|
op_deprecated = op_data.get('deprecated', None)
|
|
210
214
|
bprop_expander = op_data.get('bprop_expander', True)
|
|
215
|
+
non_differentiable = op_data.get('non-differentiable', False)
|
|
211
216
|
op_proto = OpProto(op_name=op_name, op_args=op_args, op_returns=op_returns, op_function=op_function,
|
|
212
217
|
op_class=op_class, op_dispatch=op_dispatch, op_args_signature=op_args_signature,
|
|
213
218
|
op_view=op_view, op_graph_view=op_graph_view, op_inplace=op_inplace, op_labels=op_labels,
|
|
214
|
-
op_deprecated=op_deprecated, bprop_expander=bprop_expander
|
|
219
|
+
op_deprecated=op_deprecated, bprop_expander=bprop_expander,
|
|
220
|
+
non_differentiable=non_differentiable)
|
|
215
221
|
return op_proto
|
|
216
222
|
|
|
217
223
|
|
|
@@ -401,9 +407,10 @@ def get_op_dispatch(op_name, op_data):
|
|
|
401
407
|
f'The dispatch enable value should be bool, but get {type(enable)}, op name is {op_name}.')
|
|
402
408
|
is_comm_op = op_dispatch.get('is_comm_op', False)
|
|
403
409
|
ascend = op_dispatch.get('Ascend', 'default')
|
|
410
|
+
internal_op_ascend = op_dispatch.get('InternalOpAscend', 'None')
|
|
404
411
|
cpu = op_dispatch.get('CPU', 'default')
|
|
405
412
|
gpu = op_dispatch.get('GPU', 'default')
|
|
406
|
-
return OpDispatch(enable, is_comm_op, ascend, cpu, gpu)
|
|
413
|
+
return OpDispatch(enable, is_comm_op, ascend, internal_op_ascend, cpu, gpu)
|
|
407
414
|
|
|
408
415
|
|
|
409
416
|
def get_op_class(op_name, op_data) -> OpClass:
|
|
@@ -93,7 +93,6 @@ ${func_impl_name}_impl = _Pyboost${class_name}Prim()
|
|
|
93
93
|
""")
|
|
94
94
|
|
|
95
95
|
IMPORT_PYBOOST_PRIM_HEADER = f"""
|
|
96
|
-
from mindspore.common._stub_tensor import _convert_stub
|
|
97
96
|
from mindspore.ops._utils.arg_handler import *
|
|
98
97
|
"""
|
|
99
98
|
|
|
@@ -118,19 +117,89 @@ REGISTER_PYBOOST_GRAD_DEFINE_TEMPLATE = Template(
|
|
|
118
117
|
REGISTER_PYBOOST_GRAD_TEMPLATE = Template("${register_func}")
|
|
119
118
|
|
|
120
119
|
PYBOOST_FUNCTION_HEADER_TEMPLATE = Template.load_from_file(
|
|
121
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/
|
|
120
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/pyboost_api_h.tpl'))
|
|
122
121
|
|
|
123
|
-
|
|
124
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/
|
|
122
|
+
PYBOOST_CORE_HEADER_TEMPLATE = Template.load_from_file(
|
|
123
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/pyboost_core_header.tpl'))
|
|
124
|
+
PYBOOST_INTERNAL_OP_HEADER_TEMPLATE = Template.load_from_file(
|
|
125
|
+
os.path.join(K.WORK_DIR,
|
|
126
|
+
f'./{K.MS_OPS_KERNEL_PATH}/ascend/pyboost/internal/template/pyboost_internal_header_template.tpl'))
|
|
127
|
+
|
|
128
|
+
PYBOOST_INTERNAL_SINGLE_OP_HEADER_TEMPLATE = Template.load_from_file(
|
|
129
|
+
os.path.join(K.WORK_DIR,
|
|
130
|
+
f'./{K.MS_OPS_PYBOOST_INTERNAL}/template/pyboost_internal_single_op_header_template.tpl'))
|
|
131
|
+
|
|
132
|
+
PYBOOST_INTERNAL_SINGLE_OP_SOURCE_TEMPLATE = Template.load_from_file(
|
|
133
|
+
os.path.join(K.WORK_DIR,
|
|
134
|
+
f'./{K.MS_OPS_PYBOOST_INTERNAL}/template/pyboost_internal_single_op_source_template.tpl'))
|
|
135
|
+
|
|
136
|
+
PYBOOST_INTERNAL_SINGLE_OP_CUSTOMIZE_TEMPLATE = Template.load_from_file(
|
|
137
|
+
os.path.join(K.WORK_DIR,
|
|
138
|
+
f'./{K.MS_OPS_PYBOOST_INTERNAL}/template/pyboost_internal_single_op_customize_source_template.tpl'))
|
|
139
|
+
|
|
140
|
+
PYBOOST_INTERNAL_OP_SOURCE_TEMPLATE = Template.load_from_file(
|
|
141
|
+
os.path.join(K.WORK_DIR,
|
|
142
|
+
f'./{K.MS_OPS_PYBOOST_INTERNAL}/template/pyboost_internal_source_template.tpl'))
|
|
143
|
+
|
|
144
|
+
PYBOOST_INTERNAL_FUNCTION_HEADER_TEMPLATE = Template.load_from_file(
|
|
145
|
+
os.path.join(K.WORK_DIR,
|
|
146
|
+
f'{K.MS_OPS_PYBOOST_INTERNAL}/template/pyboost_internal_functions_header_template.tpl'))
|
|
147
|
+
|
|
148
|
+
PYBOOST_INTERNAL_FUNCTION_SOURCE_TEMPLATE = Template.load_from_file(
|
|
149
|
+
os.path.join(K.WORK_DIR,
|
|
150
|
+
f'{K.MS_OPS_PYBOOST_INTERNAL}/template/pyboost_internal_functions_source_template.tpl'))
|
|
151
|
+
|
|
152
|
+
PYBOOST_INTERNAL_FUNCTION_TEMPLATE = Template.load_from_file(
|
|
153
|
+
os.path.join(K.WORK_DIR,
|
|
154
|
+
f'{K.MS_OPS_PYBOOST_INTERNAL}/template/pyboost_internal_function_template.tpl'))
|
|
155
|
+
|
|
156
|
+
PYBOOST_KERNEL_INFO_ADAPTER_TEMPLATE = Template.load_from_file(
|
|
157
|
+
os.path.join(K.WORK_DIR,
|
|
158
|
+
f'{K.MS_PLUGIN_INTERNAL_PATH}/pyboost/template/kernel_info_adapter.tpl'))
|
|
159
|
+
|
|
160
|
+
PYBOOST_KERNEL_INFO_ADAPTER_H_TEMPLATE = Template.load_from_file(
|
|
161
|
+
os.path.join(K.WORK_DIR,
|
|
162
|
+
f'{K.MS_PLUGIN_INTERNAL_PATH}/pyboost/template/kernel_info_adapter_h.tpl'))
|
|
163
|
+
|
|
164
|
+
PYBOOST_INTERNAL_KERNEL_INFO_ADAPTER_H_TEMPLATE = Template.load_from_file(
|
|
165
|
+
os.path.join(K.WORK_DIR,
|
|
166
|
+
f'{K.MS_PLUGIN_INTERNAL_PATH}/pyboost/template/internal_kernel_info_adapter_h.tpl'))
|
|
167
|
+
|
|
168
|
+
PYBOOST_INTERNAL_KERNEL_INFO_ADAPTER_TEMPLATE = Template.load_from_file(
|
|
169
|
+
os.path.join(K.WORK_DIR,
|
|
170
|
+
f'{K.MS_PLUGIN_INTERNAL_PATH}/pyboost/template/internal_kernel_info_adapter.tpl'))
|
|
171
|
+
|
|
172
|
+
PYBOOST_INTERNAL_KERNEL_INFO_ADAPTER_CPP_TEMPLATE = Template.load_from_file(
|
|
173
|
+
os.path.join(K.WORK_DIR,
|
|
174
|
+
f'{K.MS_PLUGIN_INTERNAL_PATH}/pyboost/template/internal_kernel_info_adapter_cpp.tpl'))
|
|
175
|
+
|
|
176
|
+
PYBOOST_INTERNAL_KERNEL_INFO_ADAPTER_SINGLE_CPP_TEMPLATE = Template.load_from_file(
|
|
177
|
+
os.path.join(K.WORK_DIR,
|
|
178
|
+
f'{K.MS_PLUGIN_INTERNAL_PATH}/pyboost/template/internal_kernel_info_adapter_single_cpp.tpl'))
|
|
125
179
|
|
|
126
|
-
|
|
127
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/
|
|
180
|
+
PYBOOST_REGISTRY_BODY_CC_TEMPLATE = Template.load_from_file(
|
|
181
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/pyboost_registry_body_cc.tpl'))
|
|
128
182
|
|
|
129
|
-
|
|
130
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/
|
|
183
|
+
PYBOOST_CORE_BODY_TEMPLATE = Template.load_from_file(
|
|
184
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/pyboost_core_body.tpl'))
|
|
131
185
|
|
|
132
|
-
|
|
133
|
-
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/
|
|
186
|
+
PYBOOST_CORE_BODY_COMM_TEMPLATE = Template.load_from_file(
|
|
187
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/pyboost_core_body_comm.tpl'))
|
|
188
|
+
|
|
189
|
+
PYBOOST_CORE_BODY_SYNC_TEMPLATE = Template.load_from_file(
|
|
190
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/pyboost_core_body_sync.tpl'))
|
|
191
|
+
|
|
192
|
+
PYBOOST_REGISTRY_CC_TEMPLATE = Template.load_from_file(
|
|
193
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/pyboost_registry_cc.tpl'))
|
|
194
|
+
|
|
195
|
+
PYBOOST_API_CC_TEMPLATE = Template.load_from_file(
|
|
196
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/pyboost_api_cc.tpl'))
|
|
197
|
+
|
|
198
|
+
PYBOOST_API_BODY_CC_TEMPLATE = Template.load_from_file(
|
|
199
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/pyboost_api_body_cc.tpl'))
|
|
200
|
+
|
|
201
|
+
PYBOOST_CORE_CC_TEMPLATE = Template.load_from_file(
|
|
202
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/pyboost_core_cc.tpl'))
|
|
134
203
|
|
|
135
204
|
PYBOOST_OVERLOAD_FUNCTIONS_CC_TEMPLATE = Template.load_from_file(
|
|
136
205
|
os.path.join(
|
|
@@ -213,6 +282,10 @@ PYBOOST_OP_REGISTER_TEMPLATE = Template.load_from_file(
|
|
|
213
282
|
PYBOOST_ASCEND_OP_HEADER_TEMPLATE = Template.load_from_file(
|
|
214
283
|
os.path.join(K.WORK_DIR,
|
|
215
284
|
f'./{K.MS_OPS_KERNEL_PATH}/ascend/pyboost/template/pyboost_aclnn_header_template.tpl'))
|
|
285
|
+
PYBOOST_ASCEND_INTERNAL_OP_HEADER_TEMPLATE = Template.load_from_file(
|
|
286
|
+
os.path.join(K.WORK_DIR,
|
|
287
|
+
f'./{K.MS_OPS_KERNEL_PATH}/ascend/pyboost/internal/template/pyboost_internal_header_template.tpl')
|
|
288
|
+
)
|
|
216
289
|
|
|
217
290
|
PYBOOST_ASCEND_OP_SOURCE_TEMPLATE = Template.load_from_file(
|
|
218
291
|
os.path.join(K.WORK_DIR,
|
|
@@ -226,6 +299,8 @@ PYBOOST_ASCEND_SINGLE_HCLL_OP_HEADER_TEMPLATE = Template.load_from_file(
|
|
|
226
299
|
os.path.join(K.WORK_DIR,
|
|
227
300
|
f'./{K.MS_OPS_KERNEL_PATH}/ascend/pyboost/template/pyboost_aclnn_single_hccl_op_header_template.tpl'))
|
|
228
301
|
|
|
302
|
+
PYBOOST_CALL_FUNC_TEMPLATE = Template('${return_type} Call(${call_args_with_type}) override;')
|
|
303
|
+
|
|
229
304
|
PYBOOST_ASCEND_SINGLE_OP_SOURCE_TEMPLATE = Template.load_from_file(
|
|
230
305
|
os.path.join(K.WORK_DIR,
|
|
231
306
|
f'./{K.MS_OPS_KERNEL_PATH}/ascend/pyboost/template/pyboost_aclnn_single_op_source_template.tpl'))
|
|
@@ -373,7 +448,6 @@ from mindspore.ops._primitive_cache import _get_cache_prim
|
|
|
373
448
|
from mindspore.ops._utils.arg_dtype_cast import type_it
|
|
374
449
|
from mindspore.ops._utils.arg_handler import *
|
|
375
450
|
from mindspore._c_expression import OpDtype
|
|
376
|
-
from mindspore.common._stub_tensor import _convert_stub
|
|
377
451
|
from mindspore.common.jit_context import jit_context
|
|
378
452
|
from mindspore._checkparam import is_stub_tensor
|
|
379
453
|
"""
|
|
@@ -509,6 +583,9 @@ FUNCTIONS_CC_TEMPLATE = Template.load_from_file(
|
|
|
509
583
|
FUNCTION_BODY_TEMPLATE = Template.load_from_file(
|
|
510
584
|
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/function_body.tpl'))
|
|
511
585
|
|
|
586
|
+
FUNCTION_COMM_BODY_TEMPLATE = Template.load_from_file(
|
|
587
|
+
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/comm_function_body.tpl'))
|
|
588
|
+
|
|
512
589
|
FUNCTIONS_H_TEMPLATE = Template.load_from_file(
|
|
513
590
|
os.path.join(K.WORK_DIR, './mindspore/ccsrc/pynative/op_function/template/functions_h.tpl'))
|
|
514
591
|
|
|
@@ -24,7 +24,6 @@ import common.template as template
|
|
|
24
24
|
from common.base_generator import BaseGenerator
|
|
25
25
|
from pyboost import pyboost_utils
|
|
26
26
|
|
|
27
|
-
|
|
28
27
|
LITE_OPS_H = """
|
|
29
28
|
#ifndef MINDSPORE_CORE_OPS_GEN_LITE_OPS_H_
|
|
30
29
|
#define MINDSPORE_CORE_OPS_GEN_LITE_OPS_H_
|
|
@@ -122,9 +121,10 @@ class LiteOpsCcGenerator(BaseGenerator):
|
|
|
122
121
|
self.inc_ops_head_templat = template.Template(INC_OPS_HEAD)
|
|
123
122
|
self.lite_ops_cc_template = template.Template(LITE_OPS_CC)
|
|
124
123
|
self.op_template = template.op_template
|
|
125
|
-
self.register_primitive_c_template = template.Template(
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
self.register_primitive_c_template = template.Template(
|
|
125
|
+
"${op_name}::${op_name}():BaseOperator(kName${op_name}) {}\n"
|
|
126
|
+
"REGISTER_PRIMITIVE_C(kName${op_name}, ${op_name});\n"
|
|
127
|
+
"MIND_API_OPERATOR_IMPL(${op_name}, BaseOperator);\n\n")
|
|
128
128
|
|
|
129
129
|
def generate(self, work_path, op_protos):
|
|
130
130
|
"""
|
|
@@ -19,15 +19,12 @@ This module defines the `OpsNameHGenerator` class, which produces C++ code to de
|
|
|
19
19
|
constants for operator names based on given prototypes.
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
|
-
import os
|
|
23
|
-
|
|
24
22
|
import common.gen_constants as K
|
|
25
23
|
import common.gen_utils as gen_utils
|
|
26
24
|
import common.template as template
|
|
27
25
|
from common.base_generator import BaseGenerator
|
|
28
26
|
from pyboost import pyboost_utils
|
|
29
27
|
|
|
30
|
-
|
|
31
28
|
OP_NAME_OP_DEF = """
|
|
32
29
|
#ifndef MINDSPORE_CORE_OP_NAME_${suffix}_H_
|
|
33
30
|
#define MINDSPORE_CORE_OP_NAME_${suffix}_H_
|
|
@@ -19,15 +19,12 @@ This module defines the `OpsPrimitiveHGenerator` class, which creates C++ header
|
|
|
19
19
|
containing definitions for operator primitives based on provided operator prototypes.
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
|
-
import os
|
|
23
|
-
|
|
24
22
|
import common.gen_constants as K
|
|
25
23
|
import common.gen_utils as gen_utils
|
|
26
24
|
import common.template as template
|
|
27
25
|
from common.base_generator import BaseGenerator
|
|
28
26
|
from pyboost import pyboost_utils
|
|
29
27
|
|
|
30
|
-
|
|
31
28
|
OP_PRIM_OP_DEF_H = """
|
|
32
29
|
#ifndef MINDSPORE_CORE_OPS_GEN_OPS_PRIMITIVE_${suffix}_H_
|
|
33
30
|
#define MINDSPORE_CORE_OPS_GEN_OPS_PRIMITIVE_${suffix}_H_
|
|
@@ -42,7 +39,6 @@ $ops_prim_gen
|
|
|
42
39
|
#endif // MINDSPORE_CORE_OPS_GEN_OPS_PRIMITIVE_${suffix}_H_
|
|
43
40
|
"""
|
|
44
41
|
|
|
45
|
-
|
|
46
42
|
OP_PRIM_OP_DEF_CC = """
|
|
47
43
|
|
|
48
44
|
#include "$auto_gen_path/gen_ops_primitive_${suffix}.h"
|
|
@@ -142,7 +142,10 @@ class OpPrimPyGenerator(BaseGenerator):
|
|
|
142
142
|
# step1.3: get args set prim arg expression:
|
|
143
143
|
assign_str = self._get_assign_str_by_type_it(op_proto.op_class.name, arg)
|
|
144
144
|
if arg.arg_handler:
|
|
145
|
-
assign_str =
|
|
145
|
+
assign_str = (
|
|
146
|
+
f' self._set_prim_arg_with_handler('
|
|
147
|
+
f'"{arg.arg_name}", {assign_str}, {arg.arg_handler})'
|
|
148
|
+
)
|
|
146
149
|
else:
|
|
147
150
|
assign_str = f""" self._set_prim_arg("{arg.arg_name}", {assign_str})"""
|
|
148
151
|
args_assign.append(assign_str)
|
|
@@ -318,7 +321,7 @@ class OpPrimPyGenerator(BaseGenerator):
|
|
|
318
321
|
call_method_body_str += f"""
|
|
319
322
|
# Add for jit context.
|
|
320
323
|
if jit_context() and jit_context().compiled:
|
|
321
|
-
return
|
|
324
|
+
return jit_context().default_output()"""
|
|
322
325
|
pyboost_func_name = pyboost_utils.get_pyboost_name(op_proto.op_name)
|
|
323
326
|
call_method_body_str += f"""
|
|
324
327
|
res = {pyboost_func_name}(self, [{call_args_list_str}])"""
|
|
@@ -58,7 +58,7 @@ class AutoGradImplGenerator(BaseGenerator):
|
|
|
58
58
|
do_grad_op_list = []
|
|
59
59
|
ops_inc_head_set = set()
|
|
60
60
|
for op_proto in op_protos:
|
|
61
|
-
if op_proto.op_dispatch is None
|
|
61
|
+
if op_proto.op_dispatch is None:
|
|
62
62
|
continue
|
|
63
63
|
auto_grad_reg_list.append(self.auto_grad_reg_template.replace(class_name=op_proto.op_class.name))
|
|
64
64
|
do_grad_op_list.append(self._get_single_do_grad_op(op_proto))
|
|
@@ -80,24 +80,38 @@ class AutoGradImplGenerator(BaseGenerator):
|
|
|
80
80
|
Returns:
|
|
81
81
|
str: The generated DoGrad function string.
|
|
82
82
|
"""
|
|
83
|
-
input_args_str = self._get_input_args(op_proto, False, False)
|
|
84
|
-
input_args_with_optional_str = self._get_input_args(op_proto, False, True)
|
|
85
|
-
input_args_with_type_str = self._get_input_args(op_proto, True, False)
|
|
83
|
+
input_args_str = self._get_input_args(op_proto, False, False, op_proto.op_view)
|
|
84
|
+
input_args_with_optional_str = self._get_input_args(op_proto, False, True, op_proto.op_view)
|
|
85
|
+
input_args_with_type_str = self._get_input_args(op_proto, True, False, op_proto.op_view)
|
|
86
|
+
inner_grad_args_with_type = self._get_input_args(op_proto, True, False, False)
|
|
86
87
|
multi_output_str = 'Multi' if is_op_multi_output(op_proto.op_returns) else ''
|
|
87
88
|
view_arg_str = self._get_view_str(op_proto.op_view, input_args_str)
|
|
88
89
|
grad_args_with_type_str = self.do_grad_op_args_with_type.replace(input_args_with_type=input_args_with_type_str)
|
|
90
|
+
inner_grad_args_with_type =\
|
|
91
|
+
self.do_grad_op_args_with_type.replace(input_args_with_type=inner_grad_args_with_type)
|
|
89
92
|
op_def_name_str = "g" + op_proto.op_class.name
|
|
90
|
-
|
|
93
|
+
TRUE = "true"
|
|
94
|
+
FALSE = "false"
|
|
95
|
+
bprop_expander = TRUE if op_proto.bprop_expander else FALSE
|
|
96
|
+
non_differentiable = TRUE if op_proto.non_differentiable else FALSE
|
|
97
|
+
if not op_proto.op_view:
|
|
98
|
+
convert_basic_to_value = ''
|
|
99
|
+
else:
|
|
100
|
+
input_args_with_optional_str, convert_basic_to_value = self._get_convert_str(op_proto,
|
|
101
|
+
input_args_with_optional_str)
|
|
91
102
|
return self.DO_GRAD_FUNCTION_BODY_TEMPLATE.replace(class_name=op_proto.op_class.name,
|
|
103
|
+
inner_grad_args_with_type=inner_grad_args_with_type,
|
|
92
104
|
grad_args_with_type=grad_args_with_type_str,
|
|
93
105
|
grad_input_args=input_args_str,
|
|
94
106
|
grad_input_args_with_optional=input_args_with_optional_str,
|
|
95
107
|
is_multi=multi_output_str,
|
|
96
108
|
view_arg=view_arg_str,
|
|
97
109
|
op_def_name=op_def_name_str,
|
|
98
|
-
bprop_expander=bprop_expander
|
|
110
|
+
bprop_expander=bprop_expander,
|
|
111
|
+
non_differentiable=non_differentiable,
|
|
112
|
+
convert_basic_to_value=convert_basic_to_value)
|
|
99
113
|
|
|
100
|
-
def _get_input_args(self, op_proto, has_type, with_optional):
|
|
114
|
+
def _get_input_args(self, op_proto, has_type, with_optional, use_basic_type=False):
|
|
101
115
|
"""
|
|
102
116
|
Get the input arguments for the DoGrad function.
|
|
103
117
|
|
|
@@ -110,7 +124,7 @@ class AutoGradImplGenerator(BaseGenerator):
|
|
|
110
124
|
"""
|
|
111
125
|
args_list = []
|
|
112
126
|
for op_arg in op_proto.op_args:
|
|
113
|
-
input_dtype = get_input_dtype(op_arg.arg_dtype, is_optional_param(op_arg))
|
|
127
|
+
input_dtype = get_input_dtype(op_arg.arg_dtype, is_optional_param(op_arg), use_basic_type)
|
|
114
128
|
if has_type:
|
|
115
129
|
args_list.append(f"const {input_dtype} &{op_arg.arg_name}_tensor")
|
|
116
130
|
else:
|
|
@@ -120,6 +134,33 @@ class AutoGradImplGenerator(BaseGenerator):
|
|
|
120
134
|
args_list.append(f"{op_arg.arg_name}_tensor")
|
|
121
135
|
return args_list
|
|
122
136
|
|
|
137
|
+
def _get_convert_str(self, op_proto, args_name):
|
|
138
|
+
"""
|
|
139
|
+
Get the input convert func for the DoGrad function.
|
|
140
|
+
|
|
141
|
+
Args:
|
|
142
|
+
op_proto: The operator prototype.
|
|
143
|
+
has_type (bool): Whether to include type information for the arguments.
|
|
144
|
+
|
|
145
|
+
Returns:
|
|
146
|
+
list: A list of input arguments for the DoGrad function.
|
|
147
|
+
list: A list of convert functions.
|
|
148
|
+
"""
|
|
149
|
+
args_name_list = []
|
|
150
|
+
convert_funcs = []
|
|
151
|
+
convert_types = ["tuple[int]", "list[int]", "int"]
|
|
152
|
+
convert_func_template = Template("const auto &${arg_name} = PackToValue(${input_name});")
|
|
153
|
+
for op_arg, arg_name in zip(op_proto.op_args, args_name):
|
|
154
|
+
if op_arg.arg_dtype not in convert_types:
|
|
155
|
+
args_name_list.append(arg_name)
|
|
156
|
+
continue
|
|
157
|
+
out_arg_name = arg_name + "_value"
|
|
158
|
+
input_name = arg_name
|
|
159
|
+
convert_funcs.append(convert_func_template.replace(arg_name=out_arg_name,
|
|
160
|
+
input_name=input_name))
|
|
161
|
+
args_name_list.append(out_arg_name)
|
|
162
|
+
return args_name_list, convert_funcs
|
|
163
|
+
|
|
123
164
|
def _get_view_str(self, is_view_op: bool, grad_args: list):
|
|
124
165
|
"""
|
|
125
166
|
Get the view argument string for a DoGrad function.
|
|
@@ -56,7 +56,7 @@ class AutoGradRegHeaderGenerator(BaseGenerator):
|
|
|
56
56
|
op_grad_func_obj_list = []
|
|
57
57
|
index = 0
|
|
58
58
|
for op_proto in op_protos:
|
|
59
|
-
if op_proto.op_dispatch is None
|
|
59
|
+
if op_proto.op_dispatch is None:
|
|
60
60
|
continue
|
|
61
61
|
op_type_enum_list.append(self.op_type_enum_template.replace(class_name=op_proto.op_class.name,
|
|
62
62
|
enum_val=index))
|
|
@@ -87,7 +87,7 @@ class AutoGradRegHeaderGenerator(BaseGenerator):
|
|
|
87
87
|
input_tensor_prt_args_str = ""
|
|
88
88
|
for op_arg in op_proto.op_args:
|
|
89
89
|
is_optional = is_optional_param(op_arg)
|
|
90
|
-
input_dtype = get_input_dtype(op_arg.arg_dtype, is_optional)
|
|
90
|
+
input_dtype = get_input_dtype(op_arg.arg_dtype, is_optional, op_proto.op_view)
|
|
91
91
|
input_tensor_prt_args_str += f"const {input_dtype} &, "
|
|
92
92
|
|
|
93
93
|
return self.op_grad_func_args_template.replace(input_tensor_prt_args=input_tensor_prt_args_str.rstrip(', '))
|
|
@@ -26,7 +26,11 @@ from .pyboost_inner_prim_generator import PyboostInnerPrimGenerator
|
|
|
26
26
|
from .pyboost_functions_py_generator import PyboostFunctionsPyGenerator
|
|
27
27
|
from .pyboost_functions_h_generator import PyboostFunctionsHeaderGenerator
|
|
28
28
|
from .pyboost_functions_cpp_generator import PyboostFunctionsGenerator
|
|
29
|
+
from .pyboost_functions_impl_cpp_generator import PyboostFunctionsImplGenerator
|
|
29
30
|
from .pyboost_grad_function_cpp_generator import PyboostGradFunctionsGenerator
|
|
31
|
+
from .pyboost_internal_functions_h_generator import PyboostInternalFunctionsHeaderGenerator
|
|
32
|
+
from .pyboost_internal_functions_cpp_generator import PyboostInternalFunctionsCppGenerator
|
|
33
|
+
from .pyboost_internal_kernel_info_adapter_generator import PyboostKernelInfoAdapterGenerator
|
|
30
34
|
from .pyboost_native_grad_functions_generator import (
|
|
31
35
|
PyboostGradFunctionsHeaderGenerator,
|
|
32
36
|
PyboostGradFunctionsCppGenerator,
|
|
@@ -35,6 +39,7 @@ from .pyboost_op_cpp_code_generator import (
|
|
|
35
39
|
PyboostCommonOpHeaderGenerator,
|
|
36
40
|
PyboostOpFunctionGenerator,
|
|
37
41
|
PyboostOpHeaderGenerator,
|
|
42
|
+
PyboostInternalOpHeaderGenerator,
|
|
38
43
|
delete_residual_files,
|
|
39
44
|
PyboostOpRegisterCppCodeGenerator,
|
|
40
45
|
)
|
|
@@ -68,6 +73,9 @@ def gen_pyboost_code(resource_mgr):
|
|
|
68
73
|
call_pyboost_functions_h_generator(work_path, op_protos)
|
|
69
74
|
call_pyboost_functions_cpp_generator(work_path, op_protos)
|
|
70
75
|
call_pyboost_overload_functions_cpp_generator(work_path, op_protos, mint_func_protos, alias_func_mapping)
|
|
76
|
+
call_pyboost_internal_functions_h_generator(work_path, op_protos)
|
|
77
|
+
call_pyboost_internal_functions_cpp_generator(work_path, op_protos)
|
|
78
|
+
call_pyboost_internal_kernel_info_adapter_generator(work_path, op_protos)
|
|
71
79
|
call_pyboost_grad_functions_cpp_generator(work_path, op_protos)
|
|
72
80
|
call_pyboost_native_grad_functions_generator(work_path, op_protos)
|
|
73
81
|
call_pyboost_op_cpp_code_generator(work_path, op_protos)
|
|
@@ -117,7 +125,27 @@ def call_pyboost_functions_h_generator(work_path, op_protos):
|
|
|
117
125
|
generator.generate(work_path, op_protos)
|
|
118
126
|
|
|
119
127
|
|
|
128
|
+
def call_pyboost_internal_functions_h_generator(work_path, op_protos):
|
|
129
|
+
"gen internal op functions headers"
|
|
130
|
+
generator = PyboostInternalFunctionsHeaderGenerator()
|
|
131
|
+
generator.generate(work_path, op_protos)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def call_pyboost_internal_functions_cpp_generator(work_path, op_protos):
|
|
135
|
+
"gen internal op functions sources"
|
|
136
|
+
generator = PyboostInternalFunctionsCppGenerator()
|
|
137
|
+
generator.generate(work_path, op_protos)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def call_pyboost_internal_kernel_info_adapter_generator(work_path, op_protos):
|
|
141
|
+
"gen kernel info adapter for internal op"
|
|
142
|
+
generator = PyboostKernelInfoAdapterGenerator()
|
|
143
|
+
generator.generate(work_path, op_protos)
|
|
144
|
+
|
|
145
|
+
|
|
120
146
|
def call_pyboost_functions_cpp_generator(work_path, op_protos):
|
|
147
|
+
impl_generator = PyboostFunctionsImplGenerator()
|
|
148
|
+
impl_generator.generate(work_path, op_protos)
|
|
121
149
|
generator = PyboostFunctionsGenerator()
|
|
122
150
|
generator.generate(work_path, op_protos)
|
|
123
151
|
|
|
@@ -160,8 +188,11 @@ def call_PyboostCommonOpCppCodeGenerator(work_path, op_protos):
|
|
|
160
188
|
|
|
161
189
|
|
|
162
190
|
def call_PyboostOpHeaderGenerator(work_path, op_protos):
|
|
191
|
+
""" generate pyboost op headers """
|
|
163
192
|
generator = PyboostOpHeaderGenerator('ascend')
|
|
164
193
|
generator.generate(work_path, op_protos)
|
|
194
|
+
generator = PyboostInternalOpHeaderGenerator('ascend')
|
|
195
|
+
generator.generate(work_path, op_protos)
|
|
165
196
|
|
|
166
197
|
generator = PyboostOpHeaderGenerator('gpu')
|
|
167
198
|
generator.generate(work_path, op_protos)
|