mindspore 2.2.14__cp38-cp38-manylinux1_x86_64.whl → 2.3.0rc1__cp38-cp38-manylinux1_x86_64.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 (1153) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/__init__.py +4 -4
  3. mindspore/_akg/akg/composite/build_module.py +155 -11
  4. mindspore/_akg/akg/config/repository.json +38 -0
  5. mindspore/_akg/akg/ms/info_version_adapt.py +29 -0
  6. mindspore/_akg/akg/tvm/contrib/nvcc.py +4 -1
  7. mindspore/_akg/akg/utils/ascend_profilier/path_manager.py +2 -1
  8. mindspore/_akg/akg/utils/composite_op_helper.py +4 -2
  9. mindspore/_akg/akg/utils/dump_ascend_meta.py +2 -2
  10. mindspore/_akg/akg/utils/gen_random.py +14 -8
  11. mindspore/_akg/akg/utils/op_dsl.py +11 -0
  12. mindspore/_akg/akg/utils/tbe_codegen_utils.py +5 -5
  13. mindspore/_c_dataengine.cpython-38-x86_64-linux-gnu.so +0 -0
  14. mindspore/_c_expression.cpython-38-x86_64-linux-gnu.so +0 -0
  15. mindspore/_c_mindrecord.cpython-38-x86_64-linux-gnu.so +0 -0
  16. mindspore/_checkparam.py +58 -0
  17. mindspore/_extends/builtin_operations.py +2 -1
  18. mindspore/_extends/graph_kernel/model/graph_parallel.py +16 -6
  19. mindspore/_extends/parallel_compile/akg_compiler/akg_process.py +3 -16
  20. mindspore/_extends/parallel_compile/akg_compiler/build_tbe_kernel.py +16 -4
  21. mindspore/_extends/parallel_compile/akg_compiler/compiler.py +1 -0
  22. mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +96 -0
  23. mindspore/_extends/parallel_compile/akg_compiler/tbe_topi.py +2 -1
  24. mindspore/_extends/parallel_compile/akg_compiler/util.py +5 -2
  25. mindspore/_extends/parse/__init__.py +18 -14
  26. mindspore/_extends/parse/compile_config.py +229 -0
  27. mindspore/_extends/parse/parser.py +155 -59
  28. mindspore/_extends/parse/resources.py +40 -7
  29. mindspore/_extends/parse/standard_method.py +124 -204
  30. mindspore/_extends/remote/kernel_build_server.py +2 -0
  31. mindspore/_mindspore_offline_debug.cpython-38-x86_64-linux-gnu.so +0 -0
  32. mindspore/_profiler.py +30 -0
  33. mindspore/amp.py +24 -18
  34. mindspore/bin/cache_admin +0 -0
  35. mindspore/bin/cache_server +0 -0
  36. mindspore/boost/boost_cell_wrapper.py +1 -1
  37. mindspore/boost/group_loss_scale_manager.py +1 -1
  38. mindspore/common/__init__.py +3 -1
  39. mindspore/common/_jit_fallback_utils.py +2 -3
  40. mindspore/common/_register_for_adapter.py +7 -0
  41. mindspore/common/_stub_tensor.py +6 -1
  42. mindspore/common/_utils.py +5 -17
  43. mindspore/common/api.py +91 -48
  44. mindspore/common/auto_dynamic_shape.py +27 -14
  45. mindspore/common/dtype.py +5 -4
  46. mindspore/common/dump.py +5 -4
  47. mindspore/common/initializer.py +1 -1
  48. mindspore/common/jit_config.py +20 -11
  49. mindspore/common/lazy_inline.py +58 -17
  50. mindspore/common/mindir_util.py +12 -2
  51. mindspore/common/mutable.py +79 -14
  52. mindspore/common/parameter.py +19 -4
  53. mindspore/common/seed.py +9 -9
  54. mindspore/common/sparse_tensor.py +251 -18
  55. mindspore/common/symbol.py +122 -0
  56. mindspore/common/tensor.py +321 -433
  57. mindspore/communication/__init__.py +3 -3
  58. mindspore/communication/_comm_helper.py +5 -0
  59. mindspore/communication/management.py +53 -38
  60. mindspore/config/op_info.config +22 -54
  61. mindspore/context.py +167 -59
  62. mindspore/dataset/__init__.py +5 -5
  63. mindspore/dataset/audio/__init__.py +6 -6
  64. mindspore/dataset/audio/transforms.py +711 -158
  65. mindspore/dataset/callback/ds_callback.py +2 -2
  66. mindspore/dataset/engine/cache_client.py +2 -2
  67. mindspore/dataset/engine/datasets.py +72 -38
  68. mindspore/dataset/engine/datasets_audio.py +14 -14
  69. mindspore/dataset/engine/datasets_standard_format.py +33 -3
  70. mindspore/dataset/engine/datasets_text.py +38 -38
  71. mindspore/dataset/engine/datasets_user_defined.py +7 -7
  72. mindspore/dataset/engine/datasets_vision.py +75 -71
  73. mindspore/dataset/engine/offload.py +5 -7
  74. mindspore/dataset/text/__init__.py +3 -3
  75. mindspore/dataset/text/transforms.py +408 -121
  76. mindspore/dataset/text/utils.py +9 -9
  77. mindspore/dataset/transforms/__init__.py +1 -1
  78. mindspore/dataset/transforms/transforms.py +261 -76
  79. mindspore/dataset/utils/browse_dataset.py +9 -9
  80. mindspore/dataset/vision/__init__.py +3 -3
  81. mindspore/dataset/vision/c_transforms.py +5 -5
  82. mindspore/dataset/vision/transforms.py +2264 -514
  83. mindspore/dataset/vision/utils.py +40 -9
  84. mindspore/dataset/vision/validators.py +7 -1
  85. mindspore/experimental/optim/__init__.py +12 -2
  86. mindspore/experimental/optim/adadelta.py +161 -0
  87. mindspore/experimental/optim/adagrad.py +168 -0
  88. mindspore/experimental/optim/adam.py +35 -34
  89. mindspore/experimental/optim/adamax.py +170 -0
  90. mindspore/experimental/optim/adamw.py +40 -16
  91. mindspore/experimental/optim/asgd.py +153 -0
  92. mindspore/experimental/optim/lr_scheduler.py +60 -119
  93. mindspore/experimental/optim/nadam.py +157 -0
  94. mindspore/experimental/optim/optimizer.py +15 -8
  95. mindspore/experimental/optim/radam.py +194 -0
  96. mindspore/experimental/optim/rmsprop.py +154 -0
  97. mindspore/experimental/optim/rprop.py +164 -0
  98. mindspore/experimental/optim/sgd.py +28 -19
  99. mindspore/hal/__init__.py +34 -0
  100. mindspore/hal/_ascend.py +57 -0
  101. mindspore/hal/_base.py +57 -0
  102. mindspore/hal/_cpu.py +56 -0
  103. mindspore/hal/_gpu.py +57 -0
  104. mindspore/hal/device.py +356 -0
  105. mindspore/hal/event.py +179 -0
  106. mindspore/hal/stream.py +337 -0
  107. mindspore/include/api/data_type.h +2 -2
  108. mindspore/include/api/dual_abi_helper.h +16 -3
  109. mindspore/include/api/model.h +1 -3
  110. mindspore/include/api/status.h +14 -0
  111. mindspore/include/c_api/model_c.h +173 -0
  112. mindspore/include/c_api/ms/base/types.h +1 -0
  113. mindspore/include/c_api/types_c.h +19 -0
  114. mindspore/include/dataset/execute.h +1 -3
  115. mindspore/include/mindapi/base/format.h +125 -23
  116. mindspore/include/mindapi/base/types.h +7 -0
  117. mindspore/lib/libdnnl.so.2 +0 -0
  118. mindspore/lib/libmindspore.so +0 -0
  119. mindspore/lib/libmindspore_backend.so +0 -0
  120. mindspore/lib/libmindspore_common.so +0 -0
  121. mindspore/lib/libmindspore_core.so +0 -0
  122. mindspore/lib/libmindspore_glog.so.0 +0 -0
  123. mindspore/lib/libmindspore_gpr.so.15 +0 -0
  124. mindspore/lib/libmindspore_grpc.so.15 +0 -0
  125. mindspore/lib/libmindspore_shared_lib.so +0 -0
  126. mindspore/lib/libmpi_adapter.so +0 -0
  127. mindspore/lib/libmpi_collective.so +0 -0
  128. mindspore/lib/libnnacl.so +0 -0
  129. mindspore/lib/libopencv_core.so.4.5 +0 -0
  130. mindspore/lib/libopencv_imgcodecs.so.4.5 +0 -0
  131. mindspore/lib/libopencv_imgproc.so.4.5 +0 -0
  132. mindspore/lib/libps_cache.so +0 -0
  133. mindspore/lib/plugin/ascend/custom_aicore_ops/op_impl/ai_core/tbe/config/ascend910/aic-ascend910-ops-info.json +2044 -154
  134. mindspore/lib/plugin/ascend/custom_aicore_ops/op_impl/ai_core/tbe/config/ascend910b/aic-ascend910b-ops-info.json +2044 -33
  135. mindspore/lib/plugin/ascend/custom_aicore_ops/op_impl/ai_core/tbe/custom_aicore_ops_impl/build_tbe_kernel.py +529 -0
  136. mindspore/lib/plugin/ascend/custom_aicore_ops/op_impl/ai_core/tbe/custom_aicore_ops_impl/compiler.py +56 -0
  137. mindspore/lib/plugin/ascend/custom_aicore_ops/op_impl/ai_core/tbe/custom_aicore_ops_impl/custom.py +1109 -0
  138. mindspore/lib/plugin/ascend/custom_aicore_ops/op_impl/ai_core/tbe/custom_aicore_ops_impl/get_file_path.py +36 -0
  139. mindspore/lib/plugin/ascend/custom_aicore_ops/op_impl/ai_core/tbe/custom_aicore_ops_impl/kv_cache_mgr.py +0 -2
  140. mindspore/lib/plugin/ascend/custom_aicore_ops/op_impl/ai_core/tbe/custom_aicore_ops_impl/tbe_topi.py +556 -0
  141. mindspore/lib/plugin/ascend/custom_aicore_ops/op_impl/vector_core/tbe/custom_aicore_ops_impl/kv_cache_mgr.py +0 -2
  142. mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/aicpu_kernel/impl/libcust_cpu_kernels.so +0 -0
  143. mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/config/cust_aicpu_kernel.json +6325 -1767
  144. mindspore/lib/plugin/ascend/custom_aicpu_ops/op_proto/libcust_op_proto.so +0 -0
  145. mindspore/lib/plugin/ascend/custom_ascendc_ops/op_api/include/aclnn_add_custom.h +49 -0
  146. mindspore/lib/plugin/ascend/custom_ascendc_ops/op_api/include/aclnn_decoder_kv_cache.h +59 -0
  147. mindspore/lib/plugin/ascend/custom_ascendc_ops/op_api/include/aclnn_prompt_kv_cache.h +59 -0
  148. mindspore/lib/plugin/ascend/custom_ascendc_ops/op_api/lib/libcust_opapi.so +0 -0
  149. mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/config/ascend310p/aic-ascend310p-ops-info.json +52 -0
  150. mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/config/ascend910/aic-ascend910-ops-info.json +232 -0
  151. mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/config/ascend910b/aic-ascend910b-ops-info.json +232 -0
  152. mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/custom_ascendc_ops_impl/dynamic/add_custom.cpp +81 -0
  153. mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/custom_ascendc_ops_impl/dynamic/add_custom.py +134 -0
  154. mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/custom_ascendc_ops_impl/dynamic/decoder_kv_cache.cpp +192 -0
  155. mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/custom_ascendc_ops_impl/dynamic/decoder_kv_cache.py +134 -0
  156. mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/custom_ascendc_ops_impl/dynamic/prompt_kv_cache.cpp +274 -0
  157. mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/custom_ascendc_ops_impl/dynamic/prompt_kv_cache.py +134 -0
  158. mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/op_tiling/lib/linux/x86_64/libcust_opmaster_rt2.0.so +0 -0
  159. mindspore/lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/op_tiling/liboptiling.so +0 -0
  160. mindspore/lib/plugin/ascend/custom_ascendc_ops/op_proto/inc/op_proto.h +39 -0
  161. mindspore/lib/plugin/ascend/custom_ascendc_ops/op_proto/lib/linux/x86_64/libcust_opsproto_rt2.0.so +0 -0
  162. mindspore/lib/plugin/ascend/libakg.so +0 -0
  163. mindspore/lib/plugin/ascend/libascend_collective.so +0 -0
  164. mindspore/lib/plugin/ascend/libdvpp_utils.so +0 -0
  165. mindspore/lib/plugin/ascend/libhccl_plugin.so +0 -0
  166. mindspore/lib/plugin/ascend/libmindspore_cpu_kernels.so +0 -0
  167. mindspore/lib/plugin/cpu/libakg.so +0 -0
  168. mindspore/lib/plugin/gpu/libcuda_ops.so.10 +0 -0
  169. mindspore/lib/plugin/gpu/libcuda_ops.so.11 +0 -0
  170. mindspore/lib/plugin/gpu10.1/libakg.so +0 -0
  171. mindspore/lib/plugin/gpu10.1/libnccl.so.2 +0 -0
  172. mindspore/lib/plugin/gpu10.1/libnvidia_collective.so +0 -0
  173. mindspore/lib/plugin/gpu11.1/libakg.so +0 -0
  174. mindspore/lib/plugin/gpu11.1/libnccl.so.2 +0 -0
  175. mindspore/lib/plugin/gpu11.1/libnvidia_collective.so +0 -0
  176. mindspore/lib/plugin/gpu11.6/libakg.so +0 -0
  177. mindspore/lib/plugin/gpu11.6/libnccl.so.2 +0 -0
  178. mindspore/lib/plugin/gpu11.6/libnvidia_collective.so +0 -0
  179. mindspore/lib/plugin/{libmindspore_ascend.so.1 → libmindspore_ascend.so.2} +0 -0
  180. mindspore/lib/plugin/libmindspore_gpu.so.10.1 +0 -0
  181. mindspore/lib/plugin/libmindspore_gpu.so.11.1 +0 -0
  182. mindspore/lib/plugin/libmindspore_gpu.so.11.6 +0 -0
  183. mindspore/mindrecord/__init__.py +5 -1
  184. mindspore/mindrecord/config.py +809 -0
  185. mindspore/mindrecord/filereader.py +25 -0
  186. mindspore/mindrecord/filewriter.py +74 -56
  187. mindspore/mindrecord/mindpage.py +40 -6
  188. mindspore/mindrecord/shardutils.py +3 -2
  189. mindspore/mindrecord/shardwriter.py +7 -0
  190. mindspore/mindrecord/tools/cifar100_to_mr.py +8 -13
  191. mindspore/mindrecord/tools/cifar10_to_mr.py +9 -15
  192. mindspore/mindrecord/tools/csv_to_mr.py +4 -9
  193. mindspore/mindrecord/tools/imagenet_to_mr.py +3 -8
  194. mindspore/mindrecord/tools/mnist_to_mr.py +7 -12
  195. mindspore/mindrecord/tools/tfrecord_to_mr.py +1 -6
  196. mindspore/multiprocessing/__init__.py +68 -0
  197. mindspore/nn/cell.py +86 -133
  198. mindspore/nn/dynamic_lr.py +2 -2
  199. mindspore/nn/layer/activation.py +79 -90
  200. mindspore/nn/layer/basic.py +4 -80
  201. mindspore/nn/layer/channel_shuffle.py +3 -16
  202. mindspore/nn/layer/container.py +3 -3
  203. mindspore/nn/layer/conv.py +71 -71
  204. mindspore/nn/layer/embedding.py +105 -44
  205. mindspore/nn/layer/image.py +4 -7
  206. mindspore/nn/layer/normalization.py +46 -38
  207. mindspore/nn/layer/padding.py +26 -39
  208. mindspore/nn/layer/pooling.py +13 -9
  209. mindspore/nn/layer/rnn_cells.py +5 -15
  210. mindspore/nn/layer/rnns.py +6 -5
  211. mindspore/nn/layer/thor_layer.py +1 -2
  212. mindspore/nn/layer/timedistributed.py +1 -1
  213. mindspore/nn/layer/transformer.py +52 -50
  214. mindspore/nn/learning_rate_schedule.py +6 -5
  215. mindspore/nn/loss/loss.py +43 -64
  216. mindspore/nn/optim/ada_grad.py +4 -2
  217. mindspore/nn/optim/adadelta.py +3 -1
  218. mindspore/nn/optim/adafactor.py +1 -1
  219. mindspore/nn/optim/adam.py +102 -181
  220. mindspore/nn/optim/adamax.py +4 -2
  221. mindspore/nn/optim/adasum.py +2 -2
  222. mindspore/nn/optim/asgd.py +4 -2
  223. mindspore/nn/optim/ftrl.py +31 -61
  224. mindspore/nn/optim/lamb.py +5 -3
  225. mindspore/nn/optim/lars.py +2 -2
  226. mindspore/nn/optim/lazyadam.py +6 -4
  227. mindspore/nn/optim/momentum.py +13 -25
  228. mindspore/nn/optim/optimizer.py +6 -3
  229. mindspore/nn/optim/proximal_ada_grad.py +4 -2
  230. mindspore/nn/optim/rmsprop.py +9 -3
  231. mindspore/nn/optim/rprop.py +4 -2
  232. mindspore/nn/optim/sgd.py +6 -5
  233. mindspore/nn/optim/thor.py +2 -2
  234. mindspore/nn/probability/distribution/_utils/custom_ops.py +2 -2
  235. mindspore/nn/probability/distribution/beta.py +2 -2
  236. mindspore/nn/probability/distribution/categorical.py +4 -6
  237. mindspore/nn/probability/distribution/cauchy.py +2 -2
  238. mindspore/nn/probability/distribution/exponential.py +1 -1
  239. mindspore/nn/probability/distribution/gumbel.py +2 -2
  240. mindspore/nn/probability/distribution/poisson.py +2 -2
  241. mindspore/nn/probability/distribution/uniform.py +2 -2
  242. mindspore/nn/reinforcement/_tensors_queue.py +13 -1
  243. mindspore/nn/wrap/__init__.py +2 -1
  244. mindspore/nn/wrap/cell_wrapper.py +33 -12
  245. mindspore/nn/wrap/grad_reducer.py +148 -8
  246. mindspore/nn/wrap/loss_scale.py +7 -7
  247. mindspore/numpy/__init__.py +2 -0
  248. mindspore/numpy/array_creations.py +2 -0
  249. mindspore/numpy/array_ops.py +1 -5
  250. mindspore/numpy/fft.py +431 -0
  251. mindspore/numpy/math_ops.py +54 -60
  252. mindspore/numpy/utils.py +3 -0
  253. mindspore/ops/__init__.py +5 -4
  254. mindspore/ops/_grad_experimental/grad_array_ops.py +4 -129
  255. mindspore/ops/_grad_experimental/grad_comm_ops.py +16 -22
  256. mindspore/ops/_grad_experimental/grad_math_ops.py +68 -283
  257. mindspore/ops/_grad_experimental/grad_nn_ops.py +0 -53
  258. mindspore/ops/_grad_experimental/grad_quant_ops.py +3 -3
  259. mindspore/ops/_grad_experimental/grad_sparse.py +1 -1
  260. mindspore/ops/_grad_experimental/grad_sparse_ops.py +3 -3
  261. mindspore/ops/_op_impl/__init__.py +0 -1
  262. mindspore/ops/_op_impl/aicpu/gamma.py +2 -0
  263. mindspore/ops/_op_impl/aicpu/generate_eod_mask.py +1 -1
  264. mindspore/ops/_op_impl/aicpu/log_uniform_candidate_sampler.py +1 -3
  265. mindspore/ops/_op_impl/aicpu/poisson.py +2 -0
  266. mindspore/ops/_op_impl/cpu/__init__.py +1 -3
  267. mindspore/ops/_op_impl/cpu/adam.py +2 -2
  268. mindspore/ops/_op_impl/cpu/adam_weight_decay.py +3 -2
  269. mindspore/ops/_op_impl/cpu/maximum_grad.py +16 -14
  270. mindspore/ops/_op_impl/cpu/minimum_grad.py +8 -0
  271. mindspore/ops/_vmap/vmap_array_ops.py +137 -101
  272. mindspore/ops/_vmap/vmap_base.py +8 -1
  273. mindspore/ops/_vmap/vmap_grad_math_ops.py +95 -9
  274. mindspore/ops/_vmap/vmap_grad_nn_ops.py +102 -56
  275. mindspore/ops/_vmap/vmap_image_ops.py +70 -13
  276. mindspore/ops/_vmap/vmap_math_ops.py +74 -49
  277. mindspore/ops/_vmap/vmap_nn_ops.py +164 -89
  278. mindspore/ops/_vmap/vmap_other_ops.py +1 -1
  279. mindspore/ops/auto_generate/__init__.py +31 -0
  280. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +133 -0
  281. mindspore/ops/auto_generate/gen_arg_dtype_cast.py +248 -0
  282. mindspore/ops/auto_generate/gen_arg_handler.py +147 -0
  283. mindspore/ops/auto_generate/gen_extend_func.py +130 -0
  284. mindspore/ops/auto_generate/gen_ops_def.py +4786 -0
  285. mindspore/ops/auto_generate/gen_ops_prim.py +8335 -0
  286. mindspore/ops/auto_generate/pyboost_inner_prim.py +77 -0
  287. mindspore/ops/composite/__init__.py +5 -2
  288. mindspore/ops/composite/base.py +118 -17
  289. mindspore/ops/composite/math_ops.py +9 -48
  290. mindspore/ops/composite/multitype_ops/_compile_utils.py +166 -601
  291. mindspore/ops/composite/multitype_ops/_constexpr_utils.py +15 -133
  292. mindspore/ops/composite/multitype_ops/add_impl.py +6 -0
  293. mindspore/ops/composite/multitype_ops/bitwise_and_impl.py +6 -0
  294. mindspore/ops/composite/multitype_ops/bitwise_or_impl.py +6 -0
  295. mindspore/ops/composite/multitype_ops/bitwise_xor_impl.py +6 -0
  296. mindspore/ops/composite/multitype_ops/div_impl.py +8 -0
  297. mindspore/ops/composite/multitype_ops/equal_impl.py +6 -0
  298. mindspore/ops/composite/multitype_ops/floordiv_impl.py +8 -0
  299. mindspore/ops/composite/multitype_ops/getitem_impl.py +6 -0
  300. mindspore/ops/composite/multitype_ops/greater_equal_impl.py +6 -0
  301. mindspore/ops/composite/multitype_ops/greater_impl.py +6 -0
  302. mindspore/ops/composite/multitype_ops/in_impl.py +8 -2
  303. mindspore/ops/composite/multitype_ops/left_shift_impl.py +6 -0
  304. mindspore/ops/composite/multitype_ops/less_equal_impl.py +6 -0
  305. mindspore/ops/composite/multitype_ops/less_impl.py +6 -0
  306. mindspore/ops/composite/multitype_ops/logic_not_impl.py +6 -0
  307. mindspore/ops/composite/multitype_ops/logical_and_impl.py +6 -0
  308. mindspore/ops/composite/multitype_ops/logical_or_impl.py +6 -0
  309. mindspore/ops/composite/multitype_ops/mod_impl.py +6 -0
  310. mindspore/ops/composite/multitype_ops/mul_impl.py +6 -0
  311. mindspore/ops/composite/multitype_ops/negative_impl.py +9 -3
  312. mindspore/ops/composite/multitype_ops/not_equal_impl.py +6 -0
  313. mindspore/ops/composite/multitype_ops/not_in_impl.py +6 -1
  314. mindspore/ops/composite/multitype_ops/ones_like_impl.py +2 -2
  315. mindspore/ops/composite/multitype_ops/pow_impl.py +6 -0
  316. mindspore/ops/composite/multitype_ops/right_shift_impl.py +6 -0
  317. mindspore/ops/composite/multitype_ops/setitem_impl.py +32 -21
  318. mindspore/ops/composite/multitype_ops/sub_impl.py +6 -0
  319. mindspore/ops/composite/multitype_ops/zeros_like_impl.py +6 -3
  320. mindspore/ops/deprecated.py +14 -3
  321. mindspore/ops/extend/__init__.py +46 -0
  322. mindspore/ops/extend/array_func.py +152 -0
  323. mindspore/ops/extend/math_func.py +76 -0
  324. mindspore/ops/{_op_impl/tbe/atomic_addr_clean.py → extend/nn_func.py} +5 -15
  325. mindspore/ops/function/__init__.py +19 -11
  326. mindspore/ops/function/array_func.py +251 -1440
  327. mindspore/ops/function/clip_func.py +12 -13
  328. mindspore/ops/function/debug_func.py +1 -4
  329. mindspore/ops/function/fft_func.py +31 -0
  330. mindspore/ops/function/grad/grad_func.py +24 -17
  331. mindspore/ops/function/image_func.py +27 -21
  332. mindspore/ops/function/linalg_func.py +35 -68
  333. mindspore/ops/function/math_func.py +451 -2360
  334. mindspore/ops/function/nn_func.py +459 -780
  335. mindspore/ops/function/other_func.py +4 -5
  336. mindspore/ops/function/parameter_func.py +5 -93
  337. mindspore/ops/function/random_func.py +24 -80
  338. mindspore/ops/function/sparse_unary_func.py +9 -16
  339. mindspore/ops/function/spectral_func.py +1 -1
  340. mindspore/ops/function/vmap_func.py +14 -14
  341. mindspore/ops/functional.py +56 -62
  342. mindspore/ops/op_info_register.py +22 -19
  343. mindspore/ops/operations/__init__.py +19 -19
  344. mindspore/ops/operations/_grad_ops.py +20 -723
  345. mindspore/ops/operations/_inner_ops.py +178 -286
  346. mindspore/ops/operations/_scalar_ops.py +5 -480
  347. mindspore/ops/operations/_sequence_ops.py +4 -34
  348. mindspore/ops/operations/array_ops.py +99 -2491
  349. mindspore/ops/operations/comm_ops.py +38 -46
  350. mindspore/ops/operations/custom_ops.py +8 -8
  351. mindspore/ops/operations/debug_ops.py +100 -31
  352. mindspore/ops/operations/image_ops.py +1 -217
  353. mindspore/ops/operations/inner_ops.py +3 -38
  354. mindspore/ops/operations/linalg_ops.py +1 -49
  355. mindspore/{rewrite/ast_transformers → ops/operations/manually_defined}/__init__.py +11 -4
  356. mindspore/ops/operations/manually_defined/_inner.py +61 -0
  357. mindspore/ops/operations/manually_defined/ops_def.py +1391 -0
  358. mindspore/ops/operations/math_ops.py +703 -4601
  359. mindspore/ops/operations/nn_ops.py +374 -1748
  360. mindspore/ops/operations/other_ops.py +50 -42
  361. mindspore/ops/operations/random_ops.py +3 -52
  362. mindspore/ops/primitive.py +196 -96
  363. mindspore/ops_generate/__init__.py +27 -0
  364. mindspore/ops_generate/arg_dtype_cast.py +248 -0
  365. mindspore/ops_generate/arg_handler.py +147 -0
  366. mindspore/ops_generate/gen_aclnn_implement.py +266 -0
  367. mindspore/ops_generate/gen_ops.py +1062 -0
  368. mindspore/ops_generate/gen_ops_inner_prim.py +129 -0
  369. mindspore/ops_generate/gen_pyboost_func.py +932 -0
  370. mindspore/ops_generate/gen_utils.py +188 -0
  371. mindspore/ops_generate/op_proto.py +138 -0
  372. mindspore/ops_generate/pyboost_utils.py +364 -0
  373. mindspore/ops_generate/template.py +238 -0
  374. mindspore/parallel/__init__.py +5 -4
  375. mindspore/parallel/_auto_parallel_context.py +21 -76
  376. mindspore/parallel/_cell_wrapper.py +16 -9
  377. mindspore/parallel/_cost_model_context.py +1 -1
  378. mindspore/parallel/_dp_allreduce_fusion.py +159 -159
  379. mindspore/parallel/_parallel_serialization.py +30 -46
  380. mindspore/parallel/_ps_context.py +1 -1
  381. mindspore/parallel/_recovery_context.py +1 -1
  382. mindspore/parallel/_tensor.py +19 -7
  383. mindspore/parallel/_transformer/__init__.py +1 -1
  384. mindspore/parallel/_transformer/layers.py +1 -1
  385. mindspore/parallel/_transformer/loss.py +1 -1
  386. mindspore/parallel/_transformer/moe.py +1 -1
  387. mindspore/parallel/_transformer/op_parallel_config.py +1 -1
  388. mindspore/parallel/_transformer/transformer.py +1 -1
  389. mindspore/parallel/_utils.py +131 -6
  390. mindspore/parallel/algo_parameter_config.py +6 -6
  391. mindspore/parallel/checkpoint_transform.py +180 -196
  392. mindspore/parallel/cluster/__init__.py +15 -0
  393. mindspore/parallel/cluster/process_entity/__init__.py +18 -0
  394. mindspore/parallel/cluster/process_entity/_api.py +345 -0
  395. mindspore/parallel/cluster/process_entity/_utils.py +116 -0
  396. mindspore/parallel/cluster/run.py +139 -0
  397. mindspore/parallel/mpi/__init__.py +1 -1
  398. mindspore/parallel/mpi/_mpi_config.py +1 -1
  399. mindspore/parallel/parameter_broadcast.py +152 -0
  400. mindspore/parallel/shard.py +99 -2
  401. mindspore/profiler/common/util.py +20 -0
  402. mindspore/profiler/envprofiling.py +1 -1
  403. mindspore/{_extends/parallel_compile/tbe_compiler → profiler/parser/ascend_analysis}/__init__.py +1 -1
  404. mindspore/profiler/parser/ascend_analysis/constant.py +66 -0
  405. mindspore/profiler/parser/ascend_analysis/file_manager.py +77 -0
  406. mindspore/profiler/parser/ascend_analysis/function_event.py +146 -0
  407. mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +108 -0
  408. mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +80 -0
  409. mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +52 -0
  410. mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +104 -0
  411. mindspore/profiler/parser/ascend_analysis/tlv_decoder.py +86 -0
  412. mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +59 -0
  413. mindspore/profiler/parser/ascend_cluster_generator.py +14 -9
  414. mindspore/profiler/parser/ascend_communicate_generator.py +0 -1
  415. mindspore/profiler/parser/ascend_flops_generator.py +20 -4
  416. mindspore/profiler/parser/ascend_hccl_generator.py +25 -277
  417. mindspore/profiler/parser/ascend_msprof_exporter.py +112 -132
  418. mindspore/profiler/parser/ascend_msprof_generator.py +68 -285
  419. mindspore/profiler/parser/ascend_op_generator.py +75 -42
  420. mindspore/profiler/parser/ascend_timeline_generator.py +293 -135
  421. mindspore/profiler/parser/base_timeline_generator.py +6 -0
  422. mindspore/profiler/parser/framework_parser.py +3 -2
  423. mindspore/profiler/parser/integrator.py +3 -1
  424. mindspore/profiler/parser/msadvisor_analyzer.py +1 -1
  425. mindspore/profiler/parser/msadvisor_parser.py +1 -1
  426. mindspore/profiler/parser/profiler_info.py +5 -0
  427. mindspore/profiler/profiling.py +296 -166
  428. mindspore/rewrite/__init__.py +2 -13
  429. mindspore/rewrite/api/node.py +121 -35
  430. mindspore/rewrite/api/pattern_engine.py +2 -3
  431. mindspore/rewrite/api/scoped_value.py +16 -15
  432. mindspore/rewrite/api/symbol_tree.py +45 -29
  433. mindspore/rewrite/ast_helpers/__init__.py +3 -6
  434. mindspore/rewrite/ast_helpers/ast_converter.py +143 -0
  435. mindspore/rewrite/ast_helpers/ast_finder.py +48 -0
  436. mindspore/rewrite/ast_helpers/ast_flattener.py +268 -0
  437. mindspore/rewrite/ast_helpers/ast_modifier.py +160 -92
  438. mindspore/rewrite/common/__init__.py +1 -2
  439. mindspore/rewrite/common/config.py +24 -0
  440. mindspore/rewrite/common/{rewrite_elog.py → error_log.py} +39 -39
  441. mindspore/rewrite/{namer.py → common/namer.py} +63 -18
  442. mindspore/rewrite/common/namespace.py +118 -0
  443. mindspore/rewrite/node/__init__.py +5 -5
  444. mindspore/rewrite/node/call_function.py +23 -7
  445. mindspore/rewrite/node/cell_container.py +7 -3
  446. mindspore/rewrite/node/control_flow.py +53 -28
  447. mindspore/rewrite/node/node.py +212 -196
  448. mindspore/rewrite/node/node_manager.py +51 -22
  449. mindspore/rewrite/node/node_topological_manager.py +3 -23
  450. mindspore/rewrite/parsers/__init__.py +12 -0
  451. mindspore/rewrite/parsers/arguments_parser.py +8 -9
  452. mindspore/rewrite/parsers/assign_parser.py +635 -413
  453. mindspore/rewrite/parsers/attribute_parser.py +3 -4
  454. mindspore/rewrite/parsers/class_def_parser.py +107 -144
  455. mindspore/rewrite/parsers/constant_parser.py +5 -5
  456. mindspore/rewrite/parsers/container_parser.py +4 -6
  457. mindspore/rewrite/parsers/expr_parser.py +55 -0
  458. mindspore/rewrite/parsers/for_parser.py +31 -98
  459. mindspore/rewrite/parsers/function_def_parser.py +13 -5
  460. mindspore/rewrite/parsers/if_parser.py +28 -10
  461. mindspore/rewrite/parsers/module_parser.py +8 -182
  462. mindspore/rewrite/parsers/parser.py +1 -5
  463. mindspore/rewrite/parsers/parser_register.py +1 -1
  464. mindspore/rewrite/parsers/return_parser.py +5 -10
  465. mindspore/rewrite/parsers/while_parser.py +59 -0
  466. mindspore/rewrite/sparsify/utils.py +1 -1
  467. mindspore/rewrite/symbol_tree/__init__.py +20 -0
  468. mindspore/rewrite/{symbol_tree.py → symbol_tree/symbol_tree.py} +704 -185
  469. mindspore/rewrite/{symbol_tree_builder.py → symbol_tree/symbol_tree_builder.py} +8 -8
  470. mindspore/rewrite/{symbol_tree_dumper.py → symbol_tree/symbol_tree_dumper.py} +4 -4
  471. mindspore/run_check/_check_version.py +6 -14
  472. mindspore/run_check/run_check.py +1 -1
  473. mindspore/safeguard/rewrite_obfuscation.py +9 -19
  474. mindspore/scipy/__init__.py +2 -1
  475. mindspore/scipy/fft.py +133 -0
  476. mindspore/scipy/linalg.py +140 -55
  477. mindspore/scipy/ops.py +15 -71
  478. mindspore/scipy/ops_grad.py +5 -34
  479. mindspore/scipy/optimize/line_search.py +2 -2
  480. mindspore/scipy/optimize/minimize.py +1 -1
  481. mindspore/train/__init__.py +3 -2
  482. mindspore/train/_utils.py +178 -4
  483. mindspore/train/amp.py +167 -245
  484. mindspore/train/callback/_backup_and_restore.py +4 -4
  485. mindspore/train/callback/_callback.py +4 -4
  486. mindspore/train/callback/_checkpoint.py +39 -13
  487. mindspore/train/callback/_early_stop.py +2 -2
  488. mindspore/train/callback/_landscape.py +14 -8
  489. mindspore/train/callback/_loss_monitor.py +2 -2
  490. mindspore/train/callback/_on_request_exit.py +2 -2
  491. mindspore/train/callback/_reduce_lr_on_plateau.py +2 -2
  492. mindspore/train/callback/_summary_collector.py +7 -7
  493. mindspore/train/callback/_time_monitor.py +2 -2
  494. mindspore/train/data_sink.py +1 -1
  495. mindspore/train/dataset_helper.py +13 -4
  496. mindspore/train/loss_scale_manager.py +2 -2
  497. mindspore/train/metrics/accuracy.py +7 -7
  498. mindspore/train/metrics/confusion_matrix.py +8 -6
  499. mindspore/train/metrics/cosine_similarity.py +6 -4
  500. mindspore/train/metrics/error.py +2 -2
  501. mindspore/train/metrics/metric.py +3 -3
  502. mindspore/train/metrics/perplexity.py +2 -1
  503. mindspore/train/metrics/topk.py +2 -2
  504. mindspore/train/mind_ir_pb2.py +75 -6
  505. mindspore/train/model.py +24 -22
  506. mindspore/train/serialization.py +256 -132
  507. mindspore/train/summary/summary_record.py +51 -28
  508. mindspore/train/train_thor/convert_utils.py +3 -3
  509. mindspore/version.py +1 -1
  510. {mindspore-2.2.14.dist-info → mindspore-2.3.0rc1.dist-info}/METADATA +2 -2
  511. {mindspore-2.2.14.dist-info → mindspore-2.3.0rc1.dist-info}/RECORD +514 -1060
  512. {mindspore-2.2.14.dist-info → mindspore-2.3.0rc1.dist-info}/entry_points.txt +1 -0
  513. mindspore/_extends/parallel_compile/tbe_compiler/tbe_adapter.py +0 -662
  514. mindspore/_extends/parallel_compile/tbe_compiler/tbe_helper.py +0 -377
  515. mindspore/_extends/parallel_compile/tbe_compiler/tbe_job.py +0 -201
  516. mindspore/_extends/parallel_compile/tbe_compiler/tbe_job_manager.py +0 -515
  517. mindspore/config/super_bar_config.json +0 -544
  518. mindspore/gen_ops.py +0 -273
  519. mindspore/lib/plugin/ascend/custom_aicpu_ops/op_impl/cpu/aicpu_kernel/impl/libcust_aicpu_kernels.so +0 -0
  520. mindspore/lib/plugin/ascend/libmindspore_aicpu_kernels.so +0 -0
  521. mindspore/nn/layer/flash_attention.py +0 -189
  522. mindspore/ops/_op_impl/cpu/concat.py +0 -39
  523. mindspore/ops/_op_impl/cpu/tensor_shape.py +0 -42
  524. mindspore/ops/_op_impl/tbe/__init__.py +0 -47
  525. mindspore/ops/_op_impl/tbe/abs.py +0 -38
  526. mindspore/ops/_op_impl/tbe/abs_ds.py +0 -39
  527. mindspore/ops/_op_impl/tbe/abs_grad.py +0 -43
  528. mindspore/ops/_op_impl/tbe/abs_grad_ds.py +0 -44
  529. mindspore/ops/_op_impl/tbe/accumulate_n_v2.py +0 -41
  530. mindspore/ops/_op_impl/tbe/accumulate_n_v2_ds.py +0 -42
  531. mindspore/ops/_op_impl/tbe/acos.py +0 -37
  532. mindspore/ops/_op_impl/tbe/acos_ds.py +0 -38
  533. mindspore/ops/_op_impl/tbe/acos_grad.py +0 -43
  534. mindspore/ops/_op_impl/tbe/acos_grad_ds.py +0 -44
  535. mindspore/ops/_op_impl/tbe/acosh.py +0 -37
  536. mindspore/ops/_op_impl/tbe/acosh_ds.py +0 -38
  537. mindspore/ops/_op_impl/tbe/acosh_grad.py +0 -43
  538. mindspore/ops/_op_impl/tbe/acosh_grad_ds.py +0 -44
  539. mindspore/ops/_op_impl/tbe/act_ulq_clamp_max_grad.py +0 -38
  540. mindspore/ops/_op_impl/tbe/act_ulq_clamp_min_grad.py +0 -38
  541. mindspore/ops/_op_impl/tbe/acts_ulq.py +0 -45
  542. mindspore/ops/_op_impl/tbe/acts_ulq_input_grad.py +0 -38
  543. mindspore/ops/_op_impl/tbe/adam_apply_one.py +0 -50
  544. mindspore/ops/_op_impl/tbe/adam_apply_one_assign.py +0 -53
  545. mindspore/ops/_op_impl/tbe/adam_apply_one_ds.py +0 -51
  546. mindspore/ops/_op_impl/tbe/adam_apply_one_with_decay.py +0 -54
  547. mindspore/ops/_op_impl/tbe/adam_apply_one_with_decay_assign.py +0 -54
  548. mindspore/ops/_op_impl/tbe/adam_apply_one_with_decay_ds.py +0 -55
  549. mindspore/ops/_op_impl/tbe/adaptive_max_pool2d.py +0 -37
  550. mindspore/ops/_op_impl/tbe/add.py +0 -42
  551. mindspore/ops/_op_impl/tbe/add_ds.py +0 -43
  552. mindspore/ops/_op_impl/tbe/add_n.py +0 -39
  553. mindspore/ops/_op_impl/tbe/add_n_ds.py +0 -40
  554. mindspore/ops/_op_impl/tbe/addcdiv.py +0 -41
  555. mindspore/ops/_op_impl/tbe/addcdiv_ds.py +0 -42
  556. mindspore/ops/_op_impl/tbe/addcmul.py +0 -43
  557. mindspore/ops/_op_impl/tbe/addcmul_ds.py +0 -44
  558. mindspore/ops/_op_impl/tbe/apply_ada_max.py +0 -68
  559. mindspore/ops/_op_impl/tbe/apply_ada_max_ds.py +0 -69
  560. mindspore/ops/_op_impl/tbe/apply_adadelta.py +0 -66
  561. mindspore/ops/_op_impl/tbe/apply_adadelta_ds.py +0 -67
  562. mindspore/ops/_op_impl/tbe/apply_adagrad.py +0 -55
  563. mindspore/ops/_op_impl/tbe/apply_adagrad_d_a.py +0 -67
  564. mindspore/ops/_op_impl/tbe/apply_adagrad_ds.py +0 -56
  565. mindspore/ops/_op_impl/tbe/apply_adagrad_v2.py +0 -48
  566. mindspore/ops/_op_impl/tbe/apply_adagrad_v2_ds.py +0 -49
  567. mindspore/ops/_op_impl/tbe/apply_adam.py +0 -79
  568. mindspore/ops/_op_impl/tbe/apply_adam_ds.py +0 -80
  569. mindspore/ops/_op_impl/tbe/apply_adam_with_amsgrad.py +0 -60
  570. mindspore/ops/_op_impl/tbe/apply_adam_with_amsgrad_ds.py +0 -61
  571. mindspore/ops/_op_impl/tbe/apply_add_sign.py +0 -65
  572. mindspore/ops/_op_impl/tbe/apply_add_sign_ds.py +0 -66
  573. mindspore/ops/_op_impl/tbe/apply_centered_rms_prop.py +0 -77
  574. mindspore/ops/_op_impl/tbe/apply_centered_rms_prop_ds.py +0 -78
  575. mindspore/ops/_op_impl/tbe/apply_ftrl.py +0 -67
  576. mindspore/ops/_op_impl/tbe/apply_ftrl_ds.py +0 -68
  577. mindspore/ops/_op_impl/tbe/apply_gradient_descent.py +0 -44
  578. mindspore/ops/_op_impl/tbe/apply_gradient_descent_ds.py +0 -45
  579. mindspore/ops/_op_impl/tbe/apply_keras_momentum.py +0 -49
  580. mindspore/ops/_op_impl/tbe/apply_momentum.py +0 -64
  581. mindspore/ops/_op_impl/tbe/apply_momentum_ds.py +0 -65
  582. mindspore/ops/_op_impl/tbe/apply_power_sign.py +0 -65
  583. mindspore/ops/_op_impl/tbe/apply_power_sign_ds.py +0 -66
  584. mindspore/ops/_op_impl/tbe/apply_proximal_adagrad.py +0 -57
  585. mindspore/ops/_op_impl/tbe/apply_proximal_adagrad_ds.py +0 -58
  586. mindspore/ops/_op_impl/tbe/apply_proximal_gradient_descent.py +0 -54
  587. mindspore/ops/_op_impl/tbe/apply_proximal_gradient_descent_ds.py +0 -55
  588. mindspore/ops/_op_impl/tbe/apply_rms_prop.py +0 -52
  589. mindspore/ops/_op_impl/tbe/approximate_equal.py +0 -39
  590. mindspore/ops/_op_impl/tbe/approximate_equal_ds.py +0 -40
  591. mindspore/ops/_op_impl/tbe/arg_max.py +0 -38
  592. mindspore/ops/_op_impl/tbe/arg_max_with_value.py +0 -38
  593. mindspore/ops/_op_impl/tbe/arg_max_with_value_ds.py +0 -39
  594. mindspore/ops/_op_impl/tbe/arg_min.py +0 -38
  595. mindspore/ops/_op_impl/tbe/arg_min_v2_ds.py +0 -40
  596. mindspore/ops/_op_impl/tbe/arg_min_with_value.py +0 -38
  597. mindspore/ops/_op_impl/tbe/arg_min_with_value_ds.py +0 -39
  598. mindspore/ops/_op_impl/tbe/asin.py +0 -37
  599. mindspore/ops/_op_impl/tbe/asin_ds.py +0 -38
  600. mindspore/ops/_op_impl/tbe/asin_grad.py +0 -43
  601. mindspore/ops/_op_impl/tbe/asin_grad_ds.py +0 -44
  602. mindspore/ops/_op_impl/tbe/asinh.py +0 -37
  603. mindspore/ops/_op_impl/tbe/asinh_ds.py +0 -38
  604. mindspore/ops/_op_impl/tbe/asinh_grad.py +0 -43
  605. mindspore/ops/_op_impl/tbe/asinh_grad_ds.py +0 -44
  606. mindspore/ops/_op_impl/tbe/assign.py +0 -79
  607. mindspore/ops/_op_impl/tbe/assign_add.py +0 -59
  608. mindspore/ops/_op_impl/tbe/assign_add_ds.py +0 -60
  609. mindspore/ops/_op_impl/tbe/assign_ds.py +0 -80
  610. mindspore/ops/_op_impl/tbe/assign_sub.py +0 -55
  611. mindspore/ops/_op_impl/tbe/assign_sub_ds.py +0 -56
  612. mindspore/ops/_op_impl/tbe/atan.py +0 -37
  613. mindspore/ops/_op_impl/tbe/atan2.py +0 -38
  614. mindspore/ops/_op_impl/tbe/atan2_ds.py +0 -39
  615. mindspore/ops/_op_impl/tbe/atan_ds.py +0 -38
  616. mindspore/ops/_op_impl/tbe/atan_grad.py +0 -43
  617. mindspore/ops/_op_impl/tbe/atan_grad_ds.py +0 -44
  618. mindspore/ops/_op_impl/tbe/atanh.py +0 -37
  619. mindspore/ops/_op_impl/tbe/atanh_ds.py +0 -38
  620. mindspore/ops/_op_impl/tbe/avg_pool.py +0 -43
  621. mindspore/ops/_op_impl/tbe/avg_pool_3d.py +0 -44
  622. mindspore/ops/_op_impl/tbe/avg_pool_3d_grad.py +0 -45
  623. mindspore/ops/_op_impl/tbe/avg_pool_ds.py +0 -44
  624. mindspore/ops/_op_impl/tbe/avg_pool_grad.py +0 -42
  625. mindspore/ops/_op_impl/tbe/avg_pool_grad_vm.py +0 -42
  626. mindspore/ops/_op_impl/tbe/basic_lstm_cell.py +0 -57
  627. mindspore/ops/_op_impl/tbe/basic_lstm_cell_c_state_grad.py +0 -50
  628. mindspore/ops/_op_impl/tbe/basic_lstm_cell_c_state_grad_v2.py +0 -51
  629. mindspore/ops/_op_impl/tbe/basic_lstm_cell_input_grad.py +0 -42
  630. mindspore/ops/_op_impl/tbe/basic_lstm_cell_weight_grad.py +0 -41
  631. mindspore/ops/_op_impl/tbe/batch_matmul.py +0 -42
  632. mindspore/ops/_op_impl/tbe/batch_matmul_ds.py +0 -41
  633. mindspore/ops/_op_impl/tbe/batch_matmul_v2.py +0 -47
  634. mindspore/ops/_op_impl/tbe/batch_to_space.py +0 -38
  635. mindspore/ops/_op_impl/tbe/batch_to_space_nd.py +0 -38
  636. mindspore/ops/_op_impl/tbe/batch_to_space_nd_ds.py +0 -39
  637. mindspore/ops/_op_impl/tbe/batch_to_space_nd_v2.py +0 -41
  638. mindspore/ops/_op_impl/tbe/batchnorm.py +0 -58
  639. mindspore/ops/_op_impl/tbe/batchnorm_grad.py +0 -58
  640. mindspore/ops/_op_impl/tbe/bce_with_logits_loss.py +0 -42
  641. mindspore/ops/_op_impl/tbe/bessel_i0e.py +0 -37
  642. mindspore/ops/_op_impl/tbe/bessel_i0e_ds.py +0 -38
  643. mindspore/ops/_op_impl/tbe/bessel_i1e.py +0 -37
  644. mindspore/ops/_op_impl/tbe/bessel_i1e_ds.py +0 -38
  645. mindspore/ops/_op_impl/tbe/bias_add.py +0 -38
  646. mindspore/ops/_op_impl/tbe/bias_add_ds.py +0 -39
  647. mindspore/ops/_op_impl/tbe/bias_add_grad.py +0 -53
  648. mindspore/ops/_op_impl/tbe/binary_cross_entropy.py +0 -39
  649. mindspore/ops/_op_impl/tbe/binary_cross_entropy_ds.py +0 -40
  650. mindspore/ops/_op_impl/tbe/binary_cross_entropy_grad.py +0 -44
  651. mindspore/ops/_op_impl/tbe/binary_cross_entropy_grad_ds.py +0 -45
  652. mindspore/ops/_op_impl/tbe/bitwise_and.py +0 -39
  653. mindspore/ops/_op_impl/tbe/bitwise_and_ds.py +0 -40
  654. mindspore/ops/_op_impl/tbe/bitwise_or.py +0 -39
  655. mindspore/ops/_op_impl/tbe/bitwise_or_ds.py +0 -40
  656. mindspore/ops/_op_impl/tbe/bitwise_xor.py +0 -39
  657. mindspore/ops/_op_impl/tbe/bitwise_xor_ds.py +0 -40
  658. mindspore/ops/_op_impl/tbe/bn_infer.py +0 -43
  659. mindspore/ops/_op_impl/tbe/bn_infer_ds.py +0 -45
  660. mindspore/ops/_op_impl/tbe/bn_infer_grad.py +0 -41
  661. mindspore/ops/_op_impl/tbe/bn_infer_grad_ds.py +0 -40
  662. mindspore/ops/_op_impl/tbe/bn_inference.py +0 -50
  663. mindspore/ops/_op_impl/tbe/bn_training_reduce.py +0 -38
  664. mindspore/ops/_op_impl/tbe/bn_training_reduce_ds.py +0 -39
  665. mindspore/ops/_op_impl/tbe/bn_training_reduce_grad.py +0 -46
  666. mindspore/ops/_op_impl/tbe/bn_training_reduce_grad_ds.py +0 -47
  667. mindspore/ops/_op_impl/tbe/bn_training_update.py +0 -52
  668. mindspore/ops/_op_impl/tbe/bn_training_update_ds.py +0 -53
  669. mindspore/ops/_op_impl/tbe/bn_training_update_grad.py +0 -44
  670. mindspore/ops/_op_impl/tbe/bn_training_update_grad_ds.py +0 -45
  671. mindspore/ops/_op_impl/tbe/bn_training_update_v2.py +0 -48
  672. mindspore/ops/_op_impl/tbe/bn_training_update_v3.py +0 -51
  673. mindspore/ops/_op_impl/tbe/bounding_box_decode.py +0 -41
  674. mindspore/ops/_op_impl/tbe/bounding_box_decode_ds.py +0 -42
  675. mindspore/ops/_op_impl/tbe/bounding_box_encode.py +0 -38
  676. mindspore/ops/_op_impl/tbe/broadcast_to.py +0 -40
  677. mindspore/ops/_op_impl/tbe/broadcast_to_ds.py +0 -44
  678. mindspore/ops/_op_impl/tbe/cast.py +0 -55
  679. mindspore/ops/_op_impl/tbe/cast_ds.py +0 -58
  680. mindspore/ops/_op_impl/tbe/cdist.py +0 -38
  681. mindspore/ops/_op_impl/tbe/cdist_grad.py +0 -42
  682. mindspore/ops/_op_impl/tbe/ceil.py +0 -37
  683. mindspore/ops/_op_impl/tbe/ceil_ds.py +0 -38
  684. mindspore/ops/_op_impl/tbe/celu.py +0 -39
  685. mindspore/ops/_op_impl/tbe/centralization.py +0 -39
  686. mindspore/ops/_op_impl/tbe/check_valid.py +0 -38
  687. mindspore/ops/_op_impl/tbe/check_valid_ds.py +0 -39
  688. mindspore/ops/_op_impl/tbe/clip_by_norm_no_div_sum.py +0 -41
  689. mindspore/ops/_op_impl/tbe/clip_by_norm_no_div_sum_ds.py +0 -42
  690. mindspore/ops/_op_impl/tbe/clip_by_value.py +0 -41
  691. mindspore/ops/_op_impl/tbe/clip_by_value_ds.py +0 -42
  692. mindspore/ops/_op_impl/tbe/concat.py +0 -40
  693. mindspore/ops/_op_impl/tbe/concat_ds.py +0 -38
  694. mindspore/ops/_op_impl/tbe/confusion_matrix.py +0 -63
  695. mindspore/ops/_op_impl/tbe/confusion_mul_grad.py +0 -40
  696. mindspore/ops/_op_impl/tbe/confusion_softmax_grad.py +0 -41
  697. mindspore/ops/_op_impl/tbe/confusion_transpose_d.py +0 -39
  698. mindspore/ops/_op_impl/tbe/conv2d.py +0 -47
  699. mindspore/ops/_op_impl/tbe/conv2d_backprop_filter.py +0 -42
  700. mindspore/ops/_op_impl/tbe/conv2d_backprop_filter_ds.py +0 -43
  701. mindspore/ops/_op_impl/tbe/conv2d_backprop_input.py +0 -42
  702. mindspore/ops/_op_impl/tbe/conv2d_backprop_input_ds.py +0 -44
  703. mindspore/ops/_op_impl/tbe/conv2d_ds.py +0 -47
  704. mindspore/ops/_op_impl/tbe/conv2d_transpose.py +0 -48
  705. mindspore/ops/_op_impl/tbe/conv3d.py +0 -45
  706. mindspore/ops/_op_impl/tbe/conv3d_backprop_filter.py +0 -42
  707. mindspore/ops/_op_impl/tbe/conv3d_backprop_input.py +0 -42
  708. mindspore/ops/_op_impl/tbe/conv3d_transpose.py +0 -47
  709. mindspore/ops/_op_impl/tbe/conv3d_transpose_ds.py +0 -48
  710. mindspore/ops/_op_impl/tbe/cos.py +0 -37
  711. mindspore/ops/_op_impl/tbe/cos_ds.py +0 -38
  712. mindspore/ops/_op_impl/tbe/cosh.py +0 -37
  713. mindspore/ops/_op_impl/tbe/cosh_ds.py +0 -38
  714. mindspore/ops/_op_impl/tbe/ctc_loss_v2.py +0 -42
  715. mindspore/ops/_op_impl/tbe/ctc_loss_v2_grad.py +0 -44
  716. mindspore/ops/_op_impl/tbe/cum_sum.py +0 -42
  717. mindspore/ops/_op_impl/tbe/cum_sum_ds.py +0 -44
  718. mindspore/ops/_op_impl/tbe/cummin.py +0 -41
  719. mindspore/ops/_op_impl/tbe/cumprod.py +0 -42
  720. mindspore/ops/_op_impl/tbe/data_format_dim_map.py +0 -38
  721. mindspore/ops/_op_impl/tbe/data_format_dim_map_ds.py +0 -40
  722. mindspore/ops/_op_impl/tbe/deformable_offsets.py +0 -45
  723. mindspore/ops/_op_impl/tbe/deformable_offsets_grad.py +0 -48
  724. mindspore/ops/_op_impl/tbe/depth_to_space_ds.py +0 -49
  725. mindspore/ops/_op_impl/tbe/depthwise_conv2d.py +0 -44
  726. mindspore/ops/_op_impl/tbe/depthwise_conv2d_backprop_filter.py +0 -41
  727. mindspore/ops/_op_impl/tbe/depthwise_conv2d_backprop_input.py +0 -41
  728. mindspore/ops/_op_impl/tbe/diag.py +0 -38
  729. mindspore/ops/_op_impl/tbe/diag_part.py +0 -38
  730. mindspore/ops/_op_impl/tbe/dilation.py +0 -40
  731. mindspore/ops/_op_impl/tbe/div.py +0 -41
  732. mindspore/ops/_op_impl/tbe/div_ds.py +0 -42
  733. mindspore/ops/_op_impl/tbe/div_no_nan.py +0 -41
  734. mindspore/ops/_op_impl/tbe/div_no_nan_ds.py +0 -42
  735. mindspore/ops/_op_impl/tbe/dropout_do_mask.py +0 -38
  736. mindspore/ops/_op_impl/tbe/dropout_do_mask_ds.py +0 -39
  737. mindspore/ops/_op_impl/tbe/dropout_do_mask_v3.py +0 -39
  738. mindspore/ops/_op_impl/tbe/dynamic_atomic_addr_clean.py +0 -34
  739. mindspore/ops/_op_impl/tbe/dynamic_gru_v2.py +0 -95
  740. mindspore/ops/_op_impl/tbe/dynamic_rnn.py +0 -82
  741. mindspore/ops/_op_impl/tbe/elu.py +0 -38
  742. mindspore/ops/_op_impl/tbe/elu_ds.py +0 -39
  743. mindspore/ops/_op_impl/tbe/elu_grad.py +0 -43
  744. mindspore/ops/_op_impl/tbe/elu_grad_ds.py +0 -44
  745. mindspore/ops/_op_impl/tbe/equal.py +0 -42
  746. mindspore/ops/_op_impl/tbe/equal_ds.py +0 -42
  747. mindspore/ops/_op_impl/tbe/erf.py +0 -37
  748. mindspore/ops/_op_impl/tbe/erf_ds.py +0 -38
  749. mindspore/ops/_op_impl/tbe/erfc.py +0 -37
  750. mindspore/ops/_op_impl/tbe/erfc_ds.py +0 -38
  751. mindspore/ops/_op_impl/tbe/erfinv.py +0 -36
  752. mindspore/ops/_op_impl/tbe/exp.py +0 -40
  753. mindspore/ops/_op_impl/tbe/exp_ds.py +0 -41
  754. mindspore/ops/_op_impl/tbe/expand_dims.py +0 -38
  755. mindspore/ops/_op_impl/tbe/expm1.py +0 -37
  756. mindspore/ops/_op_impl/tbe/expm1_ds.py +0 -38
  757. mindspore/ops/_op_impl/tbe/extract_image_patches.py +0 -41
  758. mindspore/ops/_op_impl/tbe/extract_volume_patches.py +0 -39
  759. mindspore/ops/_op_impl/tbe/fake_quant_with_min_max_vars.py +0 -39
  760. mindspore/ops/_op_impl/tbe/fake_quant_with_min_max_vars_gradient.py +0 -43
  761. mindspore/ops/_op_impl/tbe/fake_quant_with_min_max_vars_per_channel.py +0 -39
  762. mindspore/ops/_op_impl/tbe/fake_quant_with_min_max_vars_per_channel_gradient.py +0 -43
  763. mindspore/ops/_op_impl/tbe/fast_gelu.py +0 -37
  764. mindspore/ops/_op_impl/tbe/fast_gelu_ds.py +0 -38
  765. mindspore/ops/_op_impl/tbe/fast_gelu_grad.py +0 -41
  766. mindspore/ops/_op_impl/tbe/fast_gelu_grad_ds.py +0 -42
  767. mindspore/ops/_op_impl/tbe/fill.py +0 -56
  768. mindspore/ops/_op_impl/tbe/fill_ds.py +0 -42
  769. mindspore/ops/_op_impl/tbe/flatten.py +0 -48
  770. mindspore/ops/_op_impl/tbe/floor.py +0 -37
  771. mindspore/ops/_op_impl/tbe/floor_div.py +0 -41
  772. mindspore/ops/_op_impl/tbe/floor_div_ds.py +0 -42
  773. mindspore/ops/_op_impl/tbe/floor_ds.py +0 -38
  774. mindspore/ops/_op_impl/tbe/floor_mod.py +0 -39
  775. mindspore/ops/_op_impl/tbe/floor_mod_ds.py +0 -40
  776. mindspore/ops/_op_impl/tbe/fused_dbn_dw.py +0 -52
  777. mindspore/ops/_op_impl/tbe/fused_mul_add.py +0 -38
  778. mindspore/ops/_op_impl/tbe/fused_mul_add_n.py +0 -48
  779. mindspore/ops/_op_impl/tbe/fused_mul_add_n_l2loss.py +0 -53
  780. mindspore/ops/_op_impl/tbe/fused_mul_apply_momentum.py +0 -57
  781. mindspore/ops/_op_impl/tbe/fused_mul_apply_momentum_extern.py +0 -67
  782. mindspore/ops/_op_impl/tbe/gather_nd.py +0 -52
  783. mindspore/ops/_op_impl/tbe/gather_nd_ds.py +0 -48
  784. mindspore/ops/_op_impl/tbe/gather_v2.py +0 -56
  785. mindspore/ops/_op_impl/tbe/gather_v2_ds.py +0 -68
  786. mindspore/ops/_op_impl/tbe/gelu.py +0 -37
  787. mindspore/ops/_op_impl/tbe/gelu_ds.py +0 -38
  788. mindspore/ops/_op_impl/tbe/gelu_grad.py +0 -42
  789. mindspore/ops/_op_impl/tbe/gelu_grad_ds.py +0 -43
  790. mindspore/ops/_op_impl/tbe/ger.py +0 -43
  791. mindspore/ops/_op_impl/tbe/ger_ds.py +0 -44
  792. mindspore/ops/_op_impl/tbe/greater.py +0 -43
  793. mindspore/ops/_op_impl/tbe/greater_equal.py +0 -41
  794. mindspore/ops/_op_impl/tbe/greater_equal_ds.py +0 -42
  795. mindspore/ops/_op_impl/tbe/gru_v2_hidden_grad.py +0 -51
  796. mindspore/ops/_op_impl/tbe/gru_v2_hidden_grad_cell.py +0 -52
  797. mindspore/ops/_op_impl/tbe/hard_swish.py +0 -37
  798. mindspore/ops/_op_impl/tbe/hard_swish_ds.py +0 -38
  799. mindspore/ops/_op_impl/tbe/hard_swish_grad.py +0 -41
  800. mindspore/ops/_op_impl/tbe/hard_swish_grad_ds.py +0 -42
  801. mindspore/ops/_op_impl/tbe/histogram_fixed_width.py +0 -40
  802. mindspore/ops/_op_impl/tbe/hshrink.py +0 -33
  803. mindspore/ops/_op_impl/tbe/hshrink_grad.py +0 -37
  804. mindspore/ops/_op_impl/tbe/hsigmoid.py +0 -45
  805. mindspore/ops/_op_impl/tbe/hsigmoid_grad.py +0 -39
  806. mindspore/ops/_op_impl/tbe/ifmr.py +0 -47
  807. mindspore/ops/_op_impl/tbe/ifmr_ds.py +0 -48
  808. mindspore/ops/_op_impl/tbe/im2col.py +0 -42
  809. mindspore/ops/_op_impl/tbe/in_top_k.py +0 -37
  810. mindspore/ops/_op_impl/tbe/inplace_add.py +0 -39
  811. mindspore/ops/_op_impl/tbe/inplace_index_add.py +0 -46
  812. mindspore/ops/_op_impl/tbe/inplace_sub.py +0 -39
  813. mindspore/ops/_op_impl/tbe/inplace_update.py +0 -39
  814. mindspore/ops/_op_impl/tbe/inplace_update_ds.py +0 -40
  815. mindspore/ops/_op_impl/tbe/inv.py +0 -38
  816. mindspore/ops/_op_impl/tbe/inv_ds.py +0 -39
  817. mindspore/ops/_op_impl/tbe/inv_grad.py +0 -40
  818. mindspore/ops/_op_impl/tbe/inv_grad_ds.py +0 -41
  819. mindspore/ops/_op_impl/tbe/invert.py +0 -37
  820. mindspore/ops/_op_impl/tbe/invert_ds.py +0 -38
  821. mindspore/ops/_op_impl/tbe/iou.py +0 -38
  822. mindspore/ops/_op_impl/tbe/iou_ds.py +0 -39
  823. mindspore/ops/_op_impl/tbe/is_close.py +0 -40
  824. mindspore/ops/_op_impl/tbe/kl_div_loss.py +0 -38
  825. mindspore/ops/_op_impl/tbe/kl_div_loss_ds.py +0 -39
  826. mindspore/ops/_op_impl/tbe/kl_div_loss_grad.py +0 -40
  827. mindspore/ops/_op_impl/tbe/l2_loss.py +0 -36
  828. mindspore/ops/_op_impl/tbe/l2_loss_ds.py +0 -37
  829. mindspore/ops/_op_impl/tbe/l2_normalize.py +0 -38
  830. mindspore/ops/_op_impl/tbe/l2_normalize_grad.py +0 -40
  831. mindspore/ops/_op_impl/tbe/lamb_apply_optimizer_assign.py +0 -55
  832. mindspore/ops/_op_impl/tbe/lamb_apply_weight_assign.py +0 -42
  833. mindspore/ops/_op_impl/tbe/lamb_next_mv.py +0 -59
  834. mindspore/ops/_op_impl/tbe/lamb_next_mv_with_decay.py +0 -59
  835. mindspore/ops/_op_impl/tbe/lamb_next_right.py +0 -44
  836. mindspore/ops/_op_impl/tbe/lamb_update_with_lr.py +0 -48
  837. mindspore/ops/_op_impl/tbe/lamb_update_with_lr_v2.py +0 -44
  838. mindspore/ops/_op_impl/tbe/lars_update.py +0 -50
  839. mindspore/ops/_op_impl/tbe/lars_update_ds.py +0 -51
  840. mindspore/ops/_op_impl/tbe/layer_norm.py +0 -46
  841. mindspore/ops/_op_impl/tbe/layer_norm_beta_gamma_backprop.py +0 -44
  842. mindspore/ops/_op_impl/tbe/layer_norm_beta_gamma_backprop_ds.py +0 -45
  843. mindspore/ops/_op_impl/tbe/layer_norm_beta_gamma_backprop_v2.py +0 -40
  844. mindspore/ops/_op_impl/tbe/layer_norm_beta_gamma_backprop_v2_ds.py +0 -41
  845. mindspore/ops/_op_impl/tbe/layer_norm_ds.py +0 -47
  846. mindspore/ops/_op_impl/tbe/layer_norm_grad.py +0 -48
  847. mindspore/ops/_op_impl/tbe/layer_norm_x_backprop.py +0 -43
  848. mindspore/ops/_op_impl/tbe/layer_norm_x_backprop_ds.py +0 -44
  849. mindspore/ops/_op_impl/tbe/layer_norm_x_backprop_v2.py +0 -45
  850. mindspore/ops/_op_impl/tbe/layer_norm_x_backprop_v2_ds.py +0 -45
  851. mindspore/ops/_op_impl/tbe/lerp.py +0 -38
  852. mindspore/ops/_op_impl/tbe/less.py +0 -41
  853. mindspore/ops/_op_impl/tbe/less_ds.py +0 -42
  854. mindspore/ops/_op_impl/tbe/less_equal.py +0 -41
  855. mindspore/ops/_op_impl/tbe/less_equal_ds.py +0 -42
  856. mindspore/ops/_op_impl/tbe/log.py +0 -40
  857. mindspore/ops/_op_impl/tbe/log1p.py +0 -37
  858. mindspore/ops/_op_impl/tbe/log1p_ds.py +0 -38
  859. mindspore/ops/_op_impl/tbe/log_ds.py +0 -41
  860. mindspore/ops/_op_impl/tbe/logical_and.py +0 -37
  861. mindspore/ops/_op_impl/tbe/logical_and_ds.py +0 -38
  862. mindspore/ops/_op_impl/tbe/logical_not.py +0 -36
  863. mindspore/ops/_op_impl/tbe/logical_not_ds.py +0 -37
  864. mindspore/ops/_op_impl/tbe/logical_or.py +0 -37
  865. mindspore/ops/_op_impl/tbe/logical_or_ds.py +0 -38
  866. mindspore/ops/_op_impl/tbe/logsoftmax.py +0 -37
  867. mindspore/ops/_op_impl/tbe/logsoftmax_ds.py +0 -38
  868. mindspore/ops/_op_impl/tbe/logsoftmax_grad.py +0 -38
  869. mindspore/ops/_op_impl/tbe/logsoftmax_grad_ds.py +0 -39
  870. mindspore/ops/_op_impl/tbe/lp_norm.py +0 -40
  871. mindspore/ops/_op_impl/tbe/lp_norm_ds.py +0 -41
  872. mindspore/ops/_op_impl/tbe/lrn.py +0 -41
  873. mindspore/ops/_op_impl/tbe/lrn_grad.py +0 -42
  874. mindspore/ops/_op_impl/tbe/lstm_input_grad.py +0 -51
  875. mindspore/ops/_op_impl/tbe/masked_fill.py +0 -40
  876. mindspore/ops/_op_impl/tbe/masked_fill_ds.py +0 -41
  877. mindspore/ops/_op_impl/tbe/matmul.py +0 -53
  878. mindspore/ops/_op_impl/tbe/matmul_ds.py +0 -47
  879. mindspore/ops/_op_impl/tbe/matmul_v2.py +0 -50
  880. mindspore/ops/_op_impl/tbe/matrix_diag.py +0 -45
  881. mindspore/ops/_op_impl/tbe/matrix_diag_part.py +0 -45
  882. mindspore/ops/_op_impl/tbe/matrix_set_diag.py +0 -46
  883. mindspore/ops/_op_impl/tbe/max_pool.py +0 -39
  884. mindspore/ops/_op_impl/tbe/max_pool3d.py +0 -44
  885. mindspore/ops/_op_impl/tbe/max_pool3d_grad.py +0 -43
  886. mindspore/ops/_op_impl/tbe/max_pool3d_grad_grad.py +0 -44
  887. mindspore/ops/_op_impl/tbe/max_pool_ds.py +0 -40
  888. mindspore/ops/_op_impl/tbe/max_pool_grad.py +0 -43
  889. mindspore/ops/_op_impl/tbe/max_pool_grad_grad.py +0 -41
  890. mindspore/ops/_op_impl/tbe/max_pool_grad_grad_with_argmax.py +0 -41
  891. mindspore/ops/_op_impl/tbe/max_pool_grad_with_argmax.py +0 -42
  892. mindspore/ops/_op_impl/tbe/max_pool_with_argmax.py +0 -40
  893. mindspore/ops/_op_impl/tbe/maximum.py +0 -39
  894. mindspore/ops/_op_impl/tbe/maximum_ds.py +0 -40
  895. mindspore/ops/_op_impl/tbe/maximum_grad.py +0 -46
  896. mindspore/ops/_op_impl/tbe/maximum_grad_ds.py +0 -47
  897. mindspore/ops/_op_impl/tbe/mem_set.py +0 -38
  898. mindspore/ops/_op_impl/tbe/minimum.py +0 -40
  899. mindspore/ops/_op_impl/tbe/minimum_ds.py +0 -41
  900. mindspore/ops/_op_impl/tbe/minimum_grad.py +0 -46
  901. mindspore/ops/_op_impl/tbe/minimum_grad_ds.py +0 -47
  902. mindspore/ops/_op_impl/tbe/mish.py +0 -37
  903. mindspore/ops/_op_impl/tbe/mod.py +0 -41
  904. mindspore/ops/_op_impl/tbe/mod_ds.py +0 -42
  905. mindspore/ops/_op_impl/tbe/mul.py +0 -37
  906. mindspore/ops/_op_impl/tbe/mul_ds.py +0 -38
  907. mindspore/ops/_op_impl/tbe/mul_no_nan.py +0 -39
  908. mindspore/ops/_op_impl/tbe/mul_no_nan_ds.py +0 -40
  909. mindspore/ops/_op_impl/tbe/multilabel_margin_loss.py +0 -39
  910. mindspore/ops/_op_impl/tbe/neg.py +0 -39
  911. mindspore/ops/_op_impl/tbe/neg_ds.py +0 -40
  912. mindspore/ops/_op_impl/tbe/new_im2col.py +0 -40
  913. mindspore/ops/_op_impl/tbe/nll_loss.py +0 -41
  914. mindspore/ops/_op_impl/tbe/nll_loss_grad.py +0 -44
  915. mindspore/ops/_op_impl/tbe/nms_with_mask.py +0 -39
  916. mindspore/ops/_op_impl/tbe/not_equal.py +0 -41
  917. mindspore/ops/_op_impl/tbe/not_equal_ds.py +0 -42
  918. mindspore/ops/_op_impl/tbe/npu_alloc_float_status.py +0 -34
  919. mindspore/ops/_op_impl/tbe/npu_clear_float_status.py +0 -35
  920. mindspore/ops/_op_impl/tbe/npu_clear_float_status_v2.py +0 -35
  921. mindspore/ops/_op_impl/tbe/npu_get_float_status.py +0 -35
  922. mindspore/ops/_op_impl/tbe/npu_get_float_status_v2.py +0 -35
  923. mindspore/ops/_op_impl/tbe/one_hot.py +0 -48
  924. mindspore/ops/_op_impl/tbe/one_hot_ds.py +0 -45
  925. mindspore/ops/_op_impl/tbe/ones_like.py +0 -40
  926. mindspore/ops/_op_impl/tbe/ones_like_ds.py +0 -41
  927. mindspore/ops/_op_impl/tbe/p_s_r_o_i_pooling.py +0 -40
  928. mindspore/ops/_op_impl/tbe/p_s_r_o_i_pooling_grad.py +0 -40
  929. mindspore/ops/_op_impl/tbe/pack.py +0 -58
  930. mindspore/ops/_op_impl/tbe/pack_ds.py +0 -59
  931. mindspore/ops/_op_impl/tbe/pad_d.py +0 -40
  932. mindspore/ops/_op_impl/tbe/pad_d_ds.py +0 -41
  933. mindspore/ops/_op_impl/tbe/parallel_concat.py +0 -70
  934. mindspore/ops/_op_impl/tbe/parallel_resize_bilinear.py +0 -45
  935. mindspore/ops/_op_impl/tbe/parallel_resize_bilinear_grad.py +0 -44
  936. mindspore/ops/_op_impl/tbe/pdist.py +0 -36
  937. mindspore/ops/_op_impl/tbe/pooling.py +0 -46
  938. mindspore/ops/_op_impl/tbe/population_count.py +0 -38
  939. mindspore/ops/_op_impl/tbe/pow.py +0 -41
  940. mindspore/ops/_op_impl/tbe/pow_ds.py +0 -42
  941. mindspore/ops/_op_impl/tbe/prelu.py +0 -37
  942. mindspore/ops/_op_impl/tbe/prelu_ds.py +0 -38
  943. mindspore/ops/_op_impl/tbe/prelu_grad.py +0 -40
  944. mindspore/ops/_op_impl/tbe/range.py +0 -39
  945. mindspore/ops/_op_impl/tbe/real_div.py +0 -38
  946. mindspore/ops/_op_impl/tbe/real_div_ds.py +0 -39
  947. mindspore/ops/_op_impl/tbe/reciprocal.py +0 -36
  948. mindspore/ops/_op_impl/tbe/reciprocal_ds.py +0 -37
  949. mindspore/ops/_op_impl/tbe/reciprocal_grad.py +0 -38
  950. mindspore/ops/_op_impl/tbe/reciprocal_grad_ds.py +0 -39
  951. mindspore/ops/_op_impl/tbe/reduce_all.py +0 -38
  952. mindspore/ops/_op_impl/tbe/reduce_all_ds.py +0 -39
  953. mindspore/ops/_op_impl/tbe/reduce_any.py +0 -38
  954. mindspore/ops/_op_impl/tbe/reduce_any_ds.py +0 -39
  955. mindspore/ops/_op_impl/tbe/reduce_max.py +0 -43
  956. mindspore/ops/_op_impl/tbe/reduce_max_ds.py +0 -41
  957. mindspore/ops/_op_impl/tbe/reduce_mean.py +0 -40
  958. mindspore/ops/_op_impl/tbe/reduce_mean_ds.py +0 -42
  959. mindspore/ops/_op_impl/tbe/reduce_min.py +0 -41
  960. mindspore/ops/_op_impl/tbe/reduce_min_ds.py +0 -41
  961. mindspore/ops/_op_impl/tbe/reduce_prod.py +0 -42
  962. mindspore/ops/_op_impl/tbe/reduce_prod_ds.py +0 -41
  963. mindspore/ops/_op_impl/tbe/reduce_std.py +0 -44
  964. mindspore/ops/_op_impl/tbe/reduce_sum.py +0 -39
  965. mindspore/ops/_op_impl/tbe/reduce_sum_ds.py +0 -41
  966. mindspore/ops/_op_impl/tbe/relu.py +0 -39
  967. mindspore/ops/_op_impl/tbe/relu6.py +0 -38
  968. mindspore/ops/_op_impl/tbe/relu6_ds.py +0 -39
  969. mindspore/ops/_op_impl/tbe/relu6_grad.py +0 -43
  970. mindspore/ops/_op_impl/tbe/relu6_grad_ds.py +0 -44
  971. mindspore/ops/_op_impl/tbe/relu_ds.py +0 -40
  972. mindspore/ops/_op_impl/tbe/relu_grad.py +0 -41
  973. mindspore/ops/_op_impl/tbe/relu_grad_ds.py +0 -42
  974. mindspore/ops/_op_impl/tbe/relu_grad_v2.py +0 -40
  975. mindspore/ops/_op_impl/tbe/relu_grad_v2_ds.py +0 -41
  976. mindspore/ops/_op_impl/tbe/relu_v2.py +0 -40
  977. mindspore/ops/_op_impl/tbe/relu_v2_ds.py +0 -41
  978. mindspore/ops/_op_impl/tbe/renorm.py +0 -39
  979. mindspore/ops/_op_impl/tbe/resize_bilinear.py +0 -40
  980. mindspore/ops/_op_impl/tbe/resize_bilinear_grad.py +0 -41
  981. mindspore/ops/_op_impl/tbe/resize_bilinear_v2.py +0 -43
  982. mindspore/ops/_op_impl/tbe/resize_nearest_neighbor.py +0 -40
  983. mindspore/ops/_op_impl/tbe/resize_nearest_neighbor_ds.py +0 -40
  984. mindspore/ops/_op_impl/tbe/resize_nearest_neighbor_grad.py +0 -39
  985. mindspore/ops/_op_impl/tbe/resize_nearest_neighbor_grad_ds.py +0 -42
  986. mindspore/ops/_op_impl/tbe/reverse_v2_d.py +0 -37
  987. mindspore/ops/_op_impl/tbe/rint.py +0 -37
  988. mindspore/ops/_op_impl/tbe/rint_ds.py +0 -38
  989. mindspore/ops/_op_impl/tbe/roi_align.py +0 -43
  990. mindspore/ops/_op_impl/tbe/roi_align_ds.py +0 -44
  991. mindspore/ops/_op_impl/tbe/roi_align_grad.py +0 -43
  992. mindspore/ops/_op_impl/tbe/roi_align_grad_ds.py +0 -44
  993. mindspore/ops/_op_impl/tbe/roll.py +0 -42
  994. mindspore/ops/_op_impl/tbe/round.py +0 -38
  995. mindspore/ops/_op_impl/tbe/round_ds.py +0 -39
  996. mindspore/ops/_op_impl/tbe/rsqrt.py +0 -37
  997. mindspore/ops/_op_impl/tbe/rsqrt_ds.py +0 -38
  998. mindspore/ops/_op_impl/tbe/rsqrt_grad.py +0 -40
  999. mindspore/ops/_op_impl/tbe/rsqrt_grad_ds.py +0 -41
  1000. mindspore/ops/_op_impl/tbe/scatter_add.py +0 -44
  1001. mindspore/ops/_op_impl/tbe/scatter_div.py +0 -46
  1002. mindspore/ops/_op_impl/tbe/scatter_max.py +0 -45
  1003. mindspore/ops/_op_impl/tbe/scatter_min.py +0 -45
  1004. mindspore/ops/_op_impl/tbe/scatter_mul.py +0 -44
  1005. mindspore/ops/_op_impl/tbe/scatter_nd.py +0 -41
  1006. mindspore/ops/_op_impl/tbe/scatter_nd_add.py +0 -45
  1007. mindspore/ops/_op_impl/tbe/scatter_nd_d.py +0 -41
  1008. mindspore/ops/_op_impl/tbe/scatter_nd_ds.py +0 -49
  1009. mindspore/ops/_op_impl/tbe/scatter_nd_sub.py +0 -47
  1010. mindspore/ops/_op_impl/tbe/scatter_nd_sub_ds.py +0 -48
  1011. mindspore/ops/_op_impl/tbe/scatter_nd_update.py +0 -47
  1012. mindspore/ops/_op_impl/tbe/scatter_nd_update_ds.py +0 -48
  1013. mindspore/ops/_op_impl/tbe/scatter_non_aliasing_add.py +0 -39
  1014. mindspore/ops/_op_impl/tbe/scatter_non_aliasing_add_ds.py +0 -40
  1015. mindspore/ops/_op_impl/tbe/scatter_sub.py +0 -47
  1016. mindspore/ops/_op_impl/tbe/scatter_sub_ds.py +0 -48
  1017. mindspore/ops/_op_impl/tbe/scatter_update.py +0 -43
  1018. mindspore/ops/_op_impl/tbe/select.py +0 -38
  1019. mindspore/ops/_op_impl/tbe/select_ds.py +0 -39
  1020. mindspore/ops/_op_impl/tbe/selu.py +0 -39
  1021. mindspore/ops/_op_impl/tbe/selu_ds.py +0 -40
  1022. mindspore/ops/_op_impl/tbe/sgd.py +0 -62
  1023. mindspore/ops/_op_impl/tbe/sigmoid.py +0 -37
  1024. mindspore/ops/_op_impl/tbe/sigmoid_cross_entropy_with_logits.py +0 -41
  1025. mindspore/ops/_op_impl/tbe/sigmoid_cross_entropy_with_logits_ds.py +0 -42
  1026. mindspore/ops/_op_impl/tbe/sigmoid_cross_entropy_with_logits_grad.py +0 -42
  1027. mindspore/ops/_op_impl/tbe/sigmoid_cross_entropy_with_logits_grad_ds.py +0 -43
  1028. mindspore/ops/_op_impl/tbe/sigmoid_ds.py +0 -38
  1029. mindspore/ops/_op_impl/tbe/sigmoid_grad.py +0 -39
  1030. mindspore/ops/_op_impl/tbe/sigmoid_grad_ds.py +0 -40
  1031. mindspore/ops/_op_impl/tbe/sign.py +0 -38
  1032. mindspore/ops/_op_impl/tbe/sign_ds.py +0 -39
  1033. mindspore/ops/_op_impl/tbe/sin.py +0 -37
  1034. mindspore/ops/_op_impl/tbe/sin_ds.py +0 -38
  1035. mindspore/ops/_op_impl/tbe/sinh.py +0 -37
  1036. mindspore/ops/_op_impl/tbe/sinh_ds.py +0 -38
  1037. mindspore/ops/_op_impl/tbe/slice.py +0 -58
  1038. mindspore/ops/_op_impl/tbe/smooth_l1_loss.py +0 -45
  1039. mindspore/ops/_op_impl/tbe/smooth_l1_loss_ds.py +0 -46
  1040. mindspore/ops/_op_impl/tbe/smooth_l1_loss_grad.py +0 -46
  1041. mindspore/ops/_op_impl/tbe/smooth_l1_loss_grad_ds.py +0 -47
  1042. mindspore/ops/_op_impl/tbe/soft_margin_loss.py +0 -38
  1043. mindspore/ops/_op_impl/tbe/soft_margin_loss_grad.py +0 -39
  1044. mindspore/ops/_op_impl/tbe/soft_shrink.py +0 -36
  1045. mindspore/ops/_op_impl/tbe/soft_shrink_grad.py +0 -38
  1046. mindspore/ops/_op_impl/tbe/softmax.py +0 -37
  1047. mindspore/ops/_op_impl/tbe/softmax_cross_entropy_with_logits.py +0 -38
  1048. mindspore/ops/_op_impl/tbe/softmax_cross_entropy_with_logits_ds.py +0 -39
  1049. mindspore/ops/_op_impl/tbe/softmax_ds.py +0 -38
  1050. mindspore/ops/_op_impl/tbe/softmax_grad_ext.py +0 -42
  1051. mindspore/ops/_op_impl/tbe/softmax_v2_with_dropout_do_mask_v3.py +0 -39
  1052. mindspore/ops/_op_impl/tbe/softplus.py +0 -37
  1053. mindspore/ops/_op_impl/tbe/softplus_ds.py +0 -38
  1054. mindspore/ops/_op_impl/tbe/softplus_grad.py +0 -38
  1055. mindspore/ops/_op_impl/tbe/softplus_grad_ds.py +0 -38
  1056. mindspore/ops/_op_impl/tbe/softsign.py +0 -37
  1057. mindspore/ops/_op_impl/tbe/softsign_ds.py +0 -38
  1058. mindspore/ops/_op_impl/tbe/sort.py +0 -38
  1059. mindspore/ops/_op_impl/tbe/sort_ds.py +0 -39
  1060. mindspore/ops/_op_impl/tbe/space_to_batch.py +0 -38
  1061. mindspore/ops/_op_impl/tbe/space_to_batch_nd.py +0 -38
  1062. mindspore/ops/_op_impl/tbe/space_to_depth.py +0 -47
  1063. mindspore/ops/_op_impl/tbe/sparse_apply_adadelta.py +0 -56
  1064. mindspore/ops/_op_impl/tbe/sparse_apply_adagrad.py +0 -45
  1065. mindspore/ops/_op_impl/tbe/sparse_apply_adagrad_ds.py +0 -46
  1066. mindspore/ops/_op_impl/tbe/sparse_apply_adagrad_v2.py +0 -46
  1067. mindspore/ops/_op_impl/tbe/sparse_apply_adagrad_v2_ds.py +0 -47
  1068. mindspore/ops/_op_impl/tbe/sparse_apply_ftrl_d.py +0 -53
  1069. mindspore/ops/_op_impl/tbe/sparse_apply_ftrl_d_ds.py +0 -50
  1070. mindspore/ops/_op_impl/tbe/sparse_apply_ftrl_v2.py +0 -50
  1071. mindspore/ops/_op_impl/tbe/sparse_apply_proximal_adagrad.py +0 -66
  1072. mindspore/ops/_op_impl/tbe/sparse_apply_proximal_adagrad_ds.py +0 -67
  1073. mindspore/ops/_op_impl/tbe/sparse_apply_r_m_s_prop.py +0 -57
  1074. mindspore/ops/_op_impl/tbe/sparse_apply_r_m_s_prop_ds.py +0 -58
  1075. mindspore/ops/_op_impl/tbe/sparse_gather_v2.py +0 -56
  1076. mindspore/ops/_op_impl/tbe/sparse_gather_v2_ds.py +0 -58
  1077. mindspore/ops/_op_impl/tbe/split_d.py +0 -38
  1078. mindspore/ops/_op_impl/tbe/split_d_ds.py +0 -39
  1079. mindspore/ops/_op_impl/tbe/split_v.py +0 -39
  1080. mindspore/ops/_op_impl/tbe/splitv.py +0 -39
  1081. mindspore/ops/_op_impl/tbe/sqrt.py +0 -37
  1082. mindspore/ops/_op_impl/tbe/sqrt_ds.py +0 -38
  1083. mindspore/ops/_op_impl/tbe/sqrt_grad.py +0 -43
  1084. mindspore/ops/_op_impl/tbe/sqrt_grad_ds.py +0 -44
  1085. mindspore/ops/_op_impl/tbe/square.py +0 -38
  1086. mindspore/ops/_op_impl/tbe/square_ds.py +0 -39
  1087. mindspore/ops/_op_impl/tbe/square_sum_all.py +0 -40
  1088. mindspore/ops/_op_impl/tbe/square_sum_all_ds.py +0 -41
  1089. mindspore/ops/_op_impl/tbe/square_sum_v1.py +0 -38
  1090. mindspore/ops/_op_impl/tbe/square_sum_v1_ds.py +0 -39
  1091. mindspore/ops/_op_impl/tbe/square_sum_v2.py +0 -39
  1092. mindspore/ops/_op_impl/tbe/squared_difference.py +0 -39
  1093. mindspore/ops/_op_impl/tbe/squared_difference_ds.py +0 -41
  1094. mindspore/ops/_op_impl/tbe/squeeze.py +0 -37
  1095. mindspore/ops/_op_impl/tbe/strided_read.py +0 -38
  1096. mindspore/ops/_op_impl/tbe/strided_slice_d.py +0 -44
  1097. mindspore/ops/_op_impl/tbe/strided_slice_ds.py +0 -71
  1098. mindspore/ops/_op_impl/tbe/strided_slice_grad_d.py +0 -51
  1099. mindspore/ops/_op_impl/tbe/strided_slice_grad_ds.py +0 -57
  1100. mindspore/ops/_op_impl/tbe/strided_write.py +0 -38
  1101. mindspore/ops/_op_impl/tbe/sub.py +0 -39
  1102. mindspore/ops/_op_impl/tbe/sub_ds.py +0 -40
  1103. mindspore/ops/_op_impl/tbe/tan.py +0 -38
  1104. mindspore/ops/_op_impl/tbe/tan_ds.py +0 -39
  1105. mindspore/ops/_op_impl/tbe/tanh.py +0 -37
  1106. mindspore/ops/_op_impl/tbe/tanh_ds.py +0 -38
  1107. mindspore/ops/_op_impl/tbe/tanh_grad.py +0 -39
  1108. mindspore/ops/_op_impl/tbe/tanh_grad_ds.py +0 -40
  1109. mindspore/ops/_op_impl/tbe/tensor_move.py +0 -49
  1110. mindspore/ops/_op_impl/tbe/tensor_move_ds.py +0 -50
  1111. mindspore/ops/_op_impl/tbe/tensor_scatter_update.py +0 -41
  1112. mindspore/ops/_op_impl/tbe/tile.py +0 -37
  1113. mindspore/ops/_op_impl/tbe/tile_ds.py +0 -42
  1114. mindspore/ops/_op_impl/tbe/top_k.py +0 -42
  1115. mindspore/ops/_op_impl/tbe/top_k_ds.py +0 -43
  1116. mindspore/ops/_op_impl/tbe/trans_data.py +0 -167
  1117. mindspore/ops/_op_impl/tbe/trans_data_ds.py +0 -180
  1118. mindspore/ops/_op_impl/tbe/trans_data_rnn.py +0 -44
  1119. mindspore/ops/_op_impl/tbe/transpose.py +0 -60
  1120. mindspore/ops/_op_impl/tbe/transpose_d.py +0 -47
  1121. mindspore/ops/_op_impl/tbe/transpose_nod.py +0 -60
  1122. mindspore/ops/_op_impl/tbe/trunc.py +0 -39
  1123. mindspore/ops/_op_impl/tbe/truncate_div.py +0 -41
  1124. mindspore/ops/_op_impl/tbe/truncate_div_ds.py +0 -42
  1125. mindspore/ops/_op_impl/tbe/truncate_mod.py +0 -41
  1126. mindspore/ops/_op_impl/tbe/truncate_mod_ds.py +0 -42
  1127. mindspore/ops/_op_impl/tbe/unpack.py +0 -38
  1128. mindspore/ops/_op_impl/tbe/unpack_ds.py +0 -39
  1129. mindspore/ops/_op_impl/tbe/unsorted_segment_max.py +0 -49
  1130. mindspore/ops/_op_impl/tbe/unsorted_segment_max_ds.py +0 -40
  1131. mindspore/ops/_op_impl/tbe/unsorted_segment_min.py +0 -49
  1132. mindspore/ops/_op_impl/tbe/unsorted_segment_min_ds.py +0 -40
  1133. mindspore/ops/_op_impl/tbe/unsorted_segment_prod.py +0 -49
  1134. mindspore/ops/_op_impl/tbe/unsorted_segment_prod_ds.py +0 -38
  1135. mindspore/ops/_op_impl/tbe/unsorted_segment_sum.py +0 -38
  1136. mindspore/ops/_op_impl/tbe/unsorted_segment_sum_ds.py +0 -41
  1137. mindspore/ops/_op_impl/tbe/wts_arq.py +0 -40
  1138. mindspore/ops/_op_impl/tbe/xdivy.py +0 -38
  1139. mindspore/ops/_op_impl/tbe/xdivy_ds.py +0 -39
  1140. mindspore/ops/_op_impl/tbe/xlogy.py +0 -38
  1141. mindspore/ops/_op_impl/tbe/xlogy_ds.py +0 -39
  1142. mindspore/ops/_op_impl/tbe/zeros_like.py +0 -41
  1143. mindspore/ops/_op_impl/tbe/zeros_like_ds.py +0 -42
  1144. mindspore/ops/_tracefunc.py +0 -241
  1145. mindspore/ops/arg_dtype_cast.py +0 -54
  1146. mindspore/rewrite/api/tree_node_helper.py +0 -60
  1147. mindspore/rewrite/ast_creator_register.py +0 -37
  1148. mindspore/rewrite/ast_helpers/ast_creator.py +0 -115
  1149. mindspore/rewrite/ast_transformers/flatten_recursive_stmt.py +0 -267
  1150. mindspore/rewrite/ast_transformers/remove_return_out_of_if.py +0 -228
  1151. mindspore/rewrite/namespace.py +0 -53
  1152. {mindspore-2.2.14.dist-info → mindspore-2.3.0rc1.dist-info}/WHEEL +0 -0
  1153. {mindspore-2.2.14.dist-info → mindspore-2.3.0rc1.dist-info}/top_level.txt +0 -0
