mindspore 2.7.0rc1__cp310-cp310-win_amd64.whl → 2.7.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 (370) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/__init__.py +5 -2
  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 +2 -2
  7. mindspore/_extends/builtin_operations.py +3 -3
  8. mindspore/_extends/parallel_compile/akg_compiler/custom.py +1109 -0
  9. mindspore/_extends/parallel_compile/akg_compiler/gen_custom_op_files.py +1 -1
  10. mindspore/_extends/parse/__init__.py +3 -3
  11. mindspore/_extends/parse/compile_config.py +24 -1
  12. mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +6 -3
  13. mindspore/_extends/parse/parser.py +28 -22
  14. mindspore/_extends/parse/resources.py +1 -1
  15. mindspore/_extends/parse/standard_method.py +23 -2
  16. mindspore/_extends/parse/trope.py +2 -1
  17. mindspore/_extends/pijit/pijit_func_white_list.py +9 -27
  18. mindspore/amp.py +0 -18
  19. mindspore/avcodec-59.dll +0 -0
  20. mindspore/avdevice-59.dll +0 -0
  21. mindspore/avfilter-8.dll +0 -0
  22. mindspore/avformat-59.dll +0 -0
  23. mindspore/avutil-57.dll +0 -0
  24. mindspore/boost/base.py +29 -2
  25. mindspore/common/__init__.py +18 -12
  26. mindspore/common/_decorator.py +3 -2
  27. mindspore/common/_grad_function.py +3 -1
  28. mindspore/common/_tensor_cpp_method.py +1 -1
  29. mindspore/common/_tensor_docs.py +371 -96
  30. mindspore/common/_utils.py +7 -43
  31. mindspore/common/api.py +434 -135
  32. mindspore/common/dtype.py +98 -57
  33. mindspore/common/dump.py +7 -108
  34. mindspore/common/dynamic_shape/__init__.py +0 -0
  35. mindspore/common/{auto_dynamic_shape.py → dynamic_shape/auto_dynamic_shape.py} +15 -23
  36. mindspore/common/dynamic_shape/enable_dynamic.py +197 -0
  37. mindspore/common/file_system.py +59 -9
  38. mindspore/common/hook_handle.py +82 -3
  39. mindspore/common/jit_config.py +5 -1
  40. mindspore/common/jit_trace.py +27 -12
  41. mindspore/common/lazy_inline.py +5 -3
  42. mindspore/common/np_dtype.py +3 -3
  43. mindspore/common/parameter.py +17 -127
  44. mindspore/common/recompute.py +4 -13
  45. mindspore/common/tensor.py +50 -217
  46. mindspore/communication/_comm_helper.py +11 -1
  47. mindspore/communication/comm_func.py +138 -4
  48. mindspore/communication/management.py +85 -1
  49. mindspore/config/op_info.config +0 -15
  50. mindspore/context.py +20 -106
  51. mindspore/dataset/__init__.py +1 -1
  52. mindspore/dataset/audio/transforms.py +1 -1
  53. mindspore/dataset/core/config.py +35 -1
  54. mindspore/dataset/engine/datasets.py +338 -319
  55. mindspore/dataset/engine/datasets_user_defined.py +38 -22
  56. mindspore/dataset/engine/datasets_vision.py +1 -1
  57. mindspore/dataset/engine/validators.py +1 -15
  58. mindspore/dataset/transforms/c_transforms.py +2 -2
  59. mindspore/dataset/transforms/transforms.py +3 -3
  60. mindspore/dataset/vision/__init__.py +1 -1
  61. mindspore/dataset/vision/py_transforms.py +8 -8
  62. mindspore/dataset/vision/transforms.py +17 -5
  63. mindspore/dataset/vision/utils.py +632 -21
  64. mindspore/device_context/ascend/op_tuning.py +35 -1
  65. mindspore/dnnl.dll +0 -0
  66. mindspore/{profiler/common/validator → graph}/__init__.py +9 -1
  67. mindspore/graph/custom_pass.py +55 -0
  68. mindspore/include/api/cell.h +28 -4
  69. mindspore/include/api/cfg.h +24 -7
  70. mindspore/include/api/context.h +1 -0
  71. mindspore/include/api/delegate.h +0 -2
  72. mindspore/include/api/dual_abi_helper.h +100 -19
  73. mindspore/include/api/graph.h +14 -1
  74. mindspore/include/api/kernel.h +16 -3
  75. mindspore/include/api/kernel_api.h +9 -1
  76. mindspore/include/api/metrics/accuracy.h +9 -0
  77. mindspore/include/api/model.h +5 -1
  78. mindspore/include/api/model_group.h +4 -0
  79. mindspore/include/api/model_parallel_runner.h +2 -0
  80. mindspore/include/api/status.h +48 -10
  81. mindspore/include/api/types.h +6 -1
  82. mindspore/include/dataset/constants.h +9 -0
  83. mindspore/include/dataset/execute.h +2 -2
  84. mindspore/jpeg62.dll +0 -0
  85. mindspore/mindrecord/__init__.py +3 -3
  86. mindspore/mindrecord/common/exceptions.py +1 -0
  87. mindspore/mindrecord/config.py +1 -1
  88. mindspore/{parallel/mpi → mindrecord/core}/__init__.py +4 -1
  89. mindspore/mindrecord/{shardheader.py → core/shardheader.py} +2 -1
  90. mindspore/mindrecord/{shardindexgenerator.py → core/shardindexgenerator.py} +1 -1
  91. mindspore/mindrecord/{shardreader.py → core/shardreader.py} +2 -1
  92. mindspore/mindrecord/{shardsegment.py → core/shardsegment.py} +2 -2
  93. mindspore/mindrecord/{shardutils.py → core/shardutils.py} +1 -1
  94. mindspore/mindrecord/{shardwriter.py → core/shardwriter.py} +1 -1
  95. mindspore/mindrecord/filereader.py +4 -4
  96. mindspore/mindrecord/filewriter.py +5 -5
  97. mindspore/mindrecord/mindpage.py +2 -2
  98. mindspore/mindrecord/tools/cifar10.py +4 -3
  99. mindspore/mindrecord/tools/cifar100.py +1 -1
  100. mindspore/mindrecord/tools/cifar100_to_mr.py +1 -1
  101. mindspore/mindrecord/tools/cifar10_to_mr.py +6 -6
  102. mindspore/mindrecord/tools/csv_to_mr.py +1 -1
  103. mindspore/mindrecord/tools/imagenet_to_mr.py +1 -1
  104. mindspore/mindrecord/tools/mnist_to_mr.py +1 -1
  105. mindspore/mindrecord/tools/tfrecord_to_mr.py +1 -1
  106. mindspore/mindspore_backend_common.dll +0 -0
  107. mindspore/mindspore_backend_manager.dll +0 -0
  108. mindspore/mindspore_cluster.dll +0 -0
  109. mindspore/mindspore_common.dll +0 -0
  110. mindspore/mindspore_core.dll +0 -0
  111. mindspore/mindspore_cpu.dll +0 -0
  112. mindspore/mindspore_dump.dll +0 -0
  113. mindspore/mindspore_frontend.dll +0 -0
  114. mindspore/mindspore_glog.dll +0 -0
  115. mindspore/mindspore_hardware_abstract.dll +0 -0
  116. mindspore/mindspore_memory_pool.dll +0 -0
  117. mindspore/mindspore_ms_backend.dll +0 -0
  118. mindspore/mindspore_ops.dll +0 -0
  119. mindspore/{mindspore_ops_host.dll → mindspore_ops_cpu.dll} +0 -0
  120. mindspore/mindspore_profiler.dll +0 -0
  121. mindspore/mindspore_pyboost.dll +0 -0
  122. mindspore/mindspore_pynative.dll +0 -0
  123. mindspore/mindspore_runtime_pipeline.dll +0 -0
  124. mindspore/mindspore_runtime_utils.dll +0 -0
  125. mindspore/mindspore_tools.dll +0 -0
  126. mindspore/mint/__init__.py +15 -10
  127. mindspore/mint/distributed/__init__.py +4 -0
  128. mindspore/mint/distributed/distributed.py +392 -69
  129. mindspore/mint/nn/__init__.py +2 -16
  130. mindspore/mint/nn/functional.py +4 -110
  131. mindspore/mint/nn/layer/__init__.py +0 -2
  132. mindspore/mint/nn/layer/_functions.py +1 -2
  133. mindspore/mint/nn/layer/activation.py +0 -6
  134. mindspore/mint/nn/layer/basic.py +0 -47
  135. mindspore/mint/nn/layer/conv.py +10 -10
  136. mindspore/mint/nn/layer/normalization.py +11 -16
  137. mindspore/mint/nn/layer/pooling.py +0 -4
  138. mindspore/nn/__init__.py +1 -3
  139. mindspore/nn/cell.py +231 -239
  140. mindspore/nn/layer/activation.py +4 -2
  141. mindspore/nn/layer/basic.py +56 -14
  142. mindspore/nn/layer/container.py +16 -0
  143. mindspore/nn/layer/embedding.py +4 -169
  144. mindspore/nn/layer/image.py +1 -1
  145. mindspore/nn/layer/normalization.py +2 -1
  146. mindspore/nn/layer/thor_layer.py +4 -85
  147. mindspore/nn/optim/ada_grad.py +0 -1
  148. mindspore/nn/optim/adafactor.py +0 -1
  149. mindspore/nn/optim/adam.py +32 -127
  150. mindspore/nn/optim/adamax.py +0 -1
  151. mindspore/nn/optim/asgd.py +0 -1
  152. mindspore/nn/optim/ftrl.py +8 -102
  153. mindspore/nn/optim/lamb.py +1 -4
  154. mindspore/nn/optim/lars.py +0 -3
  155. mindspore/nn/optim/lazyadam.py +25 -218
  156. mindspore/nn/optim/momentum.py +5 -43
  157. mindspore/nn/optim/optimizer.py +6 -55
  158. mindspore/nn/optim/proximal_ada_grad.py +0 -1
  159. mindspore/nn/optim/rmsprop.py +0 -1
  160. mindspore/nn/optim/rprop.py +0 -1
  161. mindspore/nn/optim/sgd.py +0 -1
  162. mindspore/nn/optim/tft_wrapper.py +2 -4
  163. mindspore/nn/optim/thor.py +0 -2
  164. mindspore/nn/probability/bijector/bijector.py +7 -8
  165. mindspore/nn/probability/bijector/gumbel_cdf.py +2 -2
  166. mindspore/nn/probability/bijector/power_transform.py +20 -21
  167. mindspore/nn/probability/bijector/scalar_affine.py +5 -5
  168. mindspore/nn/probability/bijector/softplus.py +13 -14
  169. mindspore/nn/probability/distribution/_utils/utils.py +2 -2
  170. mindspore/nn/wrap/cell_wrapper.py +39 -5
  171. mindspore/nn/wrap/grad_reducer.py +4 -89
  172. mindspore/numpy/array_creations.py +4 -4
  173. mindspore/numpy/fft.py +9 -9
  174. mindspore/numpy/utils_const.py +1 -1
  175. mindspore/{nn/reinforcement → onnx}/__init__.py +5 -8
  176. mindspore/onnx/onnx_export.py +137 -0
  177. mindspore/opencv_core4110.dll +0 -0
  178. mindspore/opencv_imgcodecs4110.dll +0 -0
  179. mindspore/{opencv_imgproc452.dll → opencv_imgproc4110.dll} +0 -0
  180. mindspore/ops/__init__.py +2 -0
  181. mindspore/ops/_grad_experimental/grad_comm_ops.py +38 -2
  182. mindspore/ops/_grad_experimental/grad_inner_ops.py +0 -9
  183. mindspore/ops/_op_impl/aicpu/__init__.py +0 -10
  184. mindspore/ops/_op_impl/cpu/__init__.py +1 -5
  185. mindspore/ops/_op_impl/cpu/{buffer_append.py → joinedstr_op.py} +8 -8
  186. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +28 -24
  187. mindspore/ops/auto_generate/gen_extend_func.py +6 -11
  188. mindspore/ops/auto_generate/gen_ops_def.py +385 -154
  189. mindspore/ops/auto_generate/gen_ops_prim.py +5676 -5167
  190. mindspore/ops/communication.py +97 -0
  191. mindspore/ops/composite/__init__.py +5 -2
  192. mindspore/ops/composite/base.py +16 -2
  193. mindspore/ops/composite/multitype_ops/__init__.py +3 -1
  194. mindspore/ops/composite/multitype_ops/_compile_utils.py +150 -8
  195. mindspore/ops/composite/multitype_ops/_constexpr_utils.py +1 -1
  196. mindspore/ops/composite/multitype_ops/add_impl.py +7 -0
  197. mindspore/ops/composite/multitype_ops/mod_impl.py +27 -0
  198. mindspore/ops/function/__init__.py +2 -0
  199. mindspore/ops/function/array_func.py +24 -18
  200. mindspore/ops/function/comm_func.py +3883 -0
  201. mindspore/ops/function/debug_func.py +7 -6
  202. mindspore/ops/function/grad/grad_func.py +4 -12
  203. mindspore/ops/function/math_func.py +89 -86
  204. mindspore/ops/function/nn_func.py +92 -313
  205. mindspore/ops/function/random_func.py +9 -18
  206. mindspore/ops/functional.py +4 -1
  207. mindspore/ops/functional_overload.py +377 -30
  208. mindspore/ops/operations/__init__.py +2 -5
  209. mindspore/ops/operations/_custom_ops_utils.py +7 -9
  210. mindspore/ops/operations/_inner_ops.py +12 -50
  211. mindspore/ops/operations/_rl_inner_ops.py +0 -933
  212. mindspore/ops/operations/array_ops.py +5 -50
  213. mindspore/ops/operations/comm_ops.py +95 -17
  214. mindspore/ops/operations/custom_ops.py +237 -22
  215. mindspore/ops/operations/debug_ops.py +33 -35
  216. mindspore/ops/operations/manually_defined/ops_def.py +39 -318
  217. mindspore/ops/operations/math_ops.py +5 -5
  218. mindspore/ops/operations/nn_ops.py +3 -3
  219. mindspore/ops/operations/sparse_ops.py +0 -83
  220. mindspore/ops/primitive.py +4 -27
  221. mindspore/ops/tensor_method.py +88 -10
  222. mindspore/ops_generate/aclnn/aclnn_kernel_register_auto_cc_generator.py +5 -5
  223. mindspore/ops_generate/aclnn/gen_aclnn_implement.py +8 -8
  224. mindspore/ops_generate/api/functions_cc_generator.py +53 -4
  225. mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +25 -11
  226. mindspore/ops_generate/common/gen_constants.py +11 -10
  227. mindspore/ops_generate/common/op_proto.py +18 -1
  228. mindspore/ops_generate/common/template.py +102 -245
  229. mindspore/ops_generate/common/template_utils.py +212 -0
  230. mindspore/ops_generate/gen_custom_ops.py +69 -0
  231. mindspore/ops_generate/op_def/ops_def_cc_generator.py +78 -7
  232. mindspore/ops_generate/op_def_py/base_op_prim_py_generator.py +360 -0
  233. mindspore/ops_generate/op_def_py/custom_op_prim_py_generator.py +140 -0
  234. mindspore/ops_generate/op_def_py/op_def_py_generator.py +54 -7
  235. mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -312
  236. mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +74 -17
  237. mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +22 -5
  238. mindspore/ops_generate/pyboost/gen_pyboost_func.py +0 -16
  239. mindspore/ops_generate/pyboost/op_template_parser.py +3 -2
  240. mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +21 -5
  241. mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +2 -2
  242. mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +30 -10
  243. mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +10 -3
  244. mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +1 -1
  245. mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +19 -9
  246. mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +71 -28
  247. mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +10 -9
  248. mindspore/ops_generate/pyboost/pyboost_utils.py +27 -16
  249. mindspore/ops_generate/resources/yaml_loader.py +13 -0
  250. mindspore/ops_generate/tensor_py_cc_generator.py +2 -2
  251. mindspore/parallel/_auto_parallel_context.py +5 -15
  252. mindspore/parallel/_cell_wrapper.py +1 -1
  253. mindspore/parallel/_parallel_serialization.py +4 -6
  254. mindspore/parallel/_ps_context.py +2 -2
  255. mindspore/parallel/_utils.py +34 -17
  256. mindspore/parallel/auto_parallel.py +23 -9
  257. mindspore/parallel/checkpoint_transform.py +20 -2
  258. mindspore/parallel/cluster/process_entity/_api.py +28 -33
  259. mindspore/parallel/cluster/process_entity/_utils.py +9 -5
  260. mindspore/parallel/cluster/run.py +5 -3
  261. mindspore/{experimental/llm_boost/ascend_native → parallel/distributed}/__init__.py +21 -22
  262. mindspore/parallel/distributed/distributed_data_parallel.py +393 -0
  263. mindspore/parallel/distributed/flatten_grad_buffer.py +295 -0
  264. mindspore/parallel/function/reshard_func.py +6 -5
  265. mindspore/parallel/nn/parallel_cell_wrapper.py +40 -3
  266. mindspore/parallel/nn/parallel_grad_reducer.py +0 -8
  267. mindspore/parallel/shard.py +7 -21
  268. mindspore/parallel/strategy.py +336 -0
  269. mindspore/parallel/transform_safetensors.py +127 -20
  270. mindspore/profiler/analysis/viewer/ascend_kernel_details_viewer.py +13 -9
  271. mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +1 -1
  272. mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +1 -1
  273. mindspore/profiler/common/constant.py +5 -0
  274. mindspore/profiler/common/file_manager.py +9 -0
  275. mindspore/profiler/common/msprof_cmd_tool.py +40 -4
  276. mindspore/profiler/common/path_manager.py +65 -24
  277. mindspore/profiler/common/profiler_context.py +27 -14
  278. mindspore/profiler/common/profiler_info.py +3 -3
  279. mindspore/profiler/common/profiler_meta_data.py +1 -0
  280. mindspore/profiler/common/profiler_op_analyse.py +10 -6
  281. mindspore/profiler/common/profiler_path_manager.py +13 -0
  282. mindspore/profiler/common/util.py +30 -3
  283. mindspore/profiler/dynamic_profiler.py +91 -46
  284. mindspore/profiler/envprofiler.py +30 -5
  285. mindspore/profiler/experimental_config.py +18 -2
  286. mindspore/profiler/platform/cpu_profiler.py +10 -4
  287. mindspore/profiler/platform/npu_profiler.py +34 -7
  288. mindspore/profiler/profiler.py +193 -145
  289. mindspore/profiler/profiler_action_controller.py +1 -1
  290. mindspore/profiler/profiler_interface.py +2 -2
  291. mindspore/rewrite/symbol_tree/symbol_tree.py +1 -1
  292. mindspore/run_check/_check_version.py +108 -24
  293. mindspore/runtime/__init__.py +9 -6
  294. mindspore/runtime/executor.py +35 -0
  295. mindspore/runtime/memory.py +113 -0
  296. mindspore/runtime/thread_bind_core.py +1 -1
  297. mindspore/swresample-4.dll +0 -0
  298. mindspore/swscale-6.dll +0 -0
  299. mindspore/tinyxml2.dll +0 -0
  300. mindspore/{experimental/llm_boost → tools}/__init__.py +5 -5
  301. mindspore/tools/data_dump.py +130 -0
  302. mindspore/tools/sdc_detect.py +91 -0
  303. mindspore/tools/stress_detect.py +63 -0
  304. mindspore/train/__init__.py +6 -6
  305. mindspore/train/_utils.py +8 -21
  306. mindspore/train/amp.py +6 -7
  307. mindspore/train/callback/_callback.py +2 -1
  308. mindspore/train/callback/_checkpoint.py +1 -17
  309. mindspore/train/callback/_flops_collector.py +10 -6
  310. mindspore/train/callback/_train_fault_tolerance.py +72 -25
  311. mindspore/train/data_sink.py +5 -9
  312. mindspore/train/dataset_helper.py +5 -5
  313. mindspore/train/model.py +41 -230
  314. mindspore/train/serialization.py +160 -401
  315. mindspore/train/train_thor/model_thor.py +2 -2
  316. mindspore/turbojpeg.dll +0 -0
  317. mindspore/utils/__init__.py +6 -3
  318. mindspore/utils/dlpack.py +92 -0
  319. mindspore/utils/dryrun.py +1 -1
  320. mindspore/utils/runtime_execution_order_check.py +10 -0
  321. mindspore/utils/sdc_detect.py +14 -12
  322. mindspore/utils/stress_detect.py +43 -0
  323. mindspore/utils/utils.py +152 -16
  324. mindspore/version.py +1 -1
  325. {mindspore-2.7.0rc1.dist-info → mindspore-2.7.1.dist-info}/METADATA +3 -2
  326. {mindspore-2.7.0rc1.dist-info → mindspore-2.7.1.dist-info}/RECORD +330 -344
  327. mindspore/_extends/remote/kernel_build_server_ascend.py +0 -75
  328. mindspore/communication/_hccl_management.py +0 -297
  329. mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +0 -207
  330. mindspore/experimental/llm_boost/ascend_native/llm_boost.py +0 -52
  331. mindspore/experimental/llm_boost/atb/__init__.py +0 -23
  332. mindspore/experimental/llm_boost/atb/boost_base.py +0 -385
  333. mindspore/experimental/llm_boost/atb/llama_boost.py +0 -137
  334. mindspore/experimental/llm_boost/atb/qwen_boost.py +0 -124
  335. mindspore/experimental/llm_boost/register.py +0 -130
  336. mindspore/experimental/llm_boost/utils.py +0 -31
  337. mindspore/include/OWNERS +0 -7
  338. mindspore/mindspore_cpu_res_manager.dll +0 -0
  339. mindspore/mindspore_ops_kernel_common.dll +0 -0
  340. mindspore/mindspore_res_manager.dll +0 -0
  341. mindspore/nn/optim/_dist_optimizer_registry.py +0 -111
  342. mindspore/nn/reinforcement/_batch_read_write.py +0 -142
  343. mindspore/nn/reinforcement/_tensors_queue.py +0 -152
  344. mindspore/nn/reinforcement/tensor_array.py +0 -145
  345. mindspore/opencv_core452.dll +0 -0
  346. mindspore/opencv_imgcodecs452.dll +0 -0
  347. mindspore/ops/_op_impl/aicpu/priority_replay_buffer.py +0 -113
  348. mindspore/ops/_op_impl/aicpu/reservoir_replay_buffer.py +0 -96
  349. mindspore/ops/_op_impl/aicpu/sparse_cross.py +0 -42
  350. mindspore/ops/_op_impl/cpu/buffer_get.py +0 -28
  351. mindspore/ops/_op_impl/cpu/buffer_sample.py +0 -28
  352. mindspore/ops/_op_impl/cpu/priority_replay_buffer.py +0 -42
  353. mindspore/ops/operations/_tensor_array.py +0 -359
  354. mindspore/ops/operations/rl_ops.py +0 -288
  355. mindspore/parallel/_offload_context.py +0 -275
  356. mindspore/parallel/_recovery_context.py +0 -115
  357. mindspore/parallel/_transformer/__init__.py +0 -35
  358. mindspore/parallel/_transformer/layers.py +0 -765
  359. mindspore/parallel/_transformer/loss.py +0 -251
  360. mindspore/parallel/_transformer/moe.py +0 -693
  361. mindspore/parallel/_transformer/op_parallel_config.py +0 -222
  362. mindspore/parallel/_transformer/transformer.py +0 -3124
  363. mindspore/parallel/mpi/_mpi_config.py +0 -116
  364. mindspore/profiler/common/validator/validate_path.py +0 -84
  365. mindspore/train/memory_profiling_pb2.py +0 -298
  366. mindspore/utils/hooks.py +0 -81
  367. /mindspore/common/{_auto_dynamic.py → dynamic_shape/_auto_dynamic.py} +0 -0
  368. {mindspore-2.7.0rc1.dist-info → mindspore-2.7.1.dist-info}/WHEEL +0 -0
  369. {mindspore-2.7.0rc1.dist-info → mindspore-2.7.1.dist-info}/entry_points.txt +0 -0
  370. {mindspore-2.7.0rc1.dist-info → mindspore-2.7.1.dist-info}/top_level.txt +0 -0
