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.

Files changed (455) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
  3. mindspore/Newtonsoft.Json.dll +0 -0
  4. mindspore/__init__.py +2 -2
  5. mindspore/_c_dataengine.cp310-win_amd64.pyd +0 -0
  6. mindspore/_c_expression.cp310-win_amd64.pyd +0 -0
  7. mindspore/_c_mindrecord.cp310-win_amd64.pyd +0 -0
  8. mindspore/_checkparam.py +42 -11
  9. mindspore/_extends/builtin_operations.py +3 -3
  10. mindspore/{_deprecated → _extends/optimize}/__init__.py +9 -3
  11. mindspore/_extends/optimize/cell_utils.py +96 -0
  12. mindspore/_extends/parallel_compile/akg_compiler/custom.py +1109 -0
  13. mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
  14. mindspore/_extends/parse/__init__.py +3 -3
  15. mindspore/_extends/parse/compile_config.py +44 -22
  16. mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +1 -2
  17. mindspore/_extends/parse/parser.py +64 -83
  18. mindspore/_extends/parse/resources.py +39 -0
  19. mindspore/_extends/parse/standard_method.py +47 -14
  20. mindspore/_extends/parse/trope.py +8 -1
  21. mindspore/_extends/pijit/__init__.py +1 -2
  22. mindspore/_extends/pijit/pijit_func_white_list.py +2 -5
  23. mindspore/amp.py +4 -22
  24. mindspore/atlprov.dll +0 -0
  25. mindspore/avcodec-59.dll +0 -0
  26. mindspore/avdevice-59.dll +0 -0
  27. mindspore/avfilter-8.dll +0 -0
  28. mindspore/avformat-59.dll +0 -0
  29. mindspore/avutil-57.dll +0 -0
  30. mindspore/boost/adasum.py +1 -1
  31. mindspore/boost/boost_cell_wrapper.py +4 -4
  32. mindspore/c1.dll +0 -0
  33. mindspore/c1xx.dll +0 -0
  34. mindspore/c2.dll +0 -0
  35. mindspore/common/__init__.py +43 -12
  36. mindspore/common/_grad_function.py +2 -1
  37. mindspore/common/_pijit_context.py +28 -7
  38. mindspore/common/_stub_tensor.py +1 -209
  39. mindspore/common/_tensor_cpp_method.py +1 -1
  40. mindspore/common/_tensor_docs.py +177 -52
  41. mindspore/common/_utils.py +9 -1
  42. mindspore/common/api.py +338 -208
  43. mindspore/common/dtype.py +108 -57
  44. mindspore/common/dump.py +11 -16
  45. mindspore/common/dynamic_shape/__init__.py +0 -0
  46. mindspore/common/{auto_dynamic_shape.py → dynamic_shape/auto_dynamic_shape.py} +17 -23
  47. mindspore/common/dynamic_shape/enable_dynamic.py +197 -0
  48. mindspore/common/file_system.py +59 -9
  49. mindspore/common/generator.py +2 -3
  50. mindspore/common/hook_handle.py +33 -5
  51. mindspore/common/jit_config.py +1 -1
  52. mindspore/common/jit_trace.py +84 -105
  53. mindspore/common/np_dtype.py +3 -3
  54. mindspore/common/parameter.py +27 -29
  55. mindspore/common/recompute.py +5 -7
  56. mindspore/common/sparse_tensor.py +0 -3
  57. mindspore/common/symbol.py +0 -1
  58. mindspore/common/tensor.py +84 -133
  59. mindspore/communication/_comm_helper.py +46 -4
  60. mindspore/communication/management.py +79 -7
  61. mindspore/context.py +47 -38
  62. mindspore/dataset/__init__.py +1 -1
  63. mindspore/dataset/audio/transforms.py +1 -1
  64. mindspore/dataset/core/config.py +38 -4
  65. mindspore/dataset/engine/datasets.py +350 -322
  66. mindspore/dataset/engine/datasets_user_defined.py +69 -23
  67. mindspore/dataset/engine/iterators.py +2 -2
  68. mindspore/dataset/engine/obs/config_loader.py +2 -2
  69. mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +8 -0
  70. mindspore/dataset/transforms/c_transforms.py +2 -2
  71. mindspore/dataset/transforms/py_transforms.py +7 -3
  72. mindspore/dataset/transforms/transforms.py +10 -6
  73. mindspore/dataset/vision/__init__.py +1 -1
  74. mindspore/dataset/vision/py_transforms.py +8 -8
  75. mindspore/dataset/vision/transforms.py +17 -5
  76. mindspore/dataset/vision/utils.py +632 -21
  77. mindspore/dataset/vision/validators.py +1 -0
  78. mindspore/device_context/ascend/device.py +1 -1
  79. mindspore/device_context/ascend/op_tuning.py +35 -1
  80. mindspore/device_context/gpu/__init__.py +2 -2
  81. mindspore/device_context/gpu/device.py +1 -1
  82. mindspore/device_context/gpu/op_precision.py +4 -2
  83. mindspore/device_context/gpu/op_tuning.py +6 -3
  84. mindspore/device_manager.py +16 -9
  85. mindspore/dnnl.dll +0 -0
  86. mindspore/dpcmi.dll +0 -0
  87. mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +5 -4
  88. mindspore/experimental/llm_boost/atb/boost_base.py +2 -3
  89. mindspore/experimental/optim/adadelta.py +13 -20
  90. mindspore/experimental/optim/adagrad.py +15 -22
  91. mindspore/experimental/optim/adam.py +17 -24
  92. mindspore/experimental/optim/adamax.py +14 -22
  93. mindspore/experimental/optim/adamw.py +28 -34
  94. mindspore/experimental/optim/asgd.py +15 -25
  95. mindspore/experimental/optim/lr_scheduler.py +27 -45
  96. mindspore/experimental/optim/nadam.py +14 -24
  97. mindspore/experimental/optim/optimizer.py +13 -23
  98. mindspore/experimental/optim/radam.py +18 -24
  99. mindspore/experimental/optim/rmsprop.py +14 -25
  100. mindspore/experimental/optim/rprop.py +15 -26
  101. mindspore/experimental/optim/sgd.py +9 -19
  102. mindspore/hal/__init__.py +4 -4
  103. mindspore/hal/contiguous_tensors_handle.py +2 -2
  104. mindspore/hal/memory.py +1 -0
  105. mindspore/include/api/cell.h +65 -5
  106. mindspore/include/api/cfg.h +24 -7
  107. mindspore/include/api/context.h +1 -0
  108. mindspore/include/api/delegate.h +10 -2
  109. mindspore/include/api/dual_abi_helper.h +100 -19
  110. mindspore/include/api/graph.h +14 -1
  111. mindspore/include/api/kernel.h +16 -3
  112. mindspore/include/api/kernel_api.h +9 -1
  113. mindspore/include/api/metrics/accuracy.h +9 -0
  114. mindspore/include/api/model.h +8 -1
  115. mindspore/include/api/model_group.h +4 -0
  116. mindspore/include/api/model_parallel_runner.h +2 -0
  117. mindspore/include/api/status.h +48 -10
  118. mindspore/include/api/types.h +8 -3
  119. mindspore/include/c_api/model_c.h +0 -58
  120. mindspore/include/c_api/tensor_c.h +0 -26
  121. mindspore/include/dataset/constants.h +9 -0
  122. mindspore/include/dataset/vision_ascend.h +1 -1
  123. mindspore/jpeg62.dll +0 -0
  124. mindspore/mindrecord/tools/cifar10.py +61 -11
  125. mindspore/mindrecord/tools/cifar10_to_mr.py +5 -0
  126. mindspore/mindspore_backend_common.dll +0 -0
  127. mindspore/mindspore_backend_manager.dll +0 -0
  128. mindspore/mindspore_common.dll +0 -0
  129. mindspore/mindspore_core.dll +0 -0
  130. mindspore/mindspore_cpu_res_manager.dll +0 -0
  131. mindspore/mindspore_dump.dll +0 -0
  132. mindspore/mindspore_frontend.dll +0 -0
  133. mindspore/mindspore_glog.dll +0 -0
  134. mindspore/mindspore_memory_pool.dll +0 -0
  135. mindspore/mindspore_ms_backend.dll +0 -0
  136. mindspore/mindspore_ops.dll +0 -0
  137. mindspore/mindspore_ops_host.dll +0 -0
  138. mindspore/mindspore_ops_kernel_common.dll +0 -0
  139. mindspore/mindspore_profiler.dll +0 -0
  140. mindspore/mindspore_pyboost.dll +0 -0
  141. mindspore/mindspore_pynative.dll +0 -0
  142. mindspore/mindspore_res_manager.dll +0 -0
  143. mindspore/mindspore_runtime_pipeline.dll +0 -0
  144. mindspore/mint/__init__.py +4 -44
  145. mindspore/mint/distributed/__init__.py +5 -0
  146. mindspore/mint/distributed/distributed.py +425 -19
  147. mindspore/mint/nn/__init__.py +1 -1
  148. mindspore/mint/nn/functional.py +53 -6
  149. mindspore/mint/nn/layer/_functions.py +163 -294
  150. mindspore/mint/nn/layer/activation.py +8 -6
  151. mindspore/mint/nn/layer/conv.py +125 -101
  152. mindspore/mint/nn/layer/normalization.py +11 -25
  153. mindspore/mint/optim/adam.py +19 -18
  154. mindspore/mint/optim/adamw.py +14 -8
  155. mindspore/mint/optim/sgd.py +5 -5
  156. mindspore/msobj140.dll +0 -0
  157. mindspore/mspdb140.dll +0 -0
  158. mindspore/mspdbcore.dll +0 -0
  159. mindspore/mspdbst.dll +0 -0
  160. mindspore/mspft140.dll +0 -0
  161. mindspore/msvcdis140.dll +0 -0
  162. mindspore/msvcp140_1.dll +0 -0
  163. mindspore/msvcp140_2.dll +0 -0
  164. mindspore/msvcp140_atomic_wait.dll +0 -0
  165. mindspore/msvcp140_codecvt_ids.dll +0 -0
  166. mindspore/nn/cell.py +488 -620
  167. mindspore/nn/grad/cell_grad.py +11 -12
  168. mindspore/nn/layer/activation.py +36 -36
  169. mindspore/nn/layer/basic.py +74 -77
  170. mindspore/nn/layer/channel_shuffle.py +4 -4
  171. mindspore/nn/layer/combined.py +4 -2
  172. mindspore/nn/layer/conv.py +86 -85
  173. mindspore/nn/layer/dense.py +9 -7
  174. mindspore/nn/layer/embedding.py +50 -52
  175. mindspore/nn/layer/image.py +38 -40
  176. mindspore/nn/layer/math.py +111 -112
  177. mindspore/nn/layer/normalization.py +56 -44
  178. mindspore/nn/layer/pooling.py +58 -63
  179. mindspore/nn/layer/rnn_cells.py +33 -33
  180. mindspore/nn/layer/rnns.py +56 -56
  181. mindspore/nn/layer/thor_layer.py +74 -73
  182. mindspore/nn/layer/transformer.py +11 -1
  183. mindspore/nn/learning_rate_schedule.py +20 -20
  184. mindspore/nn/loss/loss.py +79 -81
  185. mindspore/nn/optim/adam.py +2 -4
  186. mindspore/nn/optim/adasum.py +2 -2
  187. mindspore/nn/optim/lamb.py +1 -3
  188. mindspore/nn/optim/optimizer.py +1 -1
  189. mindspore/nn/optim/tft_wrapper.py +2 -3
  190. mindspore/nn/optim/thor.py +2 -2
  191. mindspore/nn/probability/distribution/_utils/utils.py +2 -2
  192. mindspore/nn/probability/distribution/exponential.py +2 -1
  193. mindspore/nn/probability/distribution/poisson.py +2 -1
  194. mindspore/nn/sparse/sparse.py +3 -3
  195. mindspore/nn/wrap/cell_wrapper.py +73 -42
  196. mindspore/nn/wrap/grad_reducer.py +37 -52
  197. mindspore/nn/wrap/loss_scale.py +72 -74
  198. mindspore/numpy/array_creations.py +7 -7
  199. mindspore/numpy/fft.py +1 -1
  200. mindspore/numpy/math_ops.py +1 -1
  201. mindspore/numpy/utils_const.py +1 -1
  202. mindspore/opencv_core452.dll +0 -0
  203. mindspore/opencv_imgcodecs452.dll +0 -0
  204. mindspore/opencv_imgproc452.dll +0 -0
  205. mindspore/ops/_grad_experimental/grad_comm_ops.py +51 -13
  206. mindspore/ops/_grad_experimental/grad_debug_ops.py +14 -0
  207. mindspore/ops/_grad_experimental/grad_inner_ops.py +0 -9
  208. mindspore/ops/_op_impl/cpu/__init__.py +1 -0
  209. mindspore/{experimental/es/__init__.py → ops/_op_impl/cpu/joinedstr_op.py} +12 -6
  210. mindspore/ops/_vmap/vmap_array_ops.py +6 -13
  211. mindspore/ops/_vmap/vmap_nn_ops.py +8 -16
  212. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +29 -10
  213. mindspore/ops/auto_generate/gen_extend_func.py +5 -55
  214. mindspore/ops/auto_generate/gen_ops_def.py +753 -273
  215. mindspore/ops/auto_generate/gen_ops_prim.py +1687 -958
  216. mindspore/ops/auto_generate/pyboost_inner_prim.py +31 -1
  217. mindspore/ops/composite/__init__.py +10 -0
  218. mindspore/ops/composite/base.py +9 -5
  219. mindspore/ops/composite/multitype_ops/__init__.py +12 -1
  220. mindspore/ops/composite/multitype_ops/_compile_utils.py +132 -108
  221. mindspore/ops/composite/multitype_ops/_constexpr_utils.py +1 -1
  222. mindspore/ops/composite/multitype_ops/add_impl.py +70 -2
  223. mindspore/ops/composite/multitype_ops/div_impl.py +49 -0
  224. mindspore/ops/composite/multitype_ops/floordiv_impl.py +29 -0
  225. mindspore/ops/composite/multitype_ops/getitem_impl.py +11 -0
  226. mindspore/ops/composite/multitype_ops/mod_impl.py +5 -3
  227. mindspore/ops/composite/multitype_ops/mul_impl.py +49 -0
  228. mindspore/ops/composite/multitype_ops/setitem_impl.py +57 -0
  229. mindspore/ops/composite/multitype_ops/sub_impl.py +34 -0
  230. mindspore/ops/composite/multitype_ops/zeros_like_impl.py +14 -0
  231. mindspore/ops/function/__init__.py +4 -1
  232. mindspore/ops/function/_add_attr_func.py +11 -6
  233. mindspore/ops/function/array_func.py +17 -100
  234. mindspore/ops/function/debug_func.py +8 -5
  235. mindspore/ops/function/grad/grad_func.py +5 -13
  236. mindspore/ops/function/math_func.py +65 -399
  237. mindspore/ops/function/nn_func.py +44 -61
  238. mindspore/ops/function/other_func.py +4 -1
  239. mindspore/ops/function/random_func.py +31 -4
  240. mindspore/ops/functional.py +2 -3
  241. mindspore/ops/functional_overload.py +486 -18
  242. mindspore/ops/op_info_register.py +21 -0
  243. mindspore/ops/operations/__init__.py +5 -2
  244. mindspore/ops/operations/_custom_ops_utils.py +675 -8
  245. mindspore/ops/operations/_inner_ops.py +14 -18
  246. mindspore/ops/operations/_sequence_ops.py +1 -1
  247. mindspore/ops/operations/array_ops.py +4 -50
  248. mindspore/ops/operations/comm_ops.py +186 -41
  249. mindspore/ops/operations/custom_ops.py +244 -175
  250. mindspore/ops/operations/debug_ops.py +55 -4
  251. mindspore/ops/operations/image_ops.py +13 -13
  252. mindspore/ops/operations/manually_defined/ops_def.py +27 -28
  253. mindspore/ops/operations/math_ops.py +8 -9
  254. mindspore/ops/operations/nn_ops.py +6 -7
  255. mindspore/ops/primitive.py +9 -20
  256. mindspore/ops/tensor_method.py +52 -11
  257. mindspore/ops_generate/api/cpp_create_prim_instance_helper_generator.py +1 -1
  258. mindspore/ops_generate/api/functional_map_cpp_generator.py +10 -9
  259. mindspore/ops_generate/api/functions_cc_generator.py +58 -10
  260. mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +1 -1
  261. mindspore/ops_generate/common/base_generator.py +14 -0
  262. mindspore/ops_generate/common/gen_constants.py +7 -2
  263. mindspore/ops_generate/common/gen_utils.py +0 -19
  264. mindspore/ops_generate/common/op_proto.py +11 -4
  265. mindspore/ops_generate/common/template.py +88 -11
  266. mindspore/ops_generate/gen_ops.py +1 -1
  267. mindspore/ops_generate/op_def/lite_ops_cpp_generator.py +4 -4
  268. mindspore/ops_generate/op_def/ops_name_h_generator.py +0 -3
  269. mindspore/ops_generate/op_def/ops_primitive_h_generator.py +0 -4
  270. mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -2
  271. mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +49 -8
  272. mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +2 -2
  273. mindspore/ops_generate/pyboost/gen_pyboost_func.py +31 -16
  274. mindspore/ops_generate/pyboost/op_template_parser.py +98 -72
  275. mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +70 -273
  276. mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +14 -6
  277. mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +316 -0
  278. mindspore/ops_generate/pyboost/pyboost_functions_py_generator.py +1 -1
  279. mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +5 -3
  280. mindspore/ops_generate/pyboost/pyboost_inner_prim_generator.py +1 -1
  281. mindspore/ops_generate/pyboost/pyboost_internal_functions_cpp_generator.py +76 -0
  282. mindspore/ops_generate/pyboost/pyboost_internal_functions_h_generator.py +76 -0
  283. mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +125 -0
  284. mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +4 -3
  285. mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +348 -61
  286. mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +1 -1
  287. mindspore/ops_generate/pyboost/pyboost_utils.py +118 -9
  288. mindspore/ops_generate/tensor_py_cc_generator.py +1 -24
  289. mindspore/parallel/_auto_parallel_context.py +9 -17
  290. mindspore/parallel/_cell_wrapper.py +106 -40
  291. mindspore/parallel/_parallel_serialization.py +4 -3
  292. mindspore/parallel/_ps_context.py +4 -6
  293. mindspore/parallel/_tensor.py +167 -12
  294. mindspore/parallel/_transformer/moe.py +1 -1
  295. mindspore/parallel/_transformer/transformer.py +17 -12
  296. mindspore/parallel/_utils.py +5 -11
  297. mindspore/parallel/auto_parallel.py +33 -12
  298. mindspore/parallel/checkpoint_convert.py +3 -3
  299. mindspore/parallel/checkpoint_transform.py +5 -1
  300. mindspore/parallel/cluster/process_entity/_api.py +88 -49
  301. mindspore/parallel/cluster/process_entity/_utils.py +95 -7
  302. mindspore/parallel/cluster/run.py +48 -7
  303. mindspore/parallel/function/__init__.py +8 -1
  304. mindspore/parallel/function/reshard_func.py +7 -6
  305. mindspore/parallel/nn/__init__.py +15 -2
  306. mindspore/parallel/nn/parallel_cell_wrapper.py +50 -14
  307. mindspore/parallel/nn/parallel_grad_reducer.py +7 -14
  308. mindspore/parallel/shard.py +9 -23
  309. mindspore/parallel/transform_safetensors.py +468 -174
  310. mindspore/pgodb140.dll +0 -0
  311. mindspore/pgort140.dll +0 -0
  312. mindspore/profiler/__init__.py +2 -1
  313. mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +7 -7
  314. mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +3 -0
  315. mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +3 -0
  316. mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +3 -3
  317. mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +3 -3
  318. mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +4 -4
  319. mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +3 -3
  320. mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +4 -1
  321. mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +2 -1
  322. mindspore/profiler/analysis/task_manager.py +1 -1
  323. mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +5 -1
  324. mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +2 -1
  325. mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +10 -9
  326. mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +43 -23
  327. mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +3 -2
  328. mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +9 -5
  329. mindspore/profiler/analysis/viewer/ms_operator_details_viewer.py +132 -0
  330. mindspore/profiler/common/constant.py +16 -0
  331. mindspore/profiler/common/msprof_cmd_tool.py +2 -2
  332. mindspore/profiler/common/path_manager.py +9 -0
  333. mindspore/profiler/common/profiler_context.py +50 -29
  334. mindspore/profiler/common/profiler_info.py +0 -16
  335. mindspore/profiler/common/profiler_meta_data.py +1 -0
  336. mindspore/profiler/common/profiler_op_analyse.py +239 -0
  337. mindspore/profiler/common/profiler_output_path.py +23 -8
  338. mindspore/profiler/common/profiler_parameters.py +128 -35
  339. mindspore/profiler/dynamic_profile/__init__.py +0 -0
  340. mindspore/profiler/dynamic_profile/dynamic_monitor_proxy.py +39 -0
  341. mindspore/profiler/dynamic_profile/dynamic_profiler_config_context.py +666 -0
  342. mindspore/profiler/dynamic_profile/dynamic_profiler_utils.py +62 -0
  343. mindspore/profiler/dynamic_profiler.py +374 -338
  344. mindspore/profiler/envprofiler.py +42 -12
  345. mindspore/profiler/experimental_config.py +112 -7
  346. mindspore/profiler/mstx.py +33 -12
  347. mindspore/profiler/platform/__init__.py +2 -3
  348. mindspore/profiler/platform/cpu_profiler.py +10 -4
  349. mindspore/profiler/platform/npu_profiler.py +30 -20
  350. mindspore/profiler/profiler.py +218 -154
  351. mindspore/profiler/profiler_action_controller.py +65 -77
  352. mindspore/profiler/profiler_interface.py +2 -2
  353. mindspore/profiler/schedule.py +10 -4
  354. mindspore/rewrite/common/config.py +1 -0
  355. mindspore/rewrite/common/namer.py +1 -0
  356. mindspore/rewrite/common/namespace.py +1 -0
  357. mindspore/rewrite/node/node.py +31 -11
  358. mindspore/rewrite/parsers/assign_parser.py +1 -1
  359. mindspore/rewrite/symbol_tree/symbol_tree.py +2 -2
  360. mindspore/run_check/_check_version.py +7 -10
  361. mindspore/runtime/__init__.py +8 -6
  362. mindspore/runtime/event.py +10 -4
  363. mindspore/runtime/executor.py +87 -45
  364. mindspore/runtime/memory.py +22 -30
  365. mindspore/runtime/thread_bind_core.py +299 -165
  366. mindspore/safeguard/rewrite_obfuscation.py +12 -13
  367. mindspore/swresample-4.dll +0 -0
  368. mindspore/swscale-6.dll +0 -0
  369. mindspore/tbbmalloc.dll +0 -0
  370. mindspore/tinyxml2.dll +0 -0
  371. mindspore/train/_utils.py +9 -5
  372. mindspore/train/amp.py +43 -23
  373. mindspore/train/callback/__init__.py +5 -5
  374. mindspore/train/callback/_callback.py +2 -1
  375. mindspore/train/callback/_checkpoint.py +4 -14
  376. mindspore/train/callback/_flops_collector.py +11 -7
  377. mindspore/train/callback/_landscape.py +0 -1
  378. mindspore/train/callback/_train_fault_tolerance.py +72 -18
  379. mindspore/train/data_sink.py +15 -6
  380. mindspore/train/dataset_helper.py +14 -5
  381. mindspore/train/model.py +49 -47
  382. mindspore/train/serialization.py +168 -126
  383. mindspore/train/summary/summary_record.py +13 -2
  384. mindspore/train/train_thor/model_thor.py +2 -2
  385. mindspore/turbojpeg.dll +0 -0
  386. mindspore/utils/__init__.py +3 -2
  387. mindspore/utils/dryrun.py +0 -6
  388. mindspore/utils/runtime_execution_order_check.py +162 -78
  389. mindspore/utils/sdc_detect.py +68 -0
  390. mindspore/utils/utils.py +14 -17
  391. mindspore/vcmeta.dll +0 -0
  392. mindspore/vcruntime140.dll +0 -0
  393. mindspore/vcruntime140_1.dll +0 -0
  394. mindspore/version.py +1 -1
  395. {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/METADATA +5 -4
  396. {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/RECORD +400 -439
  397. mindspore/_deprecated/jit.py +0 -198
  398. mindspore/_extends/remote/kernel_build_server_ascend.py +0 -75
  399. mindspore/communication/_hccl_management.py +0 -297
  400. mindspore/experimental/es/embedding_service.py +0 -891
  401. mindspore/experimental/es/embedding_service_layer.py +0 -581
  402. mindspore/profiler/common/validator/__init__.py +0 -14
  403. mindspore/profiler/common/validator/validate_path.py +0 -84
  404. mindspore/profiler/parser/__init__.py +0 -14
  405. mindspore/profiler/parser/aicpu_data_parser.py +0 -272
  406. mindspore/profiler/parser/ascend_analysis/__init__.py +0 -14
  407. mindspore/profiler/parser/ascend_analysis/constant.py +0 -71
  408. mindspore/profiler/parser/ascend_analysis/file_manager.py +0 -180
  409. mindspore/profiler/parser/ascend_analysis/function_event.py +0 -185
  410. mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +0 -136
  411. mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +0 -131
  412. mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +0 -104
  413. mindspore/profiler/parser/ascend_analysis/path_manager.py +0 -313
  414. mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +0 -123
  415. mindspore/profiler/parser/ascend_analysis/tlv_decoder.py +0 -86
  416. mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +0 -75
  417. mindspore/profiler/parser/ascend_cluster_generator.py +0 -116
  418. mindspore/profiler/parser/ascend_communicate_generator.py +0 -314
  419. mindspore/profiler/parser/ascend_flops_generator.py +0 -116
  420. mindspore/profiler/parser/ascend_fpbp_generator.py +0 -82
  421. mindspore/profiler/parser/ascend_hccl_generator.py +0 -271
  422. mindspore/profiler/parser/ascend_integrate_generator.py +0 -42
  423. mindspore/profiler/parser/ascend_memory_generator.py +0 -185
  424. mindspore/profiler/parser/ascend_msprof_exporter.py +0 -282
  425. mindspore/profiler/parser/ascend_msprof_generator.py +0 -187
  426. mindspore/profiler/parser/ascend_op_generator.py +0 -334
  427. mindspore/profiler/parser/ascend_steptrace_generator.py +0 -94
  428. mindspore/profiler/parser/ascend_timeline_generator.py +0 -545
  429. mindspore/profiler/parser/base_timeline_generator.py +0 -483
  430. mindspore/profiler/parser/container.py +0 -229
  431. mindspore/profiler/parser/cpu_gpu_timeline_generator.py +0 -697
  432. mindspore/profiler/parser/flops_parser.py +0 -531
  433. mindspore/profiler/parser/framework_enum.py +0 -111
  434. mindspore/profiler/parser/framework_parser.py +0 -464
  435. mindspore/profiler/parser/framework_struct.py +0 -61
  436. mindspore/profiler/parser/gpu_analysis/__init__.py +0 -14
  437. mindspore/profiler/parser/gpu_analysis/function_event.py +0 -44
  438. mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +0 -89
  439. mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +0 -72
  440. mindspore/profiler/parser/hccl_parser.py +0 -573
  441. mindspore/profiler/parser/hwts_log_parser.py +0 -122
  442. mindspore/profiler/parser/integrator.py +0 -526
  443. mindspore/profiler/parser/memory_usage_parser.py +0 -277
  444. mindspore/profiler/parser/minddata_analyzer.py +0 -800
  445. mindspore/profiler/parser/minddata_parser.py +0 -186
  446. mindspore/profiler/parser/minddata_pipeline_parser.py +0 -299
  447. mindspore/profiler/parser/op_intermediate_parser.py +0 -149
  448. mindspore/profiler/parser/optime_parser.py +0 -250
  449. mindspore/profiler/parser/profiler_info.py +0 -213
  450. mindspore/profiler/parser/step_trace_parser.py +0 -666
  451. mindspore/utils/hooks.py +0 -81
  452. /mindspore/common/{_auto_dynamic.py → dynamic_shape/_auto_dynamic.py} +0 -0
  453. {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/WHEEL +0 -0
  454. {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/entry_points.txt +0 -0
  455. {mindspore-2.6.0.dist-info → mindspore-2.7.0.dist-info}/top_level.txt +0 -0
@@ -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 once, twice, triple
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
- if groups <= 0:
56
- raise ValueError('groups must be a positive integer.')
57
- self.in_channels = in_channels
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{X}(N_i, k)})
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:`X` represents the input feature map.
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:`{X}(N_i, k)` represents the slice of the :math:`k`-th input
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 `x`'s input channel when applying groups convolution.
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
@@ -202,10 +200,9 @@ class Conv1d(_Conv):
202
200
  possible length. Extra sequence that could not complete a full stride will
203
201
  be discarded.
204
202
 
205
- padding_mode (str, optional): Specifies the padding mode with a padding value of 0. It can be set to:
206
- ``"zeros"`` , ``"reflect"`` ``"circular"`` or ``"replicate"`` . Default: ``"zeros"`` .
207
- dilation (Union[int, tuple[int], list[int]], optional): Specifies the dilation rate to use for dilated convolution.
208
- It can be a single int or a tuple of 1 integer.
203
+ dilation (Union[int, tuple[int], list[int]], optional): Specifies the dilation
204
+ rate to use for dilated convolution.
205
+ It can be a single int or a tuple/list of 1 integer.
209
206
  Assuming :math:`dilation=(d)`, the convolutional kernel samples the input with a
210
207
  spacing of :math:`d-1` elements in the length direction.
211
208
  Default: ``1`` .
@@ -214,16 +211,24 @@ class Conv1d(_Conv):
214
211
  this 1D convolution layer also can be called 1D depthwise convolution layer. Default: ``1`` .
215
212
  The following restraints must be met:
216
213
 
217
- - :math:`(C_{in} \text{ % } \text{groups} == 0)`
218
- - :math:`(C_{out} \text{ % } \text{groups} == 0)`
219
- - :math:`(C_{out} >= \text{groups})`
220
- - :math:`(\text{kernel_size[1]} = C_{in} / \text{groups})`
214
+ - :math:`(C_{in} \text{ % } \text{groups} == 0)`
215
+ - :math:`(C_{out} \text{ % } \text{groups} == 0)`
216
+ - :math:`(C_{out} >= \text{groups})`
217
+ - :math:`(\text{weight[1]} = C_{in} / \text{groups})`
221
218
 
222
219
  bias (bool, optional): Whether the Conv1d layer has a bias parameter. Default: ``True`` .
220
+ padding_mode (str, optional): Specifies the padding mode with a padding value of 0. It can be set to:
221
+ ``"zeros"`` , ``"reflect"`` or ``"replicate"`` . Default: ``"zeros"`` .
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
- - **x** (Tensor) - Tensor of shape :math:`(N, C_{in}, L_{in})` \
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_ = once(kernel_size)
296
- stride_ = once(stride)
297
- padding_ = padding if isinstance(padding, str) else once(padding)
298
- dilation_ = once(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
- once(0), groups, bias, padding_mode, dtype)
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{X}(N_i, k)})
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:`X` represents the input feature map.
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:`{X}(N_i, k)` represents the slice of the :math:`k`-th input
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 `x`'s input channel when applying groups convolution.
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
 