@@ -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.
@@ -29,15 +29,19 @@ from mindspore.common._utils import is_shape_unknown, is_dim_unknown
29
29
  from mindspore.ops.primitive import Primitive, PrimitiveWithInfer, PrimitiveWithCheck, prim_attr_register, _run_op
30
30
  from mindspore import _checkparam as validator
31
31
  from mindspore._checkparam import _check_3d_int_or_tuple
32
- from mindspore.ops._tracefunc import PackFunc
33
32
  from mindspore.common import dtype as mstype
34
33
  from mindspore.common._decorator import deprecated
35
- from mindspore.common.parameter import Parameter
36
34
  from mindspore.common import Tensor, CSRTensor, COOTensor
37
35
  from mindspore._c_expression import Tensor as Tensor_
38
36
  from mindspore._c_expression import CSRTensor as CSRTensor_
39
37
  from mindspore._c_expression import COOTensor as COOTensor_
40
-
38
+ from ..auto_generate import (ExpandDims, Reshape, TensorShape, Transpose, Gather, OnesLike, ZerosLike, Argmax,
39
+ ReverseV2, Diag, Eye, ScatterNd, ResizeNearestNeighborV2, GatherNd, GatherD,
40
+ Range, MaskedFill, RightShift, NonZero, ResizeNearestNeighbor, Identity, Split,
41
+ CumSum, CumProd, Cummax, Cummin, Argmin, Concat, UnsortedSegmentSum, ScalarToTensor,
42
+ BroadcastTo, StridedSlice, Select)
43
+ from .manually_defined import Rank, Shape, Tile, Cast
44
+ from ..auto_generate import ArgMaxWithValue, ArgMinWithValue
41
45
 
