mindspore 2.0.0rc1__cp38-none-any.whl → 2.2.0__cp38-none-any.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 (870) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/Third_Party_Open_Source_Software_Notice +2 -2
  3. mindspore/__init__.py +5 -2
  4. mindspore/_akg/akg/build_module.py +5 -6
  5. mindspore/_akg/akg/composite/build_module.py +49 -16
  6. mindspore/_akg/akg/composite/split_stitch.py +10 -11
  7. mindspore/_akg/akg/config/repository.json +195 -0
  8. mindspore/_akg/akg/global_configs.py +5 -1
  9. mindspore/_akg/akg/ms/info_version_adapt.py +67 -1
  10. mindspore/_akg/akg/tvm/api.py +4 -3
  11. mindspore/_akg/akg/tvm/autotvm/__init__.py +1 -2
  12. mindspore/_akg/akg/tvm/autotvm/graph_tuner/base_graph_tuner.py +1 -5
  13. mindspore/_akg/akg/tvm/autotvm/measure/__init__.py +1 -1
  14. mindspore/_akg/akg/tvm/autotvm/measure/measure.py +1 -10
  15. mindspore/_akg/akg/tvm/autotvm/measure/measure_methods.py +1 -372
  16. mindspore/_akg/akg/tvm/build_module.py +16 -1
  17. mindspore/_akg/akg/tvm/contrib/graph_runtime.py +0 -53
  18. mindspore/_akg/akg/tvm/hybrid/parser.py +7 -6
  19. mindspore/_akg/akg/tvm/ir_builder.py +1 -1
  20. mindspore/_akg/akg/tvm/module.py +1 -2
  21. mindspore/_akg/akg/tvm/stmt.py +2 -2
  22. mindspore/_akg/akg/utils/composite_op_helper.py +9 -10
  23. mindspore/_akg/akg/utils/kernel_exec.py +58 -260
  24. mindspore/_akg/akg/utils/op_dsl.py +17 -1
  25. mindspore/_akg/akg/utils/result_analysis.py +4 -24
  26. mindspore/_akg/akg/utils/tbe_codegen_utils.py +198 -0
  27. mindspore/_c_dataengine.cpython-38-aarch64-linux-gnu.so +0 -0
  28. mindspore/_c_expression.cpython-38-aarch64-linux-gnu.so +0 -0
  29. mindspore/_c_mindrecord.cpython-38-aarch64-linux-gnu.so +0 -0
  30. mindspore/_check_jit_forbidden_api.py +5 -1
  31. mindspore/_checkparam.py +79 -62
  32. mindspore/_extends/graph_kernel/__init__.py +0 -1
  33. mindspore/_extends/graph_kernel/model/graph_split.py +2 -0
  34. mindspore/_extends/graph_kernel/model/model_builder.py +9 -50
  35. mindspore/_extends/graph_kernel/splitter.py +1 -9
  36. mindspore/_extends/parallel_compile/akg_compiler/akg_process.py +128 -21
  37. mindspore/_extends/parallel_compile/akg_compiler/build_tbe_kernel.py +2 -2
  38. mindspore/_extends/parallel_compile/akg_compiler/tbe_topi.py +4 -2
  39. mindspore/_extends/parallel_compile/tbe_compiler/tbe_adapter.py +18 -13
  40. mindspore/_extends/parallel_compile/tbe_compiler/tbe_helper.py +13 -9
  41. mindspore/_extends/parallel_compile/tbe_compiler/tbe_job.py +1 -1
  42. mindspore/_extends/parallel_compile/tbe_compiler/tbe_job_manager.py +1 -1
  43. mindspore/_extends/parse/__init__.py +19 -17
  44. mindspore/_extends/parse/namespace.py +7 -36
  45. mindspore/_extends/parse/parser.py +375 -189
  46. mindspore/_extends/parse/resources.py +36 -41
  47. mindspore/_extends/parse/standard_method.py +350 -245
  48. mindspore/_extends/parse/trope.py +2 -12
  49. mindspore/_extends/remote/kernel_build_server.py +24 -7
  50. mindspore/_extends/remote/kernel_build_server_akg_v2.py +55 -0
  51. mindspore/_install_custom.py +43 -0
  52. mindspore/_mindspore_offline_debug.cpython-38-aarch64-linux-gnu.so +0 -0
  53. mindspore/amp.py +85 -19
  54. mindspore/bin/cache_admin +0 -0
  55. mindspore/bin/cache_server +0 -0
  56. mindspore/boost/base.py +2 -2
  57. mindspore/boost/boost.py +27 -32
  58. mindspore/boost/boost_cell_wrapper.py +37 -13
  59. mindspore/boost/grad_accumulation.py +1 -1
  60. mindspore/boost/grad_freeze.py +34 -6
  61. mindspore/boost/group_loss_scale_manager.py +15 -14
  62. mindspore/boost/less_batch_normalization.py +28 -3
  63. mindspore/common/__init__.py +15 -11
  64. mindspore/common/_auto_dynamic.py +68 -0
  65. mindspore/common/_jit_fallback_utils.py +111 -0
  66. mindspore/common/_register_for_adapter.py +17 -5
  67. mindspore/common/_register_for_tensor.py +2 -2
  68. mindspore/common/_stub_tensor.py +18 -15
  69. mindspore/common/_utils.py +31 -7
  70. mindspore/common/api.py +269 -101
  71. mindspore/common/auto_dynamic_shape.py +498 -0
  72. mindspore/common/dtype.py +61 -21
  73. mindspore/common/dump.py +9 -7
  74. mindspore/common/initializer.py +106 -76
  75. mindspore/common/jit_config.py +35 -14
  76. mindspore/common/lazy_inline.py +187 -0
  77. mindspore/common/mindir_util.py +101 -0
  78. mindspore/common/mutable.py +10 -13
  79. mindspore/common/parameter.py +246 -55
  80. mindspore/common/seed.py +13 -7
  81. mindspore/common/sparse_tensor.py +29 -33
  82. mindspore/common/tensor.py +907 -251
  83. mindspore/communication/__init__.py +7 -4
  84. mindspore/communication/_comm_helper.py +84 -4
  85. mindspore/communication/management.py +160 -88
  86. mindspore/config/op_info.config +99 -75
  87. mindspore/config/super_bar_config.json +36 -4
  88. mindspore/context.py +526 -219
  89. mindspore/dataset/__init__.py +9 -46
  90. mindspore/dataset/audio/__init__.py +4 -19
  91. mindspore/dataset/audio/transforms.py +545 -233
  92. mindspore/dataset/audio/utils.py +21 -18
  93. mindspore/dataset/callback/ds_callback.py +42 -13
  94. mindspore/dataset/core/config.py +158 -100
  95. mindspore/dataset/core/validator_helpers.py +1 -63
  96. mindspore/dataset/debug/debug_hook.py +45 -13
  97. mindspore/dataset/debug/pre_defined_hook.py +5 -5
  98. mindspore/dataset/engine/__init__.py +0 -5
  99. mindspore/dataset/engine/cache_client.py +38 -15
  100. mindspore/dataset/engine/datasets.py +615 -278
  101. mindspore/dataset/engine/datasets_audio.py +154 -283
  102. mindspore/dataset/engine/datasets_standard_format.py +104 -116
  103. mindspore/dataset/engine/datasets_text.py +443 -326
  104. mindspore/dataset/engine/datasets_user_defined.py +251 -164
  105. mindspore/dataset/engine/datasets_vision.py +839 -1443
  106. mindspore/dataset/engine/iterators.py +11 -4
  107. mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +7 -3
  108. mindspore/dataset/engine/obs/util.py +3 -0
  109. mindspore/dataset/engine/offload.py +6 -6
  110. mindspore/dataset/engine/queue.py +15 -14
  111. mindspore/dataset/engine/samplers.py +39 -23
  112. mindspore/dataset/engine/serializer_deserializer.py +22 -6
  113. mindspore/dataset/engine/validators.py +21 -331
  114. mindspore/dataset/text/__init__.py +5 -33
  115. mindspore/dataset/text/transforms.py +334 -165
  116. mindspore/dataset/text/utils.py +215 -145
  117. mindspore/dataset/transforms/__init__.py +1 -1
  118. mindspore/dataset/transforms/c_transforms.py +3 -2
  119. mindspore/dataset/transforms/py_transforms_util.py +40 -12
  120. mindspore/dataset/transforms/transforms.py +174 -71
  121. mindspore/dataset/utils/browse_dataset.py +25 -17
  122. mindspore/dataset/utils/line_reader.py +24 -21
  123. mindspore/dataset/vision/__init__.py +5 -26
  124. mindspore/dataset/vision/c_transforms.py +177 -165
  125. mindspore/dataset/vision/py_transforms.py +114 -119
  126. mindspore/dataset/vision/py_transforms_util.py +54 -51
  127. mindspore/dataset/vision/transforms.py +1127 -381
  128. mindspore/dataset/vision/utils.py +54 -38
  129. mindspore/dataset/vision/validators.py +12 -2
  130. mindspore/experimental/map_parameter.py +38 -4
  131. mindspore/{dataset/datapreprocess → experimental/optim}/__init__.py +14 -4
  132. mindspore/experimental/optim/adam.py +192 -0
  133. mindspore/experimental/optim/adamw.py +181 -0
  134. mindspore/experimental/optim/lr_scheduler.py +1427 -0
  135. mindspore/experimental/optim/optimizer.py +252 -0
  136. mindspore/experimental/optim/sgd.py +147 -0
  137. mindspore/gen_ops.py +273 -0
  138. mindspore/include/OWNERS +1 -2
  139. mindspore/include/api/context.h +21 -1
  140. mindspore/include/api/data_type.h +2 -1
  141. mindspore/include/api/graph.h +0 -15
  142. mindspore/include/api/kernel.h +2 -0
  143. mindspore/include/api/kernel_api.h +37 -12
  144. mindspore/include/api/model.h +29 -42
  145. mindspore/include/api/model_group.h +14 -3
  146. mindspore/include/api/model_parallel_runner.h +18 -2
  147. mindspore/include/api/serialization.h +26 -0
  148. mindspore/include/api/status.h +1 -0
  149. mindspore/include/api/types.h +38 -4
  150. mindspore/include/c_api/ms/abstract.h +67 -0
  151. mindspore/include/c_api/ms/attribute.h +197 -0
  152. mindspore/include/c_api/ms/base/handle_types.h +43 -0
  153. mindspore/include/c_api/ms/base/macros.h +32 -0
  154. mindspore/include/c_api/ms/base/status.h +33 -0
  155. mindspore/include/c_api/ms/base/types.h +282 -0
  156. mindspore/include/c_api/ms/context.h +102 -0
  157. mindspore/include/c_api/ms/graph.h +160 -0
  158. mindspore/include/c_api/ms/node.h +606 -0
  159. mindspore/include/c_api/ms/tensor.h +161 -0
  160. mindspore/include/c_api/ms/value.h +84 -0
  161. mindspore/include/c_api/status_c.h +3 -0
  162. mindspore/include/dataset/constants.h +6 -12
  163. mindspore/include/dataset/execute.h +23 -13
  164. mindspore/include/dataset/text.h +26 -26
  165. mindspore/include/dataset/transforms.h +25 -31
  166. mindspore/include/dataset/vision.h +60 -60
  167. mindspore/include/dataset/vision_ascend.h +5 -6
  168. mindspore/include/dataset/vision_lite.h +17 -17
  169. mindspore/include/mindapi/base/format.h +0 -1
  170. mindspore/include/mindapi/base/type_id.h +2 -1
  171. mindspore/include/mindapi/base/types.h +5 -1
  172. mindspore/lib/libdnnl.so.2 +0 -0
  173. mindspore/lib/libjemalloc.so.2 +0 -0
  174. mindspore/lib/libmindspore.so +0 -0
  175. mindspore/lib/libmindspore_backend.so +0 -0
  176. mindspore/lib/libmindspore_common.so +0 -0
  177. mindspore/lib/libmindspore_core.so +0 -0
  178. mindspore/lib/libmindspore_glog.so.0 +0 -0
  179. mindspore/lib/libmindspore_gpr.so.15 +0 -0
  180. mindspore/lib/libmindspore_grpc++.so.1 +0 -0
  181. mindspore/lib/libmindspore_grpc.so.15 +0 -0
  182. mindspore/lib/libmindspore_shared_lib.so +0 -0
  183. mindspore/lib/libmpi_adapter.so +0 -0
  184. mindspore/lib/libnnacl.so +0 -0
  185. mindspore/lib/libopencv_core.so.4.5 +0 -0
  186. mindspore/lib/libopencv_imgcodecs.so.4.5 +0 -0
  187. mindspore/lib/libopencv_imgproc.so.4.5 +0 -0
  188. mindspore/lib/libps_cache.so +0 -0
  189. mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/aicpu_kernel/impl/libcust_aicpu_kernels.so +0 -0
  190. mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/aicpu_kernel/impl/libcust_cpu_kernels.so +0 -0
  191. mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/config/cust_aicpu_kernel.json +9000 -0
  192. mindspore/lib/plugin/ascend/custom_aicpu_ops/op_proto/libcust_op_proto.so +0 -0
  193. mindspore/lib/plugin/ascend/libakg.so +0 -0
  194. mindspore/lib/plugin/ascend/libascend_collective.so +0 -0
  195. mindspore/lib/plugin/ascend/libdvpp_utils.so +0 -0
  196. mindspore/lib/plugin/ascend/libhccl_plugin.so +0 -0
  197. mindspore/lib/plugin/ascend/libmindspore_aicpu_kernels.so +0 -0
  198. mindspore/lib/plugin/ascend/libmindspore_cpu_kernels.so +0 -0
  199. mindspore/lib/plugin/cpu/libakg.so +0 -0
  200. mindspore/lib/plugin/libmindspore_ascend.so.1 +0 -0
  201. mindspore/lib/plugin/libmindspore_ascend.so.2 +0 -0
  202. mindspore/log.py +9 -6
  203. mindspore/mindrecord/filereader.py +33 -4
  204. mindspore/mindrecord/filewriter.py +70 -35
  205. mindspore/mindrecord/mindpage.py +40 -34
  206. mindspore/mindrecord/shardreader.py +1 -1
  207. mindspore/mindrecord/shardsegment.py +1 -1
  208. mindspore/mindrecord/tools/cifar100_to_mr.py +25 -18
  209. mindspore/mindrecord/tools/cifar10_to_mr.py +25 -18
  210. mindspore/mindrecord/tools/csv_to_mr.py +29 -13
  211. mindspore/mindrecord/tools/imagenet_to_mr.py +24 -10
  212. mindspore/mindrecord/tools/mnist_to_mr.py +24 -11
  213. mindspore/mindrecord/tools/tfrecord_to_mr.py +31 -26
  214. mindspore/nn/cell.py +463 -169
  215. mindspore/nn/dynamic_lr.py +47 -43
  216. mindspore/nn/layer/activation.py +225 -82
  217. mindspore/nn/layer/basic.py +121 -79
  218. mindspore/nn/layer/channel_shuffle.py +21 -21
  219. mindspore/nn/layer/combined.py +33 -26
  220. mindspore/nn/layer/container.py +277 -22
  221. mindspore/nn/layer/conv.py +441 -304
  222. mindspore/nn/layer/dense.py +19 -13
  223. mindspore/nn/layer/embedding.py +62 -49
  224. mindspore/nn/layer/flash_attention.py +264 -0
  225. mindspore/nn/layer/image.py +50 -39
  226. mindspore/nn/layer/math.py +62 -51
  227. mindspore/nn/layer/normalization.py +219 -167
  228. mindspore/nn/layer/padding.py +58 -70
  229. mindspore/nn/layer/pooling.py +334 -287
  230. mindspore/nn/layer/rnn_cells.py +53 -38
  231. mindspore/nn/layer/rnns.py +59 -56
  232. mindspore/nn/layer/thor_layer.py +52 -44
  233. mindspore/nn/layer/timedistributed.py +6 -4
  234. mindspore/nn/layer/transformer.py +284 -164
  235. mindspore/nn/learning_rate_schedule.py +34 -25
  236. mindspore/nn/loss/__init__.py +3 -2
  237. mindspore/nn/loss/loss.py +554 -311
  238. mindspore/nn/optim/ada_grad.py +12 -9
  239. mindspore/nn/optim/adadelta.py +14 -11
  240. mindspore/nn/optim/adafactor.py +19 -16
  241. mindspore/nn/optim/adam.py +62 -47
  242. mindspore/nn/optim/adamax.py +13 -10
  243. mindspore/nn/optim/adasum.py +12 -8
  244. mindspore/nn/optim/asgd.py +10 -9
  245. mindspore/nn/optim/ftrl.py +20 -17
  246. mindspore/nn/optim/lamb.py +16 -12
  247. mindspore/nn/optim/lars.py +8 -6
  248. mindspore/nn/optim/lazyadam.py +25 -20
  249. mindspore/nn/optim/momentum.py +10 -7
  250. mindspore/nn/optim/optimizer.py +61 -9
  251. mindspore/nn/optim/proximal_ada_grad.py +14 -13
  252. mindspore/nn/optim/rmsprop.py +17 -13
  253. mindspore/nn/optim/rprop.py +30 -17
  254. mindspore/nn/optim/sgd.py +40 -23
  255. mindspore/nn/optim/thor.py +24 -26
  256. mindspore/nn/probability/bijector/bijector.py +11 -11
  257. mindspore/nn/probability/bijector/exp.py +1 -1
  258. mindspore/nn/probability/bijector/gumbel_cdf.py +3 -3
  259. mindspore/nn/probability/bijector/invert.py +1 -1
  260. mindspore/nn/probability/bijector/power_transform.py +29 -29
  261. mindspore/nn/probability/bijector/scalar_affine.py +3 -3
  262. mindspore/nn/probability/bijector/softplus.py +5 -5
  263. mindspore/nn/probability/bnn_layers/bnn_cell_wrapper.py +4 -2
  264. mindspore/nn/probability/bnn_layers/conv_variational.py +13 -13
  265. mindspore/nn/probability/bnn_layers/dense_variational.py +12 -12
  266. mindspore/nn/probability/bnn_layers/layer_distribution.py +9 -8
  267. mindspore/nn/probability/distribution/_utils/custom_ops.py +19 -3
  268. mindspore/nn/probability/distribution/_utils/utils.py +1 -1
  269. mindspore/nn/probability/distribution/bernoulli.py +9 -9
  270. mindspore/nn/probability/distribution/beta.py +8 -8
  271. mindspore/nn/probability/distribution/categorical.py +23 -15
  272. mindspore/nn/probability/distribution/cauchy.py +5 -6
  273. mindspore/nn/probability/distribution/distribution.py +3 -3
  274. mindspore/nn/probability/distribution/exponential.py +4 -4
  275. mindspore/nn/probability/distribution/gamma.py +10 -10
  276. mindspore/nn/probability/distribution/geometric.py +8 -8
  277. mindspore/nn/probability/distribution/gumbel.py +8 -9
  278. mindspore/nn/probability/distribution/half_normal.py +5 -5
  279. mindspore/nn/probability/distribution/laplace.py +5 -5
  280. mindspore/nn/probability/distribution/log_normal.py +12 -11
  281. mindspore/nn/probability/distribution/logistic.py +8 -8
  282. mindspore/nn/probability/distribution/normal.py +6 -5
  283. mindspore/nn/probability/distribution/poisson.py +10 -11
  284. mindspore/nn/probability/distribution/student_t.py +8 -9
  285. mindspore/nn/probability/distribution/transformed_distribution.py +5 -5
  286. mindspore/nn/probability/distribution/uniform.py +11 -11
  287. mindspore/nn/reinforcement/tensor_array.py +2 -2
  288. mindspore/nn/sparse/sparse.py +9 -9
  289. mindspore/nn/wrap/cell_wrapper.py +188 -63
  290. mindspore/nn/wrap/grad_reducer.py +21 -12
  291. mindspore/nn/wrap/loss_scale.py +136 -49
  292. mindspore/numpy/__init__.py +4 -4
  293. mindspore/numpy/array_creations.py +55 -56
  294. mindspore/numpy/array_ops.py +134 -35
  295. mindspore/numpy/logic_ops.py +66 -20
  296. mindspore/numpy/math_ops.py +142 -139
  297. mindspore/numpy/utils_const.py +2 -2
  298. mindspore/offline_debug/convert_async.py +2 -2
  299. mindspore/ops/_grad_experimental/__init__.py +7 -5
  300. mindspore/ops/_grad_experimental/grad_array_ops.py +231 -348
  301. mindspore/ops/{_grad → _grad_experimental}/grad_base.py +1 -33
  302. mindspore/ops/{_grad → _grad_experimental}/grad_comm_ops.py +25 -13
  303. mindspore/ops/{_grad/__init__.py → _grad_experimental/grad_debug_ops.py} +15 -7
  304. mindspore/ops/{_grad → _grad_experimental}/grad_implementations.py +17 -11
  305. mindspore/ops/_grad_experimental/grad_inner_ops.py +33 -52
  306. mindspore/ops/_grad_experimental/grad_math_ops.py +151 -1224
  307. mindspore/ops/_grad_experimental/grad_nn_ops.py +141 -414
  308. mindspore/ops/{_grad → _grad_experimental}/grad_quant_ops.py +10 -6
  309. mindspore/ops/_grad_experimental/grad_sparse.py +317 -2
  310. mindspore/ops/_grad_experimental/grad_sparse_ops.py +3 -13
  311. mindspore/ops/{_grad → _grad_experimental}/taylor_rule.py +1 -1
  312. mindspore/ops/_op_impl/_custom_op/dsd_back_impl.py +1 -1
  313. mindspore/ops/_op_impl/_custom_op/flash_attention/__init__.py +0 -0
  314. mindspore/ops/_op_impl/_custom_op/flash_attention/attention.py +406 -0
  315. mindspore/{_extends/graph_kernel/expanders/complex/__init__.py → ops/_op_impl/_custom_op/flash_attention/constants.py} +27 -8
  316. mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_bwd.py +467 -0
  317. mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_fwd.py +563 -0
  318. mindspore/ops/_op_impl/_custom_op/flash_attention/flash_attention_impl.py +193 -0
  319. mindspore/ops/_op_impl/_custom_op/flash_attention/tik_ops_utils.py +435 -0
  320. mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/__init__.py +0 -0
  321. mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/sparse_tiling.py +45 -0
  322. mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/strategy.py +67 -0
  323. mindspore/ops/_op_impl/_custom_op/flash_attention/tiling_strategy/wukong_tiling.py +62 -0
  324. mindspore/ops/_op_impl/_custom_op/matmul_cube_dense_left_impl.py +2 -2
  325. mindspore/ops/_op_impl/aicpu/__init__.py +41 -1
  326. mindspore/ops/_op_impl/aicpu/adaptive_max_pool_2d.py +37 -0
  327. mindspore/ops/_op_impl/aicpu/bias_add_grad.py +0 -1
  328. mindspore/ops/_op_impl/aicpu/cast.py +52 -0
  329. mindspore/ops/_op_impl/aicpu/coalesce.py +2 -0
  330. mindspore/ops/_op_impl/aicpu/col2im.py +3 -1
  331. mindspore/ops/_op_impl/aicpu/count_nonzero.py +43 -0
  332. mindspore/ops/_op_impl/aicpu/dropout_genmask.py +6 -0
  333. mindspore/ops/_op_impl/aicpu/eps.py +32 -0
  334. mindspore/ops/_op_impl/aicpu/eye.py +4 -4
  335. mindspore/ops/_op_impl/aicpu/fft_with_size.py +6 -0
  336. mindspore/ops/_op_impl/aicpu/fill_diagonal.py +5 -0
  337. mindspore/ops/_op_impl/aicpu/gamma.py +2 -2
  338. mindspore/ops/_op_impl/aicpu/im2col.py +3 -5
  339. mindspore/ops/_op_impl/aicpu/lgamma.py +1 -0
  340. mindspore/ops/_op_impl/aicpu/log_uniform_candidate_sampler.py +6 -3
  341. mindspore/ops/_op_impl/aicpu/lu.py +39 -0
  342. mindspore/ops/_op_impl/aicpu/lu_unpack_grad.py +0 -1
  343. mindspore/ops/_op_impl/aicpu/masked_scatter.py +1 -0
  344. mindspore/ops/_op_impl/aicpu/masked_select_grad.py +3 -0
  345. mindspore/ops/_op_impl/aicpu/matrix_band_part.py +59 -0
  346. mindspore/ops/_op_impl/aicpu/matrix_power.py +6 -1
  347. mindspore/ops/_op_impl/aicpu/median.py +1 -0
  348. mindspore/ops/_op_impl/aicpu/multinomial.py +9 -9
  349. mindspore/ops/_op_impl/aicpu/not_equal.py +0 -5
  350. mindspore/ops/_op_impl/aicpu/pad_v3.py +3 -1
  351. mindspore/ops/_op_impl/aicpu/pad_v3_grad.py +2 -0
  352. mindspore/ops/_op_impl/aicpu/parameterized_truncated_normal.py +15 -7
  353. mindspore/ops/_op_impl/aicpu/random_categorical.py +39 -19
  354. mindspore/ops/_op_impl/aicpu/random_choice_with_mask.py +5 -2
  355. mindspore/ops/_op_impl/aicpu/random_poisson.py +103 -52
  356. mindspore/ops/_op_impl/aicpu/random_shuffle.py +17 -15
  357. mindspore/ops/_op_impl/aicpu/resize_bilinear_grad.py +0 -1
  358. mindspore/ops/_op_impl/aicpu/resize_nearest_neighbor_v2.py +0 -6
  359. mindspore/ops/_op_impl/aicpu/resize_nearest_neighbor_v2_grad.py +0 -7
  360. mindspore/ops/_op_impl/aicpu/scatter_nd.py +2 -0
  361. mindspore/ops/_op_impl/aicpu/sequence_concat.py +40 -0
  362. mindspore/ops/_op_impl/aicpu/sequence_stack.py +40 -0
  363. mindspore/ops/_op_impl/aicpu/{sparseaddmm.py → sparse_addmm.py} +2 -2
  364. mindspore/ops/_op_impl/aicpu/{sparsesparsemaximum.py → sparse_sparse_maximum.py} +4 -4
  365. mindspore/ops/_op_impl/aicpu/standard_laplace.py +5 -4
  366. mindspore/ops/_op_impl/aicpu/standard_normal.py +5 -4
  367. mindspore/ops/_op_impl/aicpu/truncated_normal.py +9 -7
  368. mindspore/ops/_op_impl/aicpu/uniform.py +5 -3
  369. mindspore/ops/_op_impl/aicpu/uniform_candidate_sampler.py +8 -4
  370. mindspore/ops/_op_impl/aicpu/uniform_int.py +5 -5
  371. mindspore/ops/_op_impl/aicpu/uniform_real.py +4 -4
  372. mindspore/ops/_op_impl/aicpu/upsample_nearest_3d.py +14 -6
  373. mindspore/ops/_op_impl/aicpu/upsample_nearest_3d_grad.py +22 -8
  374. mindspore/ops/_op_impl/aicpu/upsample_trilinear_3d.py +11 -6
  375. mindspore/ops/_op_impl/aicpu/upsample_trilinear_3d_grad.py +21 -10
  376. mindspore/ops/_op_impl/tbe/__init__.py +6 -4
  377. mindspore/ops/_op_impl/tbe/atomic_addr_clean.py +1 -1
  378. mindspore/ops/_op_impl/tbe/avg_pool.py +2 -2
  379. mindspore/ops/_op_impl/tbe/avg_pool_3d.py +3 -3
  380. mindspore/ops/_op_impl/tbe/avg_pool_3d_grad.py +4 -4
  381. mindspore/ops/_op_impl/tbe/avg_pool_ds.py +2 -2
  382. mindspore/ops/_op_impl/tbe/avg_pool_grad.py +3 -3
  383. mindspore/ops/_op_impl/tbe/avg_pool_grad_vm.py +3 -3
  384. mindspore/ops/_op_impl/tbe/batch_to_space.py +1 -1
  385. mindspore/ops/_op_impl/tbe/batch_to_space_nd.py +2 -2
  386. mindspore/ops/_op_impl/tbe/bn_infer.py +2 -2
  387. mindspore/ops/_op_impl/tbe/bn_infer_ds.py +3 -2
  388. mindspore/ops/_op_impl/tbe/broadcast_to.py +1 -1
  389. mindspore/ops/_op_impl/tbe/depthwise_conv2d.py +3 -3
  390. mindspore/ops/_op_impl/tbe/expand_dims.py +1 -1
  391. mindspore/ops/_op_impl/tbe/gather_v2.py +56 -0
  392. mindspore/ops/_op_impl/tbe/im2col.py +4 -4
  393. mindspore/ops/_op_impl/tbe/inplace_index_add.py +7 -3
  394. mindspore/ops/_op_impl/tbe/mem_set.py +38 -0
  395. mindspore/ops/_op_impl/tbe/scatter_nd_add.py +3 -0
  396. mindspore/ops/_op_impl/tbe/scatter_nd_d.py +1 -1
  397. mindspore/ops/_op_impl/tbe/space_to_batch.py +1 -1
  398. mindspore/ops/_op_impl/tbe/space_to_batch_nd.py +2 -2
  399. mindspore/ops/_op_impl/tbe/trans_data_ds.py +2 -0
  400. mindspore/ops/_primitive_cache.py +1 -1
  401. mindspore/ops/_tracefunc.py +241 -0
  402. mindspore/ops/_utils/utils.py +10 -2
  403. mindspore/ops/_vmap/vmap_array_ops.py +5 -3
  404. mindspore/ops/_vmap/vmap_base.py +5 -4
  405. mindspore/ops/_vmap/vmap_convolution_ops.py +1 -1
  406. mindspore/ops/_vmap/vmap_grad_math_ops.py +6 -4
  407. mindspore/ops/_vmap/vmap_grad_nn_ops.py +11 -6
  408. mindspore/ops/_vmap/vmap_math_ops.py +5 -2
  409. mindspore/ops/_vmap/vmap_nn_ops.py +135 -11
  410. mindspore/ops/arg_dtype_cast.py +54 -0
  411. mindspore/ops/composite/__init__.py +7 -5
  412. mindspore/ops/composite/base.py +78 -34
  413. mindspore/ops/composite/math_ops.py +5 -695
  414. mindspore/ops/composite/multitype_ops/_compile_utils.py +403 -97
  415. mindspore/ops/composite/multitype_ops/_constexpr_utils.py +28 -22
  416. mindspore/ops/composite/multitype_ops/add_impl.py +69 -7
  417. mindspore/ops/composite/multitype_ops/bitwise_and_impl.py +2 -1
  418. mindspore/ops/composite/multitype_ops/bitwise_or_impl.py +2 -1
  419. mindspore/ops/composite/multitype_ops/bitwise_xor_impl.py +2 -0
  420. mindspore/ops/composite/multitype_ops/div_impl.py +1 -0
  421. mindspore/ops/composite/multitype_ops/floordiv_impl.py +1 -0
  422. mindspore/ops/composite/multitype_ops/getitem_impl.py +48 -10
  423. mindspore/ops/composite/multitype_ops/greater_equal_impl.py +2 -0
  424. mindspore/ops/composite/multitype_ops/greater_impl.py +2 -0
  425. mindspore/ops/composite/multitype_ops/left_shift_impl.py +2 -0
  426. mindspore/ops/composite/multitype_ops/less_equal_impl.py +2 -0
  427. mindspore/ops/composite/multitype_ops/less_impl.py +2 -0
  428. mindspore/ops/composite/multitype_ops/logic_not_impl.py +2 -2
  429. mindspore/ops/composite/multitype_ops/mod_impl.py +1 -0
  430. mindspore/ops/composite/multitype_ops/mul_impl.py +1 -0
  431. mindspore/ops/composite/multitype_ops/negative_impl.py +1 -0
  432. mindspore/ops/composite/multitype_ops/not_in_impl.py +1 -0
  433. mindspore/ops/composite/multitype_ops/ones_like_impl.py +6 -0
  434. mindspore/ops/composite/multitype_ops/pow_impl.py +1 -0
  435. mindspore/ops/composite/multitype_ops/right_shift_impl.py +2 -0
  436. mindspore/ops/composite/multitype_ops/setitem_impl.py +10 -7
  437. mindspore/ops/composite/multitype_ops/sub_impl.py +1 -0
  438. mindspore/ops/composite/multitype_ops/uadd_impl.py +2 -0
  439. mindspore/ops/composite/multitype_ops/zeros_like_impl.py +9 -0
  440. mindspore/ops/deprecated.py +304 -0
  441. mindspore/ops/function/__init__.py +41 -4
  442. mindspore/ops/function/array_func.py +1108 -467
  443. mindspore/ops/function/clip_func.py +94 -27
  444. mindspore/ops/function/debug_func.py +3 -1
  445. mindspore/ops/function/grad/grad_func.py +82 -73
  446. mindspore/ops/function/image_func.py +28 -12
  447. mindspore/ops/function/linalg_func.py +135 -39
  448. mindspore/ops/function/math_func.py +3779 -894
  449. mindspore/ops/function/nn_func.py +1584 -657
  450. mindspore/ops/function/parameter_func.py +13 -3
  451. mindspore/ops/function/random_func.py +247 -153
  452. mindspore/ops/function/sparse_func.py +14 -11
  453. mindspore/ops/function/sparse_unary_func.py +173 -47
  454. mindspore/ops/function/spectral_func.py +8 -4
  455. mindspore/ops/function/vmap_func.py +8 -7
  456. mindspore/ops/functional.py +47 -16
  457. mindspore/ops/op_info_register.py +346 -86
  458. mindspore/ops/operations/__init__.py +38 -22
  459. mindspore/ops/operations/_grad_ops.py +145 -149
  460. mindspore/ops/operations/_inner_ops.py +298 -56
  461. mindspore/ops/operations/_ms_kernel.py +3 -3
  462. mindspore/ops/operations/_quant_ops.py +24 -28
  463. mindspore/ops/operations/_rl_inner_ops.py +9 -7
  464. mindspore/ops/operations/_scalar_ops.py +115 -0
  465. mindspore/ops/operations/_sequence_ops.py +148 -10
  466. mindspore/ops/operations/_tensor_array.py +1 -1
  467. mindspore/ops/operations/_thor_ops.py +2 -2
  468. mindspore/ops/operations/array_ops.py +1239 -561
  469. mindspore/ops/operations/comm_ops.py +166 -90
  470. mindspore/ops/operations/control_ops.py +3 -3
  471. mindspore/ops/operations/custom_ops.py +124 -102
  472. mindspore/ops/operations/debug_ops.py +24 -11
  473. mindspore/ops/operations/image_ops.py +86 -71
  474. mindspore/ops/operations/inner_ops.py +18 -13
  475. mindspore/ops/operations/linalg_ops.py +30 -11
  476. mindspore/ops/operations/math_ops.py +1730 -435
  477. mindspore/ops/operations/nn_ops.py +1953 -943
  478. mindspore/ops/operations/other_ops.py +65 -43
  479. mindspore/ops/operations/random_ops.py +258 -98
  480. mindspore/ops/operations/rl_ops.py +4 -36
  481. mindspore/ops/operations/sparse_ops.py +38 -33
  482. mindspore/ops/operations/spectral_ops.py +8 -4
  483. mindspore/ops/primitive.py +66 -44
  484. mindspore/ops/signature.py +5 -5
  485. mindspore/parallel/_auto_parallel_context.py +80 -19
  486. mindspore/parallel/_cost_model_context.py +42 -0
  487. mindspore/parallel/_offload_context.py +162 -72
  488. mindspore/parallel/_parallel_serialization.py +2 -2
  489. mindspore/parallel/_ps_context.py +16 -4
  490. mindspore/parallel/_recovery_context.py +2 -1
  491. mindspore/parallel/_tensor.py +15 -13
  492. mindspore/parallel/_transformer/layers.py +8 -6
  493. mindspore/parallel/_transformer/loss.py +1 -0
  494. mindspore/parallel/_transformer/moe.py +7 -7
  495. mindspore/parallel/_transformer/op_parallel_config.py +12 -1
  496. mindspore/parallel/_transformer/transformer.py +34 -14
  497. mindspore/parallel/_utils.py +36 -14
  498. mindspore/parallel/algo_parameter_config.py +114 -20
  499. mindspore/parallel/checkpoint_transform.py +16 -18
  500. mindspore/parallel/shard.py +16 -13
  501. mindspore/profiler/__init__.py +1 -1
  502. mindspore/profiler/common/struct_type.py +3 -3
  503. mindspore/profiler/common/util.py +3 -2
  504. mindspore/profiler/envprofiling.py +11 -4
  505. mindspore/profiler/parser/aicpu_data_parser.py +5 -3
  506. mindspore/profiler/parser/ascend_flops_generator.py +94 -0
  507. mindspore/profiler/parser/ascend_fpbp_generator.py +76 -0
  508. mindspore/profiler/parser/ascend_hccl_generator.py +288 -0
  509. mindspore/profiler/parser/ascend_msprof_exporter.py +213 -0
  510. mindspore/profiler/parser/ascend_msprof_generator.py +199 -0
  511. mindspore/profiler/parser/ascend_op_generator.py +276 -0
  512. mindspore/profiler/parser/ascend_steptrace_generator.py +94 -0
  513. mindspore/profiler/parser/ascend_timeline_generator.py +110 -54
  514. mindspore/profiler/parser/base_timeline_generator.py +11 -7
  515. mindspore/profiler/parser/cpu_gpu_timeline_generator.py +45 -46
  516. mindspore/profiler/parser/flops_parser.py +15 -11
  517. mindspore/profiler/parser/framework_parser.py +92 -73
  518. mindspore/profiler/parser/hccl_parser.py +16 -12
  519. mindspore/profiler/parser/integrator.py +22 -11
  520. mindspore/profiler/parser/memory_usage_parser.py +36 -11
  521. mindspore/profiler/parser/minddata_analyzer.py +12 -14
  522. mindspore/profiler/parser/minddata_pipeline_parser.py +1 -1
  523. mindspore/profiler/parser/msadvisor_parser.py +8 -4
  524. mindspore/profiler/parser/op_intermediate_parser.py +5 -2
  525. mindspore/profiler/parser/optime_parser.py +1 -1
  526. mindspore/profiler/parser/profiler_info.py +4 -5
  527. mindspore/profiler/parser/step_trace_parser.py +11 -14
  528. mindspore/profiler/profiling.py +678 -377
  529. mindspore/rewrite/api/node.py +211 -54
  530. mindspore/rewrite/api/node_type.py +5 -0
  531. mindspore/rewrite/api/pattern_engine.py +22 -23
  532. mindspore/rewrite/api/scoped_value.py +20 -17
  533. mindspore/rewrite/api/symbol_tree.py +252 -106
  534. mindspore/rewrite/api/tree_node_helper.py +3 -0
  535. mindspore/rewrite/ast_helpers/__init__.py +2 -1
  536. mindspore/rewrite/ast_helpers/ast_finder.py +129 -0
  537. mindspore/rewrite/ast_helpers/ast_modifier.py +116 -104
  538. mindspore/rewrite/ast_transformers/flatten_recursive_stmt.py +97 -46
  539. mindspore/rewrite/common/rewrite_elog.py +5 -1
  540. mindspore/rewrite/namer.py +51 -51
  541. mindspore/rewrite/namespace.py +14 -5
  542. mindspore/{ops/bprop_mindir → rewrite/node}/__init__.py +9 -4
  543. mindspore/rewrite/node/call_function.py +79 -0
  544. mindspore/rewrite/node/cell_container.py +135 -0
  545. mindspore/rewrite/node/control_flow.py +88 -0
  546. mindspore/rewrite/{node.py → node/node.py} +313 -247
  547. mindspore/rewrite/node/node_manager.py +254 -0
  548. mindspore/rewrite/node/node_topological_manager.py +243 -0
  549. mindspore/rewrite/parsers/arguments_parser.py +22 -21
  550. mindspore/rewrite/parsers/assign_parser.py +225 -239
  551. mindspore/rewrite/parsers/attribute_parser.py +9 -7
  552. mindspore/rewrite/parsers/class_def_parser.py +179 -218
  553. mindspore/rewrite/parsers/constant_parser.py +9 -6
  554. mindspore/rewrite/parsers/container_parser.py +9 -7
  555. mindspore/rewrite/parsers/for_parser.py +36 -15
  556. mindspore/rewrite/parsers/function_def_parser.py +23 -20
  557. mindspore/rewrite/parsers/if_parser.py +28 -24
  558. mindspore/rewrite/parsers/module_parser.py +202 -25
  559. mindspore/rewrite/{parser.py → parsers/parser.py} +4 -2
  560. mindspore/rewrite/{parser_register.py → parsers/parser_register.py} +1 -1
  561. mindspore/rewrite/parsers/return_parser.py +6 -6
  562. mindspore/rewrite/sparsify/sparse_transformer.py +12 -3
  563. mindspore/rewrite/sparsify/sparsify.py +4 -1
  564. mindspore/rewrite/sparsify/utils.py +11 -5
  565. mindspore/rewrite/symbol_tree.py +577 -732
  566. mindspore/rewrite/symbol_tree_builder.py +9 -175
  567. mindspore/rewrite/symbol_tree_dumper.py +2 -2
  568. mindspore/run_check/_check_version.py +46 -39
  569. mindspore/run_check/run_check.py +3 -2
  570. mindspore/{scipy/sparse → safeguard}/__init__.py +4 -5
  571. mindspore/safeguard/rewrite_obfuscation.py +517 -0
  572. mindspore/scipy/__init__.py +1 -1
  573. mindspore/scipy/linalg.py +67 -61
  574. mindspore/scipy/ops.py +5 -41
  575. mindspore/scipy/ops_grad.py +3 -2
  576. mindspore/scipy/ops_wrapper.py +5 -5
  577. mindspore/scipy/optimize/line_search.py +8 -8
  578. mindspore/scipy/optimize/linear_sum_assignment.py +4 -4
  579. mindspore/scipy/optimize/minimize.py +16 -12
  580. mindspore/scipy/utils.py +1 -52
  581. mindspore/scipy/utils_const.py +4 -4
  582. mindspore/train/__init__.py +4 -4
  583. mindspore/train/_utils.py +13 -5
  584. mindspore/train/amp.py +410 -148
  585. mindspore/train/anf_ir_pb2.py +16 -4
  586. mindspore/train/callback/_backup_and_restore.py +8 -11
  587. mindspore/train/callback/_callback.py +80 -3
  588. mindspore/train/callback/_checkpoint.py +82 -51
  589. mindspore/train/callback/_early_stop.py +12 -15
  590. mindspore/train/callback/_history.py +1 -1
  591. mindspore/train/callback/_lambda_callback.py +13 -13
  592. mindspore/train/callback/_landscape.py +21 -17
  593. mindspore/train/callback/_loss_monitor.py +9 -10
  594. mindspore/train/callback/_on_request_exit.py +16 -33
  595. mindspore/train/callback/_reduce_lr_on_plateau.py +21 -24
  596. mindspore/train/callback/_summary_collector.py +44 -30
  597. mindspore/train/callback/_time_monitor.py +62 -12
  598. mindspore/train/data_sink.py +10 -16
  599. mindspore/train/dataset_helper.py +154 -86
  600. mindspore/train/loss_scale_manager.py +14 -9
  601. mindspore/train/metrics/__init__.py +10 -2
  602. mindspore/train/metrics/accuracy.py +1 -1
  603. mindspore/train/metrics/auc.py +1 -1
  604. mindspore/train/metrics/bleu_score.py +2 -2
  605. mindspore/train/metrics/confusion_matrix.py +14 -14
  606. mindspore/train/metrics/cosine_similarity.py +3 -3
  607. mindspore/train/metrics/dice.py +1 -1
  608. mindspore/train/metrics/fbeta.py +1 -1
  609. mindspore/train/metrics/hausdorff_distance.py +8 -6
  610. mindspore/train/metrics/mean_surface_distance.py +5 -4
  611. mindspore/train/metrics/metric.py +49 -17
  612. mindspore/train/metrics/occlusion_sensitivity.py +4 -4
  613. mindspore/train/metrics/perplexity.py +1 -1
  614. mindspore/train/metrics/precision.py +2 -2
  615. mindspore/train/metrics/recall.py +2 -3
  616. mindspore/train/metrics/roc.py +7 -7
  617. mindspore/train/metrics/root_mean_square_surface_distance.py +5 -4
  618. mindspore/train/metrics/topk.py +7 -4
  619. mindspore/train/mind_ir_pb2.py +193 -48
  620. mindspore/train/model.py +377 -133
  621. mindspore/train/serialization.py +697 -245
  622. mindspore/train/summary/_summary_adapter.py +5 -2
  623. mindspore/train/summary/_writer_pool.py +4 -3
  624. mindspore/train/summary/summary_record.py +25 -23
  625. mindspore/train/train_thor/convert_utils.py +39 -23
  626. mindspore/train/train_thor/dataset_helper.py +4 -3
  627. mindspore/train/train_thor/model_thor.py +8 -8
  628. mindspore/version.py +1 -1
  629. {mindspore-2.0.0rc1.dist-info → mindspore-2.2.0.dist-info}/METADATA +7 -8
  630. {mindspore-2.0.0rc1.dist-info → mindspore-2.2.0.dist-info}/RECORD +633 -804
  631. {mindspore-2.0.0rc1.dist-info → mindspore-2.2.0.dist-info}/entry_points.txt +0 -1
  632. mindspore/_akg/akg/tvm/contrib/debugger/__init__.py +0 -16
  633. mindspore/_akg/akg/tvm/contrib/debugger/debug_result.py +0 -274
  634. mindspore/_akg/akg/tvm/contrib/debugger/debug_runtime.py +0 -259
  635. mindspore/_akg/akg/tvm/contrib/peak.py +0 -341
  636. mindspore/_akg/akg/tvm/contrib/rpc.py +0 -25
  637. mindspore/_akg/akg/tvm/contrib/xcode.py +0 -257
  638. mindspore/_akg/akg/tvm/exec/__init__.py +0 -17
  639. mindspore/_akg/akg/tvm/exec/autotvm_log_editor.py +0 -60
  640. mindspore/_akg/akg/tvm/exec/measure_peak.py +0 -48
  641. mindspore/_akg/akg/tvm/exec/query_rpc_tracker.py +0 -48
  642. mindspore/_akg/akg/tvm/exec/rpc_proxy.py +0 -98
  643. mindspore/_akg/akg/tvm/exec/rpc_server.py +0 -88
  644. mindspore/_akg/akg/tvm/exec/rpc_tracker.py +0 -62
  645. mindspore/_akg/akg/tvm/rpc/__init__.py +0 -29
  646. mindspore/_akg/akg/tvm/rpc/base.py +0 -182
  647. mindspore/_akg/akg/tvm/rpc/client.py +0 -436
  648. mindspore/_akg/akg/tvm/rpc/proxy.py +0 -595
  649. mindspore/_akg/akg/tvm/rpc/server.py +0 -413
  650. mindspore/_akg/akg/tvm/rpc/tornado_util.py +0 -121
  651. mindspore/_akg/akg/tvm/rpc/tracker.py +0 -431
  652. mindspore/_extends/graph_kernel/expander.py +0 -80
  653. mindspore/_extends/graph_kernel/expanders/__init__.py +0 -57
  654. mindspore/_extends/graph_kernel/expanders/_utils.py +0 -269
  655. mindspore/_extends/graph_kernel/expanders/addn.py +0 -33
  656. mindspore/_extends/graph_kernel/expanders/batchnorm.py +0 -152
  657. mindspore/_extends/graph_kernel/expanders/batchnorm_grad.py +0 -105
  658. mindspore/_extends/graph_kernel/expanders/bias_add_grad.py +0 -49
  659. mindspore/_extends/graph_kernel/expanders/clip_by_norm_no_div_sum.py +0 -33
  660. mindspore/_extends/graph_kernel/expanders/complex/abs.py +0 -30
  661. mindspore/_extends/graph_kernel/expanders/complex/add.py +0 -44
  662. mindspore/_extends/graph_kernel/expanders/complex/div.py +0 -62
  663. mindspore/_extends/graph_kernel/expanders/complex/mul.py +0 -52
  664. mindspore/_extends/graph_kernel/expanders/complex/real_div.py +0 -62
  665. mindspore/_extends/graph_kernel/expanders/complex/sub.py +0 -45
  666. mindspore/_extends/graph_kernel/expanders/conv2d.py +0 -200
  667. mindspore/_extends/graph_kernel/expanders/dropout_grad.py +0 -30
  668. mindspore/_extends/graph_kernel/expanders/equal_count.py +0 -50
  669. mindspore/_extends/graph_kernel/expanders/erfc.py +0 -35
  670. mindspore/_extends/graph_kernel/expanders/expand_dims.py +0 -50
  671. mindspore/_extends/graph_kernel/expanders/fused_adam.py +0 -44
  672. mindspore/_extends/graph_kernel/expanders/fused_adam_weight_decay.py +0 -47
  673. mindspore/_extends/graph_kernel/expanders/fused_mul_add.py +0 -28
  674. mindspore/_extends/graph_kernel/expanders/gather.py +0 -43
  675. mindspore/_extends/graph_kernel/expanders/gelu_grad.py +0 -70
  676. mindspore/_extends/graph_kernel/expanders/gkdropout.py +0 -40
  677. mindspore/_extends/graph_kernel/expanders/identity.py +0 -25
  678. mindspore/_extends/graph_kernel/expanders/layernorm.py +0 -93
  679. mindspore/_extends/graph_kernel/expanders/layernorm_grad.py +0 -113
  680. mindspore/_extends/graph_kernel/expanders/logsoftmax.py +0 -46
  681. mindspore/_extends/graph_kernel/expanders/logsoftmax_grad.py +0 -36
  682. mindspore/_extends/graph_kernel/expanders/matmul.py +0 -80
  683. mindspore/_extends/graph_kernel/expanders/maximum_grad.py +0 -59
  684. mindspore/_extends/graph_kernel/expanders/minimum_grad.py +0 -80
  685. mindspore/_extends/graph_kernel/expanders/oneslike.py +0 -26
  686. mindspore/_extends/graph_kernel/expanders/reduce_mean.py +0 -43
  687. mindspore/_extends/graph_kernel/expanders/relu_grad.py +0 -32
  688. mindspore/_extends/graph_kernel/expanders/sigmoid_cross_entropy_with_logits.py +0 -41
  689. mindspore/_extends/graph_kernel/expanders/sigmoid_cross_entropy_with_logits_grad.py +0 -35
  690. mindspore/_extends/graph_kernel/expanders/sigmoid_grad.py +0 -31
  691. mindspore/_extends/graph_kernel/expanders/slice.py +0 -35
  692. mindspore/_extends/graph_kernel/expanders/softmax_cross_entropy_with_logits.py +0 -42
  693. mindspore/_extends/graph_kernel/expanders/softmax_grad_ext.py +0 -41
  694. mindspore/_extends/graph_kernel/expanders/softsign.py +0 -28
  695. mindspore/_extends/graph_kernel/expanders/sqrt_grad.py +0 -29
  696. mindspore/_extends/graph_kernel/expanders/square_sum_all.py +0 -44
  697. mindspore/_extends/graph_kernel/expanders/square_sum_v1.py +0 -37
  698. mindspore/_extends/graph_kernel/expanders/squared_difference.py +0 -43
  699. mindspore/_extends/graph_kernel/expanders/tanh_grad.py +0 -31
  700. mindspore/_extends/graph_kernel/expanders/tile.py +0 -54
  701. mindspore/_extends/graph_kernel/model/op_infer.py +0 -506
  702. mindspore/_extends/parse/jit_fallback_modules.py +0 -51
  703. mindspore/dataset/datapreprocess/preprocess_imagenet_validate_dataset.py +0 -54
  704. mindspore/dataset/engine/graphdata.py +0 -1586
  705. mindspore/include/api/net.h +0 -142
  706. mindspore/ops/_grad/grad_array_ops.py +0 -1347
  707. mindspore/ops/_grad/grad_clip_ops.py +0 -84
  708. mindspore/ops/_grad/grad_debug_ops.py +0 -68
  709. mindspore/ops/_grad/grad_inner_ops.py +0 -235
  710. mindspore/ops/_grad/grad_math_ops.py +0 -1684
  711. mindspore/ops/_grad/grad_nn_ops.py +0 -1529
  712. mindspore/ops/_grad/grad_other_ops.py +0 -89
  713. mindspore/ops/_grad/grad_sequence_ops.py +0 -296
  714. mindspore/ops/_grad/grad_sparse.py +0 -323
  715. mindspore/ops/_grad_experimental/grad_image_ops.py +0 -249
  716. mindspore/ops/_grad_experimental/grad_linalg_ops.py +0 -195
  717. mindspore/ops/_grad_experimental/grad_scalar_ops.py +0 -112
  718. mindspore/ops/bprop_mindir/AdaptiveAvgPool2D_bprop.mindir +0 -0
  719. mindspore/ops/bprop_mindir/AdaptiveMaxPool2D_bprop.mindir +0 -0
  720. mindspore/ops/bprop_mindir/ApproximateEqual_bprop.mindir +0 -19
  721. mindspore/ops/bprop_mindir/Argmax_bprop.mindir +0 -15
  722. mindspore/ops/bprop_mindir/Argmin_bprop.mindir +0 -15
  723. mindspore/ops/bprop_mindir/AssignSub_bprop.mindir +0 -19
  724. mindspore/ops/bprop_mindir/Assign_bprop.mindir +0 -17
  725. mindspore/ops/bprop_mindir/AvgPool3D_bprop.mindir +0 -150
  726. mindspore/ops/bprop_mindir/AvgPool_bprop.mindir +0 -66
  727. mindspore/ops/bprop_mindir/BCEWithLogitsLoss_bprop.mindir +0 -0
  728. mindspore/ops/bprop_mindir/BNTrainingReduce_bprop.mindir +0 -15
  729. mindspore/ops/bprop_mindir/BatchNormGrad_bprop.mindir +0 -0
  730. mindspore/ops/bprop_mindir/BatchToSpaceND_bprop.mindir +0 -28
  731. mindspore/ops/bprop_mindir/BiasAddGrad_bprop.mindir +0 -0
  732. mindspore/ops/bprop_mindir/BinaryCrossEntropy_bprop.mindir +0 -33
  733. mindspore/ops/bprop_mindir/BroadcastTo_bprop.mindir +0 -306
  734. mindspore/ops/bprop_mindir/Broadcast_bprop.mindir +0 -13
  735. mindspore/ops/bprop_mindir/CTCLoss_bprop.mindir +0 -0
  736. mindspore/ops/bprop_mindir/Concat_bprop.mindir +0 -0
  737. mindspore/ops/bprop_mindir/Conv2DBackpropFilter_bprop.mindir +0 -240
  738. mindspore/ops/bprop_mindir/Conv2DBackpropInput_bprop.mindir +0 -247
  739. mindspore/ops/bprop_mindir/Conv2DTranspose_bprop.mindir +0 -247
  740. mindspore/ops/bprop_mindir/Conv3DTranspose_bprop.mindir +0 -315
  741. mindspore/ops/bprop_mindir/Conv3D_bprop.mindir +0 -278
  742. mindspore/ops/bprop_mindir/DType_bprop.mindir +0 -14
  743. mindspore/ops/bprop_mindir/DeformableOffsets_bprop.mindir +0 -58
  744. mindspore/ops/bprop_mindir/Depend_bprop.mindir +0 -13
  745. mindspore/ops/bprop_mindir/DepthToSpace_bprop.mindir +0 -23
  746. mindspore/ops/bprop_mindir/DepthwiseConv2dNative_bprop.mindir +0 -138
  747. mindspore/ops/bprop_mindir/DiagPart_bprop.mindir +0 -15
  748. mindspore/ops/bprop_mindir/Dropout2D_bprop.mindir +0 -0
  749. mindspore/ops/bprop_mindir/Dropout3D_bprop.mindir +0 -0
  750. mindspore/ops/bprop_mindir/DropoutDoMask_bprop.mindir +0 -25
  751. mindspore/ops/bprop_mindir/DropoutGenMask_bprop.mindir +0 -18
  752. mindspore/ops/bprop_mindir/DropoutGrad_bprop.mindir +0 -27
  753. mindspore/ops/bprop_mindir/Dropout_bprop.mindir +0 -0
  754. mindspore/ops/bprop_mindir/DynamicGRUV2_bprop.mindir +0 -0
  755. mindspore/ops/bprop_mindir/DynamicRNN_bprop.mindir +0 -0
  756. mindspore/ops/bprop_mindir/DynamicShape_bprop.mindir +0 -14
  757. mindspore/ops/bprop_mindir/Elu_bprop.mindir +0 -16
  758. mindspore/ops/bprop_mindir/EmbeddingLookup_bprop.mindir +0 -0
  759. mindspore/ops/bprop_mindir/Equal_bprop.mindir +0 -19
  760. mindspore/ops/bprop_mindir/ExpandDims_bprop.mindir +0 -58
  761. mindspore/ops/bprop_mindir/FastGeLU_bprop.mindir +0 -16
  762. mindspore/ops/bprop_mindir/Flatten_bprop.mindir +0 -54
  763. mindspore/ops/bprop_mindir/FloorDiv_bprop.mindir +0 -19
  764. mindspore/ops/bprop_mindir/GatherD_bprop.mindir +0 -26
  765. mindspore/ops/bprop_mindir/GatherNd_bprop.mindir +0 -57
  766. mindspore/ops/bprop_mindir/Gather_bprop.mindir +0 -0
  767. mindspore/ops/bprop_mindir/GreaterEqual_bprop.mindir +0 -19
  768. mindspore/ops/bprop_mindir/Greater_bprop.mindir +0 -19
  769. mindspore/ops/bprop_mindir/HSigmoid_bprop.mindir +0 -16
  770. mindspore/ops/bprop_mindir/HSwish_bprop.mindir +0 -16
  771. mindspore/ops/bprop_mindir/IOU_bprop.mindir +0 -19
  772. mindspore/ops/bprop_mindir/InstanceNorm_bprop.mindir +0 -0
  773. mindspore/ops/bprop_mindir/IsFinite_bprop.mindir +0 -15
  774. mindspore/ops/bprop_mindir/IsInf_bprop.mindir +0 -15
  775. mindspore/ops/bprop_mindir/IsNan_bprop.mindir +0 -15
  776. mindspore/ops/bprop_mindir/KLDivLoss_bprop.mindir +0 -126
  777. mindspore/ops/bprop_mindir/L2Loss_bprop.mindir +0 -15
  778. mindspore/ops/bprop_mindir/L2Normalize_bprop.mindir +0 -30
  779. mindspore/ops/bprop_mindir/LRN_bprop.mindir +0 -43
  780. mindspore/ops/bprop_mindir/LayerNormGrad_bprop.mindir +0 -0
  781. mindspore/ops/bprop_mindir/LessEqual_bprop.mindir +0 -19
  782. mindspore/ops/bprop_mindir/Less_bprop.mindir +0 -19
  783. mindspore/ops/bprop_mindir/LinSpace_bprop.mindir +0 -23
  784. mindspore/ops/bprop_mindir/Load_bprop.mindir +0 -13
  785. mindspore/ops/bprop_mindir/LogSoftmax_bprop.mindir +0 -23
  786. mindspore/ops/bprop_mindir/LogicalAnd_bprop.mindir +0 -19
  787. mindspore/ops/bprop_mindir/LogicalNot_bprop.mindir +0 -15
  788. mindspore/ops/bprop_mindir/MaskedSelect_bprop.mindir +0 -21
  789. mindspore/ops/bprop_mindir/MaxPool3DGradGrad_bprop.mindir +0 -74
  790. mindspore/ops/bprop_mindir/MaxPool3DGrad_bprop.mindir +0 -74
  791. mindspore/ops/bprop_mindir/MaxPool3D_bprop.mindir +0 -75
  792. mindspore/ops/bprop_mindir/MaxPoolGradGrad_bprop.mindir +0 -65
  793. mindspore/ops/bprop_mindir/MaxPoolWithArgmax_bprop.mindir +0 -0
  794. mindspore/ops/bprop_mindir/Maximum_bprop.mindir +0 -0
  795. mindspore/ops/bprop_mindir/Minimum_bprop.mindir +0 -0
  796. mindspore/ops/bprop_mindir/MirrorPad_bprop.mindir +0 -27
  797. mindspore/ops/bprop_mindir/Mish_bprop.mindir +0 -35
  798. mindspore/ops/bprop_mindir/MulNoNan_bprop.mindir +0 -0
  799. mindspore/ops/bprop_mindir/NLLLoss_bprop.mindir +0 -0
  800. mindspore/ops/bprop_mindir/NonZero_bprop.mindir +0 -14
  801. mindspore/ops/bprop_mindir/NotEqual_bprop.mindir +0 -19
  802. mindspore/ops/bprop_mindir/OneHot_bprop.mindir +0 -26
  803. mindspore/ops/bprop_mindir/OnesLike_bprop.mindir +0 -14
  804. mindspore/ops/bprop_mindir/PReLU_bprop.mindir +0 -0
  805. mindspore/ops/bprop_mindir/Pad_bprop.mindir +0 -0
  806. mindspore/ops/bprop_mindir/Padding_bprop.mindir +0 -0
  807. mindspore/ops/bprop_mindir/RNNTLoss_bprop.mindir +0 -29
  808. mindspore/ops/bprop_mindir/ROIAlign_bprop.mindir +0 -82
  809. mindspore/ops/bprop_mindir/Range_bprop.mindir +0 -22
  810. mindspore/ops/bprop_mindir/Rank_bprop.mindir +0 -14
  811. mindspore/ops/bprop_mindir/ReLU6_bprop.mindir +0 -16
  812. mindspore/ops/bprop_mindir/ReLUV2_bprop.mindir +0 -0
  813. mindspore/ops/bprop_mindir/ReduceAll_bprop.mindir +0 -19
  814. mindspore/ops/bprop_mindir/ReduceAny_bprop.mindir +0 -19
  815. mindspore/ops/bprop_mindir/ReluGrad_bprop.mindir +0 -20
  816. mindspore/ops/bprop_mindir/Reshape_bprop.mindir +0 -60
  817. mindspore/ops/bprop_mindir/ResizeBilinear_bprop.mindir +0 -29
  818. mindspore/ops/bprop_mindir/ResizeNearestNeighbor_bprop.mindir +0 -89
  819. mindspore/ops/bprop_mindir/ReverseSequence_bprop.mindir +0 -52
  820. mindspore/ops/bprop_mindir/ReverseV2_bprop.mindir +0 -22
  821. mindspore/ops/bprop_mindir/Round_bprop.mindir +0 -15
  822. mindspore/ops/bprop_mindir/ScatterMax_bprop.mindir +0 -0
  823. mindspore/ops/bprop_mindir/ScatterMin_bprop.mindir +0 -0
  824. mindspore/ops/bprop_mindir/ScatterNdUpdate_bprop.mindir +0 -22
  825. mindspore/ops/bprop_mindir/ScatterNd_bprop.mindir +0 -24
  826. mindspore/ops/bprop_mindir/ScatterNonAliasingAdd_bprop.mindir +0 -22
  827. mindspore/ops/bprop_mindir/ScatterUpdate_bprop.mindir +0 -0
  828. mindspore/ops/bprop_mindir/SeLU_bprop.mindir +0 -21
  829. mindspore/ops/bprop_mindir/Select_bprop.mindir +0 -31
  830. mindspore/ops/bprop_mindir/Shape_bprop.mindir +0 -14
  831. mindspore/ops/bprop_mindir/SigmoidCrossEntropyWithLogits_bprop.mindir +0 -21
  832. mindspore/ops/bprop_mindir/SigmoidGrad_bprop.mindir +0 -0
  833. mindspore/ops/bprop_mindir/Sigmoid_bprop.mindir +0 -16
  834. mindspore/ops/bprop_mindir/Sign_bprop.mindir +0 -15
  835. mindspore/ops/bprop_mindir/Slice_bprop.mindir +0 -26
  836. mindspore/ops/bprop_mindir/SmoothL1Loss_bprop.mindir +0 -36
  837. mindspore/ops/bprop_mindir/SoftmaxCrossEntropyWithLogits_bprop.mindir +0 -0
  838. mindspore/ops/bprop_mindir/Softplus_bprop.mindir +0 -16
  839. mindspore/ops/bprop_mindir/Softsign_bprop.mindir +0 -33
  840. mindspore/ops/bprop_mindir/Sort_bprop.mindir +0 -0
  841. mindspore/ops/bprop_mindir/SpaceToBatchND_bprop.mindir +0 -28
  842. mindspore/ops/bprop_mindir/SpaceToDepth_bprop.mindir +0 -23
  843. mindspore/ops/bprop_mindir/SparseGatherV2_bprop.mindir +0 -0
  844. mindspore/ops/bprop_mindir/SparseSoftmaxCrossEntropyWithLogits_bprop.mindir +0 -0
  845. mindspore/ops/bprop_mindir/Split_bprop.mindir +0 -22
  846. mindspore/ops/bprop_mindir/Squeeze_bprop.mindir +0 -54
  847. mindspore/ops/bprop_mindir/StridedSliceGrad_bprop.mindir +0 -95
  848. mindspore/ops/bprop_mindir/StridedSlice_bprop.mindir +0 -98
  849. mindspore/ops/bprop_mindir/Switch_bprop.mindir +0 -29
  850. mindspore/ops/bprop_mindir/TanhGrad_bprop.mindir +0 -0
  851. mindspore/ops/bprop_mindir/Tanh_bprop.mindir +0 -66
  852. mindspore/ops/bprop_mindir/TensorScatterAdd_bprop.mindir +0 -22
  853. mindspore/ops/bprop_mindir/TensorScatterUpdate_bprop.mindir +0 -29
  854. mindspore/ops/bprop_mindir/TensorShape_bprop.mindir +0 -14
  855. mindspore/ops/bprop_mindir/Tile_bprop.mindir +0 -0
  856. mindspore/ops/bprop_mindir/TopK_bprop.mindir +0 -0
  857. mindspore/ops/bprop_mindir/TransShape_bprop.mindir +0 -23
  858. mindspore/ops/bprop_mindir/TruncateDiv_bprop.mindir +0 -19
  859. mindspore/ops/bprop_mindir/TupleGetItem_bprop.mindir +0 -20
  860. mindspore/ops/bprop_mindir/Unique_bprop.mindir +0 -16
  861. mindspore/ops/bprop_mindir/Unstack_bprop.mindir +0 -22
  862. mindspore/ops/bprop_mindir/UpsampleNearest3D_bprop.mindir +0 -32
  863. mindspore/ops/bprop_mindir/UpsampleTrilinear3D_bprop.mindir +0 -38
  864. mindspore/ops/bprop_mindir/ZerosLike_bprop.mindir +0 -15
  865. mindspore/ops/bprop_mindir/generate_mindir.py +0 -114
  866. mindspore/rewrite/node_visitor.py +0 -44
  867. mindspore/rewrite/topological_manager.py +0 -203
  868. mindspore/scipy/sparse/linalg.py +0 -192
  869. {mindspore-2.0.0rc1.dist-info → mindspore-2.2.0.dist-info}/WHEEL +0 -0
  870. {mindspore-2.0.0rc1.dist-info → mindspore-2.2.0.dist-info}/top_level.txt +0 -0