@@ -388,14 +393,11 @@ class Conv2d(_Conv):
388
393
  possible height and width. Extra pixels that could not complete a full stride will
389
394
  be discarded.
390
395
 
391
- padding_mode (str, optional): Specifies the padding mode with a padding value of 0. It can be set to:
392
- ``"zeros"`` , ``"reflect"`` ``"circular"`` or ``"replicate"`` . Default: ``"zeros"`` .
393
- dilation (Union[int, tuple[int], list[int]], optional): Specifies the dilation rate to use for dilated convolution.
394
- It can be a single int or a tuple of 2 or 4 integers. A single int means the dilation size is the same
395
- in both the height and width directions. A tuple of two ints represents the dilation size in
396
- the height and width directions, respectively. For a tuple of four ints, the two ints correspond
397
- to (N, C) dimension are treated as 1, and the two correspond to (H, W) dimensions is the
398
- dilation size in the height and width directions respectively.
396
+ dilation (Union[int, tuple[int], list[int]], optional): Specifies the dilation rate to use
397
+ for dilated convolution.
398
+ It can be a single int or a tuple/list of 2 integers. A single int means the dilation size is the same
399
+ in both the height and width directions. A tuple/list of two ints represents the dilation size in
400
+ the height and width directions, respectively.
399
401
  Assuming :math:`dilation=(d0, d1)`, the convolutional kernel samples the input with a
