mindspore 2.6.0rc1__cp310-cp310-win_amd64.whl → 2.7.0rc1__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 (407) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/Microsoft.VisualStudio.Telemetry.dll +0 -0
  3. mindspore/Newtonsoft.Json.dll +0 -0
  4. mindspore/__init__.py +1 -1
  5. mindspore/_c_dataengine.cp310-win_amd64.pyd +0 -0
  6. mindspore/_c_expression.cp310-win_amd64.pyd +0 -0
  7. mindspore/_c_mindrecord.cp310-win_amd64.pyd +0 -0
  8. mindspore/_checkparam.py +40 -9
  9. mindspore/{_deprecated → _extends/optimize}/__init__.py +9 -3
  10. mindspore/_extends/optimize/cell_utils.py +96 -0
  11. mindspore/_extends/parse/__init__.py +2 -2
  12. mindspore/_extends/parse/compile_config.py +44 -22
  13. mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +1 -1
  14. mindspore/_extends/parse/parser.py +37 -62
  15. mindspore/_extends/parse/resources.py +39 -0
  16. mindspore/_extends/parse/standard_method.py +43 -13
  17. mindspore/_extends/parse/trope.py +8 -1
  18. mindspore/_extends/pijit/__init__.py +1 -2
  19. mindspore/amp.py +4 -4
  20. mindspore/atlprov.dll +0 -0
  21. mindspore/avcodec-59.dll +0 -0
  22. mindspore/avdevice-59.dll +0 -0
  23. mindspore/avfilter-8.dll +0 -0
  24. mindspore/avformat-59.dll +0 -0
  25. mindspore/avutil-57.dll +0 -0
  26. mindspore/boost/adasum.py +1 -1
  27. mindspore/boost/boost_cell_wrapper.py +4 -4
  28. mindspore/c1.dll +0 -0
  29. mindspore/c1xx.dll +0 -0
  30. mindspore/c2.dll +0 -0
  31. mindspore/common/__init__.py +27 -2
  32. mindspore/common/_grad_function.py +2 -1
  33. mindspore/common/_pijit_context.py +28 -7
  34. mindspore/common/_stub_tensor.py +1 -209
  35. mindspore/common/_tensor_cpp_method.py +1 -1
  36. mindspore/common/_tensor_docs.py +77 -16
  37. mindspore/common/api.py +238 -113
  38. mindspore/common/dtype.py +21 -11
  39. mindspore/common/dump.py +10 -15
  40. mindspore/common/generator.py +5 -3
  41. mindspore/common/hook_handle.py +11 -2
  42. mindspore/common/jit_config.py +1 -1
  43. mindspore/common/jit_trace.py +84 -105
  44. mindspore/common/parameter.py +26 -12
  45. mindspore/common/recompute.py +3 -3
  46. mindspore/common/sparse_tensor.py +0 -3
  47. mindspore/common/symbol.py +0 -1
  48. mindspore/common/tensor.py +81 -81
  49. mindspore/communication/_comm_helper.py +46 -4
  50. mindspore/communication/management.py +79 -7
  51. mindspore/context.py +58 -40
  52. mindspore/dataset/core/config.py +3 -3
  53. mindspore/dataset/engine/datasets.py +20 -7
  54. mindspore/dataset/engine/datasets_user_defined.py +33 -3
  55. mindspore/dataset/engine/iterators.py +2 -2
  56. mindspore/dataset/engine/obs/config_loader.py +2 -2
  57. mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +8 -0
  58. mindspore/dataset/transforms/py_transforms.py +7 -3
  59. mindspore/dataset/transforms/transforms.py +7 -3
  60. mindspore/dataset/vision/validators.py +1 -0
  61. mindspore/device_context/ascend/device.py +1 -1
  62. mindspore/device_context/gpu/__init__.py +2 -2
  63. mindspore/device_context/gpu/device.py +1 -1
  64. mindspore/device_context/gpu/op_precision.py +4 -2
  65. mindspore/device_context/gpu/op_tuning.py +6 -3
  66. mindspore/device_manager.py +16 -9
  67. mindspore/dnnl.dll +0 -0
  68. mindspore/dpcmi.dll +0 -0
  69. mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +3 -7
  70. mindspore/experimental/llm_boost/atb/boost_base.py +2 -3
  71. mindspore/experimental/optim/adadelta.py +13 -20
  72. mindspore/experimental/optim/adagrad.py +15 -22
  73. mindspore/experimental/optim/adam.py +17 -24
  74. mindspore/experimental/optim/adamax.py +14 -22
  75. mindspore/experimental/optim/adamw.py +28 -34
  76. mindspore/experimental/optim/asgd.py +15 -25
  77. mindspore/experimental/optim/lr_scheduler.py +27 -45
  78. mindspore/experimental/optim/nadam.py +14 -24
  79. mindspore/experimental/optim/optimizer.py +13 -23
  80. mindspore/experimental/optim/radam.py +18 -24
  81. mindspore/experimental/optim/rmsprop.py +14 -25
  82. mindspore/experimental/optim/rprop.py +15 -26
  83. mindspore/experimental/optim/sgd.py +9 -19
  84. mindspore/hal/__init__.py +4 -4
  85. mindspore/hal/contiguous_tensors_handle.py +2 -2
  86. mindspore/hal/memory.py +27 -7
  87. mindspore/include/api/cell.h +37 -1
  88. mindspore/include/api/delegate.h +10 -0
  89. mindspore/include/api/model.h +3 -0
  90. mindspore/include/api/types.h +2 -2
  91. mindspore/include/c_api/model_c.h +0 -58
  92. mindspore/include/c_api/tensor_c.h +0 -26
  93. mindspore/include/dataset/vision_ascend.h +1 -1
  94. mindspore/jpeg62.dll +0 -0
  95. mindspore/mindrecord/tools/cifar10.py +60 -11
  96. mindspore/mindrecord/tools/cifar10_to_mr.py +5 -0
  97. mindspore/mindspore_backend_common.dll +0 -0
  98. mindspore/mindspore_backend_manager.dll +0 -0
  99. mindspore/mindspore_common.dll +0 -0
  100. mindspore/mindspore_core.dll +0 -0
  101. mindspore/mindspore_cpu_res_manager.dll +0 -0
  102. mindspore/mindspore_dump.dll +0 -0
  103. mindspore/mindspore_frontend.dll +0 -0
  104. mindspore/mindspore_glog.dll +0 -0
  105. mindspore/mindspore_memory_pool.dll +0 -0
  106. mindspore/mindspore_ms_backend.dll +0 -0
  107. mindspore/mindspore_ops.dll +0 -0
  108. mindspore/mindspore_ops_host.dll +0 -0
  109. mindspore/mindspore_ops_kernel_common.dll +0 -0
  110. mindspore/mindspore_profiler.dll +0 -0
  111. mindspore/mindspore_pyboost.dll +0 -0
  112. mindspore/mindspore_pynative.dll +0 -0
  113. mindspore/mindspore_res_manager.dll +0 -0
  114. mindspore/mindspore_runtime_pipeline.dll +0 -0
  115. mindspore/mint/__init__.py +6 -46
  116. mindspore/mint/distributed/__init__.py +1 -0
  117. mindspore/mint/distributed/distributed.py +212 -9
  118. mindspore/mint/nn/__init__.py +1 -1
  119. mindspore/mint/nn/functional.py +53 -6
  120. mindspore/mint/nn/layer/_functions.py +164 -294
  121. mindspore/mint/nn/layer/activation.py +8 -6
  122. mindspore/mint/nn/layer/conv.py +137 -101
  123. mindspore/mint/nn/layer/normalization.py +8 -22
  124. mindspore/mint/optim/adam.py +19 -18
  125. mindspore/mint/optim/adamw.py +14 -8
  126. mindspore/mint/optim/sgd.py +5 -5
  127. mindspore/msobj140.dll +0 -0
  128. mindspore/mspdb140.dll +0 -0
  129. mindspore/mspdbcore.dll +0 -0
  130. mindspore/mspdbst.dll +0 -0
  131. mindspore/mspft140.dll +0 -0
  132. mindspore/msvcdis140.dll +0 -0
  133. mindspore/msvcp140_1.dll +0 -0
  134. mindspore/msvcp140_2.dll +0 -0
  135. mindspore/msvcp140_atomic_wait.dll +0 -0
  136. mindspore/msvcp140_codecvt_ids.dll +0 -0
  137. mindspore/nn/cell.py +328 -502
  138. mindspore/nn/grad/cell_grad.py +11 -12
  139. mindspore/nn/layer/activation.py +32 -34
  140. mindspore/nn/layer/basic.py +67 -64
  141. mindspore/nn/layer/channel_shuffle.py +4 -4
  142. mindspore/nn/layer/combined.py +4 -2
  143. mindspore/nn/layer/conv.py +117 -110
  144. mindspore/nn/layer/dense.py +9 -7
  145. mindspore/nn/layer/embedding.py +50 -52
  146. mindspore/nn/layer/image.py +37 -39
  147. mindspore/nn/layer/math.py +111 -112
  148. mindspore/nn/layer/normalization.py +56 -44
  149. mindspore/nn/layer/pooling.py +58 -63
  150. mindspore/nn/layer/rnn_cells.py +33 -33
  151. mindspore/nn/layer/rnns.py +56 -56
  152. mindspore/nn/layer/thor_layer.py +74 -73
  153. mindspore/nn/layer/transformer.py +11 -1
  154. mindspore/nn/learning_rate_schedule.py +20 -20
  155. mindspore/nn/loss/loss.py +79 -81
  156. mindspore/nn/optim/adam.py +3 -3
  157. mindspore/nn/optim/adasum.py +2 -2
  158. mindspore/nn/optim/asgd.py +2 -0
  159. mindspore/nn/optim/optimizer.py +1 -1
  160. mindspore/nn/optim/thor.py +2 -2
  161. mindspore/nn/probability/distribution/exponential.py +2 -1
  162. mindspore/nn/probability/distribution/poisson.py +2 -1
  163. mindspore/nn/sparse/sparse.py +3 -3
  164. mindspore/nn/wrap/cell_wrapper.py +34 -37
  165. mindspore/nn/wrap/grad_reducer.py +37 -37
  166. mindspore/nn/wrap/loss_scale.py +72 -74
  167. mindspore/numpy/array_creations.py +5 -5
  168. mindspore/numpy/fft.py +1 -1
  169. mindspore/numpy/math_ops.py +5 -5
  170. mindspore/opencv_core452.dll +0 -0
  171. mindspore/opencv_imgcodecs452.dll +0 -0
  172. mindspore/opencv_imgproc452.dll +0 -0
  173. mindspore/ops/_grad_experimental/grad_comm_ops.py +51 -13
  174. mindspore/ops/_grad_experimental/grad_debug_ops.py +14 -0
  175. mindspore/ops/_vmap/vmap_array_ops.py +31 -13
  176. mindspore/ops/_vmap/vmap_nn_ops.py +8 -16
  177. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +42 -11
  178. mindspore/ops/auto_generate/gen_extend_func.py +23 -141
  179. mindspore/ops/auto_generate/gen_ops_def.py +727 -321
  180. mindspore/ops/auto_generate/gen_ops_prim.py +1721 -984
  181. mindspore/ops/auto_generate/pyboost_inner_prim.py +31 -1
  182. mindspore/ops/composite/__init__.py +10 -0
  183. mindspore/ops/composite/base.py +8 -4
  184. mindspore/ops/composite/multitype_ops/__init__.py +12 -1
  185. mindspore/ops/composite/multitype_ops/_compile_utils.py +133 -109
  186. mindspore/ops/composite/multitype_ops/add_impl.py +70 -2
  187. mindspore/ops/composite/multitype_ops/div_impl.py +49 -0
  188. mindspore/ops/composite/multitype_ops/floordiv_impl.py +29 -0
  189. mindspore/ops/composite/multitype_ops/getitem_impl.py +11 -0
  190. mindspore/ops/composite/multitype_ops/mod_impl.py +5 -3
  191. mindspore/ops/composite/multitype_ops/mul_impl.py +49 -0
  192. mindspore/ops/composite/multitype_ops/setitem_impl.py +57 -0
  193. mindspore/ops/composite/multitype_ops/sub_impl.py +34 -0
  194. mindspore/ops/composite/multitype_ops/zeros_like_impl.py +14 -0
  195. mindspore/ops/function/__init__.py +3 -1
  196. mindspore/ops/function/_add_attr_func.py +11 -6
  197. mindspore/ops/function/array_func.py +9 -96
  198. mindspore/ops/function/debug_func.py +4 -3
  199. mindspore/ops/function/grad/grad_func.py +1 -1
  200. mindspore/ops/function/math_func.py +33 -540
  201. mindspore/ops/function/nn_func.py +28 -74
  202. mindspore/ops/function/other_func.py +4 -1
  203. mindspore/ops/function/random_func.py +44 -5
  204. mindspore/ops/function/vmap_func.py +2 -1
  205. mindspore/ops/functional.py +2 -3
  206. mindspore/ops/functional_overload.py +571 -6
  207. mindspore/ops/op_info_register.py +21 -0
  208. mindspore/ops/operations/__init__.py +16 -11
  209. mindspore/ops/operations/_custom_ops_utils.py +689 -34
  210. mindspore/ops/operations/_inner_ops.py +3 -6
  211. mindspore/ops/operations/_sequence_ops.py +1 -1
  212. mindspore/ops/operations/array_ops.py +2 -2
  213. mindspore/ops/operations/comm_ops.py +185 -26
  214. mindspore/ops/operations/custom_ops.py +294 -174
  215. mindspore/ops/operations/debug_ops.py +59 -4
  216. mindspore/ops/operations/image_ops.py +13 -13
  217. mindspore/ops/operations/manually_defined/ops_def.py +15 -16
  218. mindspore/ops/operations/math_ops.py +3 -4
  219. mindspore/ops/operations/nn_ops.py +7 -39
  220. mindspore/ops/primitive.py +6 -10
  221. mindspore/ops/tensor_method.py +47 -8
  222. mindspore/ops_generate/api/cpp_create_prim_instance_helper_generator.py +1 -1
  223. mindspore/ops_generate/api/functional_map_cpp_generator.py +10 -9
  224. mindspore/ops_generate/api/functions_cc_generator.py +58 -10
  225. mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +1 -1
  226. mindspore/ops_generate/common/base_generator.py +14 -0
  227. mindspore/ops_generate/common/gen_constants.py +8 -3
  228. mindspore/ops_generate/common/gen_utils.py +0 -19
  229. mindspore/ops_generate/common/op_proto.py +11 -4
  230. mindspore/ops_generate/common/template.py +88 -11
  231. mindspore/ops_generate/gen_ops.py +1 -1
  232. mindspore/ops_generate/op_def/lite_ops_cpp_generator.py +4 -4
  233. mindspore/ops_generate/op_def/ops_def_cc_generator.py +0 -3
  234. mindspore/ops_generate/op_def/ops_name_h_generator.py +0 -3
  235. mindspore/ops_generate/op_def/ops_primitive_h_generator.py +0 -4
  236. mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -2
  237. mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +49 -8
  238. mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +2 -2
  239. mindspore/ops_generate/pyboost/gen_pyboost_func.py +31 -0
  240. mindspore/ops_generate/pyboost/op_template_parser.py +98 -72
  241. mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +70 -273
  242. mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +14 -6
  243. mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +316 -0
  244. mindspore/ops_generate/pyboost/pyboost_functions_py_generator.py +1 -1
  245. mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +5 -3
  246. mindspore/ops_generate/pyboost/pyboost_inner_prim_generator.py +1 -1
  247. mindspore/ops_generate/pyboost/pyboost_internal_functions_cpp_generator.py +76 -0
  248. mindspore/ops_generate/pyboost/pyboost_internal_functions_h_generator.py +76 -0
  249. mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +125 -0
  250. mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +4 -3
  251. mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +348 -61
  252. mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +1 -1
  253. mindspore/ops_generate/pyboost/pyboost_utils.py +118 -9
  254. mindspore/ops_generate/tensor_py_cc_generator.py +1 -24
  255. mindspore/parallel/_auto_parallel_context.py +11 -8
  256. mindspore/parallel/_cell_wrapper.py +113 -45
  257. mindspore/parallel/_parallel_serialization.py +1 -1
  258. mindspore/parallel/_ps_context.py +4 -6
  259. mindspore/parallel/_tensor.py +167 -12
  260. mindspore/parallel/_transformer/moe.py +1 -1
  261. mindspore/parallel/_transformer/transformer.py +13 -8
  262. mindspore/parallel/auto_parallel.py +14 -7
  263. mindspore/parallel/checkpoint_convert.py +3 -3
  264. mindspore/parallel/checkpoint_transform.py +11 -7
  265. mindspore/parallel/cluster/process_entity/_api.py +84 -48
  266. mindspore/parallel/cluster/process_entity/_utils.py +95 -7
  267. mindspore/parallel/cluster/run.py +43 -4
  268. mindspore/parallel/function/__init__.py +8 -1
  269. mindspore/parallel/function/reshard_func.py +6 -7
  270. mindspore/parallel/nn/__init__.py +15 -2
  271. mindspore/parallel/nn/parallel_cell_wrapper.py +9 -10
  272. mindspore/parallel/nn/parallel_grad_reducer.py +7 -6
  273. mindspore/parallel/shard.py +3 -4
  274. mindspore/parallel/transform_safetensors.py +463 -174
  275. mindspore/pgodb140.dll +0 -0
  276. mindspore/pgort140.dll +0 -0
  277. mindspore/profiler/__init__.py +2 -1
  278. mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +7 -7
  279. mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +3 -0
  280. mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +12 -6
  281. mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +3 -3
  282. mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +3 -3
  283. mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +4 -4
  284. mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +3 -3
  285. mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +4 -1
  286. mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +2 -1
  287. mindspore/profiler/analysis/task_manager.py +1 -1
  288. mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +5 -1
  289. mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +2 -1
  290. mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +42 -22
  291. mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +3 -2
  292. mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +9 -5
  293. mindspore/profiler/analysis/viewer/ms_operator_details_viewer.py +132 -0
  294. mindspore/profiler/common/constant.py +16 -0
  295. mindspore/profiler/common/profiler_context.py +25 -27
  296. mindspore/profiler/common/profiler_info.py +0 -16
  297. mindspore/profiler/common/profiler_op_analyse.py +235 -0
  298. mindspore/profiler/common/profiler_output_path.py +23 -8
  299. mindspore/profiler/common/profiler_parameters.py +128 -35
  300. mindspore/profiler/dynamic_profile/__init__.py +0 -0
  301. mindspore/profiler/dynamic_profile/dynamic_monitor_proxy.py +39 -0
  302. mindspore/profiler/dynamic_profile/dynamic_profiler_config_context.py +666 -0
  303. mindspore/profiler/dynamic_profile/dynamic_profiler_utils.py +62 -0
  304. mindspore/profiler/dynamic_profiler.py +305 -314
  305. mindspore/profiler/envprofiler.py +12 -7
  306. mindspore/profiler/experimental_config.py +96 -6
  307. mindspore/profiler/mstx.py +33 -12
  308. mindspore/profiler/platform/__init__.py +2 -3
  309. mindspore/profiler/platform/npu_profiler.py +29 -19
  310. mindspore/profiler/profiler.py +35 -19
  311. mindspore/profiler/profiler_action_controller.py +64 -76
  312. mindspore/profiler/schedule.py +10 -4
  313. mindspore/rewrite/common/config.py +1 -0
  314. mindspore/rewrite/common/namer.py +1 -0
  315. mindspore/rewrite/common/namespace.py +1 -0
  316. mindspore/rewrite/node/node.py +31 -11
  317. mindspore/rewrite/parsers/assign_parser.py +1 -1
  318. mindspore/rewrite/symbol_tree/symbol_tree.py +1 -1
  319. mindspore/run_check/_check_version.py +7 -10
  320. mindspore/runtime/__init__.py +5 -5
  321. mindspore/runtime/event.py +10 -4
  322. mindspore/runtime/executor.py +60 -45
  323. mindspore/runtime/memory.py +30 -32
  324. mindspore/runtime/thread_bind_core.py +298 -164
  325. mindspore/safeguard/rewrite_obfuscation.py +12 -13
  326. mindspore/swresample-4.dll +0 -0
  327. mindspore/swscale-6.dll +0 -0
  328. mindspore/tbbmalloc.dll +0 -0
  329. mindspore/tinyxml2.dll +0 -0
  330. mindspore/train/_utils.py +14 -4
  331. mindspore/train/amp.py +43 -20
  332. mindspore/train/callback/__init__.py +5 -5
  333. mindspore/train/callback/_checkpoint.py +3 -6
  334. mindspore/train/callback/_flops_collector.py +1 -1
  335. mindspore/train/callback/_landscape.py +0 -1
  336. mindspore/train/callback/_train_fault_tolerance.py +97 -16
  337. mindspore/train/data_sink.py +11 -2
  338. mindspore/train/dataset_helper.py +9 -0
  339. mindspore/train/model.py +135 -55
  340. mindspore/train/serialization.py +133 -111
  341. mindspore/train/summary/summary_record.py +13 -2
  342. mindspore/turbojpeg.dll +0 -0
  343. mindspore/utils/__init__.py +3 -2
  344. mindspore/utils/dryrun.py +0 -6
  345. mindspore/utils/runtime_execution_order_check.py +163 -77
  346. mindspore/utils/sdc_detect.py +68 -0
  347. mindspore/utils/utils.py +6 -9
  348. mindspore/vcmeta.dll +0 -0
  349. mindspore/vcruntime140.dll +0 -0
  350. mindspore/vcruntime140_1.dll +0 -0
  351. mindspore/version.py +1 -1
  352. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/METADATA +5 -4
  353. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/RECORD +356 -394
  354. mindspore/_deprecated/jit.py +0 -198
  355. mindspore/experimental/es/__init__.py +0 -22
  356. mindspore/experimental/es/embedding_service.py +0 -891
  357. mindspore/experimental/es/embedding_service_layer.py +0 -581
  358. mindspore/profiler/parser/__init__.py +0 -14
  359. mindspore/profiler/parser/aicpu_data_parser.py +0 -272
  360. mindspore/profiler/parser/ascend_analysis/__init__.py +0 -14
  361. mindspore/profiler/parser/ascend_analysis/constant.py +0 -71
  362. mindspore/profiler/parser/ascend_analysis/file_manager.py +0 -180
  363. mindspore/profiler/parser/ascend_analysis/function_event.py +0 -185
  364. mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +0 -136
  365. mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +0 -131
  366. mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +0 -104
  367. mindspore/profiler/parser/ascend_analysis/path_manager.py +0 -313
  368. mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +0 -123
  369. mindspore/profiler/parser/ascend_analysis/tlv_decoder.py +0 -86
  370. mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +0 -75
  371. mindspore/profiler/parser/ascend_cluster_generator.py +0 -116
  372. mindspore/profiler/parser/ascend_communicate_generator.py +0 -314
  373. mindspore/profiler/parser/ascend_flops_generator.py +0 -116
  374. mindspore/profiler/parser/ascend_fpbp_generator.py +0 -82
  375. mindspore/profiler/parser/ascend_hccl_generator.py +0 -271
  376. mindspore/profiler/parser/ascend_integrate_generator.py +0 -42
  377. mindspore/profiler/parser/ascend_memory_generator.py +0 -185
  378. mindspore/profiler/parser/ascend_msprof_exporter.py +0 -282
  379. mindspore/profiler/parser/ascend_msprof_generator.py +0 -187
  380. mindspore/profiler/parser/ascend_op_generator.py +0 -334
  381. mindspore/profiler/parser/ascend_steptrace_generator.py +0 -94
  382. mindspore/profiler/parser/ascend_timeline_generator.py +0 -545
  383. mindspore/profiler/parser/base_timeline_generator.py +0 -483
  384. mindspore/profiler/parser/container.py +0 -229
  385. mindspore/profiler/parser/cpu_gpu_timeline_generator.py +0 -697
  386. mindspore/profiler/parser/flops_parser.py +0 -531
  387. mindspore/profiler/parser/framework_enum.py +0 -111
  388. mindspore/profiler/parser/framework_parser.py +0 -464
  389. mindspore/profiler/parser/framework_struct.py +0 -61
  390. mindspore/profiler/parser/gpu_analysis/__init__.py +0 -14
  391. mindspore/profiler/parser/gpu_analysis/function_event.py +0 -44
  392. mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +0 -89
  393. mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +0 -72
  394. mindspore/profiler/parser/hccl_parser.py +0 -573
  395. mindspore/profiler/parser/hwts_log_parser.py +0 -122
  396. mindspore/profiler/parser/integrator.py +0 -526
  397. mindspore/profiler/parser/memory_usage_parser.py +0 -277
  398. mindspore/profiler/parser/minddata_analyzer.py +0 -800
  399. mindspore/profiler/parser/minddata_parser.py +0 -186
  400. mindspore/profiler/parser/minddata_pipeline_parser.py +0 -299
  401. mindspore/profiler/parser/op_intermediate_parser.py +0 -149
  402. mindspore/profiler/parser/optime_parser.py +0 -250
  403. mindspore/profiler/parser/profiler_info.py +0 -213
  404. mindspore/profiler/parser/step_trace_parser.py +0 -666
  405. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/WHEEL +0 -0
  406. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/entry_points.txt +0 -0
  407. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/top_level.txt +0 -0