mindspore/context.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2020-2022 Huawei Technologies Co., Ltd
1
+ # Copyright 2020-2023 Huawei Technologies Co., Ltd
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -35,16 +35,21 @@ from mindspore.parallel._ps_context import _set_ps_context, _get_ps_context, _re
35
35
  _need_reset_device_target_for_ps
36
36
  from mindspore.parallel._offload_context import _set_offload_context, _get_offload_context
37
37
 
38
- __all__ = ['GRAPH_MODE', 'PYNATIVE_MODE', 'set_context', 'get_context', 'set_auto_parallel_context',
39
- 'get_auto_parallel_context', 'reset_auto_parallel_context', 'ParallelMode', 'set_ps_context',
40
- 'get_ps_context', 'reset_ps_context', 'set_offload_context', 'get_offload_context']
38
+ __all__ = ['GRAPH_MODE', 'PYNATIVE_MODE', 'STRICT', 'COMPATIBLE', 'LAX', 'set_context', 'get_context',
39
+ 'set_auto_parallel_context', 'get_auto_parallel_context', 'reset_auto_parallel_context', 'ParallelMode',
40
+ 'set_ps_context', 'get_ps_context', 'reset_ps_context', 'set_offload_context', 'get_offload_context']
41
41
 
42
42
  GRAPH_MODE = 0
