mindspore 1.10.0__cp37-none-any.whl → 2.0.0rc1__cp37-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mindspore might be problematic. Click here for more details.

Files changed (944) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/Third_Party_Open_Source_Software_Notice +9064 -0
  3. mindspore/__init__.py +9 -4
  4. mindspore/_akg/akg/composite/build_module.py +11 -0
  5. mindspore/_akg/akg/config/repository_cuda.json +11 -0
  6. mindspore/_akg/akg/tvm/contrib/nvcc.py +4 -3
  7. mindspore/_c_dataengine.cpython-37m-aarch64-linux-gnu.so +0 -0
  8. mindspore/_c_expression.cpython-37m-aarch64-linux-gnu.so +0 -0
  9. mindspore/_c_mindrecord.cpython-37m-aarch64-linux-gnu.so +0 -0
  10. mindspore/_check_jit_forbidden_api.py +102 -0
  11. mindspore/_checkparam.py +1066 -1001
  12. mindspore/_extends/builtin_operations.py +32 -4
  13. mindspore/_extends/graph_kernel/model/graph_split.py +66 -222
  14. mindspore/_extends/parallel_compile/akg_compiler/akg_process.py +12 -9
  15. mindspore/_extends/parallel_compile/akg_compiler/build_tbe_kernel.py +119 -26
  16. mindspore/_extends/parallel_compile/akg_compiler/tbe_topi.py +50 -50
  17. mindspore/_extends/parallel_compile/akg_compiler/util.py +9 -6
  18. mindspore/_extends/parallel_compile/tbe_compiler/tbe_adapter.py +4 -25
  19. mindspore/_extends/parallel_compile/tbe_compiler/tbe_helper.py +9 -4
  20. mindspore/_extends/parallel_compile/tbe_compiler/tbe_job_manager.py +1 -27
  21. mindspore/_extends/parse/__init__.py +5 -3
  22. mindspore/_extends/parse/namespace.py +17 -2
  23. mindspore/_extends/parse/parser.py +193 -34
  24. mindspore/_extends/parse/resources.py +7 -8
  25. mindspore/_extends/parse/standard_method.py +1780 -435
  26. mindspore/_extends/parse/trope.py +3 -1
  27. mindspore/_mindspore_offline_debug.cpython-37m-aarch64-linux-gnu.so +0 -0
  28. mindspore/amp.py +53 -58
  29. mindspore/bin/cache_admin +0 -0
  30. mindspore/bin/cache_server +0 -0
  31. mindspore/boost/adasum.py +3 -2
  32. mindspore/boost/boost.py +2 -2
  33. mindspore/boost/boost_cell_wrapper.py +46 -26
  34. mindspore/boost/dim_reduce.py +6 -5
  35. mindspore/boost/grad_accumulation.py +2 -1
  36. mindspore/boost/group_loss_scale_manager.py +1 -1
  37. mindspore/common/__init__.py +11 -10
  38. mindspore/common/_decorator.py +2 -0
  39. mindspore/common/_register_for_adapter.py +55 -0
  40. mindspore/common/_stub_tensor.py +201 -0
  41. mindspore/common/_utils.py +57 -0
  42. mindspore/common/api.py +582 -297
  43. mindspore/common/dtype.py +66 -18
  44. mindspore/common/dump.py +2 -2
  45. mindspore/common/initializer.py +38 -1
  46. mindspore/common/jit_config.py +25 -13
  47. mindspore/common/mutable.py +53 -24
  48. mindspore/common/parameter.py +60 -37
  49. mindspore/common/seed.py +8 -24
  50. mindspore/common/sparse_tensor.py +927 -0
  51. mindspore/common/tensor.py +1627 -3900
  52. mindspore/communication/__init__.py +10 -5
  53. mindspore/communication/_comm_helper.py +78 -214
  54. mindspore/communication/_hccl_management.py +2 -1
  55. mindspore/communication/management.py +136 -47
  56. mindspore/config/op_info.config +501 -1008
  57. mindspore/config/super_bar_config.json +512 -0
  58. mindspore/context.py +291 -56
  59. mindspore/dataset/__init__.py +12 -8
  60. mindspore/dataset/audio/__init__.py +9 -9
  61. mindspore/dataset/audio/transforms.py +1090 -228
  62. mindspore/dataset/audio/utils.py +87 -39
  63. mindspore/dataset/audio/validators.py +223 -1
  64. mindspore/dataset/callback/ds_callback.py +17 -15
  65. mindspore/dataset/core/config.py +246 -17
  66. mindspore/dataset/core/py_util_helpers.py +4 -3
  67. mindspore/dataset/core/validator_helpers.py +10 -10
  68. mindspore/{parallel/nn/layers.py → dataset/debug/__init__.py} +7 -8
  69. mindspore/dataset/debug/debug_hook.py +65 -0
  70. mindspore/dataset/debug/pre_defined_hook.py +67 -0
  71. mindspore/dataset/engine/__init__.py +7 -3
  72. mindspore/dataset/engine/cache_client.py +9 -9
  73. mindspore/dataset/engine/datasets.py +648 -477
  74. mindspore/dataset/engine/datasets_audio.py +165 -167
  75. mindspore/dataset/engine/datasets_standard_format.py +93 -67
  76. mindspore/dataset/engine/datasets_text.py +492 -342
  77. mindspore/dataset/engine/datasets_user_defined.py +85 -50
  78. mindspore/dataset/engine/datasets_vision.py +1224 -699
  79. mindspore/dataset/engine/graphdata.py +134 -69
  80. mindspore/dataset/engine/iterators.py +50 -9
  81. mindspore/dataset/engine/offload.py +52 -31
  82. mindspore/dataset/engine/samplers.py +27 -24
  83. mindspore/dataset/engine/serializer_deserializer.py +14 -15
  84. mindspore/dataset/engine/validators.py +213 -52
  85. mindspore/dataset/text/__init__.py +10 -8
  86. mindspore/dataset/text/transforms.py +152 -57
  87. mindspore/dataset/text/utils.py +98 -49
  88. mindspore/dataset/text/validators.py +25 -0
  89. mindspore/dataset/transforms/__init__.py +4 -2
  90. mindspore/dataset/transforms/c_transforms.py +11 -13
  91. mindspore/dataset/transforms/py_transforms.py +2 -2
  92. mindspore/dataset/transforms/py_transforms_util.py +10 -0
  93. mindspore/dataset/transforms/transforms.py +13 -15
  94. mindspore/dataset/transforms/validators.py +7 -7
  95. mindspore/dataset/utils/__init__.py +2 -1
  96. mindspore/dataset/utils/browse_dataset.py +13 -13
  97. mindspore/dataset/utils/line_reader.py +121 -0
  98. mindspore/dataset/vision/__init__.py +8 -7
  99. mindspore/dataset/vision/c_transforms.py +125 -126
  100. mindspore/dataset/vision/py_transforms.py +37 -37
  101. mindspore/dataset/vision/py_transforms_util.py +23 -20
  102. mindspore/dataset/vision/transforms.py +316 -315
  103. mindspore/dataset/vision/utils.py +313 -17
  104. mindspore/dataset/vision/validators.py +6 -6
  105. mindspore/default_config.py +0 -1
  106. mindspore/{compression → experimental}/__init__.py +6 -5
  107. mindspore/experimental/map_parameter.py +275 -0
  108. mindspore/include/OWNERS +0 -1
  109. mindspore/include/api/callback/callback.h +9 -13
  110. mindspore/include/api/callback/ckpt_saver.h +2 -2
  111. mindspore/include/api/callback/loss_monitor.h +2 -2
  112. mindspore/include/api/callback/lr_scheduler.h +5 -5
  113. mindspore/include/api/callback/time_monitor.h +2 -2
  114. mindspore/include/api/callback/train_accuracy.h +4 -6
  115. mindspore/include/api/cfg.h +19 -6
  116. mindspore/include/api/context.h +70 -9
  117. mindspore/include/api/delegate.h +8 -1
  118. mindspore/include/api/dual_abi_helper.h +8 -24
  119. mindspore/include/api/metrics/accuracy.h +2 -2
  120. mindspore/include/api/metrics/metrics.h +4 -3
  121. mindspore/include/api/model.h +9 -4
  122. mindspore/include/api/model_group.h +68 -0
  123. mindspore/include/api/model_parallel_runner.h +17 -17
  124. mindspore/include/api/net.h +12 -11
  125. mindspore/include/api/serialization.h +20 -4
  126. mindspore/include/api/status.h +7 -1
  127. mindspore/include/api/types.h +25 -21
  128. mindspore/include/api/visible.h +4 -0
  129. mindspore/include/c_api/model_c.h +5 -0
  130. mindspore/include/c_api/status_c.h +1 -1
  131. mindspore/include/dataset/config.h +1 -1
  132. mindspore/include/dataset/constants.h +14 -0
  133. mindspore/include/dataset/text.h +59 -0
  134. mindspore/include/dataset/vision.h +56 -117
  135. mindspore/include/dataset/vision_lite.h +102 -0
  136. mindspore/include/mindapi/base/type_id.h +42 -3
  137. mindspore/lib/libdnnl.so.2 +0 -0
  138. mindspore/lib/libicudata.so.69 +0 -0
  139. mindspore/lib/libicui18n.so.69 +0 -0
  140. mindspore/lib/libicuuc.so.69 +0 -0
  141. mindspore/lib/libmindspore.so +0 -0
  142. mindspore/lib/libmindspore_backend.so +0 -0
  143. mindspore/lib/libmindspore_common.so +0 -0
  144. mindspore/lib/libmindspore_core.so +0 -0
  145. mindspore/lib/libmindspore_glog.so.0 +0 -0
  146. mindspore/lib/libmindspore_gpr.so.15 +0 -0
  147. mindspore/lib/libmindspore_grpc++.so.1 +0 -0
  148. mindspore/lib/libmindspore_grpc.so.15 +0 -0
  149. mindspore/lib/libmindspore_shared_lib.so +0 -0
  150. mindspore/lib/libmpi_adapter.so +0 -0
  151. mindspore/lib/libmpi_collective.so +0 -0
  152. mindspore/lib/libnnacl.so +0 -0
  153. mindspore/lib/libopencv_core.so.4.5 +0 -0
  154. mindspore/lib/libopencv_imgcodecs.so.4.5 +0 -0
  155. mindspore/lib/libopencv_imgproc.so.4.5 +0 -0
  156. mindspore/lib/libps_cache.so +0 -0
  157. mindspore/lib/plugin/ascend/libakg.so +0 -0
  158. mindspore/lib/plugin/ascend/libascend_collective.so +0 -0
  159. mindspore/lib/plugin/ascend/libdvpp_utils.so +0 -0
  160. mindspore/lib/plugin/ascend/libhccl_plugin.so +0 -0
  161. mindspore/lib/plugin/ascend/libmindspore_aicpu_kernels.so +0 -0
  162. mindspore/lib/plugin/ascend/libmindspore_cpu_kernels.so +0 -0
  163. mindspore/lib/{libakg.so → plugin/cpu/libakg.so} +0 -0
  164. mindspore/lib/plugin/libmindspore_ascend.so.1 +0 -0
  165. mindspore/lib/plugin/libmindspore_ascend.so.2 +0 -0
  166. mindspore/log.py +28 -28
  167. mindspore/mindrecord/common/exceptions.py +2 -4
  168. mindspore/mindrecord/filereader.py +19 -1
  169. mindspore/mindrecord/filewriter.py +250 -88
  170. mindspore/mindrecord/mindpage.py +13 -13
  171. mindspore/mindrecord/shardheader.py +15 -15
  172. mindspore/mindrecord/shardreader.py +9 -0
  173. mindspore/mindrecord/shardwriter.py +29 -29
  174. mindspore/mindrecord/tools/cifar100_to_mr.py +9 -9
  175. mindspore/mindrecord/tools/cifar10_to_mr.py +9 -9
  176. mindspore/mindrecord/tools/csv_to_mr.py +4 -4
  177. mindspore/mindrecord/tools/imagenet_to_mr.py +70 -65
  178. mindspore/mindrecord/tools/mnist_to_mr.py +41 -41
  179. mindspore/mindrecord/tools/tfrecord_to_mr.py +6 -6
  180. mindspore/nn/__init__.py +1 -5
  181. mindspore/nn/cell.py +297 -234
  182. mindspore/nn/dynamic_lr.py +1 -1
  183. mindspore/nn/grad/cell_grad.py +17 -42
  184. mindspore/nn/layer/__init__.py +7 -4
  185. mindspore/nn/layer/activation.py +131 -88
  186. mindspore/nn/layer/basic.py +313 -613
  187. mindspore/nn/layer/channel_shuffle.py +103 -0
  188. mindspore/nn/layer/combined.py +1 -1
  189. mindspore/nn/layer/container.py +52 -6
  190. mindspore/nn/layer/conv.py +112 -43
  191. mindspore/nn/layer/dense.py +10 -9
  192. mindspore/nn/layer/embedding.py +36 -34
  193. mindspore/nn/layer/image.py +123 -27
  194. mindspore/nn/layer/math.py +108 -107
  195. mindspore/nn/layer/normalization.py +212 -366
  196. mindspore/nn/layer/padding.py +370 -42
  197. mindspore/nn/layer/pooling.py +1443 -219
  198. mindspore/nn/layer/rnn_cells.py +11 -16
  199. mindspore/nn/layer/rnns.py +38 -39
  200. mindspore/nn/layer/thor_layer.py +24 -25
  201. mindspore/nn/layer/timedistributed.py +5 -5
  202. mindspore/nn/layer/transformer.py +701 -0
  203. mindspore/nn/learning_rate_schedule.py +8 -8
  204. mindspore/nn/loss/__init__.py +9 -6
  205. mindspore/nn/loss/loss.py +678 -142
  206. mindspore/nn/metrics.py +53 -0
  207. mindspore/nn/optim/_dist_optimizer_registry.py +2 -2
  208. mindspore/nn/optim/ada_grad.py +8 -8
  209. mindspore/nn/optim/adadelta.py +2 -3
  210. mindspore/nn/optim/adafactor.py +18 -14
  211. mindspore/nn/optim/adam.py +429 -87
  212. mindspore/nn/optim/adamax.py +5 -6
  213. mindspore/nn/optim/adasum.py +10 -8
  214. mindspore/nn/optim/asgd.py +7 -7
  215. mindspore/nn/optim/ftrl.py +81 -11
  216. mindspore/nn/optim/lamb.py +7 -8
  217. mindspore/nn/optim/lars.py +4 -4
  218. mindspore/nn/optim/lazyadam.py +82 -7
  219. mindspore/nn/optim/momentum.py +8 -7
  220. mindspore/nn/optim/optimizer.py +19 -10
  221. mindspore/nn/optim/proximal_ada_grad.py +6 -5
  222. mindspore/nn/optim/rmsprop.py +3 -3
  223. mindspore/nn/optim/rprop.py +20 -16
  224. mindspore/nn/optim/sgd.py +21 -15
  225. mindspore/nn/optim/thor.py +23 -21
  226. mindspore/nn/probability/__init__.py +0 -2
  227. mindspore/nn/probability/bijector/bijector.py +7 -6
  228. mindspore/nn/probability/bijector/invert.py +4 -2
  229. mindspore/nn/probability/bijector/softplus.py +2 -2
  230. mindspore/nn/probability/bnn_layers/dense_variational.py +1 -1
  231. mindspore/nn/probability/bnn_layers/layer_distribution.py +2 -2
  232. mindspore/nn/probability/distribution/__init__.py +6 -0
  233. mindspore/nn/probability/distribution/_utils/custom_ops.py +3 -2
  234. mindspore/nn/probability/distribution/_utils/utils.py +11 -17
  235. mindspore/nn/probability/distribution/bernoulli.py +6 -6
  236. mindspore/nn/probability/distribution/beta.py +1 -1
  237. mindspore/nn/probability/distribution/categorical.py +9 -9
  238. mindspore/nn/probability/distribution/cauchy.py +8 -8
  239. mindspore/nn/probability/distribution/distribution.py +12 -6
  240. mindspore/nn/probability/distribution/exponential.py +5 -5
  241. mindspore/nn/probability/distribution/gamma.py +3 -3
  242. mindspore/nn/probability/distribution/geometric.py +6 -5
  243. mindspore/nn/probability/distribution/gumbel.py +5 -5
  244. mindspore/nn/probability/distribution/half_normal.py +133 -0
  245. mindspore/nn/probability/distribution/laplace.py +128 -0
  246. mindspore/nn/probability/distribution/log_normal.py +0 -1
  247. mindspore/nn/probability/distribution/logistic.py +4 -5
  248. mindspore/nn/probability/distribution/normal.py +11 -15
  249. mindspore/nn/probability/distribution/poisson.py +6 -2
  250. mindspore/nn/probability/distribution/student_t.py +150 -0
  251. mindspore/nn/probability/distribution/transformed_distribution.py +4 -4
  252. mindspore/nn/probability/distribution/uniform.py +5 -5
  253. mindspore/nn/reinforcement/_tensors_queue.py +3 -3
  254. mindspore/nn/reinforcement/tensor_array.py +2 -2
  255. mindspore/nn/sparse/sparse.py +8 -1
  256. mindspore/nn/wrap/cell_wrapper.py +55 -27
  257. mindspore/nn/wrap/grad_reducer.py +20 -11
  258. mindspore/nn/wrap/loss_scale.py +47 -30
  259. mindspore/numpy/array_creations.py +33 -22
  260. mindspore/numpy/array_ops.py +46 -42
  261. mindspore/numpy/logic_ops.py +6 -27
  262. mindspore/numpy/math_ops.py +26 -19
  263. mindspore/numpy/utils.py +1 -8
  264. mindspore/numpy/utils_const.py +112 -62
  265. mindspore/ops/__init__.py +6 -3
  266. mindspore/ops/_constants.py +0 -6
  267. mindspore/ops/_grad/__init__.py +2 -1
  268. mindspore/ops/_grad/grad_array_ops.py +209 -152
  269. mindspore/ops/_grad/grad_base.py +55 -17
  270. mindspore/ops/_grad/grad_clip_ops.py +11 -3
  271. mindspore/ops/_grad/grad_comm_ops.py +58 -47
  272. mindspore/ops/_grad/grad_implementations.py +21 -61
  273. mindspore/ops/_grad/grad_inner_ops.py +48 -6
  274. mindspore/ops/_grad/grad_math_ops.py +306 -161
  275. mindspore/ops/_grad/grad_nn_ops.py +192 -181
  276. mindspore/ops/_grad/grad_other_ops.py +1 -1
  277. mindspore/ops/_grad/grad_quant_ops.py +5 -5
  278. mindspore/ops/_grad/grad_sequence_ops.py +296 -0
  279. mindspore/ops/_grad/grad_sparse.py +15 -9
  280. mindspore/ops/_grad_experimental/__init__.py +1 -0
  281. mindspore/ops/_grad_experimental/grad_array_ops.py +441 -55
  282. mindspore/ops/_grad_experimental/grad_image_ops.py +25 -7
  283. mindspore/ops/_grad_experimental/grad_inner_ops.py +3 -44
  284. mindspore/ops/_grad_experimental/grad_linalg_ops.py +16 -21
  285. mindspore/ops/_grad_experimental/grad_math_ops.py +979 -49
  286. mindspore/ops/_grad_experimental/grad_nn_ops.py +78 -8
  287. mindspore/ops/_grad_experimental/grad_scalar_ops.py +112 -0
  288. mindspore/ops/_grad_experimental/grad_sparse_ops.py +197 -13
  289. mindspore/ops/_op_impl/__init__.py +3 -3
  290. mindspore/ops/_op_impl/_custom_op/__init__.py +0 -1
  291. mindspore/ops/_op_impl/_custom_op/_basic.py +0 -1
  292. mindspore/ops/_op_impl/_custom_op/batch_matmul_impl.py +1 -1
  293. mindspore/ops/_op_impl/_custom_op/batchnorm_fold.py +4 -2
  294. mindspore/ops/_op_impl/_custom_op/batchnorm_fold2.py +2 -2
  295. mindspore/ops/_op_impl/_custom_op/batchnorm_fold2_grad.py +2 -2
  296. mindspore/ops/_op_impl/_custom_op/batchnorm_fold2_grad_reduce.py +5 -5
  297. mindspore/ops/_op_impl/_custom_op/batchnorm_fold_grad.py +3 -3
  298. mindspore/ops/_op_impl/_custom_op/cholesky_trsm_impl.py +1 -1
  299. mindspore/ops/_op_impl/_custom_op/correction_mul.py +3 -3
  300. mindspore/ops/_op_impl/_custom_op/correction_mul_grad.py +2 -2
  301. mindspore/ops/_op_impl/_custom_op/dsd_back_impl.py +4 -8
  302. mindspore/ops/_op_impl/_custom_op/dsd_impl.py +1 -1
  303. mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perchannel.py +2 -2
  304. mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perchannel_grad.py +2 -2
  305. mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perchannel_grad_reduce.py +2 -2
  306. mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perlayer.py +2 -2
  307. mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perlayer_grad.py +2 -2
  308. mindspore/ops/_op_impl/_custom_op/fake_learned_scale_quant_perlayer_grad_reduce.py +2 -2
  309. mindspore/ops/_op_impl/_custom_op/fake_quant_perchannel.py +2 -2
  310. mindspore/ops/_op_impl/_custom_op/fake_quant_perchannel_grad.py +2 -2
  311. mindspore/ops/_op_impl/_custom_op/fake_quant_perlayer.py +2 -2
  312. mindspore/ops/_op_impl/_custom_op/fake_quant_perlayer_grad.py +2 -2
  313. mindspore/ops/_op_impl/_custom_op/fused_abs_max1_impl.py +1 -1
  314. mindspore/ops/_op_impl/_custom_op/img2col_impl.py +1 -1
  315. mindspore/ops/_op_impl/_custom_op/matmul_cube_dense_left_impl.py +2 -2
  316. mindspore/ops/_op_impl/_custom_op/matmul_cube_dense_right_impl.py +1 -1
  317. mindspore/ops/_op_impl/_custom_op/matmul_cube_fracz_left_cast_impl.py +1 -1
  318. mindspore/ops/_op_impl/_custom_op/matmul_cube_fracz_right_mul_impl.py +1 -1
  319. mindspore/ops/_op_impl/_custom_op/matmul_cube_impl.py +2 -2
  320. mindspore/ops/_op_impl/_custom_op/matmul_dds_grad_impl.py +0 -1
  321. mindspore/ops/_op_impl/_custom_op/matmul_dds_impl.py +0 -1
  322. mindspore/ops/_op_impl/_custom_op/matrix_combine_impl.py +1 -1
  323. mindspore/ops/_op_impl/_custom_op/minmax_update_perchannel.py +2 -2
  324. mindspore/ops/_op_impl/_custom_op/minmax_update_perlayer.py +2 -2
  325. mindspore/ops/_op_impl/_custom_op/transpose02314_impl.py +1 -1
  326. mindspore/ops/_op_impl/aicpu/__init__.py +238 -3
  327. mindspore/ops/_op_impl/aicpu/abs.py +36 -0
  328. mindspore/ops/_op_impl/aicpu/adaptive_avg_pool_2d.py +34 -0
  329. mindspore/ops/_op_impl/aicpu/adaptive_avg_pool_2d_grad.py +34 -0
  330. mindspore/ops/_op_impl/aicpu/adaptive_avg_pool_3d.py +39 -0
  331. mindspore/ops/_op_impl/aicpu/adaptive_avg_pool_3d_grad.py +39 -0
  332. mindspore/ops/_op_impl/aicpu/adaptive_max_pool_2d_grad.py +37 -0
  333. mindspore/ops/_op_impl/aicpu/adaptive_max_pool_3d.py +42 -0
  334. mindspore/ops/_op_impl/aicpu/adaptive_max_pool_3d_grad.py +152 -0
  335. mindspore/ops/_op_impl/aicpu/add.py +43 -0
  336. mindspore/ops/_op_impl/aicpu/addcdiv.py +0 -32
  337. mindspore/ops/_op_impl/aicpu/addcmul.py +0 -84
  338. mindspore/ops/_op_impl/aicpu/affine_grid_grad.py +35 -0
  339. mindspore/ops/_op_impl/aicpu/arg_max.py +75 -0
  340. mindspore/ops/_op_impl/aicpu/arg_min.py +75 -0
  341. mindspore/ops/_op_impl/aicpu/argmin_with_value.py +43 -0
  342. mindspore/ops/_op_impl/aicpu/batch_matmul.py +43 -0
  343. mindspore/ops/_op_impl/aicpu/batch_norm_grad_grad.py +49 -0
  344. mindspore/ops/_op_impl/aicpu/bernoulli.py +48 -0
  345. mindspore/ops/_op_impl/aicpu/bessel_i0.py +31 -0
  346. mindspore/ops/_op_impl/aicpu/bias_add.py +44 -0
  347. mindspore/ops/_op_impl/aicpu/bias_add_grad.py +43 -0
  348. mindspore/ops/_op_impl/aicpu/bincount.py +33 -0
  349. mindspore/{nn/probability/infer/variational/__init__.py → ops/_op_impl/aicpu/cauchy.py} +17 -10
  350. mindspore/ops/_op_impl/aicpu/channel_shuffle.py +40 -0
  351. mindspore/ops/_op_impl/aicpu/cholesky.py +1 -1
  352. mindspore/ops/_op_impl/{cpu/bias_add.py → aicpu/choleskygrad.py} +9 -7
  353. mindspore/ops/_op_impl/aicpu/combined_non_max_suppression.py +42 -0
  354. mindspore/ops/_op_impl/aicpu/concat_offset.py +42 -0
  355. mindspore/ops/_op_impl/aicpu/concat_offset_v1.py +31 -0
  356. mindspore/ops/_op_impl/aicpu/conj.py +11 -0
  357. mindspore/ops/_op_impl/aicpu/crop_and_resize_grad_image.py +38 -0
  358. mindspore/ops/_op_impl/aicpu/cumulative_logsumexp.py +36 -0
  359. mindspore/ops/_op_impl/aicpu/deformable_offsets.py +38 -0
  360. mindspore/ops/_op_impl/aicpu/deformable_offsets_grad.py +2 -2
  361. mindspore/ops/_op_impl/aicpu/dense_to_sparse_set_operation.py +48 -0
  362. mindspore/ops/_op_impl/aicpu/diag.py +36 -0
  363. mindspore/ops/_op_impl/aicpu/diag_part.py +36 -0
  364. mindspore/ops/_op_impl/aicpu/diagonal.py +35 -0
  365. mindspore/ops/_op_impl/{cpu/bias_add_grad.py → aicpu/digamma.py} +9 -7
  366. mindspore/ops/_op_impl/aicpu/eig.py +35 -0
  367. mindspore/ops/_op_impl/aicpu/fft_with_size.py +41 -0
  368. mindspore/ops/_op_impl/aicpu/flatten.py +1 -0
  369. mindspore/ops/_op_impl/aicpu/fmax.py +36 -0
  370. mindspore/ops/_op_impl/aicpu/fmin.py +37 -0
  371. mindspore/ops/_op_impl/aicpu/fractional_max_pool3d_with_fixed_ksize.py +1 -1
  372. mindspore/ops/_op_impl/aicpu/fse_decode.py +43 -0
  373. mindspore/ops/_op_impl/aicpu/glu.py +33 -0
  374. mindspore/ops/_op_impl/aicpu/glu_grad.py +34 -0
  375. mindspore/ops/_op_impl/aicpu/greater.py +41 -0
  376. mindspore/ops/_op_impl/aicpu/greater_equal.py +41 -0
  377. mindspore/ops/_op_impl/aicpu/index_put.py +50 -0
  378. mindspore/ops/_op_impl/{tbe/scatter_add_ds.py → aicpu/inplace_index_add.py} +17 -21
  379. mindspore/ops/_op_impl/aicpu/instance_norm_v2.py +41 -0
  380. mindspore/ops/_op_impl/aicpu/instance_norm_v2_grad.py +44 -0
  381. mindspore/ops/_op_impl/aicpu/layer_norm_grad_grad.py +47 -0
  382. mindspore/ops/_op_impl/aicpu/less.py +41 -0
  383. mindspore/ops/_op_impl/aicpu/less_equal.py +41 -0
  384. mindspore/ops/_op_impl/aicpu/lgamma.py +32 -0
  385. mindspore/ops/_op_impl/aicpu/log_normal_reverse.py +33 -0
  386. mindspore/ops/_op_impl/aicpu/logit.py +33 -0
  387. mindspore/ops/_op_impl/aicpu/logit_grad.py +34 -0
  388. mindspore/ops/_op_impl/aicpu/masked_fill.py +42 -0
  389. mindspore/ops/_op_impl/aicpu/masked_scatter.py +39 -0
  390. mindspore/ops/_op_impl/aicpu/matmul.py +39 -0
  391. mindspore/ops/_op_impl/aicpu/matrix_logarithm.py +31 -0
  392. mindspore/ops/_op_impl/aicpu/matrix_power.py +32 -0
  393. mindspore/ops/_op_impl/aicpu/matrix_solve_ls.py +36 -0
  394. mindspore/ops/_op_impl/aicpu/matrix_triangular_solve.py +36 -0
  395. mindspore/ops/_op_impl/aicpu/mirror_pad.py +2 -0
  396. mindspore/ops/_op_impl/aicpu/mirror_pad_grad.py +0 -4
  397. mindspore/ops/_op_impl/aicpu/mul.py +3 -1
  398. mindspore/ops/_op_impl/aicpu/multinomial.py +14 -6
  399. mindspore/ops/_op_impl/aicpu/multinomial_with_replacement.py +35 -0
  400. mindspore/ops/_op_impl/aicpu/nan_to_num.py +34 -0
  401. mindspore/ops/_op_impl/aicpu/nllloss.py +38 -0
  402. mindspore/ops/_op_impl/aicpu/nllloss_grad.py +39 -0
  403. mindspore/ops/_op_impl/aicpu/ones_like.py +0 -2
  404. mindspore/ops/_op_impl/aicpu/polar.py +32 -0
  405. mindspore/ops/_op_impl/aicpu/polygamma.py +34 -0
  406. mindspore/ops/_op_impl/aicpu/qr.py +36 -0
  407. mindspore/ops/_op_impl/aicpu/quant_dtype_cast.py +40 -0
  408. mindspore/ops/_op_impl/aicpu/quantile.py +35 -0
  409. mindspore/ops/_op_impl/aicpu/ragged_tensor_to_sparse.py +73 -0
  410. mindspore/ops/_op_impl/aicpu/ragged_tensor_to_tensor.py +74 -0
  411. mindspore/ops/_op_impl/aicpu/random_shuffle.py +3 -0
  412. mindspore/ops/_op_impl/aicpu/randperm_v2.py +41 -0
  413. mindspore/ops/_op_impl/aicpu/range.py +36 -0
  414. mindspore/ops/_op_impl/aicpu/reciprocal.py +34 -0
  415. mindspore/ops/_op_impl/aicpu/reciprocal_grad.py +35 -0
  416. mindspore/ops/_op_impl/aicpu/reduce_sum.py +57 -0
  417. mindspore/ops/_op_impl/aicpu/resize_bicubic.py +2 -8
  418. mindspore/ops/_op_impl/aicpu/resize_bicubic_grad.py +1 -1
  419. mindspore/ops/_op_impl/aicpu/resize_v2.py +68 -0
  420. mindspore/ops/_op_impl/aicpu/resize_v2_grad.py +68 -0
  421. mindspore/ops/_op_impl/aicpu/scatter_elements.py +4 -0
  422. mindspore/ops/_op_impl/aicpu/scatter_nd_update.py +2 -0
  423. mindspore/ops/_op_impl/aicpu/search_sorted.py +12 -6
  424. mindspore/ops/_op_impl/aicpu/self_adjoint_eig.py +34 -0
  425. mindspore/ops/_op_impl/aicpu/sequence_add.py +34 -0
  426. mindspore/ops/_op_impl/aicpu/sequence_add_offset.py +34 -0
  427. mindspore/ops/_op_impl/aicpu/sequence_addn.py +38 -0
  428. mindspore/ops/_op_impl/aicpu/slice_grad.py +76 -0
  429. mindspore/ops/_op_impl/aicpu/smooth_l1_loss.py +35 -0
  430. mindspore/ops/_op_impl/aicpu/smooth_l1_loss_grad.py +37 -0
  431. mindspore/ops/_op_impl/aicpu/sort.py +39 -0
  432. mindspore/ops/_op_impl/aicpu/sparse_apply_adagrad_da.py +0 -24
  433. mindspore/ops/_op_impl/aicpu/sparse_cross.py +42 -0
  434. mindspore/ops/_op_impl/aicpu/sparse_fill_empty_rows.py +63 -0
  435. mindspore/ops/_op_impl/aicpu/sparse_fill_empty_rows_grad.py +45 -0
  436. mindspore/ops/_op_impl/aicpu/sparse_matrix_mat_mul.py +56 -0
  437. mindspore/ops/_op_impl/{tbe/slice_ds.py → aicpu/sparse_segment_sum.py} +16 -24
  438. mindspore/ops/_op_impl/aicpu/sparse_segment_sum_with_num_segments.py +68 -0
  439. mindspore/ops/_op_impl/aicpu/sparse_slice.py +63 -0
  440. mindspore/ops/_op_impl/aicpu/sparse_slice_grad.py +61 -0
  441. mindspore/ops/_op_impl/aicpu/squared_difference.py +2 -0
  442. mindspore/ops/_op_impl/aicpu/strided_slice_v2.py +93 -0
  443. mindspore/ops/_op_impl/aicpu/strided_slice_v2_grad.py +66 -0
  444. mindspore/ops/_op_impl/aicpu/tensor_scatter_update.py +59 -0
  445. mindspore/ops/_op_impl/{tbe/gather_v2.py → aicpu/tile.py} +24 -24
  446. mindspore/ops/_op_impl/aicpu/tridiagonal_solve.py +35 -0
  447. mindspore/ops/_op_impl/aicpu/tril_indices.py +34 -0
  448. mindspore/ops/_op_impl/aicpu/triu_indices.py +34 -0
  449. mindspore/ops/_op_impl/aicpu/uniform.py +34 -0
  450. mindspore/ops/_op_impl/aicpu/uniform_candidate_sampler.py +1 -0
  451. mindspore/ops/_op_impl/aicpu/unique_consecutive.py +10 -2
  452. mindspore/ops/_op_impl/cpu/__init__.py +1 -2
  453. mindspore/ops/_op_impl/cpu/dynamic_shape.py +5 -1
  454. mindspore/ops/_op_impl/cpu/maximum_grad.py +2 -0
  455. mindspore/{compression/common/__init__.py → ops/_op_impl/cpu/pyexecute.py} +13 -8
  456. mindspore/ops/_op_impl/cpu/reduce_sum.py +8 -0
  457. mindspore/ops/_op_impl/cpu/sparse_slice.py +62 -0
  458. mindspore/ops/_op_impl/cpu/sparse_slice_grad.py +60 -0
  459. mindspore/ops/_op_impl/cpu/tensor_shape.py +5 -1
  460. mindspore/ops/_op_impl/tbe/__init__.py +27 -608
  461. mindspore/ops/_op_impl/tbe/addcdiv_ds.py +42 -0
  462. mindspore/ops/_op_impl/tbe/addcmul_ds.py +44 -0
  463. mindspore/ops/_op_impl/tbe/assign_add_ds.py +1 -0
  464. mindspore/ops/_op_impl/tbe/atomic_addr_clean.py +1 -1
  465. mindspore/ops/_op_impl/tbe/avg_pool_3d_grad.py +1 -1
  466. mindspore/ops/_op_impl/tbe/basic_lstm_cell_c_state_grad_v2.py +0 -1
  467. mindspore/ops/_op_impl/tbe/batch_to_space.py +1 -1
  468. mindspore/ops/_op_impl/tbe/batch_to_space_nd.py +1 -1
  469. mindspore/ops/_op_impl/tbe/batch_to_space_nd_v2.py +41 -0
  470. mindspore/ops/_op_impl/tbe/bce_with_logits_loss.py +1 -0
  471. mindspore/ops/_op_impl/tbe/bias_add_grad.py +2 -0
  472. mindspore/ops/_op_impl/tbe/bn_infer_grad.py +4 -2
  473. mindspore/ops/_op_impl/tbe/bn_infer_grad_ds.py +40 -0
  474. mindspore/ops/_op_impl/tbe/bn_training_update.py +0 -1
  475. mindspore/ops/_op_impl/tbe/bn_training_update_ds.py +0 -1
  476. mindspore/ops/_op_impl/tbe/broadcast_to_ds.py +6 -4
  477. mindspore/ops/_op_impl/tbe/cast.py +0 -2
  478. mindspore/ops/_op_impl/tbe/cast_ds.py +3 -3
  479. mindspore/ops/_op_impl/tbe/ctc_loss_v2.py +0 -2
  480. mindspore/ops/_op_impl/tbe/ctc_loss_v2_grad.py +0 -2
  481. mindspore/ops/_op_impl/tbe/data_format_dim_map_ds.py +1 -0
  482. mindspore/ops/_op_impl/tbe/deformable_offsets.py +1 -0
  483. mindspore/ops/_op_impl/tbe/depthwise_conv2d.py +1 -1
  484. mindspore/ops/_op_impl/tbe/dynamic_atomic_addr_clean.py +1 -1
  485. mindspore/ops/_op_impl/tbe/gather_nd.py +1 -0
  486. mindspore/ops/_op_impl/tbe/greater.py +2 -0
  487. mindspore/ops/_op_impl/tbe/{index_add.py → inplace_index_add.py} +3 -6
  488. mindspore/ops/_op_impl/tbe/layer_norm_beta_gamma_backprop_v2.py +0 -1
  489. mindspore/ops/_op_impl/tbe/npu_clear_float_status_v2.py +35 -0
  490. mindspore/ops/_op_impl/tbe/npu_get_float_status_v2.py +35 -0
  491. mindspore/ops/_op_impl/tbe/one_hot_ds.py +0 -6
  492. mindspore/ops/_op_impl/tbe/{greater_ds.py → reduce_all_ds.py} +13 -16
  493. mindspore/ops/_op_impl/tbe/reduce_any_ds.py +39 -0
  494. mindspore/ops/_op_impl/tbe/roi_align_ds.py +44 -0
  495. mindspore/ops/_op_impl/tbe/roi_align_grad_ds.py +44 -0
  496. mindspore/ops/_op_impl/tbe/scatter_add.py +2 -0
  497. mindspore/ops/_op_impl/tbe/scatter_nd_add.py +2 -2
  498. mindspore/ops/_op_impl/tbe/slice.py +26 -15
  499. mindspore/ops/_op_impl/tbe/space_to_batch.py +1 -1
  500. mindspore/ops/_op_impl/tbe/space_to_batch_nd.py +1 -1
  501. mindspore/ops/_op_impl/tbe/strided_slice_grad_d.py +1 -0
  502. mindspore/ops/_op_impl/tbe/trans_data_ds.py +15 -5
  503. mindspore/ops/_op_impl/tbe/unsorted_segment_sum.py +1 -1
  504. mindspore/ops/_op_impl/tbe/unsorted_segment_sum_ds.py +2 -0
  505. mindspore/ops/_primitive_cache.py +3 -2
  506. mindspore/ops/_register_for_op.py +11 -0
  507. mindspore/ops/_utils/__init__.py +1 -1
  508. mindspore/ops/_utils/utils.py +20 -41
  509. mindspore/ops/_vmap/__init__.py +2 -2
  510. mindspore/ops/_vmap/vmap_array_ops.py +170 -78
  511. mindspore/ops/_vmap/vmap_base.py +24 -10
  512. mindspore/ops/_vmap/vmap_convolution_ops.py +7 -10
  513. mindspore/ops/_vmap/vmap_grad_math_ops.py +4 -4
  514. mindspore/ops/_vmap/vmap_grad_nn_ops.py +41 -9
  515. mindspore/ops/_vmap/vmap_image_ops.py +52 -0
  516. mindspore/ops/_vmap/vmap_math_ops.py +77 -6
  517. mindspore/ops/_vmap/vmap_nn_ops.py +78 -29
  518. mindspore/ops/_vmap/vmap_other_ops.py +3 -1
  519. mindspore/ops/_vmap/vmap_random_ops.py +55 -3
  520. mindspore/ops/_vmap/vmap_sparse_ops.py +1 -0
  521. mindspore/ops/bprop_mindir/AdaptiveAvgPool2D_bprop.mindir +0 -0
  522. mindspore/ops/bprop_mindir/AdaptiveMaxPool2D_bprop.mindir +0 -0
  523. mindspore/ops/bprop_mindir/ApproximateEqual_bprop.mindir +18 -19
  524. mindspore/ops/bprop_mindir/Argmax_bprop.mindir +13 -12
  525. mindspore/ops/bprop_mindir/Argmin_bprop.mindir +14 -13
  526. mindspore/ops/bprop_mindir/AssignSub_bprop.mindir +17 -18
  527. mindspore/ops/bprop_mindir/Assign_bprop.mindir +16 -16
  528. mindspore/ops/bprop_mindir/AvgPool3D_bprop.mindir +150 -0
  529. mindspore/ops/bprop_mindir/AvgPool_bprop.mindir +66 -0
  530. mindspore/ops/bprop_mindir/BCEWithLogitsLoss_bprop.mindir +0 -0
  531. mindspore/ops/bprop_mindir/BNTrainingReduce_bprop.mindir +13 -12
  532. mindspore/ops/bprop_mindir/BatchNormGrad_bprop.mindir +0 -0
  533. mindspore/ops/bprop_mindir/BatchToSpaceND_bprop.mindir +28 -0
  534. mindspore/ops/bprop_mindir/BiasAddGrad_bprop.mindir +0 -0
  535. mindspore/ops/bprop_mindir/BinaryCrossEntropy_bprop.mindir +33 -0
  536. mindspore/ops/bprop_mindir/BroadcastTo_bprop.mindir +306 -0
  537. mindspore/ops/bprop_mindir/Broadcast_bprop.mindir +12 -8
  538. mindspore/ops/bprop_mindir/CTCLoss_bprop.mindir +0 -0
  539. mindspore/ops/bprop_mindir/Concat_bprop.mindir +0 -0
  540. mindspore/ops/bprop_mindir/Conv2DBackpropFilter_bprop.mindir +240 -0
  541. mindspore/ops/bprop_mindir/Conv2DBackpropInput_bprop.mindir +247 -0
  542. mindspore/ops/bprop_mindir/Conv2DTranspose_bprop.mindir +247 -0
  543. mindspore/ops/bprop_mindir/Conv3DTranspose_bprop.mindir +315 -0
  544. mindspore/ops/bprop_mindir/Conv3D_bprop.mindir +278 -0
  545. mindspore/ops/bprop_mindir/DType_bprop.mindir +12 -12
  546. mindspore/ops/bprop_mindir/DeformableOffsets_bprop.mindir +58 -0
  547. mindspore/ops/bprop_mindir/Depend_bprop.mindir +12 -13
  548. mindspore/ops/bprop_mindir/DepthToSpace_bprop.mindir +23 -0
  549. mindspore/ops/bprop_mindir/DepthwiseConv2dNative_bprop.mindir +138 -0
  550. mindspore/ops/bprop_mindir/DiagPart_bprop.mindir +15 -0
  551. mindspore/ops/bprop_mindir/Dropout2D_bprop.mindir +0 -0
  552. mindspore/ops/bprop_mindir/Dropout3D_bprop.mindir +0 -0
  553. mindspore/ops/bprop_mindir/DropoutDoMask_bprop.mindir +22 -24
  554. mindspore/ops/bprop_mindir/DropoutGenMask_bprop.mindir +16 -14
  555. mindspore/ops/bprop_mindir/DropoutGrad_bprop.mindir +27 -0
  556. mindspore/ops/bprop_mindir/Dropout_bprop.mindir +0 -0
  557. mindspore/ops/bprop_mindir/DynamicGRUV2_bprop.mindir +0 -0
  558. mindspore/ops/bprop_mindir/DynamicRNN_bprop.mindir +0 -0
  559. mindspore/ops/bprop_mindir/DynamicShape_bprop.mindir +12 -12
  560. mindspore/ops/bprop_mindir/Elu_bprop.mindir +16 -0
  561. mindspore/ops/bprop_mindir/EmbeddingLookup_bprop.mindir +0 -0
  562. mindspore/ops/bprop_mindir/Equal_bprop.mindir +18 -19
  563. mindspore/ops/bprop_mindir/ExpandDims_bprop.mindir +58 -0
  564. mindspore/ops/bprop_mindir/FastGeLU_bprop.mindir +16 -0
  565. mindspore/ops/bprop_mindir/Flatten_bprop.mindir +54 -0
  566. mindspore/ops/bprop_mindir/FloorDiv_bprop.mindir +18 -15
  567. mindspore/ops/bprop_mindir/GatherD_bprop.mindir +26 -0
  568. mindspore/ops/bprop_mindir/GatherNd_bprop.mindir +57 -0
  569. mindspore/ops/bprop_mindir/Gather_bprop.mindir +0 -0
  570. mindspore/ops/bprop_mindir/GreaterEqual_bprop.mindir +17 -18
  571. mindspore/ops/bprop_mindir/Greater_bprop.mindir +18 -19
  572. mindspore/ops/bprop_mindir/HSigmoid_bprop.mindir +16 -0
  573. mindspore/ops/bprop_mindir/HSwish_bprop.mindir +16 -0
  574. mindspore/ops/bprop_mindir/IOU_bprop.mindir +18 -19
  575. mindspore/ops/bprop_mindir/InstanceNorm_bprop.mindir +0 -0
  576. mindspore/ops/bprop_mindir/IsFinite_bprop.mindir +13 -12
  577. mindspore/ops/bprop_mindir/IsInf_bprop.mindir +13 -10
  578. mindspore/ops/bprop_mindir/IsNan_bprop.mindir +14 -11
  579. mindspore/ops/bprop_mindir/KLDivLoss_bprop.mindir +126 -0
  580. mindspore/ops/bprop_mindir/L2Loss_bprop.mindir +15 -0
  581. mindspore/ops/bprop_mindir/L2Normalize_bprop.mindir +30 -0
  582. mindspore/ops/bprop_mindir/LRN_bprop.mindir +43 -0
  583. mindspore/ops/bprop_mindir/LayerNormGrad_bprop.mindir +0 -0
  584. mindspore/ops/bprop_mindir/LessEqual_bprop.mindir +18 -19
  585. mindspore/ops/bprop_mindir/Less_bprop.mindir +17 -18
  586. mindspore/ops/bprop_mindir/LinSpace_bprop.mindir +22 -19
  587. mindspore/ops/bprop_mindir/Load_bprop.mindir +12 -13
  588. mindspore/ops/bprop_mindir/LogSoftmax_bprop.mindir +23 -0
  589. mindspore/ops/bprop_mindir/LogicalAnd_bprop.mindir +17 -18
  590. mindspore/ops/bprop_mindir/LogicalNot_bprop.mindir +14 -13
  591. mindspore/ops/bprop_mindir/MaskedSelect_bprop.mindir +21 -0
  592. mindspore/ops/bprop_mindir/MaxPool3DGradGrad_bprop.mindir +74 -0
  593. mindspore/ops/bprop_mindir/MaxPool3DGrad_bprop.mindir +74 -0
  594. mindspore/ops/bprop_mindir/MaxPool3D_bprop.mindir +75 -0
  595. mindspore/ops/bprop_mindir/MaxPoolGradGrad_bprop.mindir +65 -0
  596. mindspore/ops/bprop_mindir/MaxPoolWithArgmax_bprop.mindir +0 -0
  597. mindspore/ops/bprop_mindir/Maximum_bprop.mindir +0 -0
  598. mindspore/ops/bprop_mindir/Minimum_bprop.mindir +0 -0
  599. mindspore/ops/bprop_mindir/MirrorPad_bprop.mindir +27 -0
  600. mindspore/ops/bprop_mindir/Mish_bprop.mindir +35 -0
  601. mindspore/ops/bprop_mindir/MulNoNan_bprop.mindir +0 -0
  602. mindspore/ops/bprop_mindir/NLLLoss_bprop.mindir +0 -0
  603. mindspore/ops/bprop_mindir/NonZero_bprop.mindir +14 -0
  604. mindspore/ops/bprop_mindir/NotEqual_bprop.mindir +18 -19
  605. mindspore/ops/bprop_mindir/OneHot_bprop.mindir +25 -23
  606. mindspore/ops/bprop_mindir/OnesLike_bprop.mindir +13 -13
  607. mindspore/ops/bprop_mindir/PReLU_bprop.mindir +0 -0
  608. mindspore/ops/bprop_mindir/Pad_bprop.mindir +0 -0
  609. mindspore/ops/bprop_mindir/Padding_bprop.mindir +0 -0
  610. mindspore/ops/bprop_mindir/RNNTLoss_bprop.mindir +29 -0
  611. mindspore/ops/bprop_mindir/ROIAlign_bprop.mindir +82 -0
  612. mindspore/ops/bprop_mindir/Range_bprop.mindir +21 -19
  613. mindspore/ops/bprop_mindir/Rank_bprop.mindir +11 -11
  614. mindspore/ops/bprop_mindir/ReLU6_bprop.mindir +16 -0
  615. mindspore/ops/bprop_mindir/ReLUV2_bprop.mindir +0 -0
  616. mindspore/ops/bprop_mindir/ReduceAll_bprop.mindir +18 -17
  617. mindspore/ops/bprop_mindir/ReduceAny_bprop.mindir +18 -17
  618. mindspore/ops/bprop_mindir/ReluGrad_bprop.mindir +19 -23
  619. mindspore/ops/bprop_mindir/Reshape_bprop.mindir +60 -0
  620. mindspore/ops/bprop_mindir/ResizeBilinear_bprop.mindir +29 -0
  621. mindspore/ops/bprop_mindir/ResizeNearestNeighbor_bprop.mindir +89 -0
  622. mindspore/ops/bprop_mindir/ReverseSequence_bprop.mindir +52 -0
  623. mindspore/ops/bprop_mindir/ReverseV2_bprop.mindir +22 -0
  624. mindspore/ops/bprop_mindir/Round_bprop.mindir +14 -13
  625. mindspore/ops/bprop_mindir/ScatterMax_bprop.mindir +0 -0
  626. mindspore/ops/bprop_mindir/ScatterMin_bprop.mindir +0 -0
  627. mindspore/ops/bprop_mindir/ScatterNdUpdate_bprop.mindir +22 -0
  628. mindspore/ops/bprop_mindir/ScatterNd_bprop.mindir +24 -0
  629. mindspore/ops/bprop_mindir/ScatterNonAliasingAdd_bprop.mindir +22 -0
  630. mindspore/ops/bprop_mindir/ScatterUpdate_bprop.mindir +0 -0
  631. mindspore/ops/bprop_mindir/SeLU_bprop.mindir +21 -0
  632. mindspore/ops/bprop_mindir/Select_bprop.mindir +30 -34
  633. mindspore/ops/bprop_mindir/Shape_bprop.mindir +12 -12
  634. mindspore/ops/bprop_mindir/SigmoidCrossEntropyWithLogits_bprop.mindir +21 -0
  635. mindspore/ops/bprop_mindir/SigmoidGrad_bprop.mindir +0 -0
  636. mindspore/ops/bprop_mindir/Sigmoid_bprop.mindir +16 -0
  637. mindspore/ops/bprop_mindir/Sign_bprop.mindir +13 -12
  638. mindspore/ops/bprop_mindir/Slice_bprop.mindir +26 -0
  639. mindspore/ops/bprop_mindir/SmoothL1Loss_bprop.mindir +36 -0
  640. mindspore/ops/bprop_mindir/SoftmaxCrossEntropyWithLogits_bprop.mindir +0 -0
  641. mindspore/ops/bprop_mindir/Softplus_bprop.mindir +16 -0
  642. mindspore/ops/bprop_mindir/Softsign_bprop.mindir +33 -0
  643. mindspore/ops/bprop_mindir/Sort_bprop.mindir +0 -0
  644. mindspore/ops/bprop_mindir/SpaceToBatchND_bprop.mindir +28 -0
  645. mindspore/ops/bprop_mindir/SpaceToDepth_bprop.mindir +23 -0
  646. mindspore/ops/bprop_mindir/SparseGatherV2_bprop.mindir +0 -0
  647. mindspore/ops/bprop_mindir/SparseSoftmaxCrossEntropyWithLogits_bprop.mindir +0 -0
  648. mindspore/ops/bprop_mindir/Split_bprop.mindir +22 -0
  649. mindspore/ops/bprop_mindir/Squeeze_bprop.mindir +54 -0
  650. mindspore/ops/bprop_mindir/StridedSliceGrad_bprop.mindir +95 -0
  651. mindspore/ops/bprop_mindir/StridedSlice_bprop.mindir +98 -0
  652. mindspore/ops/bprop_mindir/Switch_bprop.mindir +28 -32
  653. mindspore/ops/bprop_mindir/TanhGrad_bprop.mindir +0 -0
  654. mindspore/ops/bprop_mindir/Tanh_bprop.mindir +66 -0
  655. mindspore/ops/bprop_mindir/TensorScatterAdd_bprop.mindir +22 -0
  656. mindspore/ops/bprop_mindir/TensorScatterUpdate_bprop.mindir +29 -0
  657. mindspore/ops/bprop_mindir/TensorShape_bprop.mindir +14 -0
  658. mindspore/ops/bprop_mindir/Tile_bprop.mindir +0 -0
  659. mindspore/ops/bprop_mindir/TopK_bprop.mindir +0 -0
  660. mindspore/ops/bprop_mindir/TransShape_bprop.mindir +23 -0
  661. mindspore/ops/bprop_mindir/TruncateDiv_bprop.mindir +18 -15
  662. mindspore/ops/bprop_mindir/TupleGetItem_bprop.mindir +11 -13
  663. mindspore/ops/bprop_mindir/Unique_bprop.mindir +16 -0
  664. mindspore/ops/bprop_mindir/Unstack_bprop.mindir +22 -0
  665. mindspore/ops/bprop_mindir/UpsampleNearest3D_bprop.mindir +32 -0
  666. mindspore/ops/bprop_mindir/UpsampleTrilinear3D_bprop.mindir +38 -0
  667. mindspore/ops/bprop_mindir/ZerosLike_bprop.mindir +13 -12
  668. mindspore/ops/bprop_mindir/__init__.py +1 -4
  669. mindspore/ops/bprop_mindir/generate_mindir.py +32 -20
  670. mindspore/ops/composite/__init__.py +12 -13
  671. mindspore/ops/composite/base.py +261 -254
  672. mindspore/ops/composite/env_ops.py +41 -0
  673. mindspore/ops/composite/math_ops.py +197 -156
  674. mindspore/ops/composite/multitype_ops/_compile_utils.py +428 -176
  675. mindspore/ops/composite/multitype_ops/_constexpr_utils.py +188 -87
  676. mindspore/ops/composite/multitype_ops/add_impl.py +23 -1
  677. mindspore/ops/composite/multitype_ops/div_impl.py +3 -3
  678. mindspore/ops/composite/multitype_ops/equal_impl.py +1 -0
  679. mindspore/ops/composite/multitype_ops/floordiv_impl.py +1 -1
  680. mindspore/ops/composite/multitype_ops/getitem_impl.py +52 -5
  681. mindspore/ops/composite/multitype_ops/greater_equal_impl.py +31 -0
  682. mindspore/ops/composite/multitype_ops/greater_impl.py +31 -0
  683. mindspore/ops/composite/multitype_ops/in_impl.py +15 -3
  684. mindspore/ops/composite/multitype_ops/less_equal_impl.py +33 -2
  685. mindspore/ops/composite/multitype_ops/less_impl.py +33 -0
  686. mindspore/ops/composite/multitype_ops/logical_and_impl.py +2 -2
  687. mindspore/ops/composite/multitype_ops/logical_or_impl.py +2 -1
  688. mindspore/ops/composite/multitype_ops/mod_impl.py +1 -1
  689. mindspore/ops/composite/multitype_ops/mul_impl.py +21 -7
  690. mindspore/ops/composite/multitype_ops/not_in_impl.py +15 -3
  691. mindspore/ops/composite/multitype_ops/ones_like_impl.py +2 -4
  692. mindspore/ops/composite/multitype_ops/pow_impl.py +1 -0
  693. mindspore/ops/composite/multitype_ops/setitem_impl.py +62 -70
  694. mindspore/ops/composite/multitype_ops/sub_impl.py +3 -3
  695. mindspore/ops/composite/multitype_ops/zeros_like_impl.py +41 -4
  696. mindspore/ops/function/__init__.py +323 -8
  697. mindspore/ops/function/array_func.py +3511 -780
  698. mindspore/ops/function/clip_func.py +329 -0
  699. mindspore/ops/function/debug_func.py +6 -6
  700. mindspore/ops/function/grad/__init__.py +5 -1
  701. mindspore/ops/function/grad/grad_func.py +736 -65
  702. mindspore/ops/function/image_func.py +270 -0
  703. mindspore/ops/function/linalg_func.py +268 -8
  704. mindspore/ops/function/math_func.py +8032 -3164
  705. mindspore/ops/function/nn_func.py +5619 -1855
  706. mindspore/ops/function/other_func.py +115 -0
  707. mindspore/ops/function/parameter_func.py +11 -10
  708. mindspore/ops/function/random_func.py +939 -77
  709. mindspore/ops/function/sparse_func.py +249 -84
  710. mindspore/ops/function/sparse_unary_func.py +2303 -0
  711. mindspore/ops/function/spectral_func.py +146 -0
  712. mindspore/ops/function/vmap_func.py +114 -0
  713. mindspore/ops/functional.py +182 -254
  714. mindspore/ops/op_info_register.py +79 -34
  715. mindspore/ops/operations/__init__.py +210 -118
  716. mindspore/ops/operations/_csr_ops.py +7 -7
  717. mindspore/ops/operations/_embedding_cache_ops.py +25 -15
  718. mindspore/ops/operations/_grad_ops.py +447 -322
  719. mindspore/ops/operations/_inner_ops.py +547 -176
  720. mindspore/ops/operations/_map_tensor_ops.py +112 -0
  721. mindspore/ops/operations/_ms_kernel.py +29 -27
  722. mindspore/ops/operations/_ocr_ops.py +11 -11
  723. mindspore/ops/operations/_opaque_predicate_registry.py +41 -0
  724. mindspore/ops/operations/_quant_ops.py +186 -101
  725. mindspore/ops/operations/_rl_inner_ops.py +122 -61
  726. mindspore/ops/operations/_scalar_ops.py +466 -0
  727. mindspore/ops/operations/_sequence_ops.py +1047 -0
  728. mindspore/ops/operations/_tensor_array.py +10 -11
  729. mindspore/ops/operations/_thor_ops.py +4 -4
  730. mindspore/ops/operations/array_ops.py +1428 -1226
  731. mindspore/ops/operations/comm_ops.py +180 -117
  732. mindspore/ops/operations/control_ops.py +4 -2
  733. mindspore/ops/operations/custom_ops.py +185 -98
  734. mindspore/ops/operations/debug_ops.py +92 -54
  735. mindspore/ops/operations/image_ops.py +406 -211
  736. mindspore/ops/operations/inner_ops.py +42 -53
  737. mindspore/ops/operations/linalg_ops.py +32 -29
  738. mindspore/ops/operations/math_ops.py +2076 -897
  739. mindspore/ops/operations/nn_ops.py +1282 -1252
  740. mindspore/ops/operations/other_ops.py +124 -278
  741. mindspore/ops/operations/random_ops.py +345 -178
  742. mindspore/ops/operations/rl_ops.py +8 -9
  743. mindspore/ops/operations/sparse_ops.py +502 -157
  744. mindspore/ops/operations/spectral_ops.py +107 -0
  745. mindspore/ops/primitive.py +192 -15
  746. mindspore/ops/vm_impl_registry.py +23 -2
  747. mindspore/parallel/__init__.py +6 -1
  748. mindspore/parallel/_auto_parallel_context.py +199 -92
  749. mindspore/parallel/_cell_wrapper.py +4 -2
  750. mindspore/parallel/_cost_model_context.py +3 -0
  751. mindspore/parallel/_dp_allreduce_fusion.py +2 -1
  752. mindspore/parallel/_offload_context.py +185 -0
  753. mindspore/parallel/_parallel_serialization.py +167 -28
  754. mindspore/parallel/_ps_context.py +9 -5
  755. mindspore/parallel/_recovery_context.py +1 -1
  756. mindspore/parallel/_tensor.py +9 -1
  757. mindspore/{nn/transformer → parallel/_transformer}/__init__.py +6 -6
  758. mindspore/{nn/transformer → parallel/_transformer}/layers.py +59 -37
  759. mindspore/{nn/transformer → parallel/_transformer}/loss.py +4 -7
  760. mindspore/{nn/transformer → parallel/_transformer}/moe.py +160 -35
  761. mindspore/{nn/transformer → parallel/_transformer}/op_parallel_config.py +3 -3
  762. mindspore/{nn/transformer → parallel/_transformer}/transformer.py +235 -196
  763. mindspore/parallel/_utils.py +47 -7
  764. mindspore/parallel/algo_parameter_config.py +5 -1
  765. mindspore/parallel/checkpoint_transform.py +329 -0
  766. mindspore/parallel/shard.py +229 -0
  767. mindspore/profiler/__init__.py +2 -1
  768. mindspore/profiler/common/util.py +4 -3
  769. mindspore/profiler/common/validator/validate_path.py +2 -2
  770. mindspore/profiler/envprofiling.py +249 -0
  771. mindspore/profiler/parser/aicpu_data_parser.py +38 -39
  772. mindspore/profiler/parser/ascend_timeline_generator.py +497 -0
  773. mindspore/profiler/parser/base_timeline_generator.py +471 -0
  774. mindspore/profiler/parser/cpu_gpu_timeline_generator.py +684 -0
  775. mindspore/profiler/parser/framework_parser.py +42 -16
  776. mindspore/profiler/parser/hccl_parser.py +158 -158
  777. mindspore/profiler/parser/hwts_log_parser.py +7 -6
  778. mindspore/profiler/parser/integrator.py +18 -1579
  779. mindspore/profiler/parser/minddata_analyzer.py +8 -8
  780. mindspore/profiler/parser/msadvisor_analyzer.py +14 -27
  781. mindspore/profiler/parser/msadvisor_parser.py +2 -4
  782. mindspore/profiler/parser/optime_parser.py +17 -18
  783. mindspore/profiler/parser/profiler_info.py +108 -0
  784. mindspore/profiler/parser/step_trace_parser.py +1 -1
  785. mindspore/profiler/profiling.py +396 -194
  786. mindspore/rewrite/__init__.py +6 -2
  787. mindspore/rewrite/api/node.py +51 -110
  788. mindspore/rewrite/api/node_type.py +10 -6
  789. mindspore/rewrite/api/pattern_engine.py +51 -7
  790. mindspore/rewrite/api/scoped_value.py +64 -53
  791. mindspore/rewrite/api/symbol_tree.py +108 -61
  792. mindspore/rewrite/api/tree_node_helper.py +2 -3
  793. mindspore/{compression/quant/__init__.py → rewrite/ast_creator_register.py} +20 -11
  794. mindspore/rewrite/ast_helpers/__init__.py +6 -3
  795. mindspore/rewrite/ast_helpers/ast_creator.py +115 -0
  796. mindspore/rewrite/ast_helpers/ast_finder.py +99 -1
  797. mindspore/rewrite/ast_helpers/ast_modifier.py +17 -4
  798. mindspore/rewrite/ast_helpers/ast_replacer.py +1 -1
  799. mindspore/rewrite/ast_transformers/__init__.py +0 -1
  800. mindspore/rewrite/ast_transformers/flatten_recursive_stmt.py +46 -5
  801. mindspore/rewrite/ast_transformers/remove_return_out_of_if.py +6 -3
  802. mindspore/rewrite/common/__init__.py +2 -0
  803. mindspore/rewrite/common/event.py +1 -1
  804. mindspore/rewrite/common/observable.py +1 -1
  805. mindspore/rewrite/common/observer.py +1 -1
  806. mindspore/rewrite/common/rewrite_elog.py +35 -0
  807. mindspore/rewrite/namer.py +2 -2
  808. mindspore/rewrite/namespace.py +14 -4
  809. mindspore/rewrite/node.py +161 -13
  810. mindspore/rewrite/parser.py +0 -1
  811. mindspore/rewrite/parser_register.py +0 -1
  812. mindspore/rewrite/parsers/arguments_parser.py +3 -2
  813. mindspore/rewrite/parsers/assign_parser.py +267 -67
  814. mindspore/rewrite/parsers/attribute_parser.py +56 -0
  815. mindspore/rewrite/parsers/class_def_parser.py +191 -108
  816. mindspore/rewrite/parsers/constant_parser.py +101 -0
  817. mindspore/rewrite/parsers/container_parser.py +88 -0
  818. mindspore/rewrite/parsers/for_parser.py +28 -15
  819. mindspore/rewrite/parsers/function_def_parser.py +21 -5
  820. mindspore/rewrite/parsers/if_parser.py +11 -28
  821. mindspore/rewrite/parsers/module_parser.py +9 -6
  822. mindspore/rewrite/parsers/return_parser.py +3 -2
  823. mindspore/rewrite/sparsify/__init__.py +0 -0
  824. mindspore/rewrite/sparsify/sparse_transformer.py +448 -0
  825. mindspore/rewrite/sparsify/sparsify.py +109 -0
  826. mindspore/rewrite/sparsify/utils.py +173 -0
  827. mindspore/rewrite/symbol_tree.py +322 -109
  828. mindspore/rewrite/symbol_tree_builder.py +45 -8
  829. mindspore/rewrite/symbol_tree_dumper.py +0 -1
  830. mindspore/rewrite/topological_manager.py +1 -2
  831. mindspore/run_check/_check_version.py +209 -112
  832. mindspore/run_check/run_check.py +2 -1
  833. mindspore/scipy/linalg.py +13 -117
  834. mindspore/scipy/ops.py +5 -71
  835. mindspore/scipy/ops_grad.py +1 -25
  836. mindspore/scipy/ops_wrapper.py +1 -1
  837. mindspore/scipy/optimize/_bfgs.py +1 -1
  838. mindspore/scipy/optimize/_lagrange.py +200 -0
  839. mindspore/scipy/optimize/line_search.py +3 -2
  840. mindspore/scipy/optimize/minimize.py +43 -6
  841. mindspore/scipy/sparse/__init__.py +2 -2
  842. mindspore/scipy/sparse/linalg.py +5 -465
  843. mindspore/scipy/utils.py +2 -1
  844. mindspore/scipy/utils_const.py +7 -1
  845. mindspore/train/__init__.py +6 -4
  846. mindspore/train/_utils.py +28 -5
  847. mindspore/train/amp.py +321 -50
  848. mindspore/train/callback/__init__.py +3 -1
  849. mindspore/train/callback/_backup_and_restore.py +120 -0
  850. mindspore/train/callback/_callback.py +8 -8
  851. mindspore/train/callback/_checkpoint.py +12 -9
  852. mindspore/train/callback/_early_stop.py +13 -7
  853. mindspore/train/callback/_history.py +8 -8
  854. mindspore/train/callback/_lambda_callback.py +6 -6
  855. mindspore/train/callback/_landscape.py +36 -38
  856. mindspore/train/callback/_loss_monitor.py +12 -6
  857. mindspore/train/callback/_lr_scheduler_callback.py +2 -4
  858. mindspore/train/callback/_on_request_exit.py +212 -0
  859. mindspore/train/callback/_reduce_lr_on_plateau.py +13 -7
  860. mindspore/train/callback/_summary_collector.py +27 -19
  861. mindspore/train/callback/_time_monitor.py +13 -7
  862. mindspore/train/checkpoint_pb2.py +68 -8
  863. mindspore/train/data_sink.py +122 -33
  864. mindspore/train/dataset_helper.py +28 -87
  865. mindspore/train/loss_scale_manager.py +4 -7
  866. mindspore/{nn → train}/metrics/__init__.py +20 -20
  867. mindspore/{nn → train}/metrics/accuracy.py +12 -10
  868. mindspore/{nn → train}/metrics/auc.py +4 -4
  869. mindspore/{nn → train}/metrics/bleu_score.py +4 -4
  870. mindspore/{nn → train}/metrics/confusion_matrix.py +10 -8
  871. mindspore/{nn → train}/metrics/cosine_similarity.py +4 -4
  872. mindspore/{nn → train}/metrics/dice.py +6 -5
  873. mindspore/{nn → train}/metrics/error.py +7 -5
  874. mindspore/{nn → train}/metrics/fbeta.py +9 -7
  875. mindspore/{nn → train}/metrics/hausdorff_distance.py +8 -6
  876. mindspore/{nn → train}/metrics/loss.py +4 -3
  877. mindspore/{nn → train}/metrics/mean_surface_distance.py +6 -5
  878. mindspore/{nn → train}/metrics/metric.py +6 -5
  879. mindspore/{nn → train}/metrics/occlusion_sensitivity.py +4 -3
  880. mindspore/{nn → train}/metrics/perplexity.py +5 -4
  881. mindspore/{nn → train}/metrics/precision.py +5 -4
  882. mindspore/{nn → train}/metrics/recall.py +5 -4
  883. mindspore/{nn → train}/metrics/roc.py +7 -6
  884. mindspore/{nn → train}/metrics/root_mean_square_surface_distance.py +6 -5
  885. mindspore/{nn → train}/metrics/topk.py +7 -5
  886. mindspore/train/mind_ir_pb2.py +339 -32
  887. mindspore/train/model.py +113 -84
  888. mindspore/train/serialization.py +547 -167
  889. mindspore/train/summary/_summary_adapter.py +1 -1
  890. mindspore/train/summary/summary_record.py +43 -12
  891. mindspore/train/train_thor/convert_utils.py +7 -1
  892. mindspore/train/train_thor/dataset_helper.py +3 -3
  893. mindspore/train/train_thor/model_thor.py +0 -4
  894. mindspore/version.py +1 -1
  895. {mindspore-1.10.0.dist-info → mindspore-2.0.0rc1.dist-info}/METADATA +4 -3
  896. {mindspore-1.10.0.dist-info → mindspore-2.0.0rc1.dist-info}/RECORD +899 -675
  897. mindspore/compression/common/constant.py +0 -124
  898. mindspore/compression/export/__init__.py +0 -19
  899. mindspore/compression/export/quant_export.py +0 -514
  900. mindspore/compression/quant/qat.py +0 -636
  901. mindspore/compression/quant/quant_utils.py +0 -462
  902. mindspore/compression/quant/quantizer.py +0 -68
  903. mindspore/nn/layer/quant.py +0 -1868
  904. mindspore/nn/layer/rnn_utils.py +0 -90
  905. mindspore/nn/probability/dpn/__init__.py +0 -22
  906. mindspore/nn/probability/dpn/vae/__init__.py +0 -25
  907. mindspore/nn/probability/dpn/vae/cvae.py +0 -138
  908. mindspore/nn/probability/dpn/vae/vae.py +0 -122
  909. mindspore/nn/probability/infer/__init__.py +0 -22
  910. mindspore/nn/probability/infer/variational/elbo.py +0 -70
  911. mindspore/nn/probability/infer/variational/svi.py +0 -84
  912. mindspore/nn/probability/toolbox/__init__.py +0 -22
  913. mindspore/nn/probability/toolbox/anomaly_detection.py +0 -99
  914. mindspore/nn/probability/toolbox/uncertainty_evaluation.py +0 -363
  915. mindspore/nn/probability/transforms/__init__.py +0 -22
  916. mindspore/nn/probability/transforms/transform_bnn.py +0 -262
  917. mindspore/nn/probability/zhusuan/__init__.py +0 -18
  918. mindspore/nn/probability/zhusuan/framework/__init__.py +0 -18
  919. mindspore/nn/probability/zhusuan/framework/bn.py +0 -95
  920. mindspore/nn/probability/zhusuan/variational/__init__.py +0 -18
  921. mindspore/nn/probability/zhusuan/variational/elbo.py +0 -46
  922. mindspore/ops/_op_impl/tbe/bias_add_grad_ds.py +0 -52
  923. mindspore/ops/_op_impl/tbe/scatter_nd_add_ds.py +0 -43
  924. mindspore/ops/bprop_mindir/AssignAdd_bprop.mindir +0 -20
  925. mindspore/ops/bprop_mindir/Identity_bprop.mindir +0 -9
  926. mindspore/ops/bprop_mindir/LogicalOr_bprop.mindir +0 -20
  927. mindspore/ops/bprop_mindir/ReLU_bprop.mindir +0 -16
  928. mindspore/ops/bprop_mindir/UpdateState_bprop.mindir +0 -17
  929. mindspore/ops/bprop_mindir/stop_gradient_bprop.mindir +0 -12
  930. mindspore/ops/composite/array_ops.py +0 -210
  931. mindspore/ops/composite/clip_ops.py +0 -238
  932. mindspore/ops/composite/random_ops.py +0 -426
  933. mindspore/ops/composite/vmap_ops.py +0 -38
  934. mindspore/ops/operations/sponge_ops.py +0 -3531
  935. mindspore/ops/operations/sponge_update_ops.py +0 -2546
  936. mindspore/parallel/nn/__init__.py +0 -42
  937. mindspore/parallel/nn/loss.py +0 -22
  938. mindspore/parallel/nn/moe.py +0 -21
  939. mindspore/parallel/nn/op_parallel_config.py +0 -22
  940. mindspore/parallel/nn/transformer.py +0 -31
  941. mindspore/run_check/_check_deps_version.py +0 -84
  942. {mindspore-1.10.0.dist-info → mindspore-2.0.0rc1.dist-info}/WHEEL +0 -0
  943. {mindspore-1.10.0.dist-info → mindspore-2.0.0rc1.dist-info}/entry_points.txt +0 -0
  944. {mindspore-1.10.0.dist-info → mindspore-2.0.0rc1.dist-info}/top_level.txt +0 -0
