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

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

Potentially problematic release.


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

Files changed (275) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/__init__.py +3 -1
  3. mindspore/_c_dataengine.cp310-win_amd64.pyd +0 -0
  4. mindspore/_c_expression.cp310-win_amd64.pyd +0 -0
  5. mindspore/_c_mindrecord.cp310-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/common/__init__.py +6 -4
  13. mindspore/common/_pijit_context.py +190 -0
  14. mindspore/common/_register_for_tensor.py +2 -1
  15. mindspore/common/_tensor_overload.py +139 -0
  16. mindspore/common/api.py +102 -87
  17. mindspore/common/dump.py +5 -6
  18. mindspore/common/generator.py +1 -7
  19. mindspore/common/hook_handle.py +14 -26
  20. mindspore/common/initializer.py +51 -15
  21. mindspore/common/mindir_util.py +2 -2
  22. mindspore/common/parameter.py +62 -15
  23. mindspore/common/recompute.py +39 -9
  24. mindspore/common/sparse_tensor.py +7 -3
  25. mindspore/common/tensor.py +183 -37
  26. mindspore/communication/__init__.py +1 -1
  27. mindspore/communication/_comm_helper.py +38 -3
  28. mindspore/communication/comm_func.py +315 -60
  29. mindspore/communication/management.py +14 -14
  30. mindspore/context.py +132 -22
  31. mindspore/dataset/__init__.py +1 -1
  32. mindspore/dataset/audio/__init__.py +1 -1
  33. mindspore/dataset/core/config.py +7 -0
  34. mindspore/dataset/core/validator_helpers.py +7 -0
  35. mindspore/dataset/engine/cache_client.py +1 -1
  36. mindspore/dataset/engine/datasets.py +72 -44
  37. mindspore/dataset/engine/datasets_audio.py +7 -7
  38. mindspore/dataset/engine/datasets_standard_format.py +53 -3
  39. mindspore/dataset/engine/datasets_text.py +20 -20
  40. mindspore/dataset/engine/datasets_user_defined.py +174 -104
  41. mindspore/dataset/engine/datasets_vision.py +33 -33
  42. mindspore/dataset/engine/iterators.py +29 -0
  43. mindspore/dataset/engine/obs/util.py +7 -0
  44. mindspore/dataset/engine/queue.py +114 -60
  45. mindspore/dataset/engine/serializer_deserializer.py +2 -2
  46. mindspore/dataset/engine/validators.py +34 -14
  47. mindspore/dataset/text/__init__.py +1 -4
  48. mindspore/dataset/transforms/__init__.py +0 -3
  49. mindspore/dataset/utils/line_reader.py +2 -0
  50. mindspore/dataset/vision/__init__.py +1 -4
  51. mindspore/dataset/vision/utils.py +1 -1
  52. mindspore/dataset/vision/validators.py +2 -1
  53. mindspore/{nn/extend → experimental/es}/__init__.py +4 -11
  54. mindspore/experimental/es/embedding_service.py +883 -0
  55. mindspore/{nn/layer → experimental/es}/embedding_service_layer.py +218 -30
  56. mindspore/experimental/llm_boost/__init__.py +21 -0
  57. mindspore/{nn/extend/layer → experimental/llm_boost/atb}/__init__.py +4 -8
  58. mindspore/experimental/llm_boost/atb/boost_base.py +211 -0
  59. mindspore/experimental/llm_boost/atb/llama_boost.py +115 -0
  60. mindspore/experimental/llm_boost/atb/qwen_boost.py +101 -0
  61. mindspore/experimental/llm_boost/register.py +129 -0
  62. mindspore/experimental/llm_boost/utils.py +31 -0
  63. mindspore/experimental/optim/adamw.py +85 -0
  64. mindspore/experimental/optim/optimizer.py +3 -0
  65. mindspore/hal/__init__.py +3 -3
  66. mindspore/hal/contiguous_tensors_handle.py +175 -0
  67. mindspore/hal/stream.py +18 -0
  68. mindspore/include/api/model_group.h +13 -1
  69. mindspore/include/api/types.h +10 -10
  70. mindspore/include/dataset/config.h +2 -2
  71. mindspore/include/dataset/constants.h +2 -2
  72. mindspore/include/dataset/execute.h +2 -2
  73. mindspore/include/dataset/vision.h +4 -0
  74. mindspore/log.py +1 -1
  75. mindspore/mindrecord/filewriter.py +68 -51
  76. mindspore/mindspore_backend.dll +0 -0
  77. mindspore/mindspore_common.dll +0 -0
  78. mindspore/mindspore_core.dll +0 -0
  79. mindspore/mindspore_np_dtype.dll +0 -0
  80. mindspore/mindspore_ops.dll +0 -0
  81. mindspore/mint/__init__.py +983 -46
  82. mindspore/mint/distributed/__init__.py +31 -0
  83. mindspore/mint/distributed/distributed.py +254 -0
  84. mindspore/mint/nn/__init__.py +268 -23
  85. mindspore/mint/nn/functional.py +125 -19
  86. mindspore/mint/nn/layer/__init__.py +39 -0
  87. mindspore/mint/nn/layer/activation.py +133 -0
  88. mindspore/mint/nn/layer/normalization.py +477 -0
  89. mindspore/mint/nn/layer/pooling.py +110 -0
  90. mindspore/mint/optim/adamw.py +26 -13
  91. mindspore/mint/special/__init__.py +63 -0
  92. mindspore/multiprocessing/__init__.py +2 -1
  93. mindspore/nn/__init__.py +0 -1
  94. mindspore/nn/cell.py +276 -96
  95. mindspore/nn/layer/activation.py +211 -44
  96. mindspore/nn/layer/basic.py +137 -10
  97. mindspore/nn/layer/embedding.py +137 -2
  98. mindspore/nn/layer/normalization.py +101 -5
  99. mindspore/nn/layer/padding.py +34 -48
  100. mindspore/nn/layer/pooling.py +161 -7
  101. mindspore/nn/layer/transformer.py +3 -3
  102. mindspore/nn/loss/__init__.py +2 -2
  103. mindspore/nn/loss/loss.py +84 -6
  104. mindspore/nn/optim/__init__.py +2 -1
  105. mindspore/nn/optim/adadelta.py +1 -1
  106. mindspore/nn/optim/adam.py +1 -1
  107. mindspore/nn/optim/lamb.py +1 -1
  108. mindspore/nn/optim/tft_wrapper.py +124 -0
  109. mindspore/nn/wrap/cell_wrapper.py +12 -23
  110. mindspore/nn/wrap/grad_reducer.py +5 -5
  111. mindspore/nn/wrap/loss_scale.py +17 -3
  112. mindspore/numpy/__init__.py +1 -1
  113. mindspore/numpy/array_creations.py +65 -68
  114. mindspore/numpy/array_ops.py +64 -60
  115. mindspore/numpy/fft.py +610 -75
  116. mindspore/numpy/logic_ops.py +11 -10
  117. mindspore/numpy/math_ops.py +85 -84
  118. mindspore/numpy/utils_const.py +4 -4
  119. mindspore/opencv_core452.dll +0 -0
  120. mindspore/opencv_imgcodecs452.dll +0 -0
  121. mindspore/opencv_imgproc452.dll +0 -0
  122. mindspore/ops/__init__.py +6 -4
  123. mindspore/ops/_grad_experimental/grad_array_ops.py +0 -11
  124. mindspore/ops/_grad_experimental/grad_comm_ops.py +67 -4
  125. mindspore/ops/_grad_experimental/grad_math_ops.py +0 -22
  126. mindspore/ops/_vmap/vmap_array_ops.py +2 -4
  127. mindspore/ops/_vmap/vmap_math_ops.py +17 -1
  128. mindspore/ops/_vmap/vmap_nn_ops.py +43 -2
  129. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +91 -7
  130. mindspore/ops/auto_generate/gen_arg_dtype_cast.py +2 -0
  131. mindspore/ops/auto_generate/gen_extend_func.py +767 -13
  132. mindspore/ops/auto_generate/gen_ops_def.py +2452 -364
  133. mindspore/ops/auto_generate/gen_ops_prim.py +5442 -1756
  134. mindspore/ops/auto_generate/pyboost_inner_prim.py +176 -56
  135. mindspore/ops/composite/base.py +85 -48
  136. mindspore/ops/composite/multitype_ops/_compile_utils.py +1 -0
  137. mindspore/ops/composite/multitype_ops/not_in_impl.py +2 -2
  138. mindspore/ops/function/__init__.py +22 -0
  139. mindspore/ops/function/array_func.py +492 -153
  140. mindspore/ops/function/debug_func.py +113 -1
  141. mindspore/ops/function/fft_func.py +15 -2
  142. mindspore/ops/function/grad/grad_func.py +3 -2
  143. mindspore/ops/function/math_func.py +564 -207
  144. mindspore/ops/function/nn_func.py +817 -383
  145. mindspore/ops/function/other_func.py +3 -2
  146. mindspore/ops/function/random_func.py +402 -12
  147. mindspore/ops/function/reshard_func.py +13 -11
  148. mindspore/ops/function/sparse_unary_func.py +1 -1
  149. mindspore/ops/function/vmap_func.py +3 -2
  150. mindspore/ops/functional.py +24 -14
  151. mindspore/ops/op_info_register.py +3 -3
  152. mindspore/ops/operations/__init__.py +7 -2
  153. mindspore/ops/operations/_grad_ops.py +2 -76
  154. mindspore/ops/operations/_infer_ops.py +1 -1
  155. mindspore/ops/operations/_inner_ops.py +71 -94
  156. mindspore/ops/operations/array_ops.py +14 -146
  157. mindspore/ops/operations/comm_ops.py +63 -53
  158. mindspore/ops/operations/custom_ops.py +83 -19
  159. mindspore/ops/operations/debug_ops.py +42 -10
  160. mindspore/ops/operations/manually_defined/_inner.py +12 -0
  161. mindspore/ops/operations/manually_defined/ops_def.py +273 -20
  162. mindspore/ops/operations/math_ops.py +12 -223
  163. mindspore/ops/operations/nn_ops.py +20 -114
  164. mindspore/ops/operations/other_ops.py +7 -4
  165. mindspore/ops/operations/random_ops.py +46 -1
  166. mindspore/ops/primitive.py +18 -6
  167. mindspore/ops_generate/arg_dtype_cast.py +2 -0
  168. mindspore/ops_generate/gen_aclnn_implement.py +11 -11
  169. mindspore/ops_generate/gen_constants.py +36 -0
  170. mindspore/ops_generate/gen_ops.py +67 -52
  171. mindspore/ops_generate/gen_ops_inner_prim.py +1 -1
  172. mindspore/ops_generate/gen_pyboost_func.py +131 -47
  173. mindspore/ops_generate/op_proto.py +10 -3
  174. mindspore/ops_generate/pyboost_utils.py +14 -1
  175. mindspore/ops_generate/template.py +43 -21
  176. mindspore/parallel/__init__.py +3 -1
  177. mindspore/parallel/_auto_parallel_context.py +31 -9
  178. mindspore/parallel/_cell_wrapper.py +85 -0
  179. mindspore/parallel/_parallel_serialization.py +47 -19
  180. mindspore/parallel/_tensor.py +127 -13
  181. mindspore/parallel/_utils.py +53 -22
  182. mindspore/parallel/algo_parameter_config.py +5 -5
  183. mindspore/parallel/checkpoint_transform.py +46 -39
  184. mindspore/parallel/cluster/process_entity/__init__.py +1 -1
  185. mindspore/parallel/cluster/process_entity/_api.py +31 -23
  186. mindspore/parallel/cluster/process_entity/_utils.py +2 -27
  187. mindspore/parallel/parameter_broadcast.py +3 -4
  188. mindspore/parallel/shard.py +162 -31
  189. mindspore/parallel/transform_safetensors.py +1146 -0
  190. mindspore/profiler/__init__.py +2 -1
  191. mindspore/profiler/common/constant.py +29 -0
  192. mindspore/profiler/common/registry.py +47 -0
  193. mindspore/profiler/common/util.py +28 -0
  194. mindspore/profiler/dynamic_profiler.py +694 -0
  195. mindspore/profiler/envprofiling.py +17 -19
  196. mindspore/profiler/parser/ascend_analysis/constant.py +18 -0
  197. mindspore/profiler/parser/ascend_analysis/file_manager.py +25 -4
  198. mindspore/profiler/parser/ascend_analysis/function_event.py +43 -19
  199. mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +31 -26
  200. mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +56 -10
  201. mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +55 -8
  202. mindspore/profiler/parser/ascend_analysis/path_manager.py +313 -0
  203. mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +27 -20
  204. mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +9 -2
  205. mindspore/profiler/parser/ascend_msprof_exporter.py +5 -4
  206. mindspore/profiler/parser/ascend_timeline_generator.py +27 -25
  207. mindspore/profiler/parser/base_timeline_generator.py +19 -25
  208. mindspore/profiler/parser/cpu_gpu_timeline_generator.py +25 -12
  209. mindspore/profiler/parser/framework_parser.py +1 -391
  210. mindspore/profiler/parser/gpu_analysis/__init__.py +14 -0
  211. mindspore/profiler/parser/gpu_analysis/function_event.py +44 -0
  212. mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +89 -0
  213. mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +72 -0
  214. mindspore/profiler/parser/memory_usage_parser.py +0 -154
  215. mindspore/profiler/parser/profiler_info.py +78 -6
  216. mindspore/profiler/profiler.py +153 -0
  217. mindspore/profiler/profiling.py +285 -413
  218. mindspore/rewrite/__init__.py +1 -2
  219. mindspore/rewrite/common/namespace.py +4 -4
  220. mindspore/rewrite/symbol_tree/symbol_tree.py +3 -3
  221. mindspore/run_check/_check_version.py +39 -104
  222. mindspore/safeguard/rewrite_obfuscation.py +591 -247
  223. mindspore/train/__init__.py +4 -3
  224. mindspore/train/_utils.py +105 -19
  225. mindspore/train/amp.py +171 -53
  226. mindspore/train/callback/__init__.py +2 -2
  227. mindspore/train/callback/_callback.py +4 -4
  228. mindspore/train/callback/_checkpoint.py +97 -31
  229. mindspore/train/callback/_cluster_monitor.py +1 -1
  230. mindspore/train/callback/_flops_collector.py +1 -0
  231. mindspore/train/callback/_loss_monitor.py +3 -3
  232. mindspore/train/callback/_on_request_exit.py +145 -31
  233. mindspore/train/callback/_summary_collector.py +5 -5
  234. mindspore/train/callback/_tft_register.py +375 -0
  235. mindspore/train/dataset_helper.py +15 -3
  236. mindspore/train/metrics/metric.py +3 -3
  237. mindspore/train/metrics/roc.py +4 -4
  238. mindspore/train/mind_ir_pb2.py +44 -39
  239. mindspore/train/model.py +154 -58
  240. mindspore/train/serialization.py +342 -128
  241. mindspore/utils/__init__.py +21 -0
  242. mindspore/utils/utils.py +60 -0
  243. mindspore/version.py +1 -1
  244. {mindspore-2.3.0.dist-info → mindspore-2.4.1.dist-info}/METADATA +13 -7
  245. {mindspore-2.3.0.dist-info → mindspore-2.4.1.dist-info}/RECORD +248 -242
  246. mindspore/include/c_api/ms/abstract.h +0 -67
  247. mindspore/include/c_api/ms/attribute.h +0 -197
  248. mindspore/include/c_api/ms/base/handle_types.h +0 -43
  249. mindspore/include/c_api/ms/base/macros.h +0 -32
  250. mindspore/include/c_api/ms/base/status.h +0 -33
  251. mindspore/include/c_api/ms/base/types.h +0 -283
  252. mindspore/include/c_api/ms/context.h +0 -102
  253. mindspore/include/c_api/ms/graph.h +0 -160
  254. mindspore/include/c_api/ms/node.h +0 -606
  255. mindspore/include/c_api/ms/tensor.h +0 -161
  256. mindspore/include/c_api/ms/value.h +0 -84
  257. mindspore/mindspore_shared_lib.dll +0 -0
  258. mindspore/nn/extend/basic.py +0 -140
  259. mindspore/nn/extend/embedding.py +0 -143
  260. mindspore/nn/extend/layer/normalization.py +0 -109
  261. mindspore/nn/extend/pooling.py +0 -117
  262. mindspore/nn/layer/embedding_service.py +0 -531
  263. mindspore/ops/_op_impl/aicpu/strided_slice_v2.py +0 -93
  264. mindspore/ops/_op_impl/aicpu/strided_slice_v2_grad.py +0 -66
  265. mindspore/ops/extend/__init__.py +0 -53
  266. mindspore/ops/extend/array_func.py +0 -218
  267. mindspore/ops/extend/math_func.py +0 -76
  268. mindspore/ops/extend/nn_func.py +0 -308
  269. mindspore/ops/silent_check.py +0 -162
  270. mindspore/profiler/parser/msadvisor_analyzer.py +0 -82
  271. mindspore/profiler/parser/msadvisor_parser.py +0 -240
  272. mindspore/train/callback/_mindio_ttp.py +0 -443
  273. {mindspore-2.3.0.dist-info → mindspore-2.4.1.dist-info}/WHEEL +0 -0
  274. {mindspore-2.3.0.dist-info → mindspore-2.4.1.dist-info}/entry_points.txt +0 -0
  275. {mindspore-2.3.0.dist-info → mindspore-2.4.1.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,14 @@ 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")
309
-
269
+ if not self.ascend_opp_path is None:
270
+ self.compiler_version = self.ascend_opp_path.split("opp")[0] + "compiler/version.info"
271
+ else:
272
+ self.compiler_version = ""
310
273
  # check content
311
274
  self.path_check = "/compiler/ccec_compiler/bin"
312
275
  self.python_path_check = "opp/built-in/op_impl/ai_core/tbe"
313
276
  self.ld_lib_path_check_fwk = "/lib64"
314
- self.ld_lib_path_check_addons = "/add-ons"
315
277
  self.ascend_opp_path_check = "/op"
316
278
  self.v = ""
317
279
 
@@ -322,36 +284,46 @@ class AscendEnvChecker(EnvChecker):
322
284
  else:
323
285
  os.environ[env_name] = env_value + ":" + os.environ[env_name]
324
286
 
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:
287
+ def check_custom_version(self):
288
+ """custom op version check"""
289
+ custom_ascendc_soc_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
290
+ "../lib/plugin/ascend/custom_ascendc_ops/op_impl/ai_core/tbe/kernel",
291
+ MSContext.get_instance().get_ascend_soc_version())
292
+ if not os.path.exists(custom_ascendc_soc_dir):
293
+ logger.debug(f"The path {custom_ascendc_soc_dir} of the custom ascend c operator does not exist.")
294
+ return False
295
+
296
+ if not Path(self.compiler_version).is_file():
329
297
  return True