43
43
  PYNATIVE_MODE = 1
44
44
  _DEVICE_APP_MEMORY_SIZE = 31 # The max memory size of graph plus variable.
45
- _re_pattern = r'[1-9][0-9]*(\.)?[0-9]*GB|0\.[0-9]*GB'
45
+ _RE_PATTERN = r'[1-9][0-9]*(\.)?[0-9]*GB|0\.[0-9]*GB'
46
46
  K_CONTEXT = None
47
47
 
48
+ # Enumerate for the property 'jit_syntax_level'.
49
+ STRICT = 0
50
+ COMPATIBLE = 1
51
+ LAX = 2
52
+
48
53
 
49
54
  def _make_directory(path):
50
55
  """Make directory."""
@@ -156,7 +161,6 @@ class _Context:
156
161
  self._context_switches = _ContextSwitchInfo(False)
157
162
  self._context_handle = MSContext.get_instance()
158
163
  self._support_binary = False
159
- self.enable_compile_cache = None
160
164
 
161
165
  def __getattribute__(self, attr):
162
166
  value = object.__getattribute__(self, attr)
@@ -201,6 +205,13 @@ class _Context:
201
205
  f"or context.PYNATIVE_MODE (1), but got {mode}.")
202
206
  self.set_param(ms_ctx_param.mode, mode)