@@ -18,10 +18,10 @@
18
18
 
19
19
  """Operators for sparse operators."""
20
20
 
21
- from mindspore._checkparam import Validator as validator
21
+ from mindspore import _checkparam as validator
22
22
  from mindspore.common import dtype as mstype
23
23
  from mindspore.ops import signature as sig
24
- from mindspore.ops.primitive import PrimitiveWithInfer, prim_attr_register, Primitive
24
+ from mindspore.ops.primitive import prim_attr_register, Primitive
25
25
 
26
26
 
27
27
  class SparseDenseCwiseAdd(Primitive):
@@ -57,9 +57,12 @@ class SparseDenseCwiseAdd(Primitive):
57
57
 
58
58
 
59
59
  Supported Platforms:
60
- ``Ascend`` ``CPU``
60
+ ``Ascend`` ``GPU`` ``CPU``
61
61
 
62
62
  Examples:
63
+ >>> from mindspore.common.tensor import Tensor
64
+ >>> from mindspore.common import dtype as ms
65
+ >>> from mindspore.ops.operations import sparse_ops as ops
63
66
  >>> x1_indices = Tensor([[0, 0], [2, 2]], dtype=ms.int64)
64
67
  >>> x1_values = Tensor([1, 2], dtype=ms.int32)
65
68
  >>> x1_shape = Tensor([3, 3], dtype=ms.int64)