@@ -206,3 +206,12 @@ class FileManager:
206
206
  if file_name.startswith(start_name) and file_name.endswith(".csv"):
207
207
  file_list.append(os.path.join(source_path, file_name))
208
208
  return file_list
209
+
210
+ @classmethod
211
+ def check_file_owner(cls, path):
212
+ """Check whether the file owner is the current user or root."""
213
+ stat_info = os.stat(path)
214
+ if stat_info.st_uid == 0:
215
+ return True
216
+ current_uid = os.geteuid()
217
+ return current_uid == stat_info.st_uid
@@ -22,6 +22,7 @@ from typing import Dict, List, Optional
22
22
  from mindspore import log as logger
23
23
  from mindspore.profiler.common.command_executor import CommandExecutor
24
24
  from mindspore.profiler.common.constant import ExportType
25
+ from mindspore.profiler.common.path_manager import PathManager
25
26
 
26
27
 
27
28
  class MsprofCmdTool:
@@ -120,6 +121,7 @@ class MsprofCmdTool:
120
121
  Raises:
121
122
  FileNotFoundError: If msprof or python3 command is not found.
122
123
  """
124
+ self._check_msprof_profile_path_is_valid()
123
125
  if not shutil.which(self._MSPROF_CMD):
124
126
  logger.warning(
125
127
  "The msprof command is not found in PATH. Searching in environment variables..."
@@ -131,11 +133,44 @@ class MsprofCmdTool:
131
133
  logger.info("Successfully added msprof command to PATH.")
132
134
  else:
133
135
  raise FileNotFoundError("Failed to find msprof command in environment.")
134
-
136
+ else:
137
+ msprof_path = shutil.which(self._MSPROF_CMD)
138
+ self._check_msprof_permission(msprof_path)
135
139
  if not shutil.which("python3"):
136
140
  logger.warning("Failed to find python3 command in environment.")
137
141
  raise FileNotFoundError("Failed to find python3 command in environment.")
138
142
 
143
+ def _check_msprof_profile_path_is_valid(self):
144
+ """Check msprof profiler path is invalid."""
145
+ PathManager.check_directory_path_readable(self._msprof_profile_path)
146
+ PathManager.check_directory_path_writeable(self._msprof_profile_path)
147
+ PathManager.check_path_owner_consistent(self._msprof_profile_path)
148
+ PathManager.check_path_is_other_writable(self._msprof_profile_path)
149
+ if not PathManager.check_path_is_executable(self._msprof_profile_path):
150
+ raise PermissionError(f"The '{self._msprof_profile_path}' path is not executable."
151
+ f"Please execute chmod -R 755 {self._msprof_profile_path}")
152
+
153
+ def _check_msprof_permission(self, msprof_path):
154
+ """Check msprof path permissions."""
155
+ msprof_script_path = self._get_msprof_script_path(self._MSPROF_PY_PATH)
156
+ if not msprof_script_path:
157
+ raise FileNotFoundError(
158
+ "Failed to find msprof.py path. Perhaps the permission of the 'msprof' tool is unexecutable. "
159
+ "Please check the CANN environment. You can modify the 'msprof' file to an executable permission "
160
+ "through the chmod method."
161
+ )
162
+ if not PathManager.check_path_is_owner_or_root(msprof_script_path) or \
163
+ not PathManager.check_path_is_owner_or_root(msprof_path):
164
+ raise PermissionError(f"PermissionError, CANN package user id: {os.stat(msprof_path).st_uid}, "
165
+ f"current user id: {os.getuid()}. "
166
+ f"Ensure CANN package user id and current user id consistency")
167
+ if not PathManager.check_path_is_executable(msprof_script_path) or \
168
+ not PathManager.check_path_is_executable(msprof_path):
169
+ raise PermissionError(f"The '{msprof_script_path}' path or '{msprof_path}' path is not executable."
170
+ f"Please execute chmod u+x {msprof_script_path} and "
171
+ f"chmod u+x {msprof_path}")
172
+ PathManager.check_path_is_other_writable(msprof_script_path)
173
+
139
174
  def _find_msprof_path(self) -> Optional[str]:
140
175
  """Find msprof path in environment variables.