203
207
 
208
+ def set_jit_syntax_level(self, level):
209
+ """"Set the JIT syntax level for graph compiling"""
210
+ if level != STRICT and level != COMPATIBLE and level != LAX:
211
+ raise ValueError(f"For 'context.set_jit_syntax_level', the argument 'level' should be context.STRICT "
212
+ f"or context.LAX, but got {level}.")
213
+ self.set_param(ms_ctx_param.jit_syntax_level, level)
214
+
204
215
  def set_memory_optimize_level(self, memory_optimize_level):
205
216
  """
206
217
  The memory optimize level, support "O0", "O1".
@@ -251,32 +262,91 @@ class _Context:
251
262
  Enable ascend config.
252
263
 
253
264
  Args:
254
- ascend_config (dict): 'precision_mode'
265
+ ascend_config (dict):
255
266
  - precision_mode (str): "force_fp16", "allow_fp32_to_fp16", "allow_mix_precision",
256
- "must_keep_origin_dtype", "force_fp32", "force_lowerprecision", "allow_fp32_to_bf16",
257
- "allow_fp32_to_lowprecision", "allow_mix_precision_fp16" and "allow_mix_precision_bf16".
267
+ "must_keep_origin_dtype", "force_fp32", "allow_fp32_to_bf16",
268
+ "allow_mix_precision_fp16" and "allow_mix_precision_bf16".
269
+ - jit_compile (bool): ``False`` and ``True``.
270
+ - atomic_clean_policy (int): ``0`` and ``1``. Default: ``1`` .
271
+ - op_precision_mode (str): config file path.
272
+ - parallel_speed_up_json_path(Union[str, None]): The path to the parallel speed up json file.
273
+ If its value is None or '', it does not take effect. Default None.
258
274
  """