@@ -109,9 +112,12 @@ class SparseDenseCwiseMul(Primitive):
109
112
  ValueError: If `x1_indices` proceed to cross the border the interview.
110
113
 
111
114
  Supported Platforms:
112
- ``Ascend`` ``CPU``
115
+ ``Ascend`` ``GPU`` ``CPU``
113
116
 
114
117
  Examples:
118
+ >>> from mindspore.common.tensor import Tensor
119
+ >>> from mindspore.common import dtype as ms
120
+ >>> from mindspore.ops.operations import sparse_ops as ops
115
121
  >>> x1_indices = Tensor([[0, 0], [2, 2]], dtype=ms.int64)
116
122
  >>> x1_values = Tensor([1, 2], dtype=ms.int32)
117
123
  >>> x1_shape = Tensor([3, 3], dtype=ms.int64)
@@ -161,9 +167,12 @@ class SparseDenseCwiseDiv(Primitive):
161
167
  ValueError: If `x1_indices` proceed to cross the border the interview.
162
168
 
163
169
  Supported Platforms:
164
- ``Ascend`` ``CPU``
170
+ ``Ascend`` ``GPU``
165
171
 
166
172
  Examples:
173
+ >>> from mindspore.common.tensor import Tensor
174
+ >>> from mindspore.common import dtype as ms
175
+ >>> from mindspore.ops.operations import sparse_ops as ops
167
176
  >>> x1_indices = Tensor([[0, 0], [2, 2]], dtype=ms.int64)