400
402
  spacing of :math:`d0-1` elements in the height direction and :math:`d1-1` elements in the width direction.
401
403
  The values in the height and width dimensions are in the ranges [1, H] and [1, W], respectively.
@@ -408,43 +410,51 @@ class Conv2d(_Conv):
408
410
  - :math:`(C_{in} \text{ % } \text{groups} == 0)`
409
411
  - :math:`(C_{out} \text{ % } \text{groups} == 0)`
410
412
  - :math:`(C_{out} >= \text{groups})`
411
- - :math:`(\text{kernel_size[1]} = C_{in} / \text{groups})`
413
+ - :math:`(\text{weight[1]} = C_{in} / \text{groups})`
412
414
 
413
415
  bias (bool, optional): Whether the Conv2d layer has a bias parameter. Default: ``True`` .
416
+ padding_mode (str, optional): Specifies the padding mode with a padding value of 0. It can be set to:
417
+ ``"zeros"`` , ``"reflect"`` or ``"replicate"`` . Default: ``"zeros"`` .
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
- - **x** (Tensor) - Tensor of shape :math:`(N, C_{in}, H_{in}, W_{in})` \
418
- or :math:`(C_{in}, H_{in}, W_{in})`.
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
- H_{out} = \left \lceil{\frac{H_{in}}{\text{stride[0]}}} \right \rceil \\
428
- W_{out} = \left \lceil{\frac{W_{in}}{\text{stride[1]}}} \right \rceil \\
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
- H_{out} = \left \lfloor{\frac{H_{in} - \text{dilation[0]} \times (\text{kernel_size[0]} - 1) - 1}
436
- {\text{stride[0]}}} \right \rfloor + 1 \\
437
- W_{out} = \left \lfloor{\frac{W_{in} - \text{dilation[1]} \times (\text{kernel_size[1]} - 1) - 1}
438
- {\text{stride[1]}}} \right \rfloor + 1 \\
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} + padding[0] + padding[1] - \text{dilation[0]} \times
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} + padding[2] + padding[3] - \text{dilation[1]} \times
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_ = twice(kernel_size)
492
- stride_ = twice(stride)
493
- padding_ = padding if isinstance(padding, str) else twice(padding)
494
- dilation_ = twice(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
- twice(0), groups, bias, padding_mode, dtype)
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{X}(N_i, k)})
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:`X` represents the input feature map.
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:`{X}(N_i, k)` represents the slice of the :math:`k`-th input
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 `x`'s input channel when applying groups convolution.
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
- This is an experimental API that is subject to change or deletion.
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 kernel.
572
- The data type is an integer or a tuple of two integers. An integer represents the height
573
- and width of the convolution kernel. A tuple of two integers represents the height
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. If this mode is set, `padding` must be 0.
601
+ be discarded.
593
602
 