330
298
 
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
299
+ cur_version = self._read_version(self.compiler_version)
300
+ custom_version_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
301
+ "../lib/plugin/ascend/custom_ascendc_ops/version.info")
302
+ with open(custom_version_path, 'r') as f:
303
+ all_info = f.readlines()
304
+ for line in all_info:
305
+ full_version = line.strip().split("=")[1]
306
+ compile_version = '.'.join(full_version.split('.')[0:2])
307
+ if cur_version == compile_version:
308
+ return True
336
309
 
337
- if is_append:
338
- AscendEnvChecker._concat_variable(env_name, env_value)
339
- else:
340
- os.environ[env_name] = env_value
341
- return True
310
+ logger.warning(
311
+ f"The version {compile_version} used for compiling the custom operator does not match "
312
+ f"Ascend AI software package version {cur_version} in the current environment.")
313
+ return False
342
314
 
343
315
  def check_env(self):
344
316
  self._check_env()
345
317
 
346
318
  def check_version(self):
347
- if not Path(self.fwk_version).is_file():
319
+ if not Path(self.compiler_version).is_file():
348
320
  logger.warning("Using custom Ascend AI software package (Ascend Data Center Solution) path, package "
349
321
  "version checking is skipped. Please make sure Ascend AI software package (Ascend Data "
350
322
  "Center Solution) version is supported. For details, refer to the installation guidelines "
351
323
  "https://www.mindspore.cn/install")