168
177
  >>> x1_values = Tensor([4, 2], dtype=ms.int32)
169
178
  >>> x1_shape = Tensor([3, 3], dtype=ms.int64)
@@ -183,49 +192,56 @@ class SparseDenseCwiseDiv(Primitive):
183
192
 
184
193
  class SparseSlice(Primitive):
185
194
  r"""
186
- Slices a SparseTensor based on the "start" and "size".
195
+ Slices a SparseTensor based on the `start` and `size`.
187
196
 
188
197
  Inputs:
189
- - **indices** (Tensor) - A 2D Tensor of type int64. The indices of the SparseTensor.
190
- Support int64, each element value should be a non-negative int number. The shape is :math:`(n, 2)`.
198
+ - **indices** (Tensor) - A 2D Tensor of shape :math:`(N, R)`, the indices of the SparseTensor.
199
+ Support int64, each element value should be a non-negative int number.
200
+ The shape is :math:`(N, R)`.
191
201
  - **values** (Tensor) - A 1D Tensor, represents the value corresponding to the position in the `indices`.
192
- The shape should be :math:`(n,)`.
202
+ The shape should be :math:`(N,)`.
193
203
  - **shape** (Tensor) - A 1D Tensor of type int64 which specifies the shape of sparsetensor,
194
- should have 2 elements, represent sparse tensor shape is :math:`(N, C)`.
204
+ represent sparse tensor shape. The shape should be :math:`(R,)`.
195
205
  - **start** (Tensor) - A 1D Tensor of type int64, represents the start of the slice.
206
+ The shape should be :math:`(R,)`.
196
207
  - **size** (Tensor) - A 1D Tensor of type int64, represents the size of the slice.
208
+ The shape should be :math:`(R,)`.
197
209
 
198
210
  Outputs:
199
211
  A `SparseTensor` objects resulting from splicing.
200
- - *y_indices: A Tensor of type int64.
201
- - *y_values: A Tensor. Has the same type as "values".
202
- - *y_shape: A Tensor of type int64.
212
+
213
+ - \*y_indices: A Tensor of type int64.
214
+ - \*y_values: A Tensor. Has the same type as `values`.
215
+ - \*y_shape: A Tensor of type int64. Has the same size as `size`.
203
216
 
204
217
  Raises:
205
218
  TypeError: If the dtype of `indices`, `shape`, `start`, `size` are not int64.
206
219
  ValueError: If `indices` is not 2-D tensor.
207
220
  ValueError: If `values`, `start`, `shape` , `size` is not a 1-D tensor.
208
221
  ValueError: If the number of `indices` is not corresponding to the number of `values`.
209
- ValueError: If the index of `indices` is out of the bounds of `shape`.
222
+ ValueError: If the shape of `indices[1]` is not corresponding to `shape`.
223
+ ValueError: If the shape of `shape` is not corresponding to `start`.
224
+ ValueError: If the shape of `shape` is not corresponding to `size`.
210
225
 
211
226
  Supported Platforms:
212
227
 
228
+
213
229
  Examples:
214
- >>> indices = Tensor([[0, 1], [1, 2], [1, 3], [2, 2]], dtype=ms.int64)
215
- >>> values = Tensor([1, 2, 3, 4])
216
- >>> shape = Tensor([3, 4], dtype=ms.int64)
217
- >>> start = Tensor([0, 1], dtype=ms.int64)
218
- >>> size = Tensor([2, 3], dtype=ms.int64)
230
+ >>> indices = Tensor(np.array([[0, 1], [1, 2], [1, 3], [2, 2]]).astype(np.int64))
231
+ >>> values = Tensor(np.array([1, 2, 3, 4]).astype(np.int64))
232
+ >>> shape = Tensor(np.array([3, 4]).astype(np.int64))
233
+ >>> start = Tensor(np.array([0, 1]).astype(np.int64))
234
+ >>> size = Tensor(np.array([2, 3]).astype(np.int64))
219
235
  >>> sparseslice = ops.SparseSlice()
220
236
  >>> output = sparseslice(indices, values, shape, start, size)
221
237
  >>> print(output[0])
222
- [[0, 0]
223
- [1, 1]
224
- [1, 2]]
238
+ [[0 0]
239
+ [1 1]
240
+ [1 2]]
225
241
  >>> print(output[1])
226
- [1, 2, 3]
242
+ [1 2 3]
227
243
  >>> print(output[2])
228
- [2, 3]
244
+ [2 3]
229
245
  """
