mindspore 2.6.0rc1__cp310-cp310-macosx_11_0_arm64.whl → 2.7.0rc1__cp310-cp310-macosx_11_0_arm64.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.cpython-310-darwin.so +0 -0
- mindspore/_c_expression.cpython-310-darwin.so +0 -0
- mindspore/_c_mindrecord.cpython-310-darwin.so +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 +37 -62
- mindspore/_extends/parse/resources.py +39 -0
- mindspore/_extends/parse/standard_method.py +43 -13
- mindspore/_extends/parse/trope.py +8 -1
- mindspore/_extends/pijit/__init__.py +1 -2
- mindspore/amp.py +4 -4
- 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 +77 -16
- mindspore/common/api.py +238 -113
- mindspore/common/dtype.py +21 -11
- mindspore/common/dump.py +10 -15
- mindspore/common/generator.py +5 -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 +81 -81
- mindspore/communication/_comm_helper.py +46 -4
- mindspore/communication/management.py +79 -7
- mindspore/context.py +58 -40
- mindspore/dataset/core/config.py +3 -3
- mindspore/dataset/engine/datasets.py +20 -7
- mindspore/dataset/engine/datasets_user_defined.py +33 -3
- 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/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +3 -7
- 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 +27 -7
- 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/lib/libavcodec.59.dylib +0 -0
- mindspore/lib/libavdevice.59.dylib +0 -0
- mindspore/lib/libavfilter.8.dylib +0 -0
- mindspore/lib/libavformat.59.dylib +0 -0
- mindspore/lib/libavutil.57.dylib +0 -0
- mindspore/lib/libdnnl.2.dylib +0 -0
- mindspore/lib/libmindspore_backend_common.dylib +0 -0
- mindspore/lib/libmindspore_backend_manager.dylib +0 -0
- mindspore/lib/libmindspore_common.dylib +0 -0
- mindspore/lib/libmindspore_core.dylib +0 -0
- mindspore/lib/libmindspore_dump.dylib +0 -0
- mindspore/lib/libmindspore_frontend.dylib +0 -0
- mindspore/lib/libmindspore_glog.0.dylib +0 -0
- mindspore/lib/libmindspore_gpr.15.dylib +0 -0
- mindspore/lib/libmindspore_grpc++.1.dylib +0 -0
- mindspore/lib/libmindspore_grpc.15.dylib +0 -0
- mindspore/lib/libmindspore_memory_pool.dylib +0 -0
- mindspore/lib/libmindspore_ms_backend.dylib +0 -0
- mindspore/lib/libmindspore_ops.dylib +0 -0
- mindspore/lib/libmindspore_ops_kernel_common.dylib +0 -0
- mindspore/lib/libmindspore_profiler.dylib +0 -0
- mindspore/lib/libmindspore_pyboost.dylib +0 -0
- mindspore/lib/libmindspore_pynative.dylib +0 -0
- mindspore/lib/libmindspore_res_manager.dylib +0 -0
- mindspore/lib/libmindspore_runtime_pipeline.dylib +0 -0
- mindspore/lib/libnnacl.dylib +0 -0
- mindspore/lib/libopencv_core.4.5.dylib +0 -0
- mindspore/lib/libopencv_imgcodecs.4.5.dylib +0 -0
- mindspore/lib/libopencv_imgproc.4.5.dylib +0 -0
- mindspore/lib/libps_cache.dylib +0 -0
- mindspore/lib/libswresample.4.dylib +0 -0
- mindspore/lib/libswscale.6.dylib +0 -0
- mindspore/lib/plugin/cpu/libmindspore_cpu_res_manager.dylib +0 -0
- mindspore/lib/plugin/libmindspore_ops_host.dylib +0 -0
- mindspore/mindrecord/tools/cifar10.py +60 -11
- mindspore/mindrecord/tools/cifar10_to_mr.py +5 -0
- mindspore/mint/__init__.py +6 -46
- mindspore/mint/distributed/__init__.py +1 -0
- mindspore/mint/distributed/distributed.py +212 -9
- 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 +137 -101
- 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 +328 -502
- 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 +117 -110
- 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 +3 -3
- mindspore/nn/optim/adasum.py +2 -2
- mindspore/nn/optim/asgd.py +2 -0
- 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 +5 -5
- 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 +31 -13
- mindspore/ops/_vmap/vmap_nn_ops.py +8 -16
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +42 -11
- mindspore/ops/auto_generate/gen_extend_func.py +23 -141
- mindspore/ops/auto_generate/gen_ops_def.py +785 -379
- mindspore/ops/auto_generate/gen_ops_prim.py +1807 -1070
- 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 +133 -109
- 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 +9 -96
- mindspore/ops/function/debug_func.py +4 -3
- mindspore/ops/function/grad/grad_func.py +1 -1
- mindspore/ops/function/math_func.py +33 -540
- mindspore/ops/function/nn_func.py +28 -74
- mindspore/ops/function/other_func.py +4 -1
- mindspore/ops/function/random_func.py +44 -5
- mindspore/ops/function/vmap_func.py +2 -1
- mindspore/ops/functional.py +2 -3
- mindspore/ops/functional_overload.py +571 -6
- mindspore/ops/op_info_register.py +21 -0
- mindspore/ops/operations/__init__.py +16 -11
- mindspore/ops/operations/_custom_ops_utils.py +689 -34
- mindspore/ops/operations/_inner_ops.py +3 -6
- mindspore/ops/operations/_sequence_ops.py +1 -1
- mindspore/ops/operations/array_ops.py +2 -2
- mindspore/ops/operations/comm_ops.py +185 -26
- mindspore/ops/operations/custom_ops.py +294 -174
- mindspore/ops/operations/debug_ops.py +59 -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 +7 -39
- mindspore/ops/primitive.py +6 -10
- mindspore/ops/tensor_method.py +47 -8
- 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 +8 -3
- 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_def_cc_generator.py +0 -3
- 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 +11 -8
- mindspore/parallel/_cell_wrapper.py +113 -45
- 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 +14 -7
- mindspore/parallel/checkpoint_convert.py +3 -3
- mindspore/parallel/checkpoint_transform.py +11 -7
- 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 +6 -7
- 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 +3 -4
- mindspore/parallel/transform_safetensors.py +463 -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 +12 -6
- 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 +30 -32
- mindspore/runtime/thread_bind_core.py +298 -164
- mindspore/safeguard/rewrite_obfuscation.py +12 -13
- mindspore/scipy/linalg.py +2 -2
- mindspore/scipy/utils_const.py +0 -17
- mindspore/train/_utils.py +14 -4
- 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 +97 -16
- mindspore/train/data_sink.py +11 -2
- mindspore/train/dataset_helper.py +9 -0
- mindspore/train/model.py +135 -55
- mindspore/train/serialization.py +133 -111
- mindspore/train/summary/summary_record.py +13 -2
- mindspore/utils/__init__.py +3 -2
- mindspore/utils/dryrun.py +0 -6
- mindspore/utils/runtime_execution_order_check.py +163 -77
- mindspore/utils/sdc_detect.py +68 -0
- mindspore/utils/utils.py +6 -9
- mindspore/version.py +1 -1
- {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/METADATA +5 -4
- {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/RECORD +337 -375
- 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.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/WHEEL +0 -0
- {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/entry_points.txt +0 -0
- {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/top_level.txt +0 -0
mindspore/.commit_id
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__commit_id__ = ''[sha1]:
|
|
1
|
+
__commit_id__ = ''[sha1]:e69e001d,[branch]:(HEAD,origin/r2.7.rc1,r2.7.rc1)''
|
mindspore/__init__.py
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
from __future__ import absolute_import
|
|
17
17
|
|
|
18
18
|
from mindspore.run_check import run_check
|
|
19
|
-
from mindspore import common, dataset, mindrecord, train, log, amp
|
|
19
|
+
from mindspore import common, dataset, mindrecord, train, log, amp, device_manager
|
|
20
20
|
from mindspore import profiler, communication, numpy, parallel, hal, runtime, device_context
|
|
21
21
|
from mindspore.common import *
|
|
22
22
|
from mindspore.common import _tensor_docs
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
mindspore/_checkparam.py
CHANGED
|
@@ -118,20 +118,21 @@ def _format_str_two_value(val1, val2, rel):
|
|
|
118
118
|
|
|
119
119
|
|
|
120
120
|
def _check_3d_int_or_tuple(arg_name, arg_value, prim_name, allow_five=False, ret_five=False,
|
|
121
|
-
greater_zero=True, third_one=False, three_input=False):
|
|
121
|
+
greater_zero=True, third_one=False, three_input=False, pad_value=1):
|
|
122
122
|
"""
|
|
123
123
|
Checks whether an argument is a positive int or tuple with 3 or 5(when allow_five is True) positive int elements.
|
|
124
124
|
"""
|
|
125
125
|
|
|
126
|
-
def _raise_message(third_one_flag=False, three_input_flag=False):
|
|
126
|
+
def _raise_message(third_one_flag=False, three_input_flag=False, ret_value=None):
|
|
127
|
+
ret_value = arg_value if ret_value is None else ret_value
|
|
127
128
|
if third_one_flag:
|
|
128
129
|
raise ValueError(f"For '{prim_name}', the depth of parameter '{arg_name}' must be 1, " \
|
|
129
130
|
f"but got {ret_value[-3]}.")
|
|
130
131
|
if three_input_flag:
|
|
131
132
|
raise ValueError(f"For '{prim_name}', the parameter '{arg_name}' must be an positive integer " \
|
|
132
|
-
f"or a tuple of three positive integer, but got {
|
|
133
|
+
f"or a tuple of three positive integer, but got {ret_value}.")
|
|
133
134
|
raise ValueError(f"For '{prim_name}', the parameter '{arg_name}' must be an positive integer or " \
|
|
134
|
-
f"a tuple of three {'or five ' if allow_five else ''}positive integer, but got {
|
|
135
|
+
f"a tuple of three {'or five ' if allow_five else ''}positive integer, but got {ret_value}")
|
|
135
136
|
|
|
136
137
|
def _get_return_value():
|
|
137
138
|
def _check():
|
|
@@ -144,9 +145,10 @@ def _check_3d_int_or_tuple(arg_name, arg_value, prim_name, allow_five=False, ret
|
|
|
144
145
|
|
|
145
146
|
_check()
|
|
146
147
|
if isinstance(arg_value, int):
|
|
147
|
-
ret = (
|
|
148
|
+
ret = (pad_value, pad_value, arg_value, arg_value, arg_value) \
|
|
149
|
+
if ret_five else (arg_value, arg_value, arg_value)
|
|
148
150
|
elif len(arg_value) == 3:
|
|
149
|
-
ret = (
|
|
151
|
+
ret = (pad_value, pad_value, arg_value[0], arg_value[1], arg_value[2]) if ret_five else arg_value
|
|
150
152
|
else: # case: len(arg_value) == 5
|
|
151
153
|
ret = arg_value if ret_five else (arg_value[2], arg_value[3], arg_value[4])
|
|
152
154
|
|
|
@@ -159,12 +161,12 @@ def _check_3d_int_or_tuple(arg_name, arg_value, prim_name, allow_five=False, ret
|
|
|
159
161
|
continue
|
|
160
162
|
if not greater_zero and item >= 0:
|
|
161
163
|
continue
|
|
162
|
-
_raise_message()
|
|
164
|
+
_raise_message(ret_value=ret_value)
|
|
163
165
|
|
|
164
166
|
def _check_third_one(ret_value):
|
|
165
167
|
if third_one:
|
|
166
168
|
if ret_value[-3] != 1:
|
|
167
|
-
_raise_message(third_one_flag=third_one)
|
|
169
|
+
_raise_message(third_one_flag=third_one, ret_value=ret_value)
|
|
168
170
|
|
|
169
171
|
check_value_type(arg_name, arg_value, (int, tuple), prim_name)
|
|
170
172
|
if three_input and isinstance(arg_value, tuple):
|
|
@@ -1288,6 +1290,33 @@ def _expand_tuple(n_dimensions):
|
|
|
1288
1290
|
return convert
|
|
1289
1291
|
|
|
1290
1292
|
|
|
1293
|
+
def _check_int_sequence_len(sequence, valid_len):
|
|
1294
|
+
if not len(sequence) is valid_len:
|
|
1295
|
+
raise TypeError(f"When expanding an sequence to tuple, input sequence dimension must be {valid_len}, " \
|
|
1296
|
+
f"but got {sequence}")
|
|
1297
|
+
for i in sequence:
|
|
1298
|
+
if not isinstance(i, int) or isinstance(i, bool):
|
|
1299
|
+
raise TypeError(f"When expanding an sequence to tuple, " \
|
|
1300
|
+
f"the type of element in input sequence must be an integer, but got {type(i)}.")
|
|
1301
|
+
|
|
1302
|
+
|
|
1303
|
+
def _expand_sequence_to_tuple(n_dimensions):
|
|
1304
|
+
"""To expand an int number to tuple."""
|
|
1305
|
+
|
|
1306
|
+
def convert(m):
|
|
1307
|
+
if not isinstance(m, (tuple, list)):
|
|
1308
|
+
if isinstance(m, int) and not isinstance(m, bool):
|
|
1309
|
+
return tuple(repeat(m, n_dimensions))
|
|
1310
|
+
raise TypeError(f"When expanding an input to tuple, input type must be integer or tuple[int]/list[int], " \
|
|
1311
|
+
f"but got {type(m)}")
|
|
1312
|
+
_check_int_sequence_len(m, n_dimensions)
|
|
1313
|
+
if isinstance(m, list):
|
|
1314
|
+
return tuple(m)
|
|
1315
|
+
return m
|
|
1316
|
+
|
|
1317
|
+
return convert
|
|
1318
|
+
|
|
1319
|
+
|
|
1291
1320
|
def _check_data_type_valid(data, valid_type):
|
|
1292
1321
|
"""Check data type valid."""
|
|
1293
1322
|
if valid_type is None:
|
|
@@ -1342,7 +1371,9 @@ def check_output_data(data):
|
|
|
1342
1371
|
once = _expand_tuple(1)
|
|
1343
1372
|
twice = _expand_tuple(2)
|
|
1344
1373
|
triple = _expand_tuple(3)
|
|
1345
|
-
|
|
1374
|
+
once_sequence = _expand_sequence_to_tuple(1)
|
|
1375
|
+
twice_sequence = _expand_sequence_to_tuple(2)
|
|
1376
|
+
triple_sequence = _expand_sequence_to_tuple(3)
|
|
1346
1377
|
|
|
1347
1378
|
def args_type_check(*type_args, **type_kwargs):
|
|
1348
1379
|
"""Check whether input data type is correct."""
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright
|
|
1
|
+
# Copyright 2025 Huawei Technologies Co., Ltd
|
|
2
2
|
#
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
# you may not use this file except in compliance with the License.
|
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
# ============================================================================
|
|
15
|
-
"""
|
|
15
|
+
"""
|
|
16
|
+
Interfaces for optimize module.
|
|
17
|
+
"""
|
|
18
|
+
|
|
16
19
|
from __future__ import absolute_import
|
|
17
|
-
|
|
20
|
+
|
|
21
|
+
__all__ = ['set_lazy_inline']
|
|
22
|
+
|
|
23
|
+
from .cell_utils import set_lazy_inline
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Copyright 2025 Huawei Technologies Co., Ltd
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
# ============================================================================
|
|
15
|
+
"""
|
|
16
|
+
Interfaces for optimize module.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from mindspore import log as logging
|
|
20
|
+
from mindspore.nn import Cell
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def process_cell_init_args(cells, reusing_count, allow_list, denny_list):
|
|
24
|
+
"""
|
|
25
|
+
process all the cells to use lazy inline with the conditions..
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
cells(Object map): All the cells information.
|
|
29
|
+
reusing_count(int): The count of the same key of the cell instance.
|
|
30
|
+
allow_list:(list): The allow list of the cell class to apply lazy inline
|
|
31
|
+
denny_list:(list): The denny list of the cell class to apply lazy inline
|
|
32
|
+
Returns:
|
|
33
|
+
void
|
|
34
|
+
"""
|
|
35
|
+
type_instance = {}
|
|
36
|
+
class_name = {}
|
|
37
|
+
|
|
38
|
+
for k in cells.keyrefs():
|
|
39
|
+
v = cells[k]
|
|
40
|
+
if k.construct.__code__.co_filename.find("mindspore/nn") != -1:
|
|
41
|
+
continue
|
|
42
|
+
if denny_list and any(deny in k.cls_name for deny in denny_list):
|
|
43
|
+
continue
|
|
44
|
+
if allow_list and not any(allow in k.cls_name for allow in allow_list):
|
|
45
|
+
continue
|
|
46
|
+
|
|
47
|
+
pickle_args = k.cls_name + str(id(k.__class__)) + "[" + str(v[1]) + ":kws:" + str(v[2]) + "]"
|
|
48
|
+
|
|
49
|
+
instances = type_instance.get(pickle_args)
|
|
50
|
+
if instances is not None:
|
|
51
|
+
instances.append(k)
|
|
52
|
+
if len(instances) > reusing_count:
|
|
53
|
+
if not hasattr(k, "cell_init_args"):
|
|
54
|
+
setattr(k, "cell_init_args", "lazy_inline_" + pickle_args)
|
|
55
|
+
logging.debug("Reusing cell info: %s , id: %s , args: %s",
|
|
56
|
+
k.construct.__code__.co_filename + "/" + k.cls_name, id(k), pickle_args)
|
|
57
|
+
setattr(k, "no_inline", False)
|
|
58
|
+
elif len(instances) == reusing_count:
|
|
59
|
+
class_name[v[0]] = k.construct.__code__.co_filename + "/" + k.cls_name
|
|
60
|
+
logging.info("Reusing Cell: %s , args: %s", k.construct.__code__.co_filename + "/" + k.cls_name,
|
|
61
|
+
pickle_args)
|
|
62
|
+
|
|
63
|
+
for i in instances:
|
|
64
|
+
if not hasattr(i, "cell_init_args"):
|
|
65
|
+
setattr(i, "cell_init_args", "lazy_inline_" + pickle_args)
|
|
66
|
+
logging.debug("Reusing cell info: %s , id: %s , args: %s",
|
|
67
|
+
i.construct.__code__.co_filename + "/" + i.cls_name, id(i), pickle_args)
|
|
68
|
+
setattr(i, "no_inline", False)
|
|
69
|
+
else:
|
|
70
|
+
type_instance[pickle_args] = [k]
|
|
71
|
+
|
|
72
|
+
return class_name
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def set_lazy_inline(reusing_count=3, allow_list=None, denny_list=None):
|
|
76
|
+
"""
|
|
77
|
+
Apply all the cells to use lazy inline with the conditions.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
cells(Object map): All the cells information.
|
|
81
|
+
reusing_count(int): The count of the same key of the cell instance.
|
|
82
|
+
allow_list:(list): The allow list of the cell class to apply lazy inline
|
|
83
|
+
denny_list:(list): The denny list of the cell class to apply lazy inline
|
|
84
|
+
Returns:
|
|
85
|
+
void
|
|
86
|
+
"""
|
|
87
|
+
cells = Cell.global_cells
|
|
88
|
+
if denny_list is None:
|
|
89
|
+
denny_list = []
|
|
90
|
+
if allow_list is None:
|
|
91
|
+
allow_list = []
|
|
92
|
+
|
|
93
|
+
denny_list.append("_Output")
|
|
94
|
+
denny_list.append("_MicroBatch")
|
|
95
|
+
reusing_cells = process_cell_init_args(cells, reusing_count, allow_list, denny_list)
|
|
96
|
+
return reusing_cells
|
|
@@ -30,7 +30,7 @@ from .parser import (Parser, create_instance, is_supported_create_instance_type,
|
|
|
30
30
|
get_obj_defined_from_obj_type, is_from_third_party_library, get_const_abs, get_const_round,
|
|
31
31
|
get_const_len, convert_to_namedtuple, check_attrs, generate_lambda_object,
|
|
32
32
|
check_is_subclass, check_attr_is_property, get_method_info, can_constant_fold,
|
|
33
|
-
convert_to_mutable)
|
|
33
|
+
convert_to_mutable, get_ast_augassign_namespace_symbol)
|
|
34
34
|
|
|
35
35
|
__all__ = ['Parser', 'create_instance', 'is_supported_create_instance_type', 'generate_scope', 'get_attr_from_object',
|
|
36
36
|
'get_bprop_method_of_class', 'get_class_instance_type', 'get_class_member_namespace_symbol',
|
|
@@ -45,4 +45,4 @@ __all__ = ['Parser', 'create_instance', 'is_supported_create_instance_type', 'ge
|
|
|
45
45
|
'is_class_member_recursive', 'get_obj_defined_from_obj_type',
|
|
46
46
|
'is_from_third_party_library', 'get_const_abs', 'get_const_round', 'get_const_len', 'get_method_info',
|
|
47
47
|
'convert_to_namedtuple', 'check_attrs', 'generate_lambda_object', 'check_is_subclass', 'check_attr_is_property',
|
|
48
|
-
'can_constant_fold', 'convert_to_mutable']
|
|
48
|
+
'can_constant_fold', 'convert_to_mutable', 'get_ast_augassign_namespace_symbol']
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright 2024 Huawei Technologies Co., Ltd
|
|
1
|
+
# Copyright 2024-2025 Huawei Technologies Co., Ltd
|
|
2
2
|
#
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
# you may not use this file except in compliance with the License.
|
|
@@ -275,16 +275,6 @@ Value Range:
|
|
|
275
275
|
"""
|
|
276
276
|
STRICT_CHECK_PARENT_CONTEXT = ''
|
|
277
277
|
|
|
278
|
-
"""
|
|
279
|
-
Name: CELL_PARAMETER_HOOK
|
|
280
|
-
Function: Whether to enable cell parameter hook.
|
|
281
|
-
Cell parameter hook is an experimental api that may be deleted later.
|
|
282
|
-
Value Range:
|
|
283
|
-
1: Enable
|
|
284
|
-
Default: Disable
|
|
285
|
-
"""
|
|
286
|
-
CELL_PARAMETERS_HOOK = ''
|
|
287
|
-
|
|
288
278
|
"""
|
|
289
279
|
Name: CHECK_BPROP
|
|
290
280
|
Function: Whether to check back propagation nodes. The checking ensures that the shape and dtype of
|
|
@@ -315,15 +305,6 @@ Value Range:
|
|
|
315
305
|
"""
|
|
316
306
|
DEBUG_LEVEL = ''
|
|
317
307
|
|
|
318
|
-
"""
|
|
319
|
-
Name: PYNATIVE_JIT_GRAD_MODE
|
|
320
|
-
Function: Which method used for grad jit in pynative mode
|
|
321
|
-
Value Range:
|
|
322
|
-
1: Replace ValueNode
|
|
323
|
-
Default: Parametrization
|
|
324
|
-
"""
|
|
325
|
-
PYNATIVE_JIT_GRAD_MODE = ''
|
|
326
|
-
|
|
327
308
|
"""
|
|
328
309
|
Name: PIJIT_SUBGRAPH_BREAK_OPTIMIZE
|
|
329
310
|
Function: Whether to enable subgraph break optimization in PIJit.
|
|
@@ -333,6 +314,15 @@ Value Range:
|
|
|
333
314
|
"""
|
|
334
315
|
PIJIT_SUBGRAPH_BREAK_OPTIMIZE = ''
|
|
335
316
|
|
|
317
|
+
"""
|
|
318
|
+
Name: ENABLE_ELIMINATE_UNUSED_PARAMS
|
|
319
|
+
Function: Whether to enable eliminate unused parameters optimization in PIJit.
|
|
320
|
+
Value Range:
|
|
321
|
+
1: Enable, Disable if other value.
|
|
322
|
+
Default: Disable.
|
|
323
|
+
"""
|
|
324
|
+
ENABLE_ELIMINATE_UNUSED_PARAMS = ''
|
|
325
|
+
|
|
336
326
|
"""
|
|
337
327
|
Name: PUT_ALL_CNODE_INTO_ORDER_LIST
|
|
338
328
|
Function: Whether to put all CNode into order list in back prop.
|
|
@@ -342,6 +332,36 @@ Value Range:
|
|
|
342
332
|
"""
|
|
343
333
|
PUT_ALL_CNODE_INTO_ORDER_LIST = ''
|
|
344
334
|
|
|
335
|
+
"""
|
|
336
|
+
Name: CHECK_PASS_NODE_SCOPE
|
|
337
|
+
Function: Whether to check
|
|
338
|
+
Value Range:
|
|
339
|
+
1: Enable
|
|
340
|
+
Default: Disable.
|
|
341
|
+
"""
|
|
342
|
+
CHECK_PASS_NODE_SCOPE = ''
|
|
343
|
+
|
|
344
|
+
"""
|
|
345
|
+
Name: CHECK_INVALID_VIEW_INPLACE_DOUT_LEVEL
|
|
346
|
+
Function: The level of check invalid dout under view+inplace scene
|
|
347
|
+
Value Range:
|
|
348
|
+
1: Only check scenario 1
|
|
349
|
+
2: Only check scenario 2
|
|
350
|
+
Default(""): Check all invalid dout for view inplace scene
|
|
351
|
+
Others: No invalid dout check for view inplace scene
|
|
352
|
+
"""
|
|
353
|
+
CHECK_INVALID_VIEW_INPLACE_DOUT_LEVEL = ''
|
|
354
|
+
|
|
355
|
+
"""
|
|
356
|
+
Name: JIT_ENABLE_AUGASSIGN_INPLACE
|
|
357
|
+
Function: Whether enable augassign inplace.
|
|
358
|
+
Value Range:
|
|
359
|
+
0: Disable
|
|
360
|
+
1: Enable
|
|
361
|
+
Default: Disable
|
|
362
|
+
"""
|
|
363
|
+
JIT_ENABLE_AUGASSIGN_INPLACE = '0'
|
|
364
|
+
|
|
345
365
|
__all__ = [
|
|
346
366
|
"COMPILE_PROFILE",
|
|
347
367
|
"COMPILE_PROFILE_FINISH_ACTION",
|
|
@@ -372,11 +392,13 @@ __all__ = [
|
|
|
372
392
|
"ENABLE_RECOMPUTE_BEFORE_INLINE",
|
|
373
393
|
"STRICT_CHECK_PARENT_CONTEXT",
|
|
374
394
|
"AUTO_PASSES_OPTIMIZE_PATH",
|
|
375
|
-
"CELL_PARAMETERS_HOOK",
|
|
376
395
|
"CHECK_BPROP",
|
|
377
396
|
"GRAD_FOR_SCALAR",
|
|
378
397
|
"DEBUG_LEVEL",
|
|
379
|
-
"PYNATIVE_JIT_GRAD_MODE",
|
|
380
398
|
"PIJIT_SUBGRAPH_BREAK_OPTIMIZE",
|
|
399
|
+
"ENABLE_ELIMINATE_UNUSED_PARAMS",
|
|
381
400
|
"PUT_ALL_CNODE_INTO_ORDER_LIST",
|
|
401
|
+
"CHECK_PASS_NODE_SCOPE",
|
|
402
|
+
"CHECK_INVALID_VIEW_INPLACE_DOUT_LEVEL",
|
|
403
|
+
"JIT_ENABLE_AUGASSIGN_INPLACE"
|
|
382
404
|
]
|
|
@@ -42,9 +42,9 @@ from mindspore.common.api import _JitExecutor
|
|
|
42
42
|
from mindspore.common import dtype as mstype
|
|
43
43
|
from mindspore.common.parameter import Parameter
|
|
44
44
|
from mindspore.common import mutable
|
|
45
|
-
from mindspore._checkparam import is_stub_tensor
|
|
46
45
|
from .namespace import Namespace, ModuleNamespace, ClosureNamespace, ClassMemberNamespace
|
|
47
|
-
from .resources import parse_object_map, ops_symbol_map, convert_object_map,
|
|
46
|
+
from .resources import (parse_object_map, parse_augassign_object_map, ops_symbol_map, convert_object_map,
|
|
47
|
+
convert_class_to_function_map, trope_ns)
|
|
48
48
|
from .resources import SYMBOL_UNDEFINE, constant_fold_functions
|
|
49
49
|
from .jit_fallback_modules.check_utils import third_party_checker
|
|
50
50
|
from ...common.api import _convert_python_data
|
|
@@ -264,7 +264,7 @@ def resolve_symbol(namespace, symbol):
|
|
|
264
264
|
if isinstance(resolve_, _JitExecutor):
|
|
265
265
|
logger.debug("Resolve class _JitExecutor, resolve fn instead.")
|
|
266
266
|
resolve_ = resolve_.fn
|
|
267
|
-
logger.debug(
|
|
267
|
+
logger.debug("Found '%s' in %s, resolved: %s / %s", symbol, namespace, resolve_, type(resolve_))
|
|
268
268
|
return resolve_
|
|
269
269
|
|
|
270
270
|
|
|
@@ -667,6 +667,14 @@ def get_ast_namespace_symbol(obj):
|
|
|
667
667
|
return ops_info
|
|
668
668
|
|
|
669
669
|
|
|
670
|
+
def get_ast_augassign_namespace_symbol(obj):
|
|
671
|
+
"""Get obj type and namespace and symbol."""
|
|
672
|
+
# Get symbol from object map.
|
|
673
|
+
ops_info = parse_augassign_object_map.get(type(obj), SYMBOL_UNDEFINE)
|
|
674
|
+
logger.debug("ops info: %r", ops_info)
|
|
675
|
+
return ops_info
|
|
676
|
+
|
|
677
|
+
|
|
670
678
|
def get_operation_symbol(obj):
|
|
671
679
|
"""Get obj operation symbol."""
|
|
672
680
|
ops_symbol = ops_symbol_map.get(type(obj), SYMBOL_UNDEFINE)
|
|
@@ -680,6 +688,7 @@ def get_operation_namespace_symbol(var: str):
|
|
|
680
688
|
logger.debug("get operation ops info: %r", ops_info)
|
|
681
689
|
return ops_info
|
|
682
690
|
|
|
691
|
+
|
|
683
692
|
def get_ast_type(node):
|
|
684
693
|
"""Get the ast type."""
|
|
685
694
|
ast_type = AST_SUB_TYPE_UNKNOWN
|
|
@@ -784,32 +793,6 @@ def get_arg_spec_and_default_values(func):
|
|
|
784
793
|
return arg_spec, defaults
|
|
785
794
|
|
|
786
795
|
|
|
787
|
-
def _convert_stub_tensor(data):
|
|
788
|
-
"""Convert stub tensor output to tensor"""
|
|
789
|
-
if is_stub_tensor(data):
|
|
790
|
-
return data.stub_sync()
|
|
791
|
-
if isinstance(data, tuple):
|
|
792
|
-
# Handle namedtuple since its type is tuple.
|
|
793
|
-
if hasattr(data, "_fields"):
|
|
794
|
-
type_name = data.__class__.__name__
|
|
795
|
-
data_dict = data._asdict()
|
|
796
|
-
fields = data_dict.keys()
|
|
797
|
-
return namedtuple(type_name, fields)(**_convert_stub_tensor(data_dict))
|
|
798
|
-
return tuple(_convert_stub_tensor(x) for x in data)
|
|
799
|
-
if data.__class__ is list:
|
|
800
|
-
# Keep the list object not change.
|
|
801
|
-
for i in range(len(data)):
|
|
802
|
-
data[i] = _convert_stub_tensor(data[i])
|
|
803
|
-
return data
|
|
804
|
-
if data.__class__ is dict:
|
|
805
|
-
# Keep the dict object not change.
|
|
806
|
-
keys = tuple(data.keys())
|
|
807
|
-
for key in keys:
|
|
808
|
-
data[_convert_stub_tensor(key)] = _convert_stub_tensor(data.pop(key))
|
|
809
|
-
return data
|
|
810
|
-
return data
|
|
811
|
-
|
|
812
|
-
|
|
813
796
|
def eval_script(exp_str, params):
|
|
814
797
|
"""Evaluate a python expression."""
|
|
815
798
|
if not isinstance(params, tuple):
|
|
@@ -823,7 +806,6 @@ def eval_script(exp_str, params):
|
|
|
823
806
|
try:
|
|
824
807
|
local_params = _convert_python_data(local_params)
|
|
825
808
|
res = eval(exp_str, global_params, local_params)
|
|
826
|
-
res = _convert_stub_tensor(res)
|
|
827
809
|
except Exception as e:
|
|
828
810
|
error_info = f"When eval '{exp_str}' by using JIT Fallback feature, an error occurred: " + str(e)
|
|
829
811
|
logger.debug(error_info)
|
|
@@ -852,7 +834,7 @@ def get_script_id_attrs(script):
|
|
|
852
834
|
|
|
853
835
|
def generate_lambda_object(script):
|
|
854
836
|
"""Generate lambda expression object using script"""
|
|
855
|
-
return
|
|
837
|
+
return eval_script(script, ({}, {}))
|
|
856
838
|
|
|
857
839
|
|
|
858
840
|
def get_global_params():
|
|
@@ -924,20 +906,6 @@ def get_method_info(obj):
|
|
|
924
906
|
return class_name_and_method_name[0], class_name_and_method_name[1]
|
|
925
907
|
|
|
926
908
|
|
|
927
|
-
def is_ms_tensor_method(obj):
|
|
928
|
-
"""Check if the obj is a method of MindSpore Tensor"""
|
|
929
|
-
if not hasattr(obj, '__name__') or not hasattr(Tensor, obj.__name__):
|
|
930
|
-
return False
|
|
931
|
-
fn = inspect.unwrap(obj.__func__ if isinstance(obj, types.MethodType) else obj)
|
|
932
|
-
tensor_method = getattr(Tensor, obj.__name__)
|
|
933
|
-
tensor_method = tensor_method.__func__ if hasattr(tensor_method, "__func__") else tensor_method
|
|
934
|
-
is_builtin_tensor = False
|
|
935
|
-
if inspect.isbuiltin(obj):
|
|
936
|
-
class_name_and_method_name = obj.__qualname__.split('.')
|
|
937
|
-
is_builtin_tensor = obj.__module__ is None and class_name_and_method_name[0] == Tensor.__name__
|
|
938
|
-
return fn == tensor_method or is_builtin_tensor
|
|
939
|
-
|
|
940
|
-
|
|
941
909
|
def can_constant_fold(obj):
|
|
942
910
|
"""Check if the obj is the function can be constantly folded."""
|
|
943
911
|
return obj in constant_fold_functions
|
|
@@ -1037,31 +1005,38 @@ class Parser:
|
|
|
1037
1005
|
"the code 'def __init__(self, combine_fn=lambda x: x + 1):' rewritten as\n"
|
|
1038
1006
|
"'def __init__(self, combine_fn=\nlambda x: x + 1\n):' will solve the problem.")
|
|
1039
1007
|
|
|
1008
|
+
def save_source_code(self, attr_name, source_lines):
|
|
1009
|
+
"""Save cell and func source code to support run graph mode with pyc or so."""
|
|
1010
|
+
if '/mindspore/' in self.filename or '\\mindspore\\' in self.filename:
|
|
1011
|
+
return
|
|
1012
|
+
if getattr(self.fn, attr_name, None) == source_lines:
|
|
1013
|
+
return
|
|
1014
|
+
if not os.access(self.filename, os.W_OK):
|
|
1015
|
+
raise PermissionError(f"Don't have the write permission on the file {self.filename}.")
|
|
1016
|
+
with open(self.filename, 'a') as f:
|
|
1017
|
+
logger.debug(f"setattr for {self.fn}, attr: {attr_name}, value: {source_lines}")
|
|
1018
|
+
f.write(f"\n# Set source attribute for function {self.function_name} "
|
|
1019
|
+
f"to support run so or pyc file in Graph Mode."
|
|
1020
|
+
f"\nsetattr({self.function_name}, '{attr_name}', {source_lines})\n")
|
|
1021
|
+
setattr(self.fn, attr_name, source_lines)
|
|
1022
|
+
|
|
1040
1023
|
def parse(self):
|
|
1041
1024
|
"""Parse the function or method."""
|
|
1042
1025
|
logger.debug("fn: %r", self.fn)
|
|
1043
1026
|
if isinstance(self.fn, (types.FunctionType, types.MethodType)) or \
|
|
1044
1027
|
type(self.fn).__name__ == 'cython_function_or_method':
|
|
1045
|
-
|
|
1028
|
+
attr_name = 'source'
|
|
1046
1029
|
try:
|
|
1047
1030
|
source_lines = inspect.getsourcelines(self.fn)
|
|
1048
|
-
if context.get_context('support_binary')
|
|
1049
|
-
|
|
1050
|
-
(not hasattr(self.fn, attr) or getattr(self.fn, attr) != source_lines):
|
|
1051
|
-
if not os.access(self.filename, os.W_OK):
|
|
1052
|
-
raise PermissionError(f"Don't have the write permission on the file {self.filename}.")
|
|
1053
|
-
with open(self.filename, 'a') as f:
|
|
1054
|
-
f.write(f"\n# Set source attribute for function {self.function_name} "
|
|
1055
|
-
f"to support run so or pyc file in Graph Mode."
|
|
1056
|
-
f"\nsetattr({self.function_name}, '{attr}', {source_lines})\n")
|
|
1057
|
-
setattr(self.fn, attr, source_lines)
|
|
1031
|
+
if context.get_context('support_binary') or os.getenv('MS_SUPPORT_BINARY', None) == '1':
|
|
1032
|
+
self.save_source_code(attr_name, source_lines)
|
|
1058
1033
|
except (OSError, TypeError) as e:
|
|
1059
|
-
if hasattr(self.fn,
|
|
1060
|
-
source_lines = getattr(self.fn,
|
|
1034
|
+
if hasattr(self.fn, attr_name):
|
|
1035
|
+
source_lines = getattr(self.fn, attr_name)
|
|
1036
|
+
elif e.__str__() == "could not get source code":
|
|
1037
|
+
raise OSError(f"Mindspore can not compile temporary source code in terminal. "
|
|
1038
|
+
f"Please write source code to a python file and run the file.")
|
|
1061
1039
|
else:
|
|
1062
|
-
if e.__str__() == "could not get source code":
|
|
1063
|
-
raise OSError(f"Mindspore can not compile temporary source code in terminal. "
|
|
1064
|
-
f"Please write source code to a python file and run the file.")
|
|
1065
1040
|
raise e
|
|
1066
1041
|
self.lines, self.line_offset = source_lines
|
|
1067
1042
|
original_src = ''.join(self.lines)
|
|
@@ -1072,7 +1047,7 @@ class Parser:
|
|
|
1072
1047
|
self.col_offset = \
|
|
1073
1048
|
len(original_src.split('\n')[0]) - len(src.split('\n')[0])
|
|
1074
1049
|
logger.debug("Get source: %s", src)
|
|
1075
|
-
if not hasattr(self.fn,
|
|
1050
|
+
if not hasattr(self.fn, attr_name):
|
|
1076
1051
|
self.check_lambda(src)
|
|
1077
1052
|
try:
|
|
1078
1053
|
ast_tokens = asttokens.ASTTokens(src, parse=True)
|
|
@@ -76,6 +76,45 @@ parse_object_map = {
|
|
|
76
76
|
SYMBOL_UNDEFINE: (None, 'undefine', ''),
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
parse_augassign_object_map = {
|
|
80
|
+
# ast grammar
|
|
81
|
+
ast.Add: (trope_ns, 'augassign_add', '+='),
|
|
82
|
+
ast.Sub: (trope_ns, 'augassign_sub', '-='),
|
|
83
|
+
ast.Mult: (trope_ns, 'augassign_mul', '*='),
|
|
84
|
+
ast.Div: (trope_ns, 'augassign_div', '/='),
|
|
85
|
+
ast.FloorDiv: (trope_ns, 'augassign_floordiv', '//='),
|
|
86
|
+
|
|
87
|
+
ast.Mod: (trope_ns, 'mod', '%'),
|
|
88
|
+
ast.Pow: (trope_ns, 'pow', '**'),
|
|
89
|
+
ast.MatMult: (trope_ns, 'matmul', '@'),
|
|
90
|
+
ast.LShift: (trope_ns, 'lshift', '<<'),
|
|
91
|
+
ast.RShift: (trope_ns, 'rshift', '>>'),
|
|
92
|
+
ast.BitAnd: (trope_ns, 'and_', '&'),
|
|
93
|
+
ast.BitOr: (trope_ns, 'or_', '|'),
|
|
94
|
+
ast.BitXor: (trope_ns, 'xor', '^'),
|
|
95
|
+
ast.UAdd: (trope_ns, 'pos', '+'),
|
|
96
|
+
ast.USub: (trope_ns, 'neg', '-'),
|
|
97
|
+
ast.Invert: (trope_ns, 'invert', '~'),
|
|
98
|
+
ast.Not: (trope_ns, 'not_', 'not'),
|
|
99
|
+
ast.Eq: (trope_ns, 'eq', '=='),
|
|
100
|
+
ast.NotEq: (trope_ns, 'ne', '!='),
|
|
101
|
+
ast.Lt: (trope_ns, 'lt', '<'),
|
|
102
|
+
ast.Gt: (trope_ns, 'gt', '>'),
|
|
103
|
+
ast.LtE: (trope_ns, 'le', '<='),
|
|
104
|
+
ast.GtE: (trope_ns, 'ge', '>='),
|
|
105
|
+
ast.Is: (trope_ns, 'is_', 'is'),
|
|
106
|
+
ast.IsNot: (trope_ns, 'is_not', 'is not'),
|
|
107
|
+
ast.In: (trope_ns, 'contains', 'in'),
|
|
108
|
+
ast.NotIn: (trope_ns, 'not_contains', 'not in'),
|
|
109
|
+
|
|
110
|
+
# operation symbol type
|
|
111
|
+
'getitem': (composite_ns, 'getitem', ''),
|
|
112
|
+
'ms_next': (composite_ns, 'ms_next', ''),
|
|
113
|
+
|
|
114
|
+
# undefined type
|
|
115
|
+
SYMBOL_UNDEFINE: (None, 'undefine', ''),
|
|
116
|
+
}
|
|
117
|
+
|
|
79
118
|
# Operation symbols corresponding to ast grammar
|
|
80
119
|
ops_symbol_map = {
|
|
81
120
|
# ast grammar
|