141
176
 
@@ -145,14 +180,14 @@ class MsprofCmdTool:
145
180
  if os.environ.get("ASCEND_TOOLKIT_HOME"):
146
181
  temp_path = os.path.join(os.environ.get("ASCEND_TOOLKIT_HOME"), "bin")
147
182
  if os.path.isdir(temp_path) and self._MSPROF_CMD in os.listdir(temp_path):
148
- return temp_path
183
+ return os.path.abspath(temp_path)
149
184
 
150
185
  for path in os.environ.get("PATH", "").split(":"):
151
186
  if self._ASCEND_MARK in path:
152
187
  prefix = path.split(self._ASCEND_MARK)[0]
153
188
  temp_path = os.path.join(prefix, self._HIAI_MSPROF_TAIL)
154
189
  if os.path.isdir(temp_path) and self._MSPROF_CMD in os.listdir(temp_path):
155
- return temp_path
190
+ return os.path.abspath(temp_path)
156
191
 
157
192
  return None
158
193
 
@@ -166,7 +201,8 @@ class MsprofCmdTool:
166
201
  if not script_path:
167
202
  logger.error("Failed to find get_msprof_info.py path.")
168
203
  return {}
169
-
204
+ if not PathManager.check_path_is_executable(script_path):
205
+ raise PermissionError(f"The '{script_path}' path is not executable. Please execute chmod u+x {script_path}")
170
206
  host_dir = os.path.join(self._msprof_profile_path, "host")