259
-
260
- ascend_cfgs = {'precision_mode': ["force_fp16", "allow_fp32_to_fp16", "allow_mix_precision",
261
- "must_keep_origin_dtype", "force_fp32", "force_lowerprecision",
262
- "allow_fp32_to_bf16", "allow_fp32_to_lowprecision",
263
- "allow_mix_precision_fp16", "allow_mix_precision_bf16"],
264
- 'jit_compile': [True, False]}
265
- for ascend_key in ascend_config:
266
- if ascend_key not in ascend_cfgs:
275
+ ascend_cfg_modes = {
276
+ 'precision_mode': ["force_fp16", "allow_fp32_to_fp16", "allow_mix_precision", "must_keep_origin_dtype",
277
+ "force_fp32", "allow_fp32_to_bf16", "allow_mix_precision_fp16",
278
+ "allow_mix_precision_bf16"],
279
+ 'jit_compile': [True, False],
280
+ 'atomic_clean_policy': [0, 1],
281
+ 'matmul_allow_hf32': [True, False],
282
+ 'conv_allow_hf32': [True, False],
283
+ 'op_precision_mode': (str,),
284
+ 'parallel_speed_up_json_path': (str, None)
285
+ }
286
+ ascend_cfg_setters = {
287
+ 'precision_mode': self._get_ascend_config_setter('precision_mode'),
288
+ 'jit_compile': self._get_ascend_config_setter('jit_compile', lambda v: "1" if v else "0"),
289
+ 'atomic_clean_policy': self._get_ascend_config_setter('atomic_clean_policy', str),
290
+ 'matmul_allow_hf32': self._get_ascend_config_setter('matmul_allow_hf32', lambda v: "1" if v else "0"),
291
+ 'conv_allow_hf32': self._get_ascend_config_setter('conv_allow_hf32', lambda v: "1" if v else "0"),
292
+ 'op_precision_mode': self._set_op_precision_mode,
293
+ 'parallel_speed_up_json_path': self._set_speedup_config_path
294
+ }
295
+ ascend_cfg_set = tuple(ascend_cfg_modes.keys())
296
+ for ascend_key, ascend_value in ascend_config.items():
297
+ if ascend_key not in ascend_cfg_set:
267
298
  raise ValueError(f"For 'context.set_context', the key of argument 'ascend_config' must be one of "
268
- f"{ascend_cfgs}, but got {ascend_key}.")
269
- supported_modes = ascend_cfgs.get(ascend_key)
270
- if ascend_config[ascend_key] not in supported_modes:
299
+ f"{ascend_cfg_set}, but got {ascend_key}.")
300
+ supported_modes = ascend_cfg_modes.get(ascend_key)
301
+ if isinstance(supported_modes, list) and ascend_value not in supported_modes:
271
302
  raise ValueError(f"For 'ascend_config', the value of argument {ascend_key} must be one of "
272
- f"{supported_modes}, but got {ascend_config[ascend_key]}.")
273
- if ascend_key == 'precision_mode':
274
- self.set_param(ms_ctx_param.precision_mode, ascend_config[ascend_key])
275
- if ascend_key == 'jit_compile':
276
- if ascend_config[ascend_key] is True:
277
- self.set_param(ms_ctx_param.jit_compile, "1")
278
- else:
279
- self.set_param(ms_ctx_param.jit_compile, "0")
303
+ f"{supported_modes}, but got {ascend_value}.")
304
+ if isinstance(supported_modes, tuple) and not isinstance(ascend_value, supported_modes):
305
+ raise TypeError(f"For 'ascend_config', the type of argument {ascend_key} must be one of "
306
+ f"{supported_modes}, but got {type(ascend_value)}.")
307
+ cfg_setter = ascend_cfg_setters.get(ascend_key)
308
+ cfg_setter(ascend_value)
309
+
310
+ def set_gpu_config(self, gpu_config):
311
+ """
312
+ Enable gpu config.
313
+
314
+ Args:
315
+ gpu_config (dict):
316
+
317
+ - conv_fprop_algo (str): "normal", "performance" or user specifies conv forward algorithm directly.
318
+ - conv_dgrad_algo (str): "normal", "performance" or user specifies conv data grad algorithm directly.
319
+ - conv_wgrad_algo (str): "normal", "performance" or user specifies conv weight grad algorithm directly.
320
+ - conv_allow_tf32 (bool): ``False`` and ``True``.
321
+ - matmul_allow_tf32 (bool): ``False`` and ``True``.
322
+ """
323
+
324
+ gpu_cfgs = {'conv_fprop_algo': ["normal", "performance", "implicit_gemm", "precomp_gemm", "gemm", "direct",
325
+ "fft", "fft_tiling", "winograd", "winograd_nonfused"],
326
+ 'conv_dgrad_algo': ["normal", "performance", "algo_0", "algo_1", "fft", "fft_tiling", "winograd",
327
+ "winograd_nonfused"],
328
+ 'conv_wgrad_algo': ["normal", "performance", "algo_0", "algo_1", "fft", "algo_3", "fft_tiling",
329
+ "winograd_nonfused"],
330
+ 'conv_allow_tf32': [True, False],
331
+ 'matmul_allow_tf32': [True, False]}
332
+ for gpu_key in gpu_config:
333
+ if gpu_key not in gpu_cfgs:
334
+ raise ValueError(f"For 'context.set_context', the key of argument 'gpu_config' must be one of "
335
+ f"{gpu_cfgs}, but got {gpu_key}.")
336
+ supported_value = gpu_cfgs.get(gpu_key)
337
+ if gpu_config[gpu_key] not in supported_value:
338
+ raise ValueError(f"For 'gpu_config', the value of argument {gpu_key} must be one of "
339
+ f"{supported_value}, but got {gpu_config[gpu_key]}.")
340
+ if gpu_key == 'conv_fprop_algo':
341
+ self.set_param(ms_ctx_param.conv_fprop_algo, gpu_config[gpu_key])
342
+ if gpu_key == 'conv_dgrad_algo':
343
+ self.set_param(ms_ctx_param.conv_dgrad_algo, gpu_config[gpu_key])
344
+ if gpu_key == 'conv_wgrad_algo':
345
+ self.set_param(ms_ctx_param.conv_wgrad_algo, gpu_config[gpu_key])
346
+ if gpu_key == 'conv_allow_tf32':
347
+ self.set_param(ms_ctx_param.conv_allow_tf32, gpu_config[gpu_key])
348
+ if gpu_key == 'matmul_allow_tf32':
349
+ self.set_param(ms_ctx_param.matmul_allow_tf32, gpu_config[gpu_key])
280
350
 
281
351
  def set_backend_policy(self, policy):
282
352
  success = self._context_handle.set_backend_policy(policy)
@@ -312,13 +382,42 @@ class _Context:
312
382
  if self.enable_debug_runtime and target == "CPU":
313
383
  self.set_backend_policy("vm")
314
384
 
315
- def set_auto_tune_mode(self, tune_mode):
316
- candidate = ["NO_TUNE", "RL", "GA", "RL,GA", "GA,RL"]
385
+ def set_aoe_tune_mode(self, tune_mode):
386
+ """
387
+ Set aoe tune mode, support "online" and "offline".
388
+
389
+ Args:
390
+ tune_mode (str): "online" and "offline".
391
+ """
392
+ candidate = ["online", "offline"]
317
393
  if tune_mode in candidate:
318
- self.set_param(ms_ctx_param.auto_tune_mode, tune_mode)
394
+ self.set_param(ms_ctx_param.aoe_tune_mode, tune_mode)
319
395
  else:
320
- raise ValueError(f"For 'context.set_context', the argument 'auto_tune_mode' must be in "
321
- f"['NO_TUNE', 'RL', 'GA', 'RL,GA', 'GA,RL'], but got {tune_mode}.")
396
+ raise ValueError(f"For 'context.set_context', the argument 'aoe_tune_mode' must be in "
397
+ f"['online', 'offline'], but got {tune_mode}.")
398
+
399
+ def set_aoe_config(self, aoe_config):
400
+ """
401
+ Enable aoe config.
402
+
403
+ Args:
404
+ aoe_config (dict):
405
+ - job_type (str): ``"1"``, ``"2"``. Default: ``"2"`` .
406
+ - ``"1"``: subgraph tuning.
407
+ - ``"2"``: operator tuning.
408
+ """
409
+
410
+ aoe_cfgs = {'job_type': ["1", "2"]}
411
+ for aoe_config_key in aoe_config:
412
+ if aoe_config_key not in aoe_cfgs:
413
+ raise ValueError(f"For 'context.set_context', the key of argument 'aoe_config' must be one of "
414
+ f"{aoe_cfgs}, but got {aoe_config_key}.")
415
+ supported_value = aoe_cfgs.get(aoe_config_key)
416
+ if aoe_config[aoe_config_key] not in supported_value:
417
+ raise ValueError(f"For 'aoe_config', the value of argument {aoe_config_key} must be one of "
418
+ f"{supported_value}, but got {aoe_config[aoe_config_key]}.")
419
+ if aoe_config_key == 'job_type':
420
+ self.set_param(ms_ctx_param.aoe_job_type, aoe_config[aoe_config_key])
322
421
 
323
422
  def set_device_id(self, device_id):
324
423
  if device_id < 0 or device_id > 4095:
@@ -343,14 +442,14 @@ class _Context:
343
442
  logger.warning("For 'context.set_context', the parameter 'variable_memory_max_size' is deprecated, "
344
443
  "and will be removed in a future "
345
444
  "version. Please use parameter 'max_device_memory' instead.")
346
- if not Validator.check_str_by_regular(variable_memory_max_size, _re_pattern):
445
+ if not Validator.check_str_by_regular(variable_memory_max_size, _RE_PATTERN):
347
446
  raise ValueError("For 'context.set_context', the argument 'variable_memory_max_size' should be in correct"
348
447
  " format! It must be a string ending with 'GB', in addition to that, it must contain "
349
- "only numbers or decimal points, such as \"5GB\" or \"3.5GB\", but got {}."
448
+ "only numbers or decimal points, such as \"5GB\" or \"3.5GB\", but got {}GB."
350
449
  .format(variable_memory_max_size))
351
450
  if float(variable_memory_max_size[:-2]) > _DEVICE_APP_MEMORY_SIZE:
352
451
  raise ValueError("For 'context.set_context', the argument 'variable_memory_max_size' should not be "
353
- "greater than 31GB, but got {}.".format(variable_memory_max_size))
452
+ "greater than 31GB, but got {}GB.".format(variable_memory_max_size))
354
453
  variable_memory_max_size_ = variable_memory_max_size[:-2] + " * 1024 * 1024 * 1024"
355
454
  graph_memory_max_size = _DEVICE_APP_MEMORY_SIZE - int(variable_memory_max_size[:-2])
356
455
  graph_memory_max_size_ = str(graph_memory_max_size) + " * 1024 * 1024 * 1024"
@@ -358,7 +457,7 @@ class _Context:
358
457
  self.set_param(ms_ctx_param._graph_memory_max_size, graph_memory_max_size_)
359
458
 
360
459
  def set_max_device_memory(self, max_device_memory):
361
- if not Validator.check_str_by_regular(max_device_memory, _re_pattern):
460
+ if not Validator.check_str_by_regular(max_device_memory, _RE_PATTERN):
362
461
  raise ValueError("For 'context.set_context', the argument 'max_device_memory' should be in correct "
363
462
  " format! It must be a string ending with 'GB', in addition to that, it must contain "
364
463
  "only numbers or decimal points, such as \"5GB\" or \"3.5GB\", but got {}."
@@ -374,7 +473,7 @@ class _Context:
374
473
  logger.warning("Graph mode doesn't support to set parameter 'mempool_block_size' of context currently, "
375
474
  "you can use context.set_context to set pynative mode.")
376
475
  return
377
- if not Validator.check_str_by_regular(mempool_block_size, _re_pattern):
476
+ if not Validator.check_str_by_regular(mempool_block_size, _RE_PATTERN):
378
477
  raise ValueError("For 'context.set_context', the argument 'mempool_block_size' should be in "
379
478
  "correct format! Such as \"10GB\", "
380
479
  "but got {}".format(mempool_block_size))
@@ -416,7 +515,7 @@ class _Context:
416
515
  except (TypeError, ValueError) as exo:
417
516
  raise ValueError(str(exo) + "\nFor 'context.set_context', open or load the 'env_config_path' file {} "
418
517
  "failed, please check whether 'env_config_path' is json file and correct, "
419
- "or may not have permission to read it.".format(env_config_path))
518
+ "or may not have permission to read it.".format(env_config_path)) from exo
420
519
  self.set_param(ms_ctx_param.env_config_path, env_config_path)
421
520
 
422
521
  def set_runtime_num_threads(self, runtime_num_threads):
@@ -441,8 +540,8 @@ class _Context:
441
540
  'mode': set_mode,
442
541
  'save_graphs_path': set_save_graphs_path,
443
542
  'device_target': set_device_target,
543
+ 'aoe_tune_mode': set_aoe_tune_mode,
444
544
  'device_id': set_device_id,
445
- 'auto_tune_mode': set_auto_tune_mode,
446
545
  'max_call_depth': set_max_call_depth,
447
546
  'profiling_options': set_profiling_options,
448
547
  'variable_memory_max_size': set_variable_memory_max_size,
@@ -456,7 +555,10 @@ class _Context:
456
555
  'op_timeout': set_op_timeout,
457
556
  'memory_offload': set_memory_offload,
458
557
  'deterministic': set_deterministic,
459
- 'ascend_config': set_ascend_config
558
+ 'ascend_config': set_ascend_config,
559
+ 'jit_syntax_level': set_jit_syntax_level,
560
+ 'gpu_config': set_gpu_config,
561
+ 'aoe_config': set_aoe_config,
460
562
  }
461
563
 
462
564
  @property
@@ -496,6 +598,55 @@ class _Context:
496
598
  raise TypeError(f"The attribute 'support_binary' should be a bool, but got {type(support)}.")
497
599
  self._support_binary = support
498
600
 
601
+ def _get_ascend_config_setter(self, ascend_key, trans_fn=None):
602
+ def _config_setter(ascend_value):
603
+ self.set_param(ms_ctx_param.__members__[ascend_key], trans_fn(ascend_value))
604
+
605
+ if trans_fn is None:
606
+ trans_fn = lambda x: x
607
+ return _config_setter
608
+
609
+ def _set_op_precision_mode(self, ascend_value):
610
+ op_precision_path = ascend_value
611
+ real_path = os.path.realpath(op_precision_path)
612
+ if not os.path.exists(real_path):
613
+ raise ValueError(f"For 'ascend_config', the 'op_precision_mode' is invalid path, "
614
+ f"got '{op_precision_path}'.")
615
+ self.set_param(ms_ctx_param.op_precision_mode, ascend_value)
616
+
617
+ def _set_speedup_config_path(self, speedup_config_path):
618
+ """"Check and set speedup config for auto parallel."""
619
+ if speedup_config_path is None or speedup_config_path == "":
620
+ return
621
+ speedup_config_real_path = os.path.abspath(speedup_config_path)
622
+ if not os.path.exists(speedup_config_real_path):
623
+ raise ValueError(f"For 'ascend_config', the path to parallel_speed_up_json: "
624
+ f"{speedup_config_real_path} does not exist, please check whether the "
625
+ f"'parallel_speed_up_json_path' is correct.")
626
+ try:
627
+ valid_option = {"recompute_comm_overlap": ms_ctx_param.recompute_comm_overlap,
628
+ "matmul_grad_comm_overlap": ms_ctx_param.matmul_grad_comm_overlap,
629
+ "enable_task_opt": ms_ctx_param.enable_task_opt,
630
+ "enable_grad_comm_opt": ms_ctx_param.enable_grad_comm_opt,
631
+ "interleaved_matmul_comm": ms_ctx_param.interleaved_matmul_comm,
632
+ "interleaved_layernorm_comm": ms_ctx_param.interleaved_layernorm_comm}
633
+ with open(speedup_config_real_path, 'r') as f:
634
+ speedup_config = json.load(f)
635
+ for k, v in speedup_config.items():
636
+ if not isinstance(k, str):
637
+ raise TypeError("key {} is not a str".format(k))
638
+ if k not in valid_option:
639
+ raise ValueError("key {} should be one of {}.".format(k, valid_option.keys()))
640
+ if not isinstance(v, bool):
641
+ raise TypeError("value {} is not a bool".format(v))
642
+ self.set_param(valid_option.get(k), v)
643
+ except (TypeError, ValueError) as exo:
644
+ raise ValueError(str(exo) + "\nFor 'context.set_context', "
645
+ "open or load the 'speedup_config_path' file {} "
646
+ "failed, please check whether 'speedup_config_path' is json file and correct, "
647
+ "or may not have permission to read it.".format(speedup_config_real_path)) \
648
+ from exo
649
+
499
650
 
500
651
  def _context():
501
652
  """
@@ -524,8 +675,9 @@ def _context():
524
675
  @args_type_check(device_num=int, global_rank=int, gradients_mean=bool, gradient_fp32_sync=bool, parallel_mode=str,
525
676
  auto_parallel_search_mode=str, search_mode=str, parameter_broadcast=bool, strategy_ckpt_load_file=str,
526
677
  strategy_ckpt_save_file=str, full_batch=bool, enable_parallel_optimizer=bool, enable_alltoall=bool,
527
- all_reduce_fusion_config=list, pipeline_stages=int, grad_accumulation_step=int,
528
- parallel_optimizer_config=dict, comm_fusion=dict, strategy_ckpt_config=dict)
678
+ all_reduce_fusion_config=list, pipeline_stages=int, pipeline_segments=int,
679
+ parallel_optimizer_config=dict,
680
+ comm_fusion=dict, strategy_ckpt_config=dict)
529
681
  def set_auto_parallel_context(**kwargs):
530
682
  r"""
531
683
  Set auto parallel context, only data parallel supported on CPU.
@@ -546,26 +698,26 @@ def set_auto_parallel_context(**kwargs):
546
698
  device_num gradient_fp32_sync
547
699
  global_rank loss_repeated_mean
548
700
  gradients_mean search_mode
549
- parallel_mode strategy_ckpt_load_file
550
- all_reduce_fusion_config strategy_ckpt_save_file
551
- enable_parallel_optimizer dataset_strategy
552
- parallel_optimizer_config pipeline_stages
553
- enable_alltoall grad_accumulation_step
701
+ parallel_mode parameter_broadcast
702
+ all_reduce_fusion_config strategy_ckpt_load_file
703
+ enable_parallel_optimizer strategy_ckpt_save_file
704
+ parallel_optimizer_config dataset_strategy
705
+ enable_alltoall pipeline_stages
554
706
  \ auto_parallel_search_mode
555
707
  \ comm_fusion
556
708
  \ strategy_ckpt_config
557
709
  =========================== ===========================
558
710
 
559
711
  Args:
560
- device_num (int): Available device number, the value must be in [1, 4096]. Default: 1.
561
- global_rank (int): Global rank id, the value must be in [0, 4095]. Default: 0.
712
+ device_num (int): Available device number, the value must be in [1, 4096]. Default: ``1`` .
713
+ global_rank (int): Global rank id, the value must be in [0, 4095]. Default: ``0`` .
562
714
  gradients_mean (bool): Whether to perform mean operator after allreduce of gradients.
563
- "stand_alone" do not support gradients_mean. Default: False.
715
+ "stand_alone" do not support gradients_mean. Default: ``False`` .
564
716
  gradient_fp32_sync (bool): Run allreduce of gradients in fp32. "stand_alone", "data_parallel"
565
- and "hybrid_parallel" do not support gradient_fp32_sync. Default: True.
566
- parallel_mode (str): There are five kinds of parallel modes, "stand_alone", "data_parallel",
567
- "hybrid_parallel", "semi_auto_parallel" and "auto_parallel". Note the pynative mode only supports
568
- the "stand_alone" and "data_parallel" mode. Default: "stand_alone".
717
+ and "hybrid_parallel" do not support gradient_fp32_sync. Default: ``True`` .
718
+ parallel_mode (str): There are five kinds of parallel modes, ``"stand_alone"`` , ``"data_parallel"`` ,
719
+ ``"hybrid_parallel"`` , ``"semi_auto_parallel"`` and ``"auto_parallel"`` . Note the pynative mode
720
+ only supports the ``"stand_alone"`` and ``"data_parallel"`` mode. Default: ``"stand_alone"`` .
569
721
 
570
722
  - stand_alone: Only one processor is working.
571
723
 
