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
@@ -28,6 +28,7 @@ import template
28
28
  from template import CppTemplate
29
29
  from gen_pyboost_func import gen_pyboost_code
30
30
  from gen_aclnn_implement import gen_aclnn_kernel
31
+ import gen_constants as K
31
32
 
32
33
 
33
34
  def _get_op_name(yaml_key, yaml_value):
@@ -185,6 +186,7 @@ def generate_py_op_signature(op_name, args_signature, args_name, args_default):
185
186
  """
186
187
  Generate __mindspore_signature__
187
188
  """
189
+
188
190
  def _check_signature_arg_valid(op_name, sig_arg_names, args_names):
189
191
  for sig_arg_name in sig_arg_names:
190
192
  if sig_arg_name not in args_names:
@@ -635,7 +637,7 @@ def generate_op_prim_opdef(yaml_data):
635
637
  #include <memory>
636
638
  #include "ir/anf.h"
637
639
  #include "ir/primitive.h"
638
- #include "ops/auto_generate/gen_ops_name.h"
640
+ #include "{K.MS_OP_DEF_AUTO_GENERATE_PATH}/gen_ops_name.h"
639
641
  #include "mindapi/base/macros.h"
640
642
 
641
643
  namespace mindspore::prim {{
@@ -665,7 +667,7 @@ def generate_lite_ops(yaml_data):
665
667
 
666
668
  #include <vector>
667
669
  #include "ops/base_operator.h"
668
- #include "ops/auto_generate/gen_ops_name.h"
670
+ #include "{K.OP_DEF_AUTO_GENERATE_PATH}/gen_ops_name.h"
669
671
 
670
672
  namespace mindspore::ops {{
671
673
  """
@@ -674,14 +676,14 @@ namespace mindspore::ops {{
674
676
  #endif // MINDSPORE_CORE_OPS_GEN_LITE_OPS_H_
675
677
  """
676
678
 
677
- lite_ops_cc_head = """
678
- #include "ops/auto_generate/gen_lite_ops.h"
679
- #include "mindapi/src/helper.h"
679
+ lite_ops_cc_head = f"""
680
+ #include "{K.OP_DEF_AUTO_GENERATE_PATH}/gen_lite_ops.h"
681
+ #include "mindapi/helper.h"
680
682
  #include "ops/primitive_c.h"
681
683
  #include "ops/base_operator.h"
682
684
  #include "abstract/abstract_value.h"
683
685
 
684
- namespace mindspore::ops {
686
+ namespace mindspore::ops {{
685
687
  """
686
688
 
687
689
  lite_ops_cc_end = f"""}} // namespace mindspore::ops
@@ -694,7 +696,7 @@ namespace mindspore::ops {
694
696
  lite_ops_cc_gen += lite_ops_cc_head
695
697
  for operator_name, operator_data in yaml_data.items():
696
698
  op_name = _get_op_name(operator_name, operator_data)
697
- lite_ops_h_gen += f"""class MIND_API {op_name} : public BaseOperator {{
699
+ lite_ops_h_gen += f"""class OPS_API {op_name} : public BaseOperator {{
698
700
  public:
699
701
  MIND_API_BASE_MEMBER({op_name});
700
702
  {op_name}() : BaseOperator(kName{op_name}) {{}}\n"""
@@ -740,12 +742,10 @@ def generate_cc_opdef(yaml_data):
740
742
  """
741
743
  gen_cc_code = f"""\n
742
744
  namespace mindspore::ops {{"""
743
- gen_opdef_map = f"""
744
- std::unordered_map<std::string, OpDefPtr> gOpDefTable = {{"""
745
745
  gen_include = f"""\n
746
- #include \"ops/auto_generate/gen_ops_def.h\""""
746
+ #include \"{K.MS_OP_DEF_AUTO_GENERATE_PATH}/gen_ops_def.h\""""
747
747
  gen_include += f"""
748
- #include \"mindspore/core/ir/signature.h\""""
748
+ #include \"ir/signature.h\""""
749
749
 
750
750
  for operator_name, operator_data in yaml_data.items():
751
751
  args = operator_data.get('args')
@@ -764,15 +764,13 @@ std::unordered_map<std::string, OpDefPtr> gOpDefTable = {{"""
764
764
 
765
765
  is_view = operator_data.get('view')
766
766
  if is_view:
767
- is_view = "true"
767
+ is_view_s = "true"
768
768
  else:
769
- is_view = "false"
770
- is_view_str = f"""{is_view}"""
771
-
769
+ is_view_s = "false"
770
+ is_view_str = f"""{is_view_s}"""
772
771
 
773
- gen_include += f"""\n#include "ops/ops_func_impl/{operator_name}.h\""""
772
+ gen_include += f"""\n#include "{K.MS_OPS_FUNC_IMPL_PATH}/{operator_name}.h\""""
774
773
  cc_index_str = ''
775
- gen_opdef_map += f"""\n {{"{class_name}", &g{class_name}}},"""
776
774
  input_args_str = ''
777
775
  args_dict = {}
778
776
  for i, (arg_name, arg_info) in enumerate(args.items()):
@@ -814,8 +812,9 @@ std::unordered_map<std::string, OpDefPtr> gOpDefTable = {{"""
814
812
  indexes=cc_index_str, enable_dispatch=enable_dispatch_str,
815
813
  is_view=is_view_str)
816
814
  gen_cc_code += op_def_cc
817
- gen_opdef_map += f"""\n}};"""
818
- gen_cc_code += gen_opdef_map
815
+ if is_view:
816
+ view_op_def = op_def_cc.replace(class_name, class_name+"View")
817
+ gen_cc_code += view_op_def
819
818
 
820
819
  cc_opdef_end = f"""\n}} // namespace mindspore::ops\n"""
821
820
  return gen_include + gen_cc_code + cc_opdef_end
@@ -835,7 +834,6 @@ from mindspore._c_expression import OpDtype
835
834
  from mindspore.common._stub_tensor import _convert_stub
836
835
  """
837
836
 
838
-
839
837
  ops_py_def_header = f"""
840
838
  \"\"\"Operators definition generated by gen_ops.py, includes functions.\"\"\"
841
839
 
@@ -847,8 +845,8 @@ from mindspore.ops._primitive_cache import _get_cache_prim
847
845
 
848
846
 
849
847
  def generate_ops_prim_file(work_path, yaml_str, doc_str, file_pre):
850
- py_path = os.path.join(work_path, f'mindspore/python/mindspore/ops/auto_generate/{file_pre}_ops_prim.py')
851
- tmp_py_path = os.path.join(work_path, f'mindspore/python/mindspore/ops/auto_generate/tmp_{file_pre}_ops_prim.py')
848
+ py_path = os.path.join(work_path, f'{K.PY_AUTO_GEN_PATH}/{file_pre}_ops_prim.py')
849
+ tmp_py_path = os.path.join(work_path, f'{K.PY_AUTO_GEN_PATH}/tmp_{file_pre}_ops_prim.py')
852
850
  pyboost_import_header = generate_pyboost_import_header(yaml_str)
853
851
  py_prim = generate_py_primitive(yaml_str, doc_str)
854
852
  write_file(tmp_py_path, py_licence_str + ops_py_prim_header + pyboost_import_header + py_prim)
@@ -856,8 +854,8 @@ def generate_ops_prim_file(work_path, yaml_str, doc_str, file_pre):
856
854
 
857
855
 
858
856
  def generate_ops_def_file(work_path, yaml_str, doc_str, file_pre):
859
- py_path = os.path.join(work_path, f'mindspore/python/mindspore/ops/auto_generate/{file_pre}_ops_def.py')
860
- tmp_py_path = os.path.join(work_path, f'mindspore/python/mindspore/ops/auto_generate/tmp_{file_pre}_ops_def.py')
857
+ py_path = os.path.join(work_path, f'{K.PY_AUTO_GEN_PATH}/{file_pre}_ops_def.py')
858
+ tmp_py_path = os.path.join(work_path, f'{K.PY_AUTO_GEN_PATH}/tmp_{file_pre}_ops_def.py')
861
859
  py_func = generate_py_op_func(yaml_str, doc_str)
862
860
  write_file(tmp_py_path, py_licence_str + ops_py_def_header + py_func)
863
861
  check_change_and_replace_file(py_path, tmp_py_path)
@@ -869,6 +867,8 @@ def generate_ops_py_files(work_path, yaml_str, doc_str, file_pre):
869
867
  """
870
868
  generate_ops_prim_file(work_path, yaml_str, doc_str, file_pre)
871
869
  generate_ops_def_file(work_path, yaml_str, doc_str, file_pre)
870
+ shutil.copy(os.path.join(work_path, K.PY_OPS_GEN_PATH, 'ops_auto_generate_init.txt'),
871
+ os.path.join(work_path, K.PY_AUTO_GEN_PATH, "__init__.py"))
872
872
 
873
873
 
874
874
  def generate_ops_cc_files(work_path, yaml_str):
@@ -876,35 +876,35 @@ def generate_ops_cc_files(work_path, yaml_str):
876
876
  Generate ops c++ file from yaml.
877
877
  """
878
878
  # ops_def
879
- op_cc_path = os.path.join(work_path, 'mindspore/core/ops/auto_generate/gen_ops_def.cc')
880
- tmp_op_cc_path = os.path.join(work_path, 'mindspore/core/ops/auto_generate/tmp_gen_ops_def.cc')
879
+ op_cc_path = os.path.join(work_path, K.MS_OP_DEF_AUTO_GENERATE_PATH, 'gen_ops_def.cc')
880
+ tmp_op_cc_path = os.path.join(work_path, K.MS_OP_DEF_AUTO_GENERATE_PATH, 'tmp_gen_ops_def.cc')
881
881
  cc_def_code = generate_cc_opdef(yaml_str)
882
882
  write_file(tmp_op_cc_path, cc_license_str + cc_def_code)
883
883
  check_change_and_replace_file(op_cc_path, tmp_op_cc_path)
884
884
 
885
885
  # ops_primitive
886
- op_prim_path = os.path.join(work_path, 'mindspore/core/ops/auto_generate/gen_ops_primitive.h')
887
- tmp_op_prim_path = os.path.join(work_path, 'mindspore/core/ops/auto_generate/tmp_gen_ops_primitive.h')
886
+ op_prim_path = os.path.join(work_path, K.MS_OP_DEF_AUTO_GENERATE_PATH, 'gen_ops_primitive.h')
887
+ tmp_op_prim_path = os.path.join(work_path, K.MS_OP_DEF_AUTO_GENERATE_PATH, 'tmp_gen_ops_primitive.h')
888
888
  op_prim_code = generate_op_prim_opdef(yaml_str)
889
889
  write_file(tmp_op_prim_path, cc_license_str + op_prim_code)
890
890
  check_change_and_replace_file(op_prim_path, tmp_op_prim_path)
891
891
 
892
892
  # lite_h_ops
893
- lite_ops_h_path = os.path.join(work_path, 'mindspore/core/ops/auto_generate/gen_lite_ops.h')
894
- tmp_lite_ops_h_path = os.path.join(work_path, 'mindspore/core/ops/auto_generate/tmp_gen_lite_ops.h')
893
+ lite_ops_h_path = os.path.join(work_path, K.MS_OP_DEF_AUTO_GENERATE_PATH, 'gen_lite_ops.h')
894
+ tmp_lite_ops_h_path = os.path.join(work_path, K.MS_OP_DEF_AUTO_GENERATE_PATH, 'tmp_gen_lite_ops.h')
895
895
  lite_ops_h_code, lite_ops_cc_code = generate_lite_ops(yaml_str)
896
896
  write_file(tmp_lite_ops_h_path, cc_license_str + lite_ops_h_code)
897
897
  check_change_and_replace_file(lite_ops_h_path, tmp_lite_ops_h_path)
898
898
 
899
899
  # lite_cc_ops
900
- lite_ops_cc_path = os.path.join(work_path, 'mindspore/core/ops/auto_generate/gen_lite_ops.cc')
901
- tmp_lite_ops_cc_path = os.path.join(work_path, 'mindspore/core/ops/auto_generate/tmp_gen_lite_ops.cc')
900
+ lite_ops_cc_path = os.path.join(work_path, K.MS_OP_DEF_AUTO_GENERATE_PATH, 'gen_lite_ops.cc')
901
+ tmp_lite_ops_cc_path = os.path.join(work_path, K.MS_OP_DEF_AUTO_GENERATE_PATH, 'tmp_gen_lite_ops.cc')
902
902
  write_file(tmp_lite_ops_cc_path, cc_license_str + lite_ops_cc_code)
903
903
  check_change_and_replace_file(lite_ops_cc_path, tmp_lite_ops_cc_path)
904
904
 
905
905
  # ops_names
906
- op_name_path = os.path.join(work_path, 'mindspore/core/ops/auto_generate/gen_ops_name.h')
907
- tmp_op_name_path = os.path.join(work_path, 'mindspore/core/ops/auto_generate/tmp_gen_ops_name.h')
906
+ op_name_path = os.path.join(work_path, K.MS_OP_DEF_AUTO_GENERATE_PATH, 'gen_ops_name.h')
907
+ tmp_op_name_path = os.path.join(work_path, K.MS_OP_DEF_AUTO_GENERATE_PATH, 'tmp_gen_ops_name.h')
908
908
  op_name_code = generate_op_name_opdef(yaml_str)
909
909
  write_file(tmp_op_name_path, cc_license_str + op_name_code)
910
910
  check_change_and_replace_file(op_name_path, tmp_op_name_path)
@@ -958,7 +958,7 @@ def generate_create_instance_helper_file(work_path, yaml_str):
958
958
  """
959
959
  Generate C++ helper file from yaml.
960
960
  """
961
- dst_dir = os.path.join(work_path, 'mindspore/python/mindspore/ops/auto_generate')
961
+ dst_dir = os.path.join(work_path, K.PY_AUTO_GEN_PATH)
962
962
  op_py_path = os.path.join(dst_dir, 'cpp_create_prim_instance_helper.py')
963
963
  tmp_op_py_path = os.path.join(dst_dir, 'tmp_cpp_create_prim_instance_helper.py')
964
964
  py_labels = generate_op_labels(yaml_str)
@@ -969,13 +969,13 @@ def generate_create_instance_helper_file(work_path, yaml_str):
969
969
 
970
970
  def generate_aclnn_reg_code(yaml_data):
971
971
  """generate aclnn register code"""
972
- current_path = os.path.dirname(os.path.abspath(__file__))
972
+ current_path = os.path.dirname(os.path.realpath(__file__))
973
973
  work_path = os.path.join(current_path, '../../../../')
974
- ops_yaml_path = os.path.join(work_path, 'mindspore/python/mindspore/ops_generate/ops.yaml')
974
+ ops_yaml_path = os.path.join(work_path, K.PY_OPS_GEN_PATH, "ops.yaml")
975
975
  yaml_str = gen_utils.safe_load_yaml(ops_yaml_path)
976
976
 
977
977
  reg_code = f"""
978
- #include "plugin/device/ascend/kernel/opapi/aclnn_kernel_mod.h"
978
+ #include "{K.MS_OPS_KERNEL_PATH}/ascend/opapi/aclnn_kernel_mod.h"
979
979
 
980
980
  namespace mindspore {{
981
981
  namespace kernel {{
@@ -1010,8 +1010,8 @@ def generate_aclnn_reg_file(work_path, yaml_str):
1010
1010
  """
1011
1011
  Generate nnacl kernelmod register
1012
1012
  """
1013
- tmp_register_file = work_path + 'mindspore/ccsrc/plugin/device/ascend/kernel/opapi/tmp_aclnn_kernel_register.cc'
1014
- register_file = work_path + 'mindspore/ccsrc/plugin/device/ascend/kernel/opapi/aclnn_kernel_register_auto.cc'
1013
+ tmp_register_file = work_path + f'{K.MS_OPS_KERNEL_PATH}/ascend/opapi/tmp_aclnn_kernel_register.cc'
1014
+ register_file = work_path + f'{K.MS_OPS_KERNEL_PATH}/ascend/opapi/aclnn_kernel_register_auto.cc'
1015
1015
  reg_code = generate_aclnn_reg_code(yaml_str)
1016
1016
  write_file(tmp_register_file, cc_license_str + reg_code)
1017
1017
  check_change_and_replace_file(register_file, tmp_register_file)
@@ -1021,39 +1021,52 @@ def generate_arg_handler_files(work_path):
1021
1021
  """
1022
1022
  Generate arg handler files.
1023
1023
  """
1024
- dst_dir = os.path.join(work_path, 'mindspore/python/mindspore/ops/auto_generate')
1025
- src_arg_handler_path = os.path.join(work_path, 'mindspore/python/mindspore/ops_generate/arg_handler.py')
1024
+ dst_dir = os.path.join(work_path, K.PY_AUTO_GEN_PATH)
1025
+ src_arg_handler_path = os.path.join(work_path, K.PY_OPS_GEN_PATH, 'arg_handler.py')
1026
1026
  dst_arg_handler_path = os.path.join(dst_dir, 'gen_arg_handler.py')
1027
1027
  tmp_dst_arg_handler_path = os.path.join(dst_dir, 'tmp_gen_arg_handler.py')
1028
1028
  if not os.path.exists(dst_dir):
1029
- os.makedirs(dst_dir)
1029
+ os.makedirs(dst_dir, mode=0o700)
1030
1030
  shutil.copy(src_arg_handler_path, tmp_dst_arg_handler_path)
1031
1031
  check_change_and_replace_file(dst_arg_handler_path, tmp_dst_arg_handler_path)
1032
1032
 
1033
- src_arg_dtype_cast_path = os.path.join(work_path, 'mindspore/python/mindspore/ops_generate/arg_dtype_cast.py')
1033
+ src_arg_dtype_cast_path = os.path.join(work_path, K.PY_OPS_GEN_PATH, 'arg_dtype_cast.py')
1034
1034
  dst_arg_dtype_cast_path = os.path.join(dst_dir, 'gen_arg_dtype_cast.py')
1035
1035
  tmp_arg_dtype_cast_path = os.path.join(dst_dir, 'tmp_arg_dtype_cast.py')
1036
1036
  shutil.copy(src_arg_dtype_cast_path, tmp_arg_dtype_cast_path)
1037
1037
  check_change_and_replace_file(dst_arg_dtype_cast_path, tmp_arg_dtype_cast_path)
1038
1038
 
1039
1039
 
1040
+ def get_view_ops(yaml_data):
1041
+ """
1042
+ Get ops with view: True
1043
+ """
1044
+ view_ops = []
1045
+ for operator_name, operator_data in yaml_data.items():
1046
+ class_name = _get_op_name(operator_name, operator_data)
1047
+ view = operator_data.get("view")
1048
+ if view:
1049
+ view_ops.append(class_name + "View")
1050
+ return view_ops
1051
+
1052
+
1040
1053
  def main():
1041
- current_path = os.path.dirname(os.path.abspath(__file__))
1054
+ current_path = os.path.dirname(os.path.realpath(__file__))
1042
1055
  work_path = os.path.join(current_path, '../../../../')
1043
1056
 
1044
1057
  # merge ops yaml
1045
- ops_yaml_path = os.path.join(work_path, 'mindspore/python/mindspore/ops_generate/ops.yaml')
1046
- doc_yaml_path = os.path.join(work_path, 'mindspore/python/mindspore/ops_generate/ops_doc.yaml')
1058
+ ops_yaml_path = os.path.join(work_path, K.PY_OPS_GEN_PATH, 'ops.yaml')
1059
+ doc_yaml_path = os.path.join(work_path, K.PY_OPS_GEN_PATH, 'ops_doc.yaml')
1047
1060
 
1048
- ops_yaml_dir_path = os.path.join(work_path, 'mindspore/core/ops/ops_def/')
1049
- infer_ops_yaml_dir_path = os.path.join(work_path, 'mindspore/core/ops/ops_def/infer/')
1050
- doc_yaml_dir_path = os.path.join(work_path, 'mindspore/core/ops/ops_def/doc/')
1061
+ ops_yaml_dir_path = os.path.join(work_path, K.MS_YAML_PATH)
1062
+ infer_ops_yaml_dir_path = os.path.join(ops_yaml_dir_path, "infer")
1063
+ doc_yaml_dir_path = os.path.join(ops_yaml_dir_path, "doc")
1051
1064
  merge_files(ops_yaml_dir_path, ops_yaml_path, '*op.yaml')
1052
1065
  merge_files_append(infer_ops_yaml_dir_path, ops_yaml_path, '*op.yaml')
1053
1066
  merge_files(doc_yaml_dir_path, doc_yaml_path, '*doc.yaml')
1054
1067
 
1055
1068
  # make auto_generate dir
1056
- cc_path = os.path.join(work_path, 'mindspore/core/ops/auto_generate/')
1069
+ cc_path = os.path.join(work_path, K.MS_OP_DEF_AUTO_GENERATE_PATH)
1057
1070
  pathlib.Path(cc_path).mkdir(parents=True, exist_ok=True)
1058
1071
 
1059
1072
  # generate arg_handler files
@@ -1070,8 +1083,10 @@ def main():
1070
1083
  generate_ops_cc_files(work_path, ops_yaml_str)
1071
1084
  # generate create prim instance helper file
1072
1085
  generate_create_instance_helper_file(work_path, ops_yaml_str)
1086
+ # get view extra ops
1087
+ extra_ops = get_view_ops(ops_yaml_str)
1073
1088
  # generate pyboost code
1074
- gen_pyboost_code(work_path, ops_yaml_str, doc_yaml_str)
1089
+ gen_pyboost_code(work_path, ops_yaml_str, doc_yaml_str, extra_ops)
1075
1090
  # generate aclnn kernelmod register
1076
1091
  generate_aclnn_reg_file(work_path, ops_yaml_str)
1077
1092
 
@@ -42,7 +42,7 @@ class DtypeToEnum(Primitive):
42
42
  def __call__(self, op_name, arg_name, dtype):
43
43
  """Run in PyNative mode"""
44
44
  if not isinstance(dtype, typing.Type):
45
- raise TypeError(f"For '{op_name}', the input '{arg_name}' should be mindpsore dtype, but got {dtype}.")
45
+ raise TypeError(f"For '{op_name}', the input '{arg_name}' should be mindspore dtype, but got {dtype}.")
46
46
  return typing.type_to_type_id(dtype)
47
47
 
48
48