42
46
  class _ScatterOp(PrimitiveWithInfer):
43
47
  """
@@ -187,54 +191,6 @@ class Expand(Primitive):
187
191
  self.init_prim_io_names(inputs=['x', 'shape'], outputs=['y'])
188
192
 
189
193
 
190
- class ExpandDims(PrimitiveWithCheck):
191
- """
192
- Adds an additional dimension to `input_x` at the given axis, the dimension of
193
- `input_x` should be greater than or equal to 1.
194
-
195
- Refer to :func:`mindspore.ops.expand_dims` for more details.
196
-
197
- Inputs:
198
- - **input_x** (Tensor) - The shape of tensor is :math:`(x_1, x_2, ..., x_R)`.
199
- - **axis** (int) - Specifies the dimension index at which to expand
200
- the shape of `input_x`. The value of axis must be in the range
201
- `[-input_x.ndim-1, input_x.ndim]`. Only constant value is allowed.
202
-
203
- Outputs:
204
- Tensor, the shape of tensor is :math:`(1, x_1, x_2, ..., x_R)` if the
205
- value of `axis` is 0. It has the same data type as `input_x`.
206
-
207
- Supported Platforms:
208
- ``Ascend`` ``GPU`` ``CPU``
209
-
210
- Examples:
211
- >>> import mindspore
212
- >>> import numpy as np
213
- >>> from mindspore import Tensor, ops
214
- >>> input_tensor = Tensor(np.array([[2, 2], [2, 2]]), mindspore.float32)
215
- >>> expand_dims = ops.ExpandDims()
216
- >>> output = expand_dims(input_tensor, 0)
217
- >>> print(output)
218
- [[[2. 2.]
219
- [2. 2.]]]
220
- """
221
-
222
- @prim_attr_register
223
- def __init__(self):
224
- """Initialize ExpandDims"""
225
- self.init_prim_io_names(inputs=['x', 'axis'], outputs=['output'])
226
-
227
- def infer_value(self, input_x, axis):
228
- value = None
229
- if input_x is not None and axis is not None:
230
- dtype = input_x.dtype
231
- if input_x.dtype == mstype.bfloat16:
232
- cpu_cast = Cast().set_device("CPU")
233
- input_x = cpu_cast(input_x, mstype.float32)
234
- value = Tensor(np.expand_dims(input_x.asnumpy(), axis), dtype)
235
- return value
236
-
237
-
238
194
  class DType(Primitive):
239
195
  """