230
246
 
231
247
  @prim_attr_register
@@ -271,7 +287,7 @@ class SparseSparseMaximum(Primitive):
271
287
  ValueError: If the `x1_shape` and `x2_shape` mismatch with each other.
272
288
 
273
289
  Supported Platforms:
274
- ``Ascend`` ``CPU``
290
+ ``Ascend`` ``GPU`` ``CPU``
275
291
 
276
292
  Examples:
277
293
  >>> x1_indices = Tensor([[0, 1], [1, 2]])
@@ -289,6 +305,7 @@ class SparseSparseMaximum(Primitive):
289
305
  >>> print(y_values)
290
306
  [3. 4. 2.]
291
307
  """
308
+
292
309
  @prim_attr_register
293
310
  def __init__(self):
294
311
  """Initialize SparseSparseMaximum."""
@@ -331,7 +348,7 @@ class SetSize(Primitive):
331
348
  >>> set_indices = Tensor(np.array([[0, 1], [1, 2]]).astype(np.int64))
332
349
  >>> set_values = Tensor(np.array([1, 2]).astype(np.int64))
333
350
  >>> set_shape = Tensor(np.array([3, 4]).astype(np.int64))
334
- >>> setsize = op.SetSize()
351
+ >>> setsize = ops.SetSize()
335
352
  >>> out = setsize(set_indices, set_values, set_shape)
336
353
  >>> print(out)
337
354
  [1 1 0]
@@ -366,16 +383,19 @@ class SparseReorder(Primitive):
366
383
  Raises:
367
384
  TypeError: If `indices` or `shape` is not tensor or its dtype is not int64.
368
385
  TypeError: If `values` is not tensor or its dtype is incorrect.
369
- ValueError: If the index exceeds the bounds.
386
+ ValueError: If the index exceeds the bounds. (Raise RuntimeError if on GPU Platform)
370
387
  ValueError: If the size of `indices` tensor shape is not equal to 2.
371
388
  ValueError: If the size of `values` or `shape` tensor shape is not equal to 1.
372
389
  ValueError: If `values` the first dimension length is not equal the first dimension length of 'indices'.
373
390
  ValueError: If `shape` the first dimension length is not equal the second dimension length of 'indices'.
374
391
 
375
392
  Supported Platforms:
376
- ``Ascend````CPU``
393
+ ``GPU`` ``CPU``
377
394
 
378
395
  Examples:
396
+ >>> import mindspore.common.dtype as ms
397
+ >>> from mindspore import Tensor
398
+ >>> import mindspore.ops.operations.sparse_ops as op
379
399
  >>> indices = Tensor([[2, 1], [0, 1]], dtype=ms.int64)
380
400
  >>> values = Tensor([1, 2], dtype=ms.int16)
381
401
  >>> shape = Tensor([3,3], dtype=ms.int64)
@@ -394,7 +414,7 @@ class SparseReorder(Primitive):
394
414
  self.init_prim_io_names(inputs=['indices', 'values', 'shape'], outputs=['y_indices', 'y_values'])
395
415
 
396
416
 
397
- class SparseToDense(PrimitiveWithInfer):
417
+ class SparseToDense(Primitive):
398
418
  """
399
419
  Converts a sparse representation into a dense tensor.
400
420
 
@@ -406,7 +426,7 @@ class SparseToDense(PrimitiveWithInfer):
406
426
  - **sparse_shape** (tuple(int)) - A positive int tuple which specifies the shape of sparse tensor,
407
427
  should have 2 elements, represent sparse tensor shape is :math:`(N, C)`.
408
428
 
409
- Returns:
429
+ Outputs:
410
430
  Tensor, converted from sparse tensor. The dtype is same as `values`, and the shape is `sparse_shape`.
411
431
 
412
432
  Raises:
@@ -434,34 +454,6 @@ class SparseToDense(PrimitiveWithInfer):
434
454
  self.init_prim_io_names(
435
455
  inputs=['indices', 'values', 'dense_shape'], outputs=['output'])
436
456
 
437
- def __infer__(self, indices, values, sparse_shape):
438
- validator.check_tensor_dtype_valid('indices', indices['dtype'], [
439
- mstype.int32, mstype.int64], self.name)
440
- validator.check_tensor_dtype_valid(
441
- 'values', values['dtype'], mstype.number_type + (mstype.bool_,), self.name)
442
- indices_shape = indices['shape']
443
- if len(indices_shape) != 2:
444
- raise ValueError(f"For '{self.name}', the 'indices' must be a 2-D tensor, "
445
- f"but got 'indices' shape: {indices_shape}.")
446
- values_shape = values['shape']
447
- if len(values_shape) != 1 or values_shape[0] != indices_shape[0]:
448
- raise ValueError(f"For '{self.name}', the 'values' must be a 1-D tensor and the first dimension length "
449
- f"must be equal to the first dimension length of 'indices', "
450
- f"but got 'indices' shape: {indices_shape}, 'values' shape: {values_shape}.")
451
- sparse_shape_v = sparse_shape['value']
452
- for i in sparse_shape_v:
453
- if isinstance(i, bool) or not isinstance(i, int) or i <= 0:
454
- raise ValueError(f"For '{self.name}', all elements in 'sparse_shape' must be "
455
- f"positive int number, but got 'sparse_shape': {sparse_shape_v}.")
456
- if len(sparse_shape_v) != indices_shape[1]:
457
- raise ValueError(f"For '{self.name}', the length of 'sparse_shape' must be equal to the second dimension "
458
- f"length of 'indices', but got the second dimension length of 'indices': "
459
- f"{indices_shape[1]}, length of 'sparse_shape': {len(sparse_shape_v)}.")
460
- out = {'shape': sparse_shape['value'],
461
- 'dtype': values['dtype'],
462
- 'value': None}
463
- return out
464
-
465
457
 
