mindspore 2.3.0__cp310-cp310-win_amd64.whl → 2.4.0__cp310-cp310-win_amd64.whl

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

Potentially problematic release.


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

Files changed (308) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
  3. mindspore/Newtonsoft.Json.dll +0 -0
  4. mindspore/__init__.py +3 -1
  5. mindspore/_c_dataengine.cp310-win_amd64.pyd +0 -0
  6. mindspore/_c_expression.cp310-win_amd64.pyd +0 -0
  7. mindspore/_c_mindrecord.cp310-win_amd64.pyd +0 -0
  8. mindspore/_checkparam.py +50 -9
  9. mindspore/_extends/parse/compile_config.py +41 -0
  10. mindspore/_extends/parse/parser.py +9 -7
  11. mindspore/_extends/parse/standard_method.py +52 -14
  12. mindspore/_extends/pijit/pijit_func_white_list.py +350 -24
  13. mindspore/amp.py +24 -10
  14. mindspore/atlprov.dll +0 -0
  15. mindspore/avcodec-59.dll +0 -0
  16. mindspore/avdevice-59.dll +0 -0
  17. mindspore/avfilter-8.dll +0 -0
  18. mindspore/avformat-59.dll +0 -0
  19. mindspore/avutil-57.dll +0 -0
  20. mindspore/c1.dll +0 -0
  21. mindspore/c1xx.dll +0 -0
  22. mindspore/c2.dll +0 -0
  23. mindspore/common/__init__.py +6 -4
  24. mindspore/common/_pijit_context.py +190 -0
  25. mindspore/common/_register_for_tensor.py +2 -1
  26. mindspore/common/_tensor_overload.py +139 -0
  27. mindspore/common/api.py +102 -87
  28. mindspore/common/dump.py +5 -6
  29. mindspore/common/generator.py +1 -7
  30. mindspore/common/hook_handle.py +14 -26
  31. mindspore/common/mindir_util.py +2 -2
  32. mindspore/common/parameter.py +46 -13
  33. mindspore/common/recompute.py +39 -9
  34. mindspore/common/sparse_tensor.py +7 -3
  35. mindspore/common/tensor.py +209 -29
  36. mindspore/communication/__init__.py +1 -1
  37. mindspore/communication/_comm_helper.py +38 -3
  38. mindspore/communication/comm_func.py +310 -55
  39. mindspore/communication/management.py +14 -14
  40. mindspore/context.py +123 -22
  41. mindspore/dataset/__init__.py +1 -1
  42. mindspore/dataset/audio/__init__.py +1 -1
  43. mindspore/dataset/core/config.py +7 -0
  44. mindspore/dataset/core/validator_helpers.py +7 -0
  45. mindspore/dataset/engine/cache_client.py +1 -1
  46. mindspore/dataset/engine/datasets.py +72 -44
  47. mindspore/dataset/engine/datasets_audio.py +7 -7
  48. mindspore/dataset/engine/datasets_standard_format.py +53 -3
  49. mindspore/dataset/engine/datasets_text.py +20 -20
  50. mindspore/dataset/engine/datasets_user_defined.py +174 -104
  51. mindspore/dataset/engine/datasets_vision.py +33 -33
  52. mindspore/dataset/engine/iterators.py +29 -0
  53. mindspore/dataset/engine/obs/util.py +7 -0
  54. mindspore/dataset/engine/queue.py +114 -60
  55. mindspore/dataset/engine/serializer_deserializer.py +2 -2
  56. mindspore/dataset/engine/validators.py +34 -14
  57. mindspore/dataset/text/__init__.py +1 -4
  58. mindspore/dataset/transforms/__init__.py +0 -3
  59. mindspore/dataset/utils/line_reader.py +2 -0
  60. mindspore/dataset/vision/__init__.py +1 -4
  61. mindspore/dataset/vision/utils.py +1 -1
  62. mindspore/dataset/vision/validators.py +2 -1
  63. mindspore/dnnl.dll +0 -0
  64. mindspore/dpcmi.dll +0 -0
  65. mindspore/{nn/extend → experimental/es}/__init__.py +4 -11
  66. mindspore/experimental/es/embedding_service.py +883 -0
  67. mindspore/{nn/layer → experimental/es}/embedding_service_layer.py +218 -30
  68. mindspore/experimental/llm_boost/__init__.py +21 -0
  69. mindspore/{nn/extend/layer → experimental/llm_boost/atb}/__init__.py +4 -8
  70. mindspore/experimental/llm_boost/atb/boost_base.py +211 -0
  71. mindspore/experimental/llm_boost/atb/llama_boost.py +115 -0
  72. mindspore/experimental/llm_boost/atb/qwen_boost.py +101 -0
  73. mindspore/experimental/llm_boost/register.py +129 -0
  74. mindspore/experimental/llm_boost/utils.py +31 -0
  75. mindspore/experimental/optim/adamw.py +85 -0
  76. mindspore/experimental/optim/optimizer.py +3 -0
  77. mindspore/hal/__init__.py +3 -3
  78. mindspore/hal/contiguous_tensors_handle.py +175 -0
  79. mindspore/hal/stream.py +18 -0
  80. mindspore/include/api/model_group.h +13 -1
  81. mindspore/include/api/types.h +10 -10
  82. mindspore/include/dataset/config.h +2 -2
  83. mindspore/include/dataset/constants.h +2 -2
  84. mindspore/include/dataset/execute.h +2 -2
  85. mindspore/include/dataset/vision.h +4 -0
  86. mindspore/jpeg62.dll +0 -0
  87. mindspore/log.py +1 -1
  88. mindspore/mindrecord/filewriter.py +68 -51
  89. mindspore/mindspore_backend.dll +0 -0
  90. mindspore/mindspore_common.dll +0 -0
  91. mindspore/mindspore_core.dll +0 -0
  92. mindspore/mindspore_glog.dll +0 -0
  93. mindspore/mindspore_np_dtype.dll +0 -0
  94. mindspore/mindspore_ops.dll +0 -0
  95. mindspore/mint/__init__.py +495 -46
  96. mindspore/mint/distributed/__init__.py +31 -0
  97. mindspore/mint/distributed/distributed.py +254 -0
  98. mindspore/mint/nn/__init__.py +266 -21
  99. mindspore/mint/nn/functional.py +125 -19
  100. mindspore/mint/nn/layer/__init__.py +39 -0
  101. mindspore/mint/nn/layer/activation.py +133 -0
  102. mindspore/mint/nn/layer/normalization.py +477 -0
  103. mindspore/mint/nn/layer/pooling.py +110 -0
  104. mindspore/mint/optim/adamw.py +28 -7
  105. mindspore/mint/special/__init__.py +63 -0
  106. mindspore/msobj140.dll +0 -0
  107. mindspore/mspdb140.dll +0 -0
  108. mindspore/mspdbcore.dll +0 -0
  109. mindspore/mspdbst.dll +0 -0
  110. mindspore/mspft140.dll +0 -0
  111. mindspore/msvcdis140.dll +0 -0
  112. mindspore/msvcp140_1.dll +0 -0
  113. mindspore/msvcp140_2.dll +0 -0
  114. mindspore/msvcp140_atomic_wait.dll +0 -0
  115. mindspore/msvcp140_codecvt_ids.dll +0 -0
  116. mindspore/multiprocessing/__init__.py +2 -1
  117. mindspore/nn/__init__.py +0 -1
  118. mindspore/nn/cell.py +275 -93
  119. mindspore/nn/layer/activation.py +211 -44
  120. mindspore/nn/layer/basic.py +113 -3
  121. mindspore/nn/layer/embedding.py +120 -2
  122. mindspore/nn/layer/normalization.py +101 -5
  123. mindspore/nn/layer/padding.py +34 -48
  124. mindspore/nn/layer/pooling.py +161 -7
  125. mindspore/nn/layer/transformer.py +3 -3
  126. mindspore/nn/loss/__init__.py +2 -2
  127. mindspore/nn/loss/loss.py +84 -6
  128. mindspore/nn/optim/__init__.py +2 -1
  129. mindspore/nn/optim/adadelta.py +1 -1
  130. mindspore/nn/optim/adam.py +1 -1
  131. mindspore/nn/optim/lamb.py +1 -1
  132. mindspore/nn/optim/tft_wrapper.py +127 -0
  133. mindspore/nn/wrap/cell_wrapper.py +12 -23
  134. mindspore/nn/wrap/grad_reducer.py +5 -5
  135. mindspore/nn/wrap/loss_scale.py +17 -3
  136. mindspore/numpy/__init__.py +1 -1
  137. mindspore/numpy/array_creations.py +65 -68
  138. mindspore/numpy/array_ops.py +64 -60
  139. mindspore/numpy/fft.py +610 -75
  140. mindspore/numpy/logic_ops.py +11 -10
  141. mindspore/numpy/math_ops.py +85 -84
  142. mindspore/numpy/utils_const.py +4 -4
  143. mindspore/opencv_core452.dll +0 -0
  144. mindspore/opencv_imgcodecs452.dll +0 -0
  145. mindspore/opencv_imgproc452.dll +0 -0
  146. mindspore/ops/__init__.py +6 -4
  147. mindspore/ops/_grad_experimental/grad_comm_ops.py +47 -3
  148. mindspore/ops/_grad_experimental/grad_math_ops.py +0 -22
  149. mindspore/ops/_vmap/vmap_array_ops.py +2 -4
  150. mindspore/ops/_vmap/vmap_math_ops.py +17 -1
  151. mindspore/ops/_vmap/vmap_nn_ops.py +43 -2
  152. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +85 -7
  153. mindspore/ops/auto_generate/gen_arg_dtype_cast.py +2 -0
  154. mindspore/ops/auto_generate/gen_extend_func.py +734 -13
  155. mindspore/ops/auto_generate/gen_ops_def.py +2420 -381
  156. mindspore/ops/auto_generate/gen_ops_prim.py +5196 -1659
  157. mindspore/ops/auto_generate/pyboost_inner_prim.py +176 -56
  158. mindspore/ops/composite/base.py +85 -48
  159. mindspore/ops/composite/multitype_ops/_compile_utils.py +1 -0
  160. mindspore/ops/composite/multitype_ops/not_in_impl.py +2 -2
  161. mindspore/ops/function/__init__.py +22 -0
  162. mindspore/ops/function/array_func.py +490 -153
  163. mindspore/ops/function/debug_func.py +113 -1
  164. mindspore/ops/function/fft_func.py +15 -2
  165. mindspore/ops/function/grad/grad_func.py +3 -2
  166. mindspore/ops/function/math_func.py +558 -207
  167. mindspore/ops/function/nn_func.py +817 -383
  168. mindspore/ops/function/other_func.py +3 -2
  169. mindspore/ops/function/random_func.py +184 -8
  170. mindspore/ops/function/reshard_func.py +13 -11
  171. mindspore/ops/function/sparse_unary_func.py +1 -1
  172. mindspore/ops/function/vmap_func.py +3 -2
  173. mindspore/ops/functional.py +24 -14
  174. mindspore/ops/op_info_register.py +3 -3
  175. mindspore/ops/operations/__init__.py +6 -1
  176. mindspore/ops/operations/_grad_ops.py +2 -76
  177. mindspore/ops/operations/_infer_ops.py +1 -1
  178. mindspore/ops/operations/_inner_ops.py +71 -94
  179. mindspore/ops/operations/array_ops.py +12 -146
  180. mindspore/ops/operations/comm_ops.py +42 -53
  181. mindspore/ops/operations/custom_ops.py +83 -19
  182. mindspore/ops/operations/debug_ops.py +42 -10
  183. mindspore/ops/operations/manually_defined/_inner.py +12 -0
  184. mindspore/ops/operations/manually_defined/ops_def.py +265 -10
  185. mindspore/ops/operations/math_ops.py +12 -223
  186. mindspore/ops/operations/nn_ops.py +20 -114
  187. mindspore/ops/operations/other_ops.py +7 -4
  188. mindspore/ops/operations/random_ops.py +46 -1
  189. mindspore/ops/primitive.py +18 -6
  190. mindspore/ops_generate/arg_dtype_cast.py +2 -0
  191. mindspore/ops_generate/gen_aclnn_implement.py +11 -11
  192. mindspore/ops_generate/gen_constants.py +36 -0
  193. mindspore/ops_generate/gen_ops.py +67 -52
  194. mindspore/ops_generate/gen_ops_inner_prim.py +1 -1
  195. mindspore/ops_generate/gen_pyboost_func.py +131 -47
  196. mindspore/ops_generate/op_proto.py +10 -3
  197. mindspore/ops_generate/pyboost_utils.py +14 -1
  198. mindspore/ops_generate/template.py +43 -21
  199. mindspore/parallel/__init__.py +3 -1
  200. mindspore/parallel/_auto_parallel_context.py +28 -8
  201. mindspore/parallel/_cell_wrapper.py +83 -0
  202. mindspore/parallel/_parallel_serialization.py +47 -19
  203. mindspore/parallel/_tensor.py +81 -11
  204. mindspore/parallel/_utils.py +13 -1
  205. mindspore/parallel/algo_parameter_config.py +5 -5
  206. mindspore/parallel/checkpoint_transform.py +46 -39
  207. mindspore/parallel/cluster/process_entity/__init__.py +1 -1
  208. mindspore/parallel/cluster/process_entity/_api.py +31 -23
  209. mindspore/parallel/cluster/process_entity/_utils.py +2 -27
  210. mindspore/parallel/parameter_broadcast.py +3 -4
  211. mindspore/parallel/shard.py +162 -31
  212. mindspore/parallel/transform_safetensors.py +993 -0
  213. mindspore/pgodb140.dll +0 -0
  214. mindspore/pgort140.dll +0 -0
  215. mindspore/profiler/__init__.py +2 -1
  216. mindspore/profiler/common/constant.py +29 -0
  217. mindspore/profiler/common/registry.py +47 -0
  218. mindspore/profiler/common/util.py +28 -0
  219. mindspore/profiler/dynamic_profiler.py +694 -0
  220. mindspore/profiler/envprofiling.py +17 -19
  221. mindspore/profiler/parser/ascend_analysis/constant.py +18 -0
  222. mindspore/profiler/parser/ascend_analysis/file_manager.py +25 -4
  223. mindspore/profiler/parser/ascend_analysis/function_event.py +43 -19
  224. mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +31 -26
  225. mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +56 -10
  226. mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +55 -8
  227. mindspore/profiler/parser/ascend_analysis/path_manager.py +313 -0
  228. mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +27 -20
  229. mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +9 -2
  230. mindspore/profiler/parser/ascend_msprof_exporter.py +5 -4
  231. mindspore/profiler/parser/ascend_timeline_generator.py +27 -25
  232. mindspore/profiler/parser/base_timeline_generator.py +19 -25
  233. mindspore/profiler/parser/cpu_gpu_timeline_generator.py +25 -12
  234. mindspore/profiler/parser/framework_parser.py +1 -391
  235. mindspore/profiler/parser/gpu_analysis/__init__.py +14 -0
  236. mindspore/profiler/parser/gpu_analysis/function_event.py +44 -0
  237. mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +89 -0
  238. mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +72 -0
  239. mindspore/profiler/parser/memory_usage_parser.py +0 -154
  240. mindspore/profiler/parser/profiler_info.py +78 -6
  241. mindspore/profiler/profiler.py +153 -0
  242. mindspore/profiler/profiling.py +280 -412
  243. mindspore/rewrite/__init__.py +1 -2
  244. mindspore/rewrite/common/namespace.py +4 -4
  245. mindspore/rewrite/symbol_tree/symbol_tree.py +3 -3
  246. mindspore/run_check/_check_version.py +36 -103
  247. mindspore/safeguard/rewrite_obfuscation.py +591 -247
  248. mindspore/swresample-4.dll +0 -0
  249. mindspore/swscale-6.dll +0 -0
  250. mindspore/tbbmalloc.dll +0 -0
  251. mindspore/tinyxml2.dll +0 -0
  252. mindspore/train/__init__.py +4 -3
  253. mindspore/train/_utils.py +28 -2
  254. mindspore/train/amp.py +171 -53
  255. mindspore/train/callback/__init__.py +2 -2
  256. mindspore/train/callback/_callback.py +4 -4
  257. mindspore/train/callback/_checkpoint.py +85 -22
  258. mindspore/train/callback/_cluster_monitor.py +1 -1
  259. mindspore/train/callback/_flops_collector.py +1 -0
  260. mindspore/train/callback/_loss_monitor.py +3 -3
  261. mindspore/train/callback/_on_request_exit.py +134 -31
  262. mindspore/train/callback/_summary_collector.py +5 -5
  263. mindspore/train/callback/_tft_register.py +352 -0
  264. mindspore/train/dataset_helper.py +7 -3
  265. mindspore/train/metrics/metric.py +3 -3
  266. mindspore/train/metrics/roc.py +4 -4
  267. mindspore/train/mind_ir_pb2.py +44 -39
  268. mindspore/train/model.py +134 -58
  269. mindspore/train/serialization.py +336 -112
  270. mindspore/turbojpeg.dll +0 -0
  271. mindspore/utils/__init__.py +21 -0
  272. mindspore/utils/utils.py +60 -0
  273. mindspore/vcmeta.dll +0 -0
  274. mindspore/vcruntime140.dll +0 -0
  275. mindspore/vcruntime140_1.dll +0 -0
  276. mindspore/version.py +1 -1
  277. {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/METADATA +6 -2
  278. {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/RECORD +281 -275
  279. mindspore/include/c_api/ms/abstract.h +0 -67
  280. mindspore/include/c_api/ms/attribute.h +0 -197
  281. mindspore/include/c_api/ms/base/handle_types.h +0 -43
  282. mindspore/include/c_api/ms/base/macros.h +0 -32
  283. mindspore/include/c_api/ms/base/status.h +0 -33
  284. mindspore/include/c_api/ms/base/types.h +0 -283
  285. mindspore/include/c_api/ms/context.h +0 -102
  286. mindspore/include/c_api/ms/graph.h +0 -160
  287. mindspore/include/c_api/ms/node.h +0 -606
  288. mindspore/include/c_api/ms/tensor.h +0 -161
  289. mindspore/include/c_api/ms/value.h +0 -84
  290. mindspore/mindspore_shared_lib.dll +0 -0
  291. mindspore/nn/extend/basic.py +0 -140
  292. mindspore/nn/extend/embedding.py +0 -143
  293. mindspore/nn/extend/layer/normalization.py +0 -109
  294. mindspore/nn/extend/pooling.py +0 -117
  295. mindspore/nn/layer/embedding_service.py +0 -531
  296. mindspore/ops/_op_impl/aicpu/strided_slice_v2.py +0 -93
  297. mindspore/ops/_op_impl/aicpu/strided_slice_v2_grad.py +0 -66
  298. mindspore/ops/extend/__init__.py +0 -53
  299. mindspore/ops/extend/array_func.py +0 -218
  300. mindspore/ops/extend/math_func.py +0 -76
  301. mindspore/ops/extend/nn_func.py +0 -308
  302. mindspore/ops/silent_check.py +0 -162
  303. mindspore/profiler/parser/msadvisor_analyzer.py +0 -82
  304. mindspore/profiler/parser/msadvisor_parser.py +0 -240
  305. mindspore/train/callback/_mindio_ttp.py +0 -443
  306. {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/WHEEL +0 -0
  307. {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/entry_points.txt +0 -0
  308. {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/top_level.txt +0 -0
@@ -14,7 +14,7 @@
14
14
  # ============================================================================
15
15
  """Defines other operators with functional form."""
16
16
  from mindspore.ops import operations as P
17
-
17
+ from mindspore.ops.auto_generate import rotary_position_embedding
18
18
 
19
19
  partial_ = P.Partial()
20
20
  depend_ = P.Depend()
@@ -109,6 +109,7 @@ def depend(value, expr):
109
109
 
110
110
  __all__ = [
111
111
  'depend',
112
- 'partial'
112
+ 'partial',
113
+ 'rotary_position_embedding'
113
114
  ]
114
115
  __all__.sort()
@@ -30,7 +30,7 @@ from mindspore.common.api import _function_forbid_reuse
30
30
  from mindspore.ops.auto_generate import randperm
31
31
  from mindspore.common.generator import default_generator
32
32
  from mindspore.ops.auto_generate import UniformExt, NormalTensorTensor, \
33
- NormalTensorFloat, NormalFloatTensor, NormalFloatFloat, RandExt, RandLikeExt
33
+ NormalTensorFloat, NormalFloatTensor, NormalFloatFloat, RandExt, RandLikeExt, MultinomialExt
34
34
 
35
35
  normal_tensor_tensor_op = NormalTensorTensor()
36
36
  normal_tensor_float_op = NormalTensorFloat()
@@ -45,6 +45,7 @@ top_k_ = P.TopK()
45
45
  uniform_ = UniformExt()
46
46
  rand_ext_ = RandExt()
47
47
  rand_like_ext_ = RandLikeExt()
48
+ multinomial_ext_ = MultinomialExt()
48
49
  generator_step_ = Tensor(10, mstype.int64)
49
50
 
50
51
 
@@ -116,14 +117,18 @@ def standard_laplace(shape, seed=None):
116
117
  .. math::
117
118
  \text{f}(x) = \frac{1}{2}\exp(-|x|)
118
119
 
120
+ .. warning::
121
+ The Ascend backend does not support the reproducibility of random numbers, so
122
+ the `seed` parameter has no effect.
123
+
119
124
  Args:
120
125
  shape (Union[tuple, Tensor]): The shape of random tensor to be generated. Only constant value is allowed
121
126
  when the input type is tuple. And the operator supports dynamic shape only when the input type is Tensor.
122
127
  seed (int, optional): Seed is used as entropy source for Random number engines generating pseudo-random numbers.
123
- Default: ``None`` , which will be treated as 0.
128
+ Default: ``None`` .
124
129
 
125
130
  Returns:
126
- Tensor. The shape that the input 'shape' denotes. The dtype is float32.
131
+ Tensor. The shape that the input `shape` denotes. The dtype is float32.
127
132
 
128
133
  Raises:
129
134
  TypeError: If shape is neither a tuple nor a Tensor.
@@ -153,6 +158,10 @@ def random_categorical(logits, num_sample, seed=0, dtype=mstype.int64):
153
158
  r"""
154
159
  Generates random samples from a given categorical distribution tensor.
155
160
 
161
+ .. warning::
162
+ The Ascend backend does not support the reproducibility of random numbers, so
163
+ the `seed` parameter has no effect.
164
+
156
165
  Args:
157
166
  logits (Tensor): The input tensor. 2-D Tensor with shape :math:`(batch\_size, num\_classes)`.
158
167
  num_sample (int): Number of sample to be drawn. Only constant values is allowed.
@@ -374,6 +383,10 @@ def standard_normal(shape, seed=None):
374
383
  .. math::
375
384
  f(x)=\frac{1}{\sqrt{2 \pi}} e^{\left(-\frac{x^{2}}{2}\right)}
376
385
 
386
+ .. warning::
387
+ The Ascend backend does not support the reproducibility of random numbers, so
388
+ the `seed` parameter has no effect.
389
+
377
390
  Args:
378
391
  shape (Union[tuple, Tensor]): The shape of random tensor to be generated. Only constant value is allowed
379
392
  when the input type is tuple. And the operator supports dynamic shape only when the input type is Tensor.
@@ -419,8 +432,14 @@ def uniform_candidate_sampler(true_classes,
419
432
  This function samples a set of classes(sampled_candidates) from [0, range_max-1] based on uniform distribution.
420
433
  If unique=True, candidates are drawn without replacement, else unique=False with replacement.
421
434
 
435
+ .. warning::
436
+ - The Ascend backend does not support the reproducibility of random numbers, so
437
+ the `seed` parameter has no effect.
438
+ - The Ascend backend does not support dynamic shape scenarios currently.
439
+
422
440
  Args:
423
441
  true_classes (Tensor): A Tensor. The target classes with a Tensor shape of :math:`(batch\_size, num\_true)` .
442
+ The value range of the elements must be :math:`[0, range\_max)`.
424
443
  num_true (int): The number of target classes in each training example.
425
444
  num_sampled (int): The number of classes to randomly sample. The sampled_candidates will have a shape
426
445
  of num_sampled. If unique=True, num_sampled must be less than or equal to range_max.
@@ -483,11 +502,15 @@ def random_poisson(shape, rate, seed=None, dtype=mstype.float32):
483
502
 
484
503
  \text{P}(i|μ) = \frac{\exp(-μ)μ^{i}}{i!}
485
504
 
505
+ .. warning::
506
+ The Ascend backend does not support the reproducibility of random numbers, so
507
+ the `seed` parameter has no effect.
508
+
486
509
  Args:
487
510
  shape (Tensor): The shape of random tensor to be sampled from each poisson distribution, 1-D `Tensor` whose
488
511
  dtype is mstype.int32 or mstype.int64.
489
512
  rate (Tensor): The :math:`μ` parameter the distribution is constructed with.
490
- It represents the mean of the distribution
513
+ It represents the mean of poisson distribution
491
514
  and also the variance of the distribution. It should be a `Tensor` whose dtype is mstype.int64,
492
515
  mstype.int32, mstype.float64, mstype.float32 or mstype.float16.
493
516
  seed (int, optional): Seed is used as entropy source for the random number engines to generate pseudo-random
@@ -582,6 +605,10 @@ def log_uniform_candidate_sampler(true_classes, num_true=1, num_sampled=5, uniqu
582
605
 
583
606
  Randomly samples a tensor of sampled classes from the range of integers [0, range_max).
584
607
 
608
+ .. warning::
609
+ The Ascend backend does not support the reproducibility of random numbers, so
610
+ the `seed` parameter has no effect.
611
+
585
612
  Args:
586
613
  true_classes (Tensor): The target classes. With data type of int64 and
587
614
  shape :math:`(batch\_size, num\_true)` .
@@ -640,12 +667,16 @@ def choice_with_mask(input_x, count=256, seed=None):
640
667
  The returned index tensor denotes the index of the nonzero
641
668
  sample, the mask tensor denotes which elements in the index tensor are valid.
642
669
 
670
+ .. warning::
671
+ The Ascend backend does not support the reproducibility of random numbers, so
672
+ the `seed` parameter has no effect.
673
+
643
674
  Args:
644
675
  input_x (Tensor[bool]): The input tensor.
645
676
  The input tensor rank must be greater than or equal to 1 and less than or equal to 5.
646
677
  count (int, optional): Number of items expected to get and the number must be greater than 0. Default: ``256`` .
647
678
  seed (int, optional): Seed is used as entropy source for Random number engines generating pseudo-random numbers.
648
- Default: ``None`` , which will be treated as 0.
679
+ Default: ``None`` .
649
680
 
650
681
  Returns:
651
682
  Two tensors, the first one is the index tensor and the other one is the mask tensor.
@@ -743,6 +774,10 @@ def normal(shape, mean, stddev, seed=None):
743
774
  """
744
775
  Generates random numbers according to the Normal (or Gaussian) random number distribution.
745
776
 
777
+ .. warning::
778
+ The Ascend backend does not support the reproducibility of random numbers, so
779
+ the `seed` parameter has no effect.
780
+
746
781
  Args:
747
782
  shape (tuple): The shape of random tensor to be generated.
748
783
  The format is :math:`(N,*)` where :math:`*` means, any number of additional dimensions.
@@ -809,6 +844,10 @@ def laplace(shape, mean, lambda_param, seed=None):
809
844
  .. math::
810
845
  \text{f}(x;μ,λ) = \frac{1}{2λ}\exp(-\frac{|x-μ|}{λ}),
811
846
 
847
+ .. warning::
848
+ The Ascend backend does not support the reproducibility of random numbers, so
849
+ the `seed` parameter has no effect.
850
+
812
851
  Args:
813
852
  shape (tuple): The shape of random tensor to be generated.
814
853
  The format is :math:`(N,*)` where :math:`*` means, any number of additional dimensions.
@@ -856,12 +895,16 @@ def gamma(shape, alpha, beta, seed=None):
856
895
  r"""
857
896
  Generates random numbers according to the Gamma random number distribution.
858
897
 
898
+ .. warning::
899
+ The Ascend backend does not support the reproducibility of random numbers, so
900
+ the `seed` parameter has no effect.
901
+
859
902
  Args:
860
903
  shape (tuple): The shape of random tensor to be generated.
861
904
  alpha (Tensor): The :math:`\alpha` distribution parameter. It should be greater than 0 with float32 data type.
862
905
  beta (Tensor): The :math:`\beta` distribution parameter. It should be greater than 0 with float32 data type.
863
906
  seed (int, optional): Seed is used as entropy source for the random number engines to generate
864
- pseudo-random numbers, must be non-negative. Default: ``None`` , which will be treated as ``0`` .
907
+ pseudo-random numbers, must be non-negative. Default: ``None`` .
865
908
 
866
909
  Returns:
867
910
  Tensor. The shape should be equal to the broadcasted shape between the input `shape` and shapes
@@ -959,6 +1002,10 @@ def rand(*size, dtype=None, seed=None):
959
1002
  Returns a new tensor that fills numbers from the uniform distribution over an interval :math:`[0, 1)`
960
1003
  based on the given shape and dtype.
961
1004
 
1005
+ .. warning::
1006
+ The Ascend backend does not support the reproducibility of random numbers, so
1007
+ the `seed` parameter has no effect.
1008
+
962
1009
  Args:
963
1010
  size (Union[int, tuple(int), list(int)]): Shape of the new tensor, e.g. :math:`(2, 3)` or :math:`2`.
964
1011
 
@@ -1003,6 +1050,10 @@ def rand_like(input, seed=None, *, dtype=None):
1003
1050
  Returns a new tensor that fills numbers from the uniform distribution over an interval :math:`[0, 1)`
1004
1051
  based on the given shape and dtype.
1005
1052
 
1053
+ .. warning::
1054
+ The Ascend backend does not support the reproducibility of random numbers, so
1055
+ the `seed` parameter has no effect.
1056
+
1006
1057
  Args:
1007
1058
  input (Tensor): Input Tensor to specify the output shape and its default dtype.
1008
1059
  seed (int, optional): Random seed, must be greater or equal to 0. Default: ``None`` , and ``0`` will be used.
@@ -1072,7 +1123,7 @@ def rand_ext(*size, generator=None, dtype=None):
1072
1123
  ``Ascend``
1073
1124
 
1074
1125
  Examples:
1075
- >>> import mindspore.ops as ops
1126
+ >>> from mindspore import ops
1076
1127
  >>> print(ops.function.random_func.rand_ext(2, 3).shape)
1077
1128
  (2, 3)
1078
1129
  """
@@ -1122,6 +1173,10 @@ def randn(*size, dtype=None, seed=None):
1122
1173
  Returns a new Tensor with given shape and dtype, filled with a sample (or samples)
1123
1174
  from the standard normal distribution.
1124
1175
 
1176
+ .. warning::
1177
+ The Ascend backend does not support the reproducibility of random numbers, so
1178
+ the `seed` parameter has no effect.
1179
+
1125
1180
  Args:
1126
1181
  size (Union[int, tuple(int), list(int)]): Shape of the new tensor, e.g., :math:`(2, 3)` or :math:`2`.
1127
1182
 
@@ -1167,6 +1222,10 @@ def randn_like(input, seed=None, *, dtype=None):
1167
1222
  Returns a new Tensor with given shape and dtype, filled with a sample (or samples) from the standard normal
1168
1223
  distribution.
1169
1224
 
1225
+ .. warning::
1226
+ The Ascend backend does not support the reproducibility of random numbers, so
1227
+ the `seed` parameter has no effect.
1228
+
1170
1229
  Args:
1171
1230
  input (Tensor): Input Tensor to specify the output shape and its default dtype.
1172
1231
  seed (int, optional): Random seed, must be greater or equal to 0. Default: ``None`` , and 0 will be used.
@@ -1215,6 +1274,10 @@ def randint(low, high, size, seed=None, *, dtype=None):
1215
1274
  r"""
1216
1275
  Returns a Tensor whose elements are random integers in the range of [ `low` , `high` ) .
1217
1276
 
1277
+ .. warning::
1278
+ The Ascend backend does not support the reproducibility of random numbers, so
1279
+ the `seed` parameter has no effect.
1280
+
1218
1281
  Args:
1219
1282
  low (int): Start value of interval.
1220
1283
  high (int): End value of interval.
@@ -1274,6 +1337,10 @@ def randint_like(input, low, high, seed=None, *, dtype=None):
1274
1337
  Returns a tensor with the same shape as Tensor `input` whose elements are random integers in the range
1275
1338
  of [ `low` , `high` ) .
1276
1339
 
1340
+ .. warning::
1341
+ The Ascend backend does not support the reproducibility of random numbers, so
1342
+ the `seed` parameter has no effect.
1343
+
1277
1344
  Args:
1278
1345
  input (Tensor): Input Tensor to specify the output shape and its default dtype.
1279
1346
  low(int): Start value of interval.
@@ -1418,6 +1485,10 @@ def multinomial(input, num_samples, replacement=True, seed=None):
1418
1485
  but must be non-negative, finite and have a non-zero sum. When using values as weights, it can be understood as
1419
1486
  normalizing the input along the last dimension.
1420
1487
 
1488
+ .. warning::
1489
+ The Ascend backend does not support the reproducibility of random numbers, so
1490
+ the `seed` parameter has no effect.
1491
+
1421
1492
  Args:
1422
1493
  input (Tensor): The input tensor containing probabilities, must be 1 or 2 dimensions, with
1423
1494
  float32 data type.
@@ -1428,7 +1499,7 @@ def multinomial(input, num_samples, replacement=True, seed=None):
1428
1499
 
1429
1500
  Returns:
1430
1501
  Tensor, has the same rows with input. The number of sampled indices of each row is `num_samples`.
1431
- The dtype is float32.
1502
+ The dtype is int32.
1432
1503
 
1433
1504
  Raises:
1434
1505
  TypeError: If `input` is not a Tensor whose dtype is not float32.
@@ -1506,6 +1577,111 @@ def multinomial(input, num_samples, replacement=True, seed=None):
1506
1577
  return random_nomial(input, num_samples)
1507
1578
 
1508
1579
 
1580
+ @_function_forbid_reuse
1581
+ def multinomial_ext(input, num_samples, replacement=False, *, generator=None):
1582
+ r"""
1583
+ Returns a tensor sampled from the multinomial probability distribution located in the corresponding
1584
+ row of the input tensor.
1585
+
1586
+ The polynomial distribution is a probability distribution that generalizes the binomial distribution formula to
1587
+ multiple states. In the polynomial distribution, each event has a fixed probability, and the sum of these
1588
+ probabilities is 1. The purpose of the `mindspore.mint.multinomial` interface is to perform `num_samples` sampling
1589
+ on the input `input`, and the output tensor is the index of the input tensor for each sampling.
1590
+ The values in `input` represent the probability of selecting the corresponding index for each sampling.
1591
+
1592
+ Here is an extreme example for better understanding. Suppose we have an input probability tensor with
1593
+ values `Tensor([90 / 100, 10 / 100, 0], mindspore.float32)`, which means we can sample three indices,
1594
+ namely index 0, index 1, and index 2, with probabilities of 90%, 10%, and 0%, respectively. We perform n samplings,
1595
+ and the resulting sequence is the calculation result of the polynomial distribution, with a length equal to the
1596
+ number of samplings.
1597
+
1598
+ In case 1 of the sample code, we perform two non-replacement samplings (`replacement` is `False`).
1599
+ The calculation result is most likely `[0, 1]`, and less likely `[1, 0]`. Since the probability of selecting
1600
+ index 0 is 90% for each sampling, the first result is most likely to be index 0. Since the probability of selecting
1601
+ index 2 is 0, index 2 cannot appear in the sampling result. Therefore, the second result must be index 1,
1602
+ and the resulting sequence is `[0, 1]`.
1603
+
1604
+ In case 2 of the sample code, we perform 10 replacement samplings (`replacement` is `True`).
1605
+ As expected, about 90% of the sampling results are index 0.
1606
+
1607
+ In case 3 of the sample code, we extend the input to 2 dimensions, and the sampling results
1608
+ in each dimension also match our sampling expectations.
1609
+
1610
+ Note:
1611
+ The rows of input do not need to sum to one (in which case we use the values as weights),
1612
+ but must be non-negative, finite and have a non-zero sum.
1613
+ When using values as weights, it can be understood as normalizing the input along the last dimension.
1614
+
1615
+ .. warning::
1616
+ This is an experimental API that is subject to change or deletion.
1617
+
1618
+ Args:
1619
+ input (Tensor): The input tensor containing probabilities, must be 1 or 2 dimensions, with float32 data type.
1620
+ num_samples (int): Number of samples to draw.
1621
+ replacement (bool, optional): Whether to draw with replacement or not. Default: ``False`` .
1622
+
1623
+ Keyword Args:
1624
+ generator (generator, optional): MindSpore generator. Default: ``None``.
1625
+
1626
+ Returns:
1627
+ Tensor, dtype is Int64.
1628
+ If `input` is a vector, out is a vector of size `num_samples`.
1629
+ If `input` is a matrix with m rows, out is an matrix of shape(m * num_samples).
1630
+
1631
+ Raises:
1632
+ TypeError: If `input` is not a Tensor whose dtype is not in float16, float32, float64 or bfloat16.
1633
+ , 或是shape为(1, 1)的Tensor
1634
+ TypeError: If `num_samples` is not an int, a Scalar of int
1635
+ or a Tensor with shape[1,] and only one int element.
1636
+ RuntimeError: If :math:`\text{num_samples} <= 0`.
1637
+ RuntimeError: If `replacement` is False, :math:`\text{num_samples} > shape` of the last dimension of `input`.
1638
+ RuntimeError: If shape of the last dimension of `input` exceeds ``2^24``.
1639
+
1640
+ Supported Platforms:
1641
+ ``Ascend``
1642
+
1643
+ Examples:
1644
+ >>> import mindspore
1645
+ >>> from mindspore import Tensor, ops
1646
+ >>> from mindspore import dtype as mstype
1647
+ >>> # case 1: The output is random, and the length of the output is the same as num_sample.
1648
+ >>> # replacement is False.
1649
+ >>> input1 = Tensor([90 / 100, 10 / 100, 0], mindspore.float32)
1650
+ >>> input2 = Tensor([90, 10, 0], mindspore.float32)
1651
+ >>> # input1 and input2 have the same meaning.
1652
+ >>> output1 = ops.multinomial_ext(input1, 2)
1653
+ >>> output2 = ops.multinomial_ext(input2, 2)
1654
+ >>> # print(output1)
1655
+ >>> # [0 1]
1656
+ >>> # print(output2)
1657
+ >>> # [0 1]
1658
+ >>> print(len(output1))
1659
+ 2
1660
+ >>> print(len(output2))
1661
+ 2
1662
+ >>> # case 2: The output is random, and the length of the output is the same as num_sample.
1663
+ >>> # replacement is True.
1664
+ >>> output3 = ops.multinomial_ext(input1, 10, replacement=True)
1665
+ >>> # print(output3)
1666
+ >>> # [0 0 1 0 0 0 0 0 0 0]
1667
+ >>> print(len(output3))
1668
+ 10
1669
+ >>> # case 3: The output is random, and the length of the output is the same as num_sample.
1670
+ >>> # replacement is True.
1671
+ >>> # rank is 2
1672
+ >>> input4 = Tensor([[90, 10, 0], [10, 90, 0]], mstype.float32)
1673
+ >>> output4 = ops.multinomial_ext(input4, 10, replacement=True)
1674
+ >>> # print(output4)
1675
+ >>> # [[0 0 0 0 0 0 0 0 1 0]
1676
+ >>> # [1 1 1 1 1 0 1 1 1 1]]
1677
+ """
1678
+
1679
+ if generator is None:
1680
+ generator = default_generator
1681
+ seed, offset = generator._step(generator_step_) # pylint: disable=protected-access
1682
+ return multinomial_ext_(input, num_samples, replacement, seed, offset)
1683
+
1684
+
1509
1685
  def _check_shape(input_shape):
1510
1686
  """Check 'shape' value."""
1511
1687
  if not isinstance(input_shape, tuple):
@@ -35,6 +35,8 @@ def reshard(tensor, layout):
35
35
  "sharding_propagation".
36
36
  - In the semi-auto parallel mode, the parallel mode will automatically switch to auto
37
37
  parallel mode with the search mode be set to "sharding_propagation".
38
+ - Currently, configuring multi-dimension and multi-copy reshard strategy in
39
+ mindspore.Layout is not supported.
38
40
 
39
41
  Args:
40
42
  tensor (Tensor): The tensor to be set the sharding strategy.
@@ -55,18 +57,18 @@ def reshard(tensor, layout):
55
57
  >>> from mindspore import ops, nn, Tensor, context, Layout
56
58
  >>> context.set_context(mode=ms.GRAPH_MODE)
57
59
  >>> context.set_auto_parallel_context(parallel_mode=ms.ParallelMode.AUTO_PARALLEL,
58
- >>> search_mode="sharding_propagation")
60
+ ... search_mode="sharding_propagation")
59
61
  >>> class Network(nn.Cell):
60
- >>> def __init__(self):
61
- >>> super().__init__()
62
- >>> self.matmul = ops.MatMul()
63
- >>> self.relu = ops.ReLU()
64
- >>> def construct(self, x, layout):
65
- >>> x = self.relu(x)
66
- >>> x_reshard = ops.reshard(x, self.layout)
67
- >>> y = Tensor(np.ones(shape=(128, 128)), dtype=ms.float32)
68
- >>> x = self.matmul(x_reshard, y)
69
- >>> return x
62
+ ... def __init__(self):
63
+ ... super().__init__()
64
+ ... self.matmul = ops.MatMul()
65
+ ... self.relu = ops.ReLU()
66
+ ... def construct(self, x, layout):
67
+ ... x = self.relu(x)
68
+ ... x_reshard = ops.reshard(x, layout)
69
+ ... y = Tensor(np.ones(shape=(128, 128)), dtype=ms.float32)
70
+ ... x = self.matmul(x_reshard, y)
71
+ ... return x
70
72
  >>>
71
73
  >>> layout = Layout((4, 2), ("dp", "mp"))
72
74
  >>> input_layout = layout("dp", "mp")
@@ -375,7 +375,7 @@ def coo_relu(x: COOTensor) -> COOTensor:
375
375
  Args:
376
376
  x (COOTensor): Input COOTensor with shape :math:`(N, *)`, where :math:`*`
377
377
  means any number of additional dimensions. Its dtype is
378
- `number <https://www.mindspore.cn/docs/en/master/api_python/mindspore.html#mindspore.dtype>`_.
378
+ `number <https://www.mindspore.cn/docs/en/master/api_python/mindspore/mindspore.dtype.html>`_.
379
379
 
380
380
  Returns:
381
381
  COOTensor, has the same shape and dtype as the `x`.
@@ -27,8 +27,9 @@ def vmap(fn, in_axes=0, out_axes=0):
27
27
  Vmap is pioneered by Jax and it removes the restriction of batch dimension on the operator, and provides a
28
28
  more convenient and unified operator expression. Moreover, it allows users to composite with other functional
29
29
  modules such as :func:`mindspore.grad`, to improve the development efficiency, please refer to the
30
- `Automatic Vectorization (Vmap) <https://www.mindspore.cn/tutorials/experts/en/master/vmap/vmap.html>`_ tutorial
31
- for more detail. In addition, the vectorizing map does not execute loops outside the function, but sinks loops
30
+ `Automatic Vectorization (Vmap) <https://www.mindspore.cn/docs/en/master/model_train/train_process/optimize/vmap.html>`_
31
+ tutorial for more detail.
32
+ In addition, the vectorizing map does not execute loops outside the function, but sinks loops
32
33
  into the primitive operations of the function for better performance. When combined with `Graph Kernel Fusion`,
33
34
  operational efficiency would be further improved.
34
35
 
@@ -1,6 +1,6 @@
1
1
  # This is the Python adaptation and derivative work of Myia (https://github.com/mila-iqia/myia/).
2
2
  #
3
- # Copyright 2021-2022 Huawei Technologies Co., Ltd
3
+ # Copyright 2021-2024 Huawei Technologies Co., Ltd
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@
19
19
  from mindspore.common._register_for_tensor import tensor_operator_registry
20
20
  from mindspore.ops import _constants
21
21
  from mindspore.ops.function import *
22
- from mindspore.ops.function.array_func import narrow, flatten
22
+ from mindspore.ops.function.array_func import chunk_ext, zero_
23
23
  from mindspore.ops.function.math_func import all, argmax_ext
24
24
  from mindspore.ops.function.random_func import uniform_ext
25
25
  from mindspore.ops import operations as P
@@ -34,14 +34,15 @@ from mindspore.ops.operations.math_ops import Roll
34
34
  from mindspore.ops.composite.math_ops import mm
35
35
  from mindspore.ops.function.math_func import dot
36
36
  from mindspore.ops import auto_generate
37
+ from mindspore.ops.auto_generate import cast
37
38
  from mindspore.ops_generate.gen_ops_inner_prim import DtypeToEnum
38
- from mindspore.ops.operations.manually_defined.ops_def import scalar_div, scalar_mod, scalar_add, scalar_mul,\
39
- scalar_sub, scalar_gt, scalar_ge, scalar_le, scalar_lt, scalar_eq, scalar_floordiv, scalar_log, scalar_pow,\
39
+ from mindspore.ops.operations.manually_defined.ops_def import scalar_div, scalar_mod, scalar_add, scalar_mul, \
40
+ scalar_sub, scalar_gt, scalar_ge, scalar_le, scalar_lt, scalar_eq, scalar_floordiv, scalar_log, scalar_pow, \
40
41
  scalar_uadd, scalar_usub, flash_attention_score
41
42
 
42
43
  typeof = Primitive('typeof')
43
44
  hastype = Primitive('hastype')
44
- cast = P.Cast()
45
+ _cast = P.Cast()
45
46
  dtype = P.DType()
46
47
  isconstant = _inner_ops.IsConstant()
47
48
  isconstant.set_const_prim(True)
@@ -116,7 +117,8 @@ reduced_shape = Primitive("reduced_shape")
116
117
  # shape_mul:input must be shape multiply elements in tuple(shape)
117
118
  shape_mul = _sequence_ops.shape_mul()
118
119
 
119
- setattr(tensor_operator_registry, 'tuple_to_tensor', _sequence_ops.TupleToTensor)
120
+ setattr(tensor_operator_registry, 'tuple_to_tensor',
121
+ _sequence_ops.TupleToTensor)
120
122
  setattr(tensor_operator_registry, 'add', add)
121
123
  setattr(tensor_operator_registry, 'softmax', softmax)
122
124
  setattr(tensor_operator_registry, 'addr', addr)
@@ -136,6 +138,7 @@ setattr(tensor_operator_registry, 'rsqrt', rsqrt)
136
138
  setattr(tensor_operator_registry, 'bincount', bincount)
137
139
  setattr(tensor_operator_registry, 'slogdet', slogdet)
138
140
  setattr(tensor_operator_registry, 'trace', trace)
141
+ setattr(tensor_operator_registry, 'tracev2', auto_generate.trace_v2_op)
139
142
  setattr(tensor_operator_registry, 'tril', tril)
140
143
  setattr(tensor_operator_registry, 'chunk', chunk)
141
144
  setattr(tensor_operator_registry, 'count_nonzero', count_nonzero)
@@ -210,7 +213,8 @@ setattr(tensor_operator_registry, 'dot', dot)
210
213
  setattr(tensor_operator_registry, 'outer', outer)
211
214
  setattr(tensor_operator_registry, 'log1p', log1p)
212
215
  setattr(tensor_operator_registry, 'logdet', logdet)
213
- setattr(tensor_operator_registry, 'log_matrix_determinant', log_matrix_determinant)
216
+ setattr(tensor_operator_registry,
217
+ 'log_matrix_determinant', log_matrix_determinant)
214
218
  setattr(tensor_operator_registry, 'matrix_determinant', matrix_determinant)
215
219
  setattr(tensor_operator_registry, 'ceil', ceil)
216
220
  setattr(tensor_operator_registry, 'fillv2', P.FillV2)
@@ -223,6 +227,7 @@ setattr(tensor_operator_registry, 'vsplit', vsplit)
223
227
  setattr(tensor_operator_registry, 'hsplit', hsplit)
224
228
  setattr(tensor_operator_registry, 'dsplit', dsplit)
225
229
  setattr(tensor_operator_registry, 'zeros_like', zeros_like)
230
+ setattr(tensor_operator_registry, 'zero_', zero_)
226
231
  setattr(tensor_operator_registry, 'scalar_to_tensor', scalar_to_tensor)
227
232
  setattr(tensor_operator_registry, 'stop_gradient', stop_gradient)
228
233
  setattr(tensor_operator_registry, 'masked_fill', masked_fill)
@@ -264,6 +269,7 @@ setattr(tensor_operator_registry, 'tanh', tanh)
264
269
  setattr(tensor_operator_registry, 'exp', exp)
265
270
  setattr(tensor_operator_registry, 'addbmm', addbmm)
266
271
  setattr(tensor_operator_registry, 'addmm', addmm)
272
+ setattr(tensor_operator_registry, 'addmm_', auto_generate.inplace_addmm_op)
267
273
  setattr(tensor_operator_registry, 'addmv', addmv)
268
274
  setattr(tensor_operator_registry, 'adjoint', adjoint)
269
275
  setattr(tensor_operator_registry, 'asinh', asinh)
@@ -314,7 +320,7 @@ setattr(tensor_operator_registry, 'unsqueeze', unsqueeze)
314
320
  setattr(tensor_operator_registry, 'expand_dims', expand_dims)
315
321
  setattr(tensor_operator_registry, 'contiguous', auto_generate.contiguous)
316
322
  # support GE backend for no compare operators
317
- setattr(tensor_operator_registry, 'cast', cast)
323
+ setattr(tensor_operator_registry, 'cast', _cast)
318
324
  setattr(tensor_operator_registry, 'shape_mul', shape_mul)
319
325
  setattr(tensor_operator_registry, 'concatenate', concat)
320
326
  setattr(tensor_operator_registry, 'fill', fill)
@@ -392,12 +398,13 @@ setattr(tensor_operator_registry, 'argwhere', argwhere)
392
398
  setattr(tensor_operator_registry, 'coo_add', coo_add)
393
399
  setattr(tensor_operator_registry, 'topk', topk)
394
400
  setattr(tensor_operator_registry, 'isfinite', isfinite)
395
- setattr(tensor_operator_registry, 'to', cast)
396
- setattr(tensor_operator_registry, 'bool', cast)
397
- setattr(tensor_operator_registry, 'float', cast)
398
- setattr(tensor_operator_registry, 'half', cast)
399
- setattr(tensor_operator_registry, 'int', cast)
400
- setattr(tensor_operator_registry, 'long', cast)
401
+ setattr(tensor_operator_registry, 'to', _cast)
402
+ setattr(tensor_operator_registry, 'bool', _cast)
403
+ setattr(tensor_operator_registry, 'float', _cast)
404
+ setattr(tensor_operator_registry, 'half', _cast)
405
+ setattr(tensor_operator_registry, 'int', _cast)
406
+ setattr(tensor_operator_registry, 'long', _cast)
407
+ setattr(tensor_operator_registry, 'byte', _cast)
401
408
  setattr(tensor_operator_registry, 'cholesky', cholesky)
402
409
  setattr(tensor_operator_registry, 'cholesky_inverse', cholesky_inverse)
403
410
  setattr(tensor_operator_registry, 'cholesky_solve', cholesky_solve)
@@ -440,6 +447,9 @@ setattr(tensor_operator_registry, 'imag', imag)
440
447
  setattr(tensor_operator_registry, 'repeat_interleave', repeat_interleave)
441
448
  setattr(tensor_operator_registry, 'rad2deg', rad2deg)
442
449
  setattr(tensor_operator_registry, 'deg2rad', deg2rad)
450
+ setattr(tensor_operator_registry, 'copy_', auto_generate.copy_ext)
451
+ setattr(tensor_operator_registry, 'add_', auto_generate.inplace_add_ext)
452
+ setattr(tensor_operator_registry, 'adds_', auto_generate.inplace_adds_ext)
443
453
  setattr(tensor_operator_registry, 'copysign', copysign)
444
454
  setattr(tensor_operator_registry, 'roll', Roll)
445
455
  setattr(tensor_operator_registry, 'rot90', rot90)
@@ -82,7 +82,7 @@ class _CustomInstaller:
82
82
  for dir_name in dir_names:
83
83
  if not os.path.isdir(dir_name):
84
84
  try:
85
- os.makedirs(dir_name, exist_ok=True)
85
+ os.makedirs(dir_name, mode=0o700, exist_ok=True)
86
86
  except OSError as err:
87
87
  if err.errno == 17: # File exists
88
88
  pass
@@ -121,7 +121,7 @@ class _CustomInstaller:
121
121
 
122
122
  def _find_ai_cpu_so_path(self, so_file):
123
123
  """find the absolute path of so"""
124
- current_path = os.path.dirname(os.path.abspath(__file__))
124
+ current_path = os.path.dirname(os.path.realpath(__file__))
125
125
  search_paths = [current_path + "/../lib", current_path + "/../lib/plugin/ascend"]
126
126
  for path in search_paths:
127
127
  so_path = os.path.join(path, so_file)
@@ -235,7 +235,7 @@ class _CustomInstaller:
235
235
  # generate and copy reg info file
236
236
  op_info = self._gen_ai_core_reg_info(imply_path, self.func.__name__)
237
237
  self._copy_file(imply_path, self.ai_core_impl_dir)
238
- for arc_name in ["ascend910", "ascend910b", "ascend910c", "ascend310p"]:
238
+ for arc_name in ["ascend910", "ascend910b", "ascend910_93", "ascend310p"]:
239
239
  arc_dir = os.path.join(self.ai_core_config_dir, arc_name)
240
240
  _CustomInstaller._create_dir(arc_dir)
241
241
  self._save_op_info(arc_dir, "aic-{}-ops-info.json".format(arc_name), op_info)
@@ -96,7 +96,7 @@ from .nn_ops import (LSTM, SGD, Adam, AdamWeightDecay, FusedSparseAdam, FusedSpa
96
96
  InstanceNorm,
97
97
  GeLU, FastGeLU, Elu, CeLU,
98
98
  GetNext, L2Normalize, LayerNorm, L2Loss, CTCLoss, CTCLossV2, CTCLossV2Grad, CTCGreedyDecoder,
99
- LogSoftmax, MaxPool3D, AvgPool3D,
99
+ LogSoftmax, LogSoftmaxExt, MaxPool3D, AvgPool3D,
100
100
  MaxPool, DataFormatDimMap,
101
101
  AvgPool, Conv2DBackpropInput, ComputeAccidentalHits,
102
102
  MaxPoolWithArgmaxV2, OneHot, Pad, MirrorPad, Mish, PReLU, ReLU, ReLU6,
@@ -136,6 +136,7 @@ from ..deprecated import (identity, DropoutDoMask, MaxPoolWithArgmax, DropoutGen
136
136
  TensorAdd, InplaceUpdate, ScatterNonAliasingAdd,
137
137
  BatchToSpaceND, Unpack, GatherV2, DynamicShape, ScalarToArray, Pack)
138
138
  from .manually_defined._inner import ScalarCast
139
+ from .manually_defined import WhileLoop, Scan, ForiLoop
139
140
  from .reshard_ops import (Reshard)
140
141
 
141
142
  __all__ = [
@@ -203,6 +204,7 @@ __all__ = [
203
204
  'Softmax',
204
205
  'Softsign',
205
206
  'LogSoftmax',
207
+ 'LogSoftmaxExt',
206
208
  'SoftmaxCrossEntropyWithLogits',
207
209
  'BCEWithLogitsLoss',
208
210
  'ROIAlign',
@@ -337,6 +339,9 @@ __all__ = [
337
339
  'TupleToArray',
338
340
  'GeSwitch',
339
341
  'Merge',
342
+ 'WhileLoop',
343
+ 'Scan',
344
+ 'ForiLoop',
340
345
  'CheckValid',
341
346
  'BartlettWindow',
342
347
  'BlackmanWindow',