171
207
  cmd = ["python3", script_path, "-dir", host_dir]
172
208
  command_outs = CommandExecutor.execute(cmd)[0]
@@ -73,6 +73,15 @@ class PathManager:
73
73
  msg = f"file size exceeds the limit: {cls.MAX_FILE_SIZE}, file size: {file_size}"
74
74
  raise ProfilerPathErrorException(msg)
75
75
 
76
+ file_stat = os.stat(path)
77
+ if file_stat.st_mode & (stat.S_IWGRP | stat.S_IWOTH):
78
+ msg = f"File path {path} has group or others writable permissions, which is not allowed."
79
+ raise ProfilerPathErrorException(msg)
80
+
81
+ if stat.S_ISCHR(file_stat.st_mode) or stat.S_ISBLK(file_stat.st_mode):
82
+ msg = f"Invalid input path is a character or block device path: {path}"
83
+ raise ProfilerPathErrorException(msg)
84
+
76
85
  @classmethod
77
86
  def get_directory_size(cls, directory: str, unit: str = 'MB') -> float:
78
87
  """
@@ -126,7 +135,8 @@ class PathManager:
126
135
  msg = f"The path does not exist: {path}"
127
136
  raise ProfilerPathErrorException(msg)
128
137
  if os.name != 'nt' and os.stat(path).st_uid != os.getuid():
129
- msg = f"Path {path} owner[{os.stat(path).st_uid}] does not match the current user[{os.getuid()}]."
138
+ msg = (f"Path {path} owner[{os.stat(path).st_uid}] does not match the current user[{os.getuid()}]."
139
+ f"Please execute chown -R $(id -un) {path}")
130
140
  raise ProfilerPathErrorException(msg)
131
141
 
132
142
  @classmethod
@@ -144,7 +154,7 @@ class PathManager:
144
154
  msg = f"Invalid path is a soft link: {path}"
145
155
  raise ProfilerPathErrorException(msg)
146
156
  if not os.access(path, os.W_OK):
147
- msg = f"The path writeable permission check failed: {path}"
157
+ msg = f"The path writeable permission check failed: {path}. Please execute chmod -R 755 {path}"
148
158
  raise ProfilerPathErrorException(msg)
149
159
 
150
160
  @classmethod
@@ -162,7 +172,7 @@ class PathManager:
162
172
  msg = f"Invalid path is a soft link: {path}"
163
173
  raise ProfilerPathErrorException(msg)
164
174
  if not os.access(path, os.R_OK):
165
- msg = f"The path readable permission check failed: {path}"
175
+ msg = f"The path readable permission check failed: {path}. Please execute chmod -R 755 {path}"
166
176
  raise ProfilerPathErrorException(msg)
167
177
 
168
178
  @classmethod
@@ -237,26 +247,6 @@ class PathManager:
237
247
  except Exception as err:
238
248
  raise ProfilerPathErrorException(f"Failed to make directory: {path}, err: {err}") from err
239
249
 
240
- @classmethod
241
- def create_file_safety(cls, path: str):
242
- """
243
- Function Description:
244
- create file safety
245
- Parameter:
246
- path: the file to remove
247
- Exception Description:
248
- when invalid data throw exception
249
- """
250
- if os.path.islink(path):
251
- raise RuntimeError(f"Failed to create file: {path}, is a soft link")
252
- if os.path.exists(path):
253
- logger.warning("File already exists: %s", path)
254
- return
255
- try:
256
- os.close(os.open(path, os.O_WRONLY | os.O_CREAT, cls.DATA_FILE_AUTHORITY))
257
- except Exception as err:
258
- raise RuntimeError(f"Failed to create file: {path}, err: {err}") from err
259
-
260
250
  @classmethod
261
251
  def _input_path_common_check(cls, path: str):
262
252
  """