240
196
  Returns the data type of the input tensor as mindspore.dtype.
@@ -304,88 +260,6 @@ class CheckNumerics(Primitive):
304
260
  self.init_prim_io_names(inputs=['x'], outputs=['y'])
305
261
 
306
262
 
307
- class Cast(PrimitiveWithCheck):
308
- """
309
- Returns a tensor with the new specified data type.
310
-
311
- Note:
312
- When converting complex numbers to boolean type, the imaginary part of the complex number is not
313
- taken into account. As long as the real part is non-zero, it returns True; otherwise, it returns False.
314
-
315
- Inputs:
316
- - **input_x** (Union[Tensor, Number]) - The shape of tensor is :math:`(x_1, x_2, ..., x_R)`.
317
- The tensor to be cast.
318
- - **type** (dtype.Number) - The valid data type of the output tensor. Only constant value is allowed.
319
-
320
- Outputs:
321
- Tensor, the shape of tensor is the same as `input_x`, :math:`(x_1, x_2, ..., x_R)`.
322
-
323
- Raises:
324
- TypeError: If `input_x` is neither Tensor nor Number.
325
- TypeError: If `type` is not a Number.
326
-
327
- Supported Platforms:
328
- ``Ascend`` ``GPU`` ``CPU``
329
-
330
- Examples:
331
- >>> import mindspore
332
- >>> import numpy as np
333
- >>> from mindspore import Tensor, ops
334
- >>> input_np = np.random.randn(2, 3, 4, 5).astype(np.float32)
335
- >>> input_x = Tensor(input_np)
336
- >>> type_dst = mindspore.int32
337
- >>> cast = ops.Cast()
338
- >>> output = cast(input_x, type_dst)
339
- >>> print(output.dtype)
340
- Int32
341
- >>> print(output.shape)
342
- (2, 3, 4, 5)
343
- """
344
-
345
- @prim_attr_register
346
- def __init__(self):
347
- """Initialize Cast"""
348
- self.init_prim_io_names(inputs=['x', 'dst_type'], outputs=['output'])
349
-
350
- def check_elim(self, x, dtype):
351
- if isinstance(x, (Tensor, numbers.Number, Parameter)):
352
- if isinstance(x, Parameter):
353
- data = x.data
354
- if data.dtype == dtype:
355
- return (True, x)
356
- if isinstance(x, Tensor) and x.dtype == dtype and not PackFunc.is_tracing():
357
- x = Tensor(x)
358
- x.set_cast_dtype()
359
- return (True, x)
360
- if isinstance(x, numbers.Number):
361
- return (True, Tensor(x, dtype=dtype))
362
- return (False, None)
363
-
364
- def infer_value(self, x, dst_type):
365
- if x is None:
366
- return None
367
- src_type = mstype.get_py_obj_dtype(x)
368
- validator.check_subclass("input_x", src_type,
369
- [mstype.tensor_type, mstype.number], self.name)
370
- validator.check_subclass("type", dst_type, mstype.number, self.name)
371
-
372
- if isinstance(src_type, type(mstype.tensor_type)):
373
- src_type = src_type.element_type()
374
- if isinstance(dst_type, type(mstype.tensor_type)):
375
- dst_type = dst_type.element_type()
376
-
377
- value = None
378
- np_dst_type = mstype.dtype_to_nptype(dst_type)
379
- if isinstance(x, (int, float)):
380
- value = Tensor(np.array(x).astype(np_dst_type), dtype=dst_type)
381
- else:
382
- if x.dtype == mstype.bfloat16:
383
- cpu_cast = Cast().set_device("CPU")
384
- x = cpu_cast(x, mstype.float32)
385
- value = Tensor(x.asnumpy().astype(np_dst_type), dtype=dst_type)
386
- return value
387
-
388
-
389
263
  class Im2Col(Primitive):
390
264
  r"""
391
265
  Extracts sliding local blocks from a batched input tensor.
@@ -434,7 +308,6 @@ class Im2Col(Primitive):
434
308
 
435
309
  - If one int, :math:`pad\_height = pad\_width`.
436
310
  - If two int, :math:`pad\_height = pads[0]`, :math:`pad\_width = pads[1]`.
437
- - If four int, :math:`pads = [pad\_height\_top, pad\_height\_bottom, pad\_width\_left, pad\_width\_right]`.
438
311
 
439
312
  Inputs:
440
313
  - **x** (Tensor) - input tensor, only 4-D input tensors (batched image-like tensors) are supported.
@@ -499,11 +372,10 @@ class Im2Col(Primitive):
499
372
 
500
373
  class Col2Im(Primitive):
501
374
  r"""
502
- Combines an array of sliding local blocks into a large containing tensor. It is
375
+ Rearranges a row vector to an image. It is
503
376
  usually used to reconstruct an image from a set of image patches(or sliding local blocks).
504
377
 
505
- Consider a batched :attr:`input` tensor containing sliding local blocks,
506
- e.g., patches of images, of shape :math:`(N, C, \prod(\text{kernel_size}), L)`,
378
+ Consider an input Tensor of shape :math:`(N, C, \prod(\text{kernel_size}), L)`,
507
379
  where :math:`N` is batch dimension, :math:`C` is channel dimension,
508
380
  :math:`\prod(\text{kernel_size})` is the block size, and
509
381
  :math:`L` is the total number of blocks. This operation combines these
@@ -590,149 +462,6 @@ class Col2Im(Primitive):
590
462
  self.add_prim_attr('stride', self.stride)
591
463
 
592
464
 
593
- class Reshape(PrimitiveWithCheck):
594
- """
595
- Rearranges the input Tensor based on the given shape.
596
-
597
- Refer to :func:`mindspore.ops.reshape` for more details.
598
-
599
- Inputs:
600
- - **input_x** (Tensor) - The shape of tensor is :math:`(x_1, x_2, ..., x_R)`.
601
- - **input_shape** (tuple[int]) - The input tuple is constructed by multiple
602
- integers, i.e., :math:`(y_1, y_2, ..., y_S)`.
603
-
604
- Outputs:
605
- Tensor, the shape of tensor is :math:`(y_1, y_2, ..., y_S)`.
606
-
607
- Supported Platforms:
608
- ``Ascend`` ``GPU`` ``CPU``
609
-
610
- Examples:
611
- >>> import mindspore
612
- >>> import numpy as np
613
- >>> from mindspore import Tensor, ops
614
- >>> input_x = Tensor(np.array([[-0.1, 0.3, 3.6], [0.4, 0.5, -3.2]]), mindspore.float32)
615
- >>> reshape = ops.Reshape()
616
- >>> output = reshape(input_x, (3, 2))
617
- >>> print(output)
618
- [[-0.1 0.3]
619
- [ 3.6 0.4]
620
- [ 0.5 -3.2]]
621
- """
622
-
623
- @prim_attr_register
624
- def __init__(self):
625
- """Initialize Reshape"""
626
- self.init_prim_io_names(inputs=['tensor', 'shape'], outputs=['output'])
627
-
628
- def infer_value(self, x, shape):
629
- """infer value"""
630
- # for shape is not constant
631
- if shape is None or self.none_in_tuple_or_list(shape) or x is None:
632
- return None
633
-
634
- if isinstance(shape, (Tensor, Tensor_)):
635
- validator.check_tensor_dtype_valid("shape", mstype.TensorType(shape.dtype),
636
- [mstype.int32, mstype.int64], self.name)
637
- shape = shape.asnumpy().tolist()
638
- else:
639
- validator.check_value_type("shape", shape, [tuple], self.name)
640
- shape = list(shape)
641
-
642
- neg_index = -1
643
- dim_prod = 1
644
- for i, shp_i in enumerate(shape):
645
- validator.check_value_type("shape[%d]" % i, shp_i, [int], self.name)
646
- if shp_i == -1:
647
- if neg_index != -1:
648
- raise ValueError(f"For '{self.name}', there can be at most one '-1' in 'input_shape', "
649
- f"but got {shape}.")
650
- neg_index = i
651
- else:
652
- dim_prod *= shp_i
653
- out = None
654
- if not is_shape_unknown(x.shape):
655
- x_shp = x.shape
656
- if dim_prod <= 0:
657
- raise ValueError(f"For '{self.name}', the shape of 'input_x' is {x_shp}, "
658
- f"the value of 'input_shape' is {shape}. "
659
- f"The product of 'input_shape' should > 0, but got {dim_prod}.")
660
- arr_prod = np.prod(x_shp)
661
- if neg_index != -1:
662
- shape[neg_index] = int(arr_prod // dim_prod)
663
- dim_prod *= shape[neg_index]
664
- if dim_prod != arr_prod:
665
- raise ValueError(f"For '{self.name}', the product of the 'input_x' shape "
666
- f"should be equal to product of 'input_shape', but got product of the"
667
- f" shape of 'input_x': {arr_prod}, product of 'input_shape': {dim_prod}.")
668
- out = Tensor(x.asnumpy().reshape(shape))
669
- return out
670
-
671
- def none_in_tuple_or_list(self, x):
672
- return isinstance(x, (tuple, list)) and None in x
673
-
674
-
675
- class Shape(Primitive):
676
- """
677
- Returns the shape of the input tensor.
678
-
679
- Refer to :func:`mindspore.ops.shape` for more details.
680
-
681
- Inputs:
682
- - **input_x** (Tensor) - The shape of tensor is :math:`(x_1, x_2, ..., x_R)`.
683
-
684
- Outputs:
685
- tuple[int], the output tuple is constructed by multiple integers,
686
- :math:`(x_1, x_2, ..., x_R)`.
687
-
688
- Supported Platforms:
689
- ``Ascend`` ``GPU`` ``CPU``
690
-
691
- Examples:
692
- >>> import mindspore
693
- >>> import numpy as np
694
- >>> from mindspore import Tensor, ops
695
- >>> input_x = Tensor(np.ones(shape=[3, 2, 1]), mindspore.float32)
696
- >>> shape = ops.Shape()
697
- >>> output = shape(input_x)
698
- >>> print(output)
699
- (3, 2, 1)
700
- """
701
-
702
- @prim_attr_register
703
- def __init__(self):
704
- """Initialize Shape"""
705
-
706
- def __call__(self, x):
707
- if isinstance(x, (Tensor, COOTensor, CSRTensor, Tensor_)):
708
- return x.shape
709
- raise TypeError(f"For primitive[{self.name}], the input argument must be Tensor, but got {type(x)}.")
710
-
711
-
712
- class TensorShape(Primitive):
713
- """
714
- Returns the shape of the input tensor.
715
-
716
- Supported Platforms:
717
- ``Ascend`` ``GPU`` ``CPU``
718
-
719
- Examples:
720
- >>> import mindspore
721
- >>> import numpy as np
722
- >>> from mindspore import Tensor, ops
723
- >>> input_x = Tensor(np.ones(shape=[3, 2, 1]), mindspore.float32)
724
- >>> shape = ops.TensorShape()
725
- >>> output = shape(input_x)
726
- >>> print(output)
727
- [3 2 1]
728
- """
729
-
730
- @prim_attr_register
731
- def __init__(self):
732
- """init Shape"""
733
- self.init_prim_io_names(inputs=['input_x'], outputs=['output'])
734
-
735
-
736
465
  class Unsqueeze(PrimitiveWithCheck):
737
466
  """Unsqueeze"""
738
467
 
@@ -788,48 +517,6 @@ class Squeeze(Primitive):
788
517
  self.add_prim_attr("axis", (axis,))
789
518
 
790
519
 
791
- class Transpose(Primitive):
792
- """
793
- Permutes the dimensions of the input tensor according to input permutation.
794
-
795
- Refer to :func:`mindspore.ops.transpose` for more details.
796
-
797
- Inputs:
798
- - **input_x** (Tensor) - The shape of tensor is :math:`(x_1, x_2, ..., x_R)`.
799
- - **input_perm** (tuple[int]) - The permutation to be converted. The elements in `input_perm` are composed of
800
- the indexes of each dimension of `input_x`. The length of `input_perm` and the shape of `input_x` must be
801
- the same. Only constant value is allowed. Must be in the range [0, rank(input_x)).
802
-
803
- Outputs:
804
- Tensor, the type of output tensor is the same as `input_x` and the shape of output tensor is decided by the
805
- shape of `input_x` and the value of `input_perm`.
806
-
807
- Supported Platforms:
808
- ``Ascend`` ``GPU`` ``CPU``
809
-
810
- Examples:
811
- >>> import mindspore
812
- >>> import numpy as np
813
- >>> from mindspore import Tensor, ops
814
- >>> input_x = Tensor(np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]), mindspore.float32)
815
- >>> input_perm = (0, 2, 1)
816
- >>> transpose = ops.Transpose()
817
- >>> output = transpose(input_x, input_perm)
818
- >>> print(output)
819
- [[[ 1. 4.]
820
- [ 2. 5.]
821
- [ 3. 6.]]
822
- [[ 7. 10.]
823
- [ 8. 11.]
824
- [ 9. 12.]]]
825
- """
826
-
827
- @prim_attr_register
828
- def __init__(self):
829
- """Initialize Transpose"""
830
- self.init_prim_io_names(inputs=['x', 'perm'], outputs=['output'])
831
-
832
-
833
520
  class ConjugateTranspose(Primitive):
834
521
  """
835
522
  Calculate the conjugate matrix of input x which has been transposed according to input perm.
@@ -999,99 +686,6 @@ class UniqueConsecutive(Primitive):
999
686
  self.add_prim_attr("axis", axis)
1000
687
 
1001
688
 
1002
- class Gather(Primitive):
1003
- r"""
1004
- Returns the slice of the input tensor corresponding to the elements of `input_indices` on the specified `axis`.
1005
-
1006
- Refer to :func:`mindspore.ops.gather` for more details.
1007
-
1008
- Args:
1009
- batch_dims (int, optional): Specifies the number of batch dimensions.
1010
- It must be less than or equal to the rank of `input_indices`. Default: ``0`` .
1011
-
1012
- Inputs:
1013
- - **input_params** (Tensor) - The original Tensor. The shape of tensor is :math:`(x_1, x_2, ..., x_R)`.
1014
- - **input_indices** (Tensor) - Index tensor to be sliced, the shape of tensor is :math:`(y_1, y_2, ..., y_S)`.
1015
- Specifies the indices of elements of the original Tensor. The data type can be int32 or int64.
1016
- - **axis** (Union(int, Tensor[int])) - Specifies the dimension index to gather indices.
1017
- When axis is Tensor, the size must be 1.
1018
-
1019
- Outputs:
1020
- Tensor, the shape of tensor is
1021
- :math:`input\_params.shape[:axis] + input\_indices.shape + input\_params.shape[axis + 1:]`.
1022
-
1023
- Supported Platforms:
1024
- ``Ascend`` ``GPU`` ``CPU``
1025
-
1026
- Examples:
1027
- >>> import mindspore
1028
- >>> import numpy as np
1029
- >>> from mindspore import Tensor, ops
1030
- >>> # case1: input_indices is a Tensor with shape (5, ).
1031
- >>> input_params = Tensor(np.array([1, 2, 3, 4, 5, 6, 7]), mindspore.float32)
1032
- >>> input_indices = Tensor(np.array([0, 2, 4, 2, 6]), mindspore.int32)
1033
- >>> axis = 0
1034
- >>> output = ops.Gather()(input_params, input_indices, axis)
1035
- >>> print(output)
1036
- [1. 3. 5. 3. 7.]
1037
- >>> # case2: input_indices is a Tensor with shape (2, 2). When the input_params has one dimension,
1038
- the output shape is equal to the input_indices shape.
1039
- >>> input_indices = Tensor(np.array([[0, 2], [2, 6]]), mindspore.int32)
1040
- >>> axis = 0
1041
- >>> output = ops.Gather()(input_params, input_indices, axis)
1042
- >>> print(output)
1043
- [[ 1. 3.]
1044
- [ 3. 7.]]
1045
- >>> # case3: input_indices is a Tensor with shape (2, ). input_params is a Tensor with shape (3, 4) and axis is 0.
1046
- >>> input_params = Tensor(np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]), mindspore.float32)
1047
- >>> input_indices = Tensor(np.array([0, 2]), mindspore.int32)
1048
- >>> axis = 0
1049
- >>> output = ops.Gather()(input_params, input_indices, axis)
1050
- >>> print(output)
1051
- [[1. 2. 3. 4.]
1052
- [9. 10. 11. 12.]]
1053
- >>> # case4: input_indices is a Tensor with shape (2, ).
1054
- >>> # input_params is a Tensor with shape (3, 4) and axis is 1, batch_dims is 1.
1055
- >>> input_params = Tensor(np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]), mindspore.float32)
1056
- >>> input_indices = Tensor(np.array([0, 2, 1]), mindspore.int32)
1057
- >>> axis = 1
1058
- >>> batch_dims = 1
1059
- >>> output = ops.Gather(batch_dims)(input_params, input_indices, axis)
1060
- >>> print(output)
1061
- [ 1. 7. 10.]
1062
- """
1063
-
1064
- @prim_attr_register
1065
- def __init__(self, batch_dims=0):
1066
- """Initialize Gather"""
1067
- validator.check_value_type("batch_dims", batch_dims, [int], self.name)
1068
- self.add_prim_attr("batch_dims", batch_dims)
1069
- self.init_prim_io_names(inputs=['params', 'indices', 'axis'], outputs=['output'])
1070
-
1071
-
1072
- class GatherV2(PrimitiveWithCheck):
1073
- """
1074
- Same as operator Gather. GatherV2 will be deprecated in the future.
1075
- Please use Gather instead.
1076
- """
1077
-
1078
- @deprecated("1.1", "Gather", True)
1079
- @prim_attr_register
1080
- def __init__(self):
1081
- """Initialize GatherV2"""
1082
- self.add_prim_attr("batch_dims", 0)
1083
- self.init_prim_io_names(inputs=['params', 'indices', 'axis'], outputs=['output'])
1084
-
1085
- def __check__(self, params, indices, axis):
1086
- validator.check_subclass("params", params['dtype'], mstype.tensor_type, self.name)
1087
- validator.check_tensor_dtype_valid("indices", indices['dtype'], mstype.int_type, self.name)
1088
- validator.check_subclass("axis", axis['dtype'], [mstype.number], self.name)
1089
- axis_v = axis['value']
1090
- validator.check_value_type('axis', axis_v, [int], self.name)
1091
- rank = len(params['shape'])
1092
- validator.check_int_range(axis_v, -rank, rank, validator.INC_LEFT, "axis", self.name)
1093
-
1094
-
1095
689
  class SparseGatherV2(Primitive):
1096
690
  """
1097
691
  Returns a slice of input tensor based on the specified indices and axis.
@@ -1214,100 +808,6 @@ class UniqueWithPad(Primitive):
1214
808
  self.init_prim_io_names(inputs=['x', 'pad_num'], outputs=['y', 'idx'])
1215
809
 
1216
810
 
1217
- class Split(Primitive):
1218
- r"""
1219
- Splits the input tensor into output_num of tensors along the given axis and output numbers.
1220
-
1221
- Refer to :func:`mindspore.ops.split` for more details.
1222
-
1223
- Args:
1224
- axis (int): Index of the split position. Default: ``0`` .
1225
- output_num (int): The number of output tensors. Must be positive int. Default: ``1`` .
1226
-
1227
- Inputs:
1228
- - **input_x** (Tensor) - The shape of tensor is :math:`(x_0, x_1, ..., x_{R-1})`, R >= 1.
1229
-
1230
- Outputs:
1231
- tuple[Tensor], the shape of each output tensor is the same, which is
1232
- :math:`(x_0, x_1, ..., x_{axis}/{output\_num}, ..., x_{R-1})`.
1233
- And the data type is the same as `input_x`.
1234
-
1235
- Supported Platforms:
1236
- ``Ascend`` ``GPU`` ``CPU``
1237
-
1238
- Examples:
1239
- >>> import mindspore
1240
- >>> import numpy as np
1241
- >>> from mindspore import Tensor, ops
1242
- >>> split = ops.Split(1, 2)
1243
- >>> x = Tensor(np.array([[1, 1, 1, 1], [2, 2, 2, 2]]), mindspore.int32)
1244
- >>> print(x)
1245
- [[1 1 1 1]
1246
- [2 2 2 2]]
1247
- >>> output = split(x)
1248
- >>> print(output)
1249
- (Tensor(shape=[2, 2], dtype=Int32, value=
1250
- [[1, 1],
1251
- [2, 2]]), Tensor(shape=[2, 2], dtype=Int32, value=
1252
- [[1, 1],
1253
- [2, 2]]))
1254
- >>> split = ops.Split(1, 4)
1255
- >>> output = split(x)
1256
- >>> print(output)
1257
- (Tensor(shape=[2, 1], dtype=Int32, value=
1258
- [[1],
1259
- [2]]), Tensor(shape=[2, 1], dtype=Int32, value=
1260
- [[1],
1261
- [2]]), Tensor(shape=[2, 1], dtype=Int32, value=
1262
- [[1],
1263
- [2]]), Tensor(shape=[2, 1], dtype=Int32, value=
1264
- [[1],
1265
- [2]]))
1266
- """
1267
-
1268
- @prim_attr_register
1269
- def __init__(self, axis=0, output_num=1):
1270
- """Initialize Split"""
1271
- validator.check_value_type("axis", axis, [int], self.name)
1272
- validator.check_value_type("output_num", output_num, [int], self.name)
1273
- validator.check_positive_int(output_num, "output_num", self.name)
1274
- self.axis = axis
1275
- self.output_num = output_num
1276
- self.add_prim_attr('num_split', self.output_num)
1277
-
1278
-
1279
- class Rank(Primitive):
1280
- """
1281
- Returns the rank of a tensor.
1282
-
1283
- Refer to :func:`mindspore.ops.rank` for more details.
1284
-
1285
- Supported Platforms:
1286
- ``Ascend`` ``GPU`` ``CPU``
1287
-
1288
- Examples:
1289
- >>> import mindspore
1290
- >>> import numpy as np
1291
- >>> from mindspore import Tensor, ops
1292
- >>> input_tensor = Tensor(np.array([[2, 2], [2, 2]]), mindspore.float32)
1293
- >>> rank = ops.Rank()
1294
- >>> output = rank(input_tensor)
1295
- >>> print(output)
1296
- 2
1297
- >>> print(type(output))
1298
- <class 'int'>
1299
- """
1300
-
1301
- @prim_attr_register
1302
- def __init__(self):
1303
- """Initialize Rank"""
1304
-
1305
- def __call__(self, x):
1306
- if not isinstance(x, (Tensor, Tensor_)):
1307
- raise TypeError("the input x must be Tensor!")
1308
- return len(x.shape)
1309
-
1310
-
1311
811
  class Size(Primitive):
