mindspore 2.6.0__cp310-cp310-win_amd64.whl → 2.7.0__cp310-cp310-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mindspore might be problematic. Click here for more details.
- mindspore/.commit_id +1 -1
- mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
- mindspore/Newtonsoft.Json.dll +0 -0
- mindspore/__init__.py +2 -2
- mindspore/_c_dataengine.cp310-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp310-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp310-win_amd64.pyd +0 -0
- mindspore/_checkparam.py +42 -11
- mindspore/_extends/builtin_operations.py +3 -3
- mindspore/{_deprecated → _extends/optimize}/__init__.py +9 -3
- mindspore/_extends/optimize/cell_utils.py +96 -0
- mindspore/_extends/parallel_compile/akg_compiler/custom.py +1109 -0
- mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
- mindspore/_extends/parse/__init__.py +3 -3
- mindspore/_extends/parse/compile_config.py +44 -22
- mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +1 -2
- mindspore/_extends/parse/parser.py +64 -83
- mindspore/_extends/parse/resources.py +39 -0
- mindspore/_extends/parse/standard_method.py +47 -14
- mindspore/_extends/parse/trope.py +8 -1
- mindspore/_extends/pijit/__init__.py +1 -2
- mindspore/_extends/pijit/pijit_func_white_list.py +2 -5
- mindspore/amp.py +4 -22
- mindspore/atlprov.dll +0 -0
- mindspore/avcodec-59.dll +0 -0
- mindspore/avdevice-59.dll +0 -0
- mindspore/avfilter-8.dll +0 -0
- mindspore/avformat-59.dll +0 -0
- mindspore/avutil-57.dll +0 -0
- mindspore/boost/adasum.py +1 -1
- mindspore/boost/boost_cell_wrapper.py +4 -4
- mindspore/c1.dll +0 -0
- mindspore/c1xx.dll +0 -0
- mindspore/c2.dll +0 -0
- mindspore/common/__init__.py +43 -12
- mindspore/common/_grad_function.py +2 -1
- mindspore/common/_pijit_context.py +28 -7
- mindspore/common/_stub_tensor.py +1 -209
- mindspore/common/_tensor_cpp_method.py +1 -1
- mindspore/common/_tensor_docs.py +177 -52
- mindspore/common/_utils.py +9 -1
- mindspore/common/api.py +338 -208
- mindspore/common/dtype.py +108 -57
- mindspore/common/dump.py +11 -16
- mindspore/common/dynamic_shape/__init__.py +0 -0
- mindspore/common/{auto_dynamic_shape.py → dynamic_shape/auto_dynamic_shape.py} +17 -23
- mindspore/common/dynamic_shape/enable_dynamic.py +197 -0
- mindspore/common/file_system.py +59 -9
- mindspore/common/generator.py +2 -3
- mindspore/common/hook_handle.py +33 -5
- mindspore/common/jit_config.py +1 -1
- mindspore/common/jit_trace.py +84 -105
- mindspore/common/np_dtype.py +3 -3
- mindspore/common/parameter.py +27 -29
- mindspore/common/recompute.py +5 -7
- mindspore/common/sparse_tensor.py +0 -3
- mindspore/common/symbol.py +0 -1
- mindspore/common/tensor.py +84 -133
- mindspore/communication/_comm_helper.py +46 -4
- mindspore/communication/management.py +79 -7
- mindspore/context.py +47 -38
- mindspore/dataset/__init__.py +1 -1
- mindspore/dataset/audio/transforms.py +1 -1
- mindspore/dataset/core/config.py +38 -4
- mindspore/dataset/engine/datasets.py +350 -322
- mindspore/dataset/engine/datasets_user_defined.py +69 -23
- mindspore/dataset/engine/iterators.py +2 -2
- mindspore/dataset/engine/obs/config_loader.py +2 -2
- mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +8 -0
- mindspore/dataset/transforms/c_transforms.py +2 -2
- mindspore/dataset/transforms/py_transforms.py +7 -3
- mindspore/dataset/transforms/transforms.py +10 -6
- mindspore/dataset/vision/__init__.py +1 -1
- mindspore/dataset/vision/py_transforms.py +8 -8
- mindspore/dataset/vision/transforms.py +17 -5
- mindspore/dataset/vision/utils.py +632 -21
- mindspore/dataset/vision/validators.py +1 -0
- mindspore/device_context/ascend/device.py +1 -1
- mindspore/device_context/ascend/op_tuning.py +35 -1
- mindspore/device_context/gpu/__init__.py +2 -2
- mindspore/device_context/gpu/device.py +1 -1
- mindspore/device_context/gpu/op_precision.py +4 -2
- mindspore/device_context/gpu/op_tuning.py +6 -3
- mindspore/device_manager.py +16 -9
- mindspore/dnnl.dll +0 -0
- mindspore/dpcmi.dll +0 -0
- mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +5 -4
- mindspore/experimental/llm_boost/atb/boost_base.py +2 -3
- mindspore/experimental/optim/adadelta.py +13 -20
- mindspore/experimental/optim/adagrad.py +15 -22
- mindspore/experimental/optim/adam.py +17 -24
- mindspore/experimental/optim/adamax.py +14 -22
- mindspore/experimental/optim/adamw.py +28 -34
- mindspore/experimental/optim/asgd.py +15 -25
- mindspore/experimental/optim/lr_scheduler.py +27 -45
- mindspore/experimental/optim/nadam.py +14 -24
- mindspore/experimental/optim/optimizer.py +13 -23
- mindspore/experimental/optim/radam.py +18 -24
- mindspore/experimental/optim/rmsprop.py +14 -25
- mindspore/experimental/optim/rprop.py +15 -26
- mindspore/experimental/optim/sgd.py +9 -19
- mindspore/hal/__init__.py +4 -4
- mindspore/hal/contiguous_tensors_handle.py +2 -2
- mindspore/hal/memory.py +1 -0
- mindspore/include/api/cell.h +65 -5
- mindspore/include/api/cfg.h +24 -7
- mindspore/include/api/context.h +1 -0
- mindspore/include/api/delegate.h +10 -2
- mindspore/include/api/dual_abi_helper.h +100 -19
- mindspore/include/api/graph.h +14 -1
- mindspore/include/api/kernel.h +16 -3
- mindspore/include/api/kernel_api.h +9 -1
- mindspore/include/api/metrics/accuracy.h +9 -0
- mindspore/include/api/model.h +8 -1
- mindspore/include/api/model_group.h +4 -0
- mindspore/include/api/model_parallel_runner.h +2 -0
- mindspore/include/api/status.h +48 -10
- mindspore/include/api/types.h +8 -3
- mindspore/include/c_api/model_c.h +0 -58
- mindspore/include/c_api/tensor_c.h +0 -26
- mindspore/include/dataset/constants.h +9 -0
- mindspore/include/dataset/vision_ascend.h +1 -1
- mindspore/jpeg62.dll +0 -0
- mindspore/mindrecord/tools/cifar10.py +61 -11
- mindspore/mindrecord/tools/cifar10_to_mr.py +5 -0
- mindspore/mindspore_backend_common.dll +0 -0
- mindspore/mindspore_backend_manager.dll +0 -0
- mindspore/mindspore_common.dll +0 -0
- mindspore/mindspore_core.dll +0 -0
- mindspore/mindspore_cpu_res_manager.dll +0 -0
- mindspore/mindspore_dump.dll +0 -0
- mindspore/mindspore_frontend.dll +0 -0
- mindspore/mindspore_glog.dll +0 -0
- mindspore/mindspore_memory_pool.dll +0 -0
- mindspore/mindspore_ms_backend.dll +0 -0
- mindspore/mindspore_ops.dll +0 -0
- mindspore/mindspore_ops_host.dll +0 -0
- mindspore/mindspore_ops_kernel_common.dll +0 -0
- mindspore/mindspore_profiler.dll +0 -0
- mindspore/mindspore_pyboost.dll +0 -0
- mindspore/mindspore_pynative.dll +0 -0
- mindspore/mindspore_res_manager.dll +0 -0
- mindspore/mindspore_runtime_pipeline.dll +0 -0
- mindspore/mint/__init__.py +4 -44
- mindspore/mint/distributed/__init__.py +5 -0
- mindspore/mint/distributed/distributed.py +425 -19
- mindspore/mint/nn/__init__.py +1 -1
- mindspore/mint/nn/functional.py +53 -6
- mindspore/mint/nn/layer/_functions.py +163 -294
- mindspore/mint/nn/layer/activation.py +8 -6
- mindspore/mint/nn/layer/conv.py +125 -101
- mindspore/mint/nn/layer/normalization.py +11 -25
- mindspore/mint/optim/adam.py +19 -18
- mindspore/mint/optim/adamw.py +14 -8
- mindspore/mint/optim/sgd.py +5 -5
- mindspore/msobj140.dll +0 -0
- mindspore/mspdb140.dll +0 -0
- mindspore/mspdbcore.dll +0 -0
- mindspore/mspdbst.dll +0 -0
- mindspore/mspft140.dll +0 -0
- mindspore/msvcdis140.dll +0 -0
- mindspore/msvcp140_1.dll +0 -0
- mindspore/msvcp140_2.dll +0 -0
- mindspore/msvcp140_atomic_wait.dll +0 -0
- mindspore/msvcp140_codecvt_ids.dll +0 -0
- mindspore/nn/cell.py +488 -620
- mindspore/nn/grad/cell_grad.py +11 -12
- mindspore/nn/layer/activation.py +36 -36
- mindspore/nn/layer/basic.py +74 -77
- mindspore/nn/layer/channel_shuffle.py +4 -4
- mindspore/nn/layer/combined.py +4 -2
- mindspore/nn/layer/conv.py +86 -85
- mindspore/nn/layer/dense.py +9 -7
- mindspore/nn/layer/embedding.py +50 -52
- mindspore/nn/layer/image.py +38 -40
- mindspore/nn/layer/math.py +111 -112
- mindspore/nn/layer/normalization.py +56 -44
- mindspore/nn/layer/pooling.py +58 -63
- mindspore/nn/layer/rnn_cells.py +33 -33
- mindspore/nn/layer/rnns.py +56 -56
- mindspore/nn/layer/thor_layer.py +74 -73
- mindspore/nn/layer/transformer.py +11 -1
- mindspore/nn/learning_rate_schedule.py +20 -20
- mindspore/nn/loss/loss.py +79 -81
- mindspore/nn/optim/adam.py +2 -4
- mindspore/nn/optim/adasum.py +2 -2
- mindspore/nn/optim/lamb.py +1 -3
- mindspore/nn/optim/optimizer.py +1 -1
- mindspore/nn/optim/tft_wrapper.py +2 -3
- mindspore/nn/optim/thor.py +2 -2
- mindspore/nn/probability/distribution/_utils/utils.py +2 -2
- mindspore/nn/probability/distribution/exponential.py +2 -1
- mindspore/nn/probability/distribution/poisson.py +2 -1
- mindspore/nn/sparse/sparse.py +3 -3
- mindspore/nn/wrap/cell_wrapper.py +73 -42
- mindspore/nn/wrap/grad_reducer.py +37 -52
- mindspore/nn/wrap/loss_scale.py +72 -74
- mindspore/numpy/array_creations.py +7 -7
- mindspore/numpy/fft.py +1 -1
- mindspore/numpy/math_ops.py +1 -1
- mindspore/numpy/utils_const.py +1 -1
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/opencv_imgproc452.dll +0 -0
- mindspore/ops/_grad_experimental/grad_comm_ops.py +51 -13
- mindspore/ops/_grad_experimental/grad_debug_ops.py +14 -0
- mindspore/ops/_grad_experimental/grad_inner_ops.py +0 -9
- mindspore/ops/_op_impl/cpu/__init__.py +1 -0
- mindspore/{experimental/es/__init__.py → ops/_op_impl/cpu/joinedstr_op.py} +12 -6
- mindspore/ops/_vmap/vmap_array_ops.py +6 -13
- mindspore/ops/_vmap/vmap_nn_ops.py +8 -16
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +29 -10
- mindspore/ops/auto_generate/gen_extend_func.py +5 -55
- mindspore/ops/auto_generate/gen_ops_def.py +753 -273
- mindspore/ops/auto_generate/gen_ops_prim.py +1687 -958
- mindspore/ops/auto_generate/pyboost_inner_prim.py +31 -1
- mindspore/ops/composite/__init__.py +10 -0
- mindspore/ops/composite/base.py +9 -5
- mindspore/ops/composite/multitype_ops/__init__.py +12 -1
- mindspore/ops/composite/multitype_ops/_compile_utils.py +132 -108
- mindspore/ops/composite/multitype_ops/_constexpr_utils.py +1 -1
- mindspore/ops/composite/multitype_ops/add_impl.py +70 -2
- mindspore/ops/composite/multitype_ops/div_impl.py +49 -0
- mindspore/ops/composite/multitype_ops/floordiv_impl.py +29 -0
- mindspore/ops/composite/multitype_ops/getitem_impl.py +11 -0
- mindspore/ops/composite/multitype_ops/mod_impl.py +5 -3
- mindspore/ops/composite/multitype_ops/mul_impl.py +49 -0
- mindspore/ops/composite/multitype_ops/setitem_impl.py +57 -0
- mindspore/ops/composite/multitype_ops/sub_impl.py +34 -0
- mindspore/ops/composite/multitype_ops/zeros_like_impl.py +14 -0
- mindspore/ops/function/__init__.py +4 -1
- mindspore/ops/function/_add_attr_func.py +11 -6
- mindspore/ops/function/array_func.py +17 -100
- mindspore/ops/function/debug_func.py +8 -5
- mindspore/ops/function/grad/grad_func.py +5 -13
- mindspore/ops/function/math_func.py +65 -399
- mindspore/ops/function/nn_func.py +44 -61
- mindspore/ops/function/other_func.py +4 -1
- mindspore/ops/function/random_func.py +31 -4
- mindspore/ops/functional.py +2 -3
- mindspore/ops/functional_overload.py +486 -18
- mindspore/ops/op_info_register.py +21 -0
- mindspore/ops/operations/__init__.py +5 -2
- mindspore/ops/operations/_custom_ops_utils.py +675 -8
- mindspore/ops/operations/_inner_ops.py +14 -18
- mindspore/ops/operations/_sequence_ops.py +1 -1
- mindspore/ops/operations/array_ops.py +4 -50
- mindspore/ops/operations/comm_ops.py +186 -41
- mindspore/ops/operations/custom_ops.py +244 -175
- mindspore/ops/operations/debug_ops.py +55 -4
- mindspore/ops/operations/image_ops.py +13 -13
- mindspore/ops/operations/manually_defined/ops_def.py +27 -28
- mindspore/ops/operations/math_ops.py +8 -9
- mindspore/ops/operations/nn_ops.py +6 -7
- mindspore/ops/primitive.py +9 -20
- mindspore/ops/tensor_method.py +52 -11
- mindspore/ops_generate/api/cpp_create_prim_instance_helper_generator.py +1 -1
- mindspore/ops_generate/api/functional_map_cpp_generator.py +10 -9
- mindspore/ops_generate/api/functions_cc_generator.py +58 -10
- mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +1 -1
- mindspore/ops_generate/common/base_generator.py +14 -0
- mindspore/ops_generate/common/gen_constants.py +7 -2
- mindspore/ops_generate/common/gen_utils.py +0 -19
- mindspore/ops_generate/common/op_proto.py +11 -4
- mindspore/ops_generate/common/template.py +88 -11
- mindspore/ops_generate/gen_ops.py +1 -1
- mindspore/ops_generate/op_def/lite_ops_cpp_generator.py +4 -4
- mindspore/ops_generate/op_def/ops_name_h_generator.py +0 -3
- mindspore/ops_generate/op_def/ops_primitive_h_generator.py +0 -4
- mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -2
- mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +49 -8
- mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +2 -2
- mindspore/ops_generate/pyboost/gen_pyboost_func.py +31 -16
- mindspore/ops_generate/pyboost/op_template_parser.py +98 -72
- mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +70 -273
- mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +14 -6
- mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +316 -0
- mindspore/ops_generate/pyboost/pyboost_functions_py_generator.py +1 -1
- mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +5 -3
- mindspore/ops_generate/pyboost/pyboost_inner_prim_generator.py +1 -1
- mindspore/ops_generate/pyboost/pyboost_internal_functions_cpp_generator.py +76 -0
- mindspore/ops_generate/pyboost/pyboost_internal_functions_h_generator.py +76 -0
- mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +125 -0
- mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +4 -3
- mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +348 -61
- mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +1 -1
- mindspore/ops_generate/pyboost/pyboost_utils.py +118 -9
- mindspore/ops_generate/tensor_py_cc_generator.py +1 -24
- mindspore/parallel/_auto_parallel_context.py +9 -17
- mindspore/parallel/_cell_wrapper.py +106 -40
- mindspore/parallel/_parallel_serialization.py +4 -3
- mindspore/parallel/_ps_context.py +4 -6
- mindspore/parallel/_tensor.py +167 -12
- mindspore/parallel/_transformer/moe.py +1 -1
- mindspore/parallel/_transformer/transformer.py +17 -12
- mindspore/parallel/_utils.py +5 -11
- mindspore/parallel/auto_parallel.py +33 -12
- mindspore/parallel/checkpoint_convert.py +3 -3
- mindspore/parallel/checkpoint_transform.py +5 -1
- mindspore/parallel/cluster/process_entity/_api.py +88 -49
- mindspore/parallel/cluster/process_entity/_utils.py +95 -7
- mindspore/parallel/cluster/run.py +48 -7
- mindspore/parallel/function/__init__.py +8 -1
- mindspore/parallel/function/reshard_func.py +7 -6
- mindspore/parallel/nn/__init__.py +15 -2
- mindspore/parallel/nn/parallel_cell_wrapper.py +50 -14
- mindspore/parallel/nn/parallel_grad_reducer.py +7 -14
- mindspore/parallel/shard.py +9 -23
- mindspore/parallel/transform_safetensors.py +468 -174
- mindspore/pgodb140.dll +0 -0
- mindspore/pgort140.dll +0 -0
- mindspore/profiler/__init__.py +2 -1
- mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +7 -7
- mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +3 -0
- mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +3 -0
- mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +3 -3
- mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +3 -3
- mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +4 -4
- mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +3 -3
- mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +4 -1
- mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +2 -1
- mindspore/profiler/analysis/task_manager.py +1 -1
- mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +5 -1
- mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +2 -1
- mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +10 -9
- mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +43 -23
- mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +3 -2
- mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +9 -5
- mindspore/profiler/analysis/viewer/ms_operator_details_viewer.py +132 -0
- mindspore/profiler/common/constant.py +16 -0
- mindspore/profiler/common/msprof_cmd_tool.py +2 -2
- mindspore/profiler/common/path_manager.py +9 -0
- mindspore/profiler/common/profiler_context.py +50 -29
- mindspore/profiler/common/profiler_info.py +0 -16
- mindspore/profiler/common/profiler_meta_data.py +1 -0
- mindspore/profiler/common/profiler_op_analyse.py +239 -0
- mindspore/profiler/common/profiler_output_path.py +23 -8
- mindspore/profiler/common/profiler_parameters.py +128 -35
- mindspore/profiler/dynamic_profile/__init__.py +0 -0
- mindspore/profiler/dynamic_profile/dynamic_monitor_proxy.py +39 -0
- mindspore/profiler/dynamic_profile/dynamic_profiler_config_context.py +666 -0
- mindspore/profiler/dynamic_profile/dynamic_profiler_utils.py +62 -0
- mindspore/profiler/dynamic_profiler.py +374 -338
- mindspore/profiler/envprofiler.py +42 -12
- mindspore/profiler/experimental_config.py +112 -7
- mindspore/profiler/mstx.py +33 -12
- mindspore/profiler/platform/__init__.py +2 -3
- mindspore/profiler/platform/cpu_profiler.py +10 -4
- mindspore/profiler/platform/npu_profiler.py +30 -20
- mindspore/profiler/profiler.py +218 -154
- mindspore/profiler/profiler_action_controller.py +65 -77
- mindspore/profiler/profiler_interface.py +2 -2
- mindspore/profiler/schedule.py +10 -4
- mindspore/rewrite/common/config.py +1 -0
- mindspore/rewrite/common/namer.py +1 -0
- mindspore/rewrite/common/namespace.py +1 -0
- mindspore/rewrite/node/node.py +31 -11
- mindspore/rewrite/parsers/assign_parser.py +1 -1
- mindspore/rewrite/symbol_tree/symbol_tree.py +2 -2
- mindspore/run_check/_check_version.py +7 -10
- mindspore/runtime/__init__.py +8 -6
- mindspore/runtime/event.py +10 -4
- mindspore/runtime/executor.py +87 -45
- mindspore/runtime/memory.py +22 -30
- mindspore/runtime/thread_bind_core.py +299 -165
- mindspore/safeguard/rewrite_obfuscation.py +12 -13
- mindspore/swresample-4.dll +0 -0
- mindspore/swscale-6.dll +0 -0
- mindspore/tbbmalloc.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/_utils.py +9 -5
- mindspore/train/amp.py +43 -23
- mindspore/train/callback/__init__.py +5 -5
- mindspore/train/callback/_callback.py +2 -1
- mindspore/train/callback/_checkpoint.py +4 -14
- mindspore/train/callback/_flops_collector.py +11 -7
- mindspore/train/callback/_landscape.py +0 -1
- mindspore/train/callback/_train_fault_tolerance.py +72 -18
- mindspore/train/data_sink.py +15 -6
- mindspore/train/dataset_helper.py +14 -5
- mindspore/train/model.py +49 -47
- mindspore/train/serialization.py +168 -126
- mindspore/train/summary/summary_record.py +13 -2
- mindspore/train/train_thor/model_thor.py +2 -2
- mindspore/turbojpeg.dll +0 -0
- mindspore/utils/__init__.py +3 -2
- mindspore/utils/dryrun.py +0 -6
- mindspore/utils/runtime_execution_order_check.py +162 -78
- mindspore/utils/sdc_detect.py +68 -0
- mindspore/utils/utils.py +14 -17
- mindspore/vcmeta.dll +0 -0
- mindspore/vcruntime140.dll +0 -0
- mindspore/vcruntime140_1.dll +0 -0
- mindspore/version.py +1 -1
- {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/METADATA +5 -4
- {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/RECORD +400 -439
- mindspore/_deprecated/jit.py +0 -198
- mindspore/_extends/remote/kernel_build_server_ascend.py +0 -75
- mindspore/communication/_hccl_management.py +0 -297
- mindspore/experimental/es/embedding_service.py +0 -891
- mindspore/experimental/es/embedding_service_layer.py +0 -581
- mindspore/profiler/common/validator/__init__.py +0 -14
- mindspore/profiler/common/validator/validate_path.py +0 -84
- mindspore/profiler/parser/__init__.py +0 -14
- mindspore/profiler/parser/aicpu_data_parser.py +0 -272
- mindspore/profiler/parser/ascend_analysis/__init__.py +0 -14
- mindspore/profiler/parser/ascend_analysis/constant.py +0 -71
- mindspore/profiler/parser/ascend_analysis/file_manager.py +0 -180
- mindspore/profiler/parser/ascend_analysis/function_event.py +0 -185
- mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +0 -136
- mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +0 -131
- mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +0 -104
- mindspore/profiler/parser/ascend_analysis/path_manager.py +0 -313
- mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +0 -123
- mindspore/profiler/parser/ascend_analysis/tlv_decoder.py +0 -86
- mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +0 -75
- mindspore/profiler/parser/ascend_cluster_generator.py +0 -116
- mindspore/profiler/parser/ascend_communicate_generator.py +0 -314
- mindspore/profiler/parser/ascend_flops_generator.py +0 -116
- mindspore/profiler/parser/ascend_fpbp_generator.py +0 -82
- mindspore/profiler/parser/ascend_hccl_generator.py +0 -271
- mindspore/profiler/parser/ascend_integrate_generator.py +0 -42
- mindspore/profiler/parser/ascend_memory_generator.py +0 -185
- mindspore/profiler/parser/ascend_msprof_exporter.py +0 -282
- mindspore/profiler/parser/ascend_msprof_generator.py +0 -187
- mindspore/profiler/parser/ascend_op_generator.py +0 -334
- mindspore/profiler/parser/ascend_steptrace_generator.py +0 -94
- mindspore/profiler/parser/ascend_timeline_generator.py +0 -545
- mindspore/profiler/parser/base_timeline_generator.py +0 -483
- mindspore/profiler/parser/container.py +0 -229
- mindspore/profiler/parser/cpu_gpu_timeline_generator.py +0 -697
- mindspore/profiler/parser/flops_parser.py +0 -531
- mindspore/profiler/parser/framework_enum.py +0 -111
- mindspore/profiler/parser/framework_parser.py +0 -464
- mindspore/profiler/parser/framework_struct.py +0 -61
- mindspore/profiler/parser/gpu_analysis/__init__.py +0 -14
- mindspore/profiler/parser/gpu_analysis/function_event.py +0 -44
- mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +0 -89
- mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +0 -72
- mindspore/profiler/parser/hccl_parser.py +0 -573
- mindspore/profiler/parser/hwts_log_parser.py +0 -122
- mindspore/profiler/parser/integrator.py +0 -526
- mindspore/profiler/parser/memory_usage_parser.py +0 -277
- mindspore/profiler/parser/minddata_analyzer.py +0 -800
- mindspore/profiler/parser/minddata_parser.py +0 -186
- mindspore/profiler/parser/minddata_pipeline_parser.py +0 -299
- mindspore/profiler/parser/op_intermediate_parser.py +0 -149
- mindspore/profiler/parser/optime_parser.py +0 -250
- mindspore/profiler/parser/profiler_info.py +0 -213
- mindspore/profiler/parser/step_trace_parser.py +0 -666
- mindspore/utils/hooks.py +0 -81
- /mindspore/common/{_auto_dynamic.py → dynamic_shape/_auto_dynamic.py} +0 -0
- {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/WHEEL +0 -0
- {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/entry_points.txt +0 -0
- {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/top_level.txt +0 -0
|
@@ -19,7 +19,7 @@ from __future__ import division
|
|
|
19
19
|
import math
|
|
20
20
|
|
|
21
21
|
from mindspore.common import dtype as mstype
|
|
22
|
-
from mindspore
|
|
22
|
+
from mindspore import ops
|
|
23
23
|
from mindspore.nn.cell import Cell
|
|
24
24
|
from mindspore import _checkparam as validator
|
|
25
25
|
|
|
@@ -119,13 +119,13 @@ class ExponentialDecayLR(LearningRateSchedule):
|
|
|
119
119
|
self.decay_rate = decay_rate
|
|
120
120
|
self.decay_steps = decay_steps
|
|
121
121
|
self.is_stair = is_stair
|
|
122
|
-
self.pow =
|
|
123
|
-
self.cast =
|
|
122
|
+
self.pow = ops.Pow()
|
|
123
|
+
self.cast = ops.Cast()
|
|
124
124
|
|
|
125
125
|
def construct(self, global_step):
|
|
126
126
|
p = self.cast(global_step, mstype.float32) / self.decay_steps
|
|
127
127
|
if self.is_stair:
|
|
128
|
-
p =
|
|
128
|
+
p = ops.Floor()(p)
|
|
129
129
|
return self.learning_rate * self.pow(self.decay_rate, p)
|
|
130
130
|
|
|
131
131
|
|
|
@@ -191,13 +191,13 @@ class NaturalExpDecayLR(LearningRateSchedule):
|
|
|
191
191
|
self.decay_steps = decay_steps
|
|
192
192
|
self.is_stair = is_stair
|
|
193
193
|
self.math_e = math.e
|
|
194
|
-
self.pow =
|
|
195
|
-
self.cast =
|
|
194
|
+
self.pow = ops.Pow()
|
|
195
|
+
self.cast = ops.Cast()
|
|
196
196
|
|
|
197
197
|
def construct(self, global_step):
|
|
198
198
|
p = self.cast(global_step, mstype.float32)
|
|
199
199
|
if self.is_stair:
|
|
200
|
-
p =
|
|
200
|
+
p = ops.FloorDiv()(p, self.decay_steps) * self.decay_steps
|
|
201
201
|
return self.learning_rate * self.pow(self.math_e, -self.decay_rate * p)
|
|
202
202
|
|
|
203
203
|
|
|
@@ -264,12 +264,12 @@ class InverseDecayLR(LearningRateSchedule):
|
|
|
264
264
|
self.decay_rate = decay_rate
|
|
265
265
|
self.decay_steps = decay_steps
|
|
266
266
|
self.is_stair = is_stair
|
|
267
|
-
self.cast =
|
|
267
|
+
self.cast = ops.Cast()
|
|
268
268
|
|
|
269
269
|
def construct(self, global_step):
|
|
270
270
|
p = self.cast(global_step, mstype.float32) / self.decay_steps
|
|
271
271
|
if self.is_stair:
|
|
272
|
-
p =
|
|
272
|
+
p = ops.Floor()(p)
|
|
273
273
|
return self.learning_rate / (1 + self.decay_rate * p)
|
|
274
274
|
|
|
275
275
|
|
|
@@ -334,10 +334,10 @@ class CosineDecayLR(LearningRateSchedule):
|
|
|
334
334
|
self.decay_steps = decay_steps
|
|
335
335
|
self.math_pi = math.pi
|
|
336
336
|
self.delta = 0.5 * (max_lr - min_lr)
|
|
337
|
-
self.cos =
|
|
338
|
-
self.sin =
|
|
339
|
-
self.min =
|
|
340
|
-
self.cast =
|
|
337
|
+
self.cos = ops.Cos()
|
|
338
|
+
self.sin = ops.Sin()
|
|
339
|
+
self.min = ops.Minimum()
|
|
340
|
+
self.cast = ops.Cast()
|
|
341
341
|
|
|
342
342
|
def construct(self, global_step):
|
|
343
343
|
p = self.cast(self.min(global_step, self.decay_steps), mstype.float32)
|
|
@@ -425,13 +425,13 @@ class PolynomialDecayLR(LearningRateSchedule):
|
|
|
425
425
|
self.diff_learning_rate = learning_rate - end_learning_rate
|
|
426
426
|
self.power = power
|
|
427
427
|
self.update_decay_steps = update_decay_steps
|
|
428
|
-
self.pow =
|
|
429
|
-
self.ceil =
|
|
430
|
-
self.min =
|
|
431
|
-
self.max =
|
|
428
|
+
self.pow = ops.Pow()
|
|
429
|
+
self.ceil = ops.Ceil()
|
|
430
|
+
self.min = ops.Minimum()
|
|
431
|
+
self.max = ops.Maximum()
|
|
432
432
|
|
|
433
433
|
def construct(self, global_step):
|
|
434
|
-
tmp_global_step =
|
|
434
|
+
tmp_global_step = ops.Cast()(global_step, mstype.float32)
|
|
435
435
|
tmp_decay_step = self.decay_steps
|
|
436
436
|
if self.update_decay_steps:
|
|
437
437
|
tmp_decay_step = tmp_decay_step * self.max(self.ceil(tmp_global_step / tmp_decay_step), 1)
|
|
@@ -498,8 +498,8 @@ class WarmUpLR(LearningRateSchedule):
|
|
|
498
498
|
validator.check_positive_int(warmup_steps, 'warmup_steps', self.cls_name)
|
|
499
499
|
self.warmup_steps = warmup_steps
|
|
500
500
|
self.learning_rate = learning_rate
|
|
501
|
-
self.min =
|
|
502
|
-
self.cast =
|
|
501
|
+
self.min = ops.Minimum()
|
|
502
|
+
self.cast = ops.Cast()
|
|
503
503
|
|
|
504
504
|
def construct(self, global_step):
|
|
505
505
|
warmup_percent = self.cast(self.min(global_step, self.warmup_steps), mstype.float32) / self.warmup_steps
|
mindspore/nn/loss/loss.py
CHANGED
|
@@ -22,9 +22,7 @@ import mindspore.ops as ops
|
|
|
22
22
|
from mindspore import log
|
|
23
23
|
from mindspore.common.tensor import Tensor
|
|
24
24
|
from mindspore.common.parameter import Parameter
|
|
25
|
-
from mindspore.ops import operations as P
|
|
26
25
|
from mindspore.ops.operations import _inner_ops as inner
|
|
27
|
-
from mindspore.ops import functional as F
|
|
28
26
|
from mindspore import nn
|
|
29
27
|
from mindspore.ops.primitive import constexpr, _primexpr
|
|
30
28
|
from mindspore.nn.cell import Cell
|
|
@@ -103,10 +101,10 @@ class LossBase(Cell):
|
|
|
103
101
|
if reduction == 'none':
|
|
104
102
|
self.reduce = False
|
|
105
103
|
|
|
106
|
-
self.reduce_mean =
|
|
107
|
-
self.reduce_sum =
|
|
108
|
-
self.mul =
|
|
109
|
-
self.cast =
|
|
104
|
+
self.reduce_mean = ops.ReduceMean()
|
|
105
|
+
self.reduce_sum = ops.ReduceSum()
|
|
106
|
+
self.mul = ops.Mul()
|
|
107
|
+
self.cast = ops.Cast()
|
|
110
108
|
|
|
111
109
|
def get_axis(self, x):
|
|
112
110
|
"""
|
|
@@ -115,9 +113,9 @@ class LossBase(Cell):
|
|
|
115
113
|
Args:
|
|
116
114
|
x (Tensor): Tensor of any shape.
|
|
117
115
|
"""
|
|
118
|
-
shape =
|
|
119
|
-
length =
|
|
120
|
-
perm =
|
|
116
|
+
shape = ops.shape(x)
|
|
117
|
+
length = ops.tuple_len(shape)
|
|
118
|
+
perm = ops.make_range(0, length)
|
|
121
119
|
return perm
|
|
122
120
|
|
|
123
121
|
def get_loss(self, x, weights=1.0):
|
|
@@ -168,9 +166,9 @@ class _Loss(LossBase):
|
|
|
168
166
|
@constexpr(check=False)
|
|
169
167
|
def _check_is_tensor(param_name, input_data, cls_name):
|
|
170
168
|
"""Internal function, used to check whether the input data is Tensor."""
|
|
171
|
-
if input_data is not None and not isinstance(
|
|
169
|
+
if input_data is not None and not isinstance(ops.typeof(input_data), mstype.TensorType):
|
|
172
170
|
raise TypeError(f"For '{cls_name}', the '{param_name}' must be '{mstype.TensorType}', "
|
|
173
|
-
f"but got '{
|
|
171
|
+
f"but got '{ops.typeof(input_data)}'")
|
|
174
172
|
|
|
175
173
|
|
|
176
174
|
class L1Loss(LossBase):
|
|
@@ -243,7 +241,7 @@ class L1Loss(LossBase):
|
|
|
243
241
|
self.reduction = reduction
|
|
244
242
|
|
|
245
243
|
def construct(self, logits, labels):
|
|
246
|
-
return
|
|
244
|
+
return ops.l1_loss(logits, labels, self.reduction)
|
|
247
245
|
|
|
248
246
|
|
|
249
247
|
class L1LossExt(LossBase):
|
|
@@ -389,7 +387,7 @@ class MSELoss(LossBase):
|
|
|
389
387
|
def construct(self, logits, labels):
|
|
390
388
|
_check_is_tensor('logits', logits, self.cls_name)
|
|
391
389
|
_check_is_tensor('labels', labels, self.cls_name)
|
|
392
|
-
x =
|
|
390
|
+
x = ops.square(logits - labels)
|
|
393
391
|
return self.get_loss(x)
|
|
394
392
|
|
|
395
393
|
|
|
@@ -448,7 +446,7 @@ class RMSELoss(LossBase):
|
|
|
448
446
|
def __init__(self):
|
|
449
447
|
"""Initialize RMSELoss."""
|
|
450
448
|
super(RMSELoss, self).__init__()
|
|
451
|
-
self.dtype =
|
|
449
|
+
self.dtype = ops.DType()
|
|
452
450
|
self.MSELoss = MSELoss()
|
|
453
451
|
|
|
454
452
|
def construct(self, logits, label):
|
|
@@ -458,7 +456,7 @@ class RMSELoss(LossBase):
|
|
|
458
456
|
_check_rmseloss_dtype(logits_dtype, not_supported_dtype, 'RMSELoss')
|
|
459
457
|
_check_rmseloss_dtype(label_dtype, not_supported_dtype, "RMSELoss")
|
|
460
458
|
|
|
461
|
-
rmse_loss =
|
|
459
|
+
rmse_loss = ops.sqrt(self.MSELoss(logits, label))
|
|
462
460
|
|
|
463
461
|
return rmse_loss
|
|
464
462
|
|
|
@@ -532,7 +530,7 @@ class MAELoss(LossBase):
|
|
|
532
530
|
def __init__(self, reduction='mean'):
|
|
533
531
|
"""Initialize MAELoss."""
|
|
534
532
|
super(MAELoss, self).__init__(reduction)
|
|
535
|
-
self.abs =
|
|
533
|
+
self.abs = ops.Abs()
|
|
536
534
|
|
|
537
535
|
def construct(self, logits, label):
|
|
538
536
|
_check_is_tensor('logits', logits, self.cls_name)
|
|
@@ -708,7 +706,7 @@ class SmoothL1Loss(LossBase):
|
|
|
708
706
|
super(SmoothL1Loss, self).__init__(reduction)
|
|
709
707
|
self.beta = beta
|
|
710
708
|
self.reduction = reduction
|
|
711
|
-
self.smooth_l1_loss =
|
|
709
|
+
self.smooth_l1_loss = ops.SmoothL1Loss(self.beta, self.reduction)
|
|
712
710
|
|
|
713
711
|
def construct(self, logits, labels):
|
|
714
712
|
return self.smooth_l1_loss(logits, labels)
|
|
@@ -772,7 +770,7 @@ class SoftMarginLoss(LossBase):
|
|
|
772
770
|
self.reduction = reduction
|
|
773
771
|
|
|
774
772
|
def construct(self, logits, labels):
|
|
775
|
-
return
|
|
773
|
+
return ops.soft_margin_loss(logits, labels, self.reduction)
|
|
776
774
|
|
|
777
775
|
|
|
778
776
|
class SoftmaxCrossEntropyWithLogits(LossBase):
|
|
@@ -856,12 +854,12 @@ class SoftmaxCrossEntropyWithLogits(LossBase):
|
|
|
856
854
|
super(SoftmaxCrossEntropyWithLogits, self).__init__(reduction)
|
|
857
855
|
self.sparse = validator.check_bool(sparse, "sparse", self.cls_name)
|
|
858
856
|
self.reduction = reduction
|
|
859
|
-
self.softmax_cross_entropy =
|
|
860
|
-
self.one_hot =
|
|
857
|
+
self.softmax_cross_entropy = ops.SoftmaxCrossEntropyWithLogits()
|
|
858
|
+
self.one_hot = ops.OneHot()
|
|
861
859
|
self.on_value = Tensor(1.0, mstype.float32)
|
|
862
860
|
self.off_value = Tensor(0., mstype.float32)
|
|
863
861
|
self.is_cpugpu = context.get_context('device_target') in ["CPU", "GPU"]
|
|
864
|
-
self.sparse_softmax_cross_entropy =
|
|
862
|
+
self.sparse_softmax_cross_entropy = ops.SparseSoftmaxCrossEntropyWithLogits()
|
|
865
863
|
|
|
866
864
|
def construct(self, logits, labels):
|
|
867
865
|
_check_is_tensor('logits', logits, self.cls_name)
|
|
@@ -870,7 +868,7 @@ class SoftmaxCrossEntropyWithLogits(LossBase):
|
|
|
870
868
|
if self.reduction == 'mean':
|
|
871
869
|
x = self.sparse_softmax_cross_entropy(logits, labels)
|
|
872
870
|
return x
|
|
873
|
-
labels = self.one_hot(labels,
|
|
871
|
+
labels = self.one_hot(labels, ops.shape(logits)[-1], self.on_value, self.off_value)
|
|
874
872
|
x = self.softmax_cross_entropy(logits, labels)[0]
|
|
875
873
|
return self.get_loss(x)
|
|
876
874
|
|
|
@@ -934,7 +932,7 @@ class DiceLoss(LossBase):
|
|
|
934
932
|
"""Initialize DiceLoss."""
|
|
935
933
|
super(DiceLoss, self).__init__()
|
|
936
934
|
self.smooth = validator.check_positive_float(smooth, "smooth")
|
|
937
|
-
self.reshape =
|
|
935
|
+
self.reshape = ops.Reshape()
|
|
938
936
|
|
|
939
937
|
def construct(self, logits, label):
|
|
940
938
|
_check_is_tensor('logits', logits, self.cls_name)
|
|
@@ -1049,7 +1047,7 @@ class MultiClassDiceLoss(LossBase):
|
|
|
1049
1047
|
if self.activation is not None and not isinstance(self.activation, Cell):
|
|
1050
1048
|
raise TypeError(f"For '{self.cls_name}', the 'activation' must be str or Cell, "
|
|
1051
1049
|
f"but got {type(self.activation)}.")
|
|
1052
|
-
self.reshape =
|
|
1050
|
+
self.reshape = ops.Reshape()
|
|
1053
1051
|
|
|
1054
1052
|
def construct(self, logits, label):
|
|
1055
1053
|
_check_is_tensor('logits', logits, self.cls_name)
|
|
@@ -1161,31 +1159,31 @@ class SampledSoftmaxLoss(LossBase):
|
|
|
1161
1159
|
self.sampled_values = sampled_values
|
|
1162
1160
|
self.remove_accidental_hits = remove_accidental_hits
|
|
1163
1161
|
self.seed = seed
|
|
1164
|
-
self.sampler =
|
|
1162
|
+
self.sampler = ops.UniformCandidateSampler(
|
|
1165
1163
|
num_true,
|
|
1166
1164
|
num_sampled,
|
|
1167
1165
|
True,
|
|
1168
1166
|
num_classes,
|
|
1169
1167
|
seed,
|
|
1170
1168
|
remove_accidental_hits)
|
|
1171
|
-
self.cast =
|
|
1172
|
-
self.reshape =
|
|
1173
|
-
self.shape =
|
|
1174
|
-
self.exp =
|
|
1175
|
-
self.log =
|
|
1176
|
-
self.slice_op =
|
|
1177
|
-
self.matmul =
|
|
1178
|
-
self.gather_v2 =
|
|
1179
|
-
self.reduce_max_true =
|
|
1180
|
-
self.reduce_sum =
|
|
1181
|
-
self.reduce_sum_true =
|
|
1182
|
-
self.concat_dim0 =
|
|
1183
|
-
self.concat_dim1 =
|
|
1184
|
-
self.ones_like =
|
|
1185
|
-
self.zeros_like =
|
|
1186
|
-
self.mul =
|
|
1187
|
-
self.expand_dims =
|
|
1188
|
-
self.dtype =
|
|
1169
|
+
self.cast = ops.Cast()
|
|
1170
|
+
self.reshape = ops.Reshape()
|
|
1171
|
+
self.shape = ops.Shape()
|
|
1172
|
+
self.exp = ops.Exp()
|
|
1173
|
+
self.log = ops.Log()
|
|
1174
|
+
self.slice_op = ops.Slice()
|
|
1175
|
+
self.matmul = ops.MatMul(False, True)
|
|
1176
|
+
self.gather_v2 = ops.Gather()
|
|
1177
|
+
self.reduce_max_true = ops.ReduceMax(True)
|
|
1178
|
+
self.reduce_sum = ops.ReduceSum()
|
|
1179
|
+
self.reduce_sum_true = ops.ReduceSum(True)
|
|
1180
|
+
self.concat_dim0 = ops.Concat(0)
|
|
1181
|
+
self.concat_dim1 = ops.Concat(1)
|
|
1182
|
+
self.ones_like = ops.OnesLike()
|
|
1183
|
+
self.zeros_like = ops.ZerosLike()
|
|
1184
|
+
self.mul = ops.Mul()
|
|
1185
|
+
self.expand_dims = ops.ExpandDims()
|
|
1186
|
+
self.dtype = ops.DType()
|
|
1189
1187
|
|
|
1190
1188
|
def construct(self, weights, biases, labels, logits):
|
|
1191
1189
|
_check_is_tensor('weights', weights, self.cls_name)
|
|
@@ -1393,7 +1391,7 @@ class TripletMarginWithDistanceLoss(LossBase):
|
|
|
1393
1391
|
"'ndim' of the input must be positive, "
|
|
1394
1392
|
f"but got {d.ndim}"
|
|
1395
1393
|
)
|
|
1396
|
-
return
|
|
1394
|
+
return ops.LpNorm(axis=1, p=2)(d)
|
|
1397
1395
|
|
|
1398
1396
|
self.distance_function = pairwise_distance
|
|
1399
1397
|
else:
|
|
@@ -1401,8 +1399,8 @@ class TripletMarginWithDistanceLoss(LossBase):
|
|
|
1401
1399
|
self.swap = swap
|
|
1402
1400
|
self.reduction = reduction
|
|
1403
1401
|
self.margin = margin
|
|
1404
|
-
self.minimum =
|
|
1405
|
-
self.maximum =
|
|
1402
|
+
self.minimum = ops.Minimum()
|
|
1403
|
+
self.maximum = ops.Maximum()
|
|
1406
1404
|
|
|
1407
1405
|
def construct(self, x, positive, negative):
|
|
1408
1406
|
_check_is_tensor("x", x, self.cls_name)
|
|
@@ -1486,8 +1484,8 @@ class PoissonNLLLoss(LossBase):
|
|
|
1486
1484
|
self.log_input = log_input
|
|
1487
1485
|
self.full = full
|
|
1488
1486
|
self.eps = eps
|
|
1489
|
-
self.maximum =
|
|
1490
|
-
self.cast =
|
|
1487
|
+
self.maximum = ops.Maximum()
|
|
1488
|
+
self.cast = ops.Cast()
|
|
1491
1489
|
|
|
1492
1490
|
def construct(self, input, target):
|
|
1493
1491
|
_check_is_tensor('input', input, self.cls_name)
|
|
@@ -1500,7 +1498,7 @@ class PoissonNLLLoss(LossBase):
|
|
|
1500
1498
|
if self.full:
|
|
1501
1499
|
target = self.maximum(target, self.eps)
|
|
1502
1500
|
stirling_term = (target > 1) * ((target + 0.5) * target.log() - target + get_half_ln_2_pi())
|
|
1503
|
-
loss +=
|
|
1501
|
+
loss += ops.masked_fill(stirling_term, target <= 1, ops.cast(0, stirling_term.dtype))
|
|
1504
1502
|
out = self.get_loss(loss)
|
|
1505
1503
|
return out
|
|
1506
1504
|
|
|
@@ -1570,7 +1568,7 @@ class MultiLabelSoftMarginLoss(LossBase):
|
|
|
1570
1568
|
self.reduction = reduction
|
|
1571
1569
|
|
|
1572
1570
|
def construct(self, x, target):
|
|
1573
|
-
return
|
|
1571
|
+
return ops.multilabel_soft_margin_loss(x, target, self.weight, self.reduction)
|
|
1574
1572
|
|
|
1575
1573
|
|
|
1576
1574
|
class MultiMarginLoss(LossBase):
|
|
@@ -1655,7 +1653,7 @@ class MultiMarginLoss(LossBase):
|
|
|
1655
1653
|
if not weight_one:
|
|
1656
1654
|
_check_is_tensor('weight', weight, self.cls_name)
|
|
1657
1655
|
else:
|
|
1658
|
-
weight =
|
|
1656
|
+
weight = ops.fill(x.dtype, x.astype('float32')[0].shape, 1)
|
|
1659
1657
|
loss = self.multi_margin_loss(x, target, weight)
|
|
1660
1658
|
return loss
|
|
1661
1659
|
|
|
@@ -1734,7 +1732,7 @@ class BCELoss(LossBase):
|
|
|
1734
1732
|
self.weight = weight
|
|
1735
1733
|
|
|
1736
1734
|
def construct(self, logits, labels):
|
|
1737
|
-
return
|
|
1735
|
+
return ops.binary_cross_entropy(logits, labels, self.weight, self.reduction)
|
|
1738
1736
|
|
|
1739
1737
|
|
|
1740
1738
|
class CosineEmbeddingLoss(LossBase):
|
|
@@ -1793,8 +1791,8 @@ class CosineEmbeddingLoss(LossBase):
|
|
|
1793
1791
|
def __init__(self, margin=0.0, reduction="mean"):
|
|
1794
1792
|
"""Initialize CosineEmbeddingLoss."""
|
|
1795
1793
|
super(CosineEmbeddingLoss, self).__init__(reduction)
|
|
1796
|
-
self.reduce_sum =
|
|
1797
|
-
self.maximum =
|
|
1794
|
+
self.reduce_sum = ops.ReduceSum()
|
|
1795
|
+
self.maximum = ops.Maximum()
|
|
1798
1796
|
validator.check_value_type("margin", margin, [float], self.cls_name)
|
|
1799
1797
|
self.margin = validator.check_float_range(margin, -1.0, 1.0, validator.INC_BOTH, "margin", self.cls_name)
|
|
1800
1798
|
|
|
@@ -1806,16 +1804,16 @@ class CosineEmbeddingLoss(LossBase):
|
|
|
1806
1804
|
# if labels > 0, 1-cosine(logits_x1, logits_x2)
|
|
1807
1805
|
# else, max(0, cosine(logits_x1, logits_x2)-margin)
|
|
1808
1806
|
prod_sum = self.reduce_sum(logits_x1 * logits_x2, (1,))
|
|
1809
|
-
square1 = self.reduce_sum(
|
|
1810
|
-
square2 = self.reduce_sum(
|
|
1811
|
-
denom =
|
|
1807
|
+
square1 = self.reduce_sum(ops.square(logits_x1), (1,))
|
|
1808
|
+
square2 = self.reduce_sum(ops.square(logits_x2), (1,))
|
|
1809
|
+
denom = ops.sqrt(square1) * ops.sqrt(square2)
|
|
1812
1810
|
cosine = prod_sum / denom
|
|
1813
1811
|
|
|
1814
1812
|
pos_value = 1.0 - cosine
|
|
1815
1813
|
neg_value = self.maximum(cosine - self.margin, 0.0)
|
|
1816
|
-
zeros =
|
|
1817
|
-
pos_part =
|
|
1818
|
-
neg_part =
|
|
1814
|
+
zeros = ops.zeros_like(cosine)
|
|
1815
|
+
pos_part = ops.select(labels == 1, pos_value, zeros)
|
|
1816
|
+
neg_part = ops.select(labels == -1, neg_value, zeros)
|
|
1819
1817
|
output_unreduced = pos_part + neg_part
|
|
1820
1818
|
|
|
1821
1819
|
return self.get_loss(output_unreduced)
|
|
@@ -2089,12 +2087,12 @@ class FocalLoss(LossBase):
|
|
|
2089
2087
|
if isinstance(weight, Tensor) and weight.ndim != 1:
|
|
2090
2088
|
raise ValueError(f"For '{self.cls_name}', the dimension of 'weight' must be 1, but got {weight.ndim}.")
|
|
2091
2089
|
self.weight = weight
|
|
2092
|
-
self.expand_dims =
|
|
2093
|
-
self.gather_d =
|
|
2094
|
-
self.squeeze =
|
|
2095
|
-
self.tile =
|
|
2096
|
-
self.cast =
|
|
2097
|
-
self.dtype =
|
|
2090
|
+
self.expand_dims = ops.ExpandDims()
|
|
2091
|
+
self.gather_d = ops.GatherD()
|
|
2092
|
+
self.squeeze = ops.Squeeze(axis=1)
|
|
2093
|
+
self.tile = ops.Tile()
|
|
2094
|
+
self.cast = ops.Cast()
|
|
2095
|
+
self.dtype = ops.DType()
|
|
2098
2096
|
self.logsoftmax = nn.LogSoftmax(1)
|
|
2099
2097
|
|
|
2100
2098
|
def construct(self, logits, labels):
|
|
@@ -2118,7 +2116,7 @@ class FocalLoss(LossBase):
|
|
|
2118
2116
|
log_probability = self.gather_d(log_probability, 1, self.cast(labelss, mindspore.int32))
|
|
2119
2117
|
log_probability = self.squeeze(log_probability)
|
|
2120
2118
|
|
|
2121
|
-
probability =
|
|
2119
|
+
probability = ops.exp(log_probability)
|
|
2122
2120
|
|
|
2123
2121
|
if self.weight is not None:
|
|
2124
2122
|
convert_weight = self.weight[None, :, None]
|
|
@@ -2128,7 +2126,7 @@ class FocalLoss(LossBase):
|
|
|
2128
2126
|
convert_weight = self.squeeze(convert_weight)
|
|
2129
2127
|
log_probability = log_probability * convert_weight
|
|
2130
2128
|
|
|
2131
|
-
weight =
|
|
2129
|
+
weight = ops.pows(-1 * probability + 1.0, self.gamma)
|
|
2132
2130
|
if labels.shape[1] == 1:
|
|
2133
2131
|
loss = (-1 * weight * log_probability).mean(axis=1)
|
|
2134
2132
|
else:
|
|
@@ -2225,7 +2223,7 @@ class HuberLoss(LossBase):
|
|
|
2225
2223
|
self.delta = delta
|
|
2226
2224
|
|
|
2227
2225
|
def construct(self, logits, labels):
|
|
2228
|
-
return
|
|
2226
|
+
return ops.huber_loss(logits, labels, self.reduction, self.delta)
|
|
2229
2227
|
|
|
2230
2228
|
|
|
2231
2229
|
class TripletMarginLoss(LossBase):
|
|
@@ -2323,8 +2321,8 @@ class TripletMarginLoss(LossBase):
|
|
|
2323
2321
|
def construct(self, x, positive, negative, margin=1.):
|
|
2324
2322
|
if self.margin != 1.0:
|
|
2325
2323
|
margin = self.margin
|
|
2326
|
-
return
|
|
2327
|
-
|
|
2324
|
+
return ops.triplet_margin_loss(x, positive, negative, margin=margin, p=self.p,
|
|
2325
|
+
eps=self.eps, swap=self.swap, reduction=self.reduction)
|
|
2328
2326
|
|
|
2329
2327
|
|
|
2330
2328
|
class NLLLoss(LossBase):
|
|
@@ -2352,9 +2350,9 @@ class NLLLoss(LossBase):
|
|
|
2352
2350
|
\end{array}\right.
|
|
2353
2351
|
|
|
2354
2352
|
Args:
|
|
2355
|
-
weight (Tensor): The rescaling weight to each class. If the value is not None,
|
|
2356
|
-
The data type only supports float32 or float16. Default: ``None`` .
|
|
2357
|
-
ignore_index (int): Specifies a target value that is ignored (typically for padding value)
|
|
2353
|
+
weight (Tensor, optional): The rescaling weight to each class. If the value is not None,
|
|
2354
|
+
the shape is :math:`(C,)`. The data type only supports float32 or float16. Default: ``None`` .
|
|
2355
|
+
ignore_index (int, optional): Specifies a target value that is ignored (typically for padding value)
|
|
2358
2356
|
and does not contribute to the gradient. Default: ``-100`` .
|
|
2359
2357
|
reduction (str, optional): Apply specific reduction method to the output: ``'none'`` , ``'mean'`` ,
|
|
2360
2358
|
``'sum'`` . Default: ``'mean'`` .
|
|
@@ -2406,7 +2404,7 @@ class NLLLoss(LossBase):
|
|
|
2406
2404
|
self.reduction = reduction
|
|
2407
2405
|
|
|
2408
2406
|
def construct(self, logits, labels):
|
|
2409
|
-
return
|
|
2407
|
+
return ops.nll_loss(logits, labels, self.weight, self.ignore_index, self.reduction)
|
|
2410
2408
|
|
|
2411
2409
|
|
|
2412
2410
|
@constexpr
|
|
@@ -2568,7 +2566,7 @@ class CrossEntropyLoss(LossBase):
|
|
|
2568
2566
|
logits.dtype, labels.dtype,
|
|
2569
2567
|
self.cls_name)
|
|
2570
2568
|
|
|
2571
|
-
return
|
|
2569
|
+
return ops.cross_entropy(logits, labels, self.weight, self.ignore_index, self.reduction, self.label_smoothing)
|
|
2572
2570
|
|
|
2573
2571
|
|
|
2574
2572
|
class KLDivLoss(LossBase):
|
|
@@ -2644,7 +2642,7 @@ class KLDivLoss(LossBase):
|
|
|
2644
2642
|
def construct(self, logits, labels):
|
|
2645
2643
|
_check_is_tensor('logits', logits, self.cls_name)
|
|
2646
2644
|
_check_is_tensor('labels', labels, self.cls_name)
|
|
2647
|
-
return
|
|
2645
|
+
return ops.kl_div(logits, labels, self.reduction)
|
|
2648
2646
|
|
|
2649
2647
|
|
|
2650
2648
|
@_primexpr
|
|
@@ -2753,11 +2751,11 @@ class CTCLoss(LossBase):
|
|
|
2753
2751
|
if targets.ndim == 1:
|
|
2754
2752
|
targets = targets.expand_dims(0)
|
|
2755
2753
|
log_probs = log_probs.expand_dims(-2)
|
|
2756
|
-
neg_log_hood, _ =
|
|
2757
|
-
|
|
2754
|
+
neg_log_hood, _ = ops.ctc_loss(log_probs, targets, input_lengths, target_lengths, self.blank,
|
|
2755
|
+
self.reduction, self.zero_infinity)
|
|
2758
2756
|
return neg_log_hood.squeeze(axis=0)
|
|
2759
|
-
neg_log_hood, _ =
|
|
2760
|
-
|
|
2757
|
+
neg_log_hood, _ = ops.ctc_loss(log_probs, targets, input_lengths, target_lengths, self.blank, self.reduction,
|
|
2758
|
+
self.zero_infinity)
|
|
2761
2759
|
return neg_log_hood
|
|
2762
2760
|
|
|
2763
2761
|
|
mindspore/nn/optim/adam.py
CHANGED
|
@@ -909,9 +909,7 @@ class AdamWeightDecay(Optimizer):
|
|
|
909
909
|
Note:
|
|
910
910
|
There is usually no connection between a optimizer and mixed precision. But when `FixedLossScaleManager` is used
|
|
911
911
|
and `drop_overflow_update` in `FixedLossScaleManager` is set to False, optimizer needs to set the 'loss_scale'.
|
|
912
|
-
As this optimizer has no argument of `loss_scale`, so `loss_scale` needs to be processed by other means
|
|
913
|
-
document `LossScale <https://www.mindspore.cn/tutorials/en/master/beginner/mixed_precision.html>`_ to
|
|
914
|
-
process `loss_scale` correctly.
|
|
912
|
+
As this optimizer has no argument of `loss_scale`, so `loss_scale` needs to be processed by other means.
|
|
915
913
|
|
|
916
914
|
If parameters are not grouped, the `weight_decay` in optimizer will be applied on the network parameters without
|
|
917
915
|
'beta' or 'gamma' in their names. Users can group parameters to change the strategy of decaying weight. When
|
|
@@ -1014,7 +1012,7 @@ class AdamWeightDecay(Optimizer):
|
|
|
1014
1012
|
>>>
|
|
1015
1013
|
>>> loss = nn.SoftmaxCrossEntropyWithLogits()
|
|
1016
1014
|
>>> model = ms.Model(net, loss_fn=loss, optimizer=optim)
|
|
1017
|
-
|
|
1015
|
+
"""
|
|
1018
1016
|
_support_parallel_optimizer = True
|
|
1019
1017
|
|
|
1020
1018
|
def __init__(self, params, learning_rate=1e-3, beta1=0.9, beta2=0.999, eps=1e-6, weight_decay=0.0):
|
mindspore/nn/optim/adasum.py
CHANGED
|
@@ -202,7 +202,7 @@ class _AdaSum(Cell):
|
|
|
202
202
|
@staticmethod
|
|
203
203
|
def _hash(step, target, weights_index):
|
|
204
204
|
target = "tag" + str(step) + str(target) + str(weights_index)
|
|
205
|
-
target_hash = hashlib.
|
|
205
|
+
target_hash = hashlib.sha256(target.encode()).hexdigest()
|
|
206
206
|
hash_res = int(int(target_hash, 16) % MAX_NUM_HASH)
|
|
207
207
|
return hash_res
|
|
208
208
|
|
|
@@ -430,7 +430,7 @@ class AdaSumByGradWrapCell(Cell):
|
|
|
430
430
|
requires only one input.
|
|
431
431
|
|
|
432
432
|
Inputs:
|
|
433
|
-
- **grads** (
|
|
433
|
+
- **grads** (tuple[Tensor]) - Tuple of gradients, same with the input of passed optimizer.
|
|
434
434
|
|
|
435
435
|
Raises:
|
|
436
436
|
RuntimeError: If `parallel_mode` uses `stand_alone` mode, AdaSum only supports use in distributed scenarios.
|
mindspore/nn/optim/lamb.py
CHANGED
|
@@ -131,9 +131,7 @@ class Lamb(Optimizer):
|
|
|
131
131
|
Note:
|
|
132
132
|
There is usually no connection between a optimizer and mixed precision. But when `FixedLossScaleManager` is used
|
|
133
133
|
and `drop_overflow_update` in `FixedLossScaleManager` is set to False, optimizer needs to set the 'loss_scale'.
|
|
134
|
-
As this optimizer has no argument of `loss_scale`, so `loss_scale` needs to be processed by other means.
|
|
135
|
-
document `LossScale <https://www.mindspore.cn/tutorials/en/master/beginner/mixed_precision.html>`_ to
|
|
136
|
-
process `loss_scale` correctly.
|
|
134
|
+
As this optimizer has no argument of `loss_scale`, so `loss_scale` needs to be processed by other means.
|
|
137
135
|
|
|
138
136
|
If parameters are not grouped, the `weight_decay` in optimizer will be applied on the network parameters without
|
|
139
137
|
'beta' or 'gamma' in their names. Users can group parameters to change the strategy of decaying weight. When
|
mindspore/nn/optim/optimizer.py
CHANGED
|
@@ -514,7 +514,7 @@ class Optimizer(Cell):
|
|
|
514
514
|
raise ValueError("For 'Optimizer', the property 'target' cannot be set to 'Ascend' "
|
|
515
515
|
"in the 'GPU' environment.")
|
|
516
516
|
|
|
517
|
-
self._is_device =
|
|
517
|
+
self._is_device = value != 'CPU'
|
|
518
518
|
self._target = value
|
|
519
519
|
|
|
520
520
|
def _grad_sparse_indices_deduplicate(self, gradients):
|
|
@@ -69,10 +69,9 @@ class OptTFTWrapper(Optimizer):
|
|
|
69
69
|
tft_env = os.getenv("MS_ENABLE_TFT", "")
|
|
70
70
|
if ("TTP:1" not in tft_env) and ("UCE:1" not in tft_env) and ("ARF:1" not in tft_env):
|
|
71
71
|
raise ValueError("MindIO TFT regitster need custom switch on[MS_ENABLE_TFT='{TTP:1,UCE:1,ARF:1}']!")
|
|
72
|
-
mode = context.get_context("mode")
|
|
73
72
|
device_target = context.get_context("device_target")
|
|
74
|
-
if device_target != "Ascend"
|
|
75
|
-
raise ValueError("MindIO adataper only support on Ascend device
|
|
73
|
+
if device_target != "Ascend":
|
|
74
|
+
raise ValueError("MindIO adataper only support on Ascend device!")
|
|
76
75
|
self.opt = opt
|
|
77
76
|
self.report = TensorReport()
|
|
78
77
|
self.report_end = TensorReport()
|
mindspore/nn/optim/thor.py
CHANGED
|
@@ -445,7 +445,7 @@ class ThorGpu(Optimizer):
|
|
|
445
445
|
def _define_gpu_reducer(self, split_indices):
|
|
446
446
|
"""define gpu reducer"""
|
|
447
447
|
self.parallel_mode = context.get_auto_parallel_context("parallel_mode")
|
|
448
|
-
self.is_distributed =
|
|
448
|
+
self.is_distributed = self.parallel_mode != ParallelMode.STAND_ALONE
|
|
449
449
|
if self.is_distributed:
|
|
450
450
|
mean = _get_gradients_mean()
|
|
451
451
|
degree = _get_device_num()
|
|
@@ -764,7 +764,7 @@ class ThorAscend(Optimizer):
|
|
|
764
764
|
def _define_ascend_reducer(self, split_indices):
|
|
765
765
|
"""define ascend reducer"""
|
|
766
766
|
self.parallel_mode = context.get_auto_parallel_context("parallel_mode")
|
|
767
|
-
self.is_distributed =
|
|
767
|
+
self.is_distributed = self.parallel_mode != ParallelMode.STAND_ALONE
|
|
768
768
|
if self.is_distributed:
|
|
769
769
|
mean = _get_gradients_mean()
|
|
770
770
|
degree = _get_device_num()
|
|
@@ -298,7 +298,7 @@ class CheckTuple(PrimitiveWithInfer):
|
|
|
298
298
|
# The op is not used in a cell
|
|
299
299
|
if isinstance(x, tuple):
|
|
300
300
|
return x
|
|
301
|
-
if context.get_context("mode") ==
|
|
301
|
+
if context.get_context("mode") == context.GRAPH_MODE:
|
|
302
302
|
return x["value"]
|
|
303
303
|
raise TypeError(f"For {name}, input type must be a tuple.")
|
|
304
304
|
|
|
@@ -349,7 +349,7 @@ def set_param_type(args, hint_type):
|
|
|
349
349
|
for name, arg in args.items():
|
|
350
350
|
if hasattr(arg, 'dtype'):
|
|
351
351
|
if isinstance(arg, np.ndarray):
|
|
352
|
-
cur_dtype = mstype.
|
|
352
|
+
cur_dtype = mstype._pytype_to_dtype(arg.dtype) # pylint:disable=protected-access
|
|
353
353
|
else:
|
|
354
354
|
cur_dtype = arg.dtype
|
|
355
355
|
if common_dtype is None:
|
|
@@ -35,7 +35,8 @@ class Exponential(Distribution):
|
|
|
35
35
|
where :math:`\lambda` is the rate of the distribution.
|
|
36
36
|
|
|
37
37
|
Args:
|
|
38
|
-
rate (int, float, list, numpy.ndarray, Tensor, optional): The inverse scale.
|
|
38
|
+
rate (int, float, list, numpy.ndarray, Tensor, optional): The inverse scale.
|
|
39
|
+
:math:`\lambda` in the formula. Default: ``None`` .
|
|
39
40
|
seed (int, optional): The seed used in sampling. The global seed is used if it is None. Default: ``None`` .
|
|
40
41
|
dtype (mindspore.dtype, optional): The type of the event samples. Default: ``mstype.float32`` .
|
|
41
42
|
name (str, optional): The name of the distribution. Default: ``'Exponential'`` .
|
|
@@ -36,7 +36,8 @@ class Poisson(Distribution):
|
|
|
36
36
|
where :math:`\lambda` is the rate of the distribution.
|
|
37
37
|
|
|
38
38
|
Args:
|
|
39
|
-
rate (list, numpy.ndarray, Tensor): The rate of the Poisson distribution.
|
|
39
|
+
rate (list, numpy.ndarray, Tensor): The rate of the Poisson distribution.
|
|
40
|
+
:math:`\lambda` in the formula. Default: ``None`` .
|
|
40
41
|
seed (int): The seed used in sampling. The global seed is used if it is ``None`` . Default: ``None`` .
|
|
41
42
|
dtype (mindspore.dtype): The type of the event samples. Default: ``mstype.float32`` .
|
|
42
43
|
name (str): The name of the distribution. Default: ``'Poisson'`` .
|