@@ -390,6 +380,57 @@ class PathManager:
390
380
  return False
391
381
  if os.name == 'nt':
392
382
  return False
393
- if os.stat(path).st_uid == 0 or os.stat(path).st_uid == os.getuid():
383
+ if os.stat(lib_path).st_uid == 0 or os.stat(lib_path).st_uid == os.getuid():
394
384
  return True
395
385
  return False
386
+
387
+ @classmethod
388
+ def check_path_is_other_writable(cls, path):
389
+ """Check whether the file or directory in the specified path has writable permissions for others."""
390
+ file_stat = os.stat(path)
391
+ if file_stat.st_mode & (stat.S_IWGRP | stat.S_IWOTH):
392
+ msg = (f"File path {path} has group or others writable permissions, which is not allowed."
393
+ f"Please execute chmod -R 755 {path}")
394
+ raise ProfilerPathErrorException(msg)
395
+
396
+ @classmethod
397
+ def check_path_is_owner_or_root(cls, path):
398
+ """Check path is owner or root."""
399
+ if not os.path.exists(path):
400
+ msg = f"The path does not exist: {path}"
401
+ raise ProfilerPathErrorException(msg)
402
+ file_stat = os.stat(path)
403
+ current_uid = os.getuid()
404
+ file_uid = file_stat.st_uid
405
+ if file_uid not in (0, current_uid):
406
+ return False
407
+ return True
408
+
409
+ @classmethod
410
+ def check_path_is_executable(cls, path):
411
+ """Check path is executable"""
412
+ return os.access(path, os.X_OK)
413
+
414
+ @classmethod
415
+ def check_path_is_readable(cls, path):
416
+ """Check path is readable"""
417
+ if os.path.islink(path):
418
+ msg = f"Invalid path is a soft link: {path}"
419
+ raise ProfilerPathErrorException(msg)
420
+ if not os.access(path, os.R_OK):
421
+ msg = f"The path readable permission check failed: {path}."
422
+ raise ProfilerPathErrorException(msg)
423
+
424
+ @classmethod
425
+ def walk_with_depth(cls, path, *args, max_depth=10, **kwargs):
426
+ """walk path depth"""
427
+ if not isinstance(path, str):
428
+ return
429
+ base_depth = path.count(os.sep)
430
+ if path.endswith(os.sep):
431
+ base_depth -= 1
432
+ for root, dirs, files in os.walk(path, *args, **kwargs):
433
+ if root.count(os.sep) - base_depth > max_depth:
434
+ dirs.clear()
435
+ continue
436
+ yield root, dirs, files
@@ -24,7 +24,6 @@ from typing import (
24
24
  )
