mindspore 2.3.0__cp39-cp39-win_amd64.whl → 2.4.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 (285) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/__init__.py +3 -1
  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/_checkparam.py +50 -9
  7. mindspore/_extends/parse/compile_config.py +41 -0
  8. mindspore/_extends/parse/parser.py +9 -7
  9. mindspore/_extends/parse/standard_method.py +52 -14
  10. mindspore/_extends/pijit/pijit_func_white_list.py +350 -24
  11. mindspore/amp.py +24 -10
  12. mindspore/avcodec-59.dll +0 -0
  13. mindspore/avdevice-59.dll +0 -0
  14. mindspore/avfilter-8.dll +0 -0
  15. mindspore/avformat-59.dll +0 -0
  16. mindspore/avutil-57.dll +0 -0
  17. mindspore/common/__init__.py +6 -4
  18. mindspore/common/_pijit_context.py +190 -0
  19. mindspore/common/_register_for_tensor.py +2 -1
  20. mindspore/common/_tensor_overload.py +139 -0
  21. mindspore/common/api.py +102 -87
  22. mindspore/common/dump.py +5 -6
  23. mindspore/common/generator.py +1 -7
  24. mindspore/common/hook_handle.py +14 -26
  25. mindspore/common/mindir_util.py +2 -2
  26. mindspore/common/parameter.py +46 -13
  27. mindspore/common/recompute.py +39 -9
  28. mindspore/common/sparse_tensor.py +7 -3
  29. mindspore/common/tensor.py +209 -29
  30. mindspore/communication/__init__.py +1 -1
  31. mindspore/communication/_comm_helper.py +38 -3
  32. mindspore/communication/comm_func.py +310 -55
  33. mindspore/communication/management.py +14 -14
  34. mindspore/context.py +123 -22
  35. mindspore/dataset/__init__.py +1 -1
  36. mindspore/dataset/audio/__init__.py +1 -1
  37. mindspore/dataset/core/config.py +7 -0
  38. mindspore/dataset/core/validator_helpers.py +7 -0
  39. mindspore/dataset/engine/cache_client.py +1 -1
  40. mindspore/dataset/engine/datasets.py +72 -44
  41. mindspore/dataset/engine/datasets_audio.py +7 -7
  42. mindspore/dataset/engine/datasets_standard_format.py +53 -3
  43. mindspore/dataset/engine/datasets_text.py +20 -20
  44. mindspore/dataset/engine/datasets_user_defined.py +174 -104
  45. mindspore/dataset/engine/datasets_vision.py +33 -33
  46. mindspore/dataset/engine/iterators.py +29 -0
  47. mindspore/dataset/engine/obs/util.py +7 -0
  48. mindspore/dataset/engine/queue.py +114 -60
  49. mindspore/dataset/engine/serializer_deserializer.py +2 -2
  50. mindspore/dataset/engine/validators.py +34 -14
  51. mindspore/dataset/text/__init__.py +1 -4
  52. mindspore/dataset/transforms/__init__.py +0 -3
  53. mindspore/dataset/utils/line_reader.py +2 -0
  54. mindspore/dataset/vision/__init__.py +1 -4
  55. mindspore/dataset/vision/utils.py +1 -1
  56. mindspore/dataset/vision/validators.py +2 -1
  57. mindspore/dnnl.dll +0 -0
  58. mindspore/{nn/extend → experimental/es}/__init__.py +4 -11
  59. mindspore/experimental/es/embedding_service.py +883 -0
  60. mindspore/{nn/layer → experimental/es}/embedding_service_layer.py +218 -30
  61. mindspore/experimental/llm_boost/__init__.py +21 -0
  62. mindspore/{nn/extend/layer → experimental/llm_boost/atb}/__init__.py +4 -8
  63. mindspore/experimental/llm_boost/atb/boost_base.py +211 -0
  64. mindspore/experimental/llm_boost/atb/llama_boost.py +115 -0
  65. mindspore/experimental/llm_boost/atb/qwen_boost.py +101 -0
  66. mindspore/experimental/llm_boost/register.py +129 -0
  67. mindspore/experimental/llm_boost/utils.py +31 -0
  68. mindspore/experimental/optim/adamw.py +85 -0
  69. mindspore/experimental/optim/optimizer.py +3 -0
  70. mindspore/hal/__init__.py +3 -3
  71. mindspore/hal/contiguous_tensors_handle.py +175 -0
  72. mindspore/hal/stream.py +18 -0
  73. mindspore/include/api/model_group.h +13 -1
  74. mindspore/include/api/types.h +10 -10
  75. mindspore/include/dataset/config.h +2 -2
  76. mindspore/include/dataset/constants.h +2 -2
  77. mindspore/include/dataset/execute.h +2 -2
  78. mindspore/include/dataset/vision.h +4 -0
  79. mindspore/jpeg62.dll +0 -0
  80. mindspore/log.py +1 -1
  81. mindspore/mindrecord/filewriter.py +68 -51
  82. mindspore/mindspore_backend.dll +0 -0
  83. mindspore/mindspore_common.dll +0 -0
  84. mindspore/mindspore_core.dll +0 -0
  85. mindspore/mindspore_glog.dll +0 -0
  86. mindspore/mindspore_np_dtype.dll +0 -0
  87. mindspore/mindspore_ops.dll +0 -0
  88. mindspore/mint/__init__.py +495 -46
  89. mindspore/mint/distributed/__init__.py +31 -0
  90. mindspore/mint/distributed/distributed.py +254 -0
  91. mindspore/mint/nn/__init__.py +266 -21
  92. mindspore/mint/nn/functional.py +125 -19
  93. mindspore/mint/nn/layer/__init__.py +39 -0
  94. mindspore/mint/nn/layer/activation.py +133 -0
  95. mindspore/mint/nn/layer/normalization.py +477 -0
  96. mindspore/mint/nn/layer/pooling.py +110 -0
  97. mindspore/mint/optim/adamw.py +28 -7
  98. mindspore/mint/special/__init__.py +63 -0
  99. mindspore/multiprocessing/__init__.py +2 -1
  100. mindspore/nn/__init__.py +0 -1
  101. mindspore/nn/cell.py +275 -93
  102. mindspore/nn/layer/activation.py +211 -44
  103. mindspore/nn/layer/basic.py +113 -3
  104. mindspore/nn/layer/embedding.py +120 -2
  105. mindspore/nn/layer/normalization.py +101 -5
  106. mindspore/nn/layer/padding.py +34 -48
  107. mindspore/nn/layer/pooling.py +161 -7
  108. mindspore/nn/layer/transformer.py +3 -3
  109. mindspore/nn/loss/__init__.py +2 -2
  110. mindspore/nn/loss/loss.py +84 -6
  111. mindspore/nn/optim/__init__.py +2 -1
  112. mindspore/nn/optim/adadelta.py +1 -1
  113. mindspore/nn/optim/adam.py +1 -1
  114. mindspore/nn/optim/lamb.py +1 -1
  115. mindspore/nn/optim/tft_wrapper.py +127 -0
  116. mindspore/nn/wrap/cell_wrapper.py +12 -23
  117. mindspore/nn/wrap/grad_reducer.py +5 -5
  118. mindspore/nn/wrap/loss_scale.py +17 -3
  119. mindspore/numpy/__init__.py +1 -1
  120. mindspore/numpy/array_creations.py +65 -68
  121. mindspore/numpy/array_ops.py +64 -60
  122. mindspore/numpy/fft.py +610 -75
  123. mindspore/numpy/logic_ops.py +11 -10
  124. mindspore/numpy/math_ops.py +85 -84
  125. mindspore/numpy/utils_const.py +4 -4
  126. mindspore/opencv_core452.dll +0 -0
  127. mindspore/opencv_imgcodecs452.dll +0 -0
  128. mindspore/opencv_imgproc452.dll +0 -0
  129. mindspore/ops/__init__.py +6 -4
  130. mindspore/ops/_grad_experimental/grad_comm_ops.py +47 -3
  131. mindspore/ops/_grad_experimental/grad_math_ops.py +0 -22
  132. mindspore/ops/_vmap/vmap_array_ops.py +2 -4
  133. mindspore/ops/_vmap/vmap_math_ops.py +17 -1
  134. mindspore/ops/_vmap/vmap_nn_ops.py +43 -2
  135. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +85 -7
  136. mindspore/ops/auto_generate/gen_arg_dtype_cast.py +2 -0
  137. mindspore/ops/auto_generate/gen_extend_func.py +734 -13
  138. mindspore/ops/auto_generate/gen_ops_def.py +2420 -381
  139. mindspore/ops/auto_generate/gen_ops_prim.py +5196 -1659
  140. mindspore/ops/auto_generate/pyboost_inner_prim.py +176 -56
  141. mindspore/ops/composite/base.py +85 -48
  142. mindspore/ops/composite/multitype_ops/_compile_utils.py +1 -0
  143. mindspore/ops/composite/multitype_ops/not_in_impl.py +2 -2
  144. mindspore/ops/function/__init__.py +22 -0
  145. mindspore/ops/function/array_func.py +490 -153
  146. mindspore/ops/function/debug_func.py +113 -1
  147. mindspore/ops/function/fft_func.py +15 -2
  148. mindspore/ops/function/grad/grad_func.py +3 -2
  149. mindspore/ops/function/math_func.py +558 -207
  150. mindspore/ops/function/nn_func.py +817 -383
  151. mindspore/ops/function/other_func.py +3 -2
  152. mindspore/ops/function/random_func.py +184 -8
  153. mindspore/ops/function/reshard_func.py +13 -11
  154. mindspore/ops/function/sparse_unary_func.py +1 -1
  155. mindspore/ops/function/vmap_func.py +3 -2
  156. mindspore/ops/functional.py +24 -14
  157. mindspore/ops/op_info_register.py +3 -3
  158. mindspore/ops/operations/__init__.py +6 -1
  159. mindspore/ops/operations/_grad_ops.py +2 -76
  160. mindspore/ops/operations/_infer_ops.py +1 -1
  161. mindspore/ops/operations/_inner_ops.py +71 -94
  162. mindspore/ops/operations/array_ops.py +12 -146
  163. mindspore/ops/operations/comm_ops.py +42 -53
  164. mindspore/ops/operations/custom_ops.py +83 -19
  165. mindspore/ops/operations/debug_ops.py +42 -10
  166. mindspore/ops/operations/manually_defined/_inner.py +12 -0
  167. mindspore/ops/operations/manually_defined/ops_def.py +265 -10
  168. mindspore/ops/operations/math_ops.py +12 -223
  169. mindspore/ops/operations/nn_ops.py +20 -114
  170. mindspore/ops/operations/other_ops.py +7 -4
  171. mindspore/ops/operations/random_ops.py +46 -1
  172. mindspore/ops/primitive.py +18 -6
  173. mindspore/ops_generate/arg_dtype_cast.py +2 -0
  174. mindspore/ops_generate/gen_aclnn_implement.py +11 -11
  175. mindspore/ops_generate/gen_constants.py +36 -0
  176. mindspore/ops_generate/gen_ops.py +67 -52
  177. mindspore/ops_generate/gen_ops_inner_prim.py +1 -1
  178. mindspore/ops_generate/gen_pyboost_func.py +131 -47
  179. mindspore/ops_generate/op_proto.py +10 -3
  180. mindspore/ops_generate/pyboost_utils.py +14 -1
  181. mindspore/ops_generate/template.py +43 -21
  182. mindspore/parallel/__init__.py +3 -1
  183. mindspore/parallel/_auto_parallel_context.py +28 -8
  184. mindspore/parallel/_cell_wrapper.py +83 -0
  185. mindspore/parallel/_parallel_serialization.py +47 -19
  186. mindspore/parallel/_tensor.py +81 -11
  187. mindspore/parallel/_utils.py +13 -1
  188. mindspore/parallel/algo_parameter_config.py +5 -5
  189. mindspore/parallel/checkpoint_transform.py +46 -39
  190. mindspore/parallel/cluster/process_entity/__init__.py +1 -1
  191. mindspore/parallel/cluster/process_entity/_api.py +31 -23
  192. mindspore/parallel/cluster/process_entity/_utils.py +2 -27
  193. mindspore/parallel/parameter_broadcast.py +3 -4
  194. mindspore/parallel/shard.py +162 -31
  195. mindspore/parallel/transform_safetensors.py +993 -0
  196. mindspore/profiler/__init__.py +2 -1
  197. mindspore/profiler/common/constant.py +29 -0
  198. mindspore/profiler/common/registry.py +47 -0
  199. mindspore/profiler/common/util.py +28 -0
  200. mindspore/profiler/dynamic_profiler.py +694 -0
  201. mindspore/profiler/envprofiling.py +17 -19
  202. mindspore/profiler/parser/ascend_analysis/constant.py +18 -0
  203. mindspore/profiler/parser/ascend_analysis/file_manager.py +25 -4
  204. mindspore/profiler/parser/ascend_analysis/function_event.py +43 -19
  205. mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +31 -26
  206. mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +56 -10
  207. mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +55 -8
  208. mindspore/profiler/parser/ascend_analysis/path_manager.py +313 -0
  209. mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +27 -20
  210. mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +9 -2
  211. mindspore/profiler/parser/ascend_msprof_exporter.py +5 -4
  212. mindspore/profiler/parser/ascend_timeline_generator.py +27 -25
  213. mindspore/profiler/parser/base_timeline_generator.py +19 -25
  214. mindspore/profiler/parser/cpu_gpu_timeline_generator.py +25 -12
  215. mindspore/profiler/parser/framework_parser.py +1 -391
  216. mindspore/profiler/parser/gpu_analysis/__init__.py +14 -0
  217. mindspore/profiler/parser/gpu_analysis/function_event.py +44 -0
  218. mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +89 -0
  219. mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +72 -0
  220. mindspore/profiler/parser/memory_usage_parser.py +0 -154
  221. mindspore/profiler/parser/profiler_info.py +78 -6
  222. mindspore/profiler/profiler.py +153 -0
  223. mindspore/profiler/profiling.py +280 -412
  224. mindspore/rewrite/__init__.py +1 -2
  225. mindspore/rewrite/common/namespace.py +4 -4
  226. mindspore/rewrite/symbol_tree/symbol_tree.py +3 -3
  227. mindspore/run_check/_check_version.py +36 -103
  228. mindspore/safeguard/rewrite_obfuscation.py +591 -247
  229. mindspore/swresample-4.dll +0 -0
  230. mindspore/swscale-6.dll +0 -0
  231. mindspore/tinyxml2.dll +0 -0
  232. mindspore/train/__init__.py +4 -3
  233. mindspore/train/_utils.py +28 -2
  234. mindspore/train/amp.py +171 -53
  235. mindspore/train/callback/__init__.py +2 -2
  236. mindspore/train/callback/_callback.py +4 -4
  237. mindspore/train/callback/_checkpoint.py +85 -22
  238. mindspore/train/callback/_cluster_monitor.py +1 -1
  239. mindspore/train/callback/_flops_collector.py +1 -0
  240. mindspore/train/callback/_loss_monitor.py +3 -3
  241. mindspore/train/callback/_on_request_exit.py +134 -31
  242. mindspore/train/callback/_summary_collector.py +5 -5
  243. mindspore/train/callback/_tft_register.py +352 -0
  244. mindspore/train/dataset_helper.py +7 -3
  245. mindspore/train/metrics/metric.py +3 -3
  246. mindspore/train/metrics/roc.py +4 -4
  247. mindspore/train/mind_ir_pb2.py +44 -39
  248. mindspore/train/model.py +134 -58
  249. mindspore/train/serialization.py +336 -112
  250. mindspore/turbojpeg.dll +0 -0
  251. mindspore/utils/__init__.py +21 -0
  252. mindspore/utils/utils.py +60 -0
  253. mindspore/version.py +1 -1
  254. {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/METADATA +6 -2
  255. {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/RECORD +258 -252
  256. mindspore/include/c_api/ms/abstract.h +0 -67
  257. mindspore/include/c_api/ms/attribute.h +0 -197
  258. mindspore/include/c_api/ms/base/handle_types.h +0 -43
  259. mindspore/include/c_api/ms/base/macros.h +0 -32
  260. mindspore/include/c_api/ms/base/status.h +0 -33
  261. mindspore/include/c_api/ms/base/types.h +0 -283
  262. mindspore/include/c_api/ms/context.h +0 -102
  263. mindspore/include/c_api/ms/graph.h +0 -160
  264. mindspore/include/c_api/ms/node.h +0 -606
  265. mindspore/include/c_api/ms/tensor.h +0 -161
  266. mindspore/include/c_api/ms/value.h +0 -84
  267. mindspore/mindspore_shared_lib.dll +0 -0
  268. mindspore/nn/extend/basic.py +0 -140
  269. mindspore/nn/extend/embedding.py +0 -143
  270. mindspore/nn/extend/layer/normalization.py +0 -109
  271. mindspore/nn/extend/pooling.py +0 -117
  272. mindspore/nn/layer/embedding_service.py +0 -531
  273. mindspore/ops/_op_impl/aicpu/strided_slice_v2.py +0 -93
  274. mindspore/ops/_op_impl/aicpu/strided_slice_v2_grad.py +0 -66
  275. mindspore/ops/extend/__init__.py +0 -53
  276. mindspore/ops/extend/array_func.py +0 -218
  277. mindspore/ops/extend/math_func.py +0 -76
  278. mindspore/ops/extend/nn_func.py +0 -308
  279. mindspore/ops/silent_check.py +0 -162
  280. mindspore/profiler/parser/msadvisor_analyzer.py +0 -82
  281. mindspore/profiler/parser/msadvisor_parser.py +0 -240
  282. mindspore/train/callback/_mindio_ttp.py +0 -443
  283. {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/WHEEL +0 -0
  284. {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/entry_points.txt +0 -0
  285. {mindspore-2.3.0.dist-info → mindspore-2.4.0.dist-info}/top_level.txt +0 -0
@@ -54,7 +54,7 @@ class ReduceOp:
54
54
  For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
55
55
  without any third-party or configuration file dependencies.
56
56
  Please see the `msrun start up
57
- <https://www.mindspore.cn/tutorials/experts/zh-CN/master/parallel/msrun_launcher.html>`_
57
+ <https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
58
58
  for more details.
59
59
 
60
60
  This example should be run with multiple devices.
@@ -141,7 +141,7 @@ class AllReduce(Primitive):
141
141
  For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
142
142
  without any third-party or configuration file dependencies.
143
143
  Please see the `msrun start up
144
- <https://www.mindspore.cn/tutorials/experts/zh-CN/master/parallel/msrun_launcher.html>`_
144
+ <https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
145
145
  for more details.
146
146
 
147
147
  This example should be run with 2 devices.
@@ -178,14 +178,15 @@ class AllReduce(Primitive):
178
178
  @prim_attr_register
179
179
  def __init__(self, op=ReduceOp.SUM, group=GlobalComm.WORLD_COMM_GROUP):
180
180
  """Initialize AllReduce."""
181
+ self.group = _get_group(group)
181
182
  if not isinstance(op, type(ReduceOp.SUM)):
182
183
  raise TypeError(f"For '{self.name}', the 'op' must be str, but got {type(op).__name__}.")
183
- if not isinstance(_get_group(group), str):
184
+ if not isinstance(self.group, str):
184
185
  raise TypeError(f"For '{self.name}', the 'group' must be str, "
185
- f"but got {type(_get_group(group)).__name__}.")
186
- check_hcom_group_valid(group, prim_name=self.name)
186
+ f"but got {type(self.group).__name__}.")
187
+ check_hcom_group_valid(self.group, prim_name=self.name)
187
188
  self.op = op
188
- self.add_prim_attr('group', _get_group(group))
189
+ self.add_prim_attr('group', self.group)
189
190
  self.add_prim_attr('fusion', 0)
190
191
  self.add_prim_attr('index', 0)
191
192
  self.add_prim_attr('no_eliminate', True)
@@ -230,7 +231,7 @@ class Reduce(PrimitiveWithInfer):
230
231
  For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method without any third-party
231
232
  or configuration file dependencies.
232
233
  Please see the `msrun start up
233
- <https://www.mindspore.cn/tutorials/experts/zh-CN/master/parallel/msrun_launcher.html>`_
234
+ <https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
234
235
  for more details.
235
236
 
236
237
  This example should be run with 4 devices.
@@ -314,7 +315,7 @@ class AllGather(PrimitiveWithInfer):
314
315
  For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
315
316
  without any third-party or configuration file dependencies.
316
317
  Please see the `msrun start up
317
- <https://www.mindspore.cn/tutorials/experts/zh-CN/master/parallel/msrun_launcher.html>`_
318
+ <https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
318
319
  for more details.
319
320
 
320
321
  This example should be run with 2 devices.
@@ -354,12 +355,13 @@ class AllGather(PrimitiveWithInfer):
354
355
  @prim_attr_register
355
356
  def __init__(self, group=GlobalComm.WORLD_COMM_GROUP):
356
357
  """Initialize AllGather."""
357
- validator.check_value_type('group', _get_group(group), (str,), self.name)
358
- self.rank = get_rank(_get_group(group))
359
- self.rank_size = get_group_size(_get_group(group))
358
+ self.group = _get_group(group)
359
+ validator.check_value_type('group', self.group, (str,), self.name)
360
+ self.rank = get_rank(self.group)
361
+ self.rank_size = get_group_size(self.group)
360
362
  validator.check('rank', self.rank, 'rank_size', self.rank_size, validator.LT, self.name)
361
363
  self.add_prim_attr('rank_size', self.rank_size)
362
- self.add_prim_attr('group', _get_group(group))
364
+ self.add_prim_attr('group', self.group)
363
365
  self.add_prim_attr('fusion', 0)
364
366
  self.add_prim_attr('mean_flag', False)
365
367
  self.add_prim_attr('no_eliminate', True)
@@ -375,25 +377,6 @@ class AllGather(PrimitiveWithInfer):
375
377
  return x_dtype
376
378
 
377
379
 
378
- class AShardIdentity(PrimitiveWithInfer):
379
- """
380
- Auto parallel virtual operator. Identity operator only for shard function.
381
- Do nothing in terms of infer_shape, infer_dtype, and the tensor.
382
-
383
- It is only for internal use of parallel modules and cannot be called by users.
384
- """
385
-
386
- @prim_attr_register
387
- def __init__(self):
388
- pass
389
-
390
- def infer_shape(self, x_shape):
391
- return x_shape
392
-
393
- def infer_dtype(self, x_dtype):
394
- return x_dtype
395
-
396
-
397
380
  class _MiniStepAllGather(PrimitiveWithInfer):
398
381
  """
399
382
  Auto parallel virtual operator. Do nothing in forward, do reducescatter in backward in mini-step. It is only for
@@ -555,7 +538,7 @@ class ReduceScatter(Primitive):
555
538
  For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
556
539
  without any third-party or configuration file dependencies.
557
540
  Please see the `msrun start up
558
- <https://www.mindspore.cn/tutorials/experts/zh-CN/master/parallel/msrun_launcher.html>`_
541
+ <https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
559
542
  for more details.
560
543
 
561
544
  This example should be run with 2 devices.
@@ -597,11 +580,12 @@ class ReduceScatter(Primitive):
597
580
  def __init__(self, op=ReduceOp.SUM, group=GlobalComm.WORLD_COMM_GROUP):
598
581
  """Initialize ReduceScatter."""
599
582
  validator.check_value_type('op', op, (type(ReduceOp.SUM),), self.name)
600
- validator.check_value_type('group', _get_group(group), (str,), self.name)
583
+ self.group = _get_group(group)
584
+ validator.check_value_type('group', self.group, (str,), self.name)
601
585
  self.op = op
602
- self.rank_size = get_group_size(_get_group(group))
586
+ self.rank_size = get_group_size(self.group)
603
587
  self.add_prim_attr('rank_size', self.rank_size)
604
- self.add_prim_attr('group', _get_group(group))
588
+ self.add_prim_attr('group', self.group)
605
589
  self.add_prim_attr('fusion', 0)
606
590
  self.add_prim_attr('no_eliminate', True)
607
591
 
@@ -692,7 +676,7 @@ class Broadcast(PrimitiveWithInfer):
692
676
  For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
693
677
  without any third-party or configuration file dependencies.
694
678
  Please see the `msrun start up
695
- <https://www.mindspore.cn/tutorials/experts/zh-CN/master/parallel/msrun_launcher.html>`_
679
+ <https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
696
680
  for more details.
697
681
 
698
682
  This example should be run with 2 devices.
@@ -922,7 +906,7 @@ class AlltoAll(PrimitiveWithInfer):
922
906
  For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
923
907
  without any third-party or configuration file dependencies.
924
908
  Please see the `msrun start up
925
- <https://www.mindspore.cn/tutorials/experts/zh-CN/master/parallel/msrun_launcher.html>`_
909
+ <https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
926
910
  for more details.
927
911
 
928
912
  This example should be run with 8 devices.
@@ -1041,7 +1025,7 @@ class NeighborExchangeV2(Primitive):
1041
1025
  For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
1042
1026
  without any third-party or configuration file dependencies.
1043
1027
  Please see the `msrun start up
1044
- <https://www.mindspore.cn/tutorials/experts/zh-CN/master/parallel/msrun_launcher.html>`_
1028
+ <https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
1045
1029
  for more details.
1046
1030
 
1047
1031
  This example should be run with 2 devices.
@@ -1158,7 +1142,7 @@ class CollectiveScatter(Primitive):
1158
1142
  For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
1159
1143
  without any third-party or configuration file dependencies.
1160
1144
  Please see the `msrun start up
1161
- <https://www.mindspore.cn/tutorials/experts/zh-CN/master/parallel/msrun_launcher.html>`_
1145
+ <https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
1162
1146
  for more details.
1163
1147
 
1164
1148
  This example should be run with 2 devices.
@@ -1243,7 +1227,7 @@ class CollectiveGather(Primitive):
1243
1227
  For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
1244
1228
  without any third-party or configuration file dependencies.
1245
1229
  Please see the `msrun start up
1246
- <https://www.mindspore.cn/tutorials/experts/zh-CN/master/parallel/msrun_launcher.html>`_
1230
+ <https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
1247
1231
  for more details.
1248
1232
 
1249
1233
  This example should be run with 4 devices.
@@ -1308,8 +1292,6 @@ class Barrier(PrimitiveWithInfer):
1308
1292
  Raises:
1309
1293
  TypeError: If `group` is not a str.
1310
1294
  RuntimeError: If backend is invalid, or distributed initialization fails.
1311
- ValueError: If the local rank id of the calling process in the group
1312
- is larger than the group's rank size.
1313
1295
 
1314
1296
  Supported Platforms:
1315
1297
  ``Ascend``
@@ -1321,7 +1303,7 @@ class Barrier(PrimitiveWithInfer):
1321
1303
  For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
1322
1304
  without any third-party or configuration file dependencies.
1323
1305
  Please see the `msrun start up
1324
- <https://www.mindspore.cn/tutorials/experts/zh-CN/master/parallel/msrun_launcher.html>`_
1306
+ <https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
1325
1307
  for more details.
1326
1308
 
1327
1309
  This example should be run with 2 devices.
@@ -1395,7 +1377,7 @@ class Send(PrimitiveWithInfer):
1395
1377
  For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
1396
1378
  without any third-party or configuration file dependencies.
1397
1379
  Please see the `msrun start up
1398
- <https://www.mindspore.cn/tutorials/experts/zh-CN/master/parallel/msrun_launcher.html>`_
1380
+ <https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
1399
1381
  for more details.
1400
1382
 
1401
1383
  This example should be run with 2 devices.
@@ -1431,7 +1413,7 @@ class Send(PrimitiveWithInfer):
1431
1413
  def __init__(self, sr_tag, dest_rank, group=GlobalComm.WORLD_COMM_GROUP, group_back=GlobalComm.WORLD_COMM_GROUP):
1432
1414
  self.rank = dest_rank
1433
1415
  self.sr_tag = sr_tag
1434
- self.group = group
1416
+ self.group = _get_group(group)
1435
1417
  self.add_prim_attr("no_eliminate", True)
1436
1418
 
1437
1419
  def infer_shape(self, x_shape):
@@ -1479,7 +1461,7 @@ class Receive(PrimitiveWithInfer):
1479
1461
  For Ascend/GPU/CPU devices, it is recommended to use the msrun startup method
1480
1462
  without any third-party or configuration file dependencies.
1481
1463
  Please see the `msrun start up
1482
- <https://www.mindspore.cn/tutorials/experts/zh-CN/master/parallel/msrun_launcher.html>`_
1464
+ <https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
1483
1465
  for more details.
1484
1466
 
1485
1467
  This example should be run with 2 devices.
@@ -1517,7 +1499,7 @@ class Receive(PrimitiveWithInfer):
1517
1499
  self.tag = sr_tag
1518
1500
  self.shape = shape
1519
1501
  self.dtype = dtype
1520
- self.group = group
1502
+ self.group = _get_group(group)
1521
1503
  self.add_prim_attr("no_eliminate", True)
1522
1504
  valid_type = [mstype.float16, mstype.float32, mstype.float64, mstype.bfloat16,
1523
1505
  mstype.int8, mstype.int16, mstype.int32, mstype.int64,
@@ -1695,6 +1677,8 @@ class _VirtualAssignAdd(PrimitiveWithInfer):
1695
1677
 
1696
1678
  def infer_dtype(self, x_dtype, y_dtype):
1697
1679
  return x_dtype
1680
+
1681
+
1698
1682
  virtual_assign_add = _VirtualAssignAdd()
1699
1683
 
1700
1684
 
@@ -1834,7 +1818,7 @@ class BatchISendIRecv(PrimitiveWithInfer):
1834
1818
  without any third-party or configuration file dependencies.
1835
1819
 
1836
1820
  Please see the `msrun start up
1837
- <https://www.mindspore.cn/tutorials/experts/zh-CN/master/parallel/msrun_launcher.html>`_
1821
+ <https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
1838
1822
  for more details.
1839
1823
 
1840
1824
  This example should be run with 2 devices.
@@ -1924,6 +1908,7 @@ class AlltoAllV(PrimitiveWithInfer):
1924
1908
  recv_numel_list(Union[tuple[int], list[int]]): split numel to gather from different remote rank.
1925
1909
  group (str): The communication group to work on. Default: ``GlobalComm.WORLD_COMM_GROUP``, which
1926
1910
  means ``"hccl_world_group"`` in Ascend, and ``"nccl_world_group"`` in GPU.
1911
+ TODO:
1927
1912
 
1928
1913
  Inputs:
1929
1914
  - **input_x** (Tensor) - flatten tensor to scatter. The shape of tensor is :math:`(x_1)`.
@@ -1946,7 +1931,7 @@ class AlltoAllV(PrimitiveWithInfer):
1946
1931
  without any third-party or configuration file dependencies.
1947
1932
 
1948
1933
  Please see the `msrun start up
1949
- <https://www.mindspore.cn/tutorials/experts/zh-CN/master/parallel/msrun_launcher.html>`_
1934
+ <https://www.mindspore.cn/docs/zh-CN/master/model_train/parallel/msrun_launcher.html>`_
1950
1935
  for more details.
1951
1936
 
1952
1937
  This example should be run with 2 devices.
@@ -1986,11 +1971,15 @@ class AlltoAllV(PrimitiveWithInfer):
1986
1971
  """
1987
1972
 
1988
1973
  @prim_attr_register
1989
- def __init__(self, send_numel_list, recv_numel_list, group=None):
1974
+ def __init__(self, send_numel_list, recv_numel_list, group=None, split_sizes_empty=False):
1990
1975
  validator.check_value_type("send_numel_list", send_numel_list, [tuple, list], self.name)
1991
1976
  validator.check_value_type("recv_numel_list", recv_numel_list, [tuple, list], self.name)
1992
- if group is None:
1993
- group = GlobalComm.WORLD_COMM_GROUP
1994
- self.add_prim_attr('group', group)
1977
+ self.group = GlobalComm.WORLD_COMM_GROUP if group is None else _get_group(group)
1978
+ self.send_numel_list = send_numel_list
1979
+ self.recv_numel_list = recv_numel_list
1980
+ self.split_sizes_empty = split_sizes_empty
1981
+ self.rank_size = get_group_size(self.group)
1982
+
1983
+ self.add_prim_attr('group', self.group)
1995
1984
  self.add_prim_attr('send_numel_list', send_numel_list)
1996
1985
  self.add_prim_attr('recv_numel_list', recv_numel_list)
@@ -28,6 +28,8 @@ import subprocess
28
28
  import numpy as np
29
29
  import mindspore as ms
30
30
  from mindspore._c_expression import Oplib, typing
31
+ from mindspore._c_expression import pyboost_custom_ext
32
+ from mindspore.common._stub_tensor import _convert_stub
31
33
  from mindspore import context
32
34
  from mindspore.common import Tensor
33
35
  from mindspore.common import dtype as mstype
@@ -156,6 +158,55 @@ def _compile_aot(file):
156
158
  return func_path
157
159
 
158
160
 
161
+ class _CustomExt(ops.PrimitiveWithInfer):
162
+ """
163
+ `Custom` primitive is used for PyBoost.
164
+ """
165
+
166
+ def __init__(self, func, out_shape=None, out_dtype=None, bprop=None):
167
+ super().__init__("CustomExt")
168
+ self.func = func
169
+ self.out_shape = out_shape
170
+ self.out_dtype = out_dtype
171
+ self.bprop = bprop
172
+
173
+ def __infer__(self, *args):
174
+ if callable(self.out_shape):
175
+ infer_shape = self.out_shape(*(x["shape"] for x in args))
176
+ else:
177
+ infer_shape = self.out_shape
178
+
179
+ if callable(self.out_dtype):
180
+ infer_dtype = self.out_dtype(*(x["dtype"] for x in args))
181
+ else:
182
+ infer_dtype = self.out_dtype
183
+
184
+ infer_value = None
185
+ if infer_shape is None:
186
+ logger.warning("'out_shape' is None. Add a placeholder instead. "
187
+ "A CPP version of infer shape function is required "
188
+ "in this case.")
189
+ infer_shape = (1,)
190
+ # after all automatic infer information fulfillment, throw error if infer_shape/infer_dtype is still None
191
+ if not isinstance(infer_shape, (tuple, list)):
192
+ raise TypeError("'out_shape' must be one of [tuple, list, function], but got {}".format(type(infer_shape)))
193
+
194
+ if not isinstance(infer_dtype, (typing.Type, tuple, list)):
195
+ raise TypeError("'out_dtype' must be one of [mindspore.dtype, tuple, list, function], but got {}"
196
+ .format(type(infer_dtype)))
197
+
198
+ out = {
199
+ "shape": infer_shape,
200
+ "dtype": infer_dtype,
201
+ "value": infer_value,
202
+ }
203
+ return out
204
+
205
+ def get_bprop(self):
206
+ """return back propagation function"""
207
+ return self.bprop
208
+
209
+
159
210
  class Custom(ops.PrimitiveWithInfer):
160
211
  r"""
161
212
  `Custom` primitive is used for user defined operators and is to enhance the expressive ability of built-in
@@ -164,7 +215,7 @@ class Custom(ops.PrimitiveWithInfer):
164
215
  function if needed. Then these `Custom` objects can be directly used in neural networks.
165
216
  Detailed description and introduction of user-defined operators, including correct writing of parameters,
166
217
  please refer to `Custom Operators Tutorial
167
- <https://www.mindspore.cn/tutorials/experts/en/master/operation/op_custom.html>`_ .
218
+ <https://www.mindspore.cn/docs/en/master/model_train/custom_program/op_custom.html>`_ .
168
219
 
169
220
  .. warning::
170
221
  - This is an experimental API that is subject to change.
@@ -174,7 +225,7 @@ class Custom(ops.PrimitiveWithInfer):
174
225
 
175
226
  - "hybrid": supports ["GPU", "CPU"].
176
227
  - "akg": supports ["GPU", "CPU"].
177
- - "aot": supports ["GPU", "CPU", "ASCEDN"].
228
+ - "aot": supports ["GPU", "CPU", "Ascend"].
178
229
  - "pyfunc": supports ["CPU"].
179
230
  - "julia": supports ["CPU"].
180
231
 
@@ -249,20 +300,18 @@ class Custom(ops.PrimitiveWithInfer):
249
300
  (ex. Custom(func="./reorganize.so:CustomReorganize", out_shape=[1], out_dtype=mstype.float32,
250
301
  "aot"))
251
302
 
252
- b) ASCEND platform
253
- Before using Custom operators on the ASCEND platform, users must first develop custom operators
254
- based on Ascend C and compile them. For operator development, you can refer to the tutorial on
255
- `Quick Start for End-to-End Operator Development
256
- <https://www.hiascend.com/document/detail/zh/canncommercial/70RC1/operatordev/Ascendcopdevg/atlas_ascendc_10_0022.html>`_,
257
- and for compiling custom operators, you can use the `Offline Compilation of Ascend C Custom Operators
258
- <https://www.mindspore.cn/tutorials/experts/en/master/operation/op_custom_ascendc.html>` tool.
259
- When passing the operator's name into the func parameter, taking AddCustom as an example for the
260
- name given in the custom operator implementation, there are several ways to use it:
261
-
262
- - Usin TBE: func="AddCustom"
263
- - Using AclNN: func="aclnnAddCustom"
264
- - Inferring the shape of the operator through C++ derivation: func="infer_shape.cc:aclnnAddCustom",
265
- where infer_shape.cc is the shape derivation implemented in C++.
303
+ b) Ascend platform.
304
+ Before using Custom operators on the Ascend platform, users must first develop custom operators
305
+ based on Ascend C and compile them. The complete development and usage process can refer to the
306
+ tutorial `AOT-Type Custom Operators(Ascend) <https://www.mindspore.cn/docs/en/master/model_train/custom_program/operation/op_custom_ascendc.html>`_.
307
+ By passing the name of the operator through the input parameter `func`, there are two usage methods
308
+ based on the implementation of the infer shape function:
309
+
310
+ - Python infer: If the operator's infer shape is implemented in Python, that is, the infer shape
311
+ function is passed through the `out_shape` parameter, specify `func="CustomName"` .
312
+ - C++ infer: If the operator's infer shape is implemented through C++, then pass the path of the
313
+ infer shape implementation file in `func` and separate the operator name with `:`,
314
+ for example: `func="add_custom_infer.cc:AddCustom"` .
266
315
 
267
316
  2. for "julia":
268
317
 
@@ -338,7 +387,7 @@ class Custom(ops.PrimitiveWithInfer):
338
387
  or the attributes of `func` differs in different targets.
339
388
 
340
389
  Supported Platforms:
341
- ``GPU`` ``CPU`` ``ASCEND``
390
+ ``Ascend`` ``GPU`` ``CPU``
342
391
 
343
392
  Examples:
344
393
  >>> import numpy as np
@@ -457,6 +506,12 @@ class Custom(ops.PrimitiveWithInfer):
457
506
 
458
507
  self.add_prim_attr("func_type", self.func_type)
459
508
  self._update_attr()
509
+ self.enable_pyboost = False
510
+ self.custom_pyboost = _CustomExt(self.func, self.out_shape, self.out_dtype, self.bprop)
511
+ if context.get_context("device_target") == "Ascend" and self.func_type == "aot":
512
+ self.enable_pyboost = True
513
+ for key, value in super().get_attr_dict().items():
514
+ self.custom_pyboost.add_prim_attr(key, value)
460
515
 
461
516
  def __infer__(self, *args):
462
517
  if callable(self.out_shape):
@@ -559,7 +614,7 @@ class Custom(ops.PrimitiveWithInfer):
559
614
  raise TypeError(
560
615
  "{}, 'func' should be like 'file_name:func_name', but got {}".format(
561
616
  self.log_prefix, self.func))
562
- file_path = os.path.abspath(file_name_list[0])
617
+ file_path = os.path.realpath(file_name_list[0])
563
618
  if os.environ.get('MS_CUSTOM_AOT_WHITE_LIST') is None:
564
619
  if Custom.custom_aot_warning:
565
620
  logger.info("{}, no white list is set and it might cause problems. "
@@ -567,7 +622,7 @@ class Custom(ops.PrimitiveWithInfer):
567
622
  .format(self.log_prefix))
568
623
  Custom.custom_aot_warning = False
569
624
  else:
570
- legal_path = os.path.abspath(os.environ.get('MS_CUSTOM_AOT_WHITE_LIST'))
625
+ legal_path = os.path.realpath(os.environ.get('MS_CUSTOM_AOT_WHITE_LIST'))
571
626
  if legal_path not in file_path:
572
627
  raise TypeError(
573
628
  "{}, the legal path for the file is {}, but the file is {}".format(
@@ -1063,3 +1118,12 @@ class Custom(ops.PrimitiveWithInfer):
1063
1118
  infer_value = Tensor(fake_output) if enable_infer_value else None
1064
1119
 
1065
1120
  return infer_shape, infer_dtype, infer_value
1121
+
1122
+ def __call__(self, *args):
1123
+ if self.enable_pyboost:
1124
+ return _convert_stub(pyboost_custom_ext(self.custom_pyboost, [args]))
1125
+ should_elim, output = self.check_elim(*args)
1126
+ if should_elim:
1127
+ return output
1128
+ # pylint: disable=protected-access
1129
+ return ops.primitive._run_op(self, self.name, args)
@@ -15,17 +15,17 @@
15
15
  """debug_ops"""
16
16
  import os
17
17
  import stat
18
- from types import FunctionType, MethodType
19
18
 
20
19
  import numpy as np
21
20
  from mindspore import log as logger
22
- from mindspore._c_expression import security
21
+ from mindspore._c_expression import security, HookType
23
22
  from mindspore._c_expression import Tensor as Tensor_
24
23
  from mindspore import _checkparam as validator
25
24
  from mindspore.common import dtype as mstype
26
25
  from mindspore.common.parameter import Parameter
27
26
  from mindspore.common.tensor import Tensor
28
27
  from mindspore.ops.primitive import prim_attr_register, Primitive, PrimitiveWithInfer
28
+ from mindspore._checkparam import check_hook_fn
29
29
 
30
30
 
31
31
  SUMMARY_TENSOR_CACHE = []
@@ -64,6 +64,8 @@ class ScalarSummary(Primitive):
64
64
  which specify the directory of the summary file. The summary file can
65
65
  be loaded and shown by MindInsight, see `MindInsight documents <https://www.mindspore.cn/
66
66
  mindinsight/docs/en/master/index.html>`_ for details.
67
+ In Ascend platform with graph mode, can set environment variables `MS_DUMP_SLICE_SIZE` and `MS_DUMP_WAIT_TIME`
68
+ to solve operator execution failure when calling this operator intensively.
67
69
 
68
70
  Inputs:
69
71
  - **name** (str) - The name of the input variable, it must not be an empty string.
@@ -122,6 +124,8 @@ class ImageSummary(Primitive):
122
124
  SummaryRecord or SummaryCollector, which specify the directory of the summary file. The summary file can
123
125
  be loaded and shown by MindInsight, see `MindInsight documents <https://www.mindspore.cn/
124
126
  mindinsight/docs/en/master/index.html>`_ for details.
127
+ In Ascend platform with graph mode, can set environment variables `MS_DUMP_SLICE_SIZE` and `MS_DUMP_WAIT_TIME`
128
+ to solve operator execution failure when calling this operator intensively.
125
129
 
126
130
  Inputs:
127
131
  - **name** (str) - The name of the input variable, it must not be an empty string.
@@ -173,6 +177,8 @@ class TensorSummary(Primitive):
173
177
  or SummaryCollector, which specify the directory of the summary file. The summary file can
174
178
  be loaded and shown by MindInsight, see `MindInsight documents <https://www.mindspore.cn/
175
179
  mindinsight/docs/en/master/index.html>`_ for details.
180
+ In Ascend platform with graph mode, can set environment variables `MS_DUMP_SLICE_SIZE` and `MS_DUMP_WAIT_TIME`
181
+ to solve operator execution failure when calling this operator intensively.
176
182
 
177
183
  Inputs:
178
184
  - **name** (str) - The name of the input variable.
@@ -228,9 +234,6 @@ class TensorDump(Primitive):
228
234
  """
229
235
  Save the Tensor as an npy file in numpy format.
230
236
 
231
- The file name will automatically have a prefix added based on the execution order. For example, if `file` is `a`,
232
- the first saved file will be named `0_a.npy`, and the second one will be named `1_a.npy`, and so on.
233
-
234
237
  .. warning::
235
238
  - If a large amount of data is stored within a short period, it may lead to memory overflow on the device side.
236
239
  Consider slicing the data to reduce the data scale.
@@ -238,6 +241,34 @@ class TensorDump(Primitive):
238
241
  too quickly, data loss may occur. You need to actively control the destruction time of the main process,
239
242
  such as using sleep.
240
243
 
244
+ Args:
245
+ input_output (str, optional): Used to control Tensordump behavior.
246
+ Available value is one of ['in', 'out', 'all']. Default value is ``out``.
247
+
248
+ In case of OpA --> RedistributionOps --> OpB,
249
+ The dump data of OpA's output is not equal to OpB's input (Due to the redistribution operators).
250
+ So the parameter input_output is to handle this situation.
251
+
252
+ Assuming OpA's output is used as both Tensordump's input parameter and OpB's input parameter.
253
+ Different requirements of saving dump data can be achieved by configuring parameter input_output:
254
+
255
+ - If the input_output is 'out', the dump data contains only OpA's output slice.
256
+ - If the input_output is 'all', the dump data contains both OpA's output slice and OpB's input slice.
257
+ - If the input_output is 'in', the dump data contains only OpB's input slice.
258
+
259
+ For input_output is 'all' or 'in', the input slice npy file format is:
260
+ id_fileName_cNodeID_dumpMode_rankID.npy.
261
+
262
+ For input_output is 'out' or 'all' the output slice npy file format is:
263
+ id_fileName.npy.
264
+
265
+ - id: An auto increment ID.
266
+ - fileName: Value of the parameter file
267
+ (if parameter file_name is a user-specified path, the value of fileName is the last level of the path).
268
+ - cNodeID: The node ID of the Tensordump node in the step_parallel_end.ir file.
269
+ - dumpMode: Value of the parameter input_output.
270
+ - rankID: Logical device id.
271
+
241
272
  Inputs:
242
273
  - **file** (str) - The path of the file to be saved.
243
274
  - **input_x** (Tensor) - Input Tensor of any dimension.
@@ -280,7 +311,7 @@ class TensorDump(Primitive):
280
311
  [6. 7. 8. 9.]]
281
312
  """
282
313
  @prim_attr_register
283
- def __init__(self):
314
+ def __init__(self, input_output='out'):
284
315
  """Initialize TensorDump."""
285
316
  if security.enable_security():
286
317
  raise ValueError('The TensorDump is not supported, please without `-s on` and recompile source.')
@@ -314,6 +345,8 @@ class HistogramSummary(Primitive):
314
345
  It must be used with SummaryRecord or SummaryCollector, which specify the directory of the summary file.
315
346
  The summary file can be loaded and shown by MindInsight, see `MindInsight documents <https://www.mindspore.cn/
316
347
  mindinsight/docs/en/master/index.html>`_ for details.
348
+ In Ascend platform with graph mode, can set environment variables `MS_DUMP_SLICE_SIZE` and `MS_DUMP_WAIT_TIME`
349
+ to solve operator execution failure when calling this operator intensively.
317
350
 
318
351
  Inputs:
319
352
  - **name** (str) - The name of the input variable.
@@ -499,16 +532,15 @@ class HookBackward(PrimitiveWithInfer):
499
532
  def __init__(self, hook_fn, cell_id=""):
500
533
  """Initialize HookBackward."""
501
534
  super(HookBackward, self).__init__(self.__class__.__name__)
502
- if not isinstance(hook_fn, (FunctionType, MethodType)):
503
- raise TypeError(f"For '{self.name}', the type of 'hook_fn' must be python function, "
504
- f"but got {type(hook_fn)}.")
535
+ if not check_hook_fn("HookBackward", hook_fn):
536
+ return
505
537
  if cell_id != "":
506
538
  logger.warning(f"The args 'cell_id' of HookBackward will be removed in a future version. If the value of "
507
539
  f"'cell_id' is set, the hook function will not work.")
508
540
  self.add_prim_attr("cell_id", cell_id)
509
541
  self.init_attrs["cell_id"] = cell_id
510
542
  self.cell_id = cell_id
511
- self.add_backward_hook_fn(hook_fn)
543
+ self.set_hook_fn(hook_fn, HookType.HookBackward)
512
544
 
513
545
  def infer_shape(self, *inputs_shape):
514
546
  if len(inputs_shape) == 1:
@@ -23,6 +23,7 @@ from mindspore.common import dtype as mstype
23
23
  from mindspore import _checkparam as validator
24
24
  from mindspore.common._decorator import deprecated
25
25
  from mindspore.ops.primitive import prim_attr_register, Primitive
26
+ from mindspore import log as logger
26
27
 
27
28
 
28
29
  class ScalarCast(Primitive):
@@ -59,3 +60,14 @@ class ScalarCast(Primitive):
59
60
  value = np.cast[np_dtype.lower()](input_x)
60
61
  value = value.item()
61
62
  return value
63
+
64
+
65
+ class TensorReport(Primitive):
66
+ @prim_attr_register
67
+ def __init__(self):
68
+ """Initialize TensorReport"""
69
+ self.add_prim_attr("side_effect_io", True)
70
+ self.add_prim_attr("channel_name", "ms_tensor_report")
71
+
72
+ def __call__(self, file, input_x):
73
+ logger.warning("TensorReport doesn't support pynative mode.")