1312
812
  r"""
1313
813
  Returns a Scalar of type int that represents the size of the input Tensor and the total number of elements in the
@@ -1317,7 +817,7 @@ class Size(Primitive):
1317
817
 
1318
818
  Inputs:
1319
819
  - **input_x** (Tensor) - Input parameters, the shape of tensor is :math:`(x_1, x_2, ..., x_R)`. The data type is
1320
- `number <https://www.mindspore.cn/docs/en/r2.2/api_python/mindspore.html#mindspore.dtype>`_.
820
+ `number <https://www.mindspore.cn/docs/en/r2.3.q1/api_python/mindspore.html#mindspore.dtype>`_.
1321
821
 
1322
822
  Outputs:
1323
823
  int. A scalar representing the elements' size of `input_x`, tensor is the number of elements
@@ -1504,7 +1004,7 @@ class MatrixDiagPartV3(Primitive):
1504
1004
  class MatrixSetDiagV3(Primitive):
1505
1005
  r"""
1506
1006
  Updates the diagonal part of a batched tensor.
1507
- It takes an Tensor `x` and `diagonal` as input and returns a Tensor in which
1007
+ It takes a Tensor `x` and `diagonal` as input and returns a Tensor in which
1508
1008
  the specified diagonal values in the innermost matrices will be replaced
1509
1009
  by the values in the `diagonal`.
1510
1010
 
@@ -1770,20 +1270,23 @@ class FillV2(PrimitiveWithCheck):
1770
1270
  self.init_prim_io_names(inputs=['shape', 'value'], outputs=['y'])
1771
1271
 
1772
1272
  def check_elim(self, dims, x):
1773
- x_is_invalid = x is None or (not isinstance(x, (Tensor, Tensor_))) or (x.shape != ())
1774
- dims_is_invalid = dims is None or (isinstance(dims, (tuple, list)) and dims) or\
1775
- isinstance(dims, (Tensor, Tensor_))
1776
- if x_is_invalid or dims_is_invalid:
1273
+ if x is None or (not isinstance(x, (Tensor, Tensor_))) or (x.shape != ()) or \
1274
+ dims is None or (isinstance(dims, (tuple, list)) and dims) or \
1275
+ isinstance(dims, (Tensor, Tensor_)):
1777
1276
  return (False, None)
1778
1277
  return (True, x)
1779
1278
 
1780
1279
  def infer_value(self, dims, x):
1781
- dims_is_invalid = dims is None or\
1782
- (isinstance(dims, (tuple, list)) and dims) or\
1783
- isinstance(dims, (Tensor, Tensor_))
1784
- if x is None or dims_is_invalid:
1280
+ if x is None or dims is None or isinstance(dims, (Tensor, Tensor_)):
1281
+ return None
1282
+ if isinstance(dims, (tuple, list)) and None in dims:
1785
1283
  return None
1786
- return x
1284
+ if 0 in dims:
1285
+ init_func = Zero()
1286
+ init_func.__enable_zero_dim__ = True
1287
+ out = Tensor(shape=dims, dtype=x.dtype, init=init_func)
1288
+ return out
1289
+ return Tensor(np.full(dims, x.asnumpy()))
1787
1290
 
1788
1291
 
1789
1292
  class Ones(Primitive):
@@ -1861,95 +1364,30 @@ class Zeros(Primitive):
1861
1364
  """Initialize Zeros"""
1862
1365
 
1863
1366
 
1864
- class OnesLike(Primitive):
1367
+ class TupleToArray(PrimitiveWithInfer):
1865
1368
  """
1866
- Returns a Tensor with a value of 1 and its shape and data type is the same as the input.
1369
+ Converts a tuple to a tensor.
1867
1370
 
1868
- Refer to :func:`mindspore.ops.ones_like` for more details.
1371
+ Refer to :func:`mindspore.ops.tuple_to_array` for more details.
1869
1372
 
1870
1373
  Inputs:
1871
- - **input_x** (Tensor) - Tensor of any dimension.
1374
+ - **input_x** (tuple) - A tuple of numbers. These numbers have the same type.
1375
+ The shape is :math:`(N,*)` where :math:`*` means any number of additional dimensions.
1872
1376
 
1873
1377
  Outputs:
1874
- Tensor, has the same shape and type as `input_x` but filled with ones.
1378
+ Tensor, if the input tuple contains `N` numbers, then the shape of the output tensor is :math:`(N,)`.
1875
1379
 
1876
1380
  Supported Platforms:
1877
1381
  ``Ascend`` ``GPU`` ``CPU``
1878
1382
 
1879
1383
  Examples:
1880
- >>> import numpy as np
1881
- >>> from mindspore import Tensor, ops
1882
- >>> oneslike = ops.OnesLike()
1883
- >>> input_x = Tensor(np.array([[0, 1], [2, 1]]).astype(np.int32))
1884
- >>> output = oneslike(input_x)
1885
- >>> print(output)
1886
- [[1 1]
1887
- [1 1]]
1888
- """
1889
-
1890
- @prim_attr_register
1891
- def __init__(self):
1892
- """Initialize OnesLike"""
1893
- self.init_prim_io_names(inputs=['x'], outputs=['y'])
1894
-
1895
-
1896
- class ZerosLike(Primitive):
1897
- """
1898
- Returns a Tensor with a value of 0 and its shape and data type is the same as the input.
1899
-
1900
- Inputs:
1901
- - **input_x** (Tensor) - Input Tensor of any dimension.
1902
-
1903
- Outputs:
1904
- Tensor, has the same shape and data type as `input_x` but filled with zeros.
1905
-
1906
- Raises:
1907
- TypeError: If `input_x` is not a Tensor.
1908
-
1909
- Supported Platforms:
1910
- ``Ascend`` ``GPU`` ``CPU``
1911
-
1912
- Examples:
1913
- >>> import numpy as np
1914
- >>> from mindspore import Tensor, ops
1915
- >>> zeroslike = ops.ZerosLike()
1916
- >>> input_x = Tensor(np.array([[0, 1], [2, 1]]).astype(np.float32))
1917
- >>> output = zeroslike(input_x)
1918
- >>> print(output)
1919
- [[0. 0.]
1920
- [0. 0.]]
1921
- """
1922
-
1923
- @prim_attr_register
1924
- def __init__(self):
1925
- """Initialize ZerosLike"""
1926
- self.init_prim_io_names(inputs=['x'], outputs=['y'])
1927
-
1928
-
1929
- class TupleToArray(PrimitiveWithInfer):
1930
- """
1931
- Converts a tuple to a tensor.
1932
-
1933
- Refer to :func:`mindspore.ops.tuple_to_array` for more details.
1934
-
1935
- Inputs:
1936
- - **input_x** (tuple) - A tuple of numbers. These numbers have the same type.
1937
- The shape is :math:`(N,*)` where :math:`*` means any number of additional dimensions.
1938
-
1939
- Outputs:
1940
- Tensor, if the input tuple contains `N` numbers, then the shape of the output tensor is :math:`(N,)`.
1941
-
1942
- Supported Platforms:
1943
- ``Ascend`` ``GPU`` ``CPU``
1944
-
1945
- Examples:
1946
- >>> from mindspore import ops
1947
- >>> input_x = (1,2,3)
1948
- >>> print(type(input_x))
1949
- <class 'tuple'>
1950
- >>> output = ops.TupleToArray()(input_x)
1951
- >>> print(type(output))
1952
- <class 'mindspore.common.tensor.Tensor'>
1384
+ >>> from mindspore import ops
1385
+ >>> input_x = (1,2,3)
1386
+ >>> print(type(input_x))
1387
+ <class 'tuple'>
1388
+ >>> output = ops.TupleToArray()(input_x)
1389
+ >>> print(type(output))
1390
+ <class 'mindspore.common.tensor.Tensor'>
1953
1391
  >>> print(output)
1954
1392
  [1 2 3]
1955
1393
  """
@@ -1982,42 +1420,6 @@ class TupleToArray(PrimitiveWithInfer):
1982
1420
  return _run_op(self, self.name, args)
1983
1421
 
1984
1422
 
1985
- class ScalarToTensor(PrimitiveWithInfer):
1986
- """
1987
- Converts a scalar to a `Tensor`, and converts the data type to the specified type.
1988
-
1989
- Refer to :func:`mindspore.ops.scalar_to_tensor` for more details.
1990
-
1991
- Inputs:
1992
- - **input_x** (Union[int, float]) - The input is a scalar. Only constant value is allowed.
1993
- - **dtype** (mindspore.dtype) - The target data type. Default: ``mindspore.float32`` . Only
1994
- constant value is allowed.
1995
-
1996
- Outputs:
1997
- Tensor. 0-D Tensor and the content is the input.
1998
-
1999
- Supported Platforms:
2000
- ``Ascend`` ``GPU`` ``CPU``
2001
-
2002
- Examples:
2003
- >>> import mindspore
2004
- >>> from mindspore import ops
2005
- >>> op = ops.ScalarToTensor()
2006
- >>> data = 1
2007
- >>> output = op(data, mindspore.float32)
2008
- >>> print(output)
2009
- 1.0
2010
- """
2011
-
2012
- @prim_attr_register
2013
- def __init__(self):
2014
- self.init_prim_io_names(inputs=['input_scalar', 'dtype'], outputs=['output_data'])
2015
-
2016
- def __call__(self, x, dtype=mstype.float32):
2017
- validator.check_value_type("x", x, [bool, int, float], self.name)
2018
- validator.check_subclass("dtype", dtype, mstype.number, self.name)
2019
- data_type = mstype.dtype_to_nptype(dtype)
2020
- return Tensor(np.array(x, data_type), dtype=dtype)
2021
1423
 
2022
1424
 
2023
1425
  class InvertPermutation(PrimitiveWithInfer):
@@ -2099,94 +1501,6 @@ class InvertPermutation(PrimitiveWithInfer):
2099
1501
  'value': tuple(y)}
2100
1502
 
2101
1503
 
2102
- class Argmax(Primitive):
2103
- """
2104
- Returns the indices of the maximum value along a specified `axis` of a Tensor.
2105
-
2106
- Refer to :func:`mindspore.ops.argmax` for more details.
2107
-
2108
- Args:
2109
- axis (int): Axis where the Argmax operation applies to. Default: ``-1`` .
2110
- output_type (:class:`mindspore.dtype`): Output data type.
2111
- Supported types: ``mstype.int32`` , ``mstype.int64`` . Default: ``mstype.int32`` .
2112
-
2113
- Inputs:
2114
- - **input_x** (Tensor) - The input tensor. :math:`(N, *)` where :math:`*` means, any number of additional
2115
- dimensions.
2116
-
2117
- Outputs:
2118
- Tensor, indices of the max value of input tensor across the axis.
2119
-
2120
- Supported Platforms:
2121
- ``Ascend`` ``GPU`` ``CPU``
2122
-
2123
- Examples:
2124
- >>> import mindspore
2125
- >>> import numpy as np
2126
- >>> from mindspore import Tensor, ops
2127
- >>> input_x = Tensor(np.array([[1, 20, 5], [67, 8, 9], [130, 24, 15]]).astype(np.float32))
2128
- >>> output = ops.Argmax(output_type=mindspore.int32)(input_x)
2129
- >>> print(output)
2130
- [1 0 0]
2131
- """
2132
-
2133
- @prim_attr_register
2134
- def __init__(self, axis=-1, output_type=mstype.int32):
2135
- """Initialize Argmax"""
2136
- self.init_prim_io_names(inputs=['x'], outputs=['output'])
2137
- validator.check_value_type("axis", axis, [int], self.name)
2138
- validator.check_types_same_and_valid({'output': output_type}, [mstype.int32, mstype.int64], self.name)
2139
- self.axis = axis
2140
- self.add_prim_attr('output_type', output_type)
2141
-
2142
-
2143
- class Argmin(Primitive):
2144
- """
2145
- Returns the indices of the minimum value along a specified `axis` of a Tensor.
2146
-
2147
- If the shape of input tensor is :math:`(x_1, ..., x_N)`, the shape of the output tensor is
2148
- :math:`(x_1, ..., x_{axis-1}, x_{axis+1}, ..., x_N)`.
2149
-
2150
- Args:
2151
- axis (int): Axis where the Argmin operation applies to. Default: ``-1`` .
2152
- output_type (:class:`mindspore.dtype`): Output data type.
2153
- Supported types: ``mstype.int32`` , ``mstype.int64`` . Default: ``mstype.int32`` .
2154
-
2155
- Inputs:
2156
- - **input_x** (Tensor) - Input tensor.
2157
- The shape is :math:`(N, *)` where :math:`*` means, any number of additional dimensions.
2158
-
2159
- Outputs:
2160
- Tensor, whose dtype is determined by `output_type`.
2161
-
2162
- Raises:
2163
- TypeError: If `axis` is not an int.
2164
- TypeError: If `output_type` is neither int32 nor int64.
2165
-
2166
- Supported Platforms:
2167
- ``Ascend`` ``GPU`` ``CPU``
2168
-
2169
- Examples:
2170
- >>> import mindspore
2171
- >>> import numpy as np
2172
- >>> from mindspore import Tensor, ops
2173
- >>> input_x = Tensor(np.array([2.0, 3.1, 1.2]), mindspore.float32)
2174
- >>> index = ops.Argmin()(input_x)
2175
- >>> print(index)
2176
- 2
2177
- """
2178
-
2179
- @prim_attr_register
2180
- def __init__(self, axis=-1, output_type=mstype.int32):
2181
- """Initialize Argmin"""
2182
- self.init_prim_io_names(inputs=['x'], outputs=['output'])
2183
- validator.check_value_type("axis", axis, [int], self.name)
2184
- validator.check_type_name("output_type", output_type, [mstype.int32, mstype.int64], self.name)
2185
- self.axis = axis
2186
- self.add_prim_attr('output_type', output_type)
2187
- self.add_prim_attr('axis', axis)
2188
-
2189
-
2190
1504
  class ArgminV2(Primitive):
2191
1505
  """
2192
1506
  Returns the indices of the minimum value of a tensor across the axis.
@@ -2245,328 +1559,6 @@ class ArgminV2(Primitive):
2245
1559
  return output
2246
1560
 
2247
1561
 
2248
- class ArgMaxWithValue(Primitive):
2249
- """
2250
- Calculates the maximum value along with the given axis for the input tensor, and returns the maximum values and
2251
- indices.
2252
-
2253
- Note:
2254
- In auto_parallel and semi_auto_parallel mode, the first output index can not be used.
2255
-
2256
- .. warning::
2257
- - If there are multiple maximum values, the index of the first maximum value is used.
2258
- - The value range of "axis" is [-dims, dims - 1]. "dims" is the dimension length of "x".
2259
-
2260
- Also see :func:`mindspore.ops.max`.
2261
-
2262
- Args:
2263
- axis (int): The dimension to reduce. Default: ``0`` .
2264
- keep_dims (bool): Whether to reduce dimension, if ``True`` , the output will keep same dimension with the
2265
- input, the output will reduce dimension if ``false`` . Default: ``False`` .
2266
-
2267
- Inputs:
2268
- - **x** (Tensor) - The input tensor, can be any dimension. Set the shape of input tensor as
2269
- :math:`(x_1, x_2, ..., x_N)`.
2270
-
2271
- Outputs:
2272
- tuple (Tensor), tuple of 2 tensors, containing the corresponding index and the maximum value of the input
2273
- tensor.
2274
-
2275
- - **index** (Tensor) - The index for the maximum value of the input tensor, with dtype int32. If `keep_dims`
2276
- is ``True`` , the shape of output tensors is :math:`(x_1, x_2, ..., x_{axis-1}, 1, x_{axis+1}, ..., x_N)`.
2277
- Otherwise, the shape is :math:`(x_1, x_2, ..., x_{axis-1}, x_{axis+1}, ..., x_N)` .
2278
- - **values** (Tensor) - The maximum value of input tensor, with the same shape as index, and same dtype as x.
2279
-
2280
- Raises:
2281
- TypeError: If `x` is not Tensor.
2282
- TypeError: If `keep_dims` is not a bool.
2283
- TypeError: If `axis` is not an int.
2284
-
2285
- Supported Platforms:
2286
- ``Ascend`` ``GPU`` ``CPU``
2287
-
2288
- Examples:
2289
- >>> import mindspore
2290
- >>> import numpy as np
2291
- >>> from mindspore import Tensor, ops
2292
- >>> input_x = Tensor(np.array([0.0, 0.4, 0.6, 0.7, 0.1]), mindspore.float32)
2293
- >>> index, output = ops.ArgMaxWithValue()(input_x)
2294
- >>> print(index, output)
2295
- 3 0.7
2296
- >>> index, output = ops.ArgMaxWithValue(keep_dims=True)(input_x)
2297
- >>> print(index, output)
2298
- [3] [0.7]
2299
- """
2300
-
2301
- @prim_attr_register
2302
- def __init__(self, axis=0, keep_dims=False):
2303
- """Initialize ArgMaxWithValue"""
2304
- self.init_prim_io_names(inputs=['x'], outputs=['index', 'values'])
2305
- validator.check_value_type("axis", axis, [int], self.name)
2306
- validator.check_value_type('keep_dims', keep_dims, [bool], self.name)
2307
- self.axis = axis
2308
- self.keep_dims = keep_dims
2309
- self.add_prim_attr('dimension', self.axis)
2310
-
2311
-
2312
- class ArgMinWithValue(Primitive):
2313
- """
2314
- Calculates the minimum value along with the given axis for the input tensor, and returns the minimum values and
2315
- indices.
2316
-
2317
- Note:
2318
- In auto_parallel and semi_auto_parallel mode, the first output index can not be used.
2319
-
2320
- .. warning::
2321
- - If there are multiple minimum values, the index of the first minimum value is used.
2322
- - The value range of "axis" is [-dims, dims - 1]. "dims" is the dimension length of "x".
2323
-
2324
- Also see :func:`mindspore.ops.min`.
2325
-
2326
- Args:
2327
- axis (int): The dimension to reduce. Default: ``0`` .
2328
- keep_dims (bool): Whether to reduce dimension, if ``True`` the output will keep the same dimension as the
2329
- input, the output will reduce dimension if ``false`` . Default: ``False`` .
2330
-
2331
- Inputs:
2332
- - **x** (Tensor) - The input tensor, can be any dimension. Set the shape of input tensor as
2333
- :math:`(x_1, x_2, ..., x_N)` .Complex tensor is not supported.
2334
-
2335
- Outputs:
2336
- tuple (Tensor), tuple of 2 tensors, containing the corresponding index and the minimum value of the input
2337
- tensor.
2338
-
2339
- - **index** (Tensor) - The index for the minimum value of the input tensor, with dtype int32. If `keep_dims`
2340
- is ``True`` , the shape of output tensors is :math:`(x_1, x_2, ..., x_{axis-1}, 1, x_{axis+1}, ..., x_N)`.
2341
- Otherwise, the shape is :math:`(x_1, x_2, ..., x_{axis-1}, x_{axis+1}, ..., x_N)` .
2342
- - **values** (Tensor) - The minimum value of input tensor, with the same
2343
- shape as `index`, and same dtype as `x`.
2344
-
2345
- Raises:
2346
- TypeError: If `x` is not Tensor.
2347
- TypeError: If `keep_dims` is not a bool.
2348
- TypeError: If `axis` is not an int.
2349
-
2350
- Supported Platforms:
2351
- ``Ascend`` ``GPU`` ``CPU``
2352
-
2353
- Examples:
2354
- >>> import mindspore
2355
- >>> import numpy as np
2356
- >>> from mindspore import Tensor, ops
2357
- >>> x = Tensor(np.array([0.0, 0.4, 0.6, 0.7, 0.1]), mindspore.float32)
2358
- >>> index, output = ops.ArgMinWithValue()(x)
2359
- >>> print(index, output)
2360
- 0 0.0
2361
- >>> index, output = ops.ArgMinWithValue(keep_dims=True)(x)
2362
- >>> print(index, output)
2363
- [0] [0.0]
2364
- """
2365
-
2366
- @prim_attr_register
2367
- def __init__(self, axis=0, keep_dims=False):
2368
- """Initialize ArgMinWithValue"""
2369
- self.init_prim_io_names(inputs=['x'], outputs=['index', 'values'])
2370
- validator.check_value_type("axis", axis, [int], self.name)
2371
- validator.check_value_type('keep_dims', keep_dims, [bool], self.name)
2372
- self.axis = axis
2373
- self.keep_dims = keep_dims
2374
- self.add_prim_attr('dimension', self.axis)
2375
-
2376
-
2377
- class Tile(PrimitiveWithInfer):
2378
- r"""
2379
- Replicates an input tensor with given multiples times.
2380
-
2381
- Refer to :func:`mindspore.ops.tile` for more details.
2382
-
2383
- Inputs:
2384
- - **input_x** (Tensor) - 1-D or higher dimensional Tensor. Set the shape of input tensor as
2385
- :math:`(x_1, x_2, ..., x_S)` .
2386
- - **multiples** (tuple[int]) - The parameter that specifies the number of replications,
2387
- the parameter type is tuple, and the data type is int, i.e., :math:`(y_1, y_2, ..., y_S)`.
2388
- The length of `multiples` cannot be smaller than the length of the shape of `input_x`.
2389
- Only constant value is allowed.
2390
-
2391
- Outputs:
2392
- Tensor, has the same data type as the `input_x`. Suppose the length of `multiples` is `d`,
2393
- the dimension of `input_x` is `input_x.dim`, and the shape of `input_x` is :math:`(x_1, x_2, ..., x_S)`.
2394
-
2395
- - If `input_x.dim = d`, then the shape of their corresponding positions can be multiplied, and
2396
- the shape of Outputs is :math:`(x_1*y_1, x_2*y_2, ..., x_S*y_S)`.
2397
- - If `input_x.dim < d`, fill in multiple 1 in the length of the shape of `input_x` until their
2398
- lengths are consistent. Such as set the shape of `input_x` as :math:`(1, ..., x_1, x_2, ..., x_S)`,
2399
- then the shape of their corresponding positions can be multiplied, and the shape of Outputs is
2400
- :math:`(1*y_1, ..., x_R*y_R, x_S*y_S)`.
2401
-
2402
- Supported Platforms:
2403
- ``Ascend`` ``GPU`` ``CPU``
2404
-
2405
- Examples:
2406
- >>> import mindspore
2407
- >>> import numpy as np
2408
- >>> from mindspore import Tensor, ops
2409
- >>> tile = ops.Tile()
2410
- >>> input_x = Tensor(np.array([[1, 2], [3, 4]]), mindspore.float32)
2411
- >>> multiples = (2, 3)
2412
- >>> output = tile(input_x, multiples)
2413
- >>> print(output)
2414
- [[1. 2. 1. 2. 1. 2.]
2415
- [3. 4. 3. 4. 3. 4.]
2416
- [1. 2. 1. 2. 1. 2.]
2417
- [3. 4. 3. 4. 3. 4.]]
2418
- >>> multiples = (2, 3, 2)
2419
- >>> output = tile(input_x, multiples)
2420
- >>> print(output)
2421
- [[[1. 2. 1. 2.]
2422
- [3. 4. 3. 4.]
2423
- [1. 2. 1. 2.]
2424
- [3. 4. 3. 4.]
2425
- [1. 2. 1. 2.]
2426
- [3. 4. 3. 4.]]
2427
- [[1. 2. 1. 2.]
2428
- [3. 4. 3. 4.]
2429
- [1. 2. 1. 2.]
2430
- [3. 4. 3. 4.]
2431
- [1. 2. 1. 2.]
2432
- [3. 4. 3. 4.]]]
2433
- """
2434
-
2435
- @prim_attr_register
2436
- def __init__(self):
2437
- """Initialize Tile"""
2438
- self.init_prim_io_names(inputs=['x', 'multiples'], outputs=['output'])
2439
-
2440
- def check_elim(self, *args):
2441
- base_tensor, multiplier = args
2442
- if PackFunc.is_tracing() and not PackFunc.current.is_pynative_mode:
2443
- return (False, None)
2444
- if not isinstance(base_tensor, Tensor):
2445
- raise TypeError(f"For '{self.name}', the type of 'input_x' must be Tensor, "
2446
- f"but got {type(base_tensor).__name__}.")
2447
- if not isinstance(multiplier, tuple):
2448
- raise TypeError(f"For '{self.name}', the type of 'multiplier' must be tuple, "
2449
- f"but got {type(multiplier).__name__}.")
2450
-
2451
- if all(v == 1 for v in multiplier) and len(base_tensor.shape) >= len(multiplier):
2452
- ret = Identity()(base_tensor)
2453
- return (True, ret)
2454
- return (False, None)
2455
-
2456
- def _get_shape_and_range(self, x, multiples):
2457
- """calculate tile shape and value"""
2458
- x_shp = x['shape']
2459
- if is_dim_unknown(x_shp):
2460
- return {'shape': x_shp}, None
2461
- multiples_v = multiples['value']
2462
- value = None
2463
- len_sub = len(multiples_v) - len(x_shp)
2464
- multiples_w = None
2465
- if len_sub == 0:
2466
- multiples_w = multiples_v
2467
- if len_sub > 0:
2468
- for _ in range(0, len_sub):
2469
- x_shp.insert(0, 1)
2470
- multiples_w = multiples_v
2471
- elif len_sub < 0:
2472
- raise ValueError(f"For '{self.name}', the length of 'multiples' can not be smaller than "
2473
- f"the dimension of 'input_x', but got length of 'multiples': {len(multiples_v)} "
2474
- f"and dimension of 'input_x': {len(x_shp)}.")
2475
-
2476
- for i, a in enumerate(multiples_w):
2477
- if x_shp[i] >= 0:
2478
- x_shp[i] *= a
2479
- if x['value'] is not None:
2480
- value = Tensor(np.tile(x['value'].asnumpy(), multiples_w))
2481
- out_shape = {
2482
- 'shape': x_shp
2483
- }
2484
- return out_shape, value
2485
-
2486
- def __infer__(self, x, multiples):
2487
- multiples_v = multiples['value']
2488
- if multiples_v is None or None in multiples_v:
2489
- if 'max_value' not in multiples or 'min_value' not in multiples:
2490
- if multiples_v is not None:
2491
- shape = [len(multiples['shape'])]
2492
- else:
2493
- shape = multiples['shape']
2494
- if len(shape) != 1:
2495
- raise ValueError(f'For \'{self.name}\', the dim of multiples must be 1.')
2496
- rank = max(len(x['shape']), shape[0])
2497
- out_shape = [-1] * rank
2498
- if -2 in x['shape']:
2499
- out_shape = [-2]
2500
- return {
2501
- 'shape': out_shape,
2502
- 'dtype': x['dtype'],
2503
- 'value': None
2504
- }
2505
- out_shape, value = self._get_shape_and_range(x, multiples)
2506
- shape = out_shape.get('shape', None)
2507
- out = {'shape': shape,
2508
- 'dtype': x['dtype'],
2509
- 'value': value}
2510
- return out
2511
-
2512
- validator.check_value_type(
2513
- "multiples", multiples_v, [tuple], self.name)
2514
- for i, multiple in enumerate(multiples_v):
2515
- validator.check_positive_int(
2516
- multiple, "multiples[%d]" % i, self.name)
2517
- validator.check_value_type(
2518
- "x[\'dtype\']", x["dtype"], mstype.TensorType, self.name)
2519
- out_shp, value = self._get_shape_and_range(x, multiples)
2520
- shp = out_shp.get('shape', None)
2521
- out = {'shape': shp,
2522
- 'dtype': x['dtype'],
2523
- 'value': value}
2524
- return out
2525
-
2526
-
2527
- class UnsortedSegmentSum(Primitive):
2528
- r"""
2529
- Computes the sum of a tensor along segments.
2530
-
2531
- Refer to :func:`mindspore.ops.unsorted_segment_sum` for more details.
2532
-
2533
- Inputs:
2534
- - **input_x** (Tensor) - Input Tensor contains the data to be summed.
2535
- The shape is :math:`(x_1, x_2, ..., x_R)`.
2536
- - **segment_ids** (Tensor) - The label indicates the segment to which each element belongs.
2537
- Set the shape as :math:`(x_1, x_2, ..., x_N)`, where 0 < N <= R.
2538
- - **num_segments** (int) - Set :math:`z` as num_segments, it can be an int or 0-D Tensor.
2539
-
2540
- Outputs:
2541
- Tensor, the shape is :math:`(z, x_{N+1}, ..., x_R)`.
2542
-
2543
- Supported Platforms:
2544
- ``Ascend`` ``GPU`` ``CPU``
2545
-
2546
- Examples:
2547
- >>> from mindspore import Tensor
2548
- >>> from mindspore import ops
2549
- >>> import mindspore
2550
- >>> input_x = Tensor([1, 2, 3, 4], mindspore.float32)
2551
- >>> segment_ids = Tensor([0, 0, 1, 2], mindspore.int32)
2552
- >>> num_segments = 4
2553
- >>> output = ops.UnsortedSegmentSum()(input_x, segment_ids, num_segments)
2554
- >>> print(output)
2555
- [3. 3. 4. 0.]
2556
- >>> input_x = Tensor([1, 2, 3, 4, 2, 5], mindspore.float32)
2557
- >>> segment_ids = Tensor([0, 0, 1, 2, 3, 4], mindspore.int32)
2558
- >>> num_segments = 6
2559
- >>> output = ops.UnsortedSegmentSum()(input_x, segment_ids, num_segments)
2560
- >>> print(output)
2561
- [3. 3. 4. 2. 5. 0.]
2562
- """
2563
-
2564
- @prim_attr_register
2565
- def __init__(self):
2566
- """Initialize UnsortedSegmentSum"""
2567
- self.init_prim_io_names(inputs=['x', 'segment_ids', 'num_segments'], outputs=['y'])
2568
-
2569
-
2570
1562
  class UnsortedSegmentMin(PrimitiveWithCheck):
2571
1563
  r"""