25
25
 
26
26
  from mindspore.communication.management import GlobalComm
27
- from mindspore.communication.management import get_local_rank
28
27
  from mindspore.communication.management import get_rank
29
28
  from mindspore.profiler.common.constant import (
30
29
  DeviceTarget,
@@ -43,6 +42,8 @@ from mindspore.profiler.schedule import Schedule
43
42
  from mindspore import context
44
43
  from mindspore import log as logger
45
44
  from mindspore.profiler.common.profiler_info import ProfilerInfo
45
+ from mindspore.profiler.experimental_config import _ExperimentalConfig
46
+ from mindspore.profiler.common.util import get_device_id
46
47
 
47
48
 
48
49
  @Singleton
@@ -81,12 +82,34 @@ class ProfilerContext:
81
82
  logger.warning(f"Both on_trace_ready path and output_path are provided. "
82
83
  f"The on_trace_ready path takes effect. Final path is {final_path}")
83
84
  kwargs["output_path"] = final_path
84
-
85
+ if kwargs.get("experimental_config"):
86
+ self._check_and_set_experimental_params(kwargs)
85
87
  self._profiler_params_mgr: ProfilerParameters = ProfilerParameters(**kwargs)
86
88
  self._profiler_path_mgr: ProfilerOutputPath = ProfilerOutputPath(rank_id=int(self._rank_id))
87
-
88
89
  self._profiler_path_mgr.output_path = self._profiler_params_mgr.output_path
89
90
 
91
+ @staticmethod
92
+ def _check_and_set_experimental_params(kwargs):
93
+ """
94
+ Set experimental parameters
95
+ """
96
+ if not isinstance(kwargs.get("experimental_config"), _ExperimentalConfig):
97
+ logger.warning("For Profiler, experimental_config value must be the "
98
+ "'mindspore.profiler._ExperimentalConfig' class, "
99
+ "reset to default value.")
100
+ return
101
+ kwargs["profiler_level"] = kwargs.get("experimental_config").profiler_level
102
+ kwargs["aic_metrics"] = kwargs.get("experimental_config").aic_metrics
103
+ kwargs["l2_cache"] = kwargs.get("experimental_config").l2_cache
104
+ kwargs["mstx"] = kwargs.get("experimental_config").mstx
105
+ kwargs["data_simplification"] = kwargs.get("experimental_config").data_simplification
106
+ kwargs["export_type"] = kwargs.get("experimental_config").export_type
107
+ kwargs["mstx_domain_include"] = kwargs.get("experimental_config").mstx_domain_include
108
+ kwargs["mstx_domain_exclude"] = kwargs.get("experimental_config").mstx_domain_exclude
109
+ kwargs["sys_io"] = kwargs.get("experimental_config").sys_io
110
+ kwargs["sys_interconnection"] = kwargs.get("experimental_config").sys_interconnection
111
+ kwargs["host_sys"] = kwargs.get("experimental_config").host_sys
112
+
90
113
  @property
91
114
  def on_trace_ready_output_path(self) -> str:
92
115
  """Get the on trace ready output path."""
@@ -465,17 +488,7 @@ class ProfilerContext:
465
488
  """
466
489
  Initialize the device ID.
467
490
  """
468
- self._device_id = str(context.get_context("device_id"))
469
-
470
- if not self._device_id or not self._device_id.isdigit():
471
- if GlobalComm.INITED and self._device_target == DeviceTarget.NPU.value:
472
- self._device_id = str(get_local_rank())
473
- else:
474
- self._device_id = os.getenv("DEVICE_ID")
475
-
476
- if not self._device_id or not self._device_id.isdigit():
477
- self._device_id = "0"
478
- logger.warning("Fail to get DEVICE_ID, use 0 instead.")
491
+ self._device_id = get_device_id()
479
492
 
480
493
  def _init_rank_id(self) -> None:
481
494
  """
@@ -97,13 +97,14 @@ class ProfilerInfo:
97
97
  Load time parameters from msprof profile and host start log.
98
98
  This method should be called before TimeConverter.init_parameters.
99
99
  """
100
+ msprof_info = MsprofCmdTool(msprof_profile_path).get_msprof_info()
100
101
  if not msprof_profile_path or not msprof_profile_host_path:
101
102
  raise ValueError(
102
103
  "msprof_profile_path and msprof_profile_host_path must be provided"
103
104
  )
104
105
  self._read_host_start_log(msprof_profile_host_path)
105
106
  self._read_start_info(msprof_profile_host_path)
106
- self._get_freq_from_msprof(msprof_profile_path)
107
+ self._get_freq_from_msprof(msprof_info)
107
108
 
108
109
  @property
109
110
  def time_parameters(self) -> Dict[str, Any]:
@@ -237,7 +238,7 @@ class ProfilerInfo:
237
238
  self._collection_time_begin * self.US_TO_NS - self._clock_monotonic_raw_info
238
239
  )