@@ -576,10 +728,12 @@ def set_auto_parallel_context(**kwargs):
576
728
  - semi_auto_parallel: Achieves data and model parallelism by setting parallel strategies.
577
729
 
578
730
  - auto_parallel: Achieving parallelism automatically.
579
- search_mode (str): There are three kinds of shard strategy search modes: "recursive_programming",
580
- "dynamic_programming" and "sharding_propagation". Default: "dynamic_programming".
731
+ search_mode (str): There are three kinds of shard strategy search modes: ``"recursive_programming"`` ,
732
+ ``"dynamic_programming"`` and ``"sharding_propagation"`` . Default: ``"recursive_programming"`` .
581
733
 
582
- - recursive_programming: Recursive programming search mode.
734
+ - recursive_programming: Recursive programming search mode. In order to obtain optimal performance,
735
+ it is recommended that users set the batch size to be greater than or equal to the product of
736
+ the number of devices and the number of multi-copy parallelism.
583
737
 
584
738
  - dynamic_programming: Dynamic programming search mode.
585
739
 
@@ -589,17 +743,18 @@ def set_auto_parallel_context(**kwargs):
589
743
  parameter_broadcast (bool): Whether to broadcast parameters before training. Before training, in order to have
590
744
  the same network initialization parameter values for all devices, broadcast the parameters
591
745
  on device 0 to other devices. Parameter broadcasting in different parallel modes is different,
592
- data_parallel mode, all parameters are broadcast except for the parameter whose attribute
593
- layerwise_parallel is True. Hybrid_parallel, semi_auto_parallel and auto_parallel mode, the
594
- segmented parameters do not participate in broadcasting. Default: False.
746
+ ``data_parallel`` mode, all parameters are broadcast except for the parameter whose attribute
747
+ layerwise_parallel is ``True`` . ``Hybrid_parallel`` , ``semi_auto_parallel`` and
748
+ ``auto_parallel mode`` , the segmented parameters do not participate in broadcasting.
749
+ Default: ``False`` .
595
750
  strategy_ckpt_load_file (str): The path to load parallel strategy checkpoint. The parameter is not to be
596
- recommended currently, it is better using 'strategy_ckpt_config' to replace it. Default: ''
751
+ recommended currently, it is better using 'strategy_ckpt_config' to replace it. Default: ``''``
597
752
  strategy_ckpt_save_file (str): The path to save parallel strategy checkpoint. The parameter is not to be
598
- recommended currently, it is better using 'strategy_ckpt_config' to replace it. Default: ''
599
- full_batch (bool): If you load whole batch datasets in auto_parallel mode, this parameter
600
- should be set as True. Default: False. The interface is not to be recommended currently,
601
- it is better using 'dataset_strategy' to replace it.
602
- dataset_strategy (Union[str, tuple]): Dataset sharding strategy. Default: "data_parallel".
753
+ recommended currently, it is better using 'strategy_ckpt_config' to replace it. Default: ``''``
754
+ full_batch (bool): If you load whole batch datasets in ``auto_parallel`` mode, this parameter
755
+ should be set as ``True`` . Default: ``False`` . The interface is not to be recommended
756
+ currently, it is better using 'dataset_strategy' to replace it.
757
+ dataset_strategy (Union[str, tuple]): Dataset sharding strategy. Default: ``"data_parallel"`` .
603
758
  dataset_strategy="data_parallel" is equal to full_batch=False, dataset_strategy="full_batch" is
604
759
  equal to full_batch=True. For execution mode is 'GRAPH_MODE' and dataset load into net by model
605
760
  parallel strategy likes ds_stra ((1, 8), (1, 8)), it requires using
@@ -607,45 +762,51 @@ def set_auto_parallel_context(**kwargs):
607
762
  enable_parallel_optimizer (bool): This is a developing feature, which shards the weight update computation for
608
763
  data parallel training in the benefit of time and memory saving. Currently, auto and semi auto
609
764
  parallel mode support all optimizers in both Ascend and GPU. Data parallel mode only supports
610
- `Lamb` and `AdamWeightDecay` in Ascend . Default: False.
765
+ `Lamb` and `AdamWeightDecay` in Ascend . Default: ``False`` .
611
766
  enable_alltoall (bool): A switch that allows AllToAll operators to be generated during communication. If its
612
- value is False, there will be a combination of operators such as AllGather, Split and Concat
613
- instead of AllToAll. Default: False.
767
+ value is ``False`` , there will be a combination of operators such as AllGather, Split and
768
+ Concat instead of AllToAll. Default: ``False`` .
614
769
  all_reduce_fusion_config (list): Set allreduce fusion strategy by parameters indices. Only support ReduceOp.SUM
615
770
  and HCCL_WORLD_GROUP/NCCL_WORLD_GROUP. No Default, if it is not set, the fusion is closed.
616
771
  pipeline_stages (int): Set the stage information for pipeline parallel. This indicates how the devices are
617
772
  distributed alone in the pipeline. The total devices will be divided into 'pipeline_stags'
618
- stages. Currently, this could only be used when parallel mode semi_auto_parallel is enabled.
619
- Default: 1.
620
- grad_accumulation_step (int): Set the accumulation steps of gradients in auto and semi auto parallel mode.
621
- This should be a positive int. Default: 1.
773
+ stages.
774
+ Default: ``1`` .
622
775
  parallel_optimizer_config (dict): A dict contains the keys and values for setting the parallel optimizer
623
776
  configure. The configure provides more detailed behavior control about parallel training
624
- when parallel optimizer is enabled. Currently it supports the key `gradient_accumulation_shard`.
625
- The configure will be effective when we use
777
+ when parallel optimizer is enabled. The configure will be effective when we use
626
778
  mindspore.set_auto_parallel_context(enable_parallel_optimizer=True).
627
779
  It supports the following keys.
628
780
 
629
- - gradient_accumulation_shard(bool): If true, the accumulation gradient parameters will be
781
+ - gradient_accumulation_shard(bool): If ``true`` , the accumulation gradient parameters will be
630
782
  sharded across the data parallel devices. This will
631
783
  introduce additional communication(ReduceScatter) at
632
784
  each step when accumulate the gradients, but saves a
633
785
  lot of device memories, thus can make model be trained
634
786
  with larger batch size. This configure is effective only
635
787
  when the model runs on pipeline training or gradient
636
- accumulation with data parallel. Default True.
788
+ accumulation with data parallel. Default ``False`` .
637
789
 
638
790
  - parallel_optimizer_threshold(int): Set the threshold of parallel optimizer. When parallel
639
791
  optimizer is enabled, parameters with size smaller than this threshold will not be sharded
640
792
  across the devices. Parameter size = shape[0] \* ... \* shape[n] \* size(dtype). Non-negative.
641
- Unit: KB. Default: 64.
793
+ Unit: KB. Default: ``64`` .
794
+
795
+ - optimizer_weight_shard_size(int): Set the optimizer weight shard group size, if you want to
796
+ specific the maximum group size across devices when the parallel optimizer is enabled.
797
+ The numerical range can be (0, device_num]. If pipeline parallel is enabled, the numerical
798
+ range is (0, device_num/stage]. If the size of data parallel communication domain
799
+ of the parameter cannot be divided by `optimizer_weight_shard_size`, then the specified
800
+ communication group size will not take effect. Default value is ``-1`` , which means the
801
+ optimizer weight shard group size will be the size of data parallel group of each parameter.
642
802
 
643
803
  comm_fusion (dict): A dict contains the types and configurations for setting the communication fusion. each
644
804
  communication fusion config has two keys: "mode" and "config".
645
805
  It supports following communication fusion types and configurations:
646
806
 
647
- - openstate: Whether turn on the communication fusion or not. If `openstate` is `True`, turn on
648
- the communication fusion, otherwise, turn off the communication fusion. Default: `True`.
807
+ - openstate: Whether turn on the communication fusion or not. If `openstate` is ``True`` ,
808
+ turn on the communication fusion, otherwise, turn off the communication fusion.
809
+ Default: ``True`` .
649
810
 
650
811
  - allreduce: If communication fusion type is `allreduce`. The `mode` contains: `auto`, `size`
651
812
  and `index`. In `auto` mode, AllReduce fusion is configured by gradients size and the default
@@ -677,7 +838,7 @@ def set_auto_parallel_context(**kwargs):
677
838
  Default: ''
678
839
 
679
840
  - only_trainable_params (bool): Only save/load the strategy information for trainable parameter.
680
- Default: True.
841
+ Default: ``True`` .
681
842
 
682
843
  Raises:
683
844
  ValueError: If input key is not attribute in auto parallel context.
@@ -699,7 +860,8 @@ def set_auto_parallel_context(**kwargs):
699
860
  >>> ms.set_auto_parallel_context(enable_alltoall=False)
700
861
  >>> ms.set_auto_parallel_context(all_reduce_fusion_config=[8, 160])
701
862
  >>> ms.set_auto_parallel_context(pipeline_stages=2)
702
- >>> parallel_config = {"gradient_accumulation_shard": True, "parallel_optimizer_threshold": 24}
863
+ >>> parallel_config = {"gradient_accumulation_shard": True, "parallel_optimizer_threshold": 24,
864
+ ... "optimizer_weight_shard_size": 2}
703
865
  >>> ms.set_auto_parallel_context(parallel_optimizer_config=parallel_config, enable_parallel_optimizer=True)
704
866
  >>> config = {"allreduce": {"mode": "size", "config": 32}, "allgather": {"mode": "size", "config": 32}}
705
867
  >>> ms.set_auto_parallel_context(comm_fusion=config)
@@ -739,8 +901,8 @@ def reset_auto_parallel_context():
739
901
  - gradients_mean: False.
740
902
  - gradient_fp32_sync: True.
741
903
  - parallel_mode: 'stand_alone'.
742
- - search_mode: 'dynamic_programming'.
743
- - auto_parallel_search_mode: 'dynamic_programming'.
904
+ - search_mode: 'recursive_programming'.
905
+ - auto_parallel_search_mode: 'recursive_programming'.
744
906
  - parameter_broadcast: False.
745
907
  - strategy_ckpt_load_file: ''.
746
908
  - strategy_ckpt_save_file: ''.
@@ -749,6 +911,10 @@ def reset_auto_parallel_context():
749
911
  - enable_alltoall: False.
750
912
  - pipeline_stages: 1.
751
913
  - fusion_threshold: 64.
914
+
915
+ Examples:
916
+ >>> import mindspore as ms
917
+ >>> ms.reset_auto_parallel_context()
752
918
  """
753
919
  _reset_auto_parallel_context()
754
920
 
@@ -756,36 +922,51 @@ def reset_auto_parallel_context():
756
922
  @args_type_check(offload_config=dict)
757
923
  def set_offload_context(offload_config):
758
924
  r"""
759
- Set offload context.
760
- Some configurations are offload specific, see the below table for details:
925
+ Configure heterogeneous training detailed parameters to adjust the offload strategy.
926
+
927
+ Note:
928
+ The offload configuration is only used if the memory offload feature is enabled
929
+ via mindspore.set_context(memory_offload="ON").
761
930
 
762
931
  Args:
763
932
  offload_config (dict): A dict contains the keys and values for setting the offload context
764
- configure.It supports the following keys.
765
- enable_offload (bool): The flag of whether enabling offload. Default: False.
766
- offload_param (str): The param for offload destination, cpu or disk.
767
- offload_path (str): The path of offload.
768
- offload_checkpoint (str): The checkpoint for offload destination, cpu or disk.
769
- offload_ddr_size (int): The ddr size for offload.
770
- offload_disk_size (int): The disk size for offload.
771
- enable_aio (bool): The flag of whether enabling aio. Default: True.
772
- aio_block_size (int): The size of aio block.
773
- aio_queue_depth (int): The depth of aio queue.
774
- enable_pinned_mem (bool): The flag of whether enabling pinned memory.
933
+ configure.It supports the following keys.
934
+
935
+ - offload_path (str): The path of offload, relative paths are supported. Default: ``"./offload"``.
936
+ - offload_cpu_size (str): The cpu memory size for offload. The format is "xxGB".
937
+ - offload_disk_size (str): The disk size for offload. The format is "xxGB"
938
+ - hbm_ratio (float): The ratio that can be used based on the maximum device memory.
939
+ The range is (0,1], Default: ``1.0``.
940
+ - cpu_ratio (float): The ratio that can be used based on the maximum host memory.
941
+ The range is (0,1], Default: ``1.0``.
942
+ - enable_pinned_mem (bool): The flag of whether enabling Pinned Memory. Default: ``True``.
943
+ - enable_aio (bool): The flag of whether enabling aio. Default: ``True``.
944
+ - aio_block_size (str): The size of aio block. The format is "xxGB".
945
+ - aio_queue_depth (int): The depth of aio queue.
946
+ - offload_param (str): The param for offload destination, cpu or disk, Default: ``""``.
947
+ - offload_checkpoint (str): The checkpoint for offload destination, only valid if recompute is turned on,
948
+ cpu or disk, Default: ``""``.
949
+ - auto_offload (bool): The flag of whether auto offload. Default: ``True``.
950
+ - host_mem_block_size (str): The memory block size of host memory pool. The format is "xxGB"
775
951
 
776
952
  Raises:
777
953
  ValueError: If input key is not attribute in auto parallel context.
778
954
 
779
955
  Examples:
780
956
  >>> from mindspore import context
781
- >>> context.set_offload_context(offload_config={"offload_param"="cpu"})
957
+ >>> context.set_offload_context(offload_config={"offload_param":"cpu"})
782
958
  """
783
959
  _set_offload_context(offload_config)
784
960
 
785
961
 
786
962
  def get_offload_context():
787
963
  """
788
- Get offload context.
964
+ Gets the offload configuration parameters. Configure through interface mindspore.set_offload_context().
965
+ If the user is not set, the default configuration is obtained.
966
+
967
+ Returns:
968
+ Dict, heterogeneous training offload detailed configuration parameters.
969
+
789
970
  Examples:
790
971
  >>> from mindspore import context
791
972
  >>> offload_config = context.get_offload_context()
@@ -801,11 +982,11 @@ def _check_target_specific_cfgs(device, arg_key):
801
982
  'enable_reduce_precision': ['Ascend'],
802
983
  'print_file_path': ['Ascend'],
803
984
  'variable_memory_max_size': ['Ascend'],
804
- 'auto_tune_mode': ['Ascend'],
805
985
  'max_device_memory': ['Ascend', 'GPU'],
806
986
  'mempool_block_size': ['GPU', 'Ascend'],
807
987
  'disable_format_transform': ['GPU'],
808
- 'ascend_config': ['Ascend']
988
+ 'ascend_config': ['Ascend'],
989
+ 'gpu_config': ['GPU'],
809
990
  }
810
991
  # configs not in map device_cfgs are supposed to be suitable for all devices
811
992
  if arg_key not in device_cfgs:
@@ -820,14 +1001,15 @@ def _check_target_specific_cfgs(device, arg_key):
820
1001
 
821
1002
 
822
1003
  @args_type_check(mode=int, precompile_only=bool, device_target=str, device_id=int, save_graphs=(bool, int),
823
- save_graphs_path=str, enable_dump=bool, auto_tune_mode=str,
1004
+ save_graphs_path=str, enable_dump=bool, aoe_tune_mode=str, aoe_config=dict,
824
1005
  save_dump_path=str, enable_reduce_precision=bool, variable_memory_max_size=str,
825
1006
  enable_auto_mixed_precision=bool, inter_op_parallel_num=int,
826
1007
  enable_graph_kernel=bool, reserve_class_name_in_scope=bool, check_bprop=bool,
827
1008
  max_device_memory=str, print_file_path=str, max_call_depth=int, env_config_path=str,
828
1009
  graph_kernel_flags=str, save_compile_cache=bool, runtime_num_threads=int, load_compile_cache=bool,
829
1010
  grad_for_scalar=bool, pynative_synchronize=bool, mempool_block_size=str, disable_format_transform=bool,
830
- op_timeout=int, deterministic=str, ascend_config=dict)
1011
+ op_timeout=int, deterministic=str, ascend_config=dict, jit_syntax_level=int,
1012
+ jit_enable_inplace_ops=bool, gpu_config=dict)
831
1013
  def set_context(**kwargs):
