mindspore 2.4.10__cp39-cp39-win_amd64.whl → 2.6.0__cp39-cp39-win_amd64.whl

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

Potentially problematic release.


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

Files changed (579) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/__init__.py +13 -6
  3. mindspore/_c_dataengine.cp39-win_amd64.pyd +0 -0
  4. mindspore/_c_expression.cp39-win_amd64.pyd +0 -0
  5. mindspore/_c_mindrecord.cp39-win_amd64.pyd +0 -0
  6. mindspore/_check_jit_forbidden_api.py +3 -0
  7. mindspore/_checkparam.py +3 -38
  8. mindspore/_deprecated/__init__.py +17 -0
  9. mindspore/_deprecated/jit.py +198 -0
  10. mindspore/_extends/builtin_operations.py +1 -1
  11. mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
  12. mindspore/_extends/parse/__init__.py +6 -7
  13. mindspore/_extends/parse/compile_config.py +83 -0
  14. mindspore/_extends/parse/deprecated/__init__.py +0 -0
  15. mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +394 -0
  16. mindspore/_extends/parse/jit_fallback_modules/__init__.py +0 -0
  17. mindspore/_extends/parse/jit_fallback_modules/check_utils.py +123 -0
  18. mindspore/_extends/parse/jit_fallback_modules/third_party_modules.py +50 -0
  19. mindspore/_extends/parse/parser.py +47 -198
  20. mindspore/_extends/parse/resources.py +1 -5
  21. mindspore/_extends/parse/standard_method.py +229 -99
  22. mindspore/_extends/pijit/__init__.py +2 -2
  23. mindspore/_extends/pijit/pijit_func_white_list.py +17 -12
  24. mindspore/_extends/pijit/tensor_func_list.py +27 -0
  25. mindspore/_extends/utils.py +1 -1
  26. mindspore/amp.py +11 -5
  27. mindspore/avcodec-59.dll +0 -0
  28. mindspore/avdevice-59.dll +0 -0
  29. mindspore/avfilter-8.dll +0 -0
  30. mindspore/avformat-59.dll +0 -0
  31. mindspore/avutil-57.dll +0 -0
  32. mindspore/boost/__init__.py +2 -2
  33. mindspore/boost/base.py +3 -7
  34. mindspore/boost/boost_cell_wrapper.py +138 -43
  35. mindspore/common/__init__.py +6 -3
  36. mindspore/common/_grad_function.py +56 -0
  37. mindspore/common/_pijit_context.py +14 -5
  38. mindspore/common/_register_for_tensor.py +1 -2
  39. mindspore/common/_stub_tensor.py +30 -14
  40. mindspore/common/_tensor_cpp_method.py +17 -0
  41. mindspore/common/_tensor_docs.py +4760 -0
  42. mindspore/common/api.py +480 -372
  43. mindspore/common/auto_dynamic_shape.py +41 -44
  44. mindspore/common/dtype.py +39 -36
  45. mindspore/common/dump.py +9 -6
  46. mindspore/common/file_system.py +9 -1
  47. mindspore/common/generator.py +5 -0
  48. mindspore/common/hook_handle.py +6 -2
  49. mindspore/common/initializer.py +13 -10
  50. mindspore/common/jit_begin_end.py +94 -0
  51. mindspore/common/jit_config.py +6 -1
  52. mindspore/common/jit_context.py +76 -0
  53. mindspore/common/jit_trace.py +378 -0
  54. mindspore/common/lazy_inline.py +9 -3
  55. mindspore/common/mindir_util.py +10 -2
  56. mindspore/common/mutable.py +5 -4
  57. mindspore/common/parameter.py +135 -52
  58. mindspore/common/seed.py +2 -2
  59. mindspore/common/sparse_tensor.py +23 -17
  60. mindspore/common/tensor.py +975 -1981
  61. mindspore/communication/__init__.py +7 -5
  62. mindspore/communication/_comm_helper.py +52 -2
  63. mindspore/communication/comm_func.py +240 -181
  64. mindspore/communication/management.py +95 -26
  65. mindspore/context.py +324 -573
  66. mindspore/dataset/__init__.py +65 -37
  67. mindspore/dataset/audio/__init__.py +2 -8
  68. mindspore/dataset/audio/transforms.py +3 -17
  69. mindspore/dataset/callback/ds_callback.py +2 -1
  70. mindspore/dataset/core/config.py +87 -6
  71. mindspore/dataset/engine/cache_admin.py +3 -3
  72. mindspore/dataset/engine/cache_client.py +6 -5
  73. mindspore/dataset/engine/datasets.py +292 -267
  74. mindspore/dataset/engine/datasets_audio.py +22 -8
  75. mindspore/dataset/engine/datasets_standard_format.py +46 -27
  76. mindspore/dataset/engine/datasets_text.py +78 -48
  77. mindspore/dataset/engine/datasets_user_defined.py +183 -117
  78. mindspore/dataset/engine/datasets_vision.py +120 -44
  79. mindspore/dataset/engine/iterators.py +283 -63
  80. mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +1 -1
  81. mindspore/dataset/engine/obs/util.py +8 -0
  82. mindspore/dataset/engine/queue.py +40 -0
  83. mindspore/dataset/engine/samplers.py +289 -43
  84. mindspore/dataset/engine/serializer_deserializer.py +3 -2
  85. mindspore/dataset/engine/validators.py +53 -11
  86. mindspore/dataset/text/__init__.py +7 -6
  87. mindspore/dataset/text/transforms.py +6 -5
  88. mindspore/dataset/text/utils.py +3 -3
  89. mindspore/dataset/transforms/__init__.py +0 -9
  90. mindspore/dataset/transforms/py_transforms_util.py +17 -0
  91. mindspore/dataset/transforms/transforms.py +31 -14
  92. mindspore/dataset/utils/browse_dataset.py +1 -1
  93. mindspore/dataset/vision/__init__.py +2 -9
  94. mindspore/dataset/vision/transforms.py +202 -158
  95. mindspore/dataset/vision/utils.py +7 -5
  96. mindspore/dataset/vision/validators.py +1 -2
  97. mindspore/device_context/__init__.py +21 -0
  98. mindspore/device_context/ascend/__init__.py +25 -0
  99. mindspore/device_context/ascend/device.py +72 -0
  100. mindspore/device_context/ascend/op_debug.py +153 -0
  101. mindspore/device_context/ascend/op_precision.py +193 -0
  102. mindspore/device_context/ascend/op_tuning.py +123 -0
  103. mindspore/{ops_generate/gen_constants.py → device_context/cpu/__init__.py} +6 -17
  104. mindspore/device_context/cpu/device.py +62 -0
  105. mindspore/device_context/cpu/op_tuning.py +43 -0
  106. mindspore/device_context/gpu/__init__.py +21 -0
  107. mindspore/device_context/gpu/device.py +70 -0
  108. mindspore/device_context/gpu/op_precision.py +67 -0
  109. mindspore/device_context/gpu/op_tuning.py +175 -0
  110. mindspore/device_manager.py +170 -0
  111. mindspore/dnnl.dll +0 -0
  112. mindspore/experimental/es/embedding_service.py +35 -27
  113. mindspore/experimental/llm_boost/__init__.py +1 -0
  114. mindspore/experimental/llm_boost/ascend_native/__init__.py +22 -0
  115. mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +209 -0
  116. mindspore/experimental/llm_boost/ascend_native/llm_boost.py +52 -0
  117. mindspore/experimental/llm_boost/atb/boost_base.py +2 -3
  118. mindspore/experimental/llm_boost/atb/llama_boost.py +6 -1
  119. mindspore/experimental/llm_boost/register.py +1 -0
  120. mindspore/experimental/map_parameter.py +4 -4
  121. mindspore/experimental/optim/adadelta.py +6 -6
  122. mindspore/experimental/optim/adagrad.py +4 -4
  123. mindspore/experimental/optim/adam.py +7 -0
  124. mindspore/experimental/optim/adamax.py +4 -4
  125. mindspore/experimental/optim/adamw.py +4 -0
  126. mindspore/experimental/optim/asgd.py +1 -1
  127. mindspore/experimental/optim/lr_scheduler.py +73 -46
  128. mindspore/experimental/optim/radam.py +34 -31
  129. mindspore/experimental/optim/rprop.py +1 -1
  130. mindspore/experimental/optim/sgd.py +1 -1
  131. mindspore/hal/contiguous_tensors_handle.py +6 -10
  132. mindspore/hal/device.py +55 -53
  133. mindspore/hal/event.py +52 -52
  134. mindspore/hal/memory.py +179 -120
  135. mindspore/hal/stream.py +150 -109
  136. mindspore/include/api/context.h +0 -1
  137. mindspore/include/dataset/constants.h +7 -4
  138. mindspore/include/dataset/execute.h +2 -2
  139. mindspore/jpeg62.dll +0 -0
  140. mindspore/log.py +50 -0
  141. mindspore/mindrecord/__init__.py +21 -8
  142. mindspore/mindrecord/config.py +17 -316
  143. mindspore/mindrecord/filereader.py +1 -9
  144. mindspore/mindrecord/filewriter.py +5 -15
  145. mindspore/mindrecord/mindpage.py +1 -9
  146. mindspore/mindspore_backend_common.dll +0 -0
  147. mindspore/mindspore_backend_manager.dll +0 -0
  148. mindspore/mindspore_common.dll +0 -0
  149. mindspore/mindspore_core.dll +0 -0
  150. mindspore/mindspore_dump.dll +0 -0
  151. mindspore/mindspore_frontend.dll +0 -0
  152. mindspore/mindspore_glog.dll +0 -0
  153. mindspore/mindspore_memory_pool.dll +0 -0
  154. mindspore/mindspore_ms_backend.dll +0 -0
  155. mindspore/mindspore_ops.dll +0 -0
  156. mindspore/{mindspore_backend.dll → mindspore_ops_host.dll} +0 -0
  157. mindspore/mindspore_ops_kernel_common.dll +0 -0
  158. mindspore/mindspore_profiler.dll +0 -0
  159. mindspore/mindspore_pyboost.dll +0 -0
  160. mindspore/mindspore_pynative.dll +0 -0
  161. mindspore/mindspore_res_manager.dll +0 -0
  162. mindspore/mindspore_runtime_pipeline.dll +0 -0
  163. mindspore/mint/__init__.py +798 -761
  164. mindspore/mint/distributed/__init__.py +70 -4
  165. mindspore/mint/distributed/distributed.py +2679 -44
  166. mindspore/mint/linalg/__init__.py +8 -0
  167. mindspore/mint/nn/__init__.py +743 -22
  168. mindspore/mint/nn/functional.py +716 -23
  169. mindspore/mint/nn/layer/__init__.py +21 -4
  170. mindspore/mint/nn/layer/_functions.py +334 -0
  171. mindspore/mint/nn/layer/activation.py +276 -1
  172. mindspore/mint/nn/layer/basic.py +123 -0
  173. mindspore/mint/nn/layer/conv.py +933 -0
  174. mindspore/mint/nn/layer/normalization.py +223 -28
  175. mindspore/mint/nn/layer/padding.py +797 -0
  176. mindspore/mint/nn/layer/pooling.py +235 -0
  177. mindspore/mint/optim/__init__.py +3 -1
  178. mindspore/mint/optim/adam.py +223 -0
  179. mindspore/mint/optim/adamw.py +26 -19
  180. mindspore/mint/optim/sgd.py +171 -0
  181. mindspore/mint/special/__init__.py +2 -1
  182. mindspore/multiprocessing/__init__.py +5 -0
  183. mindspore/nn/__init__.py +4 -1
  184. mindspore/nn/cell.py +1373 -192
  185. mindspore/nn/dynamic_lr.py +2 -1
  186. mindspore/nn/layer/activation.py +29 -27
  187. mindspore/nn/layer/basic.py +51 -35
  188. mindspore/nn/layer/channel_shuffle.py +3 -3
  189. mindspore/nn/layer/container.py +1 -1
  190. mindspore/nn/layer/conv.py +53 -42
  191. mindspore/nn/layer/embedding.py +12 -11
  192. mindspore/nn/layer/normalization.py +56 -49
  193. mindspore/nn/layer/padding.py +4 -3
  194. mindspore/nn/layer/pooling.py +120 -42
  195. mindspore/nn/layer/rnn_cells.py +1 -1
  196. mindspore/nn/layer/rnns.py +2 -1
  197. mindspore/nn/layer/timedistributed.py +5 -5
  198. mindspore/nn/layer/transformer.py +59 -36
  199. mindspore/nn/learning_rate_schedule.py +8 -4
  200. mindspore/nn/loss/loss.py +58 -55
  201. mindspore/nn/optim/ada_grad.py +7 -5
  202. mindspore/nn/optim/adadelta.py +11 -9
  203. mindspore/nn/optim/adafactor.py +1 -1
  204. mindspore/nn/optim/adam.py +19 -15
  205. mindspore/nn/optim/adamax.py +8 -7
  206. mindspore/nn/optim/adasum.py +5 -5
  207. mindspore/nn/optim/asgd.py +3 -1
  208. mindspore/nn/optim/ftrl.py +11 -9
  209. mindspore/nn/optim/lamb.py +1 -1
  210. mindspore/nn/optim/lars.py +1 -4
  211. mindspore/nn/optim/lazyadam.py +12 -10
  212. mindspore/nn/optim/momentum.py +7 -6
  213. mindspore/nn/optim/optimizer.py +3 -3
  214. mindspore/nn/optim/proximal_ada_grad.py +12 -10
  215. mindspore/nn/optim/rmsprop.py +13 -12
  216. mindspore/nn/optim/rprop.py +11 -9
  217. mindspore/nn/optim/sgd.py +9 -6
  218. mindspore/nn/optim/tft_wrapper.py +5 -2
  219. mindspore/nn/optim/thor.py +2 -1
  220. mindspore/nn/probability/bijector/bijector.py +17 -11
  221. mindspore/nn/probability/bijector/gumbel_cdf.py +5 -5
  222. mindspore/nn/probability/bijector/invert.py +2 -2
  223. mindspore/nn/probability/bijector/scalar_affine.py +3 -3
  224. mindspore/nn/probability/bijector/softplus.py +3 -2
  225. mindspore/nn/probability/distribution/beta.py +3 -3
  226. mindspore/nn/probability/distribution/categorical.py +1 -1
  227. mindspore/nn/probability/distribution/cauchy.py +4 -2
  228. mindspore/nn/probability/distribution/exponential.py +6 -7
  229. mindspore/nn/probability/distribution/gamma.py +2 -2
  230. mindspore/nn/probability/distribution/gumbel.py +2 -2
  231. mindspore/nn/probability/distribution/half_normal.py +5 -3
  232. mindspore/nn/probability/distribution/logistic.py +5 -3
  233. mindspore/nn/probability/distribution/poisson.py +1 -1
  234. mindspore/nn/probability/distribution/uniform.py +5 -3
  235. mindspore/nn/reinforcement/_tensors_queue.py +1 -1
  236. mindspore/nn/reinforcement/tensor_array.py +1 -1
  237. mindspore/nn/utils/init.py +13 -11
  238. mindspore/nn/wrap/__init__.py +6 -6
  239. mindspore/nn/wrap/cell_wrapper.py +181 -122
  240. mindspore/nn/wrap/grad_reducer.py +45 -36
  241. mindspore/nn/wrap/loss_scale.py +6 -7
  242. mindspore/numpy/array_creations.py +63 -65
  243. mindspore/numpy/array_ops.py +149 -144
  244. mindspore/numpy/logic_ops.py +41 -42
  245. mindspore/numpy/math_ops.py +361 -359
  246. mindspore/numpy/utils.py +17 -18
  247. mindspore/numpy/utils_const.py +5 -6
  248. mindspore/opencv_core452.dll +0 -0
  249. mindspore/opencv_imgcodecs452.dll +0 -0
  250. mindspore/opencv_imgproc452.dll +0 -0
  251. mindspore/ops/__init__.py +5 -3
  252. mindspore/ops/_grad_experimental/grad_comm_ops.py +112 -16
  253. mindspore/ops/_grad_experimental/grad_debug_ops.py +14 -2
  254. mindspore/ops/_grad_experimental/grad_inner_ops.py +9 -0
  255. mindspore/ops/_grad_experimental/grad_math_ops.py +2 -1
  256. mindspore/ops/_grad_experimental/taylor_rule.py +29 -0
  257. mindspore/ops/_op_impl/cpu/__init__.py +1 -0
  258. mindspore/ops/_op_impl/cpu/raise_op.py +28 -0
  259. mindspore/ops/_register_for_op.py +0 -11
  260. mindspore/{ops_generate → ops/_utils}/arg_dtype_cast.py +123 -4
  261. mindspore/{ops_generate → ops/_utils}/arg_handler.py +3 -65
  262. mindspore/ops/_vmap/vmap_array_ops.py +52 -25
  263. mindspore/ops/_vmap/vmap_base.py +0 -2
  264. mindspore/ops/_vmap/vmap_grad_nn_ops.py +21 -14
  265. mindspore/ops/_vmap/vmap_math_ops.py +15 -16
  266. mindspore/ops/_vmap/vmap_nn_ops.py +29 -42
  267. mindspore/ops/auto_generate/__init__.py +4 -3
  268. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +258 -46
  269. mindspore/ops/auto_generate/gen_extend_func.py +757 -185
  270. mindspore/ops/auto_generate/gen_ops_def.py +4197 -2243
  271. mindspore/ops/auto_generate/gen_ops_prim.py +16976 -6055
  272. mindspore/ops/auto_generate/pyboost_inner_prim.py +221 -87
  273. mindspore/ops/composite/__init__.py +2 -1
  274. mindspore/ops/composite/base.py +20 -25
  275. mindspore/ops/composite/math_ops.py +6 -16
  276. mindspore/ops/composite/multitype_ops/__init__.py +5 -2
  277. mindspore/ops/composite/multitype_ops/_compile_utils.py +228 -30
  278. mindspore/ops/composite/multitype_ops/_constexpr_utils.py +1 -2
  279. mindspore/ops/composite/multitype_ops/add_impl.py +2 -1
  280. mindspore/ops/composite/multitype_ops/bitwise_and_impl.py +2 -1
  281. mindspore/ops/composite/multitype_ops/bitwise_or_impl.py +2 -1
  282. mindspore/ops/composite/multitype_ops/bitwise_xor_impl.py +2 -1
  283. mindspore/ops/composite/multitype_ops/div_impl.py +6 -4
  284. mindspore/ops/composite/multitype_ops/equal_impl.py +4 -3
  285. mindspore/ops/composite/multitype_ops/floordiv_impl.py +2 -1
  286. mindspore/ops/composite/multitype_ops/getitem_impl.py +3 -2
  287. mindspore/ops/composite/multitype_ops/greater_equal_impl.py +4 -3
  288. mindspore/ops/composite/multitype_ops/greater_impl.py +4 -3
  289. mindspore/ops/composite/multitype_ops/in_impl.py +2 -1
  290. mindspore/ops/composite/multitype_ops/invert_impl.py +50 -0
  291. mindspore/ops/composite/multitype_ops/left_shift_impl.py +2 -1
  292. mindspore/ops/composite/multitype_ops/less_equal_impl.py +4 -3
  293. mindspore/ops/composite/multitype_ops/less_impl.py +4 -3
  294. mindspore/ops/composite/multitype_ops/logic_not_impl.py +3 -2
  295. mindspore/ops/composite/multitype_ops/logical_and_impl.py +2 -1
  296. mindspore/ops/composite/multitype_ops/logical_or_impl.py +2 -1
  297. mindspore/ops/composite/multitype_ops/mod_impl.py +2 -1
  298. mindspore/ops/composite/multitype_ops/mul_impl.py +3 -2
  299. mindspore/ops/composite/multitype_ops/negative_impl.py +2 -1
  300. mindspore/ops/composite/multitype_ops/not_equal_impl.py +2 -1
  301. mindspore/ops/composite/multitype_ops/not_in_impl.py +2 -1
  302. mindspore/ops/composite/multitype_ops/ones_like_impl.py +18 -0
  303. mindspore/ops/composite/multitype_ops/pow_impl.py +2 -30
  304. mindspore/ops/composite/multitype_ops/right_shift_impl.py +2 -1
  305. mindspore/ops/composite/multitype_ops/setitem_impl.py +2 -1
  306. mindspore/ops/composite/multitype_ops/sub_impl.py +2 -1
  307. mindspore/ops/function/__init__.py +40 -2
  308. mindspore/ops/function/_add_attr_func.py +58 -0
  309. mindspore/ops/function/array_func.py +2089 -2403
  310. mindspore/ops/function/clip_func.py +80 -23
  311. mindspore/ops/function/debug_func.py +57 -57
  312. mindspore/ops/function/grad/__init__.py +1 -0
  313. mindspore/ops/function/grad/grad_func.py +104 -71
  314. mindspore/ops/function/image_func.py +2 -2
  315. mindspore/ops/function/linalg_func.py +47 -78
  316. mindspore/ops/function/math_func.py +4351 -3813
  317. mindspore/ops/function/nn_func.py +1712 -637
  318. mindspore/ops/function/other_func.py +159 -1
  319. mindspore/ops/function/parameter_func.py +18 -84
  320. mindspore/ops/function/random_func.py +452 -387
  321. mindspore/ops/function/reshard_func.py +4 -70
  322. mindspore/ops/function/sparse_func.py +3 -3
  323. mindspore/ops/function/sparse_unary_func.py +6 -6
  324. mindspore/ops/function/spectral_func.py +25 -58
  325. mindspore/ops/function/vmap_func.py +26 -18
  326. mindspore/ops/functional.py +23 -7
  327. mindspore/ops/functional_overload.py +1548 -0
  328. mindspore/ops/op_info_register.py +32 -244
  329. mindspore/ops/operations/__init__.py +23 -15
  330. mindspore/ops/operations/_custom_ops_utils.py +235 -0
  331. mindspore/ops/operations/_embedding_cache_ops.py +4 -4
  332. mindspore/ops/operations/_grad_ops.py +2 -43
  333. mindspore/ops/operations/_infer_ops.py +2 -1
  334. mindspore/ops/operations/_inner_ops.py +43 -84
  335. mindspore/ops/operations/_ms_kernel.py +4 -10
  336. mindspore/ops/operations/_rl_inner_ops.py +1 -1
  337. mindspore/ops/operations/_scalar_ops.py +3 -2
  338. mindspore/ops/operations/_sequence_ops.py +1 -1
  339. mindspore/ops/operations/_tensor_array.py +1 -1
  340. mindspore/ops/operations/array_ops.py +81 -324
  341. mindspore/ops/operations/comm_ops.py +154 -108
  342. mindspore/ops/operations/custom_ops.py +298 -87
  343. mindspore/ops/operations/debug_ops.py +157 -59
  344. mindspore/ops/operations/inner_ops.py +7 -5
  345. mindspore/ops/operations/linalg_ops.py +1 -57
  346. mindspore/ops/operations/manually_defined/_inner.py +1 -1
  347. mindspore/ops/operations/manually_defined/ops_def.py +928 -180
  348. mindspore/ops/operations/math_ops.py +32 -234
  349. mindspore/ops/operations/nn_ops.py +212 -531
  350. mindspore/ops/operations/other_ops.py +62 -9
  351. mindspore/ops/operations/random_ops.py +13 -7
  352. mindspore/ops/operations/reshard_ops.py +1 -1
  353. mindspore/ops/operations/sparse_ops.py +2 -2
  354. mindspore/ops/primitive.py +66 -53
  355. mindspore/ops/tensor_method.py +1895 -0
  356. mindspore/ops_generate/__init__.py +0 -5
  357. mindspore/ops_generate/aclnn/__init__.py +0 -0
  358. mindspore/ops_generate/aclnn/aclnn_kernel_register_auto_cc_generator.py +135 -0
  359. mindspore/ops_generate/aclnn/gen_aclnn_implement.py +257 -0
  360. mindspore/ops_generate/api/__init__.py +0 -0
  361. mindspore/ops_generate/api/add_tensor_docs_generator.py +56 -0
  362. mindspore/ops_generate/api/cpp_create_prim_instance_helper_generator.py +105 -0
  363. mindspore/ops_generate/api/functional_map_cpp_generator.py +504 -0
  364. mindspore/ops_generate/api/functional_overload_py_generator.py +112 -0
  365. mindspore/ops_generate/api/functions_cc_generator.py +237 -0
  366. mindspore/ops_generate/api/gen_api.py +103 -0
  367. mindspore/ops_generate/api/op_api_proto.py +235 -0
  368. mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +461 -0
  369. mindspore/ops_generate/common/__init__.py +0 -0
  370. mindspore/ops_generate/common/base_generator.py +11 -0
  371. mindspore/ops_generate/common/gen_constants.py +91 -0
  372. mindspore/ops_generate/common/gen_utils.py +348 -0
  373. mindspore/ops_generate/common/op_proto.py +473 -0
  374. mindspore/ops_generate/common/template.py +523 -0
  375. mindspore/ops_generate/gen_ops.py +22 -1069
  376. mindspore/ops_generate/op_def/__init__.py +0 -0
  377. mindspore/ops_generate/op_def/gen_op_def.py +90 -0
  378. mindspore/ops_generate/op_def/lite_ops_cpp_generator.py +191 -0
  379. mindspore/ops_generate/op_def/ops_def_cc_generator.py +296 -0
  380. mindspore/ops_generate/op_def/ops_def_h_generator.py +74 -0
  381. mindspore/ops_generate/op_def/ops_name_h_generator.py +83 -0
  382. mindspore/ops_generate/op_def/ops_primitive_h_generator.py +125 -0
  383. mindspore/ops_generate/op_def_py/__init__.py +0 -0
  384. mindspore/ops_generate/op_def_py/gen_op_def_py.py +47 -0
  385. mindspore/ops_generate/op_def_py/op_def_py_generator.py +132 -0
  386. mindspore/ops_generate/op_def_py/op_prim_py_generator.py +489 -0
  387. mindspore/ops_generate/pyboost/__init__.py +0 -0
  388. mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +139 -0
  389. mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +93 -0
  390. mindspore/ops_generate/pyboost/gen_pyboost_func.py +175 -0
  391. mindspore/ops_generate/pyboost/op_template_parser.py +517 -0
  392. mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +407 -0
  393. mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +100 -0
  394. mindspore/ops_generate/pyboost/pyboost_functions_py_generator.py +148 -0
  395. mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +155 -0
  396. mindspore/ops_generate/pyboost/pyboost_inner_prim_generator.py +132 -0
  397. mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +272 -0
  398. mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +938 -0
  399. mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +357 -0
  400. mindspore/ops_generate/{pyboost_utils.py → pyboost/pyboost_utils.py} +179 -36
  401. mindspore/ops_generate/resources/__init__.py +0 -0
  402. mindspore/ops_generate/resources/resource_list.py +30 -0
  403. mindspore/ops_generate/resources/resource_loader.py +36 -0
  404. mindspore/ops_generate/resources/resource_manager.py +64 -0
  405. mindspore/ops_generate/resources/yaml_loader.py +88 -0
  406. mindspore/ops_generate/tensor_py_cc_generator.py +122 -0
  407. mindspore/parallel/__init__.py +7 -3
  408. mindspore/parallel/_auto_parallel_context.py +159 -40
  409. mindspore/parallel/_cell_wrapper.py +132 -15
  410. mindspore/parallel/_parallel_serialization.py +107 -5
  411. mindspore/parallel/_ps_context.py +1 -1
  412. mindspore/parallel/_recovery_context.py +7 -2
  413. mindspore/parallel/_tensor.py +142 -18
  414. mindspore/parallel/_utils.py +199 -23
  415. mindspore/parallel/algo_parameter_config.py +4 -4
  416. mindspore/parallel/auto_parallel.py +732 -0
  417. mindspore/parallel/checkpoint_convert.py +159 -0
  418. mindspore/parallel/checkpoint_transform.py +700 -35
  419. mindspore/parallel/cluster/process_entity/_api.py +276 -50
  420. mindspore/parallel/cluster/process_entity/_utils.py +41 -6
  421. mindspore/parallel/cluster/run.py +21 -4
  422. mindspore/parallel/function/__init__.py +24 -0
  423. mindspore/parallel/function/reshard_func.py +258 -0
  424. mindspore/parallel/nn/__init__.py +25 -0
  425. mindspore/parallel/nn/parallel_cell_wrapper.py +263 -0
  426. mindspore/parallel/nn/parallel_grad_reducer.py +169 -0
  427. mindspore/parallel/parameter_broadcast.py +25 -14
  428. mindspore/parallel/shard.py +137 -59
  429. mindspore/parallel/transform_safetensors.py +364 -305
  430. mindspore/profiler/__init__.py +22 -5
  431. mindspore/profiler/analysis/__init__.py +0 -0
  432. mindspore/profiler/analysis/parser/__init__.py +0 -0
  433. mindspore/profiler/analysis/parser/ascend_cann_parser.py +170 -0
  434. mindspore/profiler/analysis/parser/base_parser.py +158 -0
  435. mindspore/profiler/analysis/parser/framework_cann_relation_parser.py +45 -0
  436. mindspore/profiler/analysis/parser/ms_framework_parser.py +142 -0
  437. mindspore/profiler/analysis/parser/ms_minddata_parser.py +145 -0
  438. mindspore/profiler/analysis/parser/timeline_assembly_factory/__init__.py +0 -0
  439. mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +264 -0
  440. mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +40 -0
  441. mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +109 -0
  442. mindspore/profiler/analysis/parser/timeline_creator/__init__.py +0 -0
  443. mindspore/profiler/analysis/parser/timeline_creator/base_timeline_creator.py +44 -0
  444. mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +90 -0
  445. mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +76 -0
  446. mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +103 -0
  447. mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +134 -0
  448. mindspore/profiler/analysis/parser/timeline_event/__init__.py +0 -0
  449. mindspore/profiler/analysis/parser/timeline_event/base_event.py +233 -0
  450. mindspore/profiler/analysis/parser/timeline_event/cpu_op_event.py +47 -0
  451. mindspore/profiler/analysis/parser/timeline_event/flow_event.py +36 -0
  452. mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +415 -0
  453. mindspore/profiler/analysis/parser/timeline_event/msprof_event.py +73 -0
  454. mindspore/profiler/analysis/parser/timeline_event/scope_layer_event.py +53 -0
  455. mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +146 -0
  456. mindspore/profiler/analysis/task_manager.py +131 -0
  457. mindspore/profiler/analysis/time_converter.py +84 -0
  458. mindspore/profiler/analysis/viewer/__init__.py +0 -0
  459. mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +372 -0
  460. mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +87 -0
  461. mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +250 -0
  462. mindspore/profiler/analysis/viewer/ascend_memory_viewer.py +320 -0
  463. mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +327 -0
  464. mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +376 -0
  465. mindspore/profiler/analysis/viewer/ascend_timeline_viewer.py +58 -0
  466. mindspore/profiler/analysis/viewer/base_viewer.py +26 -0
  467. mindspore/profiler/analysis/viewer/ms_dataset_viewer.py +96 -0
  468. mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +581 -0
  469. mindspore/profiler/analysis/work_flow.py +73 -0
  470. mindspore/profiler/common/ascend_msprof_exporter.py +139 -0
  471. mindspore/profiler/common/command_executor.py +90 -0
  472. mindspore/profiler/common/constant.py +186 -3
  473. mindspore/profiler/common/file_manager.py +208 -0
  474. mindspore/profiler/common/log.py +130 -0
  475. mindspore/profiler/common/msprof_cmd_tool.py +221 -0
  476. mindspore/profiler/common/path_manager.py +395 -0
  477. mindspore/profiler/common/process_bar.py +168 -0
  478. mindspore/profiler/common/process_pool.py +9 -3
  479. mindspore/profiler/common/profiler_context.py +500 -0
  480. mindspore/profiler/common/profiler_info.py +304 -0
  481. mindspore/profiler/common/profiler_meta_data.py +74 -0
  482. mindspore/profiler/common/profiler_output_path.py +284 -0
  483. mindspore/profiler/common/profiler_parameters.py +251 -0
  484. mindspore/profiler/common/profiler_path_manager.py +179 -0
  485. mindspore/profiler/common/record_function.py +76 -0
  486. mindspore/profiler/common/tlv_decoder.py +76 -0
  487. mindspore/profiler/common/util.py +75 -2
  488. mindspore/profiler/dynamic_profiler.py +341 -75
  489. mindspore/profiler/envprofiler.py +163 -0
  490. mindspore/profiler/experimental_config.py +197 -0
  491. mindspore/profiler/mstx.py +242 -0
  492. mindspore/profiler/platform/__init__.py +21 -0
  493. mindspore/profiler/platform/base_profiler.py +40 -0
  494. mindspore/profiler/platform/cpu_profiler.py +124 -0
  495. mindspore/profiler/platform/gpu_profiler.py +74 -0
  496. mindspore/profiler/platform/npu_profiler.py +335 -0
  497. mindspore/profiler/profiler.py +1073 -90
  498. mindspore/profiler/profiler_action_controller.py +187 -0
  499. mindspore/profiler/profiler_interface.py +118 -0
  500. mindspore/profiler/schedule.py +243 -0
  501. mindspore/rewrite/api/node.py +15 -13
  502. mindspore/rewrite/api/symbol_tree.py +2 -3
  503. mindspore/run_check/_check_version.py +27 -20
  504. mindspore/run_check/run_check.py +1 -1
  505. mindspore/runtime/__init__.py +37 -0
  506. mindspore/runtime/device.py +27 -0
  507. mindspore/runtime/event.py +209 -0
  508. mindspore/runtime/executor.py +177 -0
  509. mindspore/runtime/memory.py +416 -0
  510. mindspore/runtime/stream.py +460 -0
  511. mindspore/runtime/thread_bind_core.py +401 -0
  512. mindspore/safeguard/rewrite_obfuscation.py +12 -9
  513. mindspore/swresample-4.dll +0 -0
  514. mindspore/swscale-6.dll +0 -0
  515. mindspore/tinyxml2.dll +0 -0
  516. mindspore/train/__init__.py +8 -8
  517. mindspore/train/_utils.py +96 -27
  518. mindspore/train/amp.py +9 -5
  519. mindspore/train/callback/__init__.py +2 -2
  520. mindspore/train/callback/_callback.py +2 -16
  521. mindspore/train/callback/_checkpoint.py +53 -55
  522. mindspore/train/callback/_cluster_monitor.py +14 -18
  523. mindspore/train/callback/_early_stop.py +1 -1
  524. mindspore/train/callback/_flops_collector.py +103 -68
  525. mindspore/train/callback/_history.py +8 -5
  526. mindspore/train/callback/_lambda_callback.py +2 -2
  527. mindspore/train/callback/_landscape.py +0 -3
  528. mindspore/train/callback/_loss_monitor.py +2 -1
  529. mindspore/train/callback/_on_request_exit.py +6 -5
  530. mindspore/train/callback/_reduce_lr_on_plateau.py +11 -6
  531. mindspore/train/callback/_summary_collector.py +52 -19
  532. mindspore/train/callback/_time_monitor.py +2 -1
  533. mindspore/train/callback/{_tft_register.py → _train_fault_tolerance.py} +228 -108
  534. mindspore/train/data_sink.py +25 -2
  535. mindspore/train/dataset_helper.py +15 -16
  536. mindspore/train/loss_scale_manager.py +8 -7
  537. mindspore/train/metrics/accuracy.py +3 -3
  538. mindspore/train/metrics/confusion_matrix.py +9 -9
  539. mindspore/train/metrics/error.py +3 -3
  540. mindspore/train/metrics/hausdorff_distance.py +4 -4
  541. mindspore/train/metrics/mean_surface_distance.py +3 -3
  542. mindspore/train/metrics/metric.py +0 -12
  543. mindspore/train/metrics/occlusion_sensitivity.py +4 -2
  544. mindspore/train/metrics/precision.py +11 -10
  545. mindspore/train/metrics/recall.py +9 -9
  546. mindspore/train/metrics/root_mean_square_surface_distance.py +2 -2
  547. mindspore/train/mind_ir_pb2.py +174 -46
  548. mindspore/train/model.py +269 -136
  549. mindspore/train/serialization.py +622 -978
  550. mindspore/train/summary/_summary_adapter.py +2 -2
  551. mindspore/train/summary/summary_record.py +2 -3
  552. mindspore/train/train_thor/model_thor.py +1 -1
  553. mindspore/turbojpeg.dll +0 -0
  554. mindspore/utils/__init__.py +6 -3
  555. mindspore/utils/dryrun.py +140 -0
  556. mindspore/utils/hooks.py +81 -0
  557. mindspore/utils/runtime_execution_order_check.py +552 -0
  558. mindspore/utils/utils.py +138 -4
  559. mindspore/version.py +1 -1
  560. {mindspore-2.4.10.dist-info → mindspore-2.6.0.dist-info}/METADATA +3 -3
  561. {mindspore-2.4.10.dist-info → mindspore-2.6.0.dist-info}/RECORD +564 -395
  562. {mindspore-2.4.10.dist-info → mindspore-2.6.0.dist-info}/entry_points.txt +1 -1
  563. mindspore/_install_custom.py +0 -43
  564. mindspore/common/_register_for_adapter.py +0 -74
  565. mindspore/common/_tensor_overload.py +0 -139
  566. mindspore/mindspore_np_dtype.dll +0 -0
  567. mindspore/ops/auto_generate/gen_arg_dtype_cast.py +0 -252
  568. mindspore/ops/auto_generate/gen_arg_handler.py +0 -197
  569. mindspore/ops/operations/_opaque_predicate_registry.py +0 -41
  570. mindspore/ops_generate/gen_aclnn_implement.py +0 -263
  571. mindspore/ops_generate/gen_ops_inner_prim.py +0 -131
  572. mindspore/ops_generate/gen_pyboost_func.py +0 -1052
  573. mindspore/ops_generate/gen_utils.py +0 -209
  574. mindspore/ops_generate/op_proto.py +0 -145
  575. mindspore/ops_generate/template.py +0 -261
  576. mindspore/profiler/envprofiling.py +0 -254
  577. mindspore/profiler/profiling.py +0 -1926
  578. {mindspore-2.4.10.dist-info → mindspore-2.6.0.dist-info}/WHEEL +0 -0
  579. {mindspore-2.4.10.dist-info → mindspore-2.6.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,1895 @@
1
+ # Copyright 2024 Huawei Technologies Co., Ltd
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # ============================================================================
15
+ """Tensor method for overload."""
16
+
17
+ from mindspore import _checkparam as validator
18
+ from mindspore import log as logger
19
+ from mindspore import ops
20
+ from mindspore.ops import operations as P
21
+ from mindspore.ops import functional as F
22
+ from mindspore.ops.composite.multitype_ops import _compile_utils as utils
23
+ from mindspore.ops.composite.multitype_ops._compile_utils import (
24
+ sequence_to_tensor, _tensor_sub, _tensor_pow, _tensor_div, _tensor_floordiv
25
+ )
26
+ from mindspore.ops.auto_generate.gen_ops_prim import (
27
+ inplace_scatter_src_op, inplace_scatter_src_reduce_op, inplace_scatter_value_op, inplace_scatter_value_reduce_op,
28
+ inplace_copy_op
29
+ )
30
+ from mindspore.ops.auto_generate.gen_ops_prim import (
31
+ floor_div_op, floor_div_scalar_op
32
+ )
33
+ # 1 common import
34
+
35
+ # 2 common import
36
+ from mindspore import Tensor
37
+ # 3 common import
38
+ from mindspore.common import dtype as mstype
39
+ # 4 common import
40
+ from mindspore.common import COOTensor
41
+
42
+ # 5 common import
43
+ from mindspore.ops.function.nn_func import gelu
44
+ # 6 common import
45
+
46
+ # 7 common import
47
+
48
+
49
+ # 1 to
50
+ from mindspore.ops.auto_generate import cast
51
+ # 2 masked_fill
52
+
53
+ # 3 abs
54
+ from mindspore.ops.auto_generate import abs
55
+ # 4 __abs__
56
+
57
+ # 5 add
58
+ from mindspore.ops.auto_generate import add_ext, add
59
+
60
+ # 6 all
61
+ from mindspore.ops.auto_generate import all
62
+ # 7 allclose
63
+
64
+ # 8 any
65
+ from mindspore.ops.function.math_func import any
66
+ # 9 arctan2
67
+ from mindspore.ops.function.math_func import arctan2
68
+ # 10 argmax
69
+ from mindspore.ops.function.array_func import argmax
70
+ # 11 argmin
71
+ from mindspore.ops.function.math_func import argmin
72
+ # 12 argsort
73
+ from mindspore.ops.function.array_func import argsort
74
+ # 13 atan2
75
+ from mindspore.ops.function.math_func import atan2
76
+ # 14 bfloat16
77
+
78
+ # 15 bmm
79
+
80
+ # 16 bool
81
+
82
+ # 17 broadcast_to
83
+ from mindspore.ops.auto_generate import broadcast_to
84
+ # 18 byte
85
+
86
+ # 19 ceil
87
+ from mindspore.ops.function.math_func import ceil
88
+ # 20 chunk
89
+ from mindspore.ops.function.array_func import chunk
90
+ # 21 clamp
91
+ from mindspore.ops.auto_generate import clamp_tensor, clamp_scalar
92
+ # 22 clip
93
+
94
+ # 23 cos
95
+ from mindspore.ops.function.math_func import cos
96
+ # 24 cumprod
97
+
98
+ # 25 cumsum
99
+ from mindspore.ops.function.math_func import cumsum
100
+ # 26 dim
101
+
102
+ # 27 div
103
+ from mindspore.ops.function.math_func import div
104
+ # 28 divide
105
+
106
+ # 29 eq
107
+ from mindspore.ops.function.math_func import eq
108
+ # 30 erf
109
+ from mindspore.ops.auto_generate import erf
110
+ # 31 exp
111
+ from mindspore.ops.auto_generate import exp
112
+ # 32 expand
113
+
114
+ # 33 expand_as
115
+
116
+ # 34 flatten
117
+ from mindspore.ops.function.array_func import flatten
118
+
119
+ # 35 flip
120
+
121
+ # 36 float
122
+
123
+ # 37 floor
124
+ from mindspore.ops.function.math_func import floor
125
+ # 38 gather
126
+ from mindspore.ops.auto_generate import gather
127
+ from mindspore.ops.function.array_func import gather_ext
128
+ # 39 greater
129
+ from mindspore.ops.function.math_func import greater
130
+ # 40 greater_equal
131
+ from mindspore.ops.function.math_func import greater_equal
132
+ # 41 gt
133
+
134
+ # 42 half
135
+
136
+ # 43 index_put
137
+
138
+ # 44 index_select
139
+ from mindspore.ops.function.array_func import index_select
140
+ # 45 int
141
+
142
+ # 46 inverse
143
+ from mindspore.ops.function.math_func import inverse
144
+ # 47 is_contiguous
145
+
146
+ # 48 isclose
147
+ from mindspore.ops.function.math_func import isclose
148
+ # 49 isfinite
149
+ from mindspore.ops.auto_generate import isfinite
150
+ # 50 isnan
151
+
152
+ # 51 item
153
+
154
+ # 52 le
155
+ from mindspore.ops.function.math_func import le
156
+ # 53 less
157
+
158
+ # 54 less_equal
159
+
160
+ # 55 log
161
+
162
+ # 56 log2
163
+ from mindspore.ops.function.math_func import log2
164
+ # 57 logical_and
165
+ from mindspore.ops.function.math_func import logical_and
166
+ # 58 logical_not
167
+ from mindspore.ops.function.math_func import logical_not
168
+ # 59 logical_or
169
+ from mindspore.ops.function.math_func import logical_or
170
+ # 60 long
171
+
172
+ # 61 lt
173
+
174
+ # 62 masked_fill
175
+ from mindspore.ops.auto_generate import masked_fill
176
+ # 63 masked_select
177
+
178
+ # 64 matmul
179
+ from mindspore.ops.auto_generate import matmul_ext
180
+ # 65 max
181
+ from mindspore.ops.auto_generate import max_
182
+ from mindspore.ops.function.array_func import max as max_func
183
+ # 66 maximum
184
+
185
+ # 67 mean
186
+ from mindspore.ops.auto_generate import mean_ext
187
+ from mindspore.ops.function.math_func import mean
188
+ # 68 min
189
+ from mindspore.ops.auto_generate import min_
190
+ from mindspore.ops.function.array_func import min as min_func
191
+ # 69 minimum
192
+
193
+ # 70 mul
194
+
195
+ # 71 nan_to_num
196
+
197
+ # 72 narrow
198
+
199
+ # 73 ne
200
+
201
+ # 74 neg
202
+
203
+ # 75 negative
204
+
205
+ # 76 nonzero
206
+
207
+ # 77 norm
208
+
209
+ # 78 numel
210
+
211
+ # 79 numpy
212
+
213
+ # 80 outer
214
+
215
+ # 81 permute
216
+
217
+ # 82 pow
218
+ from mindspore.ops.auto_generate import pow
219
+ # 83 prod
220
+ from mindspore.ops.auto_generate import prod_ext
221
+ # 84 reciprocal
222
+ from mindspore.ops.function.math_func import reciprocal
223
+ # 85 remainder
224
+ from mindspore.ops.function.math_func import remainder
225
+ # 86 repeat
226
+
227
+ # 87 repeat_interleave
228
+ from mindspore.ops.function.array_func import repeat_interleave, repeat_interleave_ext
229
+ # 88 reshape
230
+ from mindspore.ops.auto_generate import reshape
231
+ # 89 round
232
+ from mindspore.ops.function.math_func import round
233
+ # 90 rsqrt
234
+ from mindspore.ops.auto_generate import rsqrt
235
+ # 91 scatter
236
+ from mindspore.ops.function.array_func import scatter
237
+ # 92 scatter_add
238
+ from mindspore.ops.function.array_func import tensor_scatter_add
239
+ # 93 select
240
+ from mindspore.ops.auto_generate import select, select_ext_view
241
+ # 94 sigmoid
242
+ from mindspore.ops.auto_generate import sigmoid
243
+ # 95 sin
244
+ from mindspore.ops.auto_generate import sin
245
+ # 96 size
246
+
247
+ # 97 sort
248
+ from mindspore.ops.function.array_func import sort
249
+ # 98 split
250
+ from mindspore.ops.function.array_func import split
251
+ # 99 sqrt
252
+ from mindspore.ops.auto_generate import sqrt
253
+ # 100 square
254
+ from mindspore.ops.auto_generate import square
255
+ # 101 squeeze
256
+
257
+ # 102 std
258
+
259
+ # 103 sub
260
+ from mindspore.ops.auto_generate import sub, sub_ext
261
+ # 104 sum
262
+ from mindspore.ops.function.math_func import sum
263
+ # 105 swapaxes
264
+
265
+ # 106 t
266
+ from mindspore.ops.function.math_func import t
267
+ # 107 tanh
268
+ from mindspore.ops.auto_generate import tanh
269
+ # 108 tile
270
+ from mindspore.ops.operations.manually_defined import tile
271
+ # 109 tolist
272
+
273
+ # 110 topk
274
+ from mindspore.ops.function.array_func import topk
275
+ # 111 transpose
276
+ from mindspore.ops.auto_generate import transpose, transpose_ext_view
277
+ # 112 tril
278
+ from mindspore.ops.function.array_func import tril
279
+ # 113 trunc
280
+
281
+ # 114 type
282
+
283
+ # 115 type_as
284
+
285
+ # 116 unbind
286
+
287
+ # 117 unfold
288
+
289
+ # 118 unique
290
+ from mindspore.ops.auto_generate import UniqueDim, Unique2
291
+ # 119 unsqeeze
292
+
293
+ # 120 view
294
+
295
+ # 121 contiguous
296
+
297
+ # 122 where
298
+ from mindspore.ops.function.array_func import where as where_func
299
+
300
+ # 123 div_
301
+
302
+ # 124 fill_
303
+
304
+ # 125 floor_
305
+
306
+ # 126 masked_fill_
307
+
308
+ # 127 mul_
309
+
310
+ # 128 normal_
311
+
312
+ # 129 requires_grad_
313
+
314
+ # 130 sub_
315
+
316
+ # 131 uniform_
317
+
318
+ # 132 absolute
319
+
320
+ # 133 bincount
321
+ from mindspore.ops.function.math_func import bincount, roll
322
+
323
+ # 134 diff
324
+
325
+ # 135 double
326
+
327
+ # 136 lcm
328
+
329
+ # 137 mm
330
+
331
+ # 138 ravel
332
+
333
+ # 139 nelement
334
+
335
+ # 140 stride
336
+
337
+ # 141 indices
338
+
339
+ # 142 view_as
340
+ from mindspore.ops.auto_generate import view_as
341
+ # 143 values
342
+
343
+ # 144 index_copy
344
+
345
+ # 145 element_size
346
+
347
+ # 146 gcd
348
+ from mindspore.ops.auto_generate import gcd
349
+
350
+ # 147 isinf
351
+ from mindspore.ops.auto_generate import isinf
352
+ # 148 not_equal
353
+
354
+ # 149 triu
355
+
356
+ # 150 __eq__
357
+
358
+ # 151 fmod
359
+ from mindspore.ops.function.math_func import fmod
360
+ # 152
361
+ from mindspore.ops.auto_generate import logaddexp2
362
+ # 153
363
+ from mindspore.ops.auto_generate import acos_ext, acosh_ext, asin_ext, asinh_ext, atan_ext, dot
364
+ # 154 isneginf
365
+
366
+ # 155
367
+ from mindspore.ops.function.math_func import median
368
+
369
+ # 156
370
+
371
+ # 157
372
+ from mindspore.ops.auto_generate import xlogy_op
373
+
374
+ # 158
375
+
376
+ # 159 histc
377
+ from mindspore.ops.function.math_func import histc
378
+
379
+ # 160 frac
380
+ from mindspore.ops.function.math_func import frac
381
+
382
+ # 161 bitwise_not
383
+ from mindspore.ops.auto_generate.gen_ops_prim import bitwise_not_op
384
+ from mindspore.ops.function.math_func import bitwise_or, bitwise_and, bitwise_xor
385
+ from mindspore.ops.auto_generate import logical_xor_op
386
+
387
+ # 162 log10
388
+ from mindspore.ops.function.math_func import log10
389
+
390
+ from mindspore.ops.auto_generate import clone
391
+ from mindspore.ops.function.array_func import new_ones
392
+ from mindspore.ops.function.array_func import new_zeros
393
+
394
+ # 163
395
+ from mindspore.ops.auto_generate import cosh
396
+ from mindspore.ops.auto_generate import sinc
397
+ from mindspore.ops.auto_generate import sinh
398
+ from mindspore.ops.function.array_func import unsqueeze
399
+
400
+ # 186
401
+ from mindspore.ops.function.math_func import addcdiv
402
+ from mindspore.ops.auto_generate import addcdiv_ext_op
403
+
404
+ # 204 erfc
405
+ from mindspore.ops.auto_generate import erfc
406
+
407
+ # 207 expm1
408
+ from mindspore.ops.auto_generate import expm1
409
+
410
+ # 220 hardshrink
411
+ from mindspore.ops.auto_generate import hardshrink
412
+
413
+ # 931
414
+ from mindspore.ops.function.math_func import nansum
415
+
416
+ # 244 log1p
417
+ from mindspore.ops.auto_generate import log1p
418
+
419
+ # 501
420
+ from mindspore.ops.function.math_func import addbmm
421
+ # 502
422
+ from mindspore.ops.function.math_func import addmm
423
+ # 846
424
+ from mindspore.ops.function.math_func import count_nonzero
425
+
426
+ # 880
427
+ from mindspore.ops.auto_generate import lerp, lerp_scalar
428
+
429
+ # 790 addmv
430
+ from mindspore.ops.function.math_func import addmv
431
+
432
+ # 916 index_add
433
+ from mindspore.ops.primitive import constexpr
434
+ from mindspore._checkparam import check_is_number
435
+
436
+ # 1028
437
+ from mindspore.ops.function.math_func import var_ext
438
+
439
+ # 1029 exp_
440
+ from mindspore.ops.auto_generate.gen_ops_prim import inplace_exp_op
441
+
442
+ # 1030 log_
443
+ from mindspore.ops.auto_generate.gen_ops_prim import inplace_log_op
444
+
445
+ from .._checkparam import check_axis_in_range
446
+ from ..ops.composite.multitype_ops import _compile_utils as compile_utils
447
+
448
+
449
+ ########################################functions########################################
450
+ def place_holder():
451
+ logger.error(
452
+ "This is a place holder function and should not be called. Please check the implementation.")
453
+
454
+
455
+ unique_dim_ = UniqueDim()
456
+ unique2_ = Unique2()
457
+ tuple_slice = validator.tuple_slice
458
+ expanded_shape = validator.expanded_shape
459
+
460
+
461
+ # 1 to
462
+ def tensor_to(input, dtype):
463
+ return cast(input, dtype)
464
+
465
+
466
+ # 2 masked_fill
467
+ def tensor_masked_fill(input_x, mask, value):
468
+ return masked_fill(input_x, mask, value)
469
+
470
+
471
+ # 3 abs
472
+ def tensor_abs(input):
473
+ return abs(input)
474
+
475
+
476
+ # 4 __abs__
477
+
478
+ # 5 add
479
+ def tensor_add_ext(input, other, *, alpha=1):
480
+ return add_ext(input, other, alpha=alpha)
481
+
482
+
483
+ def deprecated_tensor_add(input, other):
484
+ if isinstance(other, COOTensor):
485
+ return other + input
486
+ if isinstance(other, (tuple, list)):
487
+ other = sequence_to_tensor(other, F.dtype(input))
488
+ return add(input, other)
489
+
490
+
491
+ # 6 all
492
+ def tensor_all(x, axis=None, keep_dims=False):
493
+ return all(x, axis, keep_dims)
494
+
495
+
496
+ def deprecated_tensor_all(x, dim=None, keepdim=False):
497
+ return all(x, dim, keepdim)
498
+
499
+
500
+ # 7 allclose
501
+ def tensor_allclose(input, other, rtol=1e-05, atol=1e-08, equal_nan=False):
502
+ return isclose(input, other, rtol, atol, equal_nan).all().item()
503
+
504
+
505
+ # 8 any
506
+ def tensor_any(x, axis=None, keep_dims=False):
507
+ if axis is None:
508
+ axis = ()
509
+ return any(x, axis, keep_dims)
510
+
511
+
512
+ def deprecated_tensor_any(x, dim=None, keepdim=False):
513
+ if dim is None:
514
+ dim = ()
515
+ return any(x, dim, keepdim)
516
+
517
+
518
+ # 9 arctan2
519
+ def tensor_arctan2(input, other):
520
+ return arctan2(input, other)
521
+
522
+
523
+ # 10 argmax
524
+ def tensor_argmax(input, dim=None, keepdim=False):
525
+ return argmax(input, dim, keepdim)
526
+
527
+
528
+ def deprecated_tensor_argmax(input, axis=None, keepdims=False):
529
+ return argmax(input, axis, keepdims)
530
+
531
+
532
+ # 11 argmin
533
+ def tensor_argmin(input, dim=None, keepdim=False):
534
+ return argmin(input, dim, keepdim)
535
+
536
+
537
+ def deprecated_tensor_argmin(input, axis=None, keepdims=False):
538
+ return argmin(input, axis, keepdims)
539
+
540
+
541
+ # 12 argsort
542
+ def tensor_argsort(input, dim=-1, descending=False, stable=False):
543
+ return argsort(input, dim, descending)
544
+
545
+
546
+ def deprecated_tensor_argsort(input, axis=-1, descending=False):
547
+ return argsort(input, axis, descending)
548
+
549
+
550
+ # 13 atan2
551
+ def tensor_atan2(input, other):
552
+ return atan2(input, other)
553
+
554
+
555
+ # 14 bfloat16
556
+
557
+ # 15 bmm
558
+
559
+ # 16 bool
560
+
561
+ # 17 broadcast_to
562
+
563
+ # 18 byte
564
+
565
+ # 19 ceil
566
+ def tensor_ceil(input):
567
+ return ceil(input)
568
+
569
+
570
+ # 20 chunk
571
+ def deprecated_tensor_chunk(input, chunks, axis=0):
572
+ return chunk(input, chunks, axis)
573
+
574
+
575
+ def tensor_chunk(input, chunks, dim=0):
576
+ return chunk(input, chunks, dim)
577
+
578
+
579
+ # 21 clamp
580
+ def tensor_clamp_tensor(input, min=None, max=None):
581
+ return clamp_tensor(input, min, max)
582
+
583
+
584
+ def tensor_clamp_scalar(input, min=None, max=None):
585
+ return clamp_scalar(input, min, max)
586
+
587
+
588
+ # 22 clip
589
+
590
+ # 23 cos
591
+ def tensor_cos(input):
592
+ return cos(input)
593
+
594
+
595
+ # 24 cumprod
596
+
597
+ # 25 cumsum
598
+ def deprecated_tensor_cumsum(x, axis=None, dtype=None):
599
+ r"""
600
+ For details, please refer to :func:`mindspore.ops.cumsum`.
601
+ """
602
+ original_dtype = x.dtype
603
+ # If original tensor is int, and has precision less then int32, convert to int32
604
+ if x.dtype in (mstype.bool_, mstype.int8, mstype.int16, mstype.uint8, mstype.int16):
605
+ x = x.astype(mstype.int32)
606
+ if axis is None:
607
+ x = x.ravel()
608
+ axis = 0
609
+ validator.check_axis_in_range(axis, x.ndim)
610
+ if dtype is not None and original_dtype != dtype:
611
+ return cumsum(x, axis).astype(dtype, copy=False)
612
+ return cumsum(x, axis)
613
+
614
+
615
+ def tensor_cumsum(input, dim, *, dtype=None):
616
+ return deprecated_tensor_cumsum(input, dim, dtype)
617
+
618
+
619
+ # 26 dim
620
+
621
+ # 27 div
622
+ def tensor_div(input, value, *, rounding_mode=None):
623
+ return div(input, value, rounding_mode=rounding_mode)
624
+
625
+
626
+ def tensor_div_deal_sequence(input, other, *, rounding_mode=None):
627
+ if isinstance(input, (tuple, list)):
628
+ input = sequence_to_tensor(input, F.dtype(other))
629
+ if isinstance(other, (tuple, list)):
630
+ other = sequence_to_tensor(other, F.dtype(input))
631
+ return div(input, other, rounding_mode=rounding_mode)
632
+
633
+ # 28 divide
634
+
635
+ # 29 eq
636
+ def tensor_eq(input, other):
637
+ return eq(input, other)
638
+
639
+
640
+ # 30 erf
641
+ def tensor_erf(input):
642
+ return erf(input)
643
+
644
+
645
+ # 31 exp
646
+ def tensor_exp(input):
647
+ return exp(input)
648
+
649
+
650
+ # 32 expand
651
+
652
+ # 33 expand_as
653
+ def tensor_expand_as(input, other):
654
+ return broadcast_to(input, other.shape)
655
+
656
+
657
+ def deprecated_tensor_expand_as(input, x):
658
+ return broadcast_to(input, x.shape)
659
+
660
+
661
+ # 34 flatten
662
+ def deprecated_tensor_flatten(input, order='C', *, start_dim=0, end_dim=-1):
663
+ return flatten(input, order, start_dim=start_dim, end_dim=end_dim)
664
+
665
+
666
+ def tensor_flatten(input, start_dim=0, end_dim=-1):
667
+ return flatten(input, start_dim=start_dim, end_dim=end_dim)
668
+
669
+
670
+ # 35 flip
671
+
672
+ # 36 float
673
+
674
+ # 37 floor
675
+ def tensor_floor(input):
676
+ return floor(input)
677
+
678
+
679
+ # 38 gather
680
+ def tensor_gather_ext(input, dim, index):
681
+ return gather_ext(input, dim, index)
682
+
683
+
684
+ def deprecated_tensor_gather(input, input_indices, axis, batch_dims=0):
685
+ r"""
686
+ For details, please refer to :func:`mindspore.ops.gather`.
687
+ """
688
+ validator.check_is_int(axis, 'axis')
689
+ validator.check_is_int(batch_dims, "batch_dims")
690
+ return gather(input, input_indices, axis, batch_dims)
691
+
692
+
693
+ # 39 greater
694
+ def tensor_greater(input, other):
695
+ return greater(input, other)
696
+
697
+
698
+ # 40 greater_equal
699
+ def tensor_greater_equal(input, other):
700
+ return greater_equal(input, other)
701
+
702
+
703
+ def deprecated_tensor_greater_equal(input, other):
704
+ return greater_equal(input, other)
705
+
706
+
707
+ # 41 gt
708
+
709
+ # 42 half
710
+
711
+ # 43 index_put
712
+
713
+ # 44 index_select
714
+ def tensor_index_select(input, dim, index):
715
+ return index_select(input, dim, index)
716
+
717
+
718
+ def deprecated_tensor_index_select(input, axis, index):
719
+ return index_select(input, axis, index)
720
+
721
+
722
+ # 45 int
723
+
724
+ # 46 inverse
725
+ def tensor_inverse(input):
726
+ return inverse(input)
727
+
728
+
729
+ def deprecated_tensor_inverse(input):
730
+ return inverse(input)
731
+
732
+
733
+ # 47 is_contiguous
734
+
735
+ # 48 isclose
736
+ def deprecated_tensor_isclose(input, x2, rtol=1e-05, atol=1e-08, equal_nan=False):
737
+ return isclose(input, x2, rtol, atol, equal_nan)
738
+
739
+
740
+ # 49 isfinite
741
+ def tensor_isfinite(input):
742
+ return isfinite(input)
743
+
744
+
745
+ # 50 isnan
746
+
747
+ # 51 item
748
+
749
+ # 52 le
750
+ def tensor_le(input, other):
751
+ return le(input, other)
752
+
753
+
754
+ # 53 less
755
+ def tensor_less(input, other):
756
+ return F.less(input, other)
757
+
758
+
759
+ # 54 less_equal
760
+
761
+ # 55 log
762
+ def tensor_log(input):
763
+ return F.log(input)
764
+
765
+
766
+ # 56 log2
767
+ def tensor_log2(input):
768
+ return log2(input)
769
+
770
+
771
+ # 57 logical_and
772
+ def tensor_logical_and(input, other):
773
+ return logical_and(input, other)
774
+
775
+
776
+ # 58 logical_not
777
+ def tensor_logical_not(input):
778
+ return logical_not(input)
779
+
780
+
781
+ # 59 logical_or
782
+ def tensor_logical_or(input, other):
783
+ return logical_or(input, other)
784
+
785
+
786
+ # 60 long
787
+
788
+ # 61 lt
789
+
790
+ # 62 masked_fill
791
+
792
+ # 63 masked_select
793
+ def tensor_masked_select(tensor, mask):
794
+ return F.masked_select(tensor, mask)
795
+
796
+
797
+ # 64 matmul
798
+ def tensor_matmul(input, mat2):
799
+ return matmul_ext(input, mat2)
800
+
801
+
802
+ def deprecated_tensor_matmul(input, tensor2):
803
+ return F.matmul(input, tensor2)
804
+
805
+
806
+ # 65 max
807
+ def tensor_max(input):
808
+ return max_(input)
809
+
810
+
811
+ def tensor_maxdim(input, dim, keepdim=False):
812
+ argmax_with_value_op = P.ArgMaxWithValue(dim, keepdim)
813
+ indices, values = argmax_with_value_op(input)
814
+ return values, indices
815
+
816
+
817
+ def deprecated_tensor_max(input, axis=None, keepdims=False, *, initial=None, where=True, return_indices=False):
818
+ r"""
819
+ For details, please refer to :func:`mindspore.ops.max`.
820
+ """
821
+ if isinstance(axis, (list, tuple)):
822
+ reduce_max = P.ReduceMax
823
+ maximum = F.maximum
824
+ return utils.reduce_(input, reduce_max(keepdims), cmp_fn=maximum, axis=axis, keepdims=keepdims,
825
+ initial=initial, where=where)
826
+ values, indices = max_func(input, axis, keepdims, initial=initial, where=where)
827
+ if not return_indices:
828
+ return values
829
+ return values, indices
830
+
831
+
832
+ # 66 maximum
833
+ def tensor_maximum(input, other):
834
+ return F.maximum(input, other)
835
+
836
+
837
+ # 67 mean
838
+ def tensor_mean_ext(input, axis=None, keep_dims=False, *, dtype=None):
839
+ return mean_ext(input, axis, keep_dims, dtype=dtype)
840
+
841
+
842
+ def deprecated_tensor_mean(input, axis=None, keep_dims=False):
843
+ return mean(input, axis, keep_dims)
844
+
845
+
846
+ # 68 min
847
+ def tensor_min(input):
848
+ return min_(input)
849
+
850
+
851
+ def tensor_mindim(input, dim, keepdim=False):
852
+ argmin_with_value_op = P.ArgMinWithValue(dim, keepdim)
853
+ indices, values = argmin_with_value_op(input)
854
+ return values, indices
855
+
856
+
857
+ def deprecated_tensor_min(input, axis=None, keepdims=False, *, initial=None, where=True, return_indices=False):
858
+ r"""
859
+ For details, please refer to :func:`mindspore.ops.min`.
860
+ """
861
+ if isinstance(axis, (list, tuple)):
862
+ reduce_min = P.ReduceMin
863
+ minimum = F.minimum
864
+ return utils.reduce_(input, reduce_min(keepdims), cmp_fn=minimum, axis=axis, keepdims=keepdims,
865
+ initial=initial, where=where)
866
+ values, indices = min_func(input, axis, keepdims, initial=initial, where=where)
867
+ if not return_indices:
868
+ return values
869
+ return values, indices
870
+
871
+
872
+ # 69 minimum
873
+ def tensor_minimum(input, other):
874
+ return F.minimum(input, other)
875
+
876
+
877
+ # 70 mul
878
+ def tensor_mul(input, other):
879
+ return F.mul(input, other)
880
+
881
+
882
+ # 71 nan_to_num
883
+ def tensor_nan_to_num(input, nan=0.0, posinf=None, neginf=None):
884
+ return F.nan_to_num(input, nan, posinf, neginf)
885
+
886
+
887
+ # 72 narrow
888
+ def deprecated_tensor_narrow(input, axis, start, length):
889
+ return F.narrow(input, axis, start, length)
890
+
891
+
892
+ # 73 ne
893
+ def tensor_ne(input, other):
894
+ return F.ne(input, other)
895
+
896
+
897
+ # 74 neg
898
+ def tensor_neg(input):
899
+ return F.neg(input)
900
+
901
+
902
+ # 75 negative
903
+
904
+ # 76 nonzero
905
+
906
+ # 77 norm
907
+
908
+ # 78 numel
909
+
910
+ # 79 numpy
911
+
912
+ # 80 outer
913
+ def deprecated_tensor_outer(input, vec2):
914
+ return F.outer(input, vec2)
915
+
916
+
917
+ # 81 permute
918
+
919
+ # 82 pow
920
+ def tensor_pow_tensor_tensor(input, exponent):
921
+ return pow(input, exponent)
922
+
923
+
924
+ def deprecated_tensor_pow(input, exponent):
925
+ return pow(input, exponent)
926
+
927
+
928
+ # 83 prod
929
+ def tensor_prod(input, axis=None, keep_dims=False, dtype=None):
930
+ return prod_ext(input, axis, keep_dims, dtype)
931
+
932
+
933
+ def deprecated_tensor_prod(input, dim=None, keepdim=False, dtype=None):
934
+ return prod_ext(input, dim, keepdim, dtype)
935
+
936
+
937
+ # 84 reciprocal
938
+ def tensor_reciprocal(input):
939
+ return reciprocal(input)
940
+
941
+
942
+ # 85 remainder
943
+ def tensor_remainder(input, other):
944
+ return remainder(input, other)
945
+
946
+
947
+ def deprecated_tensor_remainder(input, divisor):
948
+ return remainder(input, divisor)
949
+
950
+
951
+ # 86 repeat
952
+ def tensor_repeat(input, *repeats):
953
+ raise RuntimeError("'repeat' is not supported on this device.")
954
+
955
+
956
+ # 87 repeat_interleave
957
+ def deprecated_tensor_repeat_interleave(input, repeats, dim=None):
958
+ return repeat_interleave(input, repeats, dim)
959
+
960
+
961
+ def tensor_repeat_interleave_ext(input, repeats, dim=None, *, output_size=None):
962
+ return repeat_interleave_ext(input, repeats, dim, output_size)
963
+
964
+
965
+ # 88 reshape
966
+ def tensor_reshape(input, *shape):
967
+ new_shape = validator.check_reshape_shp(shape)
968
+ return reshape(input, new_shape)
969
+
970
+
971
+ # 89 round
972
+ def tensor_round(input, decimals=0):
973
+ return round(input, decimals=decimals)
974
+
975
+
976
+ # 90 rsqrt
977
+ def tensor_rsqrt(input):
978
+ return rsqrt(input)
979
+
980
+
981
+ # 91 scatter
982
+ def tensor_scatter(input, dim, index, src):
983
+ return scatter(input, dim, index, src)
984
+
985
+
986
+ def deprecated_tensor_scatter(input, axis, index, src):
987
+ return scatter(input, axis, index, src)
988
+
989
+
990
+ # 92 scatter_add
991
+ def tensor_scatter_add_empty(input, dim, index, src):
992
+ raise ValueError("should not come here for scatter_add method.")
993
+
994
+
995
+ def deprecated_tensor_scatter_add(input, indices, updates):
996
+ return tensor_scatter_add(input, indices, updates)
997
+
998
+
999
+ # 93 select
1000
+ def tensor_select_ext(input, dim, index):
1001
+ return select_ext_view(input, dim, index)
1002
+
1003
+
1004
+ def deprecated_tensor_select(input, condition, y):
1005
+ r"""
1006
+ For details, please refer to :func:`mindspore.ops.select`.
1007
+ """
1008
+ if not isinstance(condition, Tensor):
1009
+ raise TypeError(f"For 'Tensor.select', the argument 'condition' should be Tensor,"
1010
+ f" but got {type(condition)}.")
1011
+ if not isinstance(y, (Tensor, int, float)):
1012
+ raise TypeError(f"For 'Tensor.select', the argument 'y' should be Tensor, int or float,"
1013
+ f" but got {type(y)}.")
1014
+ if isinstance(y, int) and input.dtype != mstype.int32:
1015
+ raise TypeError(f"For 'Tensor.select', if the argument 'y' is int,"
1016
+ f" then the tensor type should be int32 but got {input.dtype}")
1017
+ if isinstance(y, float) and input.dtype != mstype.float32:
1018
+ raise TypeError(f"For 'Tensor.select', if the argument 'y' is float,"
1019
+ f" then the tensor type should be float32 but got {input.dtype}")
1020
+ input_y = y
1021
+ if isinstance(y, (int, float)):
1022
+ zeros_like = F.zeros_like
1023
+ cast_f = F.cast
1024
+ input_y = zeros_like(input) + y
1025
+ if isinstance(y, int):
1026
+ input_y = cast_f(input_y, mstype.int32)
1027
+ else:
1028
+ input_y = cast_f(input_y, mstype.float32)
1029
+ return select(condition, input, input_y)
1030
+
1031
+
1032
+ # 94 sigmoid
1033
+ def tensor_sigmoid(input):
1034
+ return sigmoid(input)
1035
+
1036
+
1037
+ # 95 sin
1038
+ def tensor_sin(input):
1039
+ return sin(input)
1040
+
1041
+
1042
+ # 96 size
1043
+
1044
+ # 97 sort
1045
+ def deprecated_tensor_sort(input, axis=-1, descending=False):
1046
+ return sort(input, axis, descending)
1047
+
1048
+
1049
+ def tensor_sort(input, dim=-1, descending=False, stable=False):
1050
+ return sort(input, dim, descending)
1051
+
1052
+
1053
+ # 98 split
1054
+ def deprecated_tensor_split(input, split_size_or_sections, axis=0):
1055
+ return split(input, split_size_or_sections, axis)
1056
+
1057
+
1058
+ def tensor_split_tensor(input, split_size, dim=0):
1059
+ return deprecated_tensor_split(input, split_size, dim)
1060
+
1061
+
1062
+ def tensor_split_with_size(input, split_size, dim=0):
1063
+ return deprecated_tensor_split(input, split_size, dim)
1064
+
1065
+
1066
+ # 99 sqrt
1067
+ def tensor_sqrt(x):
1068
+ return sqrt(x)
1069
+
1070
+
1071
+ # 100 square
1072
+ def tensor_square(input):
1073
+ return square(input)
1074
+
1075
+
1076
+ # 101 squeeze
1077
+
1078
+ # 102 std
1079
+ def tensor_std(input, dim=None, *, correction=0, keepdim=False):
1080
+ x_var = input.var(dim, correction, keepdim)
1081
+ return F.tensor_pow(x_var, 0.5)
1082
+
1083
+
1084
+ def deprecated_tensor_std(self, axis=None, ddof=0, keepdims=False):
1085
+ """
1086
+ For details, please refer to :func:`mindspore.ops.std`.
1087
+ """
1088
+ x_var = self.var(axis, ddof, keepdims)
1089
+ return F.tensor_pow(x_var, 0.5)
1090
+
1091
+
1092
+ # 103 sub
1093
+ def tensor_sub_ext(input, other, *, alpha=1):
1094
+ return sub_ext(input, other, alpha=alpha)
1095
+
1096
+
1097
+ def deprecated_tensor_sub(input, y):
1098
+ if isinstance(y, COOTensor):
1099
+ return F.tensor_scatter_sub(input, y.indices, y.values)
1100
+ if isinstance(input, (tuple, list)):
1101
+ input = sequence_to_tensor(input, F.dtype(y))
1102
+ if isinstance(y, (tuple, list)):
1103
+ y = sequence_to_tensor(y, F.dtype(input))
1104
+ return sub(input, y)
1105
+
1106
+
1107
+ def deprecated_tensor_sub_(input, y):
1108
+ if isinstance(y, COOTensor):
1109
+ return F.tensor_scatter_sub(input, y.indices, y.values)
1110
+ if isinstance(input, (tuple, list)):
1111
+ input = sequence_to_tensor(input, F.dtype(y))
1112
+ if isinstance(y, (tuple, list)):
1113
+ y = sequence_to_tensor(y, F.dtype(input))
1114
+ return sub(input, y)
1115
+
1116
+
1117
+ # 104 sum
1118
+ def tensor_sum_ext(input, dim=None, keepdim=False, *, dtype=None):
1119
+ return sum(input, dim, keepdim, dtype=dtype)
1120
+
1121
+
1122
+ def deprecated_tensor_sum(input, axis=None, dtype=None, keepdims=False, initial=None):
1123
+ if initial is None:
1124
+ res = sum(input, axis, keepdims, dtype=dtype)
1125
+ else:
1126
+ res = sum(input, axis, keepdims, dtype=dtype) + initial
1127
+ if dtype is not None and (dtype == mstype.bool_):
1128
+ res = res.astype(mstype.bool_)
1129
+ return res
1130
+
1131
+
1132
+ # 105 swapaxes
1133
+
1134
+ # 106 t
1135
+ def tensor_t(input):
1136
+ return t(input)
1137
+
1138
+
1139
+ def deprecated_tensor_t(input):
1140
+ r"""
1141
+ For details, please refer to :func:`mindspore.ops.t`.
1142
+ """
1143
+ return t(input)
1144
+
1145
+
1146
+ # 107 tanh
1147
+ def tensor_tanh(input):
1148
+ return tanh(input)
1149
+
1150
+
1151
+ # 108 tile
1152
+ def tensor_tile(input, dims):
1153
+ return tile(input, dims)
1154
+
1155
+
1156
+ def deprecated_tensor_tile(input, reps):
1157
+ return tile(input, reps)
1158
+
1159
+
1160
+ # 109 tolist
1161
+
1162
+ # 110 topk
1163
+ def tensor_topk(input, k, dim=-1, largest=True, sorted=True):
1164
+ return topk(input, k, dim, largest, sorted)
1165
+
1166
+
1167
+ def deprecated_tensor_topk(input, k, dim=None, largest=True, sorted=True):
1168
+ return topk(input, k, dim, largest, sorted)
1169
+
1170
+
1171
+ # 111 transpose
1172
+ def tensor_transpose_ext(input, dim0, dim1):
1173
+ return transpose_ext_view(input, dim0, dim1)
1174
+
1175
+
1176
+ def deprecated_tensor_transpose(input, *axes):
1177
+ perm = validator.check_transpose_axis(axes, input.ndim)
1178
+ return transpose(input, perm)
1179
+
1180
+
1181
+ # 112 tril
1182
+ def deprecated_tensor_tril(input, diagonal=0):
1183
+ return tril(input, diagonal)
1184
+
1185
+
1186
+ # 113 trunc
1187
+ def tensor_trunc(input):
1188
+ return F.trunc(input)
1189
+
1190
+
1191
+ # 114 type
1192
+
1193
+ # 115 type_as
1194
+ def deprecated_tensor_type_as(input, other):
1195
+ return input.astype(other.dtype)
1196
+
1197
+
1198
+ # 116 unbind
1199
+ def deprecated_tensor_unbind(input, dim=0):
1200
+ r"""
1201
+ For details, please refer to :func:`mindspore.ops.unbind`.
1202
+ """
1203
+ return F.unstack(input, dim)
1204
+
1205
+
1206
+ # 117 unfold
1207
+
1208
+ # 118 unique
1209
+ def deprecated_tensor_unique(input, sorted=True, return_inverse=False, return_counts=False, dim=None):
1210
+ """
1211
+ Function for computing the unique elements of a tensor along a specified dimension or over the entire tensor.
1212
+
1213
+ Args:
1214
+ input (Tensor): The input tensor from which to find unique elements.
1215
+ sorted (bool, optional): If True, the unique elements will be sorted. Default is True.
1216
+ return_inverse (bool, optional): Return the indices of the unique elements of the input tensor if true.
1217
+ return_counts (bool, optional): Return the count of each unique element of the input tensor if true.
1218
+ dim (int, optional): The dimension along which to find the unique elements.
1219
+
1220
+ Returns:
1221
+ Tensor or tuple:
1222
+ - If `return_inverse` is False and `return_counts` is False, returns a tensor of unique elements.
1223
+ - If `return_inverse` is True, returns a tuple (unique_elements, inverse_indices).
1224
+ - If `return_counts` is True, returns a tuple (unique_elements, counts).
1225
+ - If both `return_inverse` and `return_counts` are True,
1226
+ returns a tuple (unique_elements, inverse_indices, counts).
1227
+
1228
+ Raises:
1229
+ ValueError: If `return_inverse` or `return_counts` are mutable (non-constant).
1230
+ TypeError: If the `return_counts` argument is not a boolean when `dim` is specified.
1231
+ """
1232
+ if not F.isconstant(return_inverse) or not F.isconstant(return_counts):
1233
+ raise ValueError(
1234
+ f"For 'unique_ext', 'return_inverse' and 'return_counts' cannot be mutable")
1235
+ if dim is None:
1236
+ y, inverse_, counts = unique2_(
1237
+ input, sorted, return_inverse, return_counts)
1238
+ else:
1239
+ validator.check_value_type(
1240
+ "return_counts", return_counts, [bool], "unique_ext")
1241
+ y, inverse_, counts = unique_dim_(input, sorted, return_inverse, dim)
1242
+ if return_inverse and return_counts:
1243
+ return y, inverse_, counts
1244
+ if return_inverse:
1245
+ return y, inverse_
1246
+ if return_counts:
1247
+ return y, counts
1248
+ return y
1249
+
1250
+
1251
+ # 119 unsqeeze
1252
+
1253
+ # 120 view
1254
+
1255
+ # 121 contiguous
1256
+
1257
+ # 122 where
1258
+ def tensor_where(condition, input, other):
1259
+ return where_func(condition, input, other)
1260
+
1261
+
1262
+ def deprecated_tensor_where(input, condition, y):
1263
+ return where_func(condition, input, y)
1264
+
1265
+
1266
+ # 123 div_
1267
+
1268
+ # 124 fill_
1269
+ def tensor_inplace_fill_scalar_empty(input, value):
1270
+ raise ValueError("should not come here for fill_scalar method.")
1271
+
1272
+
1273
+ def tensor_inplace_fill_tensor_empty(input, value):
1274
+ raise ValueError("should not come here for fill_tensor method.")
1275
+
1276
+
1277
+ def tensor_inplace_fill_diagonal(input, fill_value, wrap=False):
1278
+ raise ValueError("should not come here for fill_diagonal method.")
1279
+
1280
+
1281
+ # 125 floor_
1282
+
1283
+ # 126 masked_fill_
1284
+ def tensor_inplace_masked_fill_scalar_empty(input, masked, value):
1285
+ raise ValueError("should not come here for masked_fill_scalar method.")
1286
+
1287
+
1288
+ def tensor_inplace_masked_fill_tensor_empty(input, masked, value):
1289
+ raise ValueError("should not come here for masked_fill_tensor method.")
1290
+
1291
+
1292
+ # 127 mul_
1293
+ def tensor_inplace_mul(input, other):
1294
+ return F.mul(input, other)
1295
+
1296
+ # 128 normal_
1297
+
1298
+ # 129 requires_grad_
1299
+
1300
+ # 130 sub_
1301
+
1302
+ # 131 uniform_
1303
+
1304
+ # 132 absolute
1305
+
1306
+ # 133 bincount
1307
+ def tensor_bincount(input, weights=None, minlength=0):
1308
+ return bincount(input, weights, minlength)
1309
+
1310
+
1311
+ def tensor_roll(input, shifts, dims=None):
1312
+ return roll(input, shifts, dims)
1313
+
1314
+ # 134 diff
1315
+
1316
+ # 135 double
1317
+
1318
+ # 136 lcm
1319
+
1320
+
1321
+ # 137 mm
1322
+ def tensor_mm(input, mat2):
1323
+ return F.mm(input, mat2)
1324
+
1325
+
1326
+ def deprecated_tensor_mm(input, mat2):
1327
+ return F.mm(input, mat2)
1328
+
1329
+
1330
+ # 138 ravel
1331
+
1332
+ # 139 nelement
1333
+
1334
+ # 140 stride
1335
+
1336
+ # 141 indices
1337
+
1338
+ # 142 view_as
1339
+ def tensor_view_as(input, other):
1340
+ shape = other.shape
1341
+ return reshape(input, shape)
1342
+
1343
+
1344
+ def deprecated_tensor_view_as(input, other):
1345
+ return view_as(input, other)
1346
+
1347
+
1348
+ # 143 values
1349
+
1350
+ # 144 index_copy
1351
+
1352
+ # 145 element_size
1353
+
1354
+ # 146 gcd
1355
+ def tensor_gcd(input, other):
1356
+ return gcd(input, other)
1357
+
1358
+
1359
+ # 147 isinf
1360
+ def tensor_isinf():
1361
+ return isinf()
1362
+
1363
+
1364
+ # 148 not_equal
1365
+ def tensor_not_equal(input, other):
1366
+ return F.ne(input, other)
1367
+
1368
+
1369
+ # 149 triu
1370
+ def tensor_triu(input, diagonal=0):
1371
+ return F.triu(input, diagonal)
1372
+
1373
+
1374
+ # 150 __eq__
1375
+
1376
+
1377
+ # 151 scatter_
1378
+ def tensor_inplace_scatter_src(input, dim, index, src):
1379
+ return inplace_scatter_src_op(input, dim, index, src)
1380
+
1381
+
1382
+ def tensor_inplace_scatter_src_reduce(input, dim, index, src, *, reduce):
1383
+ return inplace_scatter_src_reduce_op(input, dim, index, src, reduce=reduce)
1384
+
1385
+
1386
+ def tensor_inplace_scatter_value(input, dim, index, value):
1387
+ return inplace_scatter_value_op(input, dim, index, value)
1388
+
1389
+
1390
+ def tensor_inplace_scatter_value_reduce(input, dim, index, value, *, reduce):
1391
+ return inplace_scatter_value_reduce_op(input, dim, index, value, reduce=reduce)
1392
+
1393
+
1394
+ # 152 fmod
1395
+ def fmod_tensor(input, other):
1396
+ return fmod(input, other)
1397
+
1398
+
1399
+ def fmod_scalar(input, other):
1400
+ return fmod(input, other)
1401
+
1402
+
1403
+ def deprecated_tensor_fmod(input, other):
1404
+ return fmod(input, other)
1405
+
1406
+
1407
+ # 153 acos, arccos; acosh, arccosh; asin, arcsin; asinh, arcsinh; atan, arctanh, dot
1408
+ def tensor_acos(input):
1409
+ return acos_ext(input)
1410
+
1411
+
1412
+ def deprecated_tensor_acos(input):
1413
+ return F.acos(input)
1414
+
1415
+
1416
+ def tensor_acosh(input):
1417
+ return acosh_ext(input)
1418
+
1419
+
1420
+ def deprecated_tensor_acosh(input):
1421
+ return F.acosh(input)
1422
+
1423
+
1424
+ def tensor_asin(input):
1425
+ return asin_ext(input)
1426
+
1427
+
1428
+ def deprecated_tensor_asin(input):
1429
+ return F.asin(input)
1430
+
1431
+
1432
+ def tensor_asinh(input):
1433
+ return asinh_ext(input)
1434
+
1435
+
1436
+ def deprecated_tensor_asinh(input):
1437
+ return F.asinh(input)
1438
+
1439
+
1440
+ def tensor_atan(input):
1441
+ return atan_ext(input)
1442
+
1443
+
1444
+ def deprecated_tensor_atan(input):
1445
+ return F.atan(input)
1446
+
1447
+
1448
+ def tensor_atanh(input):
1449
+ return F.atanh(input)
1450
+
1451
+
1452
+ def tensor_copy_(input, src):
1453
+ raise ValueError("should not come here for copy_ method")
1454
+
1455
+
1456
+ def deprecated_tensor_copy_(input, src, non_blocking=False):
1457
+ return inplace_copy_op(input, src)
1458
+
1459
+
1460
+ def tensor_tan(input):
1461
+ return F.tan(input)
1462
+
1463
+
1464
+ def tensor_dot(input, other):
1465
+ return dot(input, other)
1466
+
1467
+
1468
+ def deprecated_tensor_dot(input, other):
1469
+ return F.dot(input, other)
1470
+
1471
+
1472
+ def deprecated_tensor_logsumexp(input, dim, keepdim=False):
1473
+ return F.logsumexp(input, dim, keepdim)
1474
+
1475
+
1476
+ # 154
1477
+ def tensor_isneginf(input):
1478
+ inf_tensor = isinf(input)
1479
+ neg_tensor = input < 0
1480
+ return logical_and(inf_tensor, neg_tensor)
1481
+
1482
+
1483
+ def deprecated_tensor_isneginf(input):
1484
+ inf_tensor = isinf(input)
1485
+ neg_tensor = input < 0
1486
+ return logical_and(inf_tensor, neg_tensor)
1487
+
1488
+
1489
+ # 155
1490
+ def deprecated_tensor_median(input, axis=-1, keepdims=False):
1491
+ return median(input, axis, keepdims)
1492
+
1493
+
1494
+ def tensor_median(input):
1495
+ return median(input)
1496
+
1497
+
1498
+ def tensor_median_dim(input, dim=-1, keepdim=False):
1499
+ return median(input, dim, keepdim)
1500
+
1501
+
1502
+ # 156
1503
+ def tensor_logaddexp2(input, other):
1504
+ return logaddexp2(input, other)
1505
+
1506
+
1507
+ def deprecated_tensor_logaddexp2(input, other):
1508
+ return F.logaddexp2(input, other)
1509
+
1510
+
1511
+ # 157
1512
+ def tensor_empty(*size, dtype=None, device=None):
1513
+ logger.error(
1514
+ "This is a function for empty not should be called. Please check the implementation.")
1515
+
1516
+
1517
+ def deprecated_tensor_logaddexp(input, other):
1518
+ return F.logaddexp(input, other)
1519
+
1520
+
1521
+ def tensor_xlogy(input, other):
1522
+ if isinstance(other, (float, int, bool)):
1523
+ other = F.scalar_to_tensor(other)
1524
+ return xlogy_op(input, other)
1525
+
1526
+
1527
+ # 158
1528
+
1529
+
1530
+ # 159 histc
1531
+ def tensor_histc(input, bins=100, min=0, max=0):
1532
+ return histc(input, bins, min, max)
1533
+
1534
+
1535
+ # 160 frac
1536
+ def tensor_frac(input):
1537
+ return frac(input)
1538
+
1539
+
1540
+ # 161 bitwise_not baddbmm bitwise_or bitwise_and bitwise_xor logical_xor
1541
+ def deprecated_baddbmm(input, batch1, batch2, *, beta=1, alpha=1):
1542
+ return F.baddbmm(input, batch1, batch2, beta=beta, alpha=alpha)
1543
+
1544
+
1545
+ def tensor_bitwise_not(input):
1546
+ return bitwise_not_op(input)
1547
+
1548
+
1549
+ def deprecated_bitwise_or(input, other):
1550
+ return bitwise_or(input, other)
1551
+
1552
+
1553
+ def deprecated_bitwise_and(input, other):
1554
+ return bitwise_and(input, other)
1555
+
1556
+
1557
+ def deprecated_bitwise_xor(input, other):
1558
+ return bitwise_xor(input, other)
1559
+
1560
+
1561
+ def tensor_logical_xor(input, other):
1562
+ return logical_xor_op(input, other)
1563
+
1564
+
1565
+ # 162
1566
+ def tensor_log10(input):
1567
+ return log10(input)
1568
+
1569
+
1570
+ # 186
1571
+ def deprecated_tensor_addcdiv(input, tensor1, tensor2, value=1):
1572
+ return addcdiv(input, tensor1, tensor2, value=value)
1573
+
1574
+
1575
+ def tensor_addcdiv_ext(input, tensor1, tensor2, *, value=1):
1576
+ return addcdiv_ext_op(input, tensor1, tensor2, value=value)
1577
+
1578
+
1579
+ # 501
1580
+ def tensor_addbmm(input, batch1, batch2, *, beta=1, alpha=1):
1581
+ return addbmm(input, batch1, batch2, beta=beta, alpha=alpha)
1582
+
1583
+
1584
+ def deprecated_tensor_addbmm(input, batch1, batch2, *, beta=1, alpha=1):
1585
+ r"""
1586
+ For details, please refer to :func:`mindspore.ops.addbmm`.
1587
+ """
1588
+ return addbmm(input, batch1, batch2, beta=beta, alpha=alpha)
1589
+
1590
+
1591
+ # 502
1592
+ def tensor_addmm(input, mat1, mat2, *, beta=1, alpha=1):
1593
+ return addmm(input, mat1, mat2, beta=beta, alpha=alpha)
1594
+
1595
+
1596
+ def deprecated_tensor_addmm(input, mat1, mat2, *, beta=1, alpha=1):
1597
+ r"""
1598
+ For details, please refer to :func:`mindspore.ops.addmm`.
1599
+ """
1600
+ return addmm(input, mat1, mat2, beta=beta, alpha=alpha)
1601
+
1602
+
1603
+ # 543
1604
+ def tensor_put_(input, index, source, accumulate=False):
1605
+ raise RuntimeError(f"There is no branch to go function tensor_put_!")
1606
+
1607
+
1608
+ # 790
1609
+ def tensor_addmv(input, mat, vec, *, beta=1, alpha=1):
1610
+ return addmv(input, mat, vec, beta=beta, alpha=alpha)
1611
+
1612
+
1613
+ def deprecated_tensor_addmv(input, mat, vec, beta=1, alpha=1):
1614
+ r"""
1615
+ For details, please refer to :func:`mindspore.ops.addmv`.
1616
+ """
1617
+ return addmv(input, mat, vec, beta=beta, alpha=alpha)
1618
+
1619
+
1620
+ # 846
1621
+ def deprecated_tensor_count_nonzero(input,
1622
+ axis=(),
1623
+ keep_dims=False,
1624
+ dtype=None):
1625
+ if dtype is None:
1626
+ return count_nonzero(input,
1627
+ axis=axis,
1628
+ keep_dims=keep_dims,
1629
+ dtype=mstype.int32)
1630
+ return count_nonzero(input, axis=axis, keep_dims=keep_dims, dtype=dtype)
1631
+
1632
+
1633
+ # 732
1634
+ def tensor_take(input, index):
1635
+ return deprecated_tensor_take(input, index)
1636
+
1637
+
1638
+ def deprecated_tensor_take(x, indices, axis=None, mode='clip'):
1639
+ """
1640
+ Takes elements from a tensor along an axis.
1641
+ """
1642
+ if mode not in ('raise', 'wrap', 'clip'):
1643
+ raise ValueError(f"For 'Tensor.take', the argument 'mode' should be one of in ['raise', 'wrap', 'clip'],"
1644
+ f" but got {mode}.")
1645
+ if axis is None:
1646
+ a = x.ravel()
1647
+ axis = 0
1648
+ else:
1649
+ a = x
1650
+ ndim = a.ndim
1651
+ axis = check_axis_in_range(axis, ndim)
1652
+
1653
+ shape_a = a.shape
1654
+ shape_indices = indices.shape
1655
+ size_indices = indices.size
1656
+ indices = compile_utils.check_indices(shape_a[axis], indices, mode)
1657
+
1658
+ # reshapes indices to shape (Ni..., Nj..., Nk)
1659
+ shape_ni = tuple_slice(shape_a, None, axis)
1660
+ shape_nk = tuple_slice(shape_a, axis + 1, None)
1661
+ shape_out = shape_ni + shape_indices + shape_nk
1662
+ shape_indices = expanded_shape(ndim, size_indices, axis)
1663
+ indices = indices.reshape(shape_indices)
1664
+ shape_indices = shape_ni + (indices.size,) + shape_nk
1665
+ indices = F.broadcast_to(indices, shape_indices)
1666
+
1667
+ res = F.gather_d(a, axis, indices)
1668
+ return res.reshape(shape_out)
1669
+
1670
+
1671
+ def tensor_clone(input):
1672
+ return clone(input)
1673
+
1674
+
1675
+ def tensor_new_ones(input, size, dtype=None):
1676
+ return new_ones(input, size, dtype=dtype)
1677
+
1678
+
1679
+ def tensor_new_zeros(input, size, dtype=None):
1680
+ return new_zeros(input, size, dtype=dtype)
1681
+
1682
+
1683
+ def tensor_cosh(input):
1684
+ return cosh(input)
1685
+
1686
+
1687
+ def tensor_sinh(input):
1688
+ return sinh(input)
1689
+
1690
+
1691
+ def tensor_sinc(input):
1692
+ return sinc(input)
1693
+
1694
+
1695
+ def tensor_unsqueeze(input, dim):
1696
+ return
1697
+
1698
+
1699
+ def deprecated_tensor_unsqueeze(input, dim):
1700
+ return unsqueeze(input, dim)
1701
+
1702
+
1703
+ # 204 erfc
1704
+ def tensor_erfc(input):
1705
+ return erfc(input)
1706
+
1707
+
1708
+ # 207 expm1
1709
+ def tensor_expm1(input):
1710
+ return expm1(input)
1711
+
1712
+
1713
+ # 880
1714
+ def tensor_lerp(input, end, weight):
1715
+ return lerp(input, end, weight)
1716
+
1717
+
1718
+ def tensor_lerp_scalar(input, end, weight):
1719
+ return lerp_scalar(input, end, weight)
1720
+
1721
+
1722
+ # 220 hardshrink
1723
+ def tensor_hardshrink(input, lambd=0.5):
1724
+ return hardshrink(input, lambd)
1725
+
1726
+
1727
+ # 931
1728
+ def deprecated_tensor_nansum(input, axis=(), keepdims=False, *, dtype=None):
1729
+ return nansum(input, axis, keepdims, dtype=dtype)
1730
+
1731
+
1732
+ # 244 log1p
1733
+ def tensor_log1p(input):
1734
+ return log1p(input)
1735
+
1736
+
1737
+ def tensor_diag(input, diagonal=0):
1738
+ if diagonal != 0:
1739
+ raise ValueError(f"For 'Tensor.diag', the argument 'diagonal' should be '0', but got {diagonal}.")
1740
+ return F.diag(input)
1741
+
1742
+
1743
+ def deprecated_tensor_diag(input):
1744
+ return F.diag(input)
1745
+
1746
+
1747
+ # 916 index_add
1748
+ @constexpr
1749
+ def _check_index_add_alpha(alpha):
1750
+ check_is_number(alpha, (int, float))
1751
+
1752
+
1753
+ def tensor_index_add(input, dim, index, source, *, alpha=1):
1754
+ _check_index_add_alpha(alpha)
1755
+ source = source * alpha
1756
+ return F.index_add(input, indices=index, y=source, axis=dim)
1757
+
1758
+
1759
+ def deprecated_tensor_index_add(input, indices, y, axis, use_lock=True, check_index_bound=True):
1760
+ return F.index_add(input, indices, y, axis, use_lock, check_index_bound)
1761
+
1762
+
1763
+ # 1028
1764
+ def tensor_var(input, dim=None, *, correction=1, keepdim=False):
1765
+ return var_ext(input, dim, correction=correction, keepdim=keepdim)
1766
+
1767
+
1768
+ def deprecated_tensor_var(input, axis=None, ddof=0, keepdims=False):
1769
+ r"""
1770
+ For details, please refer to :func:`mindspore.ops.var`.
1771
+ """
1772
+ if 0 in input.shape:
1773
+ return Tensor(float('nan'), input.dtype)
1774
+ if not isinstance(ddof, int):
1775
+ raise TypeError("For 'Tensor.var', the type of the argument 'ddof' must be int, but got "
1776
+ "{}.".format(type(ddof)))
1777
+ if not isinstance(keepdims, bool):
1778
+ raise TypeError("For 'Tensor.var', the type of the argument 'keepdims' must be bool, but "
1779
+ "got {}.".format(type(keepdims)))
1780
+
1781
+ if axis is None:
1782
+ axis = ()
1783
+ else:
1784
+ axis = validator.check_and_canonicalize_axes(axis, input.ndim)
1785
+ x_mean = mean(input, axis, True)
1786
+ x_sub = _tensor_sub(input, x_mean)
1787
+ x_pow = _tensor_pow(x_sub, 2)
1788
+ x_sum = P.ReduceSum(bool(keepdims))(x_pow, axis)
1789
+ nums = 1
1790
+ if axis == ():
1791
+ nums = input.size
1792
+ else:
1793
+ for ax in axis:
1794
+ nums *= input.shape[ax]
1795
+ return _tensor_div(x_sum, nums - ddof)
1796
+
1797
+
1798
+ def tensor_kthvalue(input, k, dim=-1, keepdim=False):
1799
+ raise ValueError("should not come here for kthvalue py_method.")
1800
+
1801
+
1802
+ def tensor_sub_empty_(input, other, alpha=1):
1803
+ raise ValueError("should not come here for sub_ method.")
1804
+
1805
+
1806
+ def tensor_inplace_sub(input, other, *, alpha=1):
1807
+ if alpha == 1:
1808
+ return sub(input, other)
1809
+ return sub_ext(input, other, alpha=alpha)
1810
+
1811
+
1812
+ def tensor_div_empty_(input, other, rounding_mode=None):
1813
+ raise ValueError("should not come here for div_ method.")
1814
+
1815
+
1816
+ def tensor_subtract(input, other, *, alpha=1):
1817
+ return tensor_sub_ext(input, other, alpha=alpha)
1818
+
1819
+
1820
+ def tensor_true_divide(input, other):
1821
+ return div(input, other)
1822
+
1823
+
1824
+ def all_gather_matmul(
1825
+ input,
1826
+ x2,
1827
+ group,
1828
+ world_size,
1829
+ *,
1830
+ bias=None,
1831
+ gather_index=0,
1832
+ gather_output=True,
1833
+ comm_turn=0,
1834
+ trans_input=False,
1835
+ trans_x2=False,
1836
+ ):
1837
+ """
1838
+ For details, please refer to :func:`mindspore.ops.all_gather_matmul`.
1839
+ """
1840
+ raise NotImplementedError('all_gather_matmul only supports Ascend.')
1841
+
1842
+
1843
+ def tensor_floor_divide_(input, other):
1844
+ return _tensor_floordiv(input, other)
1845
+
1846
+
1847
+ def matmul_reduce_scatter(
1848
+ input,
1849
+ x2,
1850
+ group,
1851
+ world_size,
1852
+ *,
1853
+ reduce_op=ops.ReduceOp.SUM,
1854
+ bias=None,
1855
+ comm_turn=0,
1856
+ trans_input=False,
1857
+ trans_x2=False,
1858
+ ):
1859
+ """
1860
+ For details, please refer to :func:`mindspore.ops.matmul_reduce_scatter`.
1861
+ """
1862
+ raise NotImplementedError('matmul_reduce_scatter only supports Ascend.')
1863
+
1864
+
1865
+ # 1030
1866
+ def tensor_log_(input):
1867
+ return inplace_log_op(input)
1868
+
1869
+
1870
+ def tensor_floor_div(input, other):
1871
+ return floor_div_op(input, other)
1872
+
1873
+
1874
+ def tensor_floor_div_scalar(input, other):
1875
+ return floor_div_scalar_op(input, other)
1876
+
1877
+
1878
+ # 1029
1879
+ def tensor_exp_(input):
1880
+ return inplace_exp_op(input)
1881
+
1882
+
1883
+ def tensor_gelu(input, *, approximate):
1884
+ return gelu(input, approximate)
1885
+
1886
+
1887
+ def deprecated_pixel_shuffle(input, upscale_factor):
1888
+ return F.pixel_shuffle(input, upscale_factor)
1889
+
1890
+
1891
+ def tensor_gmm(x, weight, *, bias=None, group_list=None, group_type=0, group_list_type=0):
1892
+ raise NotImplementedError("gmm has not been implemented by python.")
1893
+
1894
+ def raise_func(*args, **kwargs):
1895
+ raise NotImplementedError("this func has not been implemented.")