239
240
 
240
- def _get_freq_from_msprof(self, msprof_profile_path: str) -> None:
241
+ def _get_freq_from_msprof(self, msprof_info: str) -> None:
241
242
  """
242
243
  Get frequency from get_msprof_info.py script
243
244
 
@@ -250,7 +251,6 @@ class ProfilerInfo:
250
251
  }
251
252
  }
252
253
  """
253
- msprof_info = MsprofCmdTool(msprof_profile_path).get_msprof_info()
254
254
 
255
255
  if not isinstance(msprof_info, dict):
256
256
  raise RuntimeError("msprof_info must be a dictionary")
@@ -30,6 +30,7 @@ class ProfilerMetaData:
30
30
  This class is used to handle metadata.
31
31
  """
32
32
  metadata: Dict[str, str] = {}
33
+ MAX_META_SIZE = 100 * 1024 * 1024 # 100MB
33
34
 
34
35
  @classmethod
35
36
  def get_metadata(cls) -> Dict[str, str]:
@@ -16,7 +16,7 @@
16
16
  import json
17
17
  import os
18
18
  from collections import defaultdict
19
- from mindspore.profiler.common.validator.validate_path import validate_and_normalize_path
19
+ from mindspore.profiler.common.path_manager import PathManager
20
20
 
21
21
 
22
22
  class OpAnalyser:
@@ -34,7 +34,7 @@ class OpAnalyser:
34
34
  def __init__(self, output_path, dev_id, op_names=None):
35
35
  """The parser for parsing framework files."""
36
36
  self._dev_id = dev_id
37
- self._output_path = output_path
37
+ self._output_path = PathManager.get_real_path(output_path)
38
38
  self.op_names = op_names
39
39
  self.op_name = ''
40
40
  self.framework_list = []
@@ -66,7 +66,8 @@ class OpAnalyser:
66
66
  for filename in self.framework_info_dir:
67
67
  op_side = filename.split('_')[0]
68
68
  framework_file_path = os.path.join(self._output_path, filename)
69
- framework_file_path = validate_and_normalize_path(framework_file_path)
69
+ PathManager.check_input_file_path(framework_file_path)
70
+ PathManager.check_directory_path_readable(framework_file_path)
70
71
  with open(framework_file_path, 'r') as f_obj:
71
72
  framework_info = f_obj.readlines()
72
73
  for line_info in framework_info:
@@ -85,7 +86,8 @@ class OpAnalyser:
85
86
  for filename in self.cpu_detail_info_dir:
86
87
  op_side = filename.split('_')[0]
87
88
  op_detail_file_path = os.path.join(self._output_path, filename)
88
- op_detail_file_path = validate_and_normalize_path(op_detail_file_path)
89
+ PathManager.check_input_file_path(op_detail_file_path)
90
+ PathManager.check_directory_path_readable(op_detail_file_path)
89
91
  with open(op_detail_file_path, 'r') as f_obj:
90
92
  op_detail_info = f_obj.readlines()
91
93
  for line_info in op_detail_info[1:]:
@@ -99,7 +101,8 @@ class OpAnalyser:
99
101
  """Get gpu operators execute times."""
100
102
  if self.gpu_op_type_info_dir:
101
103
  gpu_op_type_file_path = os.path.join(self._output_path, self.gpu_op_type_info_dir[0])
102
- gpu_op_type_file_path = validate_and_normalize_path(gpu_op_type_file_path)
104
+ PathManager.check_input_file_path(gpu_op_type_file_path)
105
+ PathManager.check_directory_path_readable(gpu_op_type_file_path)
103
106
  with open(gpu_op_type_file_path, 'r') as fp:
104
107
  op_type_info = fp.readlines()
105
108
  for line_info in op_type_info[1:]:
@@ -118,7 +121,8 @@ class OpAnalyser:
118
121
  for filename in self.activity_info_dir:
119
122
  op_side = filename.split('_')[0]
120
123
  activity_file_path = os.path.join(self._output_path, filename)
121
- activity_file_path = validate_and_normalize_path(activity_file_path)
124
+ PathManager.check_input_file_path(activity_file_path)
125
+ PathManager.check_directory_path_readable(activity_file_path)
122
126
  with open(activity_file_path, 'r') as file:
123
127
  activity_info = file.readlines()
124
128
  for line_info in activity_info[1:]:
@@ -143,6 +143,19 @@ class ProfilerPathManager:
143
143
  new_file_path = os.path.join(self._prof_ctx.ascend_profiler_output_path, new_file_name)
144
144
  shutil.move(db_file, new_file_path)
145
145
 
146
+ def remove_db_file(self):
147
+ """
148
+ Remove the db file in the output path.
149
+ """
150
+ if not self._prof_ctx.msprof_profile_output_path:
151
+ return
152
+ db_files = glob.glob(os.path.join(
153
+ os.path.dirname(self._prof_ctx.msprof_profile_output_path),
154
+ 'msprof*.db'
155
+ ))
156
+ for db_file in db_files:
157
+ if os.path.isfile(db_file):
158
+ os.remove(db_file)
146
159
 
147
160
  def create_output_path(self):
148
161
  """