466
458
  class SparseToDenseV2(Primitive):
467
459
  """
@@ -513,6 +505,7 @@ class SparseToDenseV2(Primitive):
513
505
  """Initialize SparseToDenseV2."""
514
506
  self.add_prim_attr("max_length", 1000000)
515
507
  self.validate_indices = validate_indices
508
+ validator.check_value_type('validate_indices', validate_indices, [bool], self.name)
516
509
  self.add_prim_attr("validate_indices", self.validate_indices)
517
510
  self.init_prim_io_names(
518
511
  inputs=['indices', 'output_shape', 'values', 'default_value'], outputs=['output'])
@@ -544,7 +537,7 @@ class SparseSoftmax(Primitive):
544
537
  ValueError: If the size of shape < 2.
545
538
 
546
539
  Supported Platforms:
547
- ``Ascend`` ``CPU``
540
+ ``Ascend`` ``GPU`` ``CPU``
548
541
 
549
542
  Examples:
550
543
  >>> indices = Tensor([[0,0], [0,3], [1,2], [1,5], [2,0], [2,5]])
@@ -568,11 +561,11 @@ class SparseTensorDenseAdd(Primitive):
568
561
 
569
562
  Inputs:
570
563
  - **x1_indices** (Tensor) - A 2-D Tensor, represents the position of the element in the sparse tensor.
571
- Support int32, int64, each element value should be a non-negative int number. The shape is :math:`(n, 2)`.
564
+ Support int32, int64, each element value should be a non-negative int number. The shape is :math:`(n, ndim)`.
572
565
  - **x1_values** (Tensor) - A 1-D Tensor, represents the value corresponding to the position in the `indices`.
573
566
  The shape should be :math:`(n,)`.
574
567
  - **x1_shape** (tuple(int)) - A positive int tuple which specifies the shape of sparse tensor,
575
- should have 2 elements, represent sparse tensor shape is :math:`(N, C)`.
568
+ should have ndim elements, represent sparse tensor shape is :math:`(ndim,)`.
576
569
  - **x2** (Tensor) - A dense Tensor, the dtype is same as `values`.
577
570
 
578
571
  Outputs:
@@ -582,14 +575,14 @@ class SparseTensorDenseAdd(Primitive):
582
575
  Raises:
583
576
  TypeError: If the dtype of `x1_indices` and 'x1_shape' is neither int32 nor int64.
584
577
  ValueError: If `x1_shape`, shape of `x1_indices`, shape of `x1_values` and shape
585
- of 'x2' don't meet the parameter description.
578
+ of 'x2' don't meet the parameter description.
586
579
 
587
580
  Supported Platforms:
588
- ``CPU``
581
+ ``GPU`` ``CPU``
589
582
 
590
583
  Examples:
591
584
  >>> from mindspore import Tensor
592
- >>> from mindspore.ops import operations as ops
585
+ >>> import mindspore.ops as ops
593
586
  >>> from mindspore.common import dtype as mstype
594
587
  >>> x1_indices = Tensor([[0, 0], [0, 1]], dtype=mstype.int64)
595
588
  >>> x1_values = Tensor([1, 1], dtype=mstype.float32)
@@ -645,9 +638,13 @@ class SparseTensorDenseMatmul(Primitive):
645
638
  and shape of `dense` don't meet the parameter description.
646
639
 
647
640
  Supported Platforms:
648
- ``CPU``
641
+ ``GPU`` ``CPU``
649
642
 
650
643
  Examples:
644
+ >>> import mindspore
645
+ >>> from mindspore import Tensor
646
+ >>> from mindspore.ops import operations as ops
647
+ >>> from mindspore.common import dtype as mstype
651
648
  >>> indices = Tensor([[0, 1], [1, 2]], dtype=mindspore.int32)
652
649
  >>> values = Tensor([1, 2], dtype=mindspore.float32)
653
650
  >>> sparse_shape = (3, 4)
@@ -673,45 +670,6 @@ class SparseTensorDenseMatmul(Primitive):
673
670
  validator.check_value_type("adjoint_dt", adjoint_dt, [bool], self.name)
674
671
  self.set_const_input_indexes([2])
675
672
 
676
- def __infer__(self, indices, values, sparse_shape, dense):
677
- validator.check_tensor_dtype_valid('indices', indices['dtype'], [
678
- mstype.int32, mstype.int64], self.name)
679
- valid_types = (mstype.float16, mstype.float32,
680
- mstype.float64, mstype.int32, mstype.int64)
681
- args = {'values': values['dtype'], 'dense': dense['dtype']}
682
- validator.check_tensors_dtypes_same_and_valid(
683
- args, valid_types, self.name)
684
- indices_shape = indices['shape']
685
- if len(indices_shape) != 2 or indices_shape[1] != 2:
686
- raise ValueError(f"For '{self.name}', the 'indices' must be a 2-D tensor and "
687
- f"the second dimension length must be 2, but got 'indices' shape: {indices_shape}.")
688
- values_shape = values['shape']
689
- if len(values_shape) != 1 or values_shape[0] != indices_shape[0]:
690
- raise ValueError(f"For '{self.name}', the 'values' must be a 1-D tensor and "
691
- f"the first dimension length must be equal to the first dimension length of 'indices', "
692
- f"but got 'indices' shape: {indices_shape}, 'values' shape: {values_shape}.")
693
- a_shape = sparse_shape['value'][::-1] if self.adjoint_st else sparse_shape['value']
694
- b_shape = dense['shape'][::-1] if self.adjoint_dt else dense['shape']
695
- for i in a_shape:
696
- if isinstance(i, bool) or not isinstance(i, int) or i <= 0:
697
- raise ValueError(f"For '{self.name}', all elements in 'sparse_shape' must be "
698
- f"positive int number, but got 'sparse_shape': {a_shape}.")
699
- if len(a_shape) != 2 or len(b_shape) != 2:
700
- raise ValueError(f"For '{self.name}', both the length of 'sparse_shape' and the tensor "
701
- f"rank of 'dense' must be equal to 2, but got the length of "
702
- f"'sparse_shape': {len(a_shape)}, "
703
- f"the tensor rank of 'dense': {len(b_shape)}.")
704
- if a_shape[1] != b_shape[0]:
705
- raise ValueError(f"For '{self.name}', the second dimension length of 'sparse_shape' must be equal to the "
706
- f"first dimension length of 'dense', but got "
707
- f"the tensor shape of 'sparse': {a_shape} and the tensor shape of 'dense': {b_shape}. "
708
- f"Don't meet the condition for matmul")
709
- out_shape = [a_shape[0], b_shape[1]]
710
- out = {'shape': tuple(out_shape),
711
- 'dtype': values['dtype'],
712
- 'value': None}
713
- return out
714
-
715
673
 
716
674
  class CSRSparseMatrixToSparseTensor(Primitive):
717
675
  """
@@ -788,7 +746,7 @@ class DenseToCSRSparseMatrix(Primitive):
788
746
  Converts a dense matrix(maybe batched) to its CSR sparse form.
789
747
 
790
748
  .. warning::
791
- This is an experimental prototype that is subject to change and/or deletion.
749
+ This is an experimental API that is subject to change or deletion.
792
750
 
793
751
  Inputs:
794
752
  - **dense_input** (Tensor) - A 2-D or 3-D Tensor. It represents the input dense matrix.
@@ -818,7 +776,7 @@ class DenseToCSRSparseMatrix(Primitive):
818
776
  ValueError: If shape[1] of `indices` and rank of `dense_input` is not the same.
819
777
 
820
778
  Supported Platforms:
821
- ``Ascend`` ``GPU`` ``CPU``
779
+
822
780
 
823
781
  Examples:
824
782
  >>> x = Tensor([[[1., 0.], [0., 2.]]], dtype=mindspore.float32)
@@ -917,7 +875,7 @@ class Sspaddmm(Primitive):
917
875
  If `x1_shape` is :math:`(s0, s1)`, `x2_shpae` should be :math:`(s0, s2)`, the `x3_shape` should be :math:`(s2, s1)`.
918
876
 
919
877
  .. warning::
920
- This is an experimental prototype that is subject to change and/or deletion.
878
+ This is an experimental API that is subject to change or deletion.
921
879
 
922
880
  .. math::
923
881
  out =\beta * x1 + \alpha * (x2 @ x3),
@@ -980,7 +938,7 @@ class Sspaddmm(Primitive):
980
938
  ValueError: If the shape of `alpha`, `beta` is not () or (1,).
981
939
 
982
940
  Supported Platforms:
983
- ``Ascend`` ``CPU``
941
+ ``Ascend`` ``GPU`` ``CPU``
984
942
 
985
943
  Examples:
986
944
  >>> x1_indices = Tensor(np.array([[0, 1], [0, 1]]), mstype.int64)
@@ -1003,6 +961,17 @@ class Sspaddmm(Primitive):
1003
961
  >>> print(out_shapes)
1004
962
  [3 3]
1005
963
  """
964
+ __mindspore_signature__ = (
965
+ sig.make_sig('x1_indices', dtype=sig.sig_dtype.T1),
966
+ sig.make_sig('x1_values', dtype=sig.sig_dtype.T),
967
+ sig.make_sig('x1_shape', dtype=sig.sig_dtype.T2),
968
+ sig.make_sig('x2_indices', dtype=sig.sig_dtype.T3),
969
+ sig.make_sig('x2_values', dtype=sig.sig_dtype.T),
970
+ sig.make_sig('x2_shape', dtype=sig.sig_dtype.T4),
971
+ sig.make_sig('x3_dense', dtype=sig.sig_dtype.T),
972
+ sig.make_sig('alpha', dtype=sig.sig_dtype.T),
973
+ sig.make_sig('beta', dtype=sig.sig_dtype.T)
974
+ )
1006
975
 
1007
976
  @prim_attr_register
1008
977
  def __init__(self):
@@ -1041,7 +1010,7 @@ class SparseAddmm(Primitive):
1041
1010
  RuntimeError: If `x1_shape`, shape of `x2`, shape of `x3` don't meet the parameter description.
1042
1011
 
1043
1012
  Supported Platforms:
1044
- ``Ascend`` ``CPU``
1013
+ ``GPU`` ``CPU``
1045
1014
 
1046
1015
  Examples:
1047
1016
  >>> indices = Tensor([[0, 1], [1, 2]], dtype=ms.int32)
@@ -1114,6 +1083,7 @@ class SparseConcat(Primitive):
1114
1083
  [3, 0],
1115
1084
  [4, 1]]), Tensor(shape=[4], dtype=Int32, value= [1, 2, 3, 4]), Tensor(shape=[2], dtype=Int64, value= [6, 4]))
1116
1085
  """
1086
+
1117
1087
  @prim_attr_register
1118
1088
  def __init__(self, concat_dim=0):
1119
1089
  """Initialize SparseConcat."""
@@ -1127,11 +1097,11 @@ class SparseSegmentSum(Primitive):
1127
1097
  Computes the sum along sparse segments of a tensor.
1128
1098
 
1129
1099
  Inputs:
1130
- - **x** (Tensor) - A tensor.
1131
- - **indices** (Tensor) - Indices is a 1-D tensor. Must be one of the following types: int32, int64.
1132
- Has same rank as segment_ids. The shape should be :math:`(N,)`.
1133
- - **segment_ids** (Tensor) - Segment_ids is a 1-D tensor. Must be one of the following types: int32, int64.
1134
- Values should be sorted and can be repeated. The shape should be :math:`(N,)`.
1100
+ - **x** (Tensor) - A tensor of the first input of SparseSegmentSum.
1101
+ - **indices** (Tensor) - 1-D Tensor of type int32 or int 64 with indices into `x`.
1102
+ Has same rank as `segment_ids`. The shape should be :math:`(N,)`.
1103
+ - **segment_ids** (Tensor) - 1-D Tensor of type int32 or int64 with indices into the output `y`. Values
1104
+ should be sorted and can be repeated. The shape should be :math:`(N,)`.
1135
1105
 
1136
1106
  Outputs:
1137
1107
  A Tensor. Has the same type as `x` .
@@ -1145,10 +1115,10 @@ class SparseSegmentSum(Primitive):
1145
1115
  ValueError: If shape[0] of `indices` is not corresponding to shape[0] of `segment_ids`.
1146
1116
  ValueError: If indices in `segment_ids` are not contiguous or do not start from 0.
1147
1117
  ValueError: If `segment_ids` is not sorted.
1148
- ValueError: If `indices` is out of range of x's first shape.
1118
+ ValueError: If `indices` is out of range of x's first dimension.
1149
1119
 
1150
1120
  Supported Platforms:
1151
- ``GPU``
1121
+ ``Ascend`` ``GPU`` ``CPU``
1152
1122
 
1153
1123
  Examples:
1154
1124
  >>> x = Tensor([[0, 1, 2], [1, 2, 3], [3, 6, 7]], dtype=ms.float32)
@@ -1170,7 +1140,6 @@ class SparseSegmentSum(Primitive):
1170
1140
  def __init__(self):
1171
1141
  """Initialize SparseSegmentSum"""
1172
1142
  self.init_prim_io_names(inputs=['x', 'indices', 'segment_ids'], outputs=['y'])
1173
- self.add_prim_attr("cust_aicpu", self.name)
1174
1143
 
1175
1144
 
1176
1145
  class SparseSegmentSumWithNumSegments(Primitive):
@@ -1178,12 +1147,13 @@ class SparseSegmentSumWithNumSegments(Primitive):
1178
1147
  Computes the sum along sparse segments of a tensor, but it is allowed to miss id in segment_ids.
1179
1148
 
1180
1149
  Inputs:
1181
- - **x** (Tensor) - A Tensor.
1182
- - **indices** (Tensor) - Indices is a 1-D tensor. Must be one of the following types: int32, int64.
1183
- Has same rank as segment_ids. The shape should be :math:`(N,)`.
1184
- - **segment_ids** (Tensor) - Segment_ids is a 1-D tensor. Must be one of the following types: int32, int64.
1185
- Values should be sorted and can be repeated. The shape should be :math:`(N,)`.
1186
- - **num_segments** (Tensor) - Num_segments should equal the number of distinct segment_ids.
1150
+ - **x** (Tensor) - A Tensor of the first input of SparseSegmentSumWithNumSegments.
1151
+ - **indices** (Tensor) - 1-D Tensor with indices into `x`. Must be one of the following types: int32, int64.
1152
+ Has same rank as `segment_ids`. The shape should be :math:`(N,)`.
1153
+ - **segment_ids** (Tensor) - 1-D Tensor with indices into the output `y`. Must be one of the following types:
1154
+ int32, int64. Values should be sorted and can be repeated. The shape should be :math:`(N,)`.
1155
+ - **num_segments** (Tensor) - Num_segments indicates the size of the output.
1156
+ It should be bigger than the largest id of `segment_ids`.
1187
1157
 
1188
1158
  Outputs:
1189
1159
  A Tensor. Has the same type as `x` .
@@ -1199,10 +1169,10 @@ class SparseSegmentSumWithNumSegments(Primitive):
1199
1169
  ValueError: If shape[0] of `indices` is not corresponding to shape[0] of `segment_ids`.
1200
1170
  ValueError: If `segment_ids` is not sorted.
1201
1171
  ValueError: If the last number of `segment_ids` is bigger than or equal to `num_segments`.
1202
- ValueError: If `indices` is out of range of x's first shape.
1172
+ ValueError: If `indices` is out of range of x's first dimension.
1203
1173
 
1204
1174
  Supported Platforms:
1205
- ``GPU``
1175
+ ``Ascend`` ``GPU`` ``CPU``
1206
1176
 
1207
1177
  Examples:
1208
1178
  >>> x = Tensor([[0, 1, 0, 0], [0, 1, 1, 0], [1, 0, 1, 0]], dtype=ms.float16)
@@ -1221,14 +1191,13 @@ class SparseSegmentSumWithNumSegments(Primitive):
1221
1191
  sig.make_sig('x', dtype=sig.sig_dtype.T1),
1222
1192
  sig.make_sig('indices', dtype=sig.sig_dtype.T),
1223
1193
  sig.make_sig('segment_ids', dtype=sig.sig_dtype.T),
1224
- sig.make_sig('num_segemnts', dtype=sig.sig_dtype.T)
1194
+ sig.make_sig('num_segments', dtype=sig.sig_dtype.T)
1225
1195
  )
1226
1196
 
1227
1197
  @prim_attr_register
1228
1198
  def __init__(self):
1229
1199
  """Initialize SparseSegmentSumWithNumSegments"""
1230
1200
  self.init_prim_io_names(inputs=['x', 'indices', 'segment_ids', 'num_segments'], outputs=['y'])
1231
- self.add_prim_attr("cust_aicpu", self.name)
1232
1201
 
1233
1202
 
1234
1203
  class SparseSegmentSqrtN(Primitive):
@@ -1382,7 +1351,7 @@ class SparseMatrixNNZ(Primitive):
1382
1351
  ValueError: If shape[0] of `x_dense_shape` is not 2 or 3.
1383
1352
 
1384
1353
  Supported Platforms:
1385
- ``Ascend`` ``CPU``
1354
+ ``Ascend`` ``GPU`` ``CPU``
1386
1355
 
1387
1356
  Examples:
1388
1357
  >>> dense_shape = Tensor([2,3], dtype=mstype.int32)