594
- padding_mode (str, optional): Specifies the padding mode with a padding value of 0. It can be set to:
595
- ``"zeros"`` , ``"reflect"`` ``"circular"`` or ``"replicate"`` . Default: ``"zeros"`` .
596
603
  dilation (Union[int, tuple[int], list[int]], optional): Controlling the space between the kernel points.
597
604
  Default: ``1`` .
598
605
  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`. Default: ``1`` .
606
+ divisible by `groups`. If the groups is equal to `in_channels` and `out_channels`,
607
+ this 3D convolution layer also can be called 3D depthwise convolution layer. Default: ``1`` .
608
+ The following restraints must be met:
609
+
610
+ - :math:`(C_{in} \text{ % } \text{groups} == 0)`
611
+ - :math:`(C_{out} \text{ % } \text{groups} == 0)`
612
+ - :math:`(C_{out} >= \text{groups})`
613
+ - :math:`(\text{weight[1]} = C_{in} / \text{groups})`
614
+
600
615
  bias (bool, optional): Whether the Conv3d layer has a bias parameter. Default: ``True`` .
616
+ padding_mode (str, optional): Specifies the padding mode with a padding value of 0. It can be set to:
617
+ ``"zeros"`` , ``"reflect"`` or ``"replicate"`` . Default: ``"zeros"`` .
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
- - **x** (Tensor) - Tensor of shape :math:`(N, C_{in}, D_{in}, H_{in}, W_{in})` \
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 \lceil{\frac{D_{in} - \text{dilation[0]} \times (\text{kernel_size[0]} - 1) }
625
- {\text{stride[0]}}} \right \rceil \\
626
- H_{out} = \left \lceil{\frac{H_{in} - \text{dilation[1]} \times (\text{kernel_size[1]} - 1) }
627
- {\text{stride[1]}}} \right \rceil \\
628
- W_{out} = \left \lceil{\frac{W_{in} - \text{dilation[2]} \times (\text{kernel_size[2]} - 1) }
629
- {\text{stride[2]}}} \right \rceil \\
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} + padding[0] + padding[1] - \text{dilation[0]} \times
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} + padding[2] + padding[3] - \text{dilation[1]} \times
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} + padding[4] + padding[5] - \text{dilation[2]} \times
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`, `padding` or `dilation` is neither an int nor a tuple.
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_ = triple(kernel_size)
677
- stride_ = triple(stride)
678
- padding_ = padding if isinstance(padding, str) else triple(padding)
679
- dilation_ = triple(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
- triple(0), groups, bias, padding_mode, dtype)
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
- # Copyright 2020-2024 Huawei Technologies Co., Ltd
1
+ # Adapted from:
2
+ # https://github.com/pytorch/pytorch/blob/release/2.1/torch/nn/modules/batchnorm.py
2
3
  #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- # ============================================================================
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
@@ -228,7 +218,7 @@ class BatchNorm1d(_BatchNorm):
228
218
  dim = len(shape)