@@ -25,10 +25,15 @@ import re
25
25
  import shutil
26
26
  import stat
27
27
 
28
+ from mindspore.communication.management import GlobalComm
29
+ from mindspore.communication.management import get_local_rank
30
+ from mindspore import context
28
31
  from mindspore import log as logger
29
32
  from mindspore.profiler.common.path_manager import PathManager
30
33
  from mindspore.profiler.common.exceptions.exceptions import ProfilerPathErrorException
31
34
 
35
+ from mindspore.profiler.common.constant import DeviceTarget
36
+
32
37
 
33
38
  def no_exception_func(
34
39
  default_ret: Any = None,
@@ -75,12 +80,16 @@ def get_cann_version():
75
80
  ascend_home_path = os.environ.get("ASCEND_HOME_PATH", "")
76
81
  cann_version = "not known"
77
82
  try:
78
- PathManager.check_directory_path_readable(os.path.realpath(ascend_home_path))
79
- for dirpath, _, filenames in os.walk(os.path.realpath(ascend_home_path)):
83
+ if not PathManager.check_path_is_owner_or_root(ascend_home_path):
84
+ raise PermissionError(f"PermissionError, CANN package user id: {os.stat(ascend_home_path).st_uid}, "
85
+ f"current user id: {os.getuid()}. "
86
+ f"Ensure CANN package user id and current user id consistency")
87
+ PathManager.check_path_is_readable(os.path.realpath(ascend_home_path))
88
+ for dirpath, _, filenames in PathManager.walk_with_depth(os.path.realpath(ascend_home_path)):
80
89
  install_files = [file for file in filenames if re.match(r"ascend_.{1,20}_install\.info", file)]
81
90
  if install_files:
82
91
  filepath = os.path.realpath(os.path.join(dirpath, install_files[0]))
83
- PathManager.check_directory_path_readable(filepath)
92
+ PathManager.check_path_is_readable(filepath)
84
93
  with open(filepath, "r") as f:
85
94
  for line in f:
86
95
  if line.find("version") != -1:
@@ -441,6 +450,24 @@ def get_newest_file(file_list):
441
450
  return newest_file_list
442
451
 
443
452
 
453
+ def get_device_id():
454
+ """
455
+ Get device ID.
456
+ """
457
+ device_id = str(context.get_context("device_id"))
458
+
459
+ if not device_id or not device_id.isdigit():
460
+ if GlobalComm.INITED and context.get_context("device_target") == DeviceTarget.NPU.value:
461
+ device_id = str(get_local_rank())
462
+ else:
463
+ device_id = os.getenv("DEVICE_ID")
464
+
465
+ if not device_id or not device_id.isdigit():
466
+ logger.warning("Fail to get DEVICE_ID, use 0 instead.")
467
+ device_id = "0"
468
+ return device_id
469
+
470
+
444
471
  class ProfilerPathManager:
445
472
  """A path manager to manage profiler path"""
446
473