832
1014
  """
833
1015
  Set context for running environment.
@@ -838,7 +1020,7 @@ def set_context(**kwargs):
838
1020
  Note:
839
1021
  Attribute name is required for setting attributes.
840
1022
  The mode is not recommended to be changed after net was initialized because the implementations of some
841
- operations are different in graph mode and pynative mode. Default: PYNATIVE_MODE.
1023
+ operations are different in graph mode and pynative mode. Default: ``PYNATIVE_MODE`` .
842
1024
 
843
1025
  Some configurations are device specific, see the below table for details:
844
1026
 
@@ -875,7 +1057,7 @@ def set_context(**kwargs):
875
1057
  | +------------------------------+----------------------------+
876
1058
  | | reserve_class_name_in_scope | CPU/GPU/Ascend |
877
1059
  | +------------------------------+----------------------------+
878
- | | pynative_synchronize | GPU/Ascend |
1060
+ | | pynative_synchronize | CPU/GPU/Ascend |
879
1061
  +-------------------------+------------------------------+----------------------------+
880
1062
  | Executive Control | mode | CPU/GPU/Ascend |
881
1063
  | +------------------------------+----------------------------+
@@ -885,7 +1067,9 @@ def set_context(**kwargs):
885
1067
  | +------------------------------+----------------------------+
886
1068
  | | enable_reduce_precision | Ascend |
887
1069
  | +------------------------------+----------------------------+
888
- | | auto_tune_mode | Ascend |
1070
+ | | aoe_tune_mode | Ascend |
1071
+ | +------------------------------+----------------------------+
1072
+ | | aoe_config | Ascend |
889
1073
  | +------------------------------+----------------------------+
890
1074
  | | check_bprop | CPU/GPU/Ascend |
891
1075
  | +------------------------------+----------------------------+
@@ -910,47 +1094,52 @@ def set_context(**kwargs):
910
1094
  | | memory_offload | GPU/Ascend |
911
1095
  | +------------------------------+----------------------------+
912
1096
  | | ascend_config | Ascend |
1097
+ | +------------------------------+----------------------------+
1098
+ | | jit_syntax_level | CPU/GPU/Ascend |
1099
+ | +------------------------------+----------------------------+
1100
+ | | gpu_config | GPU |
913
1101
  +-------------------------+------------------------------+----------------------------+
914
1102
 
915
1103
  Args:
916
1104
  device_id (int): ID of the target device, the value must be in [0, device_num_per_host-1],
917
- while device_num_per_host should be no more than 4096. Default: 0.
1105
+ while device_num_per_host should be no more than 4096. Default: ``0`` .
918
1106
  device_target (str): The target device to run, support "Ascend", "GPU", and "CPU".
919
1107
  If device target is not set, the version of MindSpore package is used.
920
- max_device_memory (str): Set the maximum memory available for devices. The format is "xxGB". Default: "1024GB".
921
- The actual used memory size is the minimum of the available memory of the device and max_device_memory.
1108
+ max_device_memory (str): Set the maximum memory available for devices. The format is "xxGB".
1109
+ Default: ``" 1024GB"`` . The actual used memory size is the minimum of the available memory of the device
1110
+ and max_device_memory. 'max_device_memory' should be set before the program runs.
922
1111
  variable_memory_max_size (str): This parameter is deprecated, and will be removed in a future version.
923
1112
  Please use parameter 'max_device_memory' instead.
924
1113
  mempool_block_size (str): Set the size of the memory pool block in PyNative mode for devices.
925
- The format is "xxGB". Default: "1GB". Minimum size is "1G". The actual used memory block size is the minimum
926
- of the available memory of the device and mempool_block_size.
1114
+ The format is "xxGB". Default: ``"1GB"`` . Minimum size is "1G". The actual used memory block size is the
1115
+ minimum of the available memory of the device and mempool_block_size.
927
1116
  op_timeout (int): Set the maximum duration of executing an operator in seconds.
928
1117
  If the execution time exceeds this value, system will terminate the task. 0 means endless wait.
929
- Default: 1900.
930
- save_graphs (bool or int): Whether to save intermediate compilation graphs. Default: 0.
1118
+ Default: ``1900`` .
1119
+ save_graphs (bool or int): Whether to save intermediate compilation graphs. Default: ``0`` .
931
1120
  Available values are:
932
1121
 
933
1122
  - False or 0: disable saving of intermediate compilation graphs.
934
- - 1: some intermediate files will be generated during graph compliation.
1123
+ - 1: some intermediate files will be generated during graph compilation.
935
1124
  - True or 2: Generate more ir files related to backend process.
936
1125
  - 3: Generate visualization computing graphs and detailed frontend ir graphs.
937
1126
 
938
- When the `save_graphs` attribute is set as True, 1, 2 or 3, attribute of `save_graphs_path` is used
939
- to set the intermediate compilation graph storage path. By default, the graphs are saved in the current
940
- directory.
1127
+ When the `save_graphs` attribute is set as ``True`` , ``1`` , ``2`` or ``3`` , attribute of
1128
+ `save_graphs_path` is used to set the intermediate compilation graph storage path. By default, the graphs
1129
+ are saved in the current directory.
941
1130
  save_graphs_path (str): Path to save graphs. Default: ".".
942
1131
  If the specified directory does not exist, the system will automatically create the directory.
943
1132
  During distributed training, graphs will be saved to the directory of
944
1133
  `save_graphs_path/rank_${rank_id}/`. `rank_id` is the ID of the current device in the cluster.
945
1134
  deterministic (str): Whether to enable op run in deterministic mode. The value must be in the
946
- range of ['ON', 'OFF'], and the default value is 'OFF'.
1135
+ range of ['ON', 'OFF'], and the default value is ``'OFF'`` .
947
1136
 
948
1137
  - "ON": Enable operator deterministic running mode.
949
1138
  - "OFF": Disable operator deterministic running mode.
950
1139
 
951
- When deterministic mode is on, model ops will be deterministic in Ascend. This means that if op run multiple
952
- times with the same inputs on the same hardware, it will have the exact same outputs each time. This is
953
- useful for debugging models.
1140
+ When deterministic mode is on, model ops will be deterministic in Ascend. This means that if op run
1141
+ multiple times with the same inputs on the same hardware, it will have the exact same outputs each time.
1142
+ This is useful for debugging models.
954
1143
  enable_dump (bool): This parameters is deprecated, and will be deleted in the next version.
955
1144
  save_dump_path (str): This parameters is deprecated, and will be deleted in the next version.
956
1145
  print_file_path (str): The path of saving print data. If this parameter is set, print data is saved to
@@ -964,23 +1153,23 @@ def set_context(**kwargs):
964
1153
  configure RDR:
965
1154
 
966
1155
  - enable: controls whether the RDR is enabled to collect the key data during training and
967
- save key data in the fault scenario. When set to true, the RDR will be turned on.
968
- When set to false, the RDR will be turned off.
969
- - mode: sets the mode of RDR on exporting data. When set to 1, the RDR only exports data
970
- in the fault scenario. When set to 2, the RDR exports data in the fault scenario and the
971
- normal end scenario. Default: 1.
1156
+ save key data in the fault scenario. When set to ``true`` , the RDR will be turned on.
1157
+ When set to ``false`` , the RDR will be turned off.
1158
+ - mode: sets the mode of RDR on exporting data. When set to ``1`` , the RDR only exports data
1159
+ in the fault scenario. When set to ``2`` , the RDR exports data in the fault scenario and the
1160
+ normal end scenario. Default: ``1`` .
972
1161
  - path: sets the path where RDR saves data. The current path must be absolute.
973
1162
 
974
1163
  Memory reuse:
975
1164
 
976
- - mem_Reuse: controls whether the memory reuse function is turned on. When set to True,
977
- - the memory reuse function is turned on. When set to False, the memory reuse function is turned off.
1165
+ - mem_Reuse: controls whether the memory reuse function is turned on. When set to ``True`` ,
1166
+ the memory reuse function is turned on. When set to ``False`` , the memory reuse function is turned off.
978
1167
 
979
- precompile_only (bool): Whether to only precompile the network. Default: False.
980
- If set to True, the network will only be compiled, not executed.
981
- reserve_class_name_in_scope (bool) : Whether to save the network class name in the scope. Default: True.
1168
+ precompile_only (bool): Whether to only precompile the network. Default: ``False`` .
1169
+ If set to ``True`` , the network will only be compiled, not executed.
1170
+ reserve_class_name_in_scope (bool) : Whether to save the network class name in the scope. Default: ``True`` .
982
1171
  Each node has a scope. A scope of a subnode is the name of its parent node. If reserve_class_name_in_scope
983
- is set to True, the class name will be saved after keyword 'net-' in the scope.
1172
+ is set to ``True`` , the class name will be saved after keyword 'net-' in the scope.
984
1173
  For example:
985
1174
 
986
1175
  Default/net-Net1/net-Net2 (reserve_class_name_in_scope=True)
@@ -988,27 +1177,34 @@ def set_context(**kwargs):
988
1177
  Default/net/net (reserve_class_name_in_scope=False)
989
1178
 
990
1179
  pynative_synchronize (bool): Whether to enable synchronous execution of the device in PyNative mode.
991
- Default: False. When the value is set to False, the operator is executed asynchronously on the device.
992
- When an error occurs in the execution of the operator, the specific error script code location cannot
993
- be located, when the value is set to True, the operator is executed synchronously on the device. It will
994
- reduce the execution performance of the program. At this time, when an error occurs in the execution of
995
- the operator, the location of the error script code can be located according to the call stack of the error.
1180
+ Default: ``False`` . When the value is set to ``False`` , the operator is executed asynchronously on the
1181
+ device. When an error occurs in the execution of the operator, the specific error script code location
1182
+ cannot be located, when the value is set to ``True`` , the operator is executed synchronously on the
1183
+ device. It will reduce the execution performance of the program. At this time, when an error occurs in the
1184
+ execution of the operator, the location of the error script code can be located according to the call stack
1185
+ of the error.
996
1186
  mode (int): Running in GRAPH_MODE(0) or PYNATIVE_MODE(1).
997
- Both modes support all backends. Default: PYNATIVE_MODE.
1187
+ Both modes support all backends. Default: ``PYNATIVE_MODE`` .
998
1188
  enable_graph_kernel (bool): Whether to enable graph kernel fusion to optimize network execution performance.
999
- Default: False.
1189
+ Default: ``False`` .
1000
1190
  Indicates whether to enable image-computing convergence to optimize network execution performance.
1001
- If enable_graph_kernel is set to True, acceleration can be enabled.
1191
+ If enable_graph_kernel is set to ``True`` , acceleration can be enabled.
1002
1192
  For details of graph kernel fusion, please check
1003
1193
  `Enabling Graph Kernel Fusion
1004
- <https://www.mindspore.cn/tutorials/experts/en/r2.0/debug/graph_fusion_engine.html>`_.
1194
+ <https://www.mindspore.cn/tutorials/experts/en/r2.2/optimize/graph_fusion_engine.html>`_.
1005
1195
  graph_kernel_flags (str):
1006
1196
  Optimization options of graph kernel fusion, and the priority is higher when it conflicts
1007
1197
  with enable_graph_kernel. Only for experienced users.
1008
- For example, mindspore.set_context(graph_kernel_flags="--opt_level=2 --dump_as_text"). Some general options:
1198
+ For example,
1199
+
1200
+ .. code-block::
1201
+
1202
+ mindspore.set_context(graph_kernel_flags="--opt_level=2 --dump_as_text")
1203
+
1204
+ Some general options:
1009
1205
 
1010
1206
  - opt_level: Set the optimization level.
1011
- Default: 2. Graph kernel fusion can be enabled equivalently by setting opt_level greater than 0.
1207
+ Default: ``2`` . Graph kernel fusion can be enabled equivalently by setting opt_level greater than 0.
1012
1208
  Available values are:
1013
1209
 
1014
1210
  - 0: disables graph kernel fusion;
@@ -1019,55 +1215,52 @@ def set_context(**kwargs):
1019
1215
  ParallelFusion and so on. Optimizations of this level are radical and unstable in some scenarios.
1020
1216
  Be caution when using this level.
1021
1217
 
1022
- - dump_as_text: dumps detail info as text files. Default: false.
1218
+ - dump_as_text: dumps detail info as text files. Default: ``False`` .
1023
1219
 
1024
- More options can refer to the implementation code.
1025
1220
  enable_reduce_precision (bool): Whether to enable precision reduction.
1026
1221
  If the operator does not support the user-specified precision, the precision will
1027
- be changed automatically. Default: True.
1028
- auto_tune_mode (str): The mode of auto tune when op building, get the best tiling performance.
1029
- Default: NO_TUNE. The value must be in ['RL', 'GA', 'RL,GA'].
1030
-
1031
- - RL: Reinforcement Learning tune.
1032
- - GA: Genetic Algorithm tune.
1033
- - RL,GA: When both RL and GA optimization are enabled, the tool automatically selects RL or GA based on
1034
- different types of operators in the network model. The sequence of RL and GA is not differentiated.
1035
- (Automatic selection).
1036
-
1037
- For more information about the enable operator tuning tool settings, please check
1038
- `Enable the operator optimization tool
1039
- <https://www.mindspore.cn/tutorials/experts/en/r2.0/debug/auto_tune.html>`_.
1222
+ be changed automatically. Default: ``True`` .
1223
+ aoe_tune_mode (str): AOE tuning mode setting, which is not set by default.
1224
+ When set to ``"online"`` , the tuning in online function is turned on.
1225
+ When set to ``"offline"`` , ge graph will be save for offline tuning.
1226
+ aoe_config (dict): Set the parameters specific to Ascend Optimization Engine. It is not set by default.
1227
+
1228
+ - job_type (str): Mode type setting, default value is ``"2"``.
1229
+
1230
+ - ``"1"``: subgraph tuning;
1231
+ - ``"2"``: operator tuning.
1232
+
1040
1233
  check_bprop (bool): Whether to check back propagation nodes. The checking ensures that the shape and dtype
1041
- of back propagation node outputs is the same as input parameters. Default: False.
1042
- max_call_depth (int): Specify the maximum depth of function call. Must be positive integer. Default: 1000.
1234
+ of back propagation node outputs is the same as input parameters. Default: ``False`` .
1235
+ max_call_depth (int): Specify the maximum depth of function call. Must be positive integer. Default: ``1000`` .
1043
1236
  The max_call_depth parameter needs to be set when the nested call is too deep or the number
1044
1237
  of subgraphs is too large. If max_call_depth is set larger than before, the system max stack depth should be
1045
1238
  set larger too, otherwise a `core dumped` exception may be raised because of system stack overflow.
1046
- grad_for_scalar (bool): Whether to get gradient for scalar. Default: False.
1047
- When grad_for_scalar is set to True, the function's scalar input can be derived.
1048
- The default value is False. Because the back-end does not support scaling operations currently,
1239
+ grad_for_scalar (bool): Whether to get gradient for scalar. Default: ``False`` .
1240
+ When grad_for_scalar is set to ``True`` , the function's scalar input can be derived.
1241
+ The default value is ``False`` . Because the back-end does not support scaling operations currently,
1049
1242
  this interface only supports simple operations that can be deduced by the front-end.
1050
1243
  enable_compile_cache (bool): Whether to save or load the cache of the graph compiled by front-end.
1051
- After enable_compile_cache is set to True, during the first execution, a hardware-independent
1244
+ After enable_compile_cache is set to ``True`` , during the first execution, a hardware-independent
1052
1245
  compilation cache is generated and exported to a MINDIR file. When the network is executed again,
1053
- if enable_compile_cache is still set to True and the network scripts are not changed,
1246
+ if enable_compile_cache is still set to ``True`` and the network scripts are not changed,
1054
1247
  the compile cache is loaded. Note that only limited automatic detection for the changes of
1055
- python scripts is supported by now, which means that there is a correctness risk. Default: False.
1248
+ python scripts is supported by now, which means that there is a correctness risk. Default: ``False`` .
1056
1249
  This is an experimental prototype that is subject to change and/or deletion.
1057
1250
  compile_cache_path (str): Path to save the compile cache. Default: ".".
1058
1251
  If the specified directory does not exist, the system will automatically create the directory.
1059
1252
  The cache will be saved to the directory of `compile_cache_path/rank_${rank_id}/`. The `rank_id` is
1060
1253
  the ID of the current device in the cluster.
1061
- inter_op_parallel_num(int): The thread number of op parallel at the same time. Default value is 0,
1254
+ inter_op_parallel_num(int): The thread number of op parallel at the same time. Default value is ``0`` ,
1062
1255
  which means use the default num.
1063
1256
  runtime_num_threads(int): The thread pool number of cpu kernel used in runtime,
1064
- which must bigger than or equal to 0. Default value is 30, if you run many processes at
1257
+ which must bigger than or equal to 0. Default value is ``30`` , if you run many processes at
1065
1258
  the same time, you should set the value smaller to avoid thread contention.
1066
1259
  disable_format_transform (bool): Whether to disable the automatic format transform function from NCHW to NHWC.
1067
- When the network training performance of fp16 is worse than fp32,
1068
- `disable_format_transform` can be set to True to try to improve training performance. Default: False.
1260
+ When the network training performance of fp16 is worse than fp32, `disable_format_transform` can be set to
1261
+ ``True`` to try to improve training performance. Default: ``False`` .
1069
1262
  support_binary (bool): Whether to support run .pyc or .so in graph mode. If want to support run .so or .pyc
1070
- in graph mode, coulde set 'support_binary' to be True, and run once .py file. It would save the source
1263
+ in graph mode, coulde set 'support_binary' to be ``True`` , and run once .py file. It would save the source
1071
1264
  of the interfaces would be compiled by MindSpore to the interfaces definition .py file that should be
1072
1265
  guaranteed to be writable. Then compile the .py file to the .pyc or .so file, and could run in Graph mode.
1073
1266
  memory_optimize_level (str): The memory optimize level.
@@ -1077,20 +1270,20 @@ def set_context(**kwargs):
1077
1270
  - O1: priority memory option, enable SOMAS.
1078
1271
  memory_offload (str): Whether to enable the memory offload function. When it is enabled, the idle data will be
1079
1272
  temporarily copied to the host side in the case of insufficient device memory. The value must be in the
1080
- range of ['ON', 'OFF'], and the default value is 'OFF'.
1273
+ range of ['ON', 'OFF'], and the default value is ``'OFF'`` .
1081
1274
 
1082
1275
  - ON: Enable the memory Offload function. On Ascend hardware platform, this parameter does not take effect
1083
1276
  when the environment variable "GRAPH_OP_RUN=1" is not set; This parameter does not take effect when
1084
1277
  memory_optimize_level is set 'O1'.
1085
1278
  - OFF: Turn off the memory Offload function.
1086
1279
  ascend_config (dict): Set the parameters specific to Ascend hardware platform. It is not set by default.
1087
- Currently, only setting `precision_mode` and `jit_compile` are supported on Ascend910B hardware platform.
1088
- The default value of `precision_mode` and `jit_compile` are experimental parameters, may change
1089
- in the future.
1280
+ Currently, configurations except `parallel_speed_up_json_path` and `precision_mode.force_fp32` are only
1281
+ supported on Ascend910B hardware platform. The default value of `precision_mode`, `jit_compile` and
1282
+ `atomic_clean_policy` are experimental parameters, may change in the future.
1090
1283
 
1091
1284
  - precision_mode (str): Mixed precision mode setting, on Ascend910B hardware platform, the default
1092
1285
  value of training network is based on the value of CANN, and the default value of inference network
1093
- is force_fp16. The value range is as follows:
1286
+ is ``force_fp16`` . The value range is as follows:
1094
1287
 
1095
1288
  - force_fp16: When the operator supports both float16 and float32, select float16 directly.
1096
1289
  - allow_fp32_to_fp16: When the operator does not support the float32 data type, directly reduce
@@ -1101,18 +1294,123 @@ def set_context(**kwargs):
1101
1294
  - must_keep_origin_dtype: Keep the accuracy of the original drawing.
1102
1295
  - force_fp32: When the input of the matrix calculation operator is float16 and the output supports
1103
1296
  float16 and float32, output is forced to float32.
1104
- - force_lowerprecision: When the operator supports both float16 or bfloat16 and float32, select
1105
- float16 or bfloat16 directly.
1106
1297
  - allow_fp32_to_bf16: When the operator does not support the float32 data type, directly reduce
1107
1298
  the precision of bfloat16.
1108
- - allow_fp32_to_lowprecision: When the operator does not support the float32 data type, directly
1109
- reduce the precision of float16 or bfloat16.
1110
1299
  - allow_mix_precision_fp16: Automatic mixing precision, facing the whole network operator, automatically
1111
1300
  reduces the precision of some operators to float16 according to the built-in optimization strategy.
1112
1301
  - allow_mix_precision_bf16: Automatic mixing precision, facing the whole network operator, according to
1113
1302
  the built-in optimization strategy, automatically reduces the precision of some operators to bfloat16.
1114
1303
 
1115
1304
  - jit_compile (bool): Whether to select online compilation. the default value is based on CANN.
1305
+ - atomic_clean_policy (int): The policy for cleaning memory occupied by atomic operators in the network.
1306
+ Default: ``1`` .
1307
+
1308
+ - 0: The memory occupied by all atomic operators in the network is cleaned centrally.
1309
+ - 1: Memory is not cleaned centrally and each atomic operator in the network is cleaned separately.
1310
+ When the memory of the network exceeds the limit, you may try this cleaning policy, but it may cause
1311
+ performance loss.
1312
+ - matmul_allow_hf32 (bool): Whether to convert FP32 to HF32 for Matmul operators. Default value: ``False``.
1313
+ This is an experimental prototype that is subject to change and/or deletion.
1314
+ For detailed information, please refer to `Ascend community <https://www.hiascend.com/>`_ .
1315
+ - conv_allow_hf32 (bool): Whether to convert FP32 to HF32 for Conv operators. Default value: ``True``.
1316
+ This is an experimental prototype that is subject to change and/or deletion.
1317
+ For detailed information, please refer to `Ascend community <https://www.hiascend.com/>`_ .
1318
+ - op_precision_mode (str): Path to config file of op precision mode. For detailed information, please refer
1319
+ to `Ascend community <https://www.hiascend.com/>`_ .
1320
+ - parallel_speed_up_json_path(Union[str, None]): The path to the parallel speed up json file, configuration
1321
+ can refer to `parallel_speed_up.json
1322
+ <https://gitee.com/mindspore/mindspore/blob/r2.2/config/parallel_speed_up.json>`_ .
1323
+ If its value is None or '', it does not take effect. Default None.
1324
+
1325
+ - recompute_comm_overlap (bool): Enable overlap between recompute ops and communication ops if True.
1326
+ Default: False.
1327
+ - matmul_grad_comm_overlap (bool): Enable overlap between grad ops and communication ops if True.
1328
+ Default: False.
1329
+ - enable_task_opt (bool): Enable the optimization of the number of tasks for each communication if True.
1330
+ Default: False.
1331
+ - interleaved_matmul_comm (bool): Enable interleaved optimization of Matmul-Comm if True. Default: False.
1332
+ - interleaved_layernorm_comm (bool): Enable interleaved optimization of LayerNorm-Comm if True.
1333
+ Default: False.
1334
+
1335
+ jit_syntax_level (int): Set JIT syntax level for graph compiling, triggered by GRAPH_MODE and @jit decorator.
1336
+ The value must be ``STRICT`` or ``LAX`` . Default: ``LAX`` . All levels support all backends.
1337
+
1338
+ - ``STRICT`` : Only basic syntax is supported, and execution performance is optimal. Can be used for MindIR
1339
+ load and export.
1340
+ - ``LAX`` : Compatible with all Python syntax as much as possible. However, execution performance may be
1341
+ affected and not optimal. Cannot be used for MindIR load and export due to some syntax that may not be
1342
+ able to be exported.
1343
+
1344
+ gpu_config (dict): Set the parameters specific to gpu hardware platform. It is not set by default.
1345
+ Currently, only setting `conv_fprop_algo` and `conv_dgrad_algo` and `conv_wgrad_algo` and `conv_allow_tf32`
1346
+ and `matmul_allow_tf32` are supported on GPU hardware platform.
1347
+
1348
+ - conv_fprop_algo (str): Specifies convolution forward algorithm and the default value is 'normal',
1349
+ The value range is as follows:
1350
+
1351
+ - normal: Use the heuristic search algorithm.
1352
+ - performance: Use the trial search algorithm.
1353
+ - implicit_gemm: This algorithm expresses the convolution as a matrix product without actually explicitly
1354
+ forming the matrix that holds the input tensor data.
1355
+ - implicit_precomp_gemm: This algorithm expresses convolution as a matrix product without actually
1356
+ explicitly forming the matrix that holds the input tensor data, but still needs some memory workspace to
1357
+ precompute some indices in order to facilitate the implicit construction of the matrix that holds the
1358
+ input tensor data.
1359
+ - gemm: This algorithm expresses the convolution as an explicit matrix product. A significant memory
1360
+ workspace is needed to store the matrix that holds the input tensor data.
1361
+ - direct: This algorithm expresses the convolution as a direct convolution (for example, without
1362
+ implicitly or explicitly doing a matrix multiplication).
1363
+ - fft: This algorithm uses the Fast-Fourier Transform approach to compute the convolution. A significant
1364
+ memory workspace is needed to store intermediate results.
1365
+ - fft_tiling: This algorithm uses the Fast-Fourier Transform approach but splits the inputs into tiles.
1366
+ A significant memory workspace is needed to store intermediate results but less than fft algorithm for
1367
+ large size images.
1368
+ - winograd: This algorithm uses the Winograd Transform approach to compute the convolution. A reasonably
1369
+ sized workspace is needed to store intermediate results.
1370
+ - winograd_nonfused: This algorithm uses the Winograd Transform approach to compute the convolution. A
1371
+ significant workspace may be needed to store intermediate results.
1372
+ - conv_dgrad_algo (str): Specifies convolution data grad algorithm and the default value is 'normal',
1373
+ The value range is as follows:
1374
+
1375
+ - normal: Use the heuristic search algorithm.
1376
+ - performance: Use the trial search algorithm.
1377
+ - algo_0: This algorithm expresses the convolution as a sum of matrix products without actually explicitly
1378
+ forming the matrix that holds the input tensor data. The sum is done using the atomic add operation,
1379
+ thus the results are non-deterministic.
1380
+ - algo_1: This algorithm expresses the convolution as a matrix product without actually explicitly forming
1381
+ the matrix that holds the input tensor data. The results are deterministic.
1382
+ - fft: This algorithm uses a Fast-Fourier Transform approach to compute the convolution. A significant
1383
+ memory workspace is needed to store intermediate results. The results are deterministic.
1384
+ - fft_tiling: This algorithm uses the Fast-Fourier Transform approach but splits the inputs into tiles.
1385
+ A significant memory workspace is needed to store intermediate results but less than fft for large size
1386
+ images. The results are deterministic.
1387
+ - winograd: This algorithm uses the Winograd Transform approach to compute the convolution. A reasonably
1388
+ sized workspace is needed to store intermediate results. The results are deterministic.
1389
+ - winograd_nonfused: This algorithm uses the Winograd Transform approach to compute the convolution.
1390
+ A significant workspace may be needed to store intermediate results. The results are deterministic.
1391
+ - conv_wgrad_algo (str): Specifies convolution filter grad algorithm and the default value is 'normal',
1392
+ The value range is as follows:
1393
+
1394
+ - normal: Use the heuristic search algorithm.
1395
+ - performance: Use the trial search algorithm.
1396
+ - algo_0: This algorithm expresses the convolution as a sum of matrix products without actually explicitly
1397
+ forming the matrix that holds the input tensor data. The sum is done using the atomic add operation,
1398
+ thus the results are non-deterministic.
1399
+ - algo_1: This algorithm expresses the convolution as a matrix product without actually explicitly forming
1400
+ the matrix that holds the input tensor data. The results are deterministic.
1401
+ - fft: This algorithm uses a Fast-Fourier Transform approach to compute the convolution. A significant
1402
+ memory workspace is needed to store intermediate results. The results are deterministic.
1403
+ - algo_3: This algorithm is similar to algo_0 but uses some small workspace to precompute some indices.
1404
+ The results are also non-deterministic.
1405
+ - winograd_nonfused: This algorithm uses the Winograd Transform approach to compute the convolution.
1406
+ A significant workspace may be needed to store intermediate results. The results are deterministic.
1407
+ - fft_tiling: This algorithm uses the Fast-Fourier Transform approach but splits the inputs into tiles.
1408
+ A significant memory workspace is needed to store intermediate results but less than fft for large size
1409
+ images. The results are deterministic.
1410
+ - conv_allow_tf32 (bool): The flag below controls to allow Tensor core TF32 computation on CUDNN and the
1411
+ default value is ``True``.
1412
+ - matmul_allow_tf32 (bool): The flag below controls to allow Tensor core TF32 computation on CUBLAS and the
1413
+ default value is ``False``.
1116
1414
 
1117
1415
  Raises:
1118
1416
  ValueError: If input key is not an attribute in context.
@@ -1129,13 +1427,14 @@ def set_context(**kwargs):
1129
1427
  >>> ms.set_context(graph_kernel_flags="--opt_level=2 --dump_as_text")
1130
1428
  >>> ms.set_context(reserve_class_name_in_scope=True)
1131
1429
  >>> ms.set_context(variable_memory_max_size="6GB")
1430
+ >>> ms.set_context(aoe_tune_mode="online")
1431
+ >>> ms.set_context(aoe_config={"job_type": "2"})
1132
1432
  >>> ms.set_context(check_bprop=True)
1133
1433
  >>> ms.set_context(max_device_memory="3.5GB")
1134
1434
  >>> ms.set_context(mempool_block_size="1GB")
1135
1435
  >>> ms.set_context(print_file_path="print.pb")
1136
1436
  >>> ms.set_context(max_call_depth=80)
1137
1437
  >>> ms.set_context(env_config_path="./env_config.json")
1138
- >>> ms.set_context(auto_tune_mode="GA,RL")
1139
1438
  >>> ms.set_context(grad_for_scalar=True)
1140
1439
  >>> ms.set_context(enable_compile_cache=True, compile_cache_path="./cache.ms")
1141
1440
  >>> ms.set_context(pynative_synchronize=True)
@@ -1145,7 +1444,11 @@ def set_context(**kwargs):
1145
1444
  >>> ms.set_context(memory_optimize_level='O0')
1146
1445
  >>> ms.set_context(memory_offload='ON')
1147
1446
  >>> ms.set_context(deterministic='ON')
1148
- >>> ms.set_context(ascend_config={"precision_mode": "force_fp16", "jit_compile": True})
1447
+ >>> ms.set_context(ascend_config={"precision_mode": "force_fp16", "jit_compile": True,
1448
+ ... "atomic_clean_policy": 1, "op_precision_mode": "./op_precision_config_file"})
1449
+ >>> ms.set_context(jit_syntax_level=ms.STRICT)
1450
+ >>> ms.set_context(gpu_config={"conv_fprop_algo": "performance", "conv_allow_tf32": True,
1451
+ ... "matmul_allow_tf32": True})
1149
1452
  """
