mindspore 2.5.0__cp39-cp39-win_amd64.whl → 2.6.0rc1__cp39-cp39-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mindspore might be problematic. Click here for more details.
- mindspore/.commit_id +1 -1
- mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
- mindspore/Newtonsoft.Json.dll +0 -0
- mindspore/__init__.py +6 -4
- mindspore/_c_dataengine.cp39-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp39-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp39-win_amd64.pyd +0 -0
- mindspore/_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
|
@@ -29,7 +29,6 @@ import numpy as np
|
|
|
29
29
|
import mindspore as ms
|
|
30
30
|
from mindspore._c_expression import Oplib, typing
|
|
31
31
|
from mindspore._c_expression import pyboost_custom_ext
|
|
32
|
-
from mindspore.common._stub_tensor import _convert_stub
|
|
33
32
|
from mindspore import context
|
|
34
33
|
from mindspore.common import Tensor
|
|
35
34
|
from mindspore.common import dtype as mstype
|
|
@@ -40,6 +39,7 @@ from mindspore.communication.management import get_rank, GlobalComm
|
|
|
40
39
|
from ._ms_kernel import determine_variable_usage
|
|
41
40
|
from ._custom_grad import autodiff_bprop
|
|
42
41
|
from ._pyfunc_registry import add_pyfunc
|
|
42
|
+
from ._custom_ops_utils import ExtensionBuilder
|
|
43
43
|
|
|
44
44
|
if platform.system() != "Windows":
|
|
45
45
|
import fcntl
|
|
@@ -183,10 +183,16 @@ class _CustomExt(ops.PrimitiveWithInfer):
|
|
|
183
183
|
|
|
184
184
|
infer_value = None
|
|
185
185
|
if infer_shape is None:
|
|
186
|
-
logger.
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
logger.debug("'out_shape' is None. Add a placeholder instead. "
|
|
187
|
+
"A CPP version of infer shape function is required "
|
|
188
|
+
"in this case.")
|
|
189
189
|
infer_shape = (1,)
|
|
190
|
+
if infer_dtype is None:
|
|
191
|
+
logger.debug("'out_dtype' is None. Add a placeholder instead. "
|
|
192
|
+
"A CPP version of infer type function is required "
|
|
193
|
+
"in this case.")
|
|
194
|
+
infer_dtype = ms.float16
|
|
195
|
+
|
|
190
196
|
# after all automatic infer information fulfillment, throw error if infer_shape/infer_dtype is still None
|
|
191
197
|
if not isinstance(infer_shape, (tuple, list)):
|
|
192
198
|
raise TypeError("'out_shape' must be one of [tuple, list, function], but got {}".format(type(infer_shape)))
|
|
@@ -215,7 +221,7 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
215
221
|
function if needed. Then these `Custom` objects can be directly used in neural networks.
|
|
216
222
|
Detailed description and introduction of user-defined operators, including correct writing of parameters,
|
|
217
223
|
please refer to `Custom Operators Tutorial
|
|
218
|
-
<https://www.mindspore.cn/
|
|
224
|
+
<https://www.mindspore.cn/tutorials/en/master/custom_program/op_custom.html>`_ .
|
|
219
225
|
|
|
220
226
|
.. warning::
|
|
221
227
|
- This is an experimental API that is subject to change.
|
|
@@ -297,14 +303,17 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
297
303
|
b) Ascend platform.
|
|
298
304
|
Before using Custom operators on the Ascend platform, users must first develop custom operators
|
|
299
305
|
based on Ascend C and compile them. The complete development and usage process can refer to the
|
|
300
|
-
tutorial `AOT-Type Custom Operators(Ascend)
|
|
306
|
+
tutorial `AOT-Type Custom Operators(Ascend)
|
|
307
|
+
<https://www.mindspore.cn/tutorials/en/master/custom_program/operation/op_custom_ascendc.html>`_.
|
|
301
308
|
By passing the name of the operator through the input parameter `func`, there are two usage methods
|
|
302
|
-
based on the implementation of the infer
|
|
303
|
-
|
|
304
|
-
- Python infer: If the operator's infer
|
|
305
|
-
function is passed through the `out_shape` parameter,
|
|
306
|
-
|
|
307
|
-
|
|
309
|
+
based on the implementation of the infer function:
|
|
310
|
+
|
|
311
|
+
- Python infer: If the operator's infer function is implemented in Python, that is, the infer shape
|
|
312
|
+
function is passed through the `out_shape` parameter, and the infer type is passed throuht the
|
|
313
|
+
`out_dtype`, then the `func` should be specified as the operator name, for example,
|
|
314
|
+
`func="CustomName"`.
|
|
315
|
+
- C++ infer: If the operator's infer function is implemented through C++, then pass the path of the
|
|
316
|
+
infer function implementation file in `func` and separate the operator name with `:`,
|
|
308
317
|
for example: `func="add_custom_infer.cc:AddCustom"` .
|
|
309
318
|
|
|
310
319
|
2. for "julia":
|
|
@@ -425,6 +434,7 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
425
434
|
self._func_compile_attrs = {}
|
|
426
435
|
self._is_ms_kernel = False
|
|
427
436
|
self.out_shape = out_shape
|
|
437
|
+
self.out_dtype = out_dtype
|
|
428
438
|
|
|
429
439
|
self._check_platform()
|
|
430
440
|
self._check_func()
|
|
@@ -442,13 +452,17 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
442
452
|
|
|
443
453
|
if self.out_shape is None and self.func_type == "aot":
|
|
444
454
|
self.add_prim_attr("cpp_infer_shape", True)
|
|
445
|
-
self.out_dtype
|
|
455
|
+
if self.out_dtype is None and self.func_type == "aot":
|
|
456
|
+
self.add_prim_attr("cpp_infer_type", True)
|
|
457
|
+
self.multi_output = (reg_info is not None and (len(reg_info.get("outputs", [])) > 1))
|
|
458
|
+
self.add_prim_attr("multi_output", self.multi_output)
|
|
459
|
+
|
|
446
460
|
self.bprop = bprop
|
|
447
461
|
self.fake_output = False
|
|
448
462
|
self.single_scalar_output = False
|
|
449
|
-
if not self.out_dtype:
|
|
463
|
+
if not self.out_dtype and not self.func_type == "pyfunc":
|
|
450
464
|
self.fake_output = True
|
|
451
|
-
elif not self.out_shape:
|
|
465
|
+
elif not self.out_shape and self.func_type == "pyfunc":
|
|
452
466
|
self.single_scalar_output = True
|
|
453
467
|
self.add_prim_attr("fake_output", self.fake_output)
|
|
454
468
|
self.add_prim_attr("single_scalar_output", self.single_scalar_output)
|
|
@@ -464,10 +478,10 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
464
478
|
|
|
465
479
|
self.add_prim_attr("func_type", self.func_type)
|
|
466
480
|
self._update_attr()
|
|
467
|
-
|
|
468
|
-
self.
|
|
469
|
-
if
|
|
470
|
-
self.
|
|
481
|
+
|
|
482
|
+
self.enable_pyboost = (context.get_context("device_target") == "Ascend" and self.func_type == "aot")
|
|
483
|
+
if self.enable_pyboost:
|
|
484
|
+
self.custom_pyboost = _CustomExt(self.func, self.out_shape, self.out_dtype, self.bprop)
|
|
471
485
|
for key, value in super().get_attr_dict().items():
|
|
472
486
|
self.custom_pyboost.add_prim_attr(key, value)
|
|
473
487
|
|
|
@@ -510,10 +524,15 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
510
524
|
infer_dtype = mstype.int32
|
|
511
525
|
if self.func_type == "aot":
|
|
512
526
|
if infer_shape is None:
|
|
513
|
-
logger.
|
|
514
|
-
|
|
515
|
-
|
|
527
|
+
logger.debug("{}, 'out_shape' is None. Add a placeholder instead. "
|
|
528
|
+
"A CPP version of infer shape function is required "
|
|
529
|
+
"in this case.".format(self.log_prefix))
|
|
516
530
|
infer_shape = (1,)
|
|
531
|
+
if infer_dtype is None:
|
|
532
|
+
logger.debug("{}, 'out_dtype' is None. Add a placeholder instead. "
|
|
533
|
+
"A CPP version of infer type function is required "
|
|
534
|
+
"in this case.".format(self.log_prefix))
|
|
535
|
+
infer_dtype = ms.float16
|
|
517
536
|
# after all automatic infer information fulfillment, throw error if infer_shape/infer_dtype is still None
|
|
518
537
|
if not isinstance(infer_shape, (tuple, list)):
|
|
519
538
|
raise TypeError("{}, 'out_shape' must be one of [tuple, list, function], but got {}"
|
|
@@ -1079,9 +1098,188 @@ class Custom(ops.PrimitiveWithInfer):
|
|
|
1079
1098
|
|
|
1080
1099
|
def __call__(self, *args):
|
|
1081
1100
|
if self.enable_pyboost:
|
|
1082
|
-
|
|
1101
|
+
res = pyboost_custom_ext(self.custom_pyboost, [args])
|
|
1102
|
+
return res if self.multi_output else res[0]
|
|
1083
1103
|
should_elim, output = self.check_elim(*args)
|
|
1084
1104
|
if should_elim:
|
|
1085
1105
|
return output
|
|
1086
1106
|
# pylint: disable=protected-access
|
|
1087
1107
|
return ops.primitive._run_op(self, self.name, args)
|
|
1108
|
+
|
|
1109
|
+
|
|
1110
|
+
class CustomOpBuilder:
|
|
1111
|
+
r"""
|
|
1112
|
+
CustomOpBuilder is used to initialize and configure custom operators for MindSpore.
|
|
1113
|
+
Users can define and load custom operator modules through this class and apply them to the network.
|
|
1114
|
+
|
|
1115
|
+
In most cases, users only need to provide the source files and additional compilation options in the constructor
|
|
1116
|
+
and call the `load` method to complete the compilation and loading of the operator.
|
|
1117
|
+
If users have specific customization requirements, they can inherit this class and override certain methods.
|
|
1118
|
+
It is important to note that if methods are overridden, some parameters passed to the constructor may be ignored.
|
|
1119
|
+
|
|
1120
|
+
.. warning::
|
|
1121
|
+
This is an experimental API that is subject to change.
|
|
1122
|
+
|
|
1123
|
+
Args:
|
|
1124
|
+
name (str): The unique name of the custom operator module, used to identify the operator.
|
|
1125
|
+
sources (Union[str, list[str]]): The source file(s) of the custom operator. It can be a single file path or
|
|
1126
|
+
a list of file paths.
|
|
1127
|
+
backend (str, optional): The target backend for the operator, such as "CPU" or "Ascend". Default: ``None``.
|
|
1128
|
+
include_paths (list[str], optional): Additionally included paths needed during compilation. Default: ``None``.
|
|
1129
|
+
cflags (str, optional): Extra C++ compiler flags to be used during compilation. Default: ``None``.
|
|
1130
|
+
ldflags (str, optional): Extra linker flags to be used during linking. Default: ``None``.
|
|
1131
|
+
kwargs (dict, optional): Additional keyword arguments for future extensions or specific custom requirements.
|
|
1132
|
+
|
|
1133
|
+
.. note::
|
|
1134
|
+
- If the `backend` argument is provided, additional default flags will be automatically added to
|
|
1135
|
+
the compilation and linking steps to support the operator's target backend. The default options
|
|
1136
|
+
can be referenced in the implementation of the `get_cflags` and `get_ldflags` methods in the `CustomOpBuilder
|
|
1137
|
+
<https://gitee.com/mindspore/mindspore/blob/master/mindspore/python/mindspore/ops/operations/custom_ops.py>`_.
|
|
1138
|
+
- The `sources` argument must point to valid source files for the custom operator.
|
|
1139
|
+
|
|
1140
|
+
Supported Platforms:
|
|
1141
|
+
``Ascend`` ``CPU``
|
|
1142
|
+
|
|
1143
|
+
Examples:
|
|
1144
|
+
>>> from mindspore import ops
|
|
1145
|
+
>>> builder = ops.CustomOpBuilder(
|
|
1146
|
+
... name="custom_op_cpu",
|
|
1147
|
+
... sources="custom_ops_impl/pybind_op_cpu.cpp",
|
|
1148
|
+
... backend="CPU"
|
|
1149
|
+
... )
|
|
1150
|
+
>>> my_ops = builder.load()
|
|
1151
|
+
"""
|
|
1152
|
+
_mindspore_path = None
|
|
1153
|
+
_loaded_ops = {}
|
|
1154
|
+
_ms_code_base = None
|
|
1155
|
+
|
|
1156
|
+
def __init__(self, name, sources, backend=None, include_paths=None, cflags=None, ldflags=None, **kwargs):
|
|
1157
|
+
self.name = name
|
|
1158
|
+
self.source = sources
|
|
1159
|
+
self.backend = backend
|
|
1160
|
+
self.include_paths = include_paths
|
|
1161
|
+
self.cflags = cflags
|
|
1162
|
+
self.ldflags = ldflags
|
|
1163
|
+
if CustomOpBuilder._mindspore_path is None:
|
|
1164
|
+
CustomOpBuilder._mindspore_path = os.path.dirname(os.path.abspath(ms.__file__))
|
|
1165
|
+
CustomOpBuilder._ms_code_base = os.path.join(CustomOpBuilder._mindspore_path, "include")
|
|
1166
|
+
if self.backend == "Ascend":
|
|
1167
|
+
self.ascend_cann_path = os.getenv("ASCEND_OPP_PATH").split('opp')[0]
|
|
1168
|
+
|
|
1169
|
+
def get_sources(self):
|
|
1170
|
+
"""
|
|
1171
|
+
Get the source files for the custom operator.
|
|
1172
|
+
|
|
1173
|
+
Returns:
|
|
1174
|
+
str or list[str], The source file(s) for the operator.
|
|
1175
|
+
"""
|
|
1176
|
+
return self.source
|
|
1177
|
+
|
|
1178
|
+
def get_include_paths(self):
|
|
1179
|
+
"""
|
|
1180
|
+
Get the include paths required for compiling the custom operator.
|
|
1181
|
+
|
|
1182
|
+
Returns:
|
|
1183
|
+
list[str], A list of include paths.
|
|
1184
|
+
"""
|
|
1185
|
+
include_list = self.include_paths if self.include_paths is not None else []
|
|
1186
|
+
include_list.append(CustomOpBuilder._mindspore_path)
|
|
1187
|
+
include_list.append(os.path.join(CustomOpBuilder._mindspore_path, "include"))
|
|
1188
|
+
include_list.append(os.path.join(CustomOpBuilder._mindspore_path, "include/third_party"))
|
|
1189
|
+
include_list.append(os.path.join(CustomOpBuilder._mindspore_path, "include/third_party/robin_hood_hashing"))
|
|
1190
|
+
include_list.append(os.path.join(CustomOpBuilder._mindspore_path, "include/third_party/securec/include"))
|
|
1191
|
+
|
|
1192
|
+
if self.backend == "Ascend":
|
|
1193
|
+
include_list.append(os.path.join(self.ascend_cann_path, "include"))
|
|
1194
|
+
include_list += self._get_ms_inner_includes()
|
|
1195
|
+
return include_list
|
|
1196
|
+
|
|
1197
|
+
def _get_ms_inner_includes(self):
|
|
1198
|
+
"""include paths for inner module interface."""
|
|
1199
|
+
ms_inner_code_base = os.path.join(CustomOpBuilder._mindspore_path, "include", "mindspore")
|
|
1200
|
+
include_list = []
|
|
1201
|
+
include_list.append(ms_inner_code_base + "/core/include")
|
|
1202
|
+
include_list.append(ms_inner_code_base + "/core/mindrt/include")
|
|
1203
|
+
include_list.append(ms_inner_code_base + "/core/mindrt")
|
|
1204
|
+
include_list.append(ms_inner_code_base + "/ops")
|
|
1205
|
+
include_list.append(ms_inner_code_base + "/ops/kernel/include")
|
|
1206
|
+
include_list.append(ms_inner_code_base + "/ccsrc")
|
|
1207
|
+
include_list.append(ms_inner_code_base + "/ccsrc/include")
|
|
1208
|
+
include_list.append(ms_inner_code_base + "/ccsrc/minddata/mindrecord/include")
|
|
1209
|
+
return include_list
|
|
1210
|
+
|
|
1211
|
+
def get_cflags(self):
|
|
1212
|
+
"""
|
|
1213
|
+
Get the C++ compiler flags for building the custom operator.
|
|
1214
|
+
|
|
1215
|
+
Returns:
|
|
1216
|
+
list[str], A list of C++ compiler flags.
|
|
1217
|
+
"""
|
|
1218
|
+
flags = ['-fstack-protector-all', '-fPIC', '-pie']
|
|
1219
|
+
flags += ['-DENABLE_FAST_HASH_TABLE=1']
|
|
1220
|
+
if self.backend == "Ascend":
|
|
1221
|
+
flags.append('-DCUSTOM_ASCEND_OP')
|
|
1222
|
+
if self.cflags is not None:
|
|
1223
|
+
flags.append(self.cflags)
|
|
1224
|
+
return flags
|
|
1225
|
+
|
|
1226
|
+
def get_ldflags(self):
|
|
1227
|
+
"""
|
|
1228
|
+
Get the linker flags for building the custom operator.
|
|
1229
|
+
|
|
1230
|
+
Returns:
|
|
1231
|
+
list[str], A list of linker flags.
|
|
1232
|
+
"""
|
|
1233
|
+
flags = ['-Wl,-z,relro,-z,now,-z,noexecstack', '-Wl,--disable-new-dtags,--rpath', '-s']
|
|
1234
|
+
flags += [
|
|
1235
|
+
'-L' + os.path.abspath(os.path.join(CustomOpBuilder._mindspore_path, 'lib')),
|
|
1236
|
+
'-lmindspore_core',
|
|
1237
|
+
'-lmindspore_ms_backend',
|
|
1238
|
+
'-lmindspore_pynative'
|
|
1239
|
+
]
|
|
1240
|
+
if self.backend == "Ascend":
|
|
1241
|
+
flags.append('-L' + os.path.abspath(os.path.join(CustomOpBuilder._mindspore_path, 'lib/plugin')))
|
|
1242
|
+
flags.append('-L' + os.path.abspath(os.path.join(self.ascend_cann_path, "lib64")))
|
|
1243
|
+
flags.append('-lascendcl')
|
|
1244
|
+
flags.append('-l:libmindspore_ascend.so.2')
|
|
1245
|
+
if self.ldflags is not None:
|
|
1246
|
+
flags.append(self.ldflags)
|
|
1247
|
+
return flags
|
|
1248
|
+
|
|
1249
|
+
def build(self):
|
|
1250
|
+
"""
|
|
1251
|
+
Build the custom operator module.
|
|
1252
|
+
|
|
1253
|
+
This method generates a dynamic library file for the custom operator based on the provided source files,
|
|
1254
|
+
include paths, compilation flags, and link flags.
|
|
1255
|
+
|
|
1256
|
+
Returns:
|
|
1257
|
+
str, The path to the compiled module.
|
|
1258
|
+
"""
|
|
1259
|
+
return ExtensionBuilder().build(
|
|
1260
|
+
module_name=self.name,
|
|
1261
|
+
sources=self.get_sources(),
|
|
1262
|
+
extra_include_paths=self.get_include_paths(),
|
|
1263
|
+
extra_cflags=self.get_cflags(),
|
|
1264
|
+
extra_ldflags=self.get_ldflags())
|
|
1265
|
+
|
|
1266
|
+
def load(self):
|
|
1267
|
+
"""
|
|
1268
|
+
Build and load the custom operator module.
|
|
1269
|
+
|
|
1270
|
+
Returns:
|
|
1271
|
+
Module, The loaded custom operator module.
|
|
1272
|
+
"""
|
|
1273
|
+
if self.name in CustomOpBuilder._loaded_ops:
|
|
1274
|
+
return CustomOpBuilder._loaded_ops[self.name]
|
|
1275
|
+
module_path = self.build()
|
|
1276
|
+
mod = self._import_module(module_path)
|
|
1277
|
+
CustomOpBuilder._loaded_ops[self.name] = mod
|
|
1278
|
+
return mod
|
|
1279
|
+
|
|
1280
|
+
def _import_module(self, module_path):
|
|
1281
|
+
"""Import module from library."""
|
|
1282
|
+
spec = importlib.util.spec_from_file_location(self.name, module_path)
|
|
1283
|
+
module = importlib.util.module_from_spec(spec)
|
|
1284
|
+
spec.loader.exec_module(module)
|
|
1285
|
+
return module
|
|
@@ -19,12 +19,13 @@ from pathlib import Path
|
|
|
19
19
|
import numpy as np
|
|
20
20
|
from mindspore import log as logger
|
|
21
21
|
from mindspore._c_expression import security, HookType
|
|
22
|
-
from mindspore._c_expression import
|
|
22
|
+
from mindspore._c_expression import TensorPy as Tensor_
|
|
23
23
|
from mindspore._c_expression import _tensordump_process_file
|
|
24
24
|
from mindspore import _checkparam as validator
|
|
25
25
|
from mindspore.common import dtype as mstype
|
|
26
26
|
from mindspore.common.parameter import Parameter
|
|
27
27
|
from mindspore.common.tensor import Tensor
|
|
28
|
+
from mindspore.common.jit_context import jit_context
|
|
28
29
|
from mindspore.ops.primitive import prim_attr_register, Primitive, PrimitiveWithInfer
|
|
29
30
|
from mindspore._checkparam import check_hook_fn
|
|
30
31
|
from mindspore.ops import operations as P
|
|
@@ -62,9 +63,7 @@ class ScalarSummary(Primitive):
|
|
|
62
63
|
"""
|
|
63
64
|
This operator will put a scalar to a summary file with protocol buffer format.
|
|
64
65
|
It must be used with :class:`mindspore.SummaryRecord` or :class:`mindspore.SummaryCollector`,
|
|
65
|
-
which specify the directory of the summary file.
|
|
66
|
-
be loaded and shown by MindInsight, see `MindInsight documents <https://www.mindspore.cn/
|
|
67
|
-
mindinsight/docs/en/master/index.html>`_ for details.
|
|
66
|
+
which specify the directory of the summary file.
|
|
68
67
|
In Ascend platform with graph mode, the environment variables `MS_DUMP_SLICE_SIZE` and `MS_DUMP_WAIT_TIME`
|
|
69
68
|
can be set to solve operator execution failure when calling this operator intensively.
|
|
70
69
|
|
|
@@ -122,11 +121,9 @@ class ScalarSummary(Primitive):
|
|
|
122
121
|
class ImageSummary(Primitive):
|
|
123
122
|
"""
|
|
124
123
|
This operator will put an image tensor to a summary file with protocol buffer format. It must be used with
|
|
125
|
-
SummaryRecord or SummaryCollector, which specify the directory of the summary file.
|
|
126
|
-
be loaded and shown by MindInsight, see `MindInsight documents <https://www.mindspore.cn/
|
|
127
|
-
mindinsight/docs/en/master/index.html>`_ for details.
|
|
124
|
+
SummaryRecord or SummaryCollector, which specify the directory of the summary file.
|
|
128
125
|
In Ascend platform with graph mode, the environment variables `MS_DUMP_SLICE_SIZE` and `MS_DUMP_WAIT_TIME`
|
|
129
|
-
can be set to solve
|
|
126
|
+
can be set to solve execution failure when calling this operator intensively.
|
|
130
127
|
|
|
131
128
|
Inputs:
|
|
132
129
|
- **name** (str) - The name of the input variable, it must not be an empty string.
|
|
@@ -175,9 +172,7 @@ class ImageSummary(Primitive):
|
|
|
175
172
|
class TensorSummary(Primitive):
|
|
176
173
|
"""
|
|
177
174
|
This operator will put a tensor to a summary file with protocol buffer format. It must be used with SummaryRecord
|
|
178
|
-
or SummaryCollector, which specify the directory of the summary file.
|
|
179
|
-
be loaded and shown by MindInsight, see `MindInsight documents <https://www.mindspore.cn/
|
|
180
|
-
mindinsight/docs/en/master/index.html>`_ for details.
|
|
175
|
+
or SummaryCollector, which specify the directory of the summary file.
|
|
181
176
|
In Ascend platform with graph mode, the environment variables `MS_DUMP_SLICE_SIZE` and `MS_DUMP_WAIT_TIME`
|
|
182
177
|
can be set to solve operator execution failure when calling this operator intensively.
|
|
183
178
|
|
|
@@ -236,7 +231,7 @@ class TensorDump(Primitive):
|
|
|
236
231
|
Save the Tensor as an npy file in numpy format.
|
|
237
232
|
|
|
238
233
|
.. warning::
|
|
239
|
-
|
|
234
|
+
The parameter input_output will no longer support the value 'all'.
|
|
240
235
|
|
|
241
236
|
.. note::
|
|
242
237
|
In Ascend platform with graph mode, the environment variables `MS_DUMP_SLICE_SIZE` and `MS_DUMP_WAIT_TIME`
|
|
@@ -344,8 +339,6 @@ class HistogramSummary(Primitive):
|
|
|
344
339
|
"""
|
|
345
340
|
This operator will calculate the histogram of a tensor and put it to a summary file with protocol buffer format.
|
|
346
341
|
It must be used with SummaryRecord or SummaryCollector, which specify the directory of the summary file.
|
|
347
|
-
The summary file can be loaded and shown by MindInsight, see `MindInsight documents <https://www.mindspore.cn/
|
|
348
|
-
mindinsight/docs/en/master/index.html>`_ for details.
|
|
349
342
|
In Ascend platform with graph mode, the environment variables `MS_DUMP_SLICE_SIZE` and `MS_DUMP_WAIT_TIME`
|
|
350
343
|
can be set to solve operator execution failure when calling this operator intensively.
|
|
351
344
|
|
|
@@ -466,6 +459,107 @@ class InsertGradientOf(Primitive):
|
|
|
466
459
|
self.f = f
|
|
467
460
|
|
|
468
461
|
|
|
462
|
+
class Morph(PrimitiveWithInfer):
|
|
463
|
+
"""
|
|
464
|
+
The `Morph` Primitive is used to encapsulate a user-defined function `fn`, allowing it to be used as a custom
|
|
465
|
+
Primitive.
|
|
466
|
+
The primary application scenario of the `Morph` Primitive is in the auto-parallel case after `GRAPH_MODE` mode,
|
|
467
|
+
where collective communication operators are used within the user-defined `fn` to implement custom parallel
|
|
468
|
+
computation logic, especially in scenarios where `fn` involves dynamic shapes.
|
|
469
|
+
When the `Morph` Primitive is applied to inputs, it is actually the encapsulated user-defined function `fn` that is
|
|
470
|
+
applied to the inputs.
|
|
471
|
+
The main difference between the `Morph` Primitive and :func:`mindspore.ops.Custom` is that the former is expanded
|
|
472
|
+
and replaced by the user-defined `fn` before automatic differentiation, so there is no need to implement a backward
|
|
473
|
+
function.
|
|
474
|
+
|
|
475
|
+
.. note::
|
|
476
|
+
- This primitive is only supported in GRAPH_MODE.
|
|
477
|
+
- `fn` must satisfy the syntax constraints of the graph mode.
|
|
478
|
+
- Users do not need to implement a custom backward function.
|
|
479
|
+
- `vararg`, `kwarg`, `kwonlyargs` and free variables are not supported in user-defined function.
|
|
480
|
+
|
|
481
|
+
Args:
|
|
482
|
+
fn (Function): Mindspore's function, user-defined function.
|
|
483
|
+
infer_shape (Function): Mindspore's function, user-defined infer_shape function.
|
|
484
|
+
infer_dtype (Function): Mindspore's function, user-defined infer_dtype function.
|
|
485
|
+
|
|
486
|
+
Inputs:
|
|
487
|
+
The inputs of user-defined `fn`.
|
|
488
|
+
|
|
489
|
+
Outputs:
|
|
490
|
+
The outputs of user-defined `fn`.
|
|
491
|
+
|
|
492
|
+
Raises:
|
|
493
|
+
RuntimeError: if not used in GRAPH_MODE.
|
|
494
|
+
|
|
495
|
+
Examples:
|
|
496
|
+
>>> import numpy as np
|
|
497
|
+
>>> import mindspore as ms
|
|
498
|
+
>>> from mindspore import context, nn, ops, Tensor, Parameter
|
|
499
|
+
>>>
|
|
500
|
+
>>> np_weight0 = np.array([1.0, 2.0, 3.0])
|
|
501
|
+
>>> np_weight1 = np.array([4.0, 5.0, 6.0])
|
|
502
|
+
>>> np_input_x = np.array([7.0, 8.0, 9.0])
|
|
503
|
+
>>>
|
|
504
|
+
>>> def infer_dtype(args):
|
|
505
|
+
... return args
|
|
506
|
+
>>>
|
|
507
|
+
>>> def infer_shape(args):
|
|
508
|
+
... return args
|
|
509
|
+
>>>
|
|
510
|
+
>>> def mul_by(*args):
|
|
511
|
+
... def inner(x):
|
|
512
|
+
... return args[0] * x
|
|
513
|
+
... return inner
|
|
514
|
+
>>>
|
|
515
|
+
>>> NUMBER_100 = 100
|
|
516
|
+
>>> class MorphNet(nn.Cell):
|
|
517
|
+
... def __init__(self):
|
|
518
|
+
... super(MorphNet, self).__init__()
|
|
519
|
+
... self.weight0 = Parameter(Tensor(np_weight0, ms.float32), name="weight0")
|
|
520
|
+
... self.weight1 = Parameter(Tensor(np_weight1, ms.float32), name="weight1")
|
|
521
|
+
... self.mul_by_100 = ops.Morph(mul_by(NUMBER_100), infer_shape, infer_dtype)
|
|
522
|
+
... def construct(self, x):
|
|
523
|
+
... a = x * self.weight0
|
|
524
|
+
... b = self.mul_by_100(a)
|
|
525
|
+
... out = b * self.weight1
|
|
526
|
+
... return out
|
|
527
|
+
>>>
|
|
528
|
+
>>> context.set_context(mode=context.GRAPH_MODE)
|
|
529
|
+
>>> input_x = Tensor(np_input_x, ms.float32)
|
|
530
|
+
>>> net = MorphNet()
|
|
531
|
+
>>> grad_op = ops.GradOperation(get_all=True, get_by_list=True)
|
|
532
|
+
>>> grad_net = grad_op(net, net.trainable_params())
|
|
533
|
+
>>> bwd_out = grad_net(input_x)
|
|
534
|
+
>>> x_grad = bwd_out[0][0].asnumpy()
|
|
535
|
+
>>> weight0_grad = bwd_out[1][0].asnumpy()
|
|
536
|
+
>>> weight1_grad = bwd_out[1][1].asnumpy()
|
|
537
|
+
>>> print("x_grad", x_grad)
|
|
538
|
+
>>> print("weight0_grad", weight0_grad)
|
|
539
|
+
>>> print("weight1_grad", weight1_grad)
|
|
540
|
+
x_grad [ 400. 1000. 1800.]
|
|
541
|
+
weight0_grad [2800. 4000. 5400.]
|
|
542
|
+
weight1_grad [ 700. 1600. 2700.]
|
|
543
|
+
"""
|
|
544
|
+
@prim_attr_register
|
|
545
|
+
def __init__(self, fn, infer_shape, infer_dtype):
|
|
546
|
+
self.add_prim_attr('side_effect_backprop', True)
|
|
547
|
+
self.add_prim_attr('side_effect_mem', True)
|
|
548
|
+
self.add_prim_attr('side_effect_io', True)
|
|
549
|
+
self.add_prim_attr('__metamorphosis__', fn)
|
|
550
|
+
self._infer_shape = infer_shape
|
|
551
|
+
self._infer_dtype = infer_dtype
|
|
552
|
+
|
|
553
|
+
def infer_shape(self, *args):
|
|
554
|
+
return self._infer_shape(*args)
|
|
555
|
+
|
|
556
|
+
def infer_dtype(self, *args):
|
|
557
|
+
return self._infer_dtype(*args)
|
|
558
|
+
|
|
559
|
+
def __call__(self, *args):
|
|
560
|
+
raise RuntimeError("Morph is only supported in GRAPH_MODE.")
|
|
561
|
+
|
|
562
|
+
|
|
469
563
|
class HookBackward(PrimitiveWithInfer):
|
|
470
564
|
"""
|
|
471
565
|
This operation is used as a tag to hook gradient in intermediate variables. Note that this function
|
|
@@ -527,8 +621,7 @@ class HookBackward(PrimitiveWithInfer):
|
|
|
527
621
|
def __init__(self, hook_fn, cell_id=""):
|
|
528
622
|
"""Initialize HookBackward."""
|
|
529
623
|
super(HookBackward, self).__init__(self.__class__.__name__)
|
|
530
|
-
|
|
531
|
-
return
|
|
624
|
+
check_hook_fn(hook_fn)
|
|
532
625
|
if cell_id != "":
|
|
533
626
|
logger.warning(f"The args 'cell_id' of HookBackward will be removed in a future version. If the value of "
|
|
534
627
|
f"'cell_id' is set, the hook function will not work.")
|
|
@@ -600,6 +693,9 @@ class Print(Primitive):
|
|
|
600
693
|
self.add_prim_attr("side_effect_io", True)
|
|
601
694
|
|
|
602
695
|
def __call__(self, *args):
|
|
696
|
+
# Add for jit context.
|
|
697
|
+
if jit_context() and jit_context().compiled:
|
|
698
|
+
return
|
|
603
699
|
for arg in args:
|
|
604
700
|
if isinstance(arg, Parameter):
|
|
605
701
|
print(Tensor_.__repr__(arg))
|
|
@@ -607,6 +703,9 @@ class Print(Primitive):
|
|
|
607
703
|
print(arg.__repr__())
|
|
608
704
|
else:
|
|
609
705
|
print(arg)
|
|
706
|
+
# Add for jit context.
|
|
707
|
+
if jit_context():
|
|
708
|
+
jit_context().run_op(self, None, *args)
|
|
610
709
|
|
|
611
710
|
|
|
612
711
|
class Assert(PrimitiveWithInfer):
|
|
@@ -87,7 +87,7 @@ class NoRepeatNGram(Primitive):
|
|
|
87
87
|
Because 3 consecutive words [2, 3, 2] do not appear twice in the word sequence.
|
|
88
88
|
|
|
89
89
|
Args:
|
|
90
|
-
ngram_size (int): Size of n-grams, must be greater than 0. Default: ``1`` .
|
|
90
|
+
ngram_size (int, optional): Size of n-grams, must be greater than 0. Default: ``1`` .
|
|
91
91
|
|
|
92
92
|
Inputs:
|
|
93
93
|
- **state_seq** (Tensor) - n-gram word series, a 3-D tensor with shape: :math:`(batch\_size, beam\_width, m)`.
|
|
@@ -19,64 +19,7 @@ from __future__ import absolute_import
|
|
|
19
19
|
from mindspore import _checkparam as Validator
|
|
20
20
|
from mindspore.ops.primitive import Primitive
|
|
21
21
|
from mindspore.ops.primitive import prim_attr_register
|
|
22
|
-
from ..auto_generate import Geqrf
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
class Svd(Primitive):
|
|
26
|
-
"""
|
|
27
|
-
Computes the singular value decompositions of one or more matrices.
|
|
28
|
-
|
|
29
|
-
Refer to :func:`mindspore.ops.svd` for more details.
|
|
30
|
-
|
|
31
|
-
Args:
|
|
32
|
-
full_matrices (bool, optional): If ``True`` , compute full-sized :math:`U` and :math:`V`. If ``False``,
|
|
33
|
-
compute only the leading P singular vectors, with P is the minimum of M and N.
|
|
34
|
-
Default: ``False`` .
|
|
35
|
-
compute_uv (bool, optional): If ``True`` , compute the left and right singular vectors.
|
|
36
|
-
If ``False`` , compute only the singular values. Default: ``True`` .
|
|
37
|
-
|
|
38
|
-
Inputs:
|
|
39
|
-
- **input** (Tensor) - Tensor of the matrices to be decomposed. The shape should be :math:`(*, M, N)`,
|
|
40
|
-
the supported dtype are float32 and float64.
|
|
41
|
-
|
|
42
|
-
Outputs:
|
|
43
|
-
- **s** (Tensor) - Singular values. The shape is :math:`(*, P)`.
|
|
44
|
-
- **u** (Tensor) - Left singular vectors. If `compute_uv` is ``False`` , u will be zero value.
|
|
45
|
-
The shape is :math:`(*, M, P)`. If `full_matrices` is ``True`` , the shape will be :math:`(*, M, M)`.
|
|
46
|
-
- **v** (Tensor) - Right singular vectors. If `compute_uv` is ``False`` , v will be zero value.
|
|
47
|
-
The shape is :math:`(*, N, P)`. If `full_matrices` is ``True`` , the shape will be :math:`(*, N, N)`.
|
|
48
|
-
|
|
49
|
-
Supported Platforms:
|
|
50
|
-
``GPU`` ``CPU``
|
|
51
|
-
|
|
52
|
-
Examples:
|
|
53
|
-
>>> import numpy as np
|
|
54
|
-
>>> import mindspore as ms
|
|
55
|
-
>>> from mindspore import Tensor
|
|
56
|
-
>>> from mindspore import ops
|
|
57
|
-
>>> ms.set_device(device_target="CPU")
|
|
58
|
-
>>> svd = ops.Svd(full_matrices=True, compute_uv=True)
|
|
59
|
-
>>> a = Tensor(np.array([[1, 2], [-4, -5], [2, 1]]).astype(np.float32))
|
|
60
|
-
>>> s, u, v = svd(a)
|
|
61
|
-
>>> print(s)
|
|
62
|
-
[7.0652843 1.040081 ]
|
|
63
|
-
>>> print(u)
|
|
64
|
-
[[ 0.30821905 -0.48819482 0.81649697]
|
|
65
|
-
[-0.90613353 0.11070572 0.40824813]
|
|
66
|
-
[ 0.2896955 0.8656849 0.4082479 ]]
|
|
67
|
-
>>> print(v)
|
|
68
|
-
[[ 0.63863593 0.769509 ]
|
|
69
|
-
[ 0.769509 -0.63863593]]
|
|
70
|
-
"""
|
|
71
|
-
|
|
72
|
-
@prim_attr_register
|
|
73
|
-
def __init__(self, full_matrices=False, compute_uv=True):
|
|
74
|
-
super().__init__(name="Svd")
|
|
75
|
-
self.init_prim_io_names(inputs=['a'], outputs=['s', 'u', 'v'])
|
|
76
|
-
self.full_matrices = Validator.check_value_type("full_matrices", full_matrices, [bool], self.name)
|
|
77
|
-
self.compute_uv = Validator.check_value_type("compute_uv", compute_uv, [bool], self.name)
|
|
78
|
-
self.add_prim_attr('full_matrices', self.full_matrices)
|
|
79
|
-
self.add_prim_attr('compute_uv', self.compute_uv)
|
|
22
|
+
from ..auto_generate import Geqrf, Svd
|
|
80
23
|
|
|
81
24
|
|
|
82
25
|
class Eigh(Primitive):
|
|
@@ -66,7 +66,7 @@ class TensorReport(Primitive):
|
|
|
66
66
|
@prim_attr_register
|
|
67
67
|
def __init__(self):
|
|
68
68
|
"""Initialize TensorReport"""
|
|
69
|
-
self.add_prim_attr("
|
|
69
|
+
self.add_prim_attr("side_effect_mem", True)
|
|
70
70
|
self.add_prim_attr("channel_name", "ms_tensor_report")
|
|
71
71
|
|
|
72
72
|
def __call__(self, file, input_x):
|