@@ -1,271 +0,0 @@
1
- # Copyright 2023 Huawei Technologies Co., Ltd
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- # ============================================================================
15
- """hccl analyse model"""
16
- import copy
17
- import csv
18
- import json
19
- import logging
20
- import os
21
- import stat
22
- import glob
23
-
24
- import numpy as np
25
- from mindspore.profiler.common.exceptions.exceptions import ProfilerIOException
26
- from mindspore.profiler.common.util import get_newest_file
27
-
28
-
29
- class AscendHCCLGenerator:
30
- """Generate ascend hccl data from files."""
31
-
32
- DEFAULT_MODEL_ID = 4294967295
33
-
34
- def __init__(self, mindstudio_profiler_output, steptrace):
35
- self.mindstudio_profiler_output = mindstudio_profiler_output
36
- self.steptrace = steptrace
37
- self.hccl_raw = []
38
- self.hccl_data_df = np.dtype(
39
- [('model_id', int), ('iteration_id', int), ('name', object), ('pid', int), ('tid', int), ('ts', float),
40
- ('te', float), ('dur', float), ('ph', object),
41
- ('task_type', object), ('link_info', object), ('transport_type', object), ('size', int), ('tag', object)])
42
-
43
- @staticmethod
44
- def _cost_analyse(iteration):
45
- """analyse communication cost and wait cost"""
46
- communication_cost = np.sum(iteration[iteration['name'] != 'Notify_Wait']['dur'])
47
- wait_cost = np.sum(iteration[iteration['name'] == 'Notify_Wait']['dur'])
48
- return communication_cost, wait_cost
49
-
50
- @staticmethod
51
- def _rdma_analyse(groupby_transport):
52
- """rdma analyse"""
53
- thread_groups = np.unique(groupby_transport['tid'])
54
- thread_information = []
55
- for thread_index in thread_groups:
56
- groupby_thread = groupby_transport[groupby_transport['tid'] == thread_index]
57
- rdma_communication_time = 0
58
- rdma_communication_size = 0
59
- rdma_communication_wait_time = 0
60
- start_index = 0
61
- end_index = groupby_thread.size - 2
62
- while start_index < end_index:
63
- first_task_type = groupby_thread[start_index]['task_type']
64
- if first_task_type == 'RDMASend':
65
- second_index = start_index + 1
66
- third_index = start_index + 2
67
- second_task_type = groupby_thread[second_index]['task_type']
68
- third_task_type = groupby_thread[third_index]['task_type']
69
- if second_task_type == 'RDMASend' and third_task_type == 'Notify Wait':
70
- rdma_send_cost = groupby_thread[start_index]['dur']
71
- notify_record_cost = groupby_thread[second_index]['dur']
72
- notify_wait_cost = groupby_thread[third_index]['dur']
73
- rdma_communication_time += rdma_send_cost + notify_record_cost + notify_wait_cost
74
- rdma_communication_wait_time += notify_wait_cost
75
- rdma_communication_size += groupby_thread[start_index]['size'] + groupby_thread[second_index][
76
- 'size']
77
- start_index += 2
78
- start_index += 1
79
- rdma_communication_wait_time = rdma_communication_wait_time / 1e3
80
- rdma_communication_size = rdma_communication_size / 1e3
81
- rdma_communication_time = rdma_communication_time / 1e3
82
- rdma_bandwidth = rdma_communication_size / (rdma_communication_time / 1e3) \
83
- if rdma_communication_size else 0
84
- thread_information.append(
85
- [rdma_communication_time, rdma_communication_size, rdma_bandwidth, rdma_communication_wait_time])
86
- if len(thread_information) > 1:
87
- thread_information = np.sum(thread_information, axis=0).tolist()
88
-
89
- return thread_information
90
-
91
- def parse(self):
92
- """Analyse the original hccl data generator hccl data."""
93
-
94
- raw_data = []
95
- msprof_name = fr'{self.mindstudio_profiler_output}/msprof_*.json'
96
- for msprof_file in get_newest_file(glob.glob(msprof_name)):
97
- with open(msprof_file) as fr:
98
- raw_data.extend(json.load(fr))
99
-
100
- hccl_data = self._original_data_analyse(raw_data)
101
-
102
- for model_id in np.unique(hccl_data['model_id']):
103
- hccl_data_model = hccl_data[hccl_data['model_id'] == model_id]
104
- for iteration_id in np.unique(hccl_data_model['iteration_id']):
105
- hccl_data_model_iteration = hccl_data_model[hccl_data_model['iteration_id'] == iteration_id]
106
-
107
- hccl_abstract_data = hccl_data_model_iteration[hccl_data_model_iteration['task_type'] == '']
108
- hccl_detail_data = hccl_data_model_iteration[hccl_data_model_iteration['task_type'] != '']
109
- hccl_abstract_data = np.sort(hccl_abstract_data, order='ts')
110
- hccl_detail_data = np.sort(hccl_detail_data, order='ts')
111
-
112
- tag = np.searchsorted(hccl_abstract_data['ts'], hccl_detail_data['ts'], side='right') - 1
113
-
114
- hccl_detail_data['tag'] = [x[-1] for x in
115
- np.char.split(hccl_abstract_data[tag]['name'].astype(str), sep='/')]
116
-
117
- self.hccl_raw.append(self._iteration_analyse(hccl_detail_data, iteration_id))
118
-
119
- self.hccl_raw = sorted(self.hccl_raw, key=lambda x: x[0])
120
- if self.hccl_raw:
121
- self.hccl_raw.append(copy.deepcopy(self.hccl_raw[-1]))
122
- self.hccl_raw[-1][0] = '-'
123
- for _, value in self.hccl_raw[-1][4].items():
124
- value[0] = '-'
125
-
126
- def write(self, hccl_raw_path):
127
- """
128
- Write the flops.csv and flops_summary.json
129
-
130
- Args:
131
- hccl_raw_path(str): hccl_raw.csv path.
132
- """
133
- try:
134
- with os.fdopen(os.open(hccl_raw_path,
135
- os.O_WRONLY | os.O_CREAT | os.O_TRUNC, stat.S_IWUSR | stat.S_IRUSR), 'w',
136
- newline='') as hccl_row:
137
- writer = csv.writer(hccl_row)
138
- writer.writerow(
139
- ['step_num', 'communication_cost', 'wait_cost', 'link_info', 'communication_operator_cost'])
140
- for row in self.hccl_raw:
141
- row[3] = json.dumps(row[3])
142
- row[4] = json.dumps(row[4])
143
- writer.writerows(self.hccl_raw)
144
- except (IOError, OSError) as err:
145
- logging.critical('Errot occurred when write aicore detail file: %s', err)
146
- raise ProfilerIOException() from err
147
- if os.path.exists(hccl_raw_path):
148
- os.chmod(hccl_raw_path, stat.S_IREAD | stat.S_IWRITE)
149
-
150
- def _original_data_analyse(self, original_data):
151
- """analyse original data"""
152
-
153
- groups_steptrace = {model_id: np.sort(self.steptrace[self.steptrace['Model ID'] == model_id],
154
- order='Iteration ID')
155
- for model_id in np.unique(self.steptrace['Model ID'])}
156
-
157
- hccl_pid = None
158
- for row in original_data:
159
- if row.get('ph') == 'M' and row.get('name') == 'process_name' and row.get('args', {}).get('name') == 'HCCL':
160
- hccl_pid = row.get('pid')
161
- break
162
-
163
- target_data = []
164
- for row in original_data:
165
- model_id = row.get('args', {}).get('model id')
166
- pid = row.get('pid')
167
- if hccl_pid == pid and row.get('ph') == 'X' and model_id is not None:
168
- name = row.get('name')
169
- tid = row.get('tid')
170
- ts = float(row.get('ts'))
171
- dur = float(row.get('dur'))
172
- te = ts + dur
173
- ph = row.get('ph')
174
- task_type = row.get('args', {}).get('task type', '')
175
- src_rank = row.get('args', {}).get('src rank', 0)
176
- dst_rank = row.get('args', {}).get('dst rank', 0)
177
- if src_rank == int('0xffffffff', 16):
178
- src_rank = dst_rank
179
- if dst_rank == int('0xffffffff', 16):
180
- dst_rank = src_rank
181
- transport_type = row.get('args', {}).get('transport type', '')
182
- if transport_type == 'LOCAL':
183
- src_rank, dst_rank = dst_rank, src_rank
184
- link_info = str(src_rank) + '-' + str(dst_rank)
185
- size = row.get('args', {}).get('size(Byte)', 0)
186
- size = size if isinstance(size, int) else int(size, 16)
187
- steptrace = groups_steptrace.get(model_id, None)
188
- if steptrace is None:
189
- if self.DEFAULT_MODEL_ID != model_id:
190
- logging.warning('Could not find model: %s in hccl json, skip.', model_id)
191
- continue
192
- tag = np.searchsorted(steptrace['Iteration End'], te * 1e-3, side='left')
193
- iteration_id = steptrace[tag]['Iteration ID']
194
- target_data.append(
195
- tuple([model_id, iteration_id, name, pid, tid,
196
- ts, te, dur, ph, task_type,
197
- link_info, transport_type, size, -1]))
198
-
199
- hccl_data = np.array(target_data, dtype=self.hccl_data_df)
200
-
201
- return hccl_data
202
-
203
- def _iteration_analyse(self, hccl_detail_data, iteration):
204
- """analyse data by iteration """
205
- communication_cost, wait_cost = self._cost_analyse(hccl_detail_data)
206
- link_info = self._link_info_analyse(hccl_detail_data)
207
- communication_operator_cost = self._communication_operator_cost_analyse(hccl_detail_data, iteration)
208
- return [iteration, communication_cost, wait_cost, link_info, communication_operator_cost]
209
-
210
- def _link_info_analyse(self, hccl_detail_data):
211
- """analyse link info data"""
212
- groupby_iteration = hccl_detail_data[hccl_detail_data['task_type'] != 'Notify Record']
213
- link_info_groups = np.unique(groupby_iteration['link_info'])
214
- link_info_information = dict()
215
- for link_info_index in link_info_groups:
216
- groupby_link_info = groupby_iteration[groupby_iteration['link_info'] == link_info_index]
217
- transport_groups = np.unique(groupby_iteration['transport_type'])
218
- transport_information = dict()
219
- for transport_index in transport_groups:
220
- groupby_transport = groupby_link_info[groupby_link_info['transport_type'] == transport_index]
221
- if transport_index == 'SDMA' and groupby_transport.size > 0:
222
- groupby_sdma = \
223
- groupby_transport[np.isin(groupby_transport['task_type'], ['Memcpy', 'Reduce Inline'])][
224
- ['dur', 'size']]
225
- sdma_communication_time = np.sum(groupby_sdma['dur']) * 1e-3
226
- sdma_communication_size = np.sum(groupby_sdma['size']) * 1e-3
227
- sdma_bandwidth = sdma_communication_size / sdma_communication_time * 1e-3 \
228
- if sdma_communication_time != 0 else 0
229
- transport_information['SDMA'] = [sdma_communication_time, sdma_communication_size, sdma_bandwidth]
230
- elif transport_index == 'RDMA' and groupby_transport.size > 0:
231
- transport_information['RDMA'] = self._rdma_analyse(groupby_transport)
232
- link_info_information[link_info_index] = transport_information
233
- return link_info_information
234
-
235
- def _communication_operator_cost_analyse(self, hccl_detail_data, iteration_index):
236
- """analyse communication operator cost"""
237
- groupby_iteration = hccl_detail_data[hccl_detail_data['task_type'] != 'Notify Record']
238
- tag_groups = np.unique(groupby_iteration['tag'])
239
- tag_information = dict()
240
- for tag_index in tag_groups:
241
- groupby_tag = groupby_iteration[groupby_iteration['tag'] == tag_index]
242
- link_groups = np.unique(groupby_iteration['link_info'])
243
- link_info_information = dict()
244
- for link_info_index in link_groups:
245
- groupby_link_info = groupby_tag[groupby_tag['link_info'] == link_info_index]
246
- transport_groups = np.unique(groupby_link_info['transport_type'])
247
- transport_information = dict()
248
- for transport_index in transport_groups:
249
- groupby_transport = groupby_link_info[groupby_link_info['transport_type'] == transport_index]
250
- if transport_index == 'SDMA':
251
- groupby_sdma = \
252
- groupby_transport[np.isin(groupby_transport['task_type'], ['Memcpy', 'Reduce Inline'])][
253
- ['dur', 'size']]
254
- sdma_communication_time = np.sum(groupby_sdma['dur']) * 1e-3
255
- sdma_communication_size = np.sum(groupby_sdma['size']) * 1e-3
256
- sdma_bandwidth = sdma_communication_size / sdma_communication_time * 1e-3 \
257
- if sdma_communication_time != 0 else 0
258
- transport_information['SDMA'] = [
259
- sdma_communication_time, sdma_communication_size,
260
- sdma_bandwidth
261
- ]
262
- elif transport_index == 'RDMA':
263
- transport_information['RDMA'] = self._rdma_analyse(groupby_transport)
264
- link_info_information[link_info_index] = transport_information
265
- communication_cost = np.sum(groupby_tag[groupby_tag['name'] != 'Notify_Wait']['dur'])
266
- wait_cost = np.sum(groupby_tag[groupby_tag['name'] == 'Notify_Wait']['dur'])
267
- tag_information[tag_index] = [
268
- str(iteration_index), communication_cost, wait_cost,
269
- link_info_information
270
- ]
271
- return tag_information
@@ -1,42 +0,0 @@
1
- # Copyright 2024 Huawei Technologies Co., Ltd
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- # ============================================================================
15
- """PROF csv data analyze module"""
16
- import os
17
-
18
- from mindspore.profiler.parser.ascend_analysis.file_manager import FileManager
19
-
20
-
21
- class AscendIntegrateGenerator:
22
- """Generate ms profiler output csv"""
23
-
24
- def __init__(self, mindstudio_profiler_output: str, ascend_ms_output_path: str):
25
- self._mindstudio_profiler_output = mindstudio_profiler_output
26
- self._ascend_ms_output_path = ascend_ms_output_path
27
-
28
- def parse(self):
29
- """Generate ms profiler output csv"""
30
- self._generate_kernel_details()
31
-
32
- def _generate_kernel_details(self):
33
- """Generate kernel_details.csv"""
34
- header_map = {
35
- "Op Name": "Name", "OP Type": "Type", "Task Type": "Accelerator Core",
36
- "Task Start Time(us)": "Start Time(us)", "Task Duration(us)": "Duration(us)",
37
- "Task Wait Time(us)": "Wait Time(us)",
38
- }
39
- op_summary_file_list = FileManager.get_csv_file_list_by_start_name(self._mindstudio_profiler_output,
40
- "op_summary")
41
- kernel_details_file = os.path.join(self._ascend_ms_output_path, "kernel_details.csv")
42
- FileManager.combine_csv_file(op_summary_file_list, kernel_details_file, header_map)
@@ -1,185 +0,0 @@
1
- # Copyright 2024 Huawei Technologies Co., Ltd
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- # ============================================================================
15
- """memory data analyze module"""
16
- import os
17
-
18
- from decimal import Decimal
19
-
20
- from mindspore.profiler.parser.ascend_analysis.file_manager import FileManager
21
-
22
-
23
- class AscendMemoryGenerator:
24
- """Parsing the memory data of the ascend device"""
25
- GE_MEMORY_RECORD_HEADERS = ["Device id", "Component", "Timestamp(us)", "Total Allocated(KB)",
26
- "Total Reserved(KB)", "Device"]
27
- MS_MEMORY_RECORD_HEADERS = ["Timestamp(ns)", "Total Allocated(Byte)", "Total Reserved(Byte)", "Total Active(Byte)"]
28
- TARGET_MEMORY_RECORD_HEADERS = ["Component", "Timestamp(us)", "Total Allocated(MB)", "Total Reserved(MB)",
29
- "Total Active(MB)", "Device Type"]
30
-
31
- def __init__(self, source_path: str, rank_id: int, mindstudio_profiler_output: str, ascend_ms_output_path: str):
32
- self._source_path = source_path
33
- self._rank_id = rank_id
34
- self._mindstudio_profiler_output = mindstudio_profiler_output
35
- self._ascend_ms_output_path = ascend_ms_output_path
36
- self._ge_memory_record = []
37
- self._ms_memory_record = []
38
-
39
- def parse(self):
40
- """Parse all memory data"""
41
- self.copy_npu_module_mem_csv()
42
- self.parse_memory_record()
43
-
44
- def copy_npu_module_mem_csv(self):
45
- """Generate npu_module_mem.csv"""
46
- npu_module_mem_file_list = FileManager.get_csv_file_list_by_start_name(self._mindstudio_profiler_output,
47
- "npu_module_mem")
48
- target_file_path = os.path.join(self._ascend_ms_output_path, "npu_module_mem.csv")
49
- FileManager.combine_csv_file(npu_module_mem_file_list, target_file_path)
50
-
51
- def parse_memory_record(self):
52
- """Generate memory_record.csv"""
53
- self._parse_ge_memory_record()
54
- self._parse_ms_memory_record()
55
- combined_memory_data = self._combine_ge_ms_memory_record()
56
- target_file_path = os.path.join(self._ascend_ms_output_path, "memory_record.csv")
57
- FileManager.create_csv_file(target_file_path, combined_memory_data, self.TARGET_MEMORY_RECORD_HEADERS)
58
-
59
- def _parse_ge_memory_record(self):
60
- """Parse ge memory record data"""
61
- memory_record_file_list = FileManager.get_csv_file_list_by_start_name(self._mindstudio_profiler_output,
62
- "memory_record")
63
- for file in memory_record_file_list:
64
- data = FileManager.read_csv_file(file)
65
- if len(data) > 1:
66
- self._ge_memory_record.extend(data[1:])
67
-
68
- def _parse_ms_memory_record(self):
69
- """Parse mindspore memory record data"""
70
- memory_record_file = os.path.join(self._source_path, f"cpu_ms_memory_record_{self._rank_id}.txt")
71
- data = FileManager.read_txt_file(memory_record_file)
72
- if len(data) > 1:
73
- self._ms_memory_record.extend(data[1:])
74
-
75
- def _get_app_reserved_memory(self) -> list:
76
- """Get the reserved memory of the application from npu_mem.csv"""
77
- npu_module_mem_file_list = FileManager.get_csv_file_list_by_start_name(self._mindstudio_profiler_output,
78
- "npu_mem")
79
- app_mems = []
80
- for file in npu_module_mem_file_list:
81
- md_mems = FileManager.read_csv_file(file)
82
- for mem in md_mems:
83
- if mem[1] == "APP":
84
- app_mems.append(MemoryRecordBean([mem[1], mem[-1].rstrip('\t'), 0.0, float(mem[4]), 0.0,
85
- f"NPU:{self._rank_id}"]).row)
86
-
87
- return app_mems
88
-
89
- def _combine_ge_ms_memory_record(self) -> list:
90
- """Combine ge and mindspore memory record data"""
91
- memory_records = []
92
- for ge_memory in self._ge_memory_record:
93
- memory_record = dict(zip(self.GE_MEMORY_RECORD_HEADERS, ge_memory))
94
- memory_records.append(
95
- MemoryRecordBean([memory_record.get("Component", "GE"), memory_record.get("Timestamp(us)"),
96
- memory_record.get("Total Allocated(KB)", 0),
97
- memory_record.get("Total Reserved(KB)", 0),
98
- 0, memory_record.get("Device")]))
99
- for ms_memory in self._ms_memory_record:
100
- memory_record = dict(zip(self.MS_MEMORY_RECORD_HEADERS, ms_memory))
101
- memory_records.append(
102
- MemoryRecordBean(["MindSpore", Decimal(memory_record.get("Timestamp(ns)", 0)) / 1000,
103
- float(memory_record.get("Total Allocated(Byte)", 0)) / 1024,
104
- float(memory_record.get("Total Reserved(Byte)", 0)) / 1024,
105
- float(memory_record.get("Total Active(Byte)", 0)) / 1024,
106
- f"NPU:{self._rank_id}"]))
107
- memory_records.sort(key=lambda x: x.time_us)
108
- last_ge_memory, last_ms_memory = MemoryRecordBean([0] * 6), MemoryRecordBean([0] * 6)
109
- result_data = []
110
- for memory_record in memory_records:
111
- result_data.append(memory_record.row)
112
- last_memory = last_ms_memory if memory_record.is_ge_component() else last_ge_memory
113
- combined_mem = MemoryRecordBean(["MindSpore+GE", memory_record.time_us,
114
- memory_record.total_allocated_kb + last_memory.total_allocated_kb,
115
- memory_record.total_reserved_kb + last_memory.total_reserved_kb,
116
- memory_record.total_active_kb + last_memory.total_active_kb,
117
- f"NPU:{self._rank_id}"])
118
- result_data.append(combined_mem.row)
119
- if memory_record.is_ge_component():
120
- last_ge_memory = memory_record
121
- else:
122
- last_ms_memory = memory_record
123
- return result_data + self._get_app_reserved_memory()
124
-
125
-
126
- class MemoryRecordBean:
127
- """Memory Record Struct"""
128
- KB_TO_MB = 1000
129
- HEADERS = ["Component", "Timestamp(us)", "Total Allocated(KB)", "Total Reserved(KB)",
130
- "Total Active(KB)", "Device Type"]
131
-
132
- def __init__(self, data: list):
133
- self._data = dict(zip(self.HEADERS, data))
134
-
135
- @property
136
- def row(self) -> list:
137
- return [self.component, self.time_us_str, self.total_allocated_mb, self.total_reserved_mb,
138
- self.total_active_mb, self.device_type]
139
-
140
- @property
141
- def component(self) -> str:
142
- return self._data.get("Component", "")
143
-
144
- @property
145
- def time_us_str(self) -> str:
146
- ts_us = self._data.get("Timestamp(us)", 0)
147
- return str(ts_us)
148
-
149
- @property
150
- def total_allocated_mb(self) -> float:
151
- return float(self._data.get("Total Allocated(KB)", 0)) / self.KB_TO_MB
152
-
153
- @property
154
- def total_reserved_mb(self) -> float:
155
- return float(self._data.get("Total Reserved(KB)", 0)) / self.KB_TO_MB
156
-
157
- @property
158
- def total_active_mb(self) -> float:
159
- return float(self._data.get("Total Active(KB)", 0)) / self.KB_TO_MB
160
-
161
- @property
162
- def device_type(self) -> float:
163
- return self._data.get("Device Type", "")
164
-
165
- @property
166
- def total_allocated_kb(self) -> float:
167
- return float(self._data.get("Total Allocated(KB)", 0))
168
-
169
- @property
170
- def total_reserved_kb(self) -> float:
171
- return float(self._data.get("Total Reserved(KB)", 0))
172
-
173
- @property
174
- def total_active_kb(self) -> float:
175
- return float(self._data.get("Total Active(KB)", 0))
176
-
177
- @property
178
- def time_us(self) -> Decimal:
179
- return Decimal(self._data.get("Timestamp(us)", 0))
180
-
181
- def is_ge_component(self):
182
- """
183
- Determine if it is GE
184
- """
185
- return self.component == "GE"