@@ -1403,6 +1372,65 @@ class SparseMatrixNNZ(Primitive):
1403
1372
  inputs=['x_dense_shape', 'x_batch_pointers', 'x_row_pointers', 'x_col_indices', 'x_values'], outputs=['y'])
1404
1373
 
1405
1374
 
1375
+ class SparseFillEmptyRows(Primitive):
1376
+ r"""
1377
+ Fill the blank lines in the input 2D SparseTensor with default values.
1378
+
1379
+ Inputs:
1380
+ - **indices** (Tensor) - A 2-D Tensor, represents the position of the element in the sparse tensor.
1381
+ Support int64, each element value should be a non-negative int number. The shape is :math:`(n, 2)`.
1382
+ - **values** (Tensor) - A 1-D Tensor, represents the value corresponding to the position in the `indices`.
1383
+ The shape should be :math:`(n,)`.
1384
+ - **dense_shape** (Tensor) - A 1-D Tensor with only two elements, represents the shape of SparseTensor.
1385
+ Support int64.
1386
+ - **default_value** (Tensor) - A 0-D Tensor of the same type as `values`, scalar value to
1387
+ fill the blank lines in the input 2D SparseTensor.
1388
+
1389
+ Outputs:
1390
+ - **output_indices** (Tensor) - A 2-D Tensor, represents the position of the element in the sparse tensor
1391
+ after being filled. Support int64, each element value should be a non-negative int number.
1392
+ The shape is :math:`(m, 2)`, because of being filled, m>=n.
1393
+ - **output_values** (Tensor) - A 1-D Tensor. It represents the value corresponding to the position
1394
+ in the `output_indices`, the shape of which should be :math:`(m,)`, because of being filled, m>=n.
1395
+ - **empty_row_indicator** (Tensor) - A 1-D Tensor. It indicates whether each row is empty.
1396
+ Support bool. The shape is :math:`(dense\_shape[0],)`.
1397
+ - **reverse_index_map** (Tensor) - A 1-D Tensor. It is the index that means the value here is original
1398
+ rather than filled. Support bool. The shape is :math:`(n, 2)`.
1399
+
1400
+ Raises:
1401
+ TypeError: If the dtype of `indices` is not int64.
1402
+ TypeError: If the dtype of `dense_shape` is not int64.
1403
+ TypeError: If the dtype of `values` and the dtype of `default_value` are not same.
1404
+ ValueError: If `sparse_shape`, shape of `indices` and shape of `values` don't meet the parameter description.
1405
+
1406
+ Supported Platforms:
1407
+ ``Ascend`` ``GPU`` ``CPU``
1408
+
1409
+ Examples:
1410
+ >>> indices = Tensor([[1, 0]], dtype=mstype.int64)
1411
+ >>> values = Tensor([4], dtype=mstype.float32)
1412
+ >>> dense_shape = Tensor([2, 3], dtype=mstype.int64)
1413
+ >>> default_value = Tensor(5, dtype=mstype.float32)
1414
+ >>> sparsefillemptyrows = ops.SparseFillEmptyRows()
1415
+ >>> out = sparsefillemptyrows(indices, values, dense_shape, default_value)
1416
+ >>> print(out[0])
1417
+ Tensor(shape=[2, 2], dtype=Int64, value=
1418
+ [[0, 0],
1419
+ [1, 0]])
1420
+ >>> print(out[1])
1421
+ Tensor(shape=[2], dtype=Float32, value= [ 5.00000000e+00, 4.00000000e+00])
1422
+ >>> print(out[2])
1423
+ Tensor(shape=[2], dtype=Bool, value= [ True, False])
1424
+ >>> print(out[3])
1425
+ Tensor(shape=[1], dtype=Int64, value= [1])
1426
+ """
1427
+ @prim_attr_register
1428
+ def __init__(self):
1429
+ """Initialize SparseFillEmptyRows."""
1430
+ self.init_prim_io_names(inputs=['indices', 'values', 'dense_shape', 'default_value'],
1431
+ outputs=['output_indices', 'output_values', 'empty_row_indicator', 'reverse_index_map'])
1432
+
1433
+
1406
1434
  class SparseSegmentMeanWithNumSegments(Primitive):
1407
1435
  """
1408
1436
  Compute the mean along sparse segments of a tensor. It is allowed to have missing id in segment_ids.
@@ -1437,9 +1465,12 @@ class SparseSegmentMeanWithNumSegments(Primitive):
1437
1465
  ValueError: If `indices` is out of range of x's first dimension.
1438
1466
 
1439
1467
  Supported Platforms:
1440
- ``Ascend`` ``CPU``
1468
+ ``GPU`` ``CPU``
1441
1469
 
1442
1470
  Examples:
1471
+ >>> from mindspore import Tensor
1472
+ >>> import mindspore as ms
1473
+ >>> import mindspore.ops.operations.sparse_ops as ops
1443
1474
  >>> x = Tensor([[0, 2, 0, 0], [0, 1, 1, 0], [2, 0, 2, 0]], dtype=ms.float16)
1444
1475
  >>> indices = Tensor([0, 2, 1], dtype=ms.int32)
1445
1476
  >>> segment_ids = Tensor([0, 0, 2], dtype=ms.int32)
@@ -1470,8 +1501,9 @@ class SparseAdd(Primitive):
1470
1501
  - **x2_indices** (Tensor) - represents the second COOTensor's indices.
1471
1502
  - **x2_values** (Tensor) - represents the second COOTensor's values.
1472
1503
  - **x2_shape** (Tensor) - represents the second COOTensor's dense shape.
1473
- - **thresh** (Tensor) - represents the magnitude threshold that determines if an output
1474
- value/index pair take space.
1504
+ - **thresh** (Tensor) - A 0-D Tensor, represents the magnitude threshold that determines if an output
1505
+ value/index pair take space. Its dtype should match that of the values if they are real.
1506
+ If output's value is less than the `thresh`, it will vanish.
1475
1507
 
1476
1508
  Outputs:
1477
1509
  - **sum_indices** (Tensor) - this is the indices of the sum.
@@ -1497,7 +1529,7 @@ class SparseAdd(Primitive):
1497
1529
  TypeError: If (x1_values/x2_values)'s type is not matched with thresh's type.
1498
1530
 
1499
1531
  Supported Platforms:
1500
- ``CPU`` ``GPU``
1532
+ ``GPU`` ``CPU``
1501
1533
 
1502
1534
  Examples:
1503
1535
  >>> from mindspore import Tensor
@@ -1517,6 +1549,7 @@ class SparseAdd(Primitive):
1517
1549
  Tensor(shape=[4], dtype=Int32, value=[3, 1, 4, 2]),
1518
1550
  Tensor(shape=[2], dtype=Int64, value=[3, 4]))
1519
1551
  """
1552
+
1520
1553
  @prim_attr_register
1521
1554
  def __init__(self):
