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
@@ -25,5 +25,4 @@ from .sparsify.sparsify import sparsify
25
25
  from .sparsify.utils import ArgType, SparseFunc
26
26
 
27
27
 
28
- __all__ = ["SymbolTree", "Node", "NodeType", "ScopedValue", "ValueType", "PatternEngine", "PatternNode", "VarNode",
29
- "Replacement"]
28
+ __all__ = ["SymbolTree", "Node", "NodeType", "ScopedValue", "ValueType"]
@@ -85,12 +85,12 @@ def is_third_party(func_obj):
85
85
  # A module without __file__ attribute (normally to be a c++ lib) is considered to be third party module.
86
86
  if not hasattr(module, '__file__'):
87
87
  return True
88
- module_path = os.path.abspath(module.__file__)
88
+ module_path = os.path.realpath(module.__file__)
89
89
  for path in _ignore_third_party_paths:
90
90
  if module_path.startswith(path):
91
91
  return False
92
92
  # Python builtin modules are treated as third-party libraries.
93
- python_builtin_dir = os.path.abspath(os.path.dirname(os.__file__))
93
+ python_builtin_dir = os.path.realpath(os.path.dirname(os.__file__))
94
94
  if module_path.startswith(python_builtin_dir):
95
95
  return True
96
96
  # Check if module is under user workspace directory.
@@ -106,8 +106,8 @@ def is_third_party(func_obj):
106
106
 
107
107
  def get_top_level_module_path(module_path):
108
108
  """Get the path of the top level package of the current working directory."""
109
- module_abspath = os.path.abspath(module_path)
110
- upper_path = os.path.abspath(os.path.dirname(module_abspath))
109
+ module_abspath = os.path.realpath(module_path)
110
+ upper_path = os.path.realpath(os.path.dirname(module_abspath))
111
111
  if module_abspath == upper_path:
112
112
  return module_abspath
113
113
  # Check whether __init__.py exists in the upper directory.
@@ -307,7 +307,7 @@ class SymbolTree(Observer, Observable, NodeManager):
307
307
  @staticmethod
308
308
  def _get_valid_import_info(import_node: ast.ImportFrom, file_path: str):
309
309
  """Get valid import info while import_node.module is at form of relative path"""
310
- file_path = os.path.dirname(os.path.abspath(file_path))
310
+ file_path = os.path.dirname(os.path.realpath(file_path))
311
311
  # get real path from import_node.level
312
312
  # from .(A) import xxx: current path
313
313
  # from ..(A) import xxx: last level path
@@ -1452,7 +1452,7 @@ class SymbolTree(Observer, Observable, NodeManager):
1452
1452
  return self._saved_file_name
1453
1453
 
1454
1454
  def save_network_to_file(self):
1455
- abs_path = os.path.abspath(self._saved_file_name)
1455
+ abs_path = os.path.realpath(self._saved_file_name)
1456
1456
  if os.path.isfile(abs_path):
1457
1457
  os.remove(abs_path)
1458
1458
  with os.fdopen(os.open(self._saved_file_name, os.O_WRONLY | os.O_CREAT, stat.S_IRWXU), 'wb') as f:
@@ -1563,7 +1563,7 @@ class SymbolTree(Observer, Observable, NodeManager):
1563
1563
  When level_num = 1(e.g. from .xxx import yyy), current path will be saved.
1564
1564
  When level_num = 2(e.g. from ..xxx import yyy), the path one level above the current path will be saved.
1565
1565
  """
1566
- file_path = os.path.dirname(os.path.abspath(file_path))
1566
+ file_path = os.path.dirname(os.path.realpath(file_path))
1567
1567
  file_path = os.path.normcase(file_path)
1568
1568
  file_path = os.path.normpath(file_path)
1569
1569
  if level_num > 1:
@@ -20,7 +20,6 @@ import sys
20
20
  import time
21
21
  import subprocess
22
22
  import glob
23
- from copy import deepcopy
24
23
  from pathlib import Path
25
24
  from abc import abstractmethod, ABCMeta
26
25
  from packaging import version
@@ -159,7 +158,7 @@ class GPUEnvChecker(EnvChecker):
159
158
  """Get cuda bin path by lib path."""
160
159
  path_list = []
161
160
  for path in self.cuda_lib_path:
162
- path = os.path.abspath(path.strip() + "/bin/")
161
+ path = os.path.realpath(path.strip() + "/bin/")
163
162
  if Path(path).is_dir():
164
163
  path_list.append(path)
165
164
  return np.unique(path_list)
@@ -235,7 +234,7 @@ class GPUEnvChecker(EnvChecker):
235
234
  continue
236
235
  path = path.partition(lib_name)[0]
237
236
  if path:
238
- path_list.append(os.path.abspath(path.strip() + "../"))
237
+ path_list.append(os.path.realpath(path.strip() + "../"))
239
238
  return np.unique(path_list)
240
239
  except subprocess.TimeoutExpired:
241
240
  logger.warning("Failed to check cuda version due to the ldd command timeout. Please confirm that "
@@ -259,46 +258,7 @@ class AscendEnvChecker(EnvChecker):
259
258
 
260
259
  def __init__(self, library_path):
261
260
  self.library_path = library_path
262
- self.version = ["7.2", "7.3"]
263
- atlas_nnae_version = "/usr/local/Ascend/nnae/latest/compiler/version.info"
264
- atlas_toolkit_version = "/usr/local/Ascend/ascend-toolkit/latest/compiler/version.info"
265
- hisi_fwk_version = "/usr/local/Ascend/latest/compiler/version.info"
266
- if os.path.exists(atlas_nnae_version):
267
- # atlas default path
268
- self.fwk_path = "/usr/local/Ascend/nnae/latest"
269
- self.op_impl_path = "/usr/local/Ascend/nnae/latest/opp/built-in/op_impl/ai_core/tbe"
270
- self.tbe_path = self.fwk_path + "/lib64"
271
- self.cce_path = self.fwk_path + "/compiler/ccec_compiler/bin"
272
- self.fwk_version = atlas_nnae_version
273
- self.op_path = "/usr/local/Ascend/nnae/latest/opp"
274
- self.aicpu_path = "/usr/local/Ascend/nnae/latest"
275
- elif os.path.exists(atlas_toolkit_version):
276
- # atlas default path
277
- self.fwk_path = "/usr/local/Ascend/ascend-toolkit/latest"
278
- self.op_impl_path = "/usr/local/Ascend/ascend-toolkit/latest/opp/built-in/op_impl/ai_core/tbe"
279
- self.tbe_path = self.fwk_path + "/lib64"
280
- self.cce_path = self.fwk_path + "/compiler/ccec_compiler/bin"
281
- self.fwk_version = atlas_toolkit_version
282
- self.op_path = "/usr/local/Ascend/ascend-toolkit/latest/opp"
283
- self.aicpu_path = "/usr/local/Ascend/ascend-toolkit/latest"
284
- elif os.path.exists(hisi_fwk_version):
285
- # hisi default path
286
- self.fwk_path = "/usr/local/Ascend/latest"
287
- self.op_impl_path = "/usr/local/Ascend/latest/opp/built-in/op_impl/ai_core/tbe"
288
- self.tbe_path = self.fwk_path + "/lib64"
289
- self.cce_path = self.fwk_path + "/compiler/ccec_compiler/bin"
290
- self.fwk_version = hisi_fwk_version
291
- self.op_path = "/usr/local/Ascend/latest/opp"
292
- self.aicpu_path = "/usr/local/Ascend/latest"
293
- else:
294
- # custom or unknown environment
295
- self.fwk_path = ""
296
- self.op_impl_path = ""
297
- self.tbe_path = ""
298
- self.cce_path = ""
299
- self.fwk_version = ""
300
- self.op_path = ""
301
- self.aicpu_path = ""
261
+ self.version = ["7.3", "7.5"]
302
262
 
303
263
  # env
304
264
  self.path = os.getenv("PATH")
@@ -306,12 +266,12 @@ class AscendEnvChecker(EnvChecker):
306
266
  self.ld_lib_path = os.getenv("LD_LIBRARY_PATH")
307
267
  self.ascend_opp_path = os.getenv("ASCEND_OPP_PATH")
308
268
  self.ascend_aicpu_path = os.getenv("ASCEND_AICPU_PATH")
269
+ self.compiler_version = self.ascend_opp_path.split("opp")[0] + "compiler/version.info"
309
270
 
310
271
  # check content
311
272
  self.path_check = "/compiler/ccec_compiler/bin"
312
273
  self.python_path_check = "opp/built-in/op_impl/ai_core/tbe"
313
274
  self.ld_lib_path_check_fwk = "/lib64"
314
- self.ld_lib_path_check_addons = "/add-ons"
315
275
  self.ascend_opp_path_check = "/op"
316
276
  self.v = ""
317
277
 
@@ -322,36 +282,46 @@ class AscendEnvChecker(EnvChecker):
322
282
  else:
323
283
  os.environ[env_name] = env_value + ":" + os.environ[env_name]
324
284
 
325
- @staticmethod
326
- def _check_and_set_env(env_name, env_value, is_append=False):
327
- """check and set environment variable by its name"""
328
- if env_value is None:
285
+ def check_custom_version(self):
286
+ """custom op version check"""
287
+ custom_ascendc_soc_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
288
+ "../lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/kernel",
289
+ MSContext.get_instance().get_ascend_soc_version())
290
+ if not os.path.exists(custom_ascendc_soc_dir):
291
+ logger.debug(f"The path {custom_ascendc_soc_dir} of the custom ascend c operator does not exist.")
292
+ return False
293
+
294
+ if not Path(self.compiler_version).is_file():
329
295
  return True
330
296
 
331
- if not Path(env_value).is_dir():
332
- logger.error(
333
- f"No such directory: {env_value}. Please check if Ascend AI software package (Ascend Data Center"
334
- " Solution) is installed correctly.")
335
- return False
297
+ cur_version = self._read_version(self.compiler_version)
298
+ custom_version_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
299
+ "../lib/plugin/ascend/custom_ascendc_ops/version.info")
300
+ with open(custom_version_path, 'r') as f:
301
+ all_info = f.readlines()
302
+ for line in all_info:
303
+ full_version = line.strip().split("=")[1]
304
+ compile_version = '.'.join(full_version.split('.')[0:2])
305
+ if cur_version == compile_version:
306
+ return True
336
307
 
337
- if is_append:
338
- AscendEnvChecker._concat_variable(env_name, env_value)
339
- else:
340
- os.environ[env_name] = env_value
341
- return True
308
+ logger.warning(
309
+ f"The version {compile_version} used for compiling the custom operator does not match "
310
+ f"Ascend AI software package version {cur_version} in the current environment.")
311
+ return False
342
312
 
343
313
  def check_env(self):
344
314
  self._check_env()
345
315
 
346
316
  def check_version(self):
347
- if not Path(self.fwk_version).is_file():
317
+ if not Path(self.compiler_version).is_file():
348
318
  logger.warning("Using custom Ascend AI software package (Ascend Data Center Solution) path, package "
349
319
  "version checking is skipped. Please make sure Ascend AI software package (Ascend Data "
350
320
  "Center Solution) version is supported. For details, refer to the installation guidelines "
351
321
  "https://www.mindspore.cn/install")
352
322
  return
353
323
 
354
- v = self._read_version(self.fwk_version)
324
+ v = self._read_version(self.compiler_version)
355
325
  if v not in self.version:
356
326
  v_list = str([x for x in self.version])
357
327
  logger.warning(f"MindSpore version {__version__} and Ascend AI software package (Ascend Data Center "
@@ -397,10 +367,10 @@ class AscendEnvChecker(EnvChecker):
397
367
  time.sleep(1)
398
368
 
399
369
  def set_env(self):
400
- curr_path = os.path.abspath(os.path.dirname(__file__))
401
- cust_aicpu_path = os.path.abspath(os.path.join(curr_path, "../lib/plugin/ascend/custom_aicpu_ops"))
402
- cust_aicore_path = os.path.abspath(os.path.join(curr_path, "../lib/plugin/ascend/custom_aicore_ops"))
403
- cust_ascendc_path = os.path.abspath(os.path.join(curr_path, "../lib/plugin/ascend/custom_ascendc_ops"))
370
+ curr_path = os.path.realpath(os.path.dirname(__file__))
371
+ cust_aicpu_path = os.path.realpath(os.path.join(curr_path, "../lib/plugin/ascend/custom_aicpu_ops"))
372
+ cust_aicore_path = os.path.realpath(os.path.join(curr_path, "../lib/plugin/ascend/custom_aicore_ops"))
373
+ cust_ascendc_path = os.path.realpath(os.path.join(curr_path, "../lib/plugin/ascend/custom_ascendc_ops"))
404
374
  if os.getenv('ASCEND_CUSTOM_OPP_PATH'):
405
375
  os.environ['ASCEND_CUSTOM_OPP_PATH'] = os.environ['ASCEND_CUSTOM_OPP_PATH'] + ":" + \
406
376
  cust_ascendc_path + ":" + cust_aicore_path + ":" + cust_aicpu_path
@@ -410,47 +380,11 @@ class AscendEnvChecker(EnvChecker):
410
380
  akg_dir = os.path.join(plugin_dir, "ascend")
411
381
  AscendEnvChecker._concat_variable('LD_LIBRARY_PATH', akg_dir)
412
382
 
413
- if not self.tbe_path:
414
- self._check_env()
415
- return
416
-
417
- try:
418
- origin_path = deepcopy(sys.path)
419
- import te # pylint: disable=unused-import
420
- # pylint: disable=broad-except
421
- except Exception:
422
- sys.path = deepcopy(origin_path)
423
- if Path(self.tbe_path).is_dir():
424
- os.environ['LD_LIBRARY_PATH'] = self.tbe_path + ":" + os.environ['LD_LIBRARY_PATH']
425
- else:
426
- logger.error(
427
- f"No such directory: {self.tbe_path}. Please check if Ascend AI software package (Ascend Data "
428
- "Center Solution) is installed correctly.")
429
- return
383
+ self._check_env()
430
384
 
431
385
  # check te version after set te env
432
386
  self.check_deps_version()
433
387
 
434
- if Path(self.op_impl_path).is_dir():
435
- # python path for sub process
436
- AscendEnvChecker._concat_variable('PYTHONPATH', self.op_impl_path)
437
- # sys path for this process
438
- sys.path.append(self.op_impl_path)
439
-
440
- os.environ['TBE_IMPL_PATH'] = self.op_impl_path
441
- else:
442
- logger.error(
443
- f"No such directory: {self.op_impl_path}. Please check if Ascend AI software package (Ascend Data "
444
- "Center Solution) is installed correctly.")
445
- return
446
-
447
- if not AscendEnvChecker._check_and_set_env('PATH', self.cce_path, True):
448
- return
449
- if not AscendEnvChecker._check_and_set_env('ASCEND_OPP_PATH', self.op_path):
450
- return
451
- if not AscendEnvChecker._check_and_set_env('ASCEND_AICPU_PATH', self.aicpu_path):
452
- return
453
-
454
388
  def _check_env(self):
455
389
  """ascend dependence path check"""
456
390
  if self.path is None or self.path_check not in self.path:
@@ -464,8 +398,7 @@ class AscendEnvChecker(EnvChecker):
464
398
  "Environment Variable PYTHONPATH is set. For details, refer to the installation guidelines: "
465
399
  "https://www.mindspore.cn/install")
466
400
 
467
- if self.ld_lib_path is None or not (self.ld_lib_path_check_fwk in self.ld_lib_path and
468
- self.ld_lib_path_check_addons in self.ld_lib_path):
401
+ if self.ld_lib_path is None or not self.ld_lib_path_check_fwk in self.ld_lib_path:
469
402
  logger.warning("Can not find driver so(need by mindspore-ascend). Please check whether the "
470
403
  "Environment Variable LD_LIBRARY_PATH is set. For details, refer to the installation "
471
404
  "guidelines: https://www.mindspore.cn/install")