229
219
  if dim != 2 and dim != 3:
230
220
  raise ValueError(
231
- "expected 2D or 3D input (got {}D input)".format(dim)
221
+ "expected 2D or 3D input, but got " + str(dim) + "D input"
232
222
  )
233
223
 
234
224
 
@@ -298,7 +288,7 @@ class BatchNorm2d(_BatchNorm):
298
288
  dim = len(shape)
299
289
  if dim != 4:
300
290
  raise ValueError(
301
- "expected 4D input (got {}D input)".format(dim)
291
+ "expected 4D input, but got " + str(dim) + "D input"
302
292
  )
303
293
 
304
294
 
@@ -366,7 +356,7 @@ class BatchNorm3d(_BatchNorm):
366
356
  dim = len(shape)
367
357
  if dim != 5:
368
358
  raise ValueError(
369
- "expected 5D input (got {}D input)".format(dim)
359
+ "expected 5D input, but got " + str(dim) + "D input"
370
360
  )
371
361
 
372
362
 
@@ -600,21 +590,17 @@ class SyncBatchNorm(_BatchNorm):
600
590
  else: # use exponential moving average
601
591
  exponential_average_factor = self.momentum
602
592
 
603
- r"""
604
- Decide whether the mini-batch stats should be used for normalization rather than the buffers.
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
- r"""
614
- Buffers are only updated if they are to be tracked and we are in training mode. Thus they only need to be
615
- passed when the update should occur (i.e. in training mode when they are tracked), or when buffer stats are
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