1522
1555
  self.init_prim_io_names(
@@ -1530,7 +1563,7 @@ class SparseMatrixSoftmax(Primitive):
1530
1563
  Calculates the softmax of a CSRTensorMatrix.
1531
1564
 
1532
1565
  .. warning::
1533
- This is an experimental prototype that is subject to change and/or deletion.
1566
+ This is an experimental API that is subject to change or deletion.
1534
1567
 
1535
1568
  Args:
1536
1569
  dtype (dtype.Number) - The valid data type. Only constant value is allowed.
@@ -1725,6 +1758,7 @@ class SparseMatrixTranspose(Primitive):
1725
1758
  >>> print(output[4])
1726
1759
  [99.]
1727
1760
  """
1761
+
1728
1762
  @prim_attr_register
1729
1763
  def __init__(self, conjugate=False):
1730
1764
  """Initialize SparseMatrixTranspose"""
@@ -1776,7 +1810,7 @@ class SparseSparseMinimum(Primitive):
1776
1810
  ValueError: If shape[0] of `x1_shape` is not corresponding to shape[0] of `x2_shape`.
1777
1811
 
1778
1812
  Supported Platforms:
1779
- ``Ascend`` ``CPU``
1813
+ ``GPU`` ``CPU``
1780
1814
 
1781
1815
  Examples:
1782
1816
  >>> from mindspore.ops.operations.sparse_ops import SparseSparseMinimum
@@ -1998,7 +2032,7 @@ class SparseMatrixMatMul(Primitive):
1998
2032
  r"""
1999
2033
  Performs a matrix multiplication of a sparse matrix x1 with dense matrix x2; return a dense matrix x1*x2.
2000
2034
  Each matrix may be transposed or adjointed (conjugated and transposed)
2001
- according to the Boolean parameters transpose_x1,adjoint_x1,transpose_x2 and adjoint_x2.
2035
+ according to the Boolean parameters transpose_x1, adjoint_x1, transpose_x2 and adjoint_x2.
2002
2036
  At most one of transpose_x1 or adjoint_x1 may be True.
2003
2037
  Similarly, at most one of transpose_x2 or adjoint_x2 may be True.
2004
2038
 
@@ -2025,35 +2059,34 @@ class SparseMatrixMatMul(Primitive):
2025
2059
  nonzero values of the first `i - 1` rows in the corresponding batch.
2026
2060
  - **x1_col_indices** (Tensor) - A 1-D Tensor. It represents column indices of the nonzero values
2027
2061
  in the input CSR sparse matrix x1.
2028
- - **x1_values** (Tensor) - A 1-D Tensor. It represents all the nonzero values in the
2029
- input CSR sparse matrix x1.
2030
-
2062
+ - **x1_values** (Tensor) - A 1-D Tensor. It represents all the nonzero values
2063
+ in the input CSR sparse matrix x1. Support float32, float64, complex64, complex128.
2031
2064
  - **x2_dense** (Tensor) - A 2-D or 3-D Tensor, represents the input dense matrix x2.
2032
- Support float32, float64, complex64, complex128.
2065
+ Its dtype is the same as `x1_values`.
2033
2066
 
2034
2067
  Outputs:
2035
- **y_dense** (Tensor) - A 2-D or 3-D Tensor, represents the output dense matrix y.
2036
- Support float32, float64, complex64, complex128.
2068
+ Tensor, which represents the output dense matrix y.
2069
+ Its dtype is the same as `x1_values`.
2037
2070
 
2038
2071
  Raises:
2039
- TypeError: If any dtype of `x1_dense_shape`, `x1_batch_pointers`, `x1_row_pointers`, `x1_col_indices`,
2040
- `x1_values` or `x2_dense` doesn't meet the parameter description.
2041
- ValueError: If shape[0] of `x1_dense_shape` or the dimension of `x2_dense' is not 2 or 3.
2042
- ValueError: If shape[0]-1 of x1_batch_pointers and shape[0] of x2_dense are not the same.
2072
+ TypeError: If the dtype of `x1_dense_shape`, `x1_batch_pointers`, `x1_row_pointers` or `x1_col_indices`
2073
+ is not int32 or int64, or the dtypes of above inputs are not the same.
2074
+ TypeError: If the dtype of `x1_values`, `x2_dense` is not supported.
2075
+ ValueError: If shape[0] of `x1_dense_shape` or the dimension of `x2_dense` is not 2 or 3.
2076
+ ValueError: If shape[0]-1 of `x1_batch_pointers` and shape[0] of `x2_dense` are not the same.
2043
2077
 
2044
2078
  Supported Platforms:
2045
-
2079
+ ``CPU``
2046
2080
 
2047
2081
  Examples:
2048
- >>> from mindspore.ops.operations.sparse_ops import SparseMatrixMatMul
2049
- >>> x1_dense_shape = Tensor([4, 5], dtype=mindspore.int32)
2050
- >>> x1_batch_pointers = Tensor([0, 4], dtype=mindspore.int32)
2051
- >>> x1_row_pointers = Tensor([0, 1, 1, 3, 4], dtype=mindspore.int32)
2052
- >>> x1_col_indices = Tensor([0, 3, 4, 0], dtype=mindspore.int32)
2053
- >>> x1_values = Tensor([1.0, 5.0, -1.0, -2.0], dtype=mindspore.float32)
2082
+ >>> x1_dense_shape = Tensor([4, 5], dtype=ms.int32)
2083
+ >>> x1_batch_pointers = Tensor([0, 4], dtype=ms.int32)
2084
+ >>> x1_row_pointers = Tensor([0, 1, 1, 3, 4], dtype=ms.int32)
2085
+ >>> x1_col_indices = Tensor([0, 3, 4, 0], dtype=ms.int32)
2086
+ >>> x1_values = Tensor([1.0, 5.0, -1.0, -2.0], dtype=ms.float32)
2054
2087
  >>> x2_dense = Tensor([[2.0, 0.8, 1.0],[ 2.9, 3.2, 0.0],[7.0, 4.6, 0.2],[3.5, 4.9, 1.4],[4.0, 3.7, 6.9]],
2055
- ... dtype=mindspore.float32)
2056
- >>> sparse_matrix_mat_mul = SparseMatrixMatMul()
2088
+ ... dtype=ms.float32)
2089
+ >>> sparse_matrix_mat_mul = ops.SparseMatrixMatMul()
2057
2090
  >>> out = sparse_matrix_mat_mul(x1_dense_shape, x1_batch_pointers, x1_row_pointers, x1_col_indices,
2058
2091
  ... x1_values, x2_dense)
2059
2092
  >>> print(out)
@@ -2149,6 +2182,7 @@ class SparseMatrixAdd(Primitive):
2149
2182
  Tensor(shape=[2], dtype=Int32, values = [0, 1]),
2150
2183
  Tensor(shape=[2], dtype=Float32, values = [2.0, 4.0]))
2151
2184
  """
2185
+
2152
2186
  @prim_attr_register
2153
2187
  def __init__(self):
2154
2188
  '''Initialize for SparseMatrixAdd'''
@@ -2194,6 +2228,7 @@ class SparseSplit(Primitive):
2194
2228
  Supported Platforms:
2195
2229
 
2196
2230
  """
2231
+
2197
2232
  @prim_attr_register
2198
2233
  def __init__(self, num_split=1):
2199
2234
  """Initialize SparseSplit."""
@@ -2307,7 +2342,7 @@ class SparseReshape(Primitive):
2307
2342
  RuntimeError: If inferred-dim(-1) in `new_shape` cannot be correctly inferred.
2308
2343
 
2309
2344
  Supported Platforms:
2310
- ``Ascend`` ``CPU``
2345
+ ``Ascend`` ``GPU`` ``CPU``
2311
2346
 
2312
2347
  Examples:
2313
2348
  >>> indices = Tensor([[0, 0, 0],
@@ -2329,6 +2364,7 @@ class SparseReshape(Primitive):
2329
2364
  >>> print(y_shape)
2330
2365
  [9 4]
2331
2366
  """
2367
+
2332
2368
  @prim_attr_register
2333
2369
  def __init__(self):
2334
2370
  """Initialize SparseReshape."""
@@ -2371,8 +2407,8 @@ class SparseCountSparseOutput(Primitive):
2371
2407
  ValueError: If number of values does not match first dimension of indices
2372
2408
  ValueError: If number of dense_shape dimensions does not match second dimension of indices
2373
2409
  ValueError: If num dim of dense_shape is < 1
2374
- RunTimeError: If number of weights is not equal to number of values
2375
- RunTimeError: If indexes are not in bounds of the dense shape
2410
+ RuntimeError: If number of weights is not equal to number of values
2411
+ RuntimeError: If indexes are not in bounds of the dense shape
2376
2412
 
2377
2413
  Examples:
2378
2414
  >>> from mindspore.ops.operations.sparse_ops import SparseCountSparseOutput
@@ -2393,6 +2429,7 @@ class SparseCountSparseOutput(Primitive):
2393
2429
  ``CPU``
2394
2430
 
2395
2431
  """
2432
+
2396
2433
  @prim_attr_register
2397
2434
  def __init__(self, binary_output=False, minlength=-1, maxlength=-1):
2398
2435
  self.init_prim_io_names(
@@ -2401,3 +2438,311 @@ class SparseCountSparseOutput(Primitive):
2401
2438
  validator.check_value_type("binary_output", binary_output, [bool], self.name)
2402
2439
  validator.check_value_type("minlength", minlength, [int], self.name)
2403
2440
  validator.check_value_type("maxlength", maxlength, [int], self.name)
2441
+
2442
+
2443
+ class DenseToSparseSetOperation(Primitive):
2444
+ """
2445
+ Applies set operation along last dimension of `x1` and `x2`.
2446
+ Input `x2` is a SparseTensor represented by `x2_indices`, `x2_values`, and `x2_shape`.
2447
+ For `x2` ranked `n`, 1st `n-1` dimensions must be the same as `x1`. Dimension `n` contains values in a set,
2448
+ duplicates are allowed but ignored.
2449
+
2450
+ Args:
2451
+ set_operation (str): The type of set operation, supports four kinds of inputs, case insensitive. Default: "".
2452
+ "a-b": Get the difference set of x1 to x2.
2453
+ "b-a": Get the difference set of x2 to x1.
2454
+ "intersection": Get the intersection set of x2 to x1.
2455
+ "union": Get the union set of x2 to x1.
2456
+ validate_indices (bool): Optional attributes for DenseToSparseSetOperation. Default: True.
2457
+
2458
+ Inputs:
2459
+ - **x1** (Tensor) - The input tensor `x1` with rank `n`. 1st `n-1` dimensions must be the same as `x2`.
2460
+ Dimension `n` contains values in a set, duplicates are allowed but ignored. Must be one of the
2461
+ following types: int8, int16, int32, int64, uint8, uint16.
2462
+ - **x2_indices** (Tensor) - A 2-D Tensor, type int64, indices of a SparseTensor.
2463
+ - **x2_values** (Tensor) - A 1-D Tensor, must have the same type as x1, values of a SparseTensor. Size
2464
+ must be the same as `x2_indices`
2465
+ - **x2_shape** (Tensor) - A 1-D Tensor, type int64, shape of a SparseTensor, must have the same size as
2466
+ the second dimensions of `x2_indices`
2467
+
2468
+ Outputs:
2469
+ y_indices: A Tensor of type int64.
2470
+ y_values: A Tensor. Has the same type as x1.
2471
+ y_shape: A Tensor of type int64 .
2472
+
2473
+ Raises:
2474
+ TypeError: If any input is not Tensor.
2475
+ TypeError:If the dtype of `x2_values` is not the same as 'x1'.
2476
+ TypeError:If the dtype of `x2_indices` or `x2_shape` is not int64.
2477
+ ValueError: If the group shape of `x1` or `x2` mismatch with each other.
2478
+ ValueError: If the rank of `x1` is less than 2.
2479
+ ValueError: If the rank of `x2_indices` is not equal 2.
2480
+
2481
+ Supported Platforms:
2482
+ ``Ascend`` ``CPU``
2483
+
2484
+ Examples:
2485
+ >>> from mindspore.ops.operations.sparse_ops import DenseToSparseSetOperation
2486
+ >>> x1 = Tensor([[1, 2], [3, 0], [1, 5]], dtype=ms.int64)
2487
+ >>> x2_indices = Tensor([[0, 1], [0, 2], [1, 2]], dtype=ms.int64)
2488
+ >>> x2_values = Tensor([5, 1, 7],dtype=ms.int64)
2489
+ >>> x2_shape = Tensor([3, 3], dtype=ms.int64)
2490
+ >>> dense_to_sparse_set_operation = DenseToSparseSetOperation(set_operation='intersection')
2491
+ >>> out = dense_to_sparse_set_operation(x1, x2_indices, x2_values, x2_shape)
2492
+ >>> print(out)
2493
+ (Tensor(shape=[1, 2], dtype=Int64, value=
2494
+ [[0, 0]]), Tensor(shape=[1], dtype=Int64, value= [1]), Tensor(shape=[2], dtype=Int64, value= [3, 1]))
2495
+ """
2496
+
2497
+ @prim_attr_register
2498
+ def __init__(self, set_operation="", validate_indices=True):
2499
+ """Initialize DenseToSparseSetOperation."""
2500
+ self.init_prim_io_names(inputs=['x1', 'x2_indices', 'x2_values', 'x2_shape'],
2501
+ outputs=['y_indices', 'y_values', 'y_shape'])
2502
+ self.set_operation = set_operation
2503
+ self.validate_indices = validate_indices
2504
+ self.add_prim_attr('set_operation', self.set_operation)
2505
+ self.add_prim_attr('validate_indices', self.validate_indices)
2506
+
2507
+ validator.check_value_type("set_operation", set_operation, [str], self.name)
2508
+ validator.check_value_type("validate_indices", validate_indices, [bool], self.name)
2509
+
2510
+
2511
+ class RaggedTensorToTensor(Primitive):
2512
+ r"""
2513
+ Create a dense tensor from a ragged tensor, possibly altering its shape.
2514
+
2515
+ Args:
2516
+ row_partition_types(list(str)): A list of `strings`. The types of the row partition tensors.
2517
+ At present, these can be:
2518
+ "ROW_SPLITS": the row_splits tensor from the ragged tensor.
2519
+ "VALUE_ROWIDS": the value_rowids tensor from the ragged tensor.
2520
+ "FIRST_DIM_SIZE": if value_rowids is used for the first dimension, then it is preceded by "FIRST_DIM_SIZE".
2521
+
2522
+ Inputs:
2523
+ - **shape** (Tensor) - A 1-D `Tensor`. Must be one of the following types: `int64`, `int32`.
2524
+ The desired shape of the output tensor.
2525
+ - **values** (Tensor) - A 1-D or higher `Tensor` representing the values of the ragged tensor.
2526
+ - **default_value** (Tensor) - A `Tensor` representing the default value of the ragged tensor.
2527
+ Must have the same type as `values` and less dimension than `values`.
2528
+ - **row_partition_tensors** (list(Tensor)) - A list of at least 1 `Tensor` objects with the same
2529
+ type in: `int64`, `int32`. The row partition tensor is 0-D, 1-D, 1-D, when the row partition type is
2530
+ "FIRST_DIM_SIZE", "VALUE_ROWIDS", "ROW_SPLITS" respectively.
2531
+
2532
+ Outputs:
2533
+ A `Tensor`. Has the same type as `values` and the shape is `shape`.
2534
+
2535
+ Raises:
2536
+ TypeError: If the type of `shape`, `values` or `default_value` is not Tensor.
2537
+ ValueError: If the dimension of `shape` or `values` is not 1.
2538
+ ValueError: If the dimension of `default_value` is more than `values`.
2539
+ ValueError: If the order or value of `row_partition_types` is not support.
2540
+ RuntimeError: If the value of `row_partition_tensors` is not in ascending order
2541
+ when the `row_partition_types` is "ROW_SPLITS".
2542
+ RuntimeError: If value rowid is not less than first dim size
2543
+ when the `row_partition_types` is "FIRST_DIM_SIZE", "VALUE_ROWIDS".
2544
+ ValueError: If row partition size plus `values` rank is not equal to `shape` rank.
2545
+
2546
+ Supported Platforms:
2547
+ ``CPU``
2548
+
2549
+ Examples:
2550
+ >>> from mindspore.ops.operations.sparse_ops import RaggedTensorToTensor
2551
+ >>> shape = Tensor([4, 4], mstype.int32)
2552
+ >>> values = Tensor([1, 2, 3, 4, 5, 6, 7, 8, 9], mstype.int64)
2553
+ >>> default_value = Tensor(0, dtype=mstype.int64)
2554
+ >>> row_partition_tensors_list = []
2555
+ >>> row_partition_tensors = Tensor([0, 3, 3, 7, 9], mstype.int32)
2556
+ >>> row_partition_tensors_list.append(row_partition_tensors)
2557
+ >>> row_partition_types = ["ROW_SPLITS"]
2558
+ >>> ragged_tensor_to_tensor = RaggedTensorToTensor(row_partition_types)
2559
+ >>> out = ragged_tensor_to_tensor(shape, values, default_value, row_partition_tensors_list)
2560
+ >>> print(out)
2561
+ [[1 2 3 0]
2562
+ [0 0 0 0]
2563
+ [4 5 6 7]
2564
+ [8 9 0 0]]
2565
+ """
2566
+
2567
+ @prim_attr_register
2568
+ def __init__(self, row_partition_types):
2569
+ """Initialize RaggedTensorToTensor"""
2570
+ self.init_prim_io_names(inputs=['shape', 'values', 'default_value', 'row_partition_tensors'],
2571
+ outputs=['result'])
2572
+ validator.check_value_type("row_partition_types", row_partition_types, [list], self.name)
2573
+
2574
+ if not row_partition_types:
2575
+ raise ValueError(f"For {self.name}, row_partition_types cannot be empty.")
2576
+
2577
+ for i, item in enumerate(row_partition_types):
2578
+ validator.check_value_type(f"row_partition_types[{i}]", item, [str], self.name)
2579
+
2580
+ valid_values = ("ROW_SPLITS", "FIRST_DIM_SIZE", "VALUE_ROWIDS")
2581
+ if not set(row_partition_types).issubset(valid_values):
2582
+ diff = tuple(set(row_partition_types).difference(valid_values))
2583
+ raise ValueError(
2584
+ f"For {self.name}, row_partition_types only support {valid_values}, "
2585
+ f"but got {diff if len(diff) > 1 else repr(diff[0])}.")
2586
+
2587
+ first_element = valid_values[:2]
2588
+ if row_partition_types[0] not in first_element:
2589
+ raise ValueError(
2590
+ f"For {self.name}, the first element of row_partition_types must be in {first_element}, "
2591
+ f"but got '{row_partition_types[0]}'.")
2592
+
2593
+ if row_partition_types[0] == "FIRST_DIM_SIZE":
2594
+ if set(row_partition_types[1:]) != {"VALUE_ROWIDS"}:
2595
+ raise ValueError(
2596
+ f"For {self.name}, 'VALUE_ROWIDS' must be preceded by 'FIRST_DIM_SIZE' in row_partition_types.")
2597
+ else:
2598
+ if set(row_partition_types) != {"ROW_SPLITS"}:
2599
+ raise ValueError(
2600
+ f"For {self.name}, the each element of row_partition_types must be 'ROW_SPLITS' "
2601
+ f"when row_splits tensor.")
2602
+
2603
+
2604
+ class SparseCross(Primitive):
2605
+ """
2606
+ Generates sparse cross from a list of sparse and dense tensors.
2607
+
2608
+ Args:
2609
+ hashed_output (bool): If true, returns the hash of the cross instead of the string. This will allow us
2610
+ avoiding string manipulations.
2611
+ num_buckets (int): An int that is >= 0. It is used if "hashed_output" is true.output = hashed_value%num_buckets
2612
+ if num_buckets > 0 else "hashed_value".
2613
+ hash_key (int): Specify the hash_key that will be used by the "FingerprintCat64" function to combine the
2614
+ crosses fingerprints.
2615
+ out_type (mindspore.dtype): The output data type. Defaults to "int64".
2616
+ internal_type (mindspore.dtype): An type int64.
2617
+
2618
+ Inputs:
2619
+ - **indices** (list(Tensor)) - A list of Tensor objects with type int64. 2-D.
2620
+ Indices of each input SparseTensor.
2621
+ - **values** (list(Tensor)) - A list of Tensor objects with types from: int64.
2622
+ 1-D. values of each SparseTensor.
2623
+ - **shapes** (list(Tensor)) - A list with the same length as indices of Tensor objects with type int64.
2624
+ 1-D. Shapes of each SparseTensor.
2625
+ - **dense_inputs** (list(Tensor)) - A list of Tensor objects with types from: int64.
2626
+ 2-D. Columns represented by dense Tensor.
2627
+
2628
+ Outputs:
2629
+ - **output_indices** (Tensor) - A Tensor of type int64. 2-D. Indices of the concatenated SparseTensor.
2630
+ - **output_values** (Tensor) - A Tensor of type "out_type". 1-D.
2631
+ Non-empty values of the concatenated or hashed SparseTensor.
2632
+ - **output_shape** (Tensor) - A Tensor of type int64. 1-D. Shape of the concatenated SparseTensor.
2633
+
2634
+ Raises:
2635
+ TypeError: The indices shape rank is not equal to the shape rank.
2636
+ TypeError: The indices element number is not equal to the value element number.
2637
+ TypeError: The indices shape rank should be 2.
2638
+ TypeError: The denses shape rank should be 2.
2639
+ TypeError: The shapes rank should be 2.
2640
+
2641
+ Supported Platforms:
2642
+ ``CPU``
2643
+
2644
+ Examples:
2645
+ >>> from mindspore.ops.operations.sparse_ops import SparseCross
2646
+ >>> indice1 = Tensor([[0,0],[1,0],[1,1]], dtype=mstype.int64)
2647
+ >>> value1 = Tensor([1, 2, 3], dtype=mstype.int64)
2648
+ >>> shape1 = Tensor([2, 2], dtype=mstype.int64)
2649
+ >>> dense1 = Tensor([[1],[2]], dtype=mstype.int64)
2650
+ >>> indice2 = Tensor([[0,0],[1,0],[1,1]], dtype=mstype.int64)
2651
+ >>> value2 = Tensor([1, 2, 3], dtype=mstype.int64)
2652
+ >>> shape2 = Tensor([2, 2], dtype=mstype.int64)
2653
+ >>> dense2 = Tensor([[1],[2]], dtype=mstype.int64)
2654
+ >>> indices = [indice1, indice2]
2655
+ >>> values = [value1, value2]
2656
+ >>> shapes = [shape1, shape2]
2657
+ >>> dense_inputs = [dense1, dense2]
2658
+ >>> hashed_output=True
2659
+ >>> hash_key= 2
2660
+ >>> out_type= mstype.int64
2661
+ >>> internal_type = mstype.int64
2662
+ >>> num_buckets=0
2663
+ >>> sparse_cross = SparseCross(hashed_output, hash_key, out_type, internal_type, num_buckets)
2664
+ >>> out = sparse_cross(indices, values, shapes, dense_inputs)
2665
+ >>> print(out)
2666
+ (Tensor(shape=[5, 2], dtype=Int64, value=
2667
+ [[0, 0],
2668
+ [1, 0],
2669
+ [1, 1],
2670
+ [1, 2],
2671
+ [1, 3]]), Tensor(shape=[5], dtype=Int64, value= [1350190460805457680, 6319552725219729347,
2672
+ 4652439303631496997, 7670687697825594049, 174086171018132662]), Tensor(shape=[2], dtype=Int64, value= [2, 4]))
2673
+ """
2674
+
2675
+ @prim_attr_register
2676
+ def __init__(self, hashed_output, hash_key, out_type, internal_type, num_buckets=0):
2677
+ """Initialize SparseCross."""
2678
+ self.init_prim_io_names(inputs=["indices", "values", "shapes", "dense_inputs"],
2679
+ outputs=["output_indices", "output_values", "output_shape"])
2680
+ validator.check_value_type("hashed_output", hashed_output, [bool], self.name)
2681
+ validator.check_value_type("hash_key", hash_key, [int], self.name)
2682
+ validator.check_value_type("out_type", out_type, [mstype.Type], self.name)
2683
+ validator.check_value_type("internal_type", internal_type, [mstype.Type], self.name)
2684
+ validator.check_value_type("num_buckets", num_buckets, [int], self.name)
2685
+
2686
+
2687
+ class RaggedTensorToSparse(Primitive):
2688
+ r"""
2689
+ Converts a RaggedTensor into a SparseTensor with the same values.
2690
+
2691
+ Args:
2692
+ Tsplits(mindspore.dtype): A required attribute, the type of the `rt_nested_splits`. Default: `int64`.
2693
+
2694
+ Inputs:
2695
+ - **rt_nested_splits** (list(Tensor)) - A list of at least 1 `Tensor` objects with the same
2696
+ type in: `int64`, `int32`. The row_splits for the RaggedTensor.
2697
+ Ragged splits is in ascending order, first value of splits must be 0 and final value of splits
2698
+ must equal with the length of `rt_dense_values`.
2699
+ - **rt_dense_values** (Tensor) - A `Tensor`. The flat_values for the RaggedTensor. The rank of values
2700
+ must more than 0.
2701
+
2702
+ Outputs:
2703
+ - **sparse_indices** (Tensor) - A `Tensor` of type int64. Contains the indices of the output
2704
+ sparse tensor.
2705
+ - **sparse_values** (Tensor) - A `Tensor`. Has the same type as rt_dense_values.
2706
+ Contains the values of the output sparse tensor.
2707
+ - **sparse_dense_shape** (Tensor) - A `Tensor` of type int64. Contains the dense shape of the
2708
+ output sparse tensor.
2709
+
2710
+ Raises:
2711
+ TypeError: If the type of `Tsplits`, `rt_nested_splits` or `rt_dense_values` is not support.
2712
+ RuntimeError: If the order of `rt_nested_splits` is not support.
2713
+ RuntimeError: If the first value of `rt_nested_splits` is not 0.
2714
+ RuntimeError: If the final value of `rt_nested_splits` is not equal with the length of
2715
+ `rt_dense_values`.
2716
+ ValueError: If the rank of `rt_dense_values` is not more than 0.
2717
+
2718
+ Supported Platforms:
2719
+
2720
+
2721
+ Examples:
2722
+ >>> from mindspore.ops.operations.sparse_ops import RaggedTensorToSparse
2723
+ >>> rt_nested_splits = Tensor([0, 3, 3, 5, 6], mstype.int64)
2724
+ >>> rt_dense_values = Tensor([1, 2, 3, 4, 5, 6], mstype.int32)
2725
+ >>> rt_nested_splits_list = []
2726
+ >>> rt_nested_splits_list.append(rt_nested_splits)
2727
+ >>> Tsplits = mstype.int64
2728
+ >>> ragged_tensor_to_sparse = RaggedTensorToSparse(Tsplits)
2729
+ >>> out = ragged_tensor_to_sparse(rt_nested_splits_list, rt_dense_values)
2730
+ >>> print(out)
2731
+ (Tensor(shape=[6, 2], dtype=Int64, value=
2732
+ [[0, 0],
2733
+ [0, 1],
2734
+ [0, 2],
2735
+ [2, 0],
2736
+ [2, 1],
2737
+ [3, 0]]),
2738
+ Tensor(shape=[6], dtype=Int32, value= [1, 2, 3, 4, 5, 6]),
2739
+ Tensor(shape=[2], dtype=Int64, value= [4, 3]))
2740
+ """
2741
+ @prim_attr_register
2742
+ def __init__(self, Tsplits):
2743
+ """Initialize RaggedTensorToSparse."""
2744
+ self.init_prim_io_names(inputs=['rt_nested_splits', 'rt_dense_values'],
2745
+ outputs=['sparse_indices', 'sparse_values', 'sparse_dense_shape'])
2746
+ validator.check_value_type("Tsplits", Tsplits, [mstype.Type], self.name)
2747
+ valid_values = {mstype.int64, mstype.int32}
2748
+ validator.check_type_name("Tsplits", Tsplits, valid_values, self.name)