mindspore 2.5.0__cp310-cp310-win_amd64.whl → 2.6.0rc1__cp310-cp310-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mindspore might be problematic. Click here for more details.
- mindspore/.commit_id +1 -1
- mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
- mindspore/Newtonsoft.Json.dll +0 -0
- mindspore/__init__.py +6 -4
- mindspore/_c_dataengine.cp310-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp310-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp310-win_amd64.pyd +0 -0
- mindspore/_check_jit_forbidden_api.py +3 -0
- mindspore/_checkparam.py +3 -33
- mindspore/_deprecated/__init__.py +17 -0
- mindspore/_deprecated/jit.py +198 -0
- mindspore/_extends/builtin_operations.py +1 -1
- mindspore/_extends/parse/__init__.py +6 -7
- mindspore/_extends/parse/compile_config.py +19 -0
- mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +22 -3
- mindspore/_extends/parse/jit_fallback_modules/__init__.py +0 -0
- mindspore/_extends/parse/jit_fallback_modules/check_utils.py +123 -0
- mindspore/_extends/parse/jit_fallback_modules/third_party_modules.py +50 -0
- mindspore/_extends/parse/parser.py +24 -193
- mindspore/_extends/parse/resources.py +1 -5
- mindspore/_extends/parse/standard_method.py +97 -74
- mindspore/_extends/pijit/__init__.py +2 -2
- mindspore/_extends/pijit/pijit_func_white_list.py +16 -11
- mindspore/_extends/pijit/tensor_func_list.py +27 -0
- mindspore/_extends/utils.py +1 -1
- mindspore/amp.py +4 -4
- mindspore/atlprov.dll +0 -0
- mindspore/avcodec-59.dll +0 -0
- mindspore/avdevice-59.dll +0 -0
- mindspore/avfilter-8.dll +0 -0
- mindspore/avformat-59.dll +0 -0
- mindspore/avutil-57.dll +0 -0
- mindspore/boost/__init__.py +2 -2
- mindspore/boost/base.py +3 -7
- mindspore/boost/boost_cell_wrapper.py +2 -2
- mindspore/c1.dll +0 -0
- mindspore/c1xx.dll +0 -0
- mindspore/c2.dll +0 -0
- mindspore/common/__init__.py +4 -3
- mindspore/common/_grad_function.py +56 -0
- mindspore/common/_pijit_context.py +14 -5
- mindspore/common/_register_for_tensor.py +1 -1
- mindspore/common/_stub_tensor.py +5 -10
- mindspore/common/_tensor_cpp_method.py +1 -1
- mindspore/common/_tensor_docs.py +1915 -3287
- mindspore/common/api.py +341 -354
- mindspore/common/auto_dynamic_shape.py +41 -44
- mindspore/common/dtype.py +5 -2
- mindspore/common/dump.py +7 -5
- mindspore/common/file_system.py +3 -0
- mindspore/common/hook_handle.py +5 -3
- mindspore/common/initializer.py +10 -6
- mindspore/common/jit_begin_end.py +94 -0
- mindspore/common/jit_config.py +6 -1
- mindspore/common/jit_context.py +76 -0
- mindspore/common/jit_trace.py +378 -0
- mindspore/common/lazy_inline.py +2 -2
- mindspore/common/mutable.py +5 -4
- mindspore/common/parameter.py +106 -39
- mindspore/common/seed.py +2 -2
- mindspore/common/sparse_tensor.py +23 -17
- mindspore/common/tensor.py +297 -714
- mindspore/communication/__init__.py +7 -5
- mindspore/communication/_comm_helper.py +47 -2
- mindspore/communication/comm_func.py +70 -53
- mindspore/communication/management.py +83 -17
- mindspore/context.py +214 -560
- mindspore/dataset/__init__.py +44 -20
- mindspore/dataset/audio/__init__.py +2 -8
- mindspore/dataset/audio/transforms.py +3 -17
- mindspore/dataset/core/config.py +3 -3
- mindspore/dataset/engine/cache_client.py +1 -1
- mindspore/dataset/engine/datasets.py +102 -120
- mindspore/dataset/engine/datasets_audio.py +22 -22
- mindspore/dataset/engine/datasets_standard_format.py +43 -24
- mindspore/dataset/engine/datasets_text.py +78 -85
- mindspore/dataset/engine/datasets_user_defined.py +108 -76
- mindspore/dataset/engine/datasets_vision.py +111 -108
- mindspore/dataset/engine/iterators.py +5 -3
- mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +1 -1
- mindspore/dataset/engine/samplers.py +279 -57
- mindspore/dataset/engine/serializer_deserializer.py +2 -1
- mindspore/dataset/engine/validators.py +10 -0
- mindspore/dataset/text/__init__.py +7 -6
- mindspore/dataset/text/transforms.py +6 -5
- mindspore/dataset/text/utils.py +3 -3
- mindspore/dataset/transforms/__init__.py +0 -9
- mindspore/dataset/transforms/transforms.py +3 -3
- mindspore/dataset/utils/browse_dataset.py +1 -1
- mindspore/dataset/vision/__init__.py +2 -9
- mindspore/dataset/vision/transforms.py +202 -158
- mindspore/dataset/vision/utils.py +7 -5
- mindspore/device_context/ascend/op_debug.py +60 -1
- mindspore/device_context/ascend/op_tuning.py +0 -4
- mindspore/device_manager.py +39 -3
- mindspore/dnnl.dll +0 -0
- mindspore/dpcmi.dll +0 -0
- mindspore/experimental/es/embedding_service.py +35 -27
- mindspore/experimental/map_parameter.py +4 -4
- mindspore/experimental/optim/adadelta.py +22 -26
- mindspore/experimental/optim/adagrad.py +4 -4
- mindspore/experimental/optim/adam.py +4 -0
- mindspore/experimental/optim/adamax.py +4 -4
- mindspore/experimental/optim/adamw.py +4 -0
- mindspore/experimental/optim/asgd.py +1 -1
- mindspore/experimental/optim/lr_scheduler.py +40 -22
- mindspore/experimental/optim/radam.py +5 -5
- mindspore/experimental/optim/rprop.py +1 -1
- mindspore/experimental/optim/sgd.py +1 -1
- mindspore/hal/contiguous_tensors_handle.py +6 -10
- mindspore/hal/device.py +55 -81
- mindspore/hal/event.py +38 -55
- mindspore/hal/memory.py +93 -144
- mindspore/hal/stream.py +81 -125
- mindspore/include/dataset/constants.h +7 -4
- mindspore/include/dataset/execute.h +2 -2
- mindspore/jpeg62.dll +0 -0
- mindspore/log.py +40 -2
- mindspore/mindrecord/__init__.py +20 -7
- 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_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_backend.dll → 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 +131 -700
- mindspore/mint/distributed/__init__.py +5 -1
- mindspore/mint/distributed/distributed.py +194 -109
- mindspore/mint/linalg/__init__.py +2 -0
- mindspore/mint/nn/__init__.py +280 -18
- mindspore/mint/nn/functional.py +282 -64
- mindspore/mint/nn/layer/__init__.py +4 -0
- mindspore/mint/nn/layer/_functions.py +7 -3
- mindspore/mint/nn/layer/activation.py +120 -13
- mindspore/mint/nn/layer/conv.py +218 -24
- mindspore/mint/nn/layer/normalization.py +15 -16
- mindspore/mint/nn/layer/padding.py +1 -1
- mindspore/mint/nn/layer/pooling.py +66 -1
- mindspore/mint/optim/__init__.py +2 -1
- mindspore/mint/optim/sgd.py +171 -0
- mindspore/msobj140.dll +0 -0
- mindspore/mspdb140.dll +0 -0
- mindspore/mspdbcore.dll +0 -0
- mindspore/mspdbst.dll +0 -0
- mindspore/mspft140.dll +0 -0
- mindspore/msvcdis140.dll +0 -0
- mindspore/msvcp140_1.dll +0 -0
- mindspore/msvcp140_2.dll +0 -0
- mindspore/msvcp140_atomic_wait.dll +0 -0
- mindspore/msvcp140_codecvt_ids.dll +0 -0
- mindspore/nn/__init__.py +4 -1
- mindspore/nn/cell.py +1250 -176
- mindspore/nn/layer/activation.py +23 -21
- mindspore/nn/layer/basic.py +22 -16
- mindspore/nn/layer/container.py +1 -1
- mindspore/nn/layer/conv.py +22 -17
- mindspore/nn/layer/embedding.py +9 -8
- mindspore/nn/layer/normalization.py +48 -42
- mindspore/nn/layer/pooling.py +75 -31
- mindspore/nn/layer/transformer.py +11 -10
- mindspore/nn/learning_rate_schedule.py +4 -2
- mindspore/nn/loss/loss.py +27 -19
- mindspore/nn/optim/ada_grad.py +6 -5
- mindspore/nn/optim/adadelta.py +9 -7
- mindspore/nn/optim/adafactor.py +1 -1
- mindspore/nn/optim/adam.py +16 -12
- mindspore/nn/optim/adamax.py +8 -7
- mindspore/nn/optim/adasum.py +5 -5
- mindspore/nn/optim/asgd.py +1 -1
- mindspore/nn/optim/ftrl.py +11 -9
- mindspore/nn/optim/lamb.py +1 -1
- mindspore/nn/optim/lazyadam.py +12 -10
- mindspore/nn/optim/momentum.py +7 -6
- mindspore/nn/optim/optimizer.py +2 -2
- mindspore/nn/optim/proximal_ada_grad.py +12 -10
- mindspore/nn/optim/rmsprop.py +13 -12
- mindspore/nn/optim/rprop.py +9 -7
- mindspore/nn/optim/sgd.py +9 -6
- mindspore/nn/optim/tft_wrapper.py +5 -2
- mindspore/nn/probability/bijector/bijector.py +17 -11
- mindspore/nn/probability/bijector/gumbel_cdf.py +5 -5
- mindspore/nn/probability/bijector/invert.py +2 -2
- mindspore/nn/probability/bijector/scalar_affine.py +3 -3
- mindspore/nn/probability/bijector/softplus.py +3 -2
- mindspore/nn/probability/distribution/beta.py +3 -3
- mindspore/nn/probability/distribution/categorical.py +1 -1
- mindspore/nn/probability/distribution/cauchy.py +4 -2
- mindspore/nn/probability/distribution/exponential.py +6 -7
- mindspore/nn/probability/distribution/gamma.py +2 -2
- mindspore/nn/probability/distribution/gumbel.py +2 -2
- mindspore/nn/probability/distribution/half_normal.py +5 -3
- mindspore/nn/probability/distribution/logistic.py +5 -3
- mindspore/nn/probability/distribution/poisson.py +1 -1
- mindspore/nn/probability/distribution/uniform.py +5 -3
- mindspore/nn/reinforcement/_tensors_queue.py +1 -1
- mindspore/nn/reinforcement/tensor_array.py +1 -1
- mindspore/nn/wrap/__init__.py +6 -6
- mindspore/nn/wrap/cell_wrapper.py +178 -117
- mindspore/nn/wrap/grad_reducer.py +45 -36
- mindspore/nn/wrap/loss_scale.py +3 -3
- mindspore/numpy/array_creations.py +3 -3
- mindspore/numpy/array_ops.py +1 -1
- mindspore/numpy/math_ops.py +4 -4
- mindspore/numpy/utils.py +1 -2
- mindspore/numpy/utils_const.py +1 -2
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/opencv_imgproc452.dll +0 -0
- mindspore/ops/__init__.py +3 -2
- mindspore/ops/_grad_experimental/grad_comm_ops.py +18 -3
- mindspore/ops/_grad_experimental/grad_debug_ops.py +8 -1
- mindspore/ops/_grad_experimental/taylor_rule.py +29 -0
- mindspore/ops/_register_for_op.py +0 -11
- mindspore/{ops_generate → ops/_utils}/arg_dtype_cast.py +123 -4
- mindspore/{ops_generate → ops/_utils}/arg_handler.py +3 -4
- mindspore/ops/_vmap/vmap_array_ops.py +7 -6
- mindspore/ops/_vmap/vmap_grad_nn_ops.py +2 -1
- mindspore/ops/_vmap/vmap_math_ops.py +4 -7
- mindspore/ops/_vmap/vmap_nn_ops.py +9 -8
- mindspore/ops/auto_generate/__init__.py +4 -3
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +102 -49
- mindspore/ops/auto_generate/gen_extend_func.py +281 -135
- mindspore/ops/auto_generate/gen_ops_def.py +2574 -2326
- mindspore/ops/auto_generate/gen_ops_prim.py +8566 -2755
- mindspore/ops/auto_generate/pyboost_inner_prim.py +106 -76
- mindspore/ops/composite/__init__.py +2 -1
- mindspore/ops/composite/base.py +19 -24
- mindspore/ops/composite/math_ops.py +6 -16
- mindspore/ops/composite/multitype_ops/__init__.py +5 -2
- mindspore/ops/composite/multitype_ops/_compile_utils.py +2 -3
- mindspore/ops/composite/multitype_ops/_constexpr_utils.py +1 -2
- mindspore/ops/composite/multitype_ops/add_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/bitwise_and_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/bitwise_or_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/bitwise_xor_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/div_impl.py +6 -4
- mindspore/ops/composite/multitype_ops/equal_impl.py +4 -3
- mindspore/ops/composite/multitype_ops/floordiv_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/getitem_impl.py +3 -2
- mindspore/ops/composite/multitype_ops/greater_equal_impl.py +4 -3
- mindspore/ops/composite/multitype_ops/greater_impl.py +4 -3
- mindspore/ops/composite/multitype_ops/in_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/invert_impl.py +50 -0
- mindspore/ops/composite/multitype_ops/left_shift_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/less_equal_impl.py +4 -3
- mindspore/ops/composite/multitype_ops/less_impl.py +4 -3
- mindspore/ops/composite/multitype_ops/logic_not_impl.py +3 -2
- mindspore/ops/composite/multitype_ops/logical_and_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/logical_or_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/mod_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/mul_impl.py +3 -2
- mindspore/ops/composite/multitype_ops/negative_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/not_equal_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/not_in_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/ones_like_impl.py +18 -0
- mindspore/ops/composite/multitype_ops/pow_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/right_shift_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/setitem_impl.py +2 -1
- mindspore/ops/composite/multitype_ops/sub_impl.py +2 -1
- mindspore/ops/function/__init__.py +28 -2
- mindspore/ops/function/_add_attr_func.py +58 -0
- mindspore/ops/function/array_func.py +1629 -2345
- mindspore/ops/function/clip_func.py +38 -45
- mindspore/ops/function/debug_func.py +36 -44
- mindspore/ops/function/grad/__init__.py +1 -0
- mindspore/ops/function/grad/grad_func.py +104 -71
- mindspore/ops/function/image_func.py +1 -1
- mindspore/ops/function/linalg_func.py +46 -78
- mindspore/ops/function/math_func.py +3035 -3705
- mindspore/ops/function/nn_func.py +676 -241
- mindspore/ops/function/other_func.py +159 -1
- mindspore/ops/function/parameter_func.py +17 -30
- mindspore/ops/function/random_func.py +204 -361
- mindspore/ops/function/reshard_func.py +4 -70
- mindspore/ops/function/sparse_func.py +3 -3
- mindspore/ops/function/sparse_unary_func.py +5 -5
- mindspore/ops/function/spectral_func.py +25 -58
- mindspore/ops/function/vmap_func.py +24 -17
- mindspore/ops/functional.py +6 -4
- mindspore/ops/functional_overload.py +547 -4
- mindspore/ops/op_info_register.py +32 -244
- mindspore/ops/operations/__init__.py +10 -5
- mindspore/ops/operations/_custom_ops_utils.py +247 -0
- mindspore/ops/operations/_grad_ops.py +1 -10
- mindspore/ops/operations/_inner_ops.py +5 -76
- mindspore/ops/operations/_ms_kernel.py +4 -10
- mindspore/ops/operations/_rl_inner_ops.py +1 -1
- mindspore/ops/operations/_scalar_ops.py +3 -2
- mindspore/ops/operations/_sequence_ops.py +1 -1
- mindspore/ops/operations/_tensor_array.py +1 -1
- mindspore/ops/operations/array_ops.py +37 -22
- mindspore/ops/operations/comm_ops.py +150 -107
- mindspore/ops/operations/custom_ops.py +221 -23
- mindspore/ops/operations/debug_ops.py +115 -16
- mindspore/ops/operations/inner_ops.py +1 -1
- mindspore/ops/operations/linalg_ops.py +1 -58
- mindspore/ops/operations/manually_defined/_inner.py +1 -1
- mindspore/ops/operations/manually_defined/ops_def.py +746 -79
- mindspore/ops/operations/math_ops.py +21 -18
- mindspore/ops/operations/nn_ops.py +65 -191
- mindspore/ops/operations/other_ops.py +62 -9
- mindspore/ops/operations/random_ops.py +13 -7
- mindspore/ops/operations/reshard_ops.py +1 -1
- mindspore/ops/operations/sparse_ops.py +2 -2
- mindspore/ops/primitive.py +43 -32
- mindspore/ops/tensor_method.py +232 -13
- mindspore/ops_generate/__init__.py +0 -5
- mindspore/ops_generate/aclnn/__init__.py +0 -0
- mindspore/ops_generate/{aclnn_kernel_register_auto_cc_generator.py → aclnn/aclnn_kernel_register_auto_cc_generator.py} +43 -18
- mindspore/ops_generate/{gen_aclnn_implement.py → aclnn/gen_aclnn_implement.py} +49 -51
- mindspore/ops_generate/api/__init__.py +0 -0
- mindspore/ops_generate/{add_tensor_docs_generator.py → api/add_tensor_docs_generator.py} +9 -7
- mindspore/ops_generate/{cpp_create_prim_instance_helper_generator.py → api/cpp_create_prim_instance_helper_generator.py} +6 -9
- mindspore/ops_generate/{functional_map_cpp_generator.py → api/functional_map_cpp_generator.py} +25 -12
- mindspore/ops_generate/{functional_overload_py_generator.py → api/functional_overload_py_generator.py} +8 -6
- mindspore/ops_generate/{functions_cc_generator.py → api/functions_cc_generator.py} +14 -10
- mindspore/ops_generate/api/gen_api.py +103 -0
- mindspore/ops_generate/{op_api_proto.py → api/op_api_proto.py} +98 -69
- mindspore/ops_generate/{tensor_func_reg_cpp_generator.py → api/tensor_func_reg_cpp_generator.py} +82 -43
- mindspore/ops_generate/common/__init__.py +0 -0
- mindspore/ops_generate/common/gen_constants.py +91 -0
- mindspore/ops_generate/{gen_utils.py → common/gen_utils.py} +72 -19
- mindspore/ops_generate/{op_proto.py → common/op_proto.py} +64 -1
- mindspore/ops_generate/{template.py → common/template.py} +96 -84
- mindspore/ops_generate/gen_ops.py +23 -325
- mindspore/ops_generate/op_def/__init__.py +0 -0
- mindspore/ops_generate/op_def/gen_op_def.py +90 -0
- mindspore/ops_generate/{lite_ops_cpp_generator.py → op_def/lite_ops_cpp_generator.py} +47 -11
- mindspore/ops_generate/{ops_def_cc_generator.py → op_def/ops_def_cc_generator.py} +18 -7
- mindspore/ops_generate/{ops_def_h_generator.py → op_def/ops_def_h_generator.py} +5 -5
- mindspore/ops_generate/{ops_name_h_generator.py → op_def/ops_name_h_generator.py} +30 -15
- mindspore/ops_generate/op_def/ops_primitive_h_generator.py +125 -0
- mindspore/ops_generate/op_def_py/__init__.py +0 -0
- mindspore/ops_generate/op_def_py/gen_op_def_py.py +47 -0
- mindspore/ops_generate/{op_def_py_generator.py → op_def_py/op_def_py_generator.py} +6 -5
- mindspore/ops_generate/{op_prim_py_generator.py → op_def_py/op_prim_py_generator.py} +24 -15
- mindspore/ops_generate/pyboost/__init__.py +0 -0
- mindspore/ops_generate/{auto_grad_impl_cc_generator.py → pyboost/auto_grad_impl_cc_generator.py} +11 -7
- mindspore/ops_generate/{auto_grad_reg_cc_generator.py → pyboost/auto_grad_reg_cc_generator.py} +7 -7
- mindspore/ops_generate/{gen_pyboost_func.py → pyboost/gen_pyboost_func.py} +40 -16
- mindspore/ops_generate/{op_template_parser.py → pyboost/op_template_parser.py} +105 -24
- mindspore/ops_generate/{pyboost_functions_cpp_generator.py → pyboost/pyboost_functions_cpp_generator.py} +55 -18
- mindspore/ops_generate/{pyboost_functions_h_generator.py → pyboost/pyboost_functions_h_generator.py} +42 -10
- mindspore/ops_generate/{pyboost_functions_py_generator.py → pyboost/pyboost_functions_py_generator.py} +6 -6
- mindspore/ops_generate/{pyboost_grad_function_cpp_generator.py → pyboost/pyboost_grad_function_cpp_generator.py} +11 -10
- mindspore/ops_generate/{pyboost_inner_prim_generator.py → pyboost/pyboost_inner_prim_generator.py} +8 -7
- mindspore/ops_generate/{pyboost_native_grad_functions_generator.py → pyboost/pyboost_native_grad_functions_generator.py} +14 -10
- mindspore/ops_generate/{pyboost_op_cpp_code_generator.py → pyboost/pyboost_op_cpp_code_generator.py} +140 -53
- mindspore/ops_generate/{pyboost_overload_functions_cpp_generator.py → pyboost/pyboost_overload_functions_cpp_generator.py} +28 -15
- mindspore/ops_generate/{pyboost_utils.py → pyboost/pyboost_utils.py} +88 -4
- mindspore/ops_generate/resources/__init__.py +0 -0
- mindspore/ops_generate/resources/resource_list.py +30 -0
- mindspore/ops_generate/resources/resource_loader.py +36 -0
- mindspore/ops_generate/resources/resource_manager.py +64 -0
- mindspore/ops_generate/resources/yaml_loader.py +88 -0
- mindspore/ops_generate/tensor_py_cc_generator.py +122 -0
- mindspore/parallel/__init__.py +6 -2
- mindspore/parallel/_auto_parallel_context.py +133 -6
- mindspore/parallel/_cell_wrapper.py +130 -15
- mindspore/parallel/_parallel_serialization.py +95 -4
- mindspore/parallel/_ps_context.py +1 -1
- mindspore/parallel/_recovery_context.py +7 -2
- mindspore/parallel/_tensor.py +142 -18
- mindspore/parallel/_utils.py +198 -25
- mindspore/parallel/algo_parameter_config.py +3 -3
- mindspore/parallel/auto_parallel.py +732 -0
- mindspore/parallel/checkpoint_convert.py +159 -0
- mindspore/parallel/checkpoint_transform.py +656 -37
- mindspore/parallel/cluster/process_entity/_api.py +151 -19
- mindspore/parallel/cluster/run.py +1 -1
- mindspore/parallel/function/__init__.py +24 -0
- mindspore/parallel/function/reshard_func.py +259 -0
- mindspore/parallel/nn/__init__.py +25 -0
- mindspore/parallel/nn/parallel_cell_wrapper.py +263 -0
- mindspore/parallel/nn/parallel_grad_reducer.py +169 -0
- mindspore/parallel/parameter_broadcast.py +24 -13
- mindspore/parallel/shard.py +137 -61
- mindspore/parallel/transform_safetensors.py +287 -95
- mindspore/pgodb140.dll +0 -0
- mindspore/pgort140.dll +0 -0
- mindspore/profiler/__init__.py +9 -5
- mindspore/profiler/analysis/parser/ascend_cann_parser.py +6 -2
- mindspore/profiler/analysis/parser/ms_framework_parser.py +4 -4
- mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +7 -4
- mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +22 -0
- mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +3 -3
- mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +241 -86
- mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +41 -2
- mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +33 -35
- mindspore/profiler/analysis/viewer/ascend_memory_viewer.py +7 -0
- mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +8 -3
- mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +141 -30
- mindspore/profiler/analysis/viewer/ms_dataset_viewer.py +5 -6
- mindspore/profiler/common/ascend_msprof_exporter.py +5 -4
- mindspore/profiler/common/constant.py +12 -0
- mindspore/profiler/common/msprof_cmd_tool.py +42 -23
- mindspore/profiler/common/path_manager.py +24 -0
- mindspore/profiler/common/profiler_context.py +26 -2
- mindspore/profiler/common/profiler_meta_data.py +74 -0
- mindspore/profiler/common/profiler_parameters.py +59 -18
- mindspore/profiler/common/profiler_path_manager.py +66 -7
- mindspore/profiler/dynamic_profiler.py +112 -79
- mindspore/profiler/envprofiler.py +26 -1
- mindspore/profiler/experimental_config.py +197 -0
- mindspore/profiler/mstx.py +57 -14
- mindspore/profiler/platform/npu_profiler.py +33 -7
- mindspore/profiler/profiler.py +541 -45
- mindspore/profiler/profiler_action_controller.py +1 -1
- mindspore/profiler/profiler_interface.py +4 -0
- mindspore/profiler/schedule.py +57 -22
- mindspore/rewrite/api/node.py +15 -13
- mindspore/rewrite/api/symbol_tree.py +1 -1
- mindspore/run_check/_check_version.py +25 -14
- mindspore/run_check/run_check.py +1 -1
- mindspore/runtime/__init__.py +2 -2
- mindspore/runtime/executor.py +40 -11
- mindspore/runtime/memory.py +25 -8
- mindspore/safeguard/rewrite_obfuscation.py +12 -9
- mindspore/swresample-4.dll +0 -0
- mindspore/swscale-6.dll +0 -0
- mindspore/tbbmalloc.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/__init__.py +8 -8
- mindspore/train/_utils.py +35 -7
- mindspore/train/amp.py +1 -1
- mindspore/train/callback/__init__.py +2 -2
- mindspore/train/callback/_callback.py +2 -16
- mindspore/train/callback/_checkpoint.py +24 -40
- mindspore/train/callback/_cluster_monitor.py +14 -18
- mindspore/train/callback/_flops_collector.py +2 -3
- mindspore/train/callback/_history.py +7 -4
- mindspore/train/callback/_lambda_callback.py +2 -2
- mindspore/train/callback/_landscape.py +0 -3
- mindspore/train/callback/_loss_monitor.py +2 -1
- mindspore/train/callback/_on_request_exit.py +6 -5
- mindspore/train/callback/_reduce_lr_on_plateau.py +11 -6
- mindspore/train/callback/_summary_collector.py +8 -13
- mindspore/train/callback/_time_monitor.py +2 -1
- mindspore/train/callback/{_tft_register.py → _train_fault_tolerance.py} +179 -103
- mindspore/train/data_sink.py +25 -2
- mindspore/train/dataset_helper.py +4 -5
- mindspore/train/loss_scale_manager.py +8 -7
- mindspore/train/metrics/accuracy.py +3 -3
- mindspore/train/metrics/confusion_matrix.py +9 -9
- mindspore/train/metrics/error.py +3 -3
- mindspore/train/metrics/hausdorff_distance.py +4 -4
- mindspore/train/metrics/mean_surface_distance.py +3 -3
- mindspore/train/metrics/metric.py +0 -12
- mindspore/train/metrics/occlusion_sensitivity.py +4 -2
- mindspore/train/metrics/precision.py +8 -6
- mindspore/train/metrics/recall.py +9 -9
- mindspore/train/metrics/root_mean_square_surface_distance.py +2 -2
- mindspore/train/mind_ir_pb2.py +19 -12
- mindspore/train/model.py +176 -103
- mindspore/train/serialization.py +246 -988
- mindspore/train/summary/_summary_adapter.py +2 -2
- mindspore/train/summary/summary_record.py +1 -1
- mindspore/turbojpeg.dll +0 -0
- mindspore/utils/__init__.py +3 -2
- mindspore/utils/dryrun.py +4 -2
- mindspore/utils/hooks.py +81 -0
- mindspore/utils/utils.py +138 -4
- mindspore/vcmeta.dll +0 -0
- mindspore/vcruntime140.dll +0 -0
- mindspore/vcruntime140_1.dll +0 -0
- mindspore/version.py +1 -1
- {mindspore-2.5.0.dist-info → mindspore-2.6.0rc1.dist-info}/METADATA +2 -1
- {mindspore-2.5.0.dist-info → mindspore-2.6.0rc1.dist-info}/RECORD +483 -438
- mindspore/_install_custom.py +0 -43
- mindspore/common/_register_for_adapter.py +0 -74
- mindspore/ops/auto_generate/gen_arg_dtype_cast.py +0 -252
- mindspore/ops/auto_generate/gen_arg_handler.py +0 -136
- mindspore/ops/operations/_opaque_predicate_registry.py +0 -41
- mindspore/ops_generate/gen_constants.py +0 -190
- mindspore/ops_generate/gen_ops_inner_prim.py +0 -131
- mindspore/ops_generate/ops_primitive_h_generator.py +0 -81
- /mindspore/ops_generate/{base_generator.py → common/base_generator.py} +0 -0
- {mindspore-2.5.0.dist-info → mindspore-2.6.0rc1.dist-info}/WHEEL +0 -0
- {mindspore-2.5.0.dist-info → mindspore-2.6.0rc1.dist-info}/entry_points.txt +0 -0
- {mindspore-2.5.0.dist-info → mindspore-2.6.0rc1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
"""Third-party modules."""
|
|
16
|
+
|
|
17
|
+
# List common third-party modules for JIT Fallback.
|
|
18
|
+
third_party_modules_whitelist = (
|
|
19
|
+
# Python built-in modules.
|
|
20
|
+
"datetime", "re", "difflib", "math", "cmath", "random",
|
|
21
|
+
# Machine Learning.
|
|
22
|
+
"ml_metrics", "nupic", "sklearn", "pyspark", "vowpal_porpoise", "xgboost", "tensorflow", "torch", "jax",
|
|
23
|
+
# Natual Language Processing.
|
|
24
|
+
"gensim", "jieba", "langid", "nltk", "pattern", "polyglot", "snownlp", "spacy", "textblob", "quepy", "yalign",
|
|
25
|
+
"spammy", "genius", "konlpy", "nut", "rosetta", "bllipparser", "pynlpl", "ucto", "frog", "zpar", "colibricore",
|
|
26
|
+
"StanfordDependencies", "distance", "thefuzz", "jellyfish", "editdistance", "textacy", "pycorenlp", "cltk",
|
|
27
|
+
"rasa_nlu", "drqa", "dedupe",
|
|
28
|
+
# Text Processing.
|
|
29
|
+
"chardet", "ftfy", "Levenshtein", "pangu", "pyfiglet", "pypinyin", "shortuuid", "unidecode", "uniout",
|
|
30
|
+
"xpinyin", "slugify", "phonenumbers", "ply", "pygments", "pyparsing", "nameparser", "user_agents", "sqlparse",
|
|
31
|
+
# Web Content Extracting.
|
|
32
|
+
"haul", "html2text", "lassie", "micawber", "newspaper", "goose", "readability", "requests_html", "sanitize",
|
|
33
|
+
"sumy", "textract", "toapi",
|
|
34
|
+
# Web Crawling.
|
|
35
|
+
"cola", "demiurge", "feedparser", "grab", "mechanicalsoup", "pyspider", "robobrowser", "scrapy",
|
|
36
|
+
# Algorithms and Design Patterns.
|
|
37
|
+
"algorithms", "pypattyrn", "sortedcontainers", "scoop",
|
|
38
|
+
# Cryptography.
|
|
39
|
+
"cryptography", "hashids", "paramiko", "passlib", "nacl",
|
|
40
|
+
# Data Analysis (without plotting).
|
|
41
|
+
"numpy", "scipy", "blaze", "pandas", "numba", "pymc", "zipline", "pydy", "sympy", "statsmodels", "astropy",
|
|
42
|
+
"vincent", "pygal", "pycascading", "emcee", "windml", "vispy", "Dora", "ruffus", "sompy", "somoclu", "hdbscan",
|
|
43
|
+
# Computer Vision.
|
|
44
|
+
"PIL", "skimage", "SimpleCV", "PCV", "face_recognition",
|
|
45
|
+
# General-Purpose Machine Learning.
|
|
46
|
+
"cntk", "auto_ml", "xgboost", "featureforge", "scikits", "metric_learn", "simpleai", "bigml", "pylearn2", "keras",
|
|
47
|
+
"lasagne", "hebel", "topik", "pybrain", "surprise", "recsys", "thinkbayes", "nilearn", "neuropredict", "pyevolve",
|
|
48
|
+
"pyhsmm", "mrjob", "neurolab", "pebl", "yahmm", "timbl", "deap", "deeppy", "mlxtend", "neon", "optunity", "topt",
|
|
49
|
+
"pgmpy", "milk", "rep", "rgf", "FukuML", "stacked_generalization", "modAL", "cogitare", "gym",
|
|
50
|
+
)
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
|
|
19
19
|
from __future__ import absolute_import
|
|
20
20
|
import os
|
|
21
|
-
import sys
|
|
22
21
|
import ast
|
|
23
22
|
import re
|
|
24
23
|
import hashlib
|
|
@@ -39,15 +38,15 @@ from mindspore import nn
|
|
|
39
38
|
from mindspore import ops
|
|
40
39
|
from mindspore import context
|
|
41
40
|
from mindspore import tensor
|
|
42
|
-
from mindspore.common.api import
|
|
41
|
+
from mindspore.common.api import _JitExecutor
|
|
43
42
|
from mindspore.common import dtype as mstype
|
|
44
43
|
from mindspore.common.parameter import Parameter
|
|
45
44
|
from mindspore.common import mutable
|
|
46
|
-
from mindspore.common._register_for_adapter import ms_adapter_registry
|
|
47
45
|
from mindspore._checkparam import is_stub_tensor
|
|
48
46
|
from .namespace import Namespace, ModuleNamespace, ClosureNamespace, ClassMemberNamespace
|
|
49
47
|
from .resources import parse_object_map, ops_symbol_map, convert_object_map, convert_class_to_function_map, trope_ns
|
|
50
48
|
from .resources import SYMBOL_UNDEFINE, constant_fold_functions
|
|
49
|
+
from .jit_fallback_modules.check_utils import third_party_checker
|
|
51
50
|
from ...common.api import _convert_python_data
|
|
52
51
|
|
|
53
52
|
# Define resolve type
|
|
@@ -62,6 +61,7 @@ RESOLVE_TYPE_NUMPY_FLOAT_NUMBER = 7 # Resolve numpy float number.
|
|
|
62
61
|
RESOLVE_TYPE_NUMPY_BOOL_NUMBER = 8 # Resolve numpy bool number.
|
|
63
62
|
RESOLVE_TYPE_TUPLE = 9 # Resolve builtin tuple type.
|
|
64
63
|
RESOLVE_TYPE_LIST = 10 # Resolve builtin list type.
|
|
64
|
+
RESOLVE_TYPE_BUILTIN_METHOD = 11 # Resolve builtin type.
|
|
65
65
|
RESOLVE_TYPE_INVALID = 0xFF # Resolve invalid.
|
|
66
66
|
|
|
67
67
|
# Define the class instance detail type
|
|
@@ -70,7 +70,6 @@ CLASS_INSTANCE_TYPE_CELL = 0 # Class instance type is Cell
|
|
|
70
70
|
CLASS_INSTANCE_TYPE_PRIMITIVE = 1 # Class instance type is Primitive
|
|
71
71
|
CLASS_INSTANCE_TYPE_NUMPY_ARRAY = 2 # Class instance type is Numpy Array
|
|
72
72
|
CLASS_INSTANCE_TYPE_TENSOR = 3 # Class instance type is Tensor
|
|
73
|
-
CLASS_INSTANCE_TYPE_ADAPTER_TENSOR = 4 # Class instance type is Adapter Tensor
|
|
74
73
|
CLASS_INSTANCE_TYPE_INVALID = 0xFF
|
|
75
74
|
|
|
76
75
|
# Ast main type
|
|
@@ -98,12 +97,6 @@ SYNTAX_UNSUPPORTED_EXTERNAL_TYPE = 2 # Unsupported external type
|
|
|
98
97
|
SYNTAX_HYBRID_TYPE = 3 # Hybrid type
|
|
99
98
|
SYNTAX_UNSUPPORTED_NAMESPACE = 4 # Unsupported namespace
|
|
100
99
|
|
|
101
|
-
# Module source location
|
|
102
|
-
MODULE_FROM_MINDSPORE = 0
|
|
103
|
-
MODULE_FROM_THIRDPARTY = 1
|
|
104
|
-
MODULE_FROM_USER_WORKSPACE = 2
|
|
105
|
-
|
|
106
|
-
|
|
107
100
|
# Process expr statement white list
|
|
108
101
|
# Add as needed, eg: "clear", "extend", "insert", "remove", "reverse"
|
|
109
102
|
parse_expr_statement_white_list = (
|
|
@@ -137,23 +130,9 @@ _fallback_unsupported_python_builtin_type = (
|
|
|
137
130
|
compile, eval, exec
|
|
138
131
|
)
|
|
139
132
|
|
|
140
|
-
_modules_from_mindspore = (
|
|
141
|
-
"mindspore", "msadapter", "mindocr", "mindyolo", "mindnlp", "mindcv", "mindspore_rec", "mindaudio", "mindone",
|
|
142
|
-
"mindspore_rl", "mindformers", "mindpet", "mindpose", "mindface", "mindsearch", "mindinsight", "mindelec",
|
|
143
|
-
"mindflow", "mindsponge", "mindearth", "sciai", "mindquantum", "mindarmour", "mindpandas", "mindvision",
|
|
144
|
-
"mindspore_gl", "mindspore_federated", "mindspore_gs", "mindspore_serving", "mindspore_xai", "mindspore_hub",
|
|
145
|
-
"ringmo_framework", "troubleshooter", "mindtorch", "mindchemistry",
|
|
146
|
-
)
|
|
147
|
-
|
|
148
133
|
_global_params = {}
|
|
149
134
|
|
|
150
135
|
|
|
151
|
-
def _convert_map():
|
|
152
|
-
"""Get convert object map"""
|
|
153
|
-
adapter_convert_map = ms_adapter_registry.convert_map
|
|
154
|
-
return adapter_convert_map if adapter_convert_map else convert_object_map
|
|
155
|
-
|
|
156
|
-
|
|
157
136
|
def create_slice_obj(start, end, step):
|
|
158
137
|
"""Create slice object"""
|
|
159
138
|
return slice(start, end, step)
|
|
@@ -271,9 +250,8 @@ def resolve_symbol(namespace, symbol):
|
|
|
271
250
|
return resolve_
|
|
272
251
|
|
|
273
252
|
# If need trope the obj
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
resolve_ = convert_map.get(resolve_)
|
|
253
|
+
if resolve_ in convert_object_map:
|
|
254
|
+
resolve_ = convert_object_map.get(resolve_)
|
|
277
255
|
logger.debug("Convert resolve: %r", resolve_)
|
|
278
256
|
except Exception as e:
|
|
279
257
|
if isinstance(e, NotImplementedError):
|
|
@@ -283,8 +261,8 @@ def resolve_symbol(namespace, symbol):
|
|
|
283
261
|
logger.debug("Resolve type is invalid, namespace: %s, symbol: %s",
|
|
284
262
|
namespace.__str__(), symbol)
|
|
285
263
|
|
|
286
|
-
if isinstance(resolve_,
|
|
287
|
-
logger.debug("Resolve class
|
|
264
|
+
if isinstance(resolve_, _JitExecutor):
|
|
265
|
+
logger.debug("Resolve class _JitExecutor, resolve fn instead.")
|
|
288
266
|
resolve_ = resolve_.fn
|
|
289
267
|
logger.debug(f"Found '{symbol}' in {namespace.__str__()}, resolved: {resolve_} / {type(resolve_)}")
|
|
290
268
|
return resolve_
|
|
@@ -325,7 +303,8 @@ def get_object_key(obj):
|
|
|
325
303
|
logger.debug("obj_key: %s, obj_id: %s", obj_key, obj_id)
|
|
326
304
|
|
|
327
305
|
# Method has same id of different instance
|
|
328
|
-
if isinstance(obj, types.MethodType)
|
|
306
|
+
if isinstance(obj, types.MethodType) or \
|
|
307
|
+
(isinstance(obj, types.BuiltinMethodType) and obj.__qualname__.split('.')[0] == Tensor.__name__):
|
|
329
308
|
method_instance = obj.__self__
|
|
330
309
|
instance_id = "%s_ID%d" % (str(method_instance.__class__.__name__), id(method_instance))
|
|
331
310
|
if isinstance(method_instance, (tuple, list, dict)):
|
|
@@ -400,6 +379,8 @@ def get_obj_type(obj):
|
|
|
400
379
|
obj_type = RESOLVE_TYPE_NUMPY_FLOAT_NUMBER
|
|
401
380
|
elif _is_numpy_bool_number(obj):
|
|
402
381
|
obj_type = RESOLVE_TYPE_NUMPY_BOOL_NUMBER
|
|
382
|
+
elif isinstance(obj, types.BuiltinMethodType) and obj.__qualname__.split('.')[0] == Tensor.__name__:
|
|
383
|
+
obj_type = RESOLVE_TYPE_BUILTIN_METHOD
|
|
403
384
|
else:
|
|
404
385
|
obj_type = RESOLVE_TYPE_INVALID
|
|
405
386
|
return obj_type
|
|
@@ -501,7 +482,7 @@ def convert_class_to_function(cls_str, cls_obj):
|
|
|
501
482
|
f"supported in 'construct' or @jit decorated function. Try to create {cls_str} "
|
|
502
483
|
f"instances external such as initialized in the method '__init__' before assigning. "
|
|
503
484
|
f"For more details, please refer to "
|
|
504
|
-
f"https://www.mindspore.cn/
|
|
485
|
+
f"https://www.mindspore.cn/tutorials/zh-CN/master/compile/static_graph.html \n")
|
|
505
486
|
return convert_class_to_function_map.get(cls_str)
|
|
506
487
|
|
|
507
488
|
|
|
@@ -608,28 +589,6 @@ def is_class_type(cls):
|
|
|
608
589
|
return isinstance(cls, type)
|
|
609
590
|
|
|
610
591
|
|
|
611
|
-
def get_adapter_tensor_attr(name):
|
|
612
|
-
"""Get the method or @property modified function of the class, excluding those inherited from parent class."""
|
|
613
|
-
cls = ms_adapter_registry.tensor
|
|
614
|
-
properties = [key for key, value in vars(cls).items() if isinstance(value, property)]
|
|
615
|
-
if name in properties:
|
|
616
|
-
return getattr(cls, name).fget, True
|
|
617
|
-
methods = [key for key, value in vars(cls).items() if inspect.isfunction(value)]
|
|
618
|
-
if name in methods:
|
|
619
|
-
return getattr(cls, name), False
|
|
620
|
-
return None, False
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
def is_adapter_tensor_class(cls):
|
|
624
|
-
"""Check if cls is adapter tensor type."""
|
|
625
|
-
return cls in (Tensor, ms_adapter_registry.tensor)
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
def is_adapter_parameter_class(cls):
|
|
629
|
-
"""Check if cls is adapter parameter type."""
|
|
630
|
-
return cls in (Parameter, ms_adapter_registry.parameter)
|
|
631
|
-
|
|
632
|
-
|
|
633
592
|
def get_ms_class_name(cls):
|
|
634
593
|
"""Get the name of the class instance decorated with jit_class."""
|
|
635
594
|
if isinstance(cls, type):
|
|
@@ -929,133 +888,13 @@ def check_is_subclass(target_object, parent):
|
|
|
929
888
|
return False
|
|
930
889
|
|
|
931
890
|
|
|
932
|
-
class ThirdPartyLibraryChecker:
|
|
933
|
-
"""
|
|
934
|
-
Check if a module or function is from third-party libraries.
|
|
935
|
-
|
|
936
|
-
Rules for detecting third-party libraries:
|
|
937
|
-
|
|
938
|
-
1. The mindspore module and its suite are not third-party libraries.
|
|
939
|
-
|
|
940
|
-
2. Python built-in modules and python standard libraries are third-party libraries.
|
|
941
|
-
|
|
942
|
-
3. Modules with module names provided by MS_JIT_IGNORE_MODULES are treated as third-party
|
|
943
|
-
libraries, but those provided by MS_JIT_MODULES are not.
|
|
944
|
-
|
|
945
|
-
4. Third-party libraries have 'site-packages' in their installation path.
|
|
946
|
-
"""
|
|
947
|
-
def __init__(self):
|
|
948
|
-
self.user_workspace_dir = self.get_top_level_module_path(os.getcwd())
|
|
949
|
-
self.python_builtin_dir = os.path.realpath(os.path.dirname(os.__file__))
|
|
950
|
-
|
|
951
|
-
@staticmethod
|
|
952
|
-
def get_jit_modules():
|
|
953
|
-
"""Modules in jit_modules require jit."""
|
|
954
|
-
jit_modules = []
|
|
955
|
-
# Get jit modules from environment variable.
|
|
956
|
-
env_modules = os.getenv('MS_JIT_MODULES')
|
|
957
|
-
if env_modules is not None:
|
|
958
|
-
jit_modules = env_modules.split(',')
|
|
959
|
-
return jit_modules
|
|
960
|
-
|
|
961
|
-
@staticmethod
|
|
962
|
-
def get_jit_ignore_modules():
|
|
963
|
-
"""Modules in jit_ignore_modules do not need jit."""
|
|
964
|
-
jit_ignore_modules = []
|
|
965
|
-
# Get jit ignore modules from environment variable.
|
|
966
|
-
env_modules = os.getenv('MS_JIT_IGNORE_MODULES')
|
|
967
|
-
if env_modules is not None:
|
|
968
|
-
jit_ignore_modules = env_modules.split(',')
|
|
969
|
-
# sys.builtin_module_names do not need jit.
|
|
970
|
-
jit_ignore_modules.extend(sys.builtin_module_names)
|
|
971
|
-
return jit_ignore_modules
|
|
972
|
-
|
|
973
|
-
@staticmethod
|
|
974
|
-
def is_mindspore_related_module(module):
|
|
975
|
-
"""Check if module is mindspore module or its suite."""
|
|
976
|
-
module_leftmost_name = module.__name__.split('.')[0]
|
|
977
|
-
return module_leftmost_name in _modules_from_mindspore
|
|
978
|
-
|
|
979
|
-
def get_top_level_module_path(self, module_path):
|
|
980
|
-
"""Get the path of the top level package of the current working directory."""
|
|
981
|
-
module_abspath = os.path.realpath(module_path)
|
|
982
|
-
upper_path = os.path.realpath(os.path.dirname(module_abspath))
|
|
983
|
-
if module_abspath == upper_path:
|
|
984
|
-
return module_abspath
|
|
985
|
-
# Check whether __init__.py exists in the upper directory.
|
|
986
|
-
init_path = os.path.join(upper_path, '__init__.py')
|
|
987
|
-
# If the path does not exist or is accessed without permission, os.path.isfile returns false.
|
|
988
|
-
if os.path.isfile(init_path):
|
|
989
|
-
module_abspath = self.get_top_level_module_path(upper_path)
|
|
990
|
-
return module_abspath
|
|
991
|
-
|
|
992
|
-
def is_third_party_module(self, module):
|
|
993
|
-
"""Check if module is a third-party library."""
|
|
994
|
-
module_leftmost_name = module.__name__.split('.')[0]
|
|
995
|
-
# Modules in jit_ignore_modules are treated as third-party libraries, such as sys.builtin_module_names.
|
|
996
|
-
jit_ignore_modules = self.get_jit_ignore_modules()
|
|
997
|
-
if module_leftmost_name in jit_ignore_modules:
|
|
998
|
-
logger.debug(f"Found third-party module '{module_leftmost_name}' in jit_ignore_modules.")
|
|
999
|
-
return True
|
|
1000
|
-
# Modules in jit_modules require jit and they are considered to be in user workspace.
|
|
1001
|
-
jit_modules = self.get_jit_modules()
|
|
1002
|
-
if module_leftmost_name in jit_modules:
|
|
1003
|
-
logger.debug(f"Found user-defined module '{module_leftmost_name}' in jit_modules.")
|
|
1004
|
-
return False
|
|
1005
|
-
# A modules without __file__ attribute is considered to be in user workspace.
|
|
1006
|
-
if not hasattr(module, '__file__'):
|
|
1007
|
-
return False
|
|
1008
|
-
module_path = os.path.realpath(module.__file__)
|
|
1009
|
-
# Python builtin modules are treated as third-party libraries.
|
|
1010
|
-
if module_path.startswith(self.python_builtin_dir):
|
|
1011
|
-
logger.debug(f"Found python builtin module '{module.__name__}', which is a third-party module.")
|
|
1012
|
-
return True
|
|
1013
|
-
# Check if module is under user workspace directory.
|
|
1014
|
-
if module_path.startswith(self.user_workspace_dir):
|
|
1015
|
-
logger.debug(f"Found module '{module.__name__}' in user_workspace_dir: {self.user_workspace_dir}")
|
|
1016
|
-
return False
|
|
1017
|
-
# Third-party modules are under site-packages.
|
|
1018
|
-
split_path = module_path.split(os.path.sep)
|
|
1019
|
-
result = "site-packages" in split_path
|
|
1020
|
-
if result:
|
|
1021
|
-
logger.debug(f"Found third-party module '{module.__name__}' in path '{module_path}'")
|
|
1022
|
-
return result
|
|
1023
|
-
|
|
1024
|
-
def get_module_source_location(self, module):
|
|
1025
|
-
"""Get the source location of the module."""
|
|
1026
|
-
if self.is_mindspore_related_module(module):
|
|
1027
|
-
return MODULE_FROM_MINDSPORE
|
|
1028
|
-
if self.is_third_party_module(module):
|
|
1029
|
-
return MODULE_FROM_THIRDPARTY
|
|
1030
|
-
return MODULE_FROM_USER_WORKSPACE
|
|
1031
|
-
|
|
1032
|
-
def is_third_party_module_or_function(self, value):
|
|
1033
|
-
"""Check if value is from a third-party library."""
|
|
1034
|
-
if inspect.ismodule(value):
|
|
1035
|
-
module = value
|
|
1036
|
-
elif (isinstance(value, types.FunctionType) and not hasattr(value, "__jit_function__")) or \
|
|
1037
|
-
(isinstance(value, types.MethodType) and not hasattr(value.__func__, "__jit_function__")):
|
|
1038
|
-
value_hashable = True
|
|
1039
|
-
try:
|
|
1040
|
-
hash(value)
|
|
1041
|
-
except TypeError:
|
|
1042
|
-
value_hashable = False
|
|
1043
|
-
if value_hashable and value in _convert_map():
|
|
1044
|
-
return False
|
|
1045
|
-
module = inspect.getmodule(value)
|
|
1046
|
-
if module is None:
|
|
1047
|
-
return False
|
|
1048
|
-
else:
|
|
1049
|
-
return False
|
|
1050
|
-
return self.get_module_source_location(module) == MODULE_FROM_THIRDPARTY
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
third_party_checker = ThirdPartyLibraryChecker()
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
891
|
def is_from_third_party_library(value):
|
|
1057
892
|
"""Check if value is from a third-party library."""
|
|
1058
|
-
return third_party_checker.
|
|
893
|
+
return third_party_checker.is_from_third_party_module(value)
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
def convert_to_mutable(object):
|
|
897
|
+
return mutable(object)
|
|
1059
898
|
|
|
1060
899
|
|
|
1061
900
|
def get_const_abs(obj):
|
|
@@ -1092,7 +931,11 @@ def is_ms_tensor_method(obj):
|
|
|
1092
931
|
fn = inspect.unwrap(obj.__func__ if isinstance(obj, types.MethodType) else obj)
|
|
1093
932
|
tensor_method = getattr(Tensor, obj.__name__)
|
|
1094
933
|
tensor_method = tensor_method.__func__ if hasattr(tensor_method, "__func__") else tensor_method
|
|
1095
|
-
|
|
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
|
|
1096
939
|
|
|
1097
940
|
|
|
1098
941
|
def can_constant_fold(obj):
|
|
@@ -1131,7 +974,7 @@ class Parser:
|
|
|
1131
974
|
@staticmethod
|
|
1132
975
|
def is_unsupported_namespace(value):
|
|
1133
976
|
"""To check if not supported for namespace"""
|
|
1134
|
-
unsupported = isinstance(value, _builtin_function_or_method_type) and value not in
|
|
977
|
+
unsupported = isinstance(value, _builtin_function_or_method_type) and value not in convert_object_map
|
|
1135
978
|
logger.debug(f"'{value}' unsupported: {unsupported}.")
|
|
1136
979
|
if unsupported and value in _fallback_unsupported_python_builtin_type:
|
|
1137
980
|
raise TypeError(f"'{value}' is not supported both in JIT Fallback and graph mode.")
|
|
@@ -1149,18 +992,8 @@ class Parser:
|
|
|
1149
992
|
"""To check if is class Tensor type"""
|
|
1150
993
|
if value == Tensor:
|
|
1151
994
|
return CLASS_INSTANCE_TYPE_TENSOR
|
|
1152
|
-
if issubclass(value, ms_adapter_registry.tensor):
|
|
1153
|
-
return CLASS_INSTANCE_TYPE_ADAPTER_TENSOR
|
|
1154
995
|
return CLASS_INSTANCE_TYPE_INVALID
|
|
1155
996
|
|
|
1156
|
-
@staticmethod
|
|
1157
|
-
def get_adapter_convert_function(class_object):
|
|
1158
|
-
"""Get convert function for adapter tensor"""
|
|
1159
|
-
class_object_name = class_object.__name__
|
|
1160
|
-
if class_object_name in ms_adapter_registry.convert_adapter_tensor_map:
|
|
1161
|
-
return ms_adapter_registry.convert_adapter_tensor_map[class_object_name]
|
|
1162
|
-
return None
|
|
1163
|
-
|
|
1164
997
|
@staticmethod
|
|
1165
998
|
def is_unsupported_internal_type(value):
|
|
1166
999
|
"""To check if not supported internal type, such as Tensor"""
|
|
@@ -1169,8 +1002,6 @@ class Parser:
|
|
|
1169
1002
|
if value == Tensor:
|
|
1170
1003
|
logger.debug(f"Found unsupported internal type: '{value}'.")
|
|
1171
1004
|
return True
|
|
1172
|
-
if ms_adapter_registry.is_registered and issubclass(value, ms_adapter_registry.tensor):
|
|
1173
|
-
return True
|
|
1174
1005
|
return False
|
|
1175
1006
|
|
|
1176
1007
|
@staticmethod
|
|
@@ -1179,7 +1010,7 @@ class Parser:
|
|
|
1179
1010
|
# The value may not be supported to do ConvertData such as api 'mutable',
|
|
1180
1011
|
# and we get its converted object from python.
|
|
1181
1012
|
if inspect.isfunction(value) and value in (mutable,):
|
|
1182
|
-
return
|
|
1013
|
+
return convert_object_map.get(value)
|
|
1183
1014
|
return value
|
|
1184
1015
|
|
|
1185
1016
|
def get_syntax_support_type(self, value):
|
|
@@ -116,7 +116,7 @@ convert_object_map = {
|
|
|
116
116
|
T.xor: multitype_ops.bitwise_xor,
|
|
117
117
|
T.pos: multitype_ops.uadd,
|
|
118
118
|
T.neg: multitype_ops.negative,
|
|
119
|
-
T.invert:
|
|
119
|
+
T.invert: multitype_ops.invert,
|
|
120
120
|
T.not_: multitype_ops.logical_not,
|
|
121
121
|
T.eq: multitype_ops.equal,
|
|
122
122
|
T.ne: multitype_ops.not_equal,
|
|
@@ -181,16 +181,12 @@ constant_fold_functions = [
|
|
|
181
181
|
abs,
|
|
182
182
|
all,
|
|
183
183
|
any,
|
|
184
|
-
float,
|
|
185
|
-
int,
|
|
186
|
-
bool,
|
|
187
184
|
len,
|
|
188
185
|
max,
|
|
189
186
|
min,
|
|
190
187
|
pow,
|
|
191
188
|
repr,
|
|
192
189
|
round,
|
|
193
|
-
str,
|
|
194
190
|
sum,
|
|
195
191
|
type,
|
|
196
192
|
T.add,
|