1150
1453
  ctx = _context()
1151
1454
  # set device target first
@@ -1153,7 +1456,7 @@ def set_context(**kwargs):
1153
1456
  ctx.set_device_target(kwargs['device_target'])
1154
1457
  device = ctx.get_param(ms_ctx_param.device_target)
1155
1458
  for key, value in kwargs.items():
1156
- if key == 'enable_sparse':
1459
+ if key in ('enable_sparse', 'auto_tune_mode'):
1157
1460
  logger.warning(f"For 'context.set_context', '{key}' parameter is deprecated, "
1158
1461
  "and will be removed in the next version.")
1159
1462
  continue
@@ -1161,7 +1464,8 @@ def set_context(**kwargs):
1161
1464
  logger.warning(f"For 'context.set_context', '{key}' parameter is deprecated. "
1162
1465
  "For details, please see the interface parameter API comments")
1163
1466
  continue
1164
- if key in ('precision_mode', 'jit_compile'):
1467
+ if key in ('precision_mode', 'jit_compile', 'atomic_clean_policy', 'matmul_allow_hf32', 'conv_allow_hf32',
1468
+ 'op_precision_mode'):
1165
1469
  raise ValueError(f"Please set '{key}' through parameter ascend_config")
1166
1470
  if key == 'save_graphs':
1167
1471
  if value is True:
@@ -1170,6 +1474,9 @@ def set_context(**kwargs):
1170
1474
  value = 0
1171
1475
  if value > 3:
1172
1476
  raise ValueError(f"value for save_graphs should be 0-3 but got '{value}'")
1477
+ if key == 'jit_syntax_level' and value not in (STRICT, COMPATIBLE, LAX):
1478
+ raise ValueError(f"For 'jit_syntax_level', the value should be context.STRICT"
1479
+ f" or context.LAX, but got {value}.")
1173
1480
  if not _check_target_specific_cfgs(device, key):
1174
1481
  continue
1175
1482
  if hasattr(ctx, key):
@@ -1231,16 +1538,16 @@ class ParallelMode:
1231
1538
  """
1232
1539
  Parallel mode options.
1233
1540
 
1234
- There are five kinds of parallel modes, "STAND_ALONE", "DATA_PARALLEL",
1235
- "HYBRID_PARALLEL", "SEMI_AUTO_PARALLEL" and "AUTO_PARALLEL". Default: "STAND_ALONE".
1541
+ There are five kinds of parallel modes, ``STAND_ALONE``, ``DATA_PARALLEL``,
1542
+ ``HYBRID_PARALLEL``, ``SEMI_AUTO_PARALLEL`` and ``AUTO_PARALLEL``. Default: ``STAND_ALONE``.
1236
1543
 
1237
- - STAND_ALONE: Only one processor is working.
1238
- - DATA_PARALLEL: Distributes the data across different processors.
1239
- - HYBRID_PARALLEL: Achieves data parallelism and model parallelism manually.
1240
- - SEMI_AUTO_PARALLEL: Achieves data parallelism and model parallelism by setting parallel strategies.
1241
- - AUTO_PARALLEL: Achieves parallelism automatically.
1544
+ - ``STAND_ALONE``: Only one processor is working.
1545
+ - ``DATA_PARALLEL``: Distributes the data across different processors.
1546
+ - ``HYBRID_PARALLEL``: Achieves data parallelism and model parallelism manually.
1547
+ - ``SEMI_AUTO_PARALLEL``: Achieves data parallelism and model parallelism by setting parallel strategies.
1548
+ - ``AUTO_PARALLEL``: Achieves parallelism automatically.
1242
1549
 
1243
- MODE_LIST: The list of all supported parallel modes.
1550
+ ``MODE_LIST``: The list of all supported parallel modes.
1244
1551
  """
1245
1552
 
1246
1553
  STAND_ALONE = "stand_alone"
@@ -1261,32 +1568,26 @@ def set_ps_context(**kwargs):
1261
1568
  Some other environment variables should also be set for parameter server training mode.
1262
1569
  These environment variables are listed below:
1263
1570
 
1264
- MS_SERVER_NUM: Server number
1265
-
1266
- MS_WORKER_NUM: Worker number
1267
-
1268
- MS_SCHED_HOST: Scheduler IP address
1269
-
1270
- MS_SCHED_PORT: Scheduler port
1571
+ - MS_SERVER_NUM: Server number
1572
+ - MS_WORKER_NUM: Worker number
1573
+ - MS_SCHED_HOST: Scheduler IP address
1574
+ - MS_SCHED_PORT: Scheduler port
1575
+ - MS_ROLE: The role of this process:
1271
1576
 
1272
- MS_ROLE: The role of this process:
1273
-
1274
- MS_SCHED: represents the scheduler,
1275
-
1276
- MS_WORKER: represents the worker,
1277
-
1278
- MS_PSERVER/MS_SERVER: represents the Server
1577
+ - MS_SCHED: represents the scheduler,
1578
+ - MS_WORKER: represents the worker,
1579
+ - MS_PSERVER/MS_SERVER: represents the Server
1279
1580
 
1280
1581
  Args:
1281
1582
  enable_ps (bool): Whether to enable parameter server training mode.
1282
1583
  Only after enable_ps is set True, the environment variables will be effective.
1283
- Default: False.
1584
+ Default: ``False`` .
1284
1585
  config_file_path (string): Configuration file path used by recovery, parameter server training mode only
1285
- supports Server disaster recovery currently. Default: ''.
1286
- scheduler_manage_port (int): Scheduler manage port used to scale out/in. Default: 11202.
1287
- enable_ssl (bool): Set PS SSL mode enabled or disabled. Default: False.
1288
- client_password (str): Password to decrypt the secret key stored in the client certificate. Default: ''.
1289
- server_password (str): Password to decrypt the secret key stored in the server certificate. Default: ''.
1586
+ supports Server disaster recovery currently. Default: ``''`` .
1587
+ scheduler_manage_port (int): Scheduler manage port used to scale out/in. Default: ``11202`` .
1588
+ enable_ssl (bool): Set PS SSL mode enabled or disabled. Default: ``False`` .
1589
+ client_password (str): Password to decrypt the secret key stored in the client certificate. Default: ``''`` .
1590
+ server_password (str): Password to decrypt the secret key stored in the server certificate. Default: ``''`` .
1290
1591
 
1291
1592
  Raises:
1292
1593
  ValueError: If input key is not the attribute in parameter server training mode context.
@@ -1305,13 +1606,15 @@ def get_ps_context(attr_key):
1305
1606
  Args:
1306
1607
  attr_key (str): The key of the attribute:
1307
1608
 
1308
- - enable_ps (bool): Whether to enable parameter server training mode.
1609
+ - enable_ps (bool): Whether to enable parameter server training mode. Default: ``False`` .
1309
1610
  - config_file_path (string): Configuration file path used by recovery, parameter server training mode only
1310
- supports Server disaster recovery currently. Default: ''.
1311
- - scheduler_manage_port (int): Scheduler manage port used to scale out/in. Default: 11202.
1312
- - enable_ssl (bool): Set PS SSL mode enabled or disabled. Default: False.
1313
- - client_password (str): Password to decrypt the secret key stored in the client certificate. Default: ''.
1314
- - server_password (str): Password to decrypt the secret key stored in the server certificate. Default: ''.
1611
+ supports Server disaster recovery currently. Default: ``''`` .
1612
+ - scheduler_manage_port (int): Scheduler manage port used to scale out/in. Default: ``11202`` .
1613
+ - enable_ssl (bool): Set PS SSL mode enabled or disabled. Default: ``False`` .
1614
+ - client_password (str): Password to decrypt the secret key stored in the client certificate.
1615
+ Default: ``''`` .
1616
+ - server_password (str): Password to decrypt the secret key stored in the server certificate.
1617
+ Default: ``''`` .
1315
1618
 
1316
1619
  Returns:
1317
1620
  Returns attribute value according to the key.
@@ -1333,6 +1636,10 @@ def reset_ps_context():
1333
1636
  - enable_ps: False.
1334
1637
 
1335
1638
  Meaning of each field and its default value refer to :func:`mindspore.set_ps_context`.
1639
+
1640
+ Examples:
1641
+ >>> import mindspore as ms
1642
+ >>> ms.reset_ps_context()
1336
1643
  """
1337
1644
  _reset_ps_context()
1338
1645