2572
1564
  Computes the minimum of a tensor along segments.
@@ -2578,10 +1570,10 @@ class UnsortedSegmentMin(PrimitiveWithCheck):
2578
1570
  The data type must be float16, float32 or int32.
2579
1571
  - **segment_ids** (Tensor) - The label indicates the segment to which each element belongs.
2580
1572
  Set the shape as :math:`(x_1, x_2, ..., x_N)`, where 0 < N <= R.
2581
- - **num_segments** (int) - The value specifies the number of distinct `segment_ids`.
1573
+ - **num_segments** (Union[int, Tensor]) - Set :math:`z` as num_segments, it can be an int or 0-D Tensor.
2582
1574
 
2583
1575
  Outputs:
2584
- Tensor, set the number of `num_segments` as `N`, the shape is :math:`(N, x_2, ..., x_R)`.
1576
+ Tensor, the shape is :math:`(z, x_{N+1}, ..., x_R)`.
2585
1577
 
2586
1578
  Supported Platforms:
2587
1579
  ``Ascend`` ``GPU`` ``CPU``
@@ -2640,10 +1632,10 @@ class UnsortedSegmentMax(PrimitiveWithCheck):
2640
1632
  The data type must be float16, float32 or int32.
2641
1633
  - **segment_ids** (Tensor) - The label indicates the segment to which each element belongs.
2642
1634
  Set the shape as :math:`(x_1, x_2, ..., x_N)`, where 0 < N <= R.
2643
- - **num_segments** (int) - The value specifies the number of distinct `segment_ids`.
1635
+ - **num_segments** (Union[int, Tensor]) - Set :math:`z` as num_segments, it can be an int or 0-D Tensor.
2644
1636
 
2645
1637
  Outputs:
2646
- Tensor, set the number of `num_segments` as `N`, the shape is :math:`(N, x_2, ..., x_R)`.
1638
+ Tensor, the shape is :math:`(z, x_{N+1}, ..., x_R)`.
2647
1639
 
2648
1640
  Supported Platforms:
2649
1641
  ``Ascend`` ``GPU`` ``CPU``
@@ -2759,13 +1751,12 @@ class UnsortedSegmentProd(Primitive):
2759
1751
  Inputs:
2760
1752
  - **input_x** (Tensor) - The shape is :math:`(x_1, x_2, ..., x_R)`.
2761
1753
  With float16, float32 or int32 data type.
2762
- - **segment_ids** (Tensor) - A `1-D` tensor whose shape is :math:`(x_1)`, the value must be non-negative tensor.
2763
- Data type must be int32.
2764
- - **num_segments** (int) - The value specifies the number of distinct `segment_ids`,
2765
- must be greater than 0.
1754
+ - **segment_ids** (Tensor) - The label indicates the segment to which each element belongs.
1755
+ Set the shape as :math:`(x_1, x_2, ..., x_N)`, where 0 < N <= R. Data type must be int32.
1756
+ - **num_segments** (Union[int, Tensor]) - Set :math:`z` as num_segments, it can be an int or 0-D Tensor.
2766
1757
 
2767
1758
  Outputs:
2768
- Tensor, set the number of `num_segments` as `N`, the shape is :math:`(N, x_2, ..., x_R)`.
1759
+ Tensor, the shape is :math:`(z, x_{N+1}, ..., x_R)`.
2769
1760
 
2770
1761
  Supported Platforms:
2771
1762
  ``Ascend`` ``GPU`` ``CPU``
@@ -2790,65 +1781,9 @@ class UnsortedSegmentProd(Primitive):
2790
1781
  self.init_prim_io_names(inputs=['x', 'segment_ids', 'num_segments'], outputs=['y'])
2791
1782
 
2792
1783
 
2793
- class Concat(PrimitiveWithCheck):
1784
+ class ConcatOffsetV1(Primitive):
2794
1785
  r"""
2795
- Connect tensor in the specified axis.
2796
-
2797
- Refer to :func:`mindspore.ops.concat` for more details.
2798
-
2799
- Args:
2800
- axis (int, optional): The specified axis. Default: ``0`` .
2801
-
2802
- Inputs:
2803
- - **input_x** (Union[tuple, list]) - A tuple or a list of input tensors.
2804
- Suppose there are two tensors in this tuple or list, namely x1 and x2.
2805
- To perform `Concat` in the axis 0 direction, except for the 0th axis, all other axes should be equal,
2806
- that is, :math:`x1.shape[1] == x2.shape[1], x1.shape[2] == x2.shape[2], ..., x1.shape[R] == x2.shape[R]`,
2807
- where the :math:`R` indicates the last axis.
2808
-
2809
- Outputs:
2810
- - Tensor, the shape is :math:`(x_1, x_2, ..., \sum_{i=1}^Nx_{mi}, ..., x_R)`.
2811
- The data type is the same with `input_x`.
2812
-
2813
- Supported Platforms:
2814
- ``Ascend`` ``GPU`` ``CPU``
2815
-
2816
- Examples:
2817
- >>> import numpy as np
2818
- >>> from mindspore import Tensor, ops
2819
- >>> input_x1 = Tensor(np.array([[0, 1], [2, 1]]).astype(np.float32))
2820
- >>> input_x2 = Tensor(np.array([[0, 1], [2, 1]]).astype(np.float32))
2821
- >>> op = ops.Concat()
2822
- >>> output = op((input_x1, input_x2))
2823
- >>> print(output)
2824
- [[0. 1.]
2825
- [2. 1.]
2826
- [0. 1.]
2827
- [2. 1.]]
2828
- >>> op = ops.Concat(1)
2829
- >>> output = op((input_x1, input_x2))
2830
- >>> print(output)
2831
- [[0. 1. 0. 1.]
2832
- [2. 1. 2. 1.]]
2833
- """
2834
-
2835
- @prim_attr_register
2836
- def __init__(self, axis=0):
2837
- """Initialize Concat"""
2838
- self.axis = axis
2839
- validator.check_value_type("axis", axis, [int], self.name)
2840
-
2841
- def infer_value(self, input_x):
2842
- """Implement Concat infer value"""
2843
- value = None
2844
- if input_x is not None and None not in input_x:
2845
- value = Tensor(np.concatenate([x.asnumpy() for x in input_x], axis=self.axis))
2846
- return value
2847
-
2848
-
2849
- class ConcatOffsetV1(Primitive):
2850
- r"""
2851
- primitive for computing Concat’s gradient.
1786
+ primitive for computing Concat’s gradient.
2852
1787
 
2853
1788
  Computes offsets of concat inputs within its output. Accumulate offsets from zero along `axis`.
2854
1789
  If tensor element in `x` isn't along `axis`, they should be the same along their axis.
@@ -2959,7 +1894,7 @@ def _get_stack_shape(value, x_shape, x_type, axis, prim_name):
2959
1894
 
2960
1895
  out_n = len(x_shape)
2961
1896
  for i in range(1, out_n):
2962
- if x_type[i] != x_type[i-1]:
1897
+ if x_type[i] != x_type[i - 1]:
2963
1898
  raise TypeError(f"For {prim_name}, all types should be same, but got {x_type}")
2964
1899
 
2965
1900
  new_x_shape = []
@@ -3047,31 +1982,21 @@ class Stack(PrimitiveWithInfer):
3047
1982
  tuple_value = value['value']
3048
1983
  input_array = []
3049
1984
  infered_value = None
1985
+ dtype = x_type[0]
3050
1986
  if tuple_value is not None and None not in tuple_value:
3051
1987
  for item in tuple_value:
3052
- npy_item = item.asnumpy()
1988
+ npy_item = item.asnumpy() if item.dtype != mstype.bfloat16 else item.float().asnumpy()
3053
1989
  input_array.append(npy_item)
3054
- infered_value = Tensor(np.stack(input_array, axis=self.axis))
1990
+ if dtype == mstype.TensorType(mstype.bfloat16):
1991
+ infered_value = Tensor(np.stack(input_array, axis=self.axis), mstype.bfloat16)
1992
+ else:
1993
+ infered_value = Tensor(np.stack(input_array, axis=self.axis))
3055
1994
 
3056
1995
  shape = all_shape.get('shape') if isinstance(all_shape, dict) else all_shape
3057
1996
  out = {'shape': shape,
3058
- 'dtype': x_type[0],
1997
+ 'dtype': dtype,
3059
1998
  'value': infered_value}
3060
1999
 
3061
- def unpack(x):
3062
- if isinstance(x, (tuple, list)) and len(x) == 1:
3063
- return unpack(x[0])
3064
- return x
3065
-
3066
- if 'shape_value' in value and value['shape_value'] is not None:
3067
- input_shape_value = []
3068
- for item in value['shape_value']:
3069
- item = unpack(item)
3070
- item = np.array(item)
3071
- input_shape_value.append(item)
3072
- infered_shape_value = np.stack(input_shape_value, axis=self.axis)
3073
- infered_shape_value = tuple(infered_shape_value.tolist())
3074
- out['shape_value'] = infered_shape_value
3075
2000
  return out
3076
2001
 
3077
2002
 
@@ -3224,61 +2149,6 @@ class Coalesce(Primitive):
3224
2149
  outputs=['y_indices', 'y_values', 'y_shape'])
3225
2150
 
3226
2151
 
3227
- class ReverseV2(Primitive):
3228
- """
3229
- Reverses specific dimensions of a tensor.
3230
-
3231
- .. warning::
3232
- The value range of "axis" is [-dims, dims - 1]. "dims" is the dimension length of "input_x".
3233
-
3234
- Args:
3235
- axis (Union[tuple(int), list(int)]): The indices of the dimensions to reverse.
3236
-
3237
- Inputs:
3238
- - **input_x** (Tensor) - The target tensor.
3239
- The shape is :math:`(N, *)` where :math:`*` means, any number of additional dimensions.
3240
-
3241
- Outputs:
3242
- Tensor, has the same shape and type as `input_x`.
3243
-
3244
- Raises:
3245
- TypeError: If `axis` is neither list nor tuple.
3246
- TypeError: If element of `axis` is not an int.
3247
- ValueError: There are multiple identical axes in `axis`.
3248
-
3249
- Supported Platforms:
3250
- ``Ascend`` ``GPU`` ``CPU``
3251
-
3252
- Examples:
3253
- >>> import mindspore
3254
- >>> import numpy as np
3255
- >>> from mindspore import Tensor, ops
3256
- >>> input_x = Tensor(np.array([[1, 2, 3, 4], [5, 6, 7, 8]]), mindspore.int32)
3257
- >>> op = ops.ReverseV2(axis=[1])
3258
- >>> output = op(input_x)
3259
- >>> print(output)
3260
- [[4 3 2 1]
3261
- [8 7 6 5]]
3262
- >>> op = ops.ReverseV2(axis=[1, 0])
3263
- >>> output = op(input_x)
3264
- >>> print(output)
3265
- [[8 7 6 5]
3266
- [4 3 2 1]]
3267
- """
3268
-
3269
- @prim_attr_register
3270
- def __init__(self, axis):
3271
- """Initialize ReverseV2."""
3272
- validator.check_value_type('axis', axis, [list, tuple], self.name)
3273
- for i, each in enumerate(axis):
3274
- validator.check_value_type(f'axis[{i}]', each, [int], self.name)
3275
- self.axis = axis
3276
- if isinstance(axis, list):
3277
- self.axis = tuple(axis)
3278
- self.add_prim_attr('axis', self.axis)
3279
- self.init_prim_io_names(inputs=['x'], outputs=['output'])
3280
-
3281
-
3282
2152
  class Rint(Primitive):
3283
2153
  """
3284
2154
  Returns an integer that is closest to `input_x` element-wise.
@@ -3318,54 +2188,6 @@ class Rint(Primitive):
3318
2188
  self.init_prim_io_names(inputs=['x'], outputs=['output'])
3319
2189
 
3320
2190
 
3321
- class Select(Primitive):
3322
- r"""
3323
- The conditional tensor determines whether the corresponding element in the output must be
3324
- selected from `x` (if True) or `y` (if False) based on the value of each
3325
- element.
3326
-
3327
- It can be defined as:
3328
-
3329
- .. math::
3330
- out_i = \begin{cases}
3331
- x_i, & \text{if } condition_i \\
3332
- y_i, & \text{otherwise}
3333
- \end{cases}
3334
-
3335
- Inputs:
3336
- - **condition** (Tensor[bool]) - The condition tensor, decides which element is chosen.
3337
- The shape is :math:`(x_1, x_2, ..., x_N, ..., x_R)`.
3338
- - **x** (Tensor) - The first tensor to be selected and the shape is :math:`(x_1, x_2, ..., x_N, ..., x_R)`.
3339
- - **y** (Tensor) - The second tensor to be selected and the shape is :math:`(x_1, x_2, ..., x_N, ..., x_R)`.
3340
-
3341
- Outputs:
3342
- Tensor, has the same shape as `condition`.
3343
-
3344
- Raises:
3345
- TypeError: If `x` or `y` is not a Tensor.
3346
- ValueError: If shape of the three inputs are different.
3347
-
3348
- Supported Platforms:
3349
- ``Ascend`` ``GPU`` ``CPU``
3350
-
3351
- Examples:
3352
- >>> import mindspore
3353
- >>> from mindspore import Tensor, ops
3354
- >>> select = ops.Select()
3355
- >>> input_cond = Tensor([True, False])
3356
- >>> input_x = Tensor([2,3], mindspore.float32)
3357
- >>> input_y = Tensor([1,2], mindspore.float32)
3358
- >>> output = select(input_cond, input_x, input_y)
3359
- >>> print(output)
3360
- [2. 2.]
3361
- """
3362
-
3363
- @prim_attr_register
3364
- def __init__(self):
3365
- """Initialize Select."""
3366
- self.init_prim_io_names(inputs=['condition', 'x', 'y'], outputs=['output'])
3367
-
3368
-
3369
2191
  class StridedSliceV2(Primitive):
3370
2192
  r"""
3371
2193
  StridedSliceV2 will be deprecated by StridedSlice in the future.
@@ -3420,523 +2242,6 @@ class StridedSliceV2(Primitive):
3420
2242
  self.init_prim_io_names(inputs=['x', 'begin', 'end', 'strides'], outputs=['output'])
3421
2243
 
3422
2244
 
3423
- class StridedSlice(PrimitiveWithInfer):
3424
- r"""
3425
-
3426
- Extracts a strided slice of a tensor.
3427
-
3428
- Refer to :func:`mindspore.ops.strided_slice` for more details.
3429
-
3430
- Args:
3431
- begin_mask (int, optional): Starting index of the slice. Default: ``0`` .
3432
- end_mask (int, optional): Ending index of the slice. Default: ``0`` .
3433
- ellipsis_mask (int, optional): An int mask, ignore slicing operation when set to 1. Default: ``0`` .
3434
- new_axis_mask (int, optional): An int mask for adding new dims. Default: ``0`` .
3435
- shrink_axis_mask (int, optional): An int mask for shrinking dims. Default: ``0`` .
3436
-
3437
- Inputs:
3438
- - **input_x** (Tensor) - The input Tensor to be extracted from.
3439
- - **begin** (tuple[int]) - A tuple which represents the location where to start.
3440
- - **end** (tuple[int]) - A tuple or which represents the maximum location where to end.
3441
- - **strides** (tuple[int]) - A tuple which represents the strides is continuously added
3442
- before reaching the maximum location. Only int is allowed, it can be negative
3443
- which results in reversed slicing.
3444
-
3445
- Outputs:
3446
- Tensor, return the extracts a strided slice of a Tensor based on `begin/end` index and `strides`.
3447
-
3448
- Supported Platforms:
3449
- ``Ascend`` ``GPU`` ``CPU``
3450
-
3451
- Examples:
3452
- >>> import mindspore
3453
- >>> from mindspore import Tensor, ops
3454
- >>> input_x = Tensor([[[1, 1, 1], [2, 2, 2]], [[3, 3, 3], [4, 4, 4]],
3455
- ... [[5, 5, 5], [6, 6, 6]]], mindspore.float32)
3456
- >>> # [[[1. 1. 1.]
3457
- >>> # [2. 2. 2.]]
3458
- >>> #
3459
- >>> # [[3. 3. 3.]
3460
- >>> # [4. 4. 4.]]
3461
- >>> #
3462
- >>> # [[5. 5. 5.]
3463
- >>> # [6. 6. 6.]]]
3464
- >>> # In order to visually view the multi-dimensional array, write the above as follows
3465
- >>> # [
3466
- >>> # [
3467
- >>> # [1,1,1]
3468
- >>> # [2,2,2]
3469
- >>> # ]
3470
- >>> # [
3471
- >>> # [3,3,3]
3472
- >>> # [4,4,4]
3473
- >>> # ]
3474
- >>> # [
3475
- >>> # [5,5,5]
3476
- >>> # [6,6,6]
3477
- >>> # ]
3478
- >>> # ]
3479
- >>> strided_slice = ops.StridedSlice()
3480
- >>> output = strided_slice(input_x, (1, 0, 2), (3, 1, 3), (1, 1, 1))
3481
- >>> # Take this " output = strided_slice(input_x, (1, 0, 2), (3, 1, 3), (1, 1, 1)) " as an example,
3482
- >>> # start = [1, 0, 2] , end = [3, 1, 3], stride = [1, 1, 1], Find a segment of (start, end),
3483
- >>> # note that end is an open interval
3484
- >>> # To facilitate understanding, this operator can be divided into three steps:
3485
- >>> # Step 1: Calculation of the first dimension:
3486
- >>> # start = 1, end = 3, stride = 1, So can take 1st, 2nd rows, and then gets the final output at this time.
3487
- >>> # output_1th =
3488
- >>> # [
3489
- >>> # [
3490
- >>> # [3,3,3]
3491
- >>> # [4,4,4]
3492
- >>> # ]
3493
- >>> # [
3494
- >>> # [5,5,5]
3495
- >>> # [6,6,6]
3496
- >>> # ]
3497
- >>> # ]
3498
- >>> # Step 2: Calculation of the second dimension
3499
- >>> # 2nd dimension, start = 0, end = 1, stride = 1. So only 0th rows can be taken, and the output at this time.
3500
- >>> # output_2nd =
3501
- >>> # [
3502
- >>> # [
3503
- >>> # [3,3,3]
3504
- >>> # ]
3505
- >>> # [
3506
- >>> # [5,5,5]
3507
- >>> # ]
3508
- >>> # ]
3509
- >>> # Step 3: Calculation of the third dimension
3510
- >>> # 3nd dimension,start = 2, end = 3, stride = 1, So can take 2th cols,
3511
- >>> # and you get the final output at this time.
3512
- >>> # output_3ed =
3513
- >>> # [
3514
- >>> # [
3515
- >>> # [3]
3516
- >>> # ]
3517
- >>> # [
3518
- >>> # [5]
3519
- >>> # ]
3520
- >>> # ]
3521
- >>> # The final output after finishing is:
3522
- >>> print(output)
3523
- [[[3.]]
3524
- [[5.]]]
3525
- >>> # another example like :
3526
- >>> output = strided_slice(input_x, (1, 0, 0), (2, 1, 3), (1, 1, 1))
3527
- >>> print(output)
3528
- [[[3. 3. 3.]]]
3529
- """
3530
-
3531
- @prim_attr_register
3532
- def __init__(self,
3533
- begin_mask=0,
3534
- end_mask=0,
3535
- ellipsis_mask=0,
3536
- new_axis_mask=0,
3537
- shrink_axis_mask=0):
3538
- """Initialize StridedSlice"""
3539
- self.init_prim_io_names(inputs=['x', 'begin', 'end', 'strides'], outputs=['output'])
3540
-
3541
- validator.check_non_negative_int(begin_mask, 'begin_mask', self.name)
3542
- validator.check_non_negative_int(end_mask, 'end_mask', self.name)
3543
- validator.check_non_negative_int(ellipsis_mask, 'ellipsis_mask', self.name)
3544
- if len(tuple(filter(lambda x: x == '1', bin(ellipsis_mask)[-1:1:-1]))) > 1:
3545
- raise ValueError(f"For '{self.name}', only support one ellipsis in the index, but got {ellipsis_mask}.")
3546
- validator.check_non_negative_int(new_axis_mask, 'new_axis_mask', self.name)
3547
- validator.check_non_negative_int(shrink_axis_mask, 'shrink_axis_mask',
3548
- self.name)
3549
-
3550
- def __infer__(self, x, begin, end, strides):
3551
- begin_v, begin_len = self._check_and_get_value(begin, 'begin')
3552
- end_v, end_len = self._check_and_get_value(end, 'end')
3553
- strides_v, strides_len = self._check_and_get_value(strides, 'strides')
3554
-
3555
- is_dynamic_tuple = (self._is_none_in_tuple(begin_v.get('value'))
3556
- or self._is_none_in_tuple(end_v.get('value'))
3557
- or self._is_none_in_tuple(strides_v.get('value')))
3558
- is_dynamic = None in (begin_v.get('value'), end_v.get('value'), strides_v.get('value'))
3559
-
3560
- if not is_dynamic and (begin_len != strides_len or end_len != strides_len):
3561
- raise ValueError(
3562
- f"For '{self.name}', 'begin', 'end' and 'strides' must be the same length, but got "
3563
- f"'begin' length: {begin_len}, 'end' length: {end_len}, 'strides' length: {strides_len}."
3564
- )
3565
-
3566
- if is_dynamic or is_dynamic_tuple or is_shape_unknown(x['shape']):
3567
- ret_shape = self._compute_dynamic_slicing_shape(x, begin_v, end_v, strides_v, begin_len)
3568
- rets = {'shape': ret_shape,
3569
- 'dtype': x['dtype'],
3570
- 'value': None}
3571
- return rets
3572
-
3573
- ret_shape = self._compute_slicing_shape(x['shape'], begin_v['value'], end_v['value'], strides_v['value'])
3574
- if all(ret_shape):
3575
- value = None
3576
- else:
3577
- init_func = Zero()
3578
- init_func.__enable_zero_dim__ = True
3579
- value = Tensor(dtype=x['dtype'].element_type(), shape=ret_shape, init=init_func)
3580
-
3581
- if "max_value" in x and "min_value" in x:
3582
- validator.check_value_type("min_value", x["min_value"], [tuple, list], self.name)
3583
- validator.check_value_type("max_value", x["max_value"], [tuple, list], self.name)
3584
- max_value_slice = self._compute_dynamic_slicing_value(x["max_value"], begin_v, end_v, strides_v)
3585
- min_value_slice = self._compute_dynamic_slicing_value(x["min_value"], begin_v, end_v, strides_v)
3586
- return {'shape': ret_shape,
3587
- 'dtype': x['dtype'],
3588
- 'value': value,
3589
- 'max_value': max_value_slice,
3590
- 'min_value': min_value_slice}
3591
-
3592
- if "shape_value" in x:
3593
- validator.check_value_type("shape_value", x["shape_value"], [tuple], self.name)
3594
- shape_value_slice = self._compute_dynamic_slicing_value(x["shape_value"], begin_v, end_v, strides_v)
3595
- return {'shape': ret_shape,
3596
- 'dtype': x['dtype'],
3597
- 'shape_value': shape_value_slice,
3598
- 'value': value}
3599
- return {'shape': ret_shape,
3600
- 'dtype': x['dtype'],
3601
- 'value': value}
3602
-
3603
- @staticmethod
3604
- def _compute_slicing_len_for_positive_stride(begin, end, stride, x_dim):
3605
- """Compute slice length for positive stride."""
3606
- if x_dim == -1:
3607
- if begin >= end:
3608
- # When slicing forward, if begin >= end, the length of the slicing is 0.
3609
- slicing_length = 0
3610
- else:
3611
- slicing_length = -1
3612
- return slicing_length
3613
- # When slicing forward, convert begin and end to positive numbers.
3614
- if begin >= x_dim or end < -x_dim:
3615
- # When slicing forward, if begin >= x_dim or end < -x_dim, the length of the slicing is 0.
3616
- slicing_length = 0
3617
- else:
3618
- if -x_dim <= begin < 0:
3619
- begin += x_dim
3620
- if begin < -x_dim:
3621
- # When slicing forward, if begin < -x_dim, set begin = 0, which means start from the 0th element.
3622
- begin = 0
3623
- if -x_dim <= end < 0:
3624
- end += x_dim
3625
- if end > x_dim:
3626
- # When slicing forward, if end > x_dim, set end = x_dims, which means slice to the last element.
3627
- end = x_dim
3628
- if begin >= end:
3629
- # When slicing forward, if begin >= end, the length of the slicing is 0.
3630
- slicing_length = 0
3631
- else:
3632
- slicing_length = 1 + (end - 1 - begin) // stride
3633
- return slicing_length
3634
-
3635
- @staticmethod
3636
- def _compute_slicing_len_for_negative_stride(begin, end, stride, x_dim):
3637
- """Compute slice length for negative stride."""
3638
- if x_dim == -1:
3639
- if begin <= end:
3640
- slicing_length = 0
3641
- else:
3642
- slicing_length = -1
3643
- return slicing_length
3644
- # When slicing backward, convert begin and end to negative numbers.
3645
- if begin < -x_dim or end >= x_dim:
3646
- # When slicing backward, if begin < -x_dim or end >= x_dim, the length of the slicing is 0.
3647
- slicing_length = 0
3648
- else:
3649
- if 0 <= begin < x_dim:
3650
- begin += -x_dim
3651
- if begin >= x_dim:
3652
- begin = -1
3653
- if 0 <= end < x_dim:
3654
- end += -x_dim
3655
- if end < -x_dim - 1:
3656
- # Slicing to the 0th element.
3657
- end = -x_dim - 1
3658
- if begin <= end:
3659
- slicing_length = 0
3660
- else:
3661
- slicing_length = 1 + (end + 1 - begin) // stride
3662
- return slicing_length
3663
-
3664
- @staticmethod
3665
- def _get_slice_value(begin_v, end_v, strides_v):
3666
- """Get the slice value from value or shape_value."""
3667
- begin_value = begin_v['value']
3668
- end_value = end_v['value']
3669
- strides_value = strides_v['value']
3670
- if begin_value is None:
3671
- begin_value = begin_v['shape_value']
3672
- if end_value is None:
3673
- end_value = end_v['shape_value']
3674
- if strides_value is None:
3675
- strides_value = strides_v['shape_value']
3676
- return begin_value, end_value, strides_value
3677
-
3678
- def _is_none_in_tuple(self, x):
3679
- return isinstance(x, tuple) and None in x
3680
-
3681
- def _compute_slicing_length(self, begin, end, stride, x_dim):
3682
- """Computes the length of the slicing."""
3683
- if stride > 0:
3684
- slicing_length = self._compute_slicing_len_for_positive_stride(begin, end, stride, x_dim)
3685
- else:
3686
- slicing_length = self._compute_slicing_len_for_negative_stride(begin, end, stride, x_dim)
3687
- return slicing_length
3688
-
3689
- def _compute_slicing_shape(self, x_shape, begin_v, end_v, strides_v):
3690
- """Computes the shape of the slicing."""
3691
- x_rank = len(x_shape)
3692
- slice_len = len(begin_v)
3693
-
3694
- # After the integer is converted to binary, it is a str and the first two chars are the flag char '0b'.
3695
- begin_pos = bin(self.begin_mask)[-1:1:-1]
3696
- end_pos = bin(self.end_mask)[-1:1:-1]
3697
- ellipsis_pos = bin(self.ellipsis_mask)[-1:1:-1]
3698
- new_axis_pos = bin(self.new_axis_mask)[-1:1:-1]
3699
- shrink_axis_pos = bin(self.shrink_axis_mask)[-1:1:-1]
3700
-
3701
- ret_shape = []
3702
- i, j = 0, 0
3703
- has_ellipsis = False
3704
- while i < x_rank or j < slice_len:
3705
- if j < slice_len:
3706
- begin, end, stride = begin_v[j], end_v[j], strides_v[j]
3707
-
3708
- if j < len(ellipsis_pos) and ellipsis_pos[j] == '1':
3709
- # When there is ellipsis, the latter part of the ellipsis will be processed separately.
3710
- has_ellipsis = True
3711
- break
3712
- if j < len(begin_pos) and begin_pos[j] == '1':
3713
- begin = -1 if strides_v[j] < 0 else 0
3714
- if j < len(end_pos) and end_pos[j] == '1':
3715
- end = -(x_shape[i] + 1) if strides_v[j] < 0 else x_shape[i]
3716
- if j < len(new_axis_pos) and new_axis_pos[j] == '1':
3717
- ret_shape.append(1)
3718
- j += 1
3719
- continue
3720
- if j < len(shrink_axis_pos) and shrink_axis_pos[j] == '1':
3721
- if (not -x_shape[i] <= begin < x_shape[i]) or stride < 0:
3722
- raise IndexError(f"For '{self.name}', the 'strides[{i}]' cannot be negative number and "
3723
- f"'begin[{i}]' must be in [-{x_shape[i]}, {x_shape[i]}) "
3724
- f"when 'shrink_axis_mask' is greater than 0, "
3725
- f"but got 'shrink_axis_mask': {self.shrink_axis_mask}, "
3726
- f"'strides[{i}]': {stride}, 'begin[{i}]': {begin}.")
3727
- j += 1
3728
- i += 1
3729
- continue
3730
- else:
3731
- begin, end, stride = 0, x_shape[i], 1
3732
-
3733
- slicing_length = self._compute_slicing_length(begin, end, stride, x_shape[i])
3734
- ret_shape.append(slicing_length)
3735
- i += 1
3736
- j += 1
3737
- if has_ellipsis:
3738
- # When there is ellipsis, handle the second half of the ellipsis split.
3739
- ellipsis_occupied_dims = x_rank - i - (slice_len - (j + 1)) + \
3740
- len(tuple(filter(lambda x: x == '1', new_axis_pos[j + 1:slice_len])))
3741
- ret_shape.extend(x_shape[i:i + ellipsis_occupied_dims])
3742
- j += 1
3743
- i += ellipsis_occupied_dims
3744
-
3745
- while i < x_rank or j < slice_len:
3746
- begin, end, stride = begin_v[j], end_v[j], strides_v[j]
3747
-
3748
- if j < len(begin_pos) and begin_pos[j] == '1':
3749
- begin = -1 if strides_v[j] < 0 else 0
3750
- if j < len(end_pos) and end_pos[j] == '1':
3751
- end = -(x_shape[i] + 1) if strides_v[j] < 0 else x_shape[i]
3752
- if j < len(new_axis_pos) and new_axis_pos[j] == '1':
3753
- ret_shape.append(1)
3754
- j += 1
3755
- continue
3756
- if j < len(shrink_axis_pos) and shrink_axis_pos[j] == '1':
3757
- if (not -x_shape[i] <= begin < x_shape[i]) or stride < 0:
3758
- raise IndexError(f"For '{self.name}', the 'strides[{i}]' can not be negative number and "
3759
- f"'begin[{i}]' must be in [-{x_shape[i]}, {x_shape[i]}) "
3760
- f"when 'shrink_axis_mask' is greater than 0, "
3761
- f"but got 'shrink_axis_mask': {self.shrink_axis_mask}, "
3762
- f"'strides[{i}]': {stride}, 'begin[{i}]': {begin}.")
3763
- j += 1
3764
- i += 1
3765
- continue
3766
-
3767
- slicing_length = self._compute_slicing_length(begin, end, stride, x_shape[i])
3768
- ret_shape.append(slicing_length)
3769
- i += 1
3770
- j += 1
3771
- return ret_shape
3772
-
3773
- def _compute_dynamic_slicing_value(self, shape_value, begin_v, end_v, strides_v):
3774
- """Computes the length of the slicing for dynamic shape."""
3775
- shape_value_np = np.array(shape_value)
3776
- slice_index = []
3777
- for begin_i, end_i, strides_i in zip(begin_v['value'], end_v['value'], strides_v['value']):
3778
- s = slice(begin_i, end_i, strides_i)
3779
- slice_index.append(s)
3780
- slice_index = tuple(slice_index)
3781
- shape_value_slice = shape_value_np[slice_index]
3782
- shape_value_slice = tuple(shape_value_slice.tolist())
3783
- return shape_value_slice
3784
-
3785
- def _compute_dynamic_slicing_length(self, begin, end, stride, x_dim):
3786
- """Computes the length of the slicing for dynamic shape."""
3787
- slicing_length = -1
3788
- if None in (begin, end, stride) or -1 in (begin, end, stride):
3789
- return slicing_length
3790
- slicing_length = self._compute_slicing_length(begin, end, stride, x_dim)
3791
- return slicing_length
3792
-
3793
- def _compute_dynamic_slicing_shape(self, x, begin_v, end_v, strides_v, slice_len):
3794
- """Computes the shape of the slicing for dynamic shape, mask is currently not supported."""
3795
- x_shape = x['shape']
3796
- if is_dim_unknown(x_shape):
3797
- return [-2]
3798
- x_rank = len(x_shape)
3799
- new_axis_pos = bin(self.new_axis_mask)[-1:1:-1]
3800
- shrink_axis_pos = bin(self.shrink_axis_mask)[-1:1:-1]
3801
- if self.ellipsis_mask:
3802
- raise ValueError("Ellipsis Mask is currently not supported in dynamic shape.")
3803
- ret_shape = []
3804
- i, j = 0, 0
3805
- slice_has_special_value = False
3806
- begin_value, end_value, strides_value = self._get_slice_value(
3807
- begin_v, end_v, strides_v)
3808
- is_dynamic_tuple = (self._is_none_in_tuple(begin_value)
3809
- or self._is_none_in_tuple(end_value)
3810
- or self._is_none_in_tuple(strides_value))
3811
- if None in (begin_v['value'], end_v['value'], strides_v['value']) or is_dynamic_tuple:
3812
- slice_has_special_value = True
3813
- while i < x_rank or j < slice_len:
3814
- slicing_length = -1
3815
- if j < slice_len:
3816
- if j < len(new_axis_pos) and new_axis_pos[j] == '1':
3817
- ret_shape.append(1)
3818
- j += 1
3819
- continue
3820
- if j < len(shrink_axis_pos) and shrink_axis_pos[j] == '1':
3821
- j += 1
3822
- i += 1
3823
- continue
3824
- if None in (begin_value, end_value, strides_value):
3825
- slicing_length = -1
3826
- elif slice_has_special_value:
3827
- slicing_length = self._compute_dynamic_slicing_length(
3828
- begin_value[j], end_value[j], strides_value[j], x_shape[i])
3829
- else:
3830
- slicing_length = \
3831
- self._compute_slicing_length(begin_value[j], end_value[j], strides_value[j], x_shape[i])
3832
- else:
3833
- if i >= len(x_shape):
3834
- raise ValueError(f"For 'StridedSlice', the index must be less than or equal to "
3835
- f"the dimension of 'input_x', but got the dimension of 'input_x': {len(x_shape)} "
3836
- f"and the index: {i}.")
3837
- begin, end, stride = 0, x_shape[i], 1
3838
- if end > 0:
3839
- slicing_length = self._compute_slicing_length(begin, end, stride, x_shape[i])
3840
- ret_shape.append(slicing_length)
3841
- i += 1
3842
- j += 1
3843
- return ret_shape
3844
-
3845
- def _check_and_get_value(self, slice_input, name):
3846
- """Check begin, end, strides. Get its length and value."""
3847
- slice_value = slice_input['value']
3848
- slice_min = None
3849
- slice_max = None
3850
- slice_special_value = None
3851
- if "min_value" in slice_input and "max_value" in slice_input:
3852
- slice_min = slice_input["min_value"]
3853
- slice_max = slice_input["max_value"]
3854
- elif "shape_value" in slice_input:
3855
- slice_special_value = slice_input["shape_value"]
3856
- if slice_value is None:
3857
- validator.check_tensor_dtype_valid(name, slice_input['dtype'], [mstype.int32, mstype.int64], self.name)
3858
- slice_shape = slice_input['shape']
3859
- if len(slice_shape) != 1:
3860
- raise ValueError(f"For '{self.name}', both the 'begins', 'ends', and 'strides' must be 1-D, "
3861
- f"but got '{name}' shape: {slice_shape}.")
3862
- # not support scalar
3863
- slices = {
3864
- 'value': slice_value,
3865
- 'shape_value': slice_special_value,
3866
- 'min_value': slice_min,
3867
- 'max_value': slice_max
3868
- }
3869
- return slices, slice_shape[0]
3870
-
3871
- if isinstance(slice_value, (Tensor, Tensor_)):
3872
- validator.check_tensor_dtype_valid(name, slice_input['dtype'], [mstype.int64], self.name)
3873
- slice_value = slice_value.asnumpy().tolist()
3874
- elif not isinstance(slice_value, tuple):
3875
- raise TypeError(f"For '{self.name}', both the 'begin', 'end', and 'strides' must be a tuple or Tensor, "
3876
- f"but got '{name}': {slice_value}.")
3877
-
3878
- if tuple(filter(lambda x: x is not None and not isinstance(x, int), slice_value)):
3879
- raise TypeError(f"For '{self.name}', the elements of 'begin', 'end', and 'strides' must be int, "
3880
- f"but got {name}: {slice_value}.")
3881
-
3882
- if name == 'strides':
3883
- if slice_value is not None and tuple(filter(lambda x: x == 0, slice_value)):
3884
- raise ValueError(f"For '{self.name}', 'strides' cannot contain 0, but got 'strides': {slice_value}.")
3885
-
3886
- slices = {
3887
- 'value': slice_value,
3888
- 'shape_value': slice_special_value,
3889
- 'min_value': slice_min,
3890
- 'max_value': slice_max
3891
- }
3892
- return slices, len(slice_value)
3893
-
3894
-
3895
- class Diag(PrimitiveWithCheck):
3896
- r"""
3897
-
3898
- Constructs a diagonal tensor with a given diagonal values.
3899
-
3900
- .. warning::
3901
- This is an experimental API that is subject to change or deletion.
3902
-
3903
- Refer to :func:`mindspore.ops.diag` for more details.
3904
-
3905
- Inputs:
3906
- - **input_x** (Tensor) - The input tensor.
3907
-
3908
- Outputs:
3909
- Tensor, has the same dtype as the `input_x`.
3910
-
3911
- Supported Platforms:
3912
- ``Ascend`` ``GPU`` ``CPU``
3913
-
3914
- Examples:
3915
- >>> from mindspore import Tensor, ops
3916
- >>> input_x = Tensor([1, 2, 3, 4]).astype('int32')
3917
- >>> diag = ops.Diag()
3918
- >>> output = diag(input_x)
3919
- >>> print(output)
3920
- [[1 0 0 0]
3921
- [0 2 0 0]
3922
- [0 0 3 0]
3923
- [0 0 0 4]]
3924
- """
3925
-
3926
- @prim_attr_register
3927
- def __init__(self):
3928
- """Initialize Diag"""
3929
-
3930
- def infer_value(self, x):
3931
- if x is None:
3932
- return None
3933
- # do constant-folding only when x rank is 1
3934
- if len(x.shape) != 1:
3935
- return None
3936
- ret = np.diag(x.asnumpy())
3937
- return Tensor(ret)
3938
-
3939
-
3940
2245
  class DiagPart(PrimitiveWithCheck):
3941
2246
  r"""
3942
2247
 
@@ -3987,300 +2292,24 @@ class DiagPart(PrimitiveWithCheck):
3987
2292
 
3988
2293
  class Mvlgamma(Primitive):
3989
2294
  r"""
3990
- Calculates the multivariate log-gamma function element-wise for a given dimension `p`.
3991
-
3992
- .. warning::
3993
- This is an experimental API that is subject to change or deletion.
3994
-
3995
- Refer to :func:`mindspore.ops.mvlgamma` for more details.
3996
-
3997
- Args:
3998
- p(int): The number of dimensions. And the value of `p` must be greater than or equal to 1.
3999
-
4000
- Inputs:
4001
- - **x** (Tensor) - The tensor to compute the multivariate log-gamma function,
4002
- which must be one of the following types: float32, float64.
4003
- The shape is :math:`(N,*)`, where :math:`*` means any number of additional dimensions.
4004
- And the value of any element in `x` must be greater than :math:`(p - 1) / 2`.
4005
-
4006
- Outputs:
4007
- Tensor, has the same shape and type as `x`.
4008
-
4009
- Supported Platforms:
4010
- ``Ascend`` ``GPU`` ``CPU``
4011
-
4012
- Examples:
4013
- >>> import mindspore
4014
- >>> import numpy as np
4015
- >>> from mindspore import Tensor, ops
4016
- >>> x = Tensor(np.array([[3, 4, 5], [4, 2, 6]]), mindspore.float32)
4017
- >>> op = ops.Mvlgamma(p=3)
4018
- >>> y = op(x)
4019
- >>> print(y)
4020
- [[ 2.694925 5.402975 9.140645 ]
4021
- [ 5.402975 1.5963125 13.640454 ]]
4022
- """
4023
-
4024
- @prim_attr_register
4025
- def __init__(self, p):
4026
- """Initialize Mvlgamma."""
4027
- self.init_prim_io_names(inputs=['x'], outputs=['y'])
4028
- validator.check_value_type('p', p, [int], self.name)
4029
- validator.check_positive_int(p, 'p', self.name)
4030
-
4031
-
4032
- class Eye(Primitive):
4033
- """
4034
- Creates a tensor with ones on the diagonal and zeros in the rest.
4035
-
4036
- Refer to :func:`mindspore.ops.eye` for more details.
4037
-
4038
- Inputs:
4039
- - **n** (int) - The number of rows of returned tensor. Constant value only.
4040
- - **m** (int) - The number of columns of returned tensor. Constant value only.
4041
- - **t** (mindspore.dtype) - MindSpore's dtype, the data type of the returned tensor.
4042
- Default: ``None`` , the data type of the returned tensor is mindspore.float32.
4043
-
4044
- Outputs:
4045
- Tensor, a tensor with ones on the diagonal and the rest of elements are zero. The shape of `output` depends on
4046
- the user's Inputs `n` and `m`. And the data type depends on Inputs `t`.
4047
-
4048
- Supported Platforms:
4049
- ``Ascend`` ``GPU`` ``CPU``
4050
-
4051
- Examples:
4052
- >>> import mindspore
4053
- >>> from mindspore import ops
4054
- >>> eye = ops.Eye()
4055
- >>> output = eye(2, 2, mindspore.int32)
4056
- >>> print(output)
4057
- [[1 0]
4058
- [0 1]]
4059
- >>> print(output.dtype)
4060
- Int32
4061
- >>> output = eye(1, 2, mindspore.float64)
4062
- >>> print(output)
4063
- [[1. 0.]]
4064
- >>> print(output.dtype)
4065
- Float64
4066
- """
4067
-
4068
- @prim_attr_register
4069
- def __init__(self):
4070
- """Initialize Eye"""
4071
- self.init_prim_io_names(inputs=['n', 'm', 't'], outputs=['output'])
4072
-
4073
-
4074
- class ScatterNd(Primitive):
4075
- r"""
4076
- Scatters a tensor into a new tensor depending on the specified indices.
4077
-
4078
- Refer to :func:`mindspore.ops.scatter_nd` for more details.
4079
-
4080
- Inputs:
4081
- - **indices** (Tensor) - The index of scattering in the new tensor with int32 or int64 data type.
4082
- The rank of indices must be at least 2 and `indices_shape[-1] <= len(shape)`.
4083
- - **updates** (Tensor) - The source Tensor to be scattered.
4084
- It has shape `indices_shape[:-1] + shape[indices_shape[-1]:]`.
4085
- - **shape** (tuple[int]) - Define the shape of the output tensor, has the same data type as indices.
4086
- The shape of `shape` is :math:`(x_1, x_2, ..., x_R)`, and the length of 'shape' is greater than or equal to 2.
4087
- In other words, the shape of `shape` is at least :math:`(x_1, x_2)`.
4088
- And the value of any element in `shape` must be greater than or equal to 1.
4089
- In other words, :math:`x_1` >= 1, :math:`x_2` >= 1.
4090
-
4091
- Outputs:
4092
- Tensor, the new tensor, has the same type as `update` and the same shape as `shape`.
4093
-
4094
- Supported Platforms:
4095
- ``Ascend`` ``GPU`` ``CPU``
4096
-
4097
- Examples:
4098
- >>> import mindspore
4099
- >>> import numpy as np
4100
- >>> from mindspore import Tensor, ops
4101
- >>> op = ops.ScatterNd()
4102
- >>> indices = Tensor(np.array([[0], [2]]), mindspore.int32)
4103
- >>> updates = Tensor(np.array([[[1, 1, 1, 1], [2, 2, 2, 2],
4104
- ... [3, 3, 3, 3], [4, 4, 4, 4]],
4105
- ... [[1, 1, 1, 1], [2, 2, 2, 2],
4106
- ... [3, 3, 3, 3], [4, 4, 4, 4]]]), mindspore.float32)
4107
- >>> shape = (4, 4, 4)
4108
- >>> output = op(indices, updates, shape)
4109
- >>> print(output)
4110
- [[[1. 1. 1. 1.]
4111
- [2. 2. 2. 2.]
4112
- [3. 3. 3. 3.]
4113
- [4. 4. 4. 4.]]
4114
- [[0. 0. 0. 0.]
4115
- [0. 0. 0. 0.]
4116
- [0. 0. 0. 0.]
4117
- [0. 0. 0. 0.]]
4118
- [[1. 1. 1. 1.]
4119
- [2. 2. 2. 2.]
4120
- [3. 3. 3. 3.]
4121
- [4. 4. 4. 4.]]
4122
- [[0. 0. 0. 0.]
4123
- [0. 0. 0. 0.]
4124
- [0. 0. 0. 0.]
4125
- [0. 0. 0. 0.]]]
4126
- >>> indices = Tensor(np.array([[0, 1], [1, 1]]), mindspore.int32)
4127
- >>> updates = Tensor(np.array([3.2, 1.1]), mindspore.float32)
4128
- >>> shape = (3, 3)
4129
- >>> output = op(indices, updates, shape)
4130
- >>> # In order to facilitate understanding, explain the operator pseudo-operation process step by step:
4131
- >>> # Step 1: Generate an empty Tensor of the specified shape according to the shape
4132
- >>> # [
4133
- >>> # [0. 0. 0.]
4134
- >>> # [0. 0. 0.]
4135
- >>> # [0. 0. 0.]
4136
- >>> # ]
4137
- >>> # Step 2: Modify the data at the specified location according to the indicators
4138
- >>> # 0th row of indices is [0, 1], 0th row of updates is 3.2.
4139
- >>> # means that the empty tensor in the 0th row and 1st col set to 3.2
4140
- >>> # [
4141
- >>> # [0. 3.2. 0.]
4142
- >>> # [0. 0. 0.]
4143
- >>> # [0. 0. 0.]
4144
- >>> # ]
4145
- >>> # 1th row of indices is [1, 1], 1th row of updates is 1.1.
4146
- >>> # means that the empty tensor in the 1th row and 1st col set to 1.1
4147
- >>> # [
4148
- >>> # [0. 3.2. 0.]
4149
- >>> # [0. 1.1 0.]
4150
- >>> # [0. 0. 0.]
4151
- >>> # ]
4152
- >>> # The final result is as follows:
4153
- >>> print(output)
4154
- [[0. 3.2 0.]
4155
- [0. 1.1 0.]
4156
- [0. 0. 0.]]
4157
- """
4158
-
4159
- @prim_attr_register
4160
- def __init__(self):
4161
- """Initialize ScatterNd"""
4162
- self.init_prim_io_names(inputs=['indices', 'update', 'shape'], outputs=['output'])
4163
-
4164
-
4165
- class ResizeNearestNeighbor(Primitive):
4166
- r"""
4167
- Resizes the input tensor to a given size by using the nearest neighbor algorithm. The nearest
4168
- neighbor algorithm selects the value of the nearest point and does not consider the
4169
- values of neighboring points at all, yielding a piecewise-constant interpolant.
4170
-
4171
- Args:
4172
- size (Union[tuple, list]): The target size. The dimension of size must be 2.
4173
- align_corners (bool): Whether the centers of the 4 corner pixels of the input
4174
- and output tensors are aligned. Default: ``False`` .
4175
-
4176
- Inputs:
4177
- - **input_x** (Tensor) - The input tensor. The shape of the tensor is :math:`(N, C, H, W)`.
4178
-
4179
- Outputs:
4180
- Tensor, the shape of the output tensor is :math:`(N, C, NEW\_H, NEW\_W)`.
4181
- The data type is the same as the `input_x`.
4182
-
4183
- Raises:
4184
- TypeError: If `size` is neither tuple nor list.
4185
- TypeError: If `align_corners` is not a bool.
4186
- ValueError: If length of `size` is not equal to 2.
4187
-
4188
- Supported Platforms:
4189
- ``Ascend`` ``GPU`` ``CPU``
4190
-
4191
- Examples:
4192
- >>> import numpy as np
4193
- >>> import mindspore
4194
- >>> from mindspore import Tensor, ops
4195
- >>> input_tensor = Tensor(np.array([[[[-0.1, 0.3, 3.6], [0.4, 0.5, -3.2]]]]), mindspore.float32)
4196
- >>> size = (2, 2)
4197
- >>> output = ops.ResizeNearestNeighbor(size=size)(input_tensor)
4198
- >>> print(output)
4199
- [[[[-0.1 0.3]
4200
- [ 0.4 0.5]]]]
4201
- """
4202
-
4203
- @prim_attr_register
4204
- def __init__(self, size, align_corners=False):
4205
- """Initialize ResizeNearestNeighbor"""
4206
- validator.check_value_type("size", size, [tuple, list], self.name)
4207
- validator.check_value_type("align_corners", align_corners, [bool], self.name)
4208
- validator.check_equal_int(len(size), 2, "length of size", self.name)
4209
- for i, value in enumerate(size):
4210
- validator.check_non_negative_int(value, f'{i}th value of size', self.name)
4211
- self.init_prim_io_names(inputs=['image_in'], outputs=['image_out'])
4212
-
4213
-
4214
- class ResizeNearestNeighborV2(Primitive):
4215
- r"""
4216
- Resizes the input tensor to specific size by using the nearest neighbor algorithm.
4217
-
4218
- The nearest neighbor algorithm selects the value of the nearest point and does not consider the
4219
- values of neighboring points at all, yielding a piecewise-constant interpolant.
4220
-
4221
- Args:
4222
- align_corners (bool, optional): If ``True`` , the centers of the 4 corner pixels of the input and output
4223
- tensors are aligned, preserving the values at the corner pixels. Default: ``False`` .
4224
- half_pixel_centers (bool, optional): Whether half pixel center. If set to ``True`` ,
4225
- `align_corners` should be False. Default: ``False`` .
4226
-
4227
- Inputs:
4228
- - **x** (Tensor) - 4-D with shape :math:`(batch, channels, height, width)` .
4229
- - **size** (Tensor) - The new size for the images. A 1-D int32 Tensor
4230
- of 2 elements: [`new_height, new_width`].
4231
-
4232
- Outputs:
4233
- - **y** (Tensor) - The resized images. A 4-D with shape
4234
- :math:`(batch, channels, new\_height, new\_width)`. It has the same dtype as `x`.
4235
-
4236
- Raises:
4237
- TypeError: If `x` or `size` is not a Tensor.
4238
- TypeError: If the data type of `size` is not int32.
4239
- TypeError: If `align_corners` or `half_pixel_centers` is not bool.
4240
- ValueError: If any value of `size` is non positive.
4241
- ValueError: If the dimension of `x` is not 4.
4242
- ValueError: If the dimension of `size` is not 1.
4243
- ValueError: If the elements number of `size` is not 2.
4244
- ValueError: If attr `half_pixel_centers` and `align_corners` are True at the same time.
4245
-
4246
- Supported Platforms:
4247
- ``Ascend`` ``GPU`` ``CPU``
4248
-
4249
- Examples:
4250
- >>> import numpy as np
4251
- >>> from mindspore import Tensor, ops
4252
- >>> from mindspore import dtype as mstype
4253
- >>> input_tensor = Tensor(np.ones((1, 1, 4, 4)), mstype.float32)
4254
- >>> size = Tensor([2, 2], mstype.int32)
4255
- >>> resize = ops.ResizeNearestNeighborV2()
4256
- >>> output = resize(input_tensor, size)
4257
- >>> print(output)
4258
- [[[[1. 1.]
4259
- [1. 1.]]]]
4260
- >>> print(output.shape)
4261
- (1, 1, 2, 2)
4262
- """
4263
-
4264
- @prim_attr_register
4265
- def __init__(self, align_corners=False, half_pixel_centers=False):
4266
- """Initialize ResizeNearestNeighborV2"""
4267
- self.init_prim_io_names(inputs=['x', 'size'], outputs=['y'])
4268
- validator.check_bool(align_corners, 'align_corners', self.name)
4269
- validator.check_bool(half_pixel_centers, 'half_pixel_centers', self.name)
2295
+ Calculates the multivariate log-gamma function element-wise for a given dimension `p`.
4270
2296
 
2297
+ .. warning::
2298
+ This is an experimental API that is subject to change or deletion.
4271
2299
 
4272
- class GatherNd(Primitive):
4273
- r"""
4274
- Gathers slices from a tensor by indices.
2300
+ Refer to :func:`mindspore.ops.mvlgamma` for more details.
4275
2301
 
4276
- Refer to :func:`mindspore.ops.gather_nd` for more details.
2302
+ Args:
2303
+ p(int): The number of dimensions. And the value of `p` must be greater than or equal to 1.
4277
2304
 
4278
2305
  Inputs:
4279
- - **input_x** (Tensor) - The target tensor to gather values.
4280
- - **indices** (Tensor) - The index tensor, with int32 or int64 data type.
2306
+ - **x** (Tensor) - The tensor to compute the multivariate log-gamma function,
2307
+ which must be one of the following types: float32, float64.
2308
+ The shape is :math:`(N,*)`, where :math:`*` means any number of additional dimensions.
2309
+ And the value of any element in `x` must be greater than :math:`(p - 1) / 2`.
4281
2310
 
4282
2311
  Outputs:
4283
- Tensor, has the same type as `input_x` and the shape is indices_shape[:-1] + x_shape[indices_shape[-1]:].
2312
+ Tensor, has the same shape and type as `x`.
4284
2313
 
4285
2314
  Supported Platforms:
4286
2315
  ``Ascend`` ``GPU`` ``CPU``
@@ -4289,18 +2318,20 @@ class GatherNd(Primitive):
4289
2318
  >>> import mindspore
4290
2319
  >>> import numpy as np
4291
2320
  >>> from mindspore import Tensor, ops
4292
- >>> op = ops.GatherNd()
4293
- >>> input_x = Tensor(np.array([[-0.1, 0.3, 3.6], [0.4, 0.5, -3.2]]), mindspore.float32)
4294
- >>> indices = Tensor(np.array([[0, 0], [1, 1]]), mindspore.int32)
4295
- >>> output = op(input_x, indices)
4296
- >>> print(output)
4297
- [-0.1 0.5]
2321
+ >>> x = Tensor(np.array([[3, 4, 5], [4, 2, 6]]), mindspore.float32)
2322
+ >>> op = ops.Mvlgamma(p=3)
2323
+ >>> y = op(x)
2324
+ >>> print(y)
2325
+ [[ 2.694925 5.402975 9.140645 ]
2326
+ [ 5.402975 1.5963125 13.640454 ]]
4298
2327
  """
4299
2328
 
4300
2329
  @prim_attr_register
4301
- def __init__(self):
4302
- """Initialize GatherNd"""
4303
- self.init_prim_io_names(inputs=['input_x', 'indices'], outputs=['y'])
2330
+ def __init__(self, p):
2331
+ """Initialize Mvlgamma."""
2332
+ self.init_prim_io_names(inputs=['x'], outputs=['y'])
2333
+ validator.check_value_type('p', p, [int], self.name)
2334
+ validator.check_positive_int(p, 'p', self.name)
4304
2335
 
4305
2336
 
4306
2337
  class ScatterUpdate(Primitive):
@@ -4826,7 +2857,7 @@ class Triu(Primitive):
4826
2857
  - **y** (Tensor) - A tensor has the same shape and data type as input.
4827
2858
 
4828
2859
  Raises:
4829
- TypeError: If `x` is not an Tensor.
2860
+ TypeError: If `x` is not a Tensor.
4830
2861
  TypeError: If `diagonal` is not an int.
4831
2862
  ValueError: If the dimension of `input` is less than 2.
4832
2863
 
@@ -5933,59 +3964,6 @@ class BatchToSpaceNDV2(Primitive):
5933
3964
  self.add_prim_attr('origin_format', 'NHWC')
5934
3965
 
5935
3966
 
5936
- class BroadcastTo(PrimitiveWithCheck):
5937
- """
5938
- Broadcasts input tensor to a given shape.
5939
-
5940
- Refer to :func:`mindspore.ops.broadcast_to` for more details.
5941
-
5942
- Args:
5943
- shape (tuple): The target shape to broadcast. Can be fully specified, or have -1 in one position
5944
- where it will be substituted by the input tensor's shape in that position, see example.
5945
-
5946
- Inputs:
5947
- - **input_x** (Tensor) - The input tensor of any dimension.
5948
-
5949
- Outputs:
5950
- Tensor, with the given `shape` and the same data type as `input_x`.
5951
-
5952
- Supported Platforms:
5953
- ``Ascend`` ``GPU`` ``CPU``
5954
-
5955
- Examples:
5956
- >>> import numpy as np
5957
- >>> from mindspore import Tensor, ops
5958
- >>> shape = (2, 3)
5959
- >>> x = Tensor(np.array([1, 2, 3]).astype(np.float32))
5960
- >>> output = ops.BroadcastTo(shape=shape)(x)
5961
- >>> print(output)
5962
- [[1. 2. 3.]
5963
- [1. 2. 3.]]
5964
- >>>
5965
- >>> shape = (-1, 2)
5966
- >>> x = Tensor(np.array([[1], [2]]).astype(np.float32))
5967
- >>> output = ops.BroadcastTo(shape=shape)(x)
5968
- >>> print(output)
5969
- [[1. 1.]
5970
- [2. 2.]]
5971
- """
5972
-
5973
- @prim_attr_register
5974
- def __init__(self, shape):
5975
- """Initialize BroadcastTo"""
5976
- validator.check_value_type("shape", shape, (tuple), self.name)
5977
- validator.check("dimension of x", len(shape), "", 0, validator.GT, self.name)
5978
- for ix, i in enumerate(shape):
5979
- validator.check_value_type('target shape index -> ' + str(ix), i, [int], self.name)
5980
- validator.check("shape element", i, "shape element min limit", -1, validator.GE, self.name)
5981
- self.shape = shape
5982
-
5983
- def infer_value(self, x):
5984
- if x is None:
5985
- return None
5986
- return Tensor(np.broadcast_to(x.asnumpy(), self.shape))
5987
-
5988
-
5989
3967
  class Meshgrid(PrimitiveWithInfer):
5990
3968
  """
5991
3969
  Generates coordinate matrices from given coordinate tensors.
@@ -5993,13 +3971,13 @@ class Meshgrid(PrimitiveWithInfer):
5993
3971
  Refer to :func:`mindspore.ops.meshgrid` for more details.
5994
3972
 
5995
3973
  Args:
5996
- indexing (str, optional): Cartesian ('xy') or
5997
- matrix ('ij') indexing of output. Valid options: xy' or 'ij'. In the 2-D case with
3974
+ indexing (str, optional): Cartesian ``'xy'`` or
3975
+ matrix ``'ij'`` indexing of output. In the 2-D case with
5998
3976
  inputs of length `M` and `N`, the outputs are of shape :math:`(N, M)`
5999
- for 'xy' indexing and :math:`(M, N)` for 'ij' indexing. In the 3-D
3977
+ for ``'xy'`` indexing and :math:`(M, N)` for ``'ij'`` indexing. In the 3-D
6000
3978
  case with inputs of length `M`, `N` and `P`, outputs are of shape
6001
- :math:`(N, M, P)` for 'xy' indexing and :math:`(M, N, P)` for 'ij' indexing.
6002
- Default: 'xy'.
3979
+ :math:`(N, M, P)` for ``'xy'`` indexing and :math:`(M, N, P)` for ``'ij'`` indexing.
3980
+ Default: ``'xy'``.
6003
3981
 
6004
3982
  Inputs:
6005
3983
  - **input** (Union[tuple]) - A Tuple of N 1-D Tensor objects.
@@ -6390,56 +4368,6 @@ class EmbeddingLookup(Primitive):
6390
4368
  self.add_prim_attr('bprop_return_sparse', True)
6391
4369
 
6392
4370
 
6393
- class GatherD(Primitive):
6394
- """
6395
- Gathers elements along an axis specified by dim.
6396
-
6397
- Refer to :func:`mindspore.ops.gather_elements` for more details.
6398
-
6399
- Inputs:
6400
- - **x** (Tensor) - The input tensor.
6401
- - **dim** (int) - The axis along which to index. It must be int32 or int64.
6402
- - **index** (Tensor) - The indices of elements to gather. It can be one of the following data types:
6403
- int32, int64. The value range of each index element is [-x_rank[dim], x_rank[dim]).
6404
-
6405
- Outputs:
6406
- Tensor, has the same data type with `x`.
6407
-
6408
- Supported Platforms:
6409
- ``Ascend`` ``GPU`` ``CPU``
6410
-
6411
- Examples:
6412
- >>> import mindspore
6413
- >>> import numpy as np
6414
- >>> from mindspore import Tensor, ops
6415
- >>> x = Tensor(np.array([[1, 2], [3, 4]]), mindspore.int32)
6416
- >>> index = Tensor(np.array([[0, 0], [1, 0]]), mindspore.int32)
6417
- >>> dim = 1
6418
- >>> output = ops.GatherD()(x, dim, index)
6419
- >>> print(output)
6420
- [[1 1]
6421
- [4 3]]
6422
- """
6423
-
6424
- @prim_attr_register
6425
- def __init__(self):
6426
- """Initialize GatherD"""
6427
- self.init_prim_io_names(inputs=['x', 'dim', 'index'], outputs=['output'])
6428
-
6429
-
6430
- class Identity(Primitive):
6431
- """
6432
- The `mindspore.ops.Identity` interface is deprecated, please use the :func:`mindspore.ops.deepcopy` instead.
6433
-
6434
- Supported Platforms:
6435
- Deprecated
6436
- """
6437
-
6438
- @prim_attr_register
6439
- def __init__(self):
6440
- pass
6441
-
6442
-
6443
4371
  class IdentityN(Primitive):
6444
4372
  """
6445
4373
  Return a tuple of tensors with the same shapes and contents as the input.
@@ -6478,72 +4406,6 @@ class IdentityN(Primitive):
6478
4406
  self.init_prim_io_names(inputs=['x'], outputs=['y'])
6479
4407
 
6480
4408
 
6481
- class Range(PrimitiveWithCheck):
6482
- r"""
6483
- Creates a sequence of numbers that begins at `start` and extlimits by increments of
6484
- `delta` up to but not including `limit`.
6485
-
6486
- Refer to :func:`mindspore.ops.range` for more details.
6487
-
6488
- Args:
6489
- maxlen (int, optional): Memory that can fit `maxlen` many elements
6490
- will be allocated for the output. Optional, must be positive. Default: 1000000.
6491
- If the output has more than `maxlen` elements, a runtime error
6492
- will occur.
6493
-
6494
- Inputs:
6495
- - **start** (Tensor) - A scalar Tensor. The first number in the sequence.
6496
- - **limit** (Tensor) - A scalar Tensor. Upper limit of the sequence, exclusive.
6497
- - **delta** (Tensor) - A scalar Tensor. Number that increments `start`.
6498
-
6499
- Outputs:
6500
- A 1-D Tensor, with the same type as the inputs.
6501
-
6502
- Supported Platforms:
6503
- ``GPU`` ``CPU``
6504
-
6505
- Examples:
6506
- >>> from mindspore import Tensor, ops
6507
- >>> from mindspore import dtype as mstype
6508
- >>> start = Tensor(0, mstype.int32)
6509
- >>> limit = Tensor(10, mstype.int32)
6510
- >>> delta = Tensor(4, mstype.int32)
6511
- >>> output = ops.Range()(start, limit, delta)
6512
- >>> print(output)
6513
- [0 4 8]
6514
- """
6515
-
6516
- @prim_attr_register
6517
- def __init__(self, maxlen=1000000):
6518
- self.init_prim_io_names(inputs=['start', 'limit', 'delta'], outputs=['output'])
6519
- validator.check_value_type("maxlen", maxlen, [int], self.name)
6520
- validator.check_positive_int(maxlen, "maxlen", self.name)
6521
- self.maxlen = maxlen
6522
- self.add_prim_attr('maxlen', maxlen)
6523
-
6524
- def check_shape(self, start_shape, limit_shape, delta_shape):
6525
- if not is_shape_unknown(start_shape):
6526
- validator.check("start_shape", len(start_shape), "", 0, validator.EQ, self.name)
6527
- if not is_shape_unknown(limit_shape):
6528
- validator.check("limit_shape", len(limit_shape), "", 0, validator.EQ, self.name)
6529
- if not is_shape_unknown(delta_shape):
6530
- validator.check("delta_shape", len(delta_shape), "", 0, validator.EQ, self.name)
6531
-
6532
- def check_dtype(self, start_dtype, limit_dtype, delta_dtype):
6533
- valid_dtypes = [mstype.int32, mstype.float32, mstype.int64, mstype.float64]
6534
- inputs = {"start": start_dtype, "limit": limit_dtype, "delta": delta_dtype}
6535
- validator.check_tensors_dtypes_same_and_valid(inputs, valid_dtypes, self.name)
6536
-
6537
- def infer_value(self, start_value, limit_value, delat_value):
6538
- """Infer the value of input for Range."""
6539
- if start_value is not None and limit_value is not None and delat_value is not None:
6540
- start = start_value.asnumpy()
6541
- limit = limit_value.asnumpy()
6542
- delat = delat_value.asnumpy()
6543
- return Tensor(np.arange(start, limit, delat), dtype=start_value.dtype)
6544
- return None
6545
-
6546
-
6547
4409
  class RangeV2(Primitive):
6548
4410
  """
6549
4411
  Creates a sequence of numbers that begins at `start`, ends at `limit` but not including `limit`
@@ -6598,46 +4460,6 @@ class RangeV2(Primitive):
6598
4460
  validator.check_positive_int(maxlen, "maxlen", self.name)
6599
4461
 
6600
4462
 
6601
- class MaskedFill(Primitive):
6602
- """
6603
- Fills elements with value where mask is True.
6604
-
6605
- Note:
6606
- If `value` is a floating-point number of Python, it will be converted to float32 later by default.
6607
- In this case, if `input_x` is a float16 Tensor, it will be converted to float32 for calculation,
6608
- and the result type will be converted back to float16 on the CPU and Ascend platforms, which may
6609
- cause the performance penalty. A TypeError may be raised on the GPU platform. Therefore,
6610
- it is recommended that 'value' should use a Tensor with the same dtype as `input_x`.
6611
-
6612
- Refer to :func:`mindspore.ops.masked_fill` for more details.
6613
-
6614
- Inputs:
6615
- - **input** (Tensor) - The input Tensor.
6616
- - **mask** (Tensor[bool]) - The boolean mask.
6617
- - **value** (Union[float, Tensor]) - The value to fill in with, which dtype is the same as `input`.
6618
-
6619
- Outputs:
6620
- Tensor, has the same type and shape as `input`.
6621
-
6622
- Supported Platforms:
6623
- ``Ascend`` ``GPU`` ``CPU``
6624
-
6625
- Examples:
6626
- >>> import mindspore
6627
- >>> import numpy as np
6628
- >>> from mindspore import Tensor, ops
6629
- >>> input = Tensor(np.array([1., 2., 3., 4.]), mindspore.float32)
6630
- >>> mask = Tensor(np.array([True, True, False, True]), mindspore.bool_)
6631
- >>> output = ops.MaskedFill()(input, mask, 0.5)
6632
- >>> print(output)
6633
- [0.5 0.5 3. 0.5]
6634
- """
6635
-
6636
- @prim_attr_register
6637
- def __init__(self):
6638
- self.init_prim_io_names(inputs=['input', 'mask', 'value'], outputs=['output'])
6639
-
6640
-
6641
4463
  class MaskedScatter(Primitive):
6642
4464
  """
6643
4465
  Updates the value in the input with value in `updates` according to the `mask`.
@@ -6889,43 +4711,15 @@ class TensorScatterUpdate(_TensorScatterOp):
6889
4711
  def __init__(self):
6890
4712
  self.init_prim_io_names(inputs=['input_x', 'indices', 'updates'], outputs=['y'])
6891
4713
 
6892
- def _infer_specified_value(self, input_x_value, indices_value, updates_value):
6893
- """Calculate min/max value for output of TensorScatterUpdate op"""
6894
- if isinstance(input_x_value, tuple):
6895
- input_x_value = list(input_x_value)
6896
- if isinstance(input_x_value, (Tensor, Tensor_)):
6897
- input_x_value = input_x_value.asnumpy()
6898
- if indices_value is None or updates_value is None:
6899
- return None
6900
- if isinstance(indices_value, (Tensor, Tensor_)):
6901
- indices_value = indices_value.asnumpy()
6902
- if isinstance(updates_value, (Tensor, Tensor_)):
6903
- updates_value = updates_value.asnumpy()
6904
- input_x = np.array(input_x_value)
6905
- updates = np.array(updates_value)
6906
- for i, indice in enumerate(indices_value):
6907
- input_x[indice] = updates[i]
6908
- output = tuple(input_x.tolist())
6909
- return output
6910
-
6911
- def _infer_min_value(self, input_x_value, indices_value, updates_value):
6912
- return self._infer_specified_value(input_x_value, indices_value, updates_value)
6913
-
6914
- def _infer_max_value(self, input_x_value, indices_value, updates_value):
6915
- return self._infer_specified_value(input_x_value, indices_value, updates_value)
6916
-
6917
4714
  def infer_dtype(self, input_x_dtype, indices_dtype, updates_dtype):
6918
4715
  validator.check_tensor_dtype_valid('indices', indices_dtype, [mstype.int32, mstype.int64], self.name)
6919
4716
  args = {"input_x": input_x_dtype, "updates": updates_dtype}
6920
4717
  validator.check_tensors_dtypes_same_and_valid(args, (mstype.bool_,) + mstype.number_type, self.name)
6921
4718
  return input_x_dtype
6922
4719
 
6923
- def _infer_shape_value(self, input_x_value, indices_value, updates_value):
6924
- return self._infer_specified_value(input_x_value, indices_value, updates_value)
6925
-
6926
4720
 
6927
4721
  class TensorScatterMax(Primitive):
6928
- """
4722
+ r"""
6929
4723
  By comparing the value at the position indicated by `indices` in `x` with the value in the `updates`,
6930
4724
  the value at the index will eventually be equal to the largest one to create a new tensor.
6931
4725
 
@@ -6936,7 +4730,7 @@ class TensorScatterMax(Primitive):
6936
4730
  - **indices** (Tensor) - The index of input tensor whose data type is int32 or int64.
6937
4731
  The rank must be at least 2.
6938
4732
  - **updates** (Tensor) - The tensor to update the input tensor, has the same type as input,
6939
- and updates.shape should be equal to indices.shape[:-1] + input_x.shape[indices.shape[-1]:].
4733
+ and updates.shape should be equal to :math:`indices.shape[:-1] + input\_x.shape[indices.shape[-1]:]`.
6940
4734
 
6941
4735
  Outputs:
6942
4736
  Tensor, has the same shape and type as `input_x`.
@@ -6973,7 +4767,7 @@ class TensorScatterMax(Primitive):
6973
4767
 
6974
4768
 
6975
4769
  class TensorScatterMin(Primitive):
6976
- """
4770
+ r"""
6977
4771
  By comparing the value at the position indicated by `indices` in `input_x` with the value in the `updates`,
6978
4772
  the value at the index will eventually be equal to the smallest one to create a new tensor.
6979
4773
 
@@ -6984,7 +4778,7 @@ class TensorScatterMin(Primitive):
6984
4778
  - **indices** (Tensor) - The index of input tensor whose data type is int32 or int64.
6985
4779
  The rank must be at least 2.
6986
4780
  - **updates** (Tensor) - The tensor to update the input tensor, has the same type as input,
6987
- and updates.shape should be equal to indices.shape[:-1] + input_x.shape[indices.shape[-1]:].
4781
+ and updates.shape should be equal to :math:`indices.shape[:-1] + input\_x.shape[indices.shape[-1]:]`.
6988
4782
 
6989
4783
  Outputs:
6990
4784
  Tensor, has the same shape and type as `input_x`.
@@ -7029,7 +4823,7 @@ class TensorScatterSub(Primitive):
7029
4823
  instead of input `Parameter`.
7030
4824
 
7031
4825
  .. math::
7032
- output[indices] = input\_x - update
4826
+ output\left [indices \right ] = input\_x- update
7033
4827
 
7034
4828
  Refer to :func:`mindspore.ops.tensor_scatter_sub` for more details.
7035
4829
 
@@ -7133,7 +4927,7 @@ class TensorScatterMul(_TensorScatterOp):
7133
4927
  The updates are applied on output `Tensor` instead of input `Parameter`.
7134
4928
 
7135
4929
  .. math::
7136
- output[indices] = input\_x \times update
4930
+ output\left [indices \right ] = input\_x\times update
7137
4931
 
7138
4932
  Refer to :func:`mindspore.ops.tensor_scatter_mul` for more details.
7139
4933
 
@@ -7142,7 +4936,7 @@ class TensorScatterMul(_TensorScatterOp):
7142
4936
  - **indices** (Tensor) - The index of input tensor whose data type is int32 or int64.
7143
4937
  The rank must be at least 2.
7144
4938
  - **updates** (Tensor) - The tensor to update the input tensor, has the same type as `input_x`,
7145
- and the shape of `updates` should be equal to indices.shape[:-1] + input_x.shape[indices.shape[-1]:].
4939
+ and the shape of `updates` should be equal to :math:`indices.shape[:-1] + input\_x.shape[indices.shape[-1]:]`.
7146
4940
 
7147
4941
  Outputs:
7148
4942
  Tensor, has the same shape and type as `input_x`.
@@ -7179,7 +4973,7 @@ class TensorScatterMul(_TensorScatterOp):
7179
4973
 
7180
4974
 
7181
4975
  class TensorScatterDiv(_TensorScatterOp):
7182
- """
4976
+ r"""
7183
4977
  Creates a new tensor by dividing the values from the positions in `input_x` indicated by
7184
4978
  `indices`, with values from `updates`. When divided values are provided for the same
7185
4979
  index, the result of the update will be to divided these values respectively. Except that
@@ -7192,7 +4986,7 @@ class TensorScatterDiv(_TensorScatterOp):
7192
4986
  - **indices** (Tensor) - The index of input tensor whose data type is int32 or int64.
7193
4987
  The rank must be at least 2.
7194
4988
  - **updates** (Tensor) - The tensor to update the input tensor, has the same type as input,
7195
- and updates.shape should be equal to indices.shape[:-1] + input_x.shape[indices.shape[-1]:].
4989
+ and updates.shape should be equal to :math:`indices.shape[:-1] + input\_x.shape[indices.shape[-1]:]`.
7196
4990
 
7197
4991
  Outputs:
7198
4992
  Tensor, has the same shape and type as `input_x`.
@@ -7446,64 +5240,13 @@ class TensorScatterElements(Primitive):
7446
5240
 
7447
5241
 
7448
5242
  class ExtractVolumePatches(Primitive):
7449
- r"""
7450
- Extract patches from input and put them in the "depth" output dimension.
7451
- "depth" dimension is the second dim of output.
7452
-
7453
- .. warning::
7454
- This is an experimental API that is subject to change or deletion.
7455
-
7456
- Args:
7457
- kernel_size (Union[int, tuple[int], list[int]]): A list of ints which's length is 3 or 5.
7458
- The size of the sliding window for each dimension of input. Must be: :math:`[1, 1, k_d, k_h, k_w]` or
7459
- :math:`[k_d, k_h, k_w]`. If :math:`k_d = k_h = k_w`, you can enter an integer.
7460
- strides (Union[int, tuple[int], list[int]]): A list of ints which's length is 3 or 5.
7461
- How far the centers of two consecutive patches are in input. Must be: :math:`[1, 1, s_d, s_h, s_w]` or
7462
- :math:`[s_d, s_h, s_w]`. If :math:`s_d = s_h = s_w`, you can enter an integer.
7463
- padding (str): A string from: ``"SAME"`` , ``"VALID"`` . The type of padding algorithm to use.
7464
-
7465
- Inputs:
7466
- - **input_x** (Tensor) - A Tensor. 5-D Tensor with shape :math:`(x_n, x_c, x_d, x_h, x_w)`.
7467
-
7468
- Outputs:
7469
- Tensor, has the same type as input.
7470
- If padding is "VALID", the shape is :math:`(x_n, k_d * k_h * k_w * x_c, 1 + (x_d - k_d) / s_d,
7471
- 1 + (x_h - k_h) / s_h, 1 + (x_w - k_w) / s_w)`; if padding is "SAME", the shape is :math:`(
7472
- x_n, k_d * k_h * k_w * x_c, (x_d + s_d - 1) / s_d, (x_h + s_h - 1) / s_h, (x_w + s_w - 1) / s_w)`.
7473
-
7474
- Raises:
7475
- TypeError: If kernel_size or strides is not a list, a tuple or an int.
7476
- TypeError: If input_x is not a tensor.
7477
- TypeError: If padding is not str.
7478
- ValueError: If the length of kernel_size is neither 3 nor 5 and kernel_size is not an integer.
7479
- ValueError: If the length of strides is neither 3 nor 5 and strides is not an integer.
7480
- ValueError: If padding is neither ``"VALID"`` nor ``"SAME"`` .
7481
- ValueError: If elements of kernel_size or strides are not positive integer.
7482
- ValueError: If input_x is not a tensor in dimension 5.
7483
- ValueError: If input_x's shape has zero.
7484
- ValueError: If one of kernel_size or strides' first two numbers is not 1.
7485
- ValueError: If padding = "VALID" and :math:`input\_x - kernel\_size` is less than 0 in d, h or w dimension.
7486
- ValueError: If padding = "SAME" and :math:`padding\_needed = ((input\_x + strides - 1) / strides - 1) *
7487
- strides + kernel\_size - input\_x` is less than 0 in d, h or w dimension.
7488
- ValueError: If x_h is not 1 or x_w is not 1 and :math:`x_w + padding\_needed - k_w - s_w` is less than 0.
7489
- ValueError: If :math:`x_d * x_h * x_w` is greater than 2048.
5243
+ """
5244
+ `ops.ExtractVolumePatches` is deprecated from version 2.3 and will be removed in a future version.
7490
5245
 
7491
5246
  Supported Platforms:
7492
- ``Ascend`` ``GPU`` ``CPU``
7493
-
7494
- Examples:
7495
- >>> import numpy as np
7496
- >>> from mindspore import Tensor, ops
7497
- >>> from mindspore import dtype as mstype
7498
- >>> kernel_size = (1, 1, 2, 2, 2)
7499
- >>> strides = (1, 1, 1, 1, 1)
7500
- >>> padding = "VALID"
7501
- >>> input_x = ops.Reshape()(Tensor(np.arange(1, 28), mstype.float16), (1, 1, 3, 3, 3))
7502
- >>> output_y = ops.ExtractVolumePatches(kernel_size, strides, padding)(input_x)
7503
- >>> print(output_y.shape)
7504
- (1, 8, 2, 2, 2)
5247
+ Deprecated
7505
5248
  """
7506
-
5249
+ @deprecated("2.3", "ops.ExtractVolumePatches", False)
7507
5250
  @prim_attr_register
7508
5251
  def __init__(self, kernel_size, strides, padding):
7509
5252
  validator.check_value_type("kernel_size", kernel_size, (int, list, tuple), self.name)
@@ -7750,100 +5493,6 @@ class UpperBound(Primitive):
7750
5493
  self.init_prim_io_names(inputs=['sorted_x', 'values'], outputs=['y'])
7751
5494
 
7752
5495
 
7753
- class Cummax(Primitive):
7754
- """
7755
- Returns the cumulative maximum of elements and the index.
7756
-
7757
- Refer to :func:`mindspore.ops.cummax` for more details.
7758
-
7759
- Args:
7760
- axis (int): The axis to accumulate the tensor's value. Must be in the range [-rank(input), rank(input)).
7761
-
7762
- Inputs:
7763
- - **input** (Tensor) - The input tensor.
7764
-
7765
- Outputs:
7766
- A tuple of 2 Tensors(values, indices), containing the cumulative maximum of elements and the index,
7767
- The shape of each output tensor is the same as input `input`.
7768
-
7769
- Supported Platforms:
7770
- ``GPU`` ``CPU``
7771
-
7772
- Examples:
7773
- >>> import mindspore
7774
- >>> import numpy as np
7775
- >>> from mindspore import Tensor
7776
- >>> import mindspore.ops as ops
7777
- >>> cummax = ops.Cummax(axis=0)
7778
- >>> x = Tensor(np.array([[3, 4, 6, 10], [1, 6, 7, 9], [4, 3, 8, 7], [1, 3, 7, 9]]).astype(np.float32))
7779
- >>> output = cummax(x)
7780
- >>> print(output[0])
7781
- [[ 3. 4. 6. 10.]
7782
- [ 3. 6. 7. 10.]
7783
- [ 4. 6. 8. 10.]
7784
- [ 4. 6. 8. 10.]]
7785
- >>> print(output[1])
7786
- [[0 0 0 0]
7787
- [0 1 1 0]
7788
- [2 1 2 0]
7789
- [2 1 2 0]]
7790
- """
7791
-
7792
- @prim_attr_register
7793
- def __init__(self, axis):
7794
- """Initialize Cummax"""
7795
- validator.check_value_type("axis", axis, [int], self.name)
7796
- self.init_prim_io_names(inputs=['x'], outputs=['y', 'indices'])
7797
- self.add_prim_attr("dim", axis)
7798
-
7799
-
7800
- class RightShift(Primitive):
7801
- r"""
7802
- Shift the value of each position of Tensor `input_x` to the right by corresponding bits in Tensor `input_y`.
7803
- The inputs are two tensors, dtypes of them must be consistent, and the
7804
- shapes of them could be broadcast.
7805
-
7806
- .. math::
7807
-
7808
- \begin{aligned}
7809
- &out_{i} =x_{i} >> y_{i}
7810
- \end{aligned}
7811
-
7812
- .. warning::
7813
- This is an experimental API that is subject to change or deletion.
7814
-
7815
- Inputs:
7816
- - **input_x** (Tensor) - The target tensor, will be shifted to the right
7817
- by `input_y` bits element-wise. Support all int and uint types.
7818
- - **input_y** (Tensor) - Number of bits shifted, the tensor must have the same type as `input_x`.
7819
-
7820
- Outputs:
7821
- - **output** (Tensor) - The output tensor, has the same type as `input_x`.
7822
-
7823
- Raises:
7824
- TypeError: If `input_x` or `input_y` is not tensor.
7825
- TypeError: If `input_x` and `input_y` could not be broadcast.
7826
-
7827
- Supported Platforms:
7828
- ``Ascend`` ``GPU`` ``CPU``
7829
-
7830
- Examples:
7831
- >>> import numpy as np
7832
- >>> from mindspore import Tensor, ops
7833
- >>> rightshift = ops.RightShift()
7834
- >>> input_x = Tensor(np.array([1, 2, 3]).astype(np.uint8))
7835
- >>> input_y = Tensor(np.array([1, 1, 1]).astype(np.uint8))
7836
- >>> output = rightshift(input_x, input_y)
7837
- >>> print(output)
7838
- [0 1 1]
7839
- """
7840
-
7841
- @prim_attr_register
7842
- def __init__(self):
7843
- """Initialize RightShift."""
7844
- self.init_prim_io_names(inputs=['input_x', 'input_y'], outputs=['output'])
7845
-
7846
-
7847
5496
  class LogSpace(Primitive):
7848
5497
  r"""
7849
5498
  Generates a 1-D Tensor with a length of steps. The tensor's
@@ -7911,46 +5560,6 @@ class LogSpace(Primitive):
7911
5560
  self.init_prim_io_names(inputs=['start', 'end'], outputs=['y'])
7912
5561
 
7913
5562
 
7914
- class NonZero(Primitive):
7915
- """
7916
- Return a tensor of the positions of all non-zero values.
7917
-
7918
- Refer to :func:`mindspore.ops.nonzero` for more details.
7919
-
7920
- Inputs:
7921
- - **x** (Tensor) - The input Tensor, its rank should be greater than or eaqual to 1.
7922
-
7923
- Outputs:
7924
- - **y** (Tensor), 2-D Tensor of data type int64.
7925
-
7926
- Supported Platforms:
7927
- ``Ascend`` ``GPU`` ``CPU``
7928
-
7929
- Examples:
7930
- >>> import mindspore
7931
- >>> import numpy as np
7932
- >>> from mindspore import Tensor
7933
- >>> from mindspore.ops import NonZero
7934
- >>> x = Tensor(np.array([[[1, 0], [-5, 0]]]), mindspore.int32)
7935
- >>> nonzero = NonZero()
7936
- >>> output = nonzero(x)
7937
- >>> print(output)
7938
- [[0 0 0]
7939
- [0 1 0]]
7940
- >>> x = Tensor(np.array([1, 0, 2, 0, 3]), mindspore.int32)
7941
- >>> nonzero = NonZero()
7942
- >>> output = nonzero(x)
7943
- >>> print(output)
7944
- [[0]
7945
- [2]
7946
- [4]]
7947
- """
7948
-
7949
- @prim_attr_register
7950
- def __init__(self):
7951
- self.init_prim_io_names(inputs=['x'], outputs=['y'])
7952
-
7953
-
7954
5563
  class Tril(Primitive):
7955
5564
  """
7956
5565
  Returns the lower triangular portion of the 2-D matrix or the set of matrices
@@ -7963,7 +5572,7 @@ class Tril(Primitive):
7963
5572
 
7964
5573
  Args:
7965
5574
  diagonal (int, optional): An optional attribute indicates the diagonal to consider, default: ``0`` ,
7966
- indicating the main didiagonal.
5575
+ indicating the main diagonal.
7967
5576
 
7968
5577
  Inputs:
7969
5578
  - **x** (Tensor) - The input tensor with shape :math:`(M, N, *)`
@@ -8713,7 +6322,7 @@ class TopK(Primitive):
8713
6322
 
8714
6323
  .. math::
8715
6324
 
8716
- values.shape = indices.shape = input.shape[:-1] + [k].
6325
+ values.shape = indices.shape = input.shape[:-1] + [k]
8717
6326
 
8718
6327
  If the two compared elements are the same, the one with the smaller index value is returned first.
8719
6328
 
@@ -8729,8 +6338,7 @@ class TopK(Primitive):
8729
6338
  - GPU: float16, float32.
8730
6339
  - CPU: all numeric types.
8731
6340
 
8732
- - **k** (Union(Tensor, int)) - The number of top elements to be computed along the last dimension.
8733
- If `k` is a Tensor, the supported dtype is int32 and it should be 0-D or 1-D with shape :math:`(1, )` .
6341
+ - **k** (int) - The number of top elements to be computed along the last dimension, constant input is needed.
8734
6342
 
8735
6343
  Outputs:
8736
6344
  A tuple consisting of `values` and `indexes`.