352
324
  return
353
325
 
354
- v = self._read_version(self.fwk_version)
326
+ v = self._read_version(self.compiler_version)
355
327
  if v not in self.version:
356
328
  v_list = str([x for x in self.version])
357
329
  logger.warning(f"MindSpore version {__version__} and Ascend AI software package (Ascend Data Center "
@@ -397,10 +369,10 @@ class AscendEnvChecker(EnvChecker):
397
369
  time.sleep(1)
398
370
 
399
371
  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"))
372
+ curr_path = os.path.realpath(os.path.dirname(__file__))
373
+ cust_aicpu_path = os.path.realpath(os.path.join(curr_path, "../lib/plugin/ascend/custom_aicpu_ops"))
374
+ cust_aicore_path = os.path.realpath(os.path.join(curr_path, "../lib/plugin/ascend/custom_aicore_ops"))
375
+ cust_ascendc_path = os.path.realpath(os.path.join(curr_path, "../lib/plugin/ascend/custom_ascendc_ops"))
404
376
  if os.getenv('ASCEND_CUSTOM_OPP_PATH'):
405
377
  os.environ['ASCEND_CUSTOM_OPP_PATH'] = os.environ['ASCEND_CUSTOM_OPP_PATH'] + ":" + \
406
378
  cust_ascendc_path + ":" + cust_aicore_path + ":" + cust_aicpu_path
@@ -410,47 +382,11 @@ class AscendEnvChecker(EnvChecker):
410
382
  akg_dir = os.path.join(plugin_dir, "ascend")
411
383
  AscendEnvChecker._concat_variable('LD_LIBRARY_PATH', akg_dir)
412
384
 
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
385
+ self._check_env()
430
386
 
431
387
  # check te version after set te env
432
388
  self.check_deps_version()
433
389
 
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
390
  def _check_env(self):
455
391
  """ascend dependence path check"""
456
392
  if self.path is None or self.path_check not in self.path:
@@ -464,8 +400,7 @@ class AscendEnvChecker(EnvChecker):
464
400
  "Environment Variable PYTHONPATH is set. For details, refer to the installation guidelines: "
465
401
  "https://www.mindspore.cn/install")
466
402
 
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):
403
+ if self.ld_lib_path is None or not self.ld_lib_path_check_fwk in self.ld_lib_path:
469
404
  logger.warning("Can not find driver so(need by mindspore-ascend). Please check whether the "
470
405
  "Environment Variable LD_LIBRARY_PATH is set. For details, refer to the installation "
471
406
  "guidelines: https://www.mindspore.cn/install")