mindspore 2.6.0__cp311-cp311-win_amd64.whl → 2.7.0rc1__cp311-cp311-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 +1 -1
- mindspore/_c_dataengine.cp311-win_amd64.pyd +0 -0
- mindspore/_c_expression.cp311-win_amd64.pyd +0 -0
- mindspore/_c_mindrecord.cp311-win_amd64.pyd +0 -0
- mindspore/_checkparam.py +40 -9
- mindspore/{_deprecated → _extends/optimize}/__init__.py +9 -3
- mindspore/_extends/optimize/cell_utils.py +96 -0
- mindspore/_extends/parse/__init__.py +2 -2
- mindspore/_extends/parse/compile_config.py +44 -22
- mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +1 -1
- mindspore/_extends/parse/parser.py +36 -61
- mindspore/_extends/parse/resources.py +39 -0
- mindspore/_extends/parse/standard_method.py +32 -13
- mindspore/_extends/parse/trope.py +8 -1
- mindspore/_extends/pijit/__init__.py +1 -2
- mindspore/amp.py +4 -4
- mindspore/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 +27 -2
- mindspore/common/_grad_function.py +2 -1
- mindspore/common/_pijit_context.py +28 -7
- mindspore/common/_stub_tensor.py +1 -209
- mindspore/common/_tensor_cpp_method.py +1 -1
- mindspore/common/_tensor_docs.py +76 -15
- mindspore/common/api.py +193 -112
- mindspore/common/dtype.py +21 -11
- mindspore/common/dump.py +10 -15
- mindspore/common/generator.py +2 -3
- mindspore/common/hook_handle.py +11 -2
- mindspore/common/jit_config.py +1 -1
- mindspore/common/jit_trace.py +84 -105
- mindspore/common/parameter.py +26 -12
- mindspore/common/recompute.py +3 -3
- mindspore/common/sparse_tensor.py +0 -3
- mindspore/common/symbol.py +0 -1
- mindspore/common/tensor.py +48 -83
- mindspore/communication/_comm_helper.py +46 -4
- mindspore/communication/management.py +79 -7
- mindspore/context.py +38 -23
- mindspore/dataset/core/config.py +3 -3
- mindspore/dataset/engine/datasets.py +20 -7
- mindspore/dataset/engine/datasets_user_defined.py +32 -2
- mindspore/dataset/engine/iterators.py +2 -2
- mindspore/dataset/engine/obs/config_loader.py +2 -2
- mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +8 -0
- mindspore/dataset/transforms/py_transforms.py +7 -3
- mindspore/dataset/transforms/transforms.py +7 -3
- mindspore/dataset/vision/validators.py +1 -0
- mindspore/device_context/ascend/device.py +1 -1
- mindspore/device_context/gpu/__init__.py +2 -2
- mindspore/device_context/gpu/device.py +1 -1
- mindspore/device_context/gpu/op_precision.py +4 -2
- mindspore/device_context/gpu/op_tuning.py +6 -3
- mindspore/device_manager.py +16 -9
- mindspore/dnnl.dll +0 -0
- mindspore/dpcmi.dll +0 -0
- mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +3 -5
- mindspore/experimental/llm_boost/atb/boost_base.py +2 -3
- mindspore/experimental/optim/adadelta.py +13 -20
- mindspore/experimental/optim/adagrad.py +15 -22
- mindspore/experimental/optim/adam.py +17 -24
- mindspore/experimental/optim/adamax.py +14 -22
- mindspore/experimental/optim/adamw.py +28 -34
- mindspore/experimental/optim/asgd.py +15 -25
- mindspore/experimental/optim/lr_scheduler.py +27 -45
- mindspore/experimental/optim/nadam.py +14 -24
- mindspore/experimental/optim/optimizer.py +13 -23
- mindspore/experimental/optim/radam.py +18 -24
- mindspore/experimental/optim/rmsprop.py +14 -25
- mindspore/experimental/optim/rprop.py +15 -26
- mindspore/experimental/optim/sgd.py +9 -19
- mindspore/hal/__init__.py +4 -4
- mindspore/hal/contiguous_tensors_handle.py +2 -2
- mindspore/hal/memory.py +1 -0
- mindspore/include/api/cell.h +37 -1
- mindspore/include/api/delegate.h +10 -0
- mindspore/include/api/model.h +3 -0
- mindspore/include/api/types.h +2 -2
- mindspore/include/c_api/model_c.h +0 -58
- mindspore/include/c_api/tensor_c.h +0 -26
- mindspore/include/dataset/vision_ascend.h +1 -1
- mindspore/jpeg62.dll +0 -0
- mindspore/mindrecord/tools/cifar10.py +60 -11
- mindspore/mindrecord/tools/cifar10_to_mr.py +5 -0
- mindspore/mindspore_backend_common.dll +0 -0
- mindspore/mindspore_backend_manager.dll +0 -0
- mindspore/mindspore_common.dll +0 -0
- mindspore/mindspore_core.dll +0 -0
- mindspore/mindspore_cpu_res_manager.dll +0 -0
- mindspore/mindspore_dump.dll +0 -0
- mindspore/mindspore_frontend.dll +0 -0
- mindspore/mindspore_glog.dll +0 -0
- mindspore/mindspore_memory_pool.dll +0 -0
- mindspore/mindspore_ms_backend.dll +0 -0
- mindspore/mindspore_ops.dll +0 -0
- mindspore/mindspore_ops_host.dll +0 -0
- mindspore/mindspore_ops_kernel_common.dll +0 -0
- mindspore/mindspore_profiler.dll +0 -0
- mindspore/mindspore_pyboost.dll +0 -0
- mindspore/mindspore_pynative.dll +0 -0
- mindspore/mindspore_res_manager.dll +0 -0
- mindspore/mindspore_runtime_pipeline.dll +0 -0
- mindspore/mint/__init__.py +4 -44
- mindspore/mint/distributed/__init__.py +1 -0
- mindspore/mint/distributed/distributed.py +208 -5
- mindspore/mint/nn/__init__.py +1 -1
- mindspore/mint/nn/functional.py +53 -6
- mindspore/mint/nn/layer/_functions.py +164 -294
- mindspore/mint/nn/layer/activation.py +8 -6
- mindspore/mint/nn/layer/conv.py +122 -98
- mindspore/mint/nn/layer/normalization.py +8 -22
- mindspore/mint/optim/adam.py +19 -18
- mindspore/mint/optim/adamw.py +14 -8
- mindspore/mint/optim/sgd.py +5 -5
- mindspore/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 +325 -499
- mindspore/nn/grad/cell_grad.py +11 -12
- mindspore/nn/layer/activation.py +32 -34
- mindspore/nn/layer/basic.py +67 -64
- mindspore/nn/layer/channel_shuffle.py +4 -4
- mindspore/nn/layer/combined.py +4 -2
- mindspore/nn/layer/conv.py +86 -85
- mindspore/nn/layer/dense.py +9 -7
- mindspore/nn/layer/embedding.py +50 -52
- mindspore/nn/layer/image.py +37 -39
- mindspore/nn/layer/math.py +111 -112
- mindspore/nn/layer/normalization.py +56 -44
- mindspore/nn/layer/pooling.py +58 -63
- mindspore/nn/layer/rnn_cells.py +33 -33
- mindspore/nn/layer/rnns.py +56 -56
- mindspore/nn/layer/thor_layer.py +74 -73
- mindspore/nn/layer/transformer.py +11 -1
- mindspore/nn/learning_rate_schedule.py +20 -20
- mindspore/nn/loss/loss.py +79 -81
- mindspore/nn/optim/adam.py +1 -1
- mindspore/nn/optim/adasum.py +2 -2
- mindspore/nn/optim/optimizer.py +1 -1
- mindspore/nn/optim/thor.py +2 -2
- mindspore/nn/probability/distribution/exponential.py +2 -1
- mindspore/nn/probability/distribution/poisson.py +2 -1
- mindspore/nn/sparse/sparse.py +3 -3
- mindspore/nn/wrap/cell_wrapper.py +34 -37
- mindspore/nn/wrap/grad_reducer.py +37 -37
- mindspore/nn/wrap/loss_scale.py +72 -74
- mindspore/numpy/array_creations.py +5 -5
- mindspore/numpy/fft.py +1 -1
- mindspore/numpy/math_ops.py +1 -1
- mindspore/opencv_core452.dll +0 -0
- mindspore/opencv_imgcodecs452.dll +0 -0
- mindspore/opencv_imgproc452.dll +0 -0
- mindspore/ops/_grad_experimental/grad_comm_ops.py +51 -13
- mindspore/ops/_grad_experimental/grad_debug_ops.py +14 -0
- mindspore/ops/_vmap/vmap_array_ops.py +6 -13
- mindspore/ops/_vmap/vmap_nn_ops.py +8 -16
- mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +17 -8
- mindspore/ops/auto_generate/gen_extend_func.py +1 -51
- mindspore/ops/auto_generate/gen_ops_def.py +463 -257
- mindspore/ops/auto_generate/gen_ops_prim.py +1127 -885
- mindspore/ops/auto_generate/pyboost_inner_prim.py +31 -1
- mindspore/ops/composite/__init__.py +10 -0
- mindspore/ops/composite/base.py +8 -4
- mindspore/ops/composite/multitype_ops/__init__.py +12 -1
- mindspore/ops/composite/multitype_ops/_compile_utils.py +132 -108
- mindspore/ops/composite/multitype_ops/add_impl.py +70 -2
- mindspore/ops/composite/multitype_ops/div_impl.py +49 -0
- mindspore/ops/composite/multitype_ops/floordiv_impl.py +29 -0
- mindspore/ops/composite/multitype_ops/getitem_impl.py +11 -0
- mindspore/ops/composite/multitype_ops/mod_impl.py +5 -3
- mindspore/ops/composite/multitype_ops/mul_impl.py +49 -0
- mindspore/ops/composite/multitype_ops/setitem_impl.py +57 -0
- mindspore/ops/composite/multitype_ops/sub_impl.py +34 -0
- mindspore/ops/composite/multitype_ops/zeros_like_impl.py +14 -0
- mindspore/ops/function/__init__.py +3 -1
- mindspore/ops/function/_add_attr_func.py +11 -6
- mindspore/ops/function/array_func.py +7 -94
- mindspore/ops/function/debug_func.py +4 -3
- mindspore/ops/function/grad/grad_func.py +1 -1
- mindspore/ops/function/math_func.py +21 -367
- mindspore/ops/function/nn_func.py +26 -41
- mindspore/ops/function/other_func.py +4 -1
- mindspore/ops/function/random_func.py +31 -4
- mindspore/ops/functional.py +0 -2
- mindspore/ops/functional_overload.py +463 -6
- mindspore/ops/op_info_register.py +21 -0
- mindspore/ops/operations/__init__.py +5 -2
- mindspore/ops/operations/_custom_ops_utils.py +675 -8
- mindspore/ops/operations/_inner_ops.py +3 -6
- mindspore/ops/operations/_sequence_ops.py +1 -1
- mindspore/ops/operations/comm_ops.py +185 -26
- mindspore/ops/operations/custom_ops.py +235 -172
- mindspore/ops/operations/debug_ops.py +55 -4
- mindspore/ops/operations/image_ops.py +13 -13
- mindspore/ops/operations/manually_defined/ops_def.py +15 -16
- mindspore/ops/operations/math_ops.py +3 -4
- mindspore/ops/operations/nn_ops.py +5 -6
- mindspore/ops/primitive.py +6 -10
- mindspore/ops/tensor_method.py +36 -4
- mindspore/ops_generate/api/cpp_create_prim_instance_helper_generator.py +1 -1
- mindspore/ops_generate/api/functional_map_cpp_generator.py +10 -9
- mindspore/ops_generate/api/functions_cc_generator.py +58 -10
- mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +1 -1
- mindspore/ops_generate/common/base_generator.py +14 -0
- mindspore/ops_generate/common/gen_constants.py +7 -2
- mindspore/ops_generate/common/gen_utils.py +0 -19
- mindspore/ops_generate/common/op_proto.py +11 -4
- mindspore/ops_generate/common/template.py +88 -11
- mindspore/ops_generate/gen_ops.py +1 -1
- mindspore/ops_generate/op_def/lite_ops_cpp_generator.py +4 -4
- mindspore/ops_generate/op_def/ops_name_h_generator.py +0 -3
- mindspore/ops_generate/op_def/ops_primitive_h_generator.py +0 -4
- mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -2
- mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +49 -8
- mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +2 -2
- mindspore/ops_generate/pyboost/gen_pyboost_func.py +31 -0
- mindspore/ops_generate/pyboost/op_template_parser.py +98 -72
- mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +70 -273
- mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +14 -6
- mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +316 -0
- mindspore/ops_generate/pyboost/pyboost_functions_py_generator.py +1 -1
- mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +5 -3
- mindspore/ops_generate/pyboost/pyboost_inner_prim_generator.py +1 -1
- mindspore/ops_generate/pyboost/pyboost_internal_functions_cpp_generator.py +76 -0
- mindspore/ops_generate/pyboost/pyboost_internal_functions_h_generator.py +76 -0
- mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +125 -0
- mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +4 -3
- mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +348 -61
- mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +1 -1
- mindspore/ops_generate/pyboost/pyboost_utils.py +118 -9
- mindspore/ops_generate/tensor_py_cc_generator.py +1 -24
- mindspore/parallel/_auto_parallel_context.py +4 -2
- mindspore/parallel/_cell_wrapper.py +106 -40
- mindspore/parallel/_parallel_serialization.py +1 -1
- mindspore/parallel/_ps_context.py +4 -6
- mindspore/parallel/_tensor.py +167 -12
- mindspore/parallel/_transformer/moe.py +1 -1
- mindspore/parallel/_transformer/transformer.py +13 -8
- mindspore/parallel/auto_parallel.py +12 -5
- mindspore/parallel/checkpoint_convert.py +3 -3
- mindspore/parallel/checkpoint_transform.py +3 -1
- mindspore/parallel/cluster/process_entity/_api.py +84 -48
- mindspore/parallel/cluster/process_entity/_utils.py +95 -7
- mindspore/parallel/cluster/run.py +43 -4
- mindspore/parallel/function/__init__.py +8 -1
- mindspore/parallel/function/reshard_func.py +1 -1
- mindspore/parallel/nn/__init__.py +15 -2
- mindspore/parallel/nn/parallel_cell_wrapper.py +9 -10
- mindspore/parallel/nn/parallel_grad_reducer.py +7 -6
- mindspore/parallel/shard.py +2 -2
- mindspore/parallel/transform_safetensors.py +462 -174
- mindspore/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_op_memory_viewer.py +42 -22
- mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +3 -2
- mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +9 -5
- mindspore/profiler/analysis/viewer/ms_operator_details_viewer.py +132 -0
- mindspore/profiler/common/constant.py +16 -0
- mindspore/profiler/common/profiler_context.py +25 -27
- mindspore/profiler/common/profiler_info.py +0 -16
- mindspore/profiler/common/profiler_op_analyse.py +235 -0
- mindspore/profiler/common/profiler_output_path.py +23 -8
- mindspore/profiler/common/profiler_parameters.py +128 -35
- mindspore/profiler/dynamic_profile/__init__.py +0 -0
- mindspore/profiler/dynamic_profile/dynamic_monitor_proxy.py +39 -0
- mindspore/profiler/dynamic_profile/dynamic_profiler_config_context.py +666 -0
- mindspore/profiler/dynamic_profile/dynamic_profiler_utils.py +62 -0
- mindspore/profiler/dynamic_profiler.py +305 -314
- mindspore/profiler/envprofiler.py +12 -7
- mindspore/profiler/experimental_config.py +96 -6
- mindspore/profiler/mstx.py +33 -12
- mindspore/profiler/platform/__init__.py +2 -3
- mindspore/profiler/platform/npu_profiler.py +29 -19
- mindspore/profiler/profiler.py +35 -19
- mindspore/profiler/profiler_action_controller.py +64 -76
- mindspore/profiler/schedule.py +10 -4
- mindspore/rewrite/common/config.py +1 -0
- mindspore/rewrite/common/namer.py +1 -0
- mindspore/rewrite/common/namespace.py +1 -0
- mindspore/rewrite/node/node.py +31 -11
- mindspore/rewrite/parsers/assign_parser.py +1 -1
- mindspore/rewrite/symbol_tree/symbol_tree.py +1 -1
- mindspore/run_check/_check_version.py +7 -10
- mindspore/runtime/__init__.py +5 -5
- mindspore/runtime/event.py +10 -4
- mindspore/runtime/executor.py +60 -45
- mindspore/runtime/memory.py +21 -30
- mindspore/runtime/thread_bind_core.py +298 -164
- mindspore/safeguard/rewrite_obfuscation.py +12 -13
- mindspore/swresample-4.dll +0 -0
- mindspore/swscale-6.dll +0 -0
- mindspore/tbbmalloc.dll +0 -0
- mindspore/tinyxml2.dll +0 -0
- mindspore/train/_utils.py +6 -2
- mindspore/train/amp.py +43 -20
- mindspore/train/callback/__init__.py +5 -5
- mindspore/train/callback/_checkpoint.py +3 -6
- mindspore/train/callback/_flops_collector.py +1 -1
- mindspore/train/callback/_landscape.py +0 -1
- mindspore/train/callback/_train_fault_tolerance.py +71 -13
- mindspore/train/data_sink.py +11 -2
- mindspore/train/dataset_helper.py +9 -0
- mindspore/train/model.py +51 -33
- mindspore/train/serialization.py +133 -111
- mindspore/train/summary/summary_record.py +13 -2
- mindspore/turbojpeg.dll +0 -0
- mindspore/utils/__init__.py +3 -2
- mindspore/utils/dryrun.py +0 -6
- mindspore/utils/runtime_execution_order_check.py +162 -78
- mindspore/utils/sdc_detect.py +68 -0
- mindspore/utils/utils.py +6 -9
- mindspore/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.0rc1.dist-info}/METADATA +5 -4
- {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/RECORD +352 -390
- mindspore/_deprecated/jit.py +0 -198
- mindspore/experimental/es/__init__.py +0 -22
- mindspore/experimental/es/embedding_service.py +0 -891
- mindspore/experimental/es/embedding_service_layer.py +0 -581
- mindspore/profiler/parser/__init__.py +0 -14
- mindspore/profiler/parser/aicpu_data_parser.py +0 -272
- mindspore/profiler/parser/ascend_analysis/__init__.py +0 -14
- mindspore/profiler/parser/ascend_analysis/constant.py +0 -71
- mindspore/profiler/parser/ascend_analysis/file_manager.py +0 -180
- mindspore/profiler/parser/ascend_analysis/function_event.py +0 -185
- mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +0 -136
- mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +0 -131
- mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +0 -104
- mindspore/profiler/parser/ascend_analysis/path_manager.py +0 -313
- mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +0 -123
- mindspore/profiler/parser/ascend_analysis/tlv_decoder.py +0 -86
- mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +0 -75
- mindspore/profiler/parser/ascend_cluster_generator.py +0 -116
- mindspore/profiler/parser/ascend_communicate_generator.py +0 -314
- mindspore/profiler/parser/ascend_flops_generator.py +0 -116
- mindspore/profiler/parser/ascend_fpbp_generator.py +0 -82
- mindspore/profiler/parser/ascend_hccl_generator.py +0 -271
- mindspore/profiler/parser/ascend_integrate_generator.py +0 -42
- mindspore/profiler/parser/ascend_memory_generator.py +0 -185
- mindspore/profiler/parser/ascend_msprof_exporter.py +0 -282
- mindspore/profiler/parser/ascend_msprof_generator.py +0 -187
- mindspore/profiler/parser/ascend_op_generator.py +0 -334
- mindspore/profiler/parser/ascend_steptrace_generator.py +0 -94
- mindspore/profiler/parser/ascend_timeline_generator.py +0 -545
- mindspore/profiler/parser/base_timeline_generator.py +0 -483
- mindspore/profiler/parser/container.py +0 -229
- mindspore/profiler/parser/cpu_gpu_timeline_generator.py +0 -697
- mindspore/profiler/parser/flops_parser.py +0 -531
- mindspore/profiler/parser/framework_enum.py +0 -111
- mindspore/profiler/parser/framework_parser.py +0 -464
- mindspore/profiler/parser/framework_struct.py +0 -61
- mindspore/profiler/parser/gpu_analysis/__init__.py +0 -14
- mindspore/profiler/parser/gpu_analysis/function_event.py +0 -44
- mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +0 -89
- mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +0 -72
- mindspore/profiler/parser/hccl_parser.py +0 -573
- mindspore/profiler/parser/hwts_log_parser.py +0 -122
- mindspore/profiler/parser/integrator.py +0 -526
- mindspore/profiler/parser/memory_usage_parser.py +0 -277
- mindspore/profiler/parser/minddata_analyzer.py +0 -800
- mindspore/profiler/parser/minddata_parser.py +0 -186
- mindspore/profiler/parser/minddata_pipeline_parser.py +0 -299
- mindspore/profiler/parser/op_intermediate_parser.py +0 -149
- mindspore/profiler/parser/optime_parser.py +0 -250
- mindspore/profiler/parser/profiler_info.py +0 -213
- mindspore/profiler/parser/step_trace_parser.py +0 -666
- {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/WHEEL +0 -0
- {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/entry_points.txt +0 -0
- {mindspore-2.6.0.dist-info → mindspore-2.7.0rc1.dist-info}/top_level.txt +0 -0
mindspore/mint/nn/layer/conv.py
CHANGED
|
@@ -25,7 +25,7 @@ import mindspore.common.dtype as mstype
|
|
|
25
25
|
from mindspore.common.parameter import Parameter
|
|
26
26
|
from mindspore.common.initializer import initializer, HeUniform, Uniform, _calculate_fan_in_and_fan_out
|
|
27
27
|
from mindspore import _checkparam as Validator
|
|
28
|
-
from mindspore._checkparam import
|
|
28
|
+
from mindspore._checkparam import once_sequence, twice_sequence, triple_sequence
|
|
29
29
|
from mindspore._extends import cell_attr_register
|
|
30
30
|
from mindspore.nn.cell import Cell
|
|
31
31
|
from mindspore.ops.functional import isconstant
|
|
@@ -52,12 +52,11 @@ class _Conv(Cell):
|
|
|
52
52
|
dtype=mstype.float32):
|
|
53
53
|
"""Initialize _Conv."""
|
|
54
54
|
super(_Conv, self).__init__()
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
self.
|
|
55
|
+
self.groups = Validator.check_positive_int(groups)
|
|
56
|
+
self.in_channels = Validator.check_non_negative_int(in_channels)
|
|
57
|
+
self.out_channels = Validator.check_non_negative_int(out_channels)
|
|
58
58
|
if self.in_channels % groups != 0:
|
|
59
59
|
raise ValueError('in_channels must be divisible by groups.')
|
|
60
|
-
self.out_channels = out_channels
|
|
61
60
|
if self.out_channels % groups != 0:
|
|
62
61
|
raise ValueError('out_channels must be divisible by groups.')
|
|
63
62
|
valid_padding_strings = {'same', 'valid'}
|
|
@@ -75,7 +74,6 @@ class _Conv(Cell):
|
|
|
75
74
|
raise ValueError(f"The value of 'padding_mode' must be one of '{valid_padding_modes}', "
|
|
76
75
|
f"but got {padding_mode}.")
|
|
77
76
|
self.transposed = transposed
|
|
78
|
-
self.groups = Validator.check_positive_int(groups)
|
|
79
77
|
self.output_padding = output_padding
|
|
80
78
|
self.padding_mode = padding_mode
|
|
81
79
|
self.kernel_size = kernel_size
|
|
@@ -148,12 +146,12 @@ class Conv1d(_Conv):
|
|
|
148
146
|
.. math::
|
|
149
147
|
|
|
150
148
|
\text{out}(N_i, C_{\text{out}_j}) = \text{bias}(C_{\text{out}_j}) +
|
|
151
|
-
\sum_{k = 0}^{C_{in} - 1} \text{ccor}({\text{weight}(C_{\text{out}_j}, k), \text{
|
|
149
|
+
\sum_{k = 0}^{C_{in} - 1} \text{ccor}({\text{weight}(C_{\text{out}_j}, k), \text{input}(N_i, k)})
|
|
152
150
|
|
|
153
151
|
|
|
154
152
|
where :math:`bias` is the output channel bias, :math:`ccor` is
|
|
155
153
|
the `cross-correlation <https://en.wikipedia.org/wiki/Cross-correlation>`_,
|
|
156
|
-
:math:`weight` is the convolution kernel value and :math:`
|
|
154
|
+
:math:`weight` is the convolution kernel value and :math:`input` represents the input feature map.
|
|
157
155
|
|
|
158
156
|
- :math:`i` corresponds to the batch number, the range is :math:`[0, N-1]`,
|
|
159
157
|
where :math:`N` is the batch size of the input.
|
|
@@ -168,14 +166,14 @@ class Conv1d(_Conv):
|
|
|
168
166
|
|
|
169
167
|
Therefore, in the above formula, :math:`{bias}(C_{\text{out}_j})` represents the bias of the :math:`j`-th
|
|
170
168
|
output channel, :math:`{weight}(C_{\text{out}_j}, k)` represents the slice of the :math:`j`-th convolutional
|
|
171
|
-
kernel in the :math:`k`-th channel, and :math:`{
|
|
169
|
+
kernel in the :math:`k`-th channel, and :math:`{input}(N_i, k)` represents the slice of the :math:`k`-th input
|
|
172
170
|
channel in the :math:`i`-th batch of the input feature map.
|
|
173
171
|
|
|
174
172
|
The shape of the convolutional kernel is given by :math:`(\text{kernel_size})`,
|
|
175
173
|
where :math:`\text{kernel_size}` is the length of the kernel.
|
|
176
174
|
If we consider the input and output channels as well as the `groups` parameter, the complete kernel shape
|
|
177
175
|
will be :math:`(C_{out}, C_{in} / \text{groups}, \text{kernel_size})`,
|
|
178
|
-
where `groups` is the number of groups dividing `
|
|
176
|
+
where `groups` is the number of groups dividing `input`'s input channel when applying groups convolution.
|
|
179
177
|
|
|
180
178
|
For more details about convolution layer, please refer to `Gradient Based Learning Applied to Document Recognition
|
|
181
179
|
<http://vision.stanford.edu/cs598_spring07/papers/Lecun98.pdf>`_.
|
|
@@ -184,12 +182,12 @@ class Conv1d(_Conv):
|
|
|
184
182
|
in_channels (int): The channel number of the input tensor of the Conv1d layer.
|
|
185
183
|
out_channels (int): The channel number of the output tensor of the Conv1d layer.
|
|
186
184
|
kernel_size (Union[int, tuple[int], list[int]]): Specifies the length of the 1D convolution kernel.
|
|
187
|
-
The data type is an integer or a tuple of one integer.
|
|
185
|
+
The data type is an integer or a tuple/list of one integer.
|
|
188
186
|
stride (Union[int, tuple[int], list[int]], optional): The movement stride of the 1D convolution kernel.
|
|
189
|
-
The data type is an integer or a tuple of one integer. Default: ``1`` .
|
|
187
|
+
The data type is an integer or a tuple/list of one integer. Default: ``1`` .
|
|
190
188
|
padding (Union[int, tuple[int], list[int], str], optional): The number of padding
|
|
191
189
|
on the input.
|
|
192
|
-
The data type is an integer or a tuple of one integer or string {``"valid"``, ``"same"``}.
|
|
190
|
+
The data type is an integer or a tuple/list of one integer or string {``"valid"``, ``"same"``}.
|
|
193
191
|
The value should be greater than or equal to 0. Default: ``0`` .
|
|
194
192
|
|
|
195
193
|
- ``"same"``: Pad the input around its edges so that the shape of input and output
|
|
@@ -203,9 +201,10 @@ class Conv1d(_Conv):
|
|
|
203
201
|
be discarded.
|
|
204
202
|
|
|
205
203
|
padding_mode (str, optional): Specifies the padding mode with a padding value of 0. It can be set to:
|
|
206
|
-
``"zeros"`` , ``"reflect"``
|
|
207
|
-
dilation (Union[int, tuple[int], list[int]], optional): Specifies the dilation
|
|
208
|
-
|
|
204
|
+
``"zeros"`` , ``"reflect"`` or ``"replicate"`` . Default: ``"zeros"`` .
|
|
205
|
+
dilation (Union[int, tuple[int], list[int]], optional): Specifies the dilation
|
|
206
|
+
rate to use for dilated convolution.
|
|
207
|
+
It can be a single int or a tuple/list of 1 integer.
|
|
209
208
|
Assuming :math:`dilation=(d)`, the convolutional kernel samples the input with a
|
|
210
209
|
spacing of :math:`d-1` elements in the length direction.
|
|
211
210
|
Default: ``1`` .
|
|
@@ -214,16 +213,22 @@ class Conv1d(_Conv):
|
|
|
214
213
|
this 1D convolution layer also can be called 1D depthwise convolution layer. Default: ``1`` .
|
|
215
214
|
The following restraints must be met:
|
|
216
215
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
216
|
+
- :math:`(C_{in} \text{ % } \text{groups} == 0)`
|
|
217
|
+
- :math:`(C_{out} \text{ % } \text{groups} == 0)`
|
|
218
|
+
- :math:`(C_{out} >= \text{groups})`
|
|
219
|
+
- :math:`(\text{weight[1]} = C_{in} / \text{groups})`
|
|
221
220
|
|
|
222
221
|
bias (bool, optional): Whether the Conv1d layer has a bias parameter. Default: ``True`` .
|
|
223
222
|
dtype (:class:`mindspore.dtype`, optional): Dtype of Parameters. Default: ``None``, using ``mstype.float32``.
|
|
224
223
|
|
|
224
|
+
Variables:
|
|
225
|
+
- **weight** (Tensor) - The weight of the convolution layer, with shape :math:
|
|
226
|
+
`(C_{out}, C_{in} / \text{groups}, \text{kernel_size[0]})`.
|
|
227
|
+
- **bias** (Tensor) - The bias of the convolution layer, with shape :math:
|
|
228
|
+
`(C_{out})`. If bias is False, this will be None.
|
|
229
|
+
|
|
225
230
|
Inputs:
|
|
226
|
-
- **
|
|
231
|
+
- **input** (Tensor) - Tensor of shape :math:`(N, C_{in}, L_{in})` \
|
|
227
232
|
or :math:`(C_{in}, L_{in})`.
|
|
228
233
|
|
|
229
234
|
Outputs:
|
|
@@ -258,7 +263,7 @@ class Conv1d(_Conv):
|
|
|
258
263
|
RuntimeError: On Ascend, due to the limitation of the L1 cache size of different NPU chip, if input size or
|
|
259
264
|
kernel size is too large, it may trigger an error.
|
|
260
265
|
TypeError: If `in_channels`, `out_channels` or `groups` is not an int.
|
|
261
|
-
TypeError: If `kernel_size`, `stride` or `dilation` is neither an int nor a tuple.
|
|
266
|
+
TypeError: If `kernel_size`, `stride` or `dilation` is neither an int nor a tuple/list.
|
|
262
267
|
ValueError: If `in_channels`, `out_channels`, `kernel_size`, `stride` or `dilation` is less than 1.
|
|
263
268
|
ValueError: If `padding` is less than 0.
|
|
264
269
|
ValueError: If `padding` is `same` , `stride` is not equal to 1.
|
|
@@ -292,14 +297,14 @@ class Conv1d(_Conv):
|
|
|
292
297
|
padding_mode='zeros',
|
|
293
298
|
dtype=None):
|
|
294
299
|
"""Initialize Conv1d."""
|
|
295
|
-
kernel_size_ =
|
|
296
|
-
stride_ =
|
|
297
|
-
padding_ = padding if isinstance(padding, str) else
|
|
298
|
-
dilation_ =
|
|
300
|
+
kernel_size_ = once_sequence(kernel_size)
|
|
301
|
+
stride_ = once_sequence(stride)
|
|
302
|
+
padding_ = padding if isinstance(padding, str) else once_sequence(padding)
|
|
303
|
+
dilation_ = once_sequence(dilation)
|
|
299
304
|
if not dtype:
|
|
300
305
|
dtype = mstype.float32
|
|
301
306
|
super(Conv1d, self).__init__(in_channels, out_channels, kernel_size_, stride_, padding_, dilation_, False,
|
|
302
|
-
|
|
307
|
+
once_sequence(0), groups, bias, padding_mode, dtype)
|
|
303
308
|
if isinstance(padding, str) and padding_mode == "zeros":
|
|
304
309
|
self.conv1d = conv1d_padding_op
|
|
305
310
|
else:
|
|
@@ -327,11 +332,11 @@ class Conv2d(_Conv):
|
|
|
327
332
|
.. math::
|
|
328
333
|
|
|
329
334
|
\text{out}(N_i, C_{\text{out}_j}) = \text{bias}(C_{\text{out}_j}) +
|
|
330
|
-
\sum_{k = 0}^{C_{in} - 1} \text{ccor}({\text{weight}(C_{\text{out}_j}, k), \text{
|
|
335
|
+
\sum_{k = 0}^{C_{in} - 1} \text{ccor}({\text{weight}(C_{\text{out}_j}, k), \text{Input}(N_i, k)})
|
|
331
336
|
|
|
332
337
|
where :math:`bias` is the output channel bias, :math:`ccor` is
|
|
333
338
|
the `cross-correlation <https://en.wikipedia.org/wiki/Cross-correlation>`_,
|
|
334
|
-
:math:`weight` is the convolution kernel value and :math:`
|
|
339
|
+
:math:`weight` is the convolution kernel value and :math:`Input` represents the input feature map.
|
|
335
340
|
|
|
336
341
|
- :math:`i` corresponds to the batch number, the range is :math:`[0, N-1]`,
|
|
337
342
|
where :math:`N` is the batch size of the input.
|
|
@@ -346,7 +351,7 @@ class Conv2d(_Conv):
|
|
|
346
351
|
|
|
347
352
|
Therefore, in the above formula, :math:`{bias}(C_{\text{out}_j})` represents the bias of the :math:`j`-th
|
|
348
353
|
output channel, :math:`{weight}(C_{\text{out}_j}, k)` represents the slice of the :math:`j`-th convolutional
|
|
349
|
-
kernel in the :math:`k`-th channel, and :math:`{
|
|
354
|
+
kernel in the :math:`k`-th channel, and :math:`{Input}(N_i, k)` represents the slice of the :math:`k`-th input
|
|
350
355
|
channel in the :math:`i`-th batch of the input feature map.
|
|
351
356
|
|
|
352
357
|
The shape of the convolutional kernel is given by :math:`(\text{kernel_size[0]},\text{kernel_size[1]})`,
|
|
@@ -354,7 +359,7 @@ class Conv2d(_Conv):
|
|
|
354
359
|
and :math:`\text{kernel_size[1]}` are the height and width of the kernel, respectively.
|
|
355
360
|
If we consider the input and output channels as well as the `groups` parameter, the complete kernel shape
|
|
356
361
|
will be :math:`(C_{out}, C_{in} / \text{groups}, \text{kernel_size[0]}, \text{kernel_size[1]})`,
|
|
357
|
-
where `groups` is the number of groups dividing `
|
|
362
|
+
where `groups` is the number of groups dividing `Input`'s input channel when applying groups convolution.
|
|
358
363
|
|
|
359
364
|
For more details about convolution layer, please refer to `Gradient Based Learning Applied to Document Recognition
|
|
360
365
|
<http://vision.stanford.edu/cs598_spring07/papers/Lecun98.pdf>`_.
|
|
@@ -363,18 +368,18 @@ class Conv2d(_Conv):
|
|
|
363
368
|
in_channels (int): The channel number of the input tensor of the Conv2d layer.
|
|
364
369
|
out_channels (int): The channel number of the output tensor of the Conv2d layer.
|
|
365
370
|
kernel_size (Union[int, tuple[int], list[int]]): Specifies the height and width of the 2D convolution kernel.
|
|
366
|
-
The data type is an integer or a tuple of two integers. An integer represents the height
|
|
367
|
-
and width of the convolution kernel. A tuple of two integers represents the height
|
|
371
|
+
The data type is an integer or a tuple/list of two integers. An integer represents the height
|
|
372
|
+
and width of the convolution kernel. A tuple/list of two integers represents the height
|
|
368
373
|
and width of the convolution kernel respectively.
|
|
369
374
|
stride (Union[int, tuple[int], list[int]], optional): The movement stride of the 2D convolution kernel.
|
|
370
|
-
The data type is an integer or a tuple of two integers. An integer represents the movement step size
|
|
371
|
-
in both height and width directions. A tuple of two integers represents the movement step size in the height
|
|
375
|
+
The data type is an integer or a tuple/list of two integers. An integer represents the movement step size
|
|
376
|
+
in both height and width directions. A tuple/list of two integers represents the movement step size in the height
|
|
372
377
|
and width directions respectively. Default: ``1`` .
|
|
373
378
|
padding (Union[int, tuple[int], list[int], str], optional): The number of padding
|
|
374
379
|
on the height and width directions of the input.
|
|
375
|
-
The data type is an integer or a tuple of two integers or string {``"valid"``, ``"same"``}.
|
|
380
|
+
The data type is an integer or a tuple/list of two integers or string {``"valid"``, ``"same"``}.
|
|
376
381
|
If `padding` is an integer, then `padding_{H}` and `padding_{W}` are all equal to `padding`.
|
|
377
|
-
If `padding` is a tuple of 2 integers, then `padding_{H}` and `padding_{W}`
|
|
382
|
+
If `padding` is a tuple/list of 2 integers, then `padding_{H}` and `padding_{W}`
|
|
378
383
|
is equal to `padding[0]` and `padding[1]` respectively.
|
|
379
384
|
The value should be greater than or equal to 0. Default: ``0`` .
|
|
380
385
|
|
|
@@ -389,13 +394,12 @@ class Conv2d(_Conv):
|
|
|
389
394
|
be discarded.
|
|
390
395
|
|
|
391
396
|
padding_mode (str, optional): Specifies the padding mode with a padding value of 0. It can be set to:
|
|
392
|
-
``"zeros"`` , ``"reflect"``
|
|
393
|
-
dilation (Union[int, tuple[int], list[int]], optional): Specifies the dilation rate to use
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
the height and width directions
|
|
397
|
-
|
|
398
|
-
dilation size in the height and width directions respectively.
|
|
397
|
+
``"zeros"`` , ``"reflect"`` or ``"replicate"`` . Default: ``"zeros"`` .
|
|
398
|
+
dilation (Union[int, tuple[int], list[int]], optional): Specifies the dilation rate to use
|
|
399
|
+
for dilated convolution.
|
|
400
|
+
It can be a single int or a tuple/list of 2 integers. A single int means the dilation size is the same
|
|
401
|
+
in both the height and width directions. A tuple/list of two ints represents the dilation size in
|
|
402
|
+
the height and width directions, respectively.
|
|
399
403
|
Assuming :math:`dilation=(d0, d1)`, the convolutional kernel samples the input with a
|
|
400
404
|
spacing of :math:`d0-1` elements in the height direction and :math:`d1-1` elements in the width direction.
|
|
401
405
|
The values in the height and width dimensions are in the ranges [1, H] and [1, W], respectively.
|
|
@@ -408,43 +412,49 @@ class Conv2d(_Conv):
|
|
|
408
412
|
- :math:`(C_{in} \text{ % } \text{groups} == 0)`
|
|
409
413
|
- :math:`(C_{out} \text{ % } \text{groups} == 0)`
|
|
410
414
|
- :math:`(C_{out} >= \text{groups})`
|
|
411
|
-
- :math:`(\text{
|
|
415
|
+
- :math:`(\text{weight[1]} = C_{in} / \text{groups})`
|
|
412
416
|
|
|
413
417
|
bias (bool, optional): Whether the Conv2d layer has a bias parameter. Default: ``True`` .
|
|
414
418
|
dtype (:class:`mindspore.dtype`, optional): Dtype of Parameters. Default: ``None``, using ``mstype.float32``.
|
|
415
419
|
|
|
420
|
+
Variables:
|
|
421
|
+
- **weight** (Tensor) - The weight of the convolution layer, with shape
|
|
422
|
+
:math:`(C_{out}, C_{in} / \text{groups}, \text{kernel_size[0]}, \text{kernel_size[1]})`.
|
|
423
|
+
- **bias** (Tensor) - The bias of the convolution layer, with shape
|
|
424
|
+
:math:`(C_{out})`. If bias is False, this will be None.
|
|
425
|
+
|
|
416
426
|
Inputs:
|
|
417
|
-
- **
|
|
418
|
-
|
|
427
|
+
- **Input** (Tensor) - Tensor of shape :math:`(N, C_{in}, H_{in}, W_{in})` or :math:`(C_{in}, H_{in}, W_{in})`.
|
|
428
|
+
When it's an empty Tesnor, backpropagation is currently not supported.
|
|
419
429
|
|
|
420
430
|
Outputs:
|
|
421
431
|
Tensor of shape :math:`(N, C_{out}, H_{out}, W_{out})` or :math:`(C_{out}, H_{out}, W_{out})`.
|
|
422
|
-
|
|
432
|
+
|
|
423
433
|
padding is ``'same'``:
|
|
424
|
-
|
|
434
|
+
|
|
425
435
|
.. math::
|
|
426
436
|
\begin{array}{ll} \\
|
|
427
|
-
|
|
428
|
-
|
|
437
|
+
H_{out} = \left \lceil{\frac{H_{in}}{\text{stride[0]}}} \right \rceil \\
|
|
438
|
+
W_{out} = \left \lceil{\frac{W_{in}}{\text{stride[1]}}} \right \rceil \\
|
|
429
439
|
\end{array}
|
|
430
|
-
|
|
440
|
+
|
|
431
441
|
padding is ``'valid'``:
|
|
432
|
-
|
|
442
|
+
|
|
433
443
|
.. math::
|
|
434
444
|
\begin{array}{ll} \\
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
445
|
+
H_{out} = \left \lfloor{\frac{H_{in} - \text{dilation[0]} \times (\text{kernel_size[0]} - 1) - 1}
|
|
446
|
+
{\text{stride[0]}}} \right \rfloor + 1 \\
|
|
447
|
+
W_{out} = \left \lfloor{\frac{W_{in} - \text{dilation[1]} \times (\text{kernel_size[1]} - 1) - 1}
|
|
448
|
+
{\text{stride[1]}}} \right \rfloor + 1 \\
|
|
439
449
|
\end{array}
|
|
440
|
-
|
|
450
|
+
|
|
441
451
|
padding is int or tuple/list:
|
|
442
|
-
|
|
452
|
+
|
|
443
453
|
.. math::
|
|
444
454
|
\begin{array}{ll} \\
|
|
445
|
-
H_{out} = \left \lfloor{\frac{H_{in} +
|
|
455
|
+
H_{out} = \left \lfloor{\frac{H_{in} + 2 \times padding[0] - \text{dilation[0]} \times
|
|
446
456
|
(\text{kernel_size[0]} - 1) - 1}{\text{stride[0]}}} \right \rfloor + 1 \\
|
|
447
|
-
W_{out} = \left \lfloor{\frac{W_{in} +
|
|
457
|
+
W_{out} = \left \lfloor{\frac{W_{in} + 2 \times padding[1] - \text{dilation[1]} \times
|
|
448
458
|
(\text{kernel_size[1]} - 1) - 1}{\text{stride[1]}}} \right \rfloor + 1 \\
|
|
449
459
|
\end{array}
|
|
450
460
|
|
|
@@ -454,7 +464,7 @@ class Conv2d(_Conv):
|
|
|
454
464
|
RuntimeError: On Ascend, due to the limitation of the L1 cache size of different NPU chip, if input size or
|
|
455
465
|
kernel size is too large, it may trigger an error.
|
|
456
466
|
TypeError: If `in_channels`, `out_channels` or `groups` is not an int.
|
|
457
|
-
TypeError: If `kernel_size`, `stride` or `dilation` is neither an int nor a tuple.
|
|
467
|
+
TypeError: If `kernel_size`, `stride` or `dilation` is neither an int nor a tuple/list.
|
|
458
468
|
ValueError: If `in_channels`, `out_channels`, `kernel_size`, `stride` or `dilation` is less than 1.
|
|
459
469
|
ValueError: If `padding` is less than 0.
|
|
460
470
|
ValueError: If `padding` is `same` , `stride` is not equal to 1.
|
|
@@ -488,14 +498,14 @@ class Conv2d(_Conv):
|
|
|
488
498
|
padding_mode='zeros',
|
|
489
499
|
dtype=None):
|
|
490
500
|
"""Initialize Conv2d."""
|
|
491
|
-
kernel_size_ =
|
|
492
|
-
stride_ =
|
|
493
|
-
padding_ = padding if isinstance(padding, str) else
|
|
494
|
-
dilation_ =
|
|
501
|
+
kernel_size_ = twice_sequence(kernel_size)
|
|
502
|
+
stride_ = twice_sequence(stride)
|
|
503
|
+
padding_ = padding if isinstance(padding, str) else twice_sequence(padding)
|
|
504
|
+
dilation_ = twice_sequence(dilation)
|
|
495
505
|
if not dtype:
|
|
496
506
|
dtype = mstype.float32
|
|
497
507
|
super(Conv2d, self).__init__(in_channels, out_channels, kernel_size_, stride_, padding_, dilation_, False,
|
|
498
|
-
|
|
508
|
+
twice_sequence(0), groups, bias, padding_mode, dtype)
|
|
499
509
|
if isinstance(padding, str) and padding_mode == "zeros":
|
|
500
510
|
self.conv2d = conv2d_padding_op
|
|
501
511
|
else:
|
|
@@ -524,11 +534,11 @@ class Conv3d(_Conv):
|
|
|
524
534
|
.. math::
|
|
525
535
|
|
|
526
536
|
\text{out}(N_i, C_{\text{out}_j}) = \text{bias}(C_{\text{out}_j}) +
|
|
527
|
-
\sum_{k = 0}^{C_{in} - 1} \text{ccor}({\text{weight}(C_{\text{out}_j}, k), \text{
|
|
537
|
+
\sum_{k = 0}^{C_{in} - 1} \text{ccor}({\text{weight}(C_{\text{out}_j}, k), \text{input}(N_i, k)})
|
|
528
538
|
|
|
529
539
|
where :math:`bias` is the output channel bias, :math:`ccor` is
|
|
530
540
|
the `cross-correlation <https://en.wikipedia.org/wiki/Cross-correlation>`_,
|
|
531
|
-
:math:`weight` is the convolution kernel value and :math:`
|
|
541
|
+
:math:`weight` is the convolution kernel value and :math:`input` represents the input feature map.
|
|
532
542
|
|
|
533
543
|
Here are the indices' meanings:
|
|
534
544
|
|
|
@@ -545,7 +555,7 @@ class Conv3d(_Conv):
|
|
|
545
555
|
|
|
546
556
|
Therefore, in the above formula, :math:`{bias}(C_{\text{out}_j})` represents the bias of the :math:`j`-th
|
|
547
557
|
output channel, :math:`{weight}(C_{\text{out}_j}, k)` represents the slice of the :math:`j`-th convolutional
|
|
548
|
-
kernel in the :math:`k`-th channel, and :math:`{
|
|
558
|
+
kernel in the :math:`k`-th channel, and :math:`{input}(N_i, k)` represents the slice of the :math:`k`-th input
|
|
549
559
|
channel in the :math:`i`-th batch of the input feature map.
|
|
550
560
|
|
|
551
561
|
The shape of the convolutional kernel is given by
|
|
@@ -555,7 +565,7 @@ class Conv3d(_Conv):
|
|
|
555
565
|
If we consider the input and output channels as well as the `groups` parameter, the complete kernel shape
|
|
556
566
|
will be
|
|
557
567
|
:math:`(C_{out}, C_{in} / \text{groups}, \text{kernel_size[0]}, \text{kernel_size[1]}, \text{kernel_size[2]})`,
|
|
558
|
-
where `groups` is the number of groups dividing `
|
|
568
|
+
where `groups` is the number of groups dividing `input`'s input channel when applying groups convolution.
|
|
559
569
|
|
|
560
570
|
For more details about convolution layer, please refer to `Gradient Based Learning Applied to Document Recognition
|
|
561
571
|
<http://vision.stanford.edu/cs598_spring07/papers/Lecun98.pdf>`_.
|
|
@@ -563,45 +573,59 @@ class Conv3d(_Conv):
|
|
|
563
573
|
For the detail of limitations of the parameters, please refer to :func:`mindspore.mint.nn.functional.conv3d`.
|
|
564
574
|
|
|
565
575
|
.. warning::
|
|
566
|
-
|
|
576
|
+
It is only supported on Atlas A2 Training Series Products.
|
|
567
577
|
|
|
568
578
|
Args:
|
|
569
579
|
in_channels (int): The channel number of the input tensor of the Conv3d layer.
|
|
570
580
|
out_channels (int): The channel number of the output tensor of the Conv3d layer.
|
|
571
|
-
kernel_size (Union[int, tuple[int], list[int]]): Specifies the height and width of the 3D convolution
|
|
572
|
-
The data type is an integer or a tuple of
|
|
573
|
-
and width of the convolution kernel. A tuple of
|
|
581
|
+
kernel_size (Union[int, tuple[int], list[int]]): Specifies the depth, height and width of the 3D convolution
|
|
582
|
+
kernel. The data type is an integer or a tuple/list of three integers. An integer represents the depth,
|
|
583
|
+
height and width of the convolution kernel. A tuple/list of three integers represents the depth, height
|
|
574
584
|
and width of the convolution kernel respectively.
|
|
575
585
|
stride (Union[int, tuple[int], list[int]], optional): The movement stride of the 3D convolution kernel.
|
|
576
|
-
The data type is an integer or a tuple of three integers. An integer represents the movement step size
|
|
577
|
-
in both height and width directions. A tuple of three integers represents the movement step size in the
|
|
586
|
+
The data type is an integer or a tuple/list of three integers. An integer represents the movement step size
|
|
587
|
+
in both height and width directions. A tuple/list of three integers represents the movement step size in the
|
|
578
588
|
depth, height and width directions respectively. Default: ``1`` .
|
|
579
589
|
padding (Union[int, tuple[int], list[int], str], optional): The number of padding
|
|
580
590
|
on the depth, height and width directions of the input.
|
|
581
|
-
The data type is an integer or string {``"valid"``, ``"same"``} or a tuple of three integers.
|
|
591
|
+
The data type is an integer or string {``"valid"``, ``"same"``} or a tuple/list of three integers.
|
|
582
592
|
The value should be greater than or equal to 0. Default: ``0`` .
|
|
583
593
|
|
|
584
594
|
- ``"same"``: Pad the input around its edges so that the shape of input and output
|
|
585
595
|
are the same when `stride` is set to ``1``.
|
|
586
596
|
The amount of padding to is calculated by the operator internally, If the amount is even, it is
|
|
587
597
|
uniformly distributed around the input, if it is odd, the excess amount goes to the right/bottom side.
|
|
588
|
-
If this mode is set, `padding` must be 0.
|
|
589
598
|
|
|
590
599
|
- ``"valid"``: No padding is applied to the input, and the output returns the maximum
|
|
591
600
|
possible height and width. Extra pixels that could not complete a full stride will
|
|
592
|
-
be discarded.
|
|
601
|
+
be discarded.
|
|
593
602
|
|
|
594
603
|
padding_mode (str, optional): Specifies the padding mode with a padding value of 0. It can be set to:
|
|
595
|
-
``"zeros"`` , ``"reflect"``
|
|
604
|
+
``"zeros"`` , ``"reflect"`` or ``"replicate"`` . Default: ``"zeros"`` .
|
|
596
605
|
dilation (Union[int, tuple[int], list[int]], optional): Controlling the space between the kernel points.
|
|
597
606
|
Default: ``1`` .
|
|
598
607
|
groups (int, optional): Splits filter into groups, `in_channels` and `out_channels` must be
|
|
599
|
-
divisible by `groups`. If the groups is equal to `in_channels` and `out_channels
|
|
608
|
+
divisible by `groups`. If the groups is equal to `in_channels` and `out_channels`,
|
|
609
|
+
this 3D convolution layer also can be called 3D depthwise convolution layer. Default: ``1`` .
|
|
610
|
+
The following restraints must be met:
|
|
611
|
+
|
|
612
|
+
- :math:`(C_{in} \text{ % } \text{groups} == 0)`
|
|
613
|
+
- :math:`(C_{out} \text{ % } \text{groups} == 0)`
|
|
614
|
+
- :math:`(C_{out} >= \text{groups})`
|
|
615
|
+
- :math:`(\text{weight[1]} = C_{in} / \text{groups})`
|
|
616
|
+
|
|
600
617
|
bias (bool, optional): Whether the Conv3d layer has a bias parameter. Default: ``True`` .
|
|
601
618
|
dtype (:class:`mindspore.dtype`, optional): Dtype of Parameters. Default: ``None``, using ``mstype.float32``.
|
|
602
619
|
|
|
620
|
+
Variables:
|
|
621
|
+
- **weight** (Tensor) - The weight of the convolution layer, with shape
|
|
622
|
+
:math:`(C_{out}, C_{in} / \text{groups}, \text{kernel_size[0]},
|
|
623
|
+
\text{kernel_size[1]}, \text{kernel_size[2]})`.
|
|
624
|
+
- **bias** (Tensor) - The bias of the convolution layer, with shape
|
|
625
|
+
:math:`(C_{out})`. If bias is False, this will be None.
|
|
626
|
+
|
|
603
627
|
Inputs:
|
|
604
|
-
- **
|
|
628
|
+
- **input** (Tensor) - Tensor of shape :math:`(N, C_{in}, D_{in}, H_{in}, W_{in})` \
|
|
605
629
|
or :math:`(C_{in}, D_{in}, H_{in}, W_{in})`.
|
|
606
630
|
|
|
607
631
|
Outputs:
|
|
@@ -621,29 +645,29 @@ class Conv3d(_Conv):
|
|
|
621
645
|
|
|
622
646
|
.. math::
|
|
623
647
|
\begin{array}{ll} \\
|
|
624
|
-
D_{out} = \left \
|
|
625
|
-
{\text{stride[0]}}} \right \
|
|
626
|
-
H_{out} = \left \
|
|
627
|
-
{\text{stride[1]}}} \right \
|
|
628
|
-
W_{out} = \left \
|
|
629
|
-
{\text{stride[2]}}} \right \
|
|
648
|
+
D_{out} = \left \lfloor{\frac{D_{in} - \text{dilation[0]} \times (\text{kernel_size[0]} - 1) - 1}
|
|
649
|
+
{\text{stride[0]}}} \right \rfloor + 1 \\
|
|
650
|
+
H_{out} = \left \lfloor{\frac{H_{in} - \text{dilation[1]} \times (\text{kernel_size[1]} - 1) - 1}
|
|
651
|
+
{\text{stride[1]}}} \right \rfloor + 1 \\
|
|
652
|
+
W_{out} = \left \lfloor{\frac{W_{in} - \text{dilation[2]} \times (\text{kernel_size[2]} - 1) - 1}
|
|
653
|
+
{\text{stride[2]}}} \right \rfloor + 1 \\
|
|
630
654
|
\end{array}
|
|
631
655
|
|
|
632
656
|
padding is int or tuple/list:
|
|
633
657
|
|
|
634
658
|
.. math::
|
|
635
659
|
\begin{array}{ll} \\
|
|
636
|
-
D_{out} = \left \lfloor{\frac{D_{in} +
|
|
660
|
+
D_{out} = \left \lfloor{\frac{D_{in} + 2 \times padding[0] - \text{dilation[0]} \times
|
|
637
661
|
(\text{kernel_size[0]} - 1) - 1}{\text{stride[0]}} + 1} \right \rfloor \\
|
|
638
|
-
H_{out} = \left \lfloor{\frac{H_{in} +
|
|
662
|
+
H_{out} = \left \lfloor{\frac{H_{in} + 2 \times padding[1] - \text{dilation[1]} \times
|
|
639
663
|
(\text{kernel_size[1]} - 1) - 1}{\text{stride[1]}} + 1} \right \rfloor \\
|
|
640
|
-
W_{out} = \left \lfloor{\frac{W_{in} +
|
|
664
|
+
W_{out} = \left \lfloor{\frac{W_{in} + 2 \times padding[2] - \text{dilation[2]} \times
|
|
641
665
|
(\text{kernel_size[2]} - 1) - 1}{\text{stride[2]}} + 1} \right \rfloor \\
|
|
642
666
|
\end{array}
|
|
643
667
|
|
|
644
668
|
Raises:
|
|
645
669
|
TypeError: If `in_channels`, `out_channels` or `groups` is not an int.
|
|
646
|
-
TypeError: If `kernel_size`, `stride
|
|
670
|
+
TypeError: If `kernel_size`, `stride` or `dilation` is neither an int nor a tuple/list.
|
|
647
671
|
ValueError: If `in_channels`, `out_channels`, `kernel_size`, `stride` or `dilation` is less than 1.
|
|
648
672
|
ValueError: If `padding` is less than 0.
|
|
649
673
|
|
|
@@ -673,14 +697,14 @@ class Conv3d(_Conv):
|
|
|
673
697
|
padding_mode='zeros',
|
|
674
698
|
dtype=None):
|
|
675
699
|
"""Initialize Conv3d."""
|
|
676
|
-
kernel_size_ =
|
|
677
|
-
stride_ =
|
|
678
|
-
padding_ = padding if isinstance(padding, str) else
|
|
679
|
-
dilation_ =
|
|
700
|
+
kernel_size_ = triple_sequence(kernel_size)
|
|
701
|
+
stride_ = triple_sequence(stride)
|
|
702
|
+
padding_ = padding if isinstance(padding, str) else triple_sequence(padding)
|
|
703
|
+
dilation_ = triple_sequence(dilation)
|
|
680
704
|
if not dtype:
|
|
681
705
|
dtype = mstype.float32
|
|
682
706
|
super(Conv3d, self).__init__(in_channels, out_channels, kernel_size_, stride_, padding_, dilation_, False,
|
|
683
|
-
|
|
707
|
+
triple_sequence(0), groups, bias, padding_mode, dtype)
|
|
684
708
|
if isinstance(padding, str) and padding_mode == "zeros":
|
|
685
709
|
self.conv3d = conv3d_padding_op
|
|
686
710
|
else:
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Adapted from:
|
|
2
|
+
# https://github.com/pytorch/pytorch/blob/release/2.1/torch/nn/modules/batchnorm.py
|
|
2
3
|
#
|
|
3
|
-
#
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
# ============================================================================
|
|
4
|
+
# Additional modifications made by Huawei Technologies Co., Ltd in 2024.
|
|
15
5
|
"""normalization for mint"""
|
|
16
6
|
from __future__ import absolute_import
|
|
17
7
|
from __future__ import division
|
|
@@ -600,21 +590,17 @@ class SyncBatchNorm(_BatchNorm):
|
|
|
600
590
|
else: # use exponential moving average
|
|
601
591
|
exponential_average_factor = self.momentum
|
|
602
592
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
Mini-batch stats are used in training mode, and in eval mode when buffers are None.
|
|
606
|
-
"""
|
|
593
|
+
# Decide whether the mini-batch stats should be used for normalization rather than the buffers.
|
|
594
|
+
# Mini-batch stats are used in training mode, and in eval mode when buffers are None.
|
|
607
595
|
if self.training:
|
|
608
596
|
bn_training = True
|
|
609
597
|
else:
|
|
610
598
|
bn_training = (self.running_mean is None) and (
|
|
611
599
|
self.running_var is None)
|
|
612
600
|
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
used for normalization (i.e. in eval mode when buffers are not None).
|
|
617
|
-
"""
|
|
601
|
+
# Buffers are only updated if they are to be tracked and we are in training mode. Thus they only need to be
|
|
602
|
+
# passed when the update should occur (i.e. in training mode when they are tracked), or when buffer stats are
|
|
603
|
+
# used for normalization (i.e. in eval mode when buffers are not None).
|
|
618
604
|
# If buffers are not to be tracked, ensure that they won't be updated
|
|
619
605
|
running_mean = (
|
|
620
606
|
self.running_mean if not self.training or self.track_running_stats else None
|
mindspore/mint/optim/adam.py
CHANGED
|
@@ -15,17 +15,18 @@
|
|
|
15
15
|
"""Adam"""
|
|
16
16
|
from __future__ import absolute_import
|
|
17
17
|
|
|
18
|
-
from mindspore.ops import functional as F, composite as C, operations as P
|
|
19
18
|
from mindspore.common.parameter import Parameter
|
|
20
19
|
from mindspore.common.tensor import Tensor
|
|
21
20
|
from mindspore.common import dtype as mstype
|
|
22
21
|
from mindspore.experimental.optim.optimizer import Optimizer
|
|
23
22
|
from mindspore import _checkparam as validator
|
|
24
23
|
from mindspore import mint
|
|
24
|
+
from mindspore import ops
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
|
|
27
|
+
_optim_adamw_opt = ops.MultitypeFuncGraph("optim_adamw_opt")
|
|
28
|
+
hyper_map = ops.HyperMap()
|
|
29
|
+
assign_add = ops.AssignAdd()
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
@_optim_adamw_opt.register("Float", "Float", "Float", "Tensor", "Tensor", "Tensor", "Tensor",
|
|
@@ -38,12 +39,12 @@ def _run_optim_adamw_amsgrad_opt(beta1, beta2, eps, neg_step_size, sqrt_bias_cor
|
|
|
38
39
|
exp_avg_sq_tmp = mint.mul(exp_avg_sq, beta2) + mint.mul(mint.mul(grads, grads), 1 - beta2)
|
|
39
40
|
|
|
40
41
|
max_exp_avg_sq = mint.maximum(max_exp_avg_sq, exp_avg_sq_tmp)
|
|
41
|
-
denom =
|
|
42
|
+
denom = ops.cast(mint.div(mint.sqrt(max_exp_avg_sq), sqrt_bias_correction2), max_exp_avg_sq.dtype)
|
|
42
43
|
denom = mint.add(denom, eps)
|
|
43
44
|
|
|
44
|
-
delta_param = mint.mul(
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
delta_param = mint.mul(ops.cast(neg_step_size, max_exp_avg_sq.dtype), mint.div(exp_avg_tmp, denom))
|
|
46
|
+
ops.assign(exp_avg, exp_avg_tmp)
|
|
47
|
+
ops.assign(exp_avg_sq, exp_avg_sq_tmp)
|
|
47
48
|
assign_add(parameters, delta_param)
|
|
48
49
|
return success
|
|
49
50
|
|
|
@@ -56,12 +57,12 @@ def _run_optim_adamw_opt(beta1, beta2, eps, neg_step_size, sqrt_bias_correction2
|
|
|
56
57
|
exp_avg_tmp = mint.add(mint.mul(exp_avg, beta1), grads, alpha=1 - beta1)
|
|
57
58
|
exp_avg_sq_tmp = mint.mul(exp_avg_sq, beta2) + mint.mul(mint.mul(grads, grads), 1 - beta2)
|
|
58
59
|
|
|
59
|
-
denom =
|
|
60
|
+
denom = ops.cast(mint.div(mint.sqrt(exp_avg_sq_tmp), sqrt_bias_correction2), exp_avg_sq_tmp.dtype)
|
|
60
61
|
denom = mint.add(denom, eps)
|
|
61
62
|
|
|
62
|
-
delta_param = mint.mul(
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
delta_param = mint.mul(ops.cast(neg_step_size, exp_avg_sq_tmp.dtype), mint.div(exp_avg_tmp, denom))
|
|
64
|
+
ops.assign(exp_avg, exp_avg_tmp)
|
|
65
|
+
ops.assign(exp_avg_sq, exp_avg_sq_tmp)
|
|
65
66
|
assign_add(parameters, delta_param)
|
|
66
67
|
return success
|
|
67
68
|
|
|
@@ -190,8 +191,8 @@ class Adam(Optimizer):
|
|
|
190
191
|
self.exp_avg_sq = self.parameters.clone(prefix="exp_avg_sq", init='zeros')
|
|
191
192
|
self.state_step = Parameter(Tensor([0], mstype.float32), "state_step")
|
|
192
193
|
self.increase_tensor = Tensor(1, mstype.float32)
|
|
193
|
-
self.assignadd =
|
|
194
|
-
self.pow =
|
|
194
|
+
self.assignadd = ops.AssignAdd()
|
|
195
|
+
self.pow = ops.Pow()
|
|
195
196
|
|
|
196
197
|
|
|
197
198
|
def construct(self, gradients):
|
|
@@ -211,13 +212,13 @@ class Adam(Optimizer):
|
|
|
211
212
|
grads = self._decay_weight(group.get("weight_decay"), self.parameters[start_id: end_id], grads)
|
|
212
213
|
|
|
213
214
|
if group.get("amsgrad"):
|
|
214
|
-
self.hyper_map(
|
|
215
|
-
|
|
215
|
+
self.hyper_map(ops.partial(_optim_adamw_opt, beta1, beta2, group.get("eps"), neg_step_size,
|
|
216
|
+
sqrt_bias_correction2),
|
|
216
217
|
self.parameters[start_id: end_id], grads, self.exp_avg[start_id: end_id],
|
|
217
218
|
self.exp_avg_sq[start_id: end_id], group.get("max_exp_avg_sq"))
|
|
218
219
|
else:
|
|
219
|
-
self.hyper_map(
|
|
220
|
-
|
|
220
|
+
self.hyper_map(ops.partial(_optim_adamw_opt, beta1, beta2, group.get("eps"), neg_step_size,
|
|
221
|
+
sqrt_bias_correction2),
|
|
221
222
|
self.parameters[start_id: end_id], grads, self.exp_avg[start_id: end_id],
|
|
222
223
|
self.exp_avg_sq[start_id: end_id])
|
|
223
224
|
return True
|