mindspore 2.6.0rc1__cp39-cp39-win_amd64.whl → 2.7.0rc1__cp39-cp39-win_amd64.whl

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

Potentially problematic release.


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

Files changed (384) hide show
  1. mindspore/.commit_id +1 -1
  2. mindspore/__init__.py +1 -1
  3. mindspore/_c_dataengine.cp39-win_amd64.pyd +0 -0
  4. mindspore/_c_expression.cp39-win_amd64.pyd +0 -0
  5. mindspore/_c_mindrecord.cp39-win_amd64.pyd +0 -0
  6. mindspore/_checkparam.py +40 -9
  7. mindspore/{_deprecated → _extends/optimize}/__init__.py +9 -3
  8. mindspore/_extends/optimize/cell_utils.py +96 -0
  9. mindspore/_extends/parse/__init__.py +2 -2
  10. mindspore/_extends/parse/compile_config.py +44 -22
  11. mindspore/_extends/parse/deprecated/deprecated_tensor_method.py +1 -1
  12. mindspore/_extends/parse/parser.py +37 -62
  13. mindspore/_extends/parse/resources.py +39 -0
  14. mindspore/_extends/parse/standard_method.py +43 -13
  15. mindspore/_extends/parse/trope.py +8 -1
  16. mindspore/_extends/pijit/__init__.py +1 -2
  17. mindspore/amp.py +4 -4
  18. mindspore/avcodec-59.dll +0 -0
  19. mindspore/avdevice-59.dll +0 -0
  20. mindspore/avfilter-8.dll +0 -0
  21. mindspore/avformat-59.dll +0 -0
  22. mindspore/avutil-57.dll +0 -0
  23. mindspore/boost/adasum.py +1 -1
  24. mindspore/boost/boost_cell_wrapper.py +4 -4
  25. mindspore/common/__init__.py +27 -2
  26. mindspore/common/_grad_function.py +2 -1
  27. mindspore/common/_pijit_context.py +28 -7
  28. mindspore/common/_stub_tensor.py +1 -209
  29. mindspore/common/_tensor_cpp_method.py +1 -1
  30. mindspore/common/_tensor_docs.py +77 -16
  31. mindspore/common/api.py +238 -113
  32. mindspore/common/dtype.py +21 -11
  33. mindspore/common/dump.py +10 -15
  34. mindspore/common/generator.py +5 -3
  35. mindspore/common/hook_handle.py +11 -2
  36. mindspore/common/jit_config.py +1 -1
  37. mindspore/common/jit_trace.py +84 -105
  38. mindspore/common/parameter.py +26 -12
  39. mindspore/common/recompute.py +3 -3
  40. mindspore/common/sparse_tensor.py +0 -3
  41. mindspore/common/symbol.py +0 -1
  42. mindspore/common/tensor.py +81 -81
  43. mindspore/communication/_comm_helper.py +46 -4
  44. mindspore/communication/management.py +79 -7
  45. mindspore/context.py +58 -40
  46. mindspore/dataset/core/config.py +3 -3
  47. mindspore/dataset/engine/datasets.py +20 -7
  48. mindspore/dataset/engine/datasets_user_defined.py +33 -3
  49. mindspore/dataset/engine/iterators.py +2 -2
  50. mindspore/dataset/engine/obs/config_loader.py +2 -2
  51. mindspore/dataset/engine/obs/obs_mindrecord_dataset.py +8 -0
  52. mindspore/dataset/transforms/py_transforms.py +7 -3
  53. mindspore/dataset/transforms/transforms.py +7 -3
  54. mindspore/dataset/vision/validators.py +1 -0
  55. mindspore/device_context/ascend/device.py +1 -1
  56. mindspore/device_context/gpu/__init__.py +2 -2
  57. mindspore/device_context/gpu/device.py +1 -1
  58. mindspore/device_context/gpu/op_precision.py +4 -2
  59. mindspore/device_context/gpu/op_tuning.py +6 -3
  60. mindspore/device_manager.py +16 -9
  61. mindspore/dnnl.dll +0 -0
  62. mindspore/experimental/llm_boost/ascend_native/llama_boost_ascend_native.py +3 -7
  63. mindspore/experimental/llm_boost/atb/boost_base.py +2 -3
  64. mindspore/experimental/optim/adadelta.py +13 -20
  65. mindspore/experimental/optim/adagrad.py +15 -22
  66. mindspore/experimental/optim/adam.py +17 -24
  67. mindspore/experimental/optim/adamax.py +14 -22
  68. mindspore/experimental/optim/adamw.py +28 -34
  69. mindspore/experimental/optim/asgd.py +15 -25
  70. mindspore/experimental/optim/lr_scheduler.py +27 -45
  71. mindspore/experimental/optim/nadam.py +14 -24
  72. mindspore/experimental/optim/optimizer.py +13 -23
  73. mindspore/experimental/optim/radam.py +18 -24
  74. mindspore/experimental/optim/rmsprop.py +14 -25
  75. mindspore/experimental/optim/rprop.py +15 -26
  76. mindspore/experimental/optim/sgd.py +9 -19
  77. mindspore/hal/__init__.py +4 -4
  78. mindspore/hal/contiguous_tensors_handle.py +2 -2
  79. mindspore/hal/memory.py +27 -7
  80. mindspore/include/api/cell.h +37 -1
  81. mindspore/include/api/delegate.h +10 -0
  82. mindspore/include/api/model.h +3 -0
  83. mindspore/include/api/types.h +2 -2
  84. mindspore/include/c_api/model_c.h +0 -58
  85. mindspore/include/c_api/tensor_c.h +0 -26
  86. mindspore/include/dataset/vision_ascend.h +1 -1
  87. mindspore/jpeg62.dll +0 -0
  88. mindspore/mindrecord/tools/cifar10.py +60 -11
  89. mindspore/mindrecord/tools/cifar10_to_mr.py +5 -0
  90. mindspore/mindspore_backend_common.dll +0 -0
  91. mindspore/mindspore_backend_manager.dll +0 -0
  92. mindspore/mindspore_common.dll +0 -0
  93. mindspore/mindspore_core.dll +0 -0
  94. mindspore/mindspore_cpu_res_manager.dll +0 -0
  95. mindspore/mindspore_dump.dll +0 -0
  96. mindspore/mindspore_frontend.dll +0 -0
  97. mindspore/mindspore_glog.dll +0 -0
  98. mindspore/mindspore_memory_pool.dll +0 -0
  99. mindspore/mindspore_ms_backend.dll +0 -0
  100. mindspore/mindspore_ops.dll +0 -0
  101. mindspore/mindspore_ops_host.dll +0 -0
  102. mindspore/mindspore_ops_kernel_common.dll +0 -0
  103. mindspore/mindspore_profiler.dll +0 -0
  104. mindspore/mindspore_pyboost.dll +0 -0
  105. mindspore/mindspore_pynative.dll +0 -0
  106. mindspore/mindspore_res_manager.dll +0 -0
  107. mindspore/mindspore_runtime_pipeline.dll +0 -0
  108. mindspore/mint/__init__.py +6 -46
  109. mindspore/mint/distributed/__init__.py +1 -0
  110. mindspore/mint/distributed/distributed.py +212 -9
  111. mindspore/mint/nn/__init__.py +1 -1
  112. mindspore/mint/nn/functional.py +53 -6
  113. mindspore/mint/nn/layer/_functions.py +164 -294
  114. mindspore/mint/nn/layer/activation.py +8 -6
  115. mindspore/mint/nn/layer/conv.py +137 -101
  116. mindspore/mint/nn/layer/normalization.py +8 -22
  117. mindspore/mint/optim/adam.py +19 -18
  118. mindspore/mint/optim/adamw.py +14 -8
  119. mindspore/mint/optim/sgd.py +5 -5
  120. mindspore/nn/cell.py +328 -502
  121. mindspore/nn/grad/cell_grad.py +11 -12
  122. mindspore/nn/layer/activation.py +32 -34
  123. mindspore/nn/layer/basic.py +67 -64
  124. mindspore/nn/layer/channel_shuffle.py +4 -4
  125. mindspore/nn/layer/combined.py +4 -2
  126. mindspore/nn/layer/conv.py +117 -110
  127. mindspore/nn/layer/dense.py +9 -7
  128. mindspore/nn/layer/embedding.py +50 -52
  129. mindspore/nn/layer/image.py +37 -39
  130. mindspore/nn/layer/math.py +111 -112
  131. mindspore/nn/layer/normalization.py +56 -44
  132. mindspore/nn/layer/pooling.py +58 -63
  133. mindspore/nn/layer/rnn_cells.py +33 -33
  134. mindspore/nn/layer/rnns.py +56 -56
  135. mindspore/nn/layer/thor_layer.py +74 -73
  136. mindspore/nn/layer/transformer.py +11 -1
  137. mindspore/nn/learning_rate_schedule.py +20 -20
  138. mindspore/nn/loss/loss.py +79 -81
  139. mindspore/nn/optim/adam.py +3 -3
  140. mindspore/nn/optim/adasum.py +2 -2
  141. mindspore/nn/optim/asgd.py +2 -0
  142. mindspore/nn/optim/optimizer.py +1 -1
  143. mindspore/nn/optim/thor.py +2 -2
  144. mindspore/nn/probability/distribution/exponential.py +2 -1
  145. mindspore/nn/probability/distribution/poisson.py +2 -1
  146. mindspore/nn/sparse/sparse.py +3 -3
  147. mindspore/nn/wrap/cell_wrapper.py +34 -37
  148. mindspore/nn/wrap/grad_reducer.py +37 -37
  149. mindspore/nn/wrap/loss_scale.py +72 -74
  150. mindspore/numpy/array_creations.py +5 -5
  151. mindspore/numpy/fft.py +1 -1
  152. mindspore/numpy/math_ops.py +5 -5
  153. mindspore/opencv_core452.dll +0 -0
  154. mindspore/opencv_imgcodecs452.dll +0 -0
  155. mindspore/opencv_imgproc452.dll +0 -0
  156. mindspore/ops/_grad_experimental/grad_comm_ops.py +51 -13
  157. mindspore/ops/_grad_experimental/grad_debug_ops.py +14 -0
  158. mindspore/ops/_vmap/vmap_array_ops.py +31 -13
  159. mindspore/ops/_vmap/vmap_nn_ops.py +8 -16
  160. mindspore/ops/auto_generate/cpp_create_prim_instance_helper.py +42 -11
  161. mindspore/ops/auto_generate/gen_extend_func.py +23 -141
  162. mindspore/ops/auto_generate/gen_ops_def.py +727 -321
  163. mindspore/ops/auto_generate/gen_ops_prim.py +1721 -984
  164. mindspore/ops/auto_generate/pyboost_inner_prim.py +31 -1
  165. mindspore/ops/composite/__init__.py +10 -0
  166. mindspore/ops/composite/base.py +8 -4
  167. mindspore/ops/composite/multitype_ops/__init__.py +12 -1
  168. mindspore/ops/composite/multitype_ops/_compile_utils.py +133 -109
  169. mindspore/ops/composite/multitype_ops/add_impl.py +70 -2
  170. mindspore/ops/composite/multitype_ops/div_impl.py +49 -0
  171. mindspore/ops/composite/multitype_ops/floordiv_impl.py +29 -0
  172. mindspore/ops/composite/multitype_ops/getitem_impl.py +11 -0
  173. mindspore/ops/composite/multitype_ops/mod_impl.py +5 -3
  174. mindspore/ops/composite/multitype_ops/mul_impl.py +49 -0
  175. mindspore/ops/composite/multitype_ops/setitem_impl.py +57 -0
  176. mindspore/ops/composite/multitype_ops/sub_impl.py +34 -0
  177. mindspore/ops/composite/multitype_ops/zeros_like_impl.py +14 -0
  178. mindspore/ops/function/__init__.py +3 -1
  179. mindspore/ops/function/_add_attr_func.py +11 -6
  180. mindspore/ops/function/array_func.py +9 -96
  181. mindspore/ops/function/debug_func.py +4 -3
  182. mindspore/ops/function/grad/grad_func.py +1 -1
  183. mindspore/ops/function/math_func.py +33 -540
  184. mindspore/ops/function/nn_func.py +28 -74
  185. mindspore/ops/function/other_func.py +4 -1
  186. mindspore/ops/function/random_func.py +44 -5
  187. mindspore/ops/function/vmap_func.py +2 -1
  188. mindspore/ops/functional.py +2 -3
  189. mindspore/ops/functional_overload.py +571 -6
  190. mindspore/ops/op_info_register.py +21 -0
  191. mindspore/ops/operations/__init__.py +16 -11
  192. mindspore/ops/operations/_custom_ops_utils.py +689 -34
  193. mindspore/ops/operations/_inner_ops.py +3 -6
  194. mindspore/ops/operations/_sequence_ops.py +1 -1
  195. mindspore/ops/operations/array_ops.py +2 -2
  196. mindspore/ops/operations/comm_ops.py +185 -26
  197. mindspore/ops/operations/custom_ops.py +294 -174
  198. mindspore/ops/operations/debug_ops.py +59 -4
  199. mindspore/ops/operations/image_ops.py +13 -13
  200. mindspore/ops/operations/manually_defined/ops_def.py +15 -16
  201. mindspore/ops/operations/math_ops.py +3 -4
  202. mindspore/ops/operations/nn_ops.py +7 -39
  203. mindspore/ops/primitive.py +6 -10
  204. mindspore/ops/tensor_method.py +47 -8
  205. mindspore/ops_generate/api/cpp_create_prim_instance_helper_generator.py +1 -1
  206. mindspore/ops_generate/api/functional_map_cpp_generator.py +10 -9
  207. mindspore/ops_generate/api/functions_cc_generator.py +58 -10
  208. mindspore/ops_generate/api/tensor_func_reg_cpp_generator.py +1 -1
  209. mindspore/ops_generate/common/base_generator.py +14 -0
  210. mindspore/ops_generate/common/gen_constants.py +8 -3
  211. mindspore/ops_generate/common/gen_utils.py +0 -19
  212. mindspore/ops_generate/common/op_proto.py +11 -4
  213. mindspore/ops_generate/common/template.py +88 -11
  214. mindspore/ops_generate/gen_ops.py +1 -1
  215. mindspore/ops_generate/op_def/lite_ops_cpp_generator.py +4 -4
  216. mindspore/ops_generate/op_def/ops_def_cc_generator.py +0 -3
  217. mindspore/ops_generate/op_def/ops_name_h_generator.py +0 -3
  218. mindspore/ops_generate/op_def/ops_primitive_h_generator.py +0 -4
  219. mindspore/ops_generate/op_def_py/op_prim_py_generator.py +5 -2
  220. mindspore/ops_generate/pyboost/auto_grad_impl_cc_generator.py +49 -8
  221. mindspore/ops_generate/pyboost/auto_grad_reg_cc_generator.py +2 -2
  222. mindspore/ops_generate/pyboost/gen_pyboost_func.py +31 -0
  223. mindspore/ops_generate/pyboost/op_template_parser.py +98 -72
  224. mindspore/ops_generate/pyboost/pyboost_functions_cpp_generator.py +70 -273
  225. mindspore/ops_generate/pyboost/pyboost_functions_h_generator.py +14 -6
  226. mindspore/ops_generate/pyboost/pyboost_functions_impl_cpp_generator.py +316 -0
  227. mindspore/ops_generate/pyboost/pyboost_functions_py_generator.py +1 -1
  228. mindspore/ops_generate/pyboost/pyboost_grad_function_cpp_generator.py +5 -3
  229. mindspore/ops_generate/pyboost/pyboost_inner_prim_generator.py +1 -1
  230. mindspore/ops_generate/pyboost/pyboost_internal_functions_cpp_generator.py +76 -0
  231. mindspore/ops_generate/pyboost/pyboost_internal_functions_h_generator.py +76 -0
  232. mindspore/ops_generate/pyboost/pyboost_internal_kernel_info_adapter_generator.py +125 -0
  233. mindspore/ops_generate/pyboost/pyboost_native_grad_functions_generator.py +4 -3
  234. mindspore/ops_generate/pyboost/pyboost_op_cpp_code_generator.py +348 -61
  235. mindspore/ops_generate/pyboost/pyboost_overload_functions_cpp_generator.py +1 -1
  236. mindspore/ops_generate/pyboost/pyboost_utils.py +118 -9
  237. mindspore/ops_generate/tensor_py_cc_generator.py +1 -24
  238. mindspore/parallel/_auto_parallel_context.py +11 -8
  239. mindspore/parallel/_cell_wrapper.py +113 -45
  240. mindspore/parallel/_parallel_serialization.py +1 -1
  241. mindspore/parallel/_ps_context.py +4 -6
  242. mindspore/parallel/_tensor.py +167 -12
  243. mindspore/parallel/_transformer/moe.py +1 -1
  244. mindspore/parallel/_transformer/transformer.py +13 -8
  245. mindspore/parallel/auto_parallel.py +14 -7
  246. mindspore/parallel/checkpoint_convert.py +3 -3
  247. mindspore/parallel/checkpoint_transform.py +11 -7
  248. mindspore/parallel/cluster/process_entity/_api.py +84 -48
  249. mindspore/parallel/cluster/process_entity/_utils.py +95 -7
  250. mindspore/parallel/cluster/run.py +43 -4
  251. mindspore/parallel/function/__init__.py +8 -1
  252. mindspore/parallel/function/reshard_func.py +6 -7
  253. mindspore/parallel/nn/__init__.py +15 -2
  254. mindspore/parallel/nn/parallel_cell_wrapper.py +9 -10
  255. mindspore/parallel/nn/parallel_grad_reducer.py +7 -6
  256. mindspore/parallel/shard.py +3 -4
  257. mindspore/parallel/transform_safetensors.py +463 -174
  258. mindspore/profiler/__init__.py +2 -1
  259. mindspore/profiler/analysis/parser/timeline_assembly_factory/ascend_timeline_assembler.py +7 -7
  260. mindspore/profiler/analysis/parser/timeline_assembly_factory/base_timeline_assembler.py +3 -0
  261. mindspore/profiler/analysis/parser/timeline_assembly_factory/trace_view_container.py +12 -6
  262. mindspore/profiler/analysis/parser/timeline_creator/cpu_op_timeline_creator.py +3 -3
  263. mindspore/profiler/analysis/parser/timeline_creator/fwk_timeline_creator.py +3 -3
  264. mindspore/profiler/analysis/parser/timeline_creator/msprof_timeline_creator.py +4 -4
  265. mindspore/profiler/analysis/parser/timeline_creator/scope_layer_timeline_creator.py +3 -3
  266. mindspore/profiler/analysis/parser/timeline_event/fwk_event.py +4 -1
  267. mindspore/profiler/analysis/parser/timeline_event/timeline_event_pool.py +2 -1
  268. mindspore/profiler/analysis/task_manager.py +1 -1
  269. mindspore/profiler/analysis/viewer/ascend_communication_viewer.py +5 -1
  270. mindspore/profiler/analysis/viewer/ascend_integrate_viewer.py +2 -1
  271. mindspore/profiler/analysis/viewer/ascend_op_memory_viewer.py +42 -22
  272. mindspore/profiler/analysis/viewer/ascend_step_trace_time_viewer.py +3 -2
  273. mindspore/profiler/analysis/viewer/ms_minddata_viewer.py +9 -5
  274. mindspore/profiler/analysis/viewer/ms_operator_details_viewer.py +132 -0
  275. mindspore/profiler/common/constant.py +16 -0
  276. mindspore/profiler/common/profiler_context.py +25 -27
  277. mindspore/profiler/common/profiler_info.py +0 -16
  278. mindspore/profiler/common/profiler_op_analyse.py +235 -0
  279. mindspore/profiler/common/profiler_output_path.py +23 -8
  280. mindspore/profiler/common/profiler_parameters.py +128 -35
  281. mindspore/profiler/dynamic_profile/__init__.py +0 -0
  282. mindspore/profiler/dynamic_profile/dynamic_monitor_proxy.py +39 -0
  283. mindspore/profiler/dynamic_profile/dynamic_profiler_config_context.py +666 -0
  284. mindspore/profiler/dynamic_profile/dynamic_profiler_utils.py +62 -0
  285. mindspore/profiler/dynamic_profiler.py +305 -314
  286. mindspore/profiler/envprofiler.py +12 -7
  287. mindspore/profiler/experimental_config.py +96 -6
  288. mindspore/profiler/mstx.py +33 -12
  289. mindspore/profiler/platform/__init__.py +2 -3
  290. mindspore/profiler/platform/npu_profiler.py +29 -19
  291. mindspore/profiler/profiler.py +35 -19
  292. mindspore/profiler/profiler_action_controller.py +64 -76
  293. mindspore/profiler/schedule.py +10 -4
  294. mindspore/rewrite/common/config.py +1 -0
  295. mindspore/rewrite/common/namer.py +1 -0
  296. mindspore/rewrite/common/namespace.py +1 -0
  297. mindspore/rewrite/node/node.py +31 -11
  298. mindspore/rewrite/parsers/assign_parser.py +1 -1
  299. mindspore/rewrite/symbol_tree/symbol_tree.py +1 -1
  300. mindspore/run_check/_check_version.py +7 -10
  301. mindspore/runtime/__init__.py +5 -5
  302. mindspore/runtime/event.py +10 -4
  303. mindspore/runtime/executor.py +60 -45
  304. mindspore/runtime/memory.py +30 -32
  305. mindspore/runtime/thread_bind_core.py +298 -164
  306. mindspore/safeguard/rewrite_obfuscation.py +12 -13
  307. mindspore/swresample-4.dll +0 -0
  308. mindspore/swscale-6.dll +0 -0
  309. mindspore/tinyxml2.dll +0 -0
  310. mindspore/train/_utils.py +14 -4
  311. mindspore/train/amp.py +43 -20
  312. mindspore/train/callback/__init__.py +5 -5
  313. mindspore/train/callback/_checkpoint.py +3 -6
  314. mindspore/train/callback/_flops_collector.py +1 -1
  315. mindspore/train/callback/_landscape.py +0 -1
  316. mindspore/train/callback/_train_fault_tolerance.py +97 -16
  317. mindspore/train/data_sink.py +11 -2
  318. mindspore/train/dataset_helper.py +9 -0
  319. mindspore/train/model.py +135 -55
  320. mindspore/train/serialization.py +133 -111
  321. mindspore/train/summary/summary_record.py +13 -2
  322. mindspore/turbojpeg.dll +0 -0
  323. mindspore/utils/__init__.py +3 -2
  324. mindspore/utils/dryrun.py +0 -6
  325. mindspore/utils/runtime_execution_order_check.py +163 -77
  326. mindspore/utils/sdc_detect.py +68 -0
  327. mindspore/utils/utils.py +6 -9
  328. mindspore/version.py +1 -1
  329. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/METADATA +5 -4
  330. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/RECORD +333 -371
  331. mindspore/_deprecated/jit.py +0 -198
  332. mindspore/experimental/es/__init__.py +0 -22
  333. mindspore/experimental/es/embedding_service.py +0 -891
  334. mindspore/experimental/es/embedding_service_layer.py +0 -581
  335. mindspore/profiler/parser/__init__.py +0 -14
  336. mindspore/profiler/parser/aicpu_data_parser.py +0 -272
  337. mindspore/profiler/parser/ascend_analysis/__init__.py +0 -14
  338. mindspore/profiler/parser/ascend_analysis/constant.py +0 -71
  339. mindspore/profiler/parser/ascend_analysis/file_manager.py +0 -180
  340. mindspore/profiler/parser/ascend_analysis/function_event.py +0 -185
  341. mindspore/profiler/parser/ascend_analysis/fwk_cann_parser.py +0 -136
  342. mindspore/profiler/parser/ascend_analysis/fwk_file_parser.py +0 -131
  343. mindspore/profiler/parser/ascend_analysis/msprof_timeline_parser.py +0 -104
  344. mindspore/profiler/parser/ascend_analysis/path_manager.py +0 -313
  345. mindspore/profiler/parser/ascend_analysis/profiler_info_parser.py +0 -123
  346. mindspore/profiler/parser/ascend_analysis/tlv_decoder.py +0 -86
  347. mindspore/profiler/parser/ascend_analysis/trace_event_manager.py +0 -75
  348. mindspore/profiler/parser/ascend_cluster_generator.py +0 -116
  349. mindspore/profiler/parser/ascend_communicate_generator.py +0 -314
  350. mindspore/profiler/parser/ascend_flops_generator.py +0 -116
  351. mindspore/profiler/parser/ascend_fpbp_generator.py +0 -82
  352. mindspore/profiler/parser/ascend_hccl_generator.py +0 -271
  353. mindspore/profiler/parser/ascend_integrate_generator.py +0 -42
  354. mindspore/profiler/parser/ascend_memory_generator.py +0 -185
  355. mindspore/profiler/parser/ascend_msprof_exporter.py +0 -282
  356. mindspore/profiler/parser/ascend_msprof_generator.py +0 -187
  357. mindspore/profiler/parser/ascend_op_generator.py +0 -334
  358. mindspore/profiler/parser/ascend_steptrace_generator.py +0 -94
  359. mindspore/profiler/parser/ascend_timeline_generator.py +0 -545
  360. mindspore/profiler/parser/base_timeline_generator.py +0 -483
  361. mindspore/profiler/parser/container.py +0 -229
  362. mindspore/profiler/parser/cpu_gpu_timeline_generator.py +0 -697
  363. mindspore/profiler/parser/flops_parser.py +0 -531
  364. mindspore/profiler/parser/framework_enum.py +0 -111
  365. mindspore/profiler/parser/framework_parser.py +0 -464
  366. mindspore/profiler/parser/framework_struct.py +0 -61
  367. mindspore/profiler/parser/gpu_analysis/__init__.py +0 -14
  368. mindspore/profiler/parser/gpu_analysis/function_event.py +0 -44
  369. mindspore/profiler/parser/gpu_analysis/fwk_file_parser.py +0 -89
  370. mindspore/profiler/parser/gpu_analysis/profiler_info_parser.py +0 -72
  371. mindspore/profiler/parser/hccl_parser.py +0 -573
  372. mindspore/profiler/parser/hwts_log_parser.py +0 -122
  373. mindspore/profiler/parser/integrator.py +0 -526
  374. mindspore/profiler/parser/memory_usage_parser.py +0 -277
  375. mindspore/profiler/parser/minddata_analyzer.py +0 -800
  376. mindspore/profiler/parser/minddata_parser.py +0 -186
  377. mindspore/profiler/parser/minddata_pipeline_parser.py +0 -299
  378. mindspore/profiler/parser/op_intermediate_parser.py +0 -149
  379. mindspore/profiler/parser/optime_parser.py +0 -250
  380. mindspore/profiler/parser/profiler_info.py +0 -213
  381. mindspore/profiler/parser/step_trace_parser.py +0 -666
  382. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/WHEEL +0 -0
  383. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/entry_points.txt +0 -0
  384. {mindspore-2.6.0rc1.dist-info → mindspore-2.7.0rc1.dist-info}/top_level.txt +0 -0
@@ -1,531 +0,0 @@
1
- # Copyright 2021 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
- """Flops parser which parsing flops from aicore file."""
16
- import os
17
- import struct
18
- import json
19
- import stat
20
-
21
- from mindspore import log as logger
22
- from mindspore.profiler.common.exceptions.exceptions import ProfilerIOException, \
23
- ProfilerFileNotFoundException, ProfilerRawFileException, ProfilerPathErrorException
24
- from mindspore.profiler.common.validator.validate_path import \
25
- validate_and_normalize_path
26
-
27
-
28
- class FlopsParser:
29
- """
30
- The parser for parsing flops from aicore file.
31
-
32
- Args:
33
- input_dir (str): Directory(JOBXXX) where the original profiling data are located.
34
- output_dir (str): Directory(profiler-{timestamp}) where the parsed profiling files are located.
35
- op_task_dict (dict): The mapping relation of task_id and op_full_name.
36
- device_id (str): The device ID.
37
- """
38
- HEX = 16
39
- PMU_COUNT = 8
40
- AICORE_LOG_SIZE = 128 # the size of each struct is 128 Byte.
41
- RUNTIME_COMMON = "BBHHHII10Q8I"
42
-
43
- # If the task id is less than the task id threshold,
44
- # the combination of task id and Stream id represents one operator,
45
- # else the task id represents one operator.
46
- _task_id_threshold = 65536
47
-
48
- def __init__(self, input_dir, output_dir, op_task_dict, device_id, rank_id, is_training_mode_flag=True):
49
- self._input_dir = input_dir
50
- self._output_dir = output_dir
51
- self._op_task_dict = op_task_dict
52
- self._device_id = device_id
53
- self._rank_id = rank_id
54
- self.is_training_mode_flag = is_training_mode_flag
55
- # output files.
56
- self._flops_filename = f'flops_{self._rank_id}.txt'
57
- self._flops_summary_filename = f'flops_summary_{self._rank_id}.json'
58
- self._flops_scope_filename = f'flops_scope_{self._rank_id}.json'
59
- self._flops_utilization_step_filename = f'flops_utilization_step_{self._rank_id}.json'
60
- # input files.
61
- self._aicore_filename_pref = f'aicore.data.{self._device_id}.slice'
62
- self._optime_filename = f'output_op_compute_time_{self._rank_id}.txt'
63
- self._info_json = f'info.json.{self._device_id}'
64
- self._step_trace_filename = f'step_trace_raw_{self._rank_id}_detail_time.csv'
65
- self._timeline_data_filename = f'output_timeline_data_{self._rank_id}.txt'
66
- self._flops_summary = {
67
- 'FLOPs': 0,
68
- 'FLOPS': 0,
69
- 'FLOPS_Utilization': 0
70
- }
71
- self._flops_each_scope = {}
72
- self._flops_sankey_diagram = {}
73
- self._max_scope_num = 0
74
-
75
- @staticmethod
76
- def _read_line(start_dot, end_dot, op_avg_time_lines, op_all_step_time, op_all_step_comp):
77
- """Read the bp and fp time from line."""
78
- for op_avg_idx in op_avg_time_lines:
79
- line = op_avg_idx.split(',')
80
- fp = float(line[start_dot]) / 100000.0
81
- bp = float(line[end_dot]) / 100000.0
82
- op_all_step_time.append([fp, bp])
83
- op_all_step_comp.append([0.0, bp - fp])
84
- return op_all_step_time, op_all_step_comp
85
-
86
- @staticmethod
87
- def _add_step_flops_time(op_name, task_fops, op_idx, step_idx, op_start_time,
88
- op_all_step_time, op_all_step_comp):
89
- """Get the start time from the current task."""
90
- while((op_idx < len(op_start_time)) and (op_name != op_start_time[op_idx][0])):
91
- op_idx += 1
92
- if op_idx >= len(op_start_time):
93
- logger.debug(f"Op name {op_name} does not exist in timeline dict.")
94
- return op_idx, step_idx, op_all_step_comp
95
-
96
- # do not add the op FLOPS that not in fp_and_bp time.
97
- while((step_idx < len(op_all_step_time)) and
98
- (op_start_time[op_idx][1] >= op_all_step_time[step_idx][1])):
99
- step_idx += 1
100
- if step_idx >= len(op_all_step_time):
101
- logger.info(f"Op name {op_name} does not exist in timeline dict.")
102
-
103
- # add the op FLOPS that in fp_and_bp time.
104
- if ((step_idx < len(op_all_step_time)) and
105
- (op_start_time[op_idx][1] >= op_all_step_time[step_idx][0]) and
106
- (op_start_time[op_idx][1] <= op_all_step_time[step_idx][1])):
107
- op_all_step_comp[step_idx][0] += task_fops
108
- # next op.
109
- op_idx += 1
110
- return op_idx, step_idx, op_all_step_comp
111
-
112
- def execute(self):
113
- """Get the flops of aicore operators and write to file."""
114
- peak_flops = self._get_peak_flops()
115
-
116
- op_avg_time_dict = self._get_op_avg_time_dict()
117
- op_flops_list = []
118
- op_name_set = set()
119
- op_compute_dict = dict()
120
- # get all step time.
121
- op_all_step_time, op_all_step_comp = self._get_all_step_time()
122
- op_start_time = self._get_op_start_time()
123
- op_idx = 0
124
- step_idx = 0
125
- aicore_file_doc = os.path.join(self._input_dir, "data")
126
- source_files = self._get_aicore_files(aicore_file_doc)
127
- if not source_files:
128
- return
129
- # parse all sliced aicore files.
130
- for source_file in source_files:
131
- source_file = validate_and_normalize_path(source_file)
132
- read_count, all_log_struct = self._load_aicore_data(source_file)
133
-
134
- for idx in range(read_count):
135
- log_struct = all_log_struct[idx * self.AICORE_LOG_SIZE:
136
- (idx + 1) * self.AICORE_LOG_SIZE]
137
- result = [hex(i) for i in struct.unpack(self.RUNTIME_COMMON, log_struct)]
138
- op_name = self._get_op_name(result)
139
-
140
- if op_name == "":
141
- # filter out the blank line in the file.
142
- continue
143
- if op_name not in op_avg_time_dict:
144
- logger.info(f"Op name {op_name} does not exist in op average time dict.")
145
- continue
146
- # Convert the unit of task_fops to MFLOPs(1e6).
147
- if op_name in op_compute_dict:
148
- task_fops = op_compute_dict.get(op_name)
149
- else:
150
- task_fops = self._compute_task_flops(result) * 1e-6
151
- op_compute_dict[op_name] = task_fops
152
-
153
- # add the op FLOPS in current step.
154
- if len(op_start_time) >= 1 and len(op_all_step_time) >= 1:
155
- op_idx, step_idx, op_all_step_comp = self._add_step_flops_time(
156
- op_name, task_fops, op_idx, step_idx, op_start_time, op_all_step_time, op_all_step_comp)
157
-
158
- # calculate averge op FLOPS.
159
- if op_name in op_name_set:
160
- continue
161
- op_avg_time = op_avg_time_dict.get(op_name)
162
- # Time unit of op_avg_time is ms.
163
- # The unit of gflop_per_second is GFLOPS(1e9).
164
- if float(op_avg_time) == 0.0:
165
- raise ValueError("All operators take 0 ms.")
166
- if peak_flops == 0:
167
- raise ValueError("The frequency of an operator is 0.")
168
- gflop_per_second = task_fops / float(op_avg_time)
169
- flops_utilization = (gflop_per_second * 1e9 / peak_flops) * 100
170
- self._flops_summary['FLOPs'] += task_fops
171
- self._flops_summary['FLOPS'] += gflop_per_second
172
- op_flops = [op_name, str(task_fops), str(gflop_per_second), str(flops_utilization)]
173
- op_flops_list.append(op_flops)
174
- op_name_set.add(op_name)
175
- self._add_flops_to_each_scope(op_name, task_fops)
176
-
177
- if not op_name_set:
178
- raise ProfilerRawFileException("No aicore operator found.")
179
- self._flops_summary['FLOPS'] /= len(op_name_set)
180
-
181
- sum_flops_utilization = 0.0
182
- # calculate the every step FLOPS utilization and the average values.
183
- utilization_save_filename = os.path.join(self._output_dir, self._flops_utilization_step_filename)
184
- with os.fdopen(os.open(utilization_save_filename, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600), 'w') as f:
185
- f.write("steps, FLOPS_Utilization %\n")
186
- for i, x in enumerate(op_all_step_comp):
187
- current_utilization = x[0] / x[1] * 1e9 / peak_flops * 100
188
- sum_flops_utilization += current_utilization
189
- f.write(str(i + 1))
190
- f.write(",")
191
- f.write(str(current_utilization))
192
- f.write("\n")
193
- os.chmod(utilization_save_filename, stat.S_IREAD | stat.S_IWRITE)
194
-
195
- if len(op_all_step_comp) >= 1:
196
- self._flops_summary['FLOPS_Utilization'] = sum_flops_utilization / len(op_all_step_comp)
197
- else:
198
- logger.warning("The number of data calculation steps is 0, please check whether the "
199
- "output timeline data is none.")
200
- self._flops_summary['FLOPS_Utilization'] = 0.0
201
- self._format_scope_flops()
202
- self._write_file(op_flops_list)
203
-
204
- def _load_aicore_data(self, aicore_file_path):
205
- """Load the original binary aicore data."""
206
- logger.info("the aicore file path is %s", aicore_file_path)
207
-
208
- if not os.path.exists(aicore_file_path):
209
- logger.critical(f'The file {aicore_file_path} does not exist.')
210
- raise ProfilerFileNotFoundException('aicore.data')
211
-
212
- file_size = os.path.getsize(aicore_file_path)
213
- read_count = file_size // self.AICORE_LOG_SIZE
214
-
215
- if not read_count:
216
- logger.critical(f'the file {aicore_file_path} '
217
- f'does not have enough content to be parsed.')
218
- raise ProfilerRawFileException(
219
- 'aicore.data file does not have enough content to be parsed'
220
- )
221
- aicore_file_path = os.path.realpath(aicore_file_path)
222
- try:
223
- with open(aicore_file_path, "rb") as aicore_file:
224
- all_log_struct = aicore_file.read(self.AICORE_LOG_SIZE * read_count)
225
- except (IOError, OSError) as err:
226
- logger.critical(f'Error occurred when read {aicore_file_path} file: {err}')
227
- raise ProfilerIOException() from err
228
-
229
- return read_count, all_log_struct
230
-
231
- def _get_peak_flops(self):
232
- """Get the peak FLOPS of current ascend device."""
233
- info_json_file_path = os.path.join(
234
- self._input_dir,
235
- self._info_json
236
- )
237
-
238
- if not os.path.exists(info_json_file_path):
239
- logger.critical(f'The file {info_json_file_path} does not exist.')
240
- raise ProfilerFileNotFoundException(info_json_file_path)
241
-
242
- try:
243
- with open(info_json_file_path, 'r', encoding='utf-8') as info_file:
244
- device_info = json.load(info_file)['DeviceInfo'][0]
245
- device_frequency = float(device_info["aic_frequency"])
246
- ai_core_num = float(device_info["ai_core_num"])
247
- # peak_flops formula (provided by Hisi): device_frequency * num_of_aicore * 4096 * 2.
248
- peak_flops = device_frequency * 1e6 * ai_core_num * 4096 * 2
249
- except (IOError, OSError, json.JSONDecodeError) as err:
250
- logger.critical(f'Error occurred when read {info_json_file_path} file: {err}')
251
- raise ProfilerIOException() from err
252
-
253
- return peak_flops
254
-
255
- def _compute_task_flops(self, log_result):
256
- """Compute the FLOPs of each task."""
257
- pmu_cnt = list(
258
- int(i.replace('0x', ''), self.HEX)
259
- for i in log_result[9:17]
260
- )
261
- cube_fp16_exec = pmu_cnt[0]
262
- cube_int8_exec = pmu_cnt[1]
263
- vec_fp32 = pmu_cnt[2]
264
- vec_fp16_128lane_exec = pmu_cnt[3]
265
- vec_fp16_64lane_exec = pmu_cnt[4]
266
- vec_int32_exec = pmu_cnt[5]
267
- vec_misc_exec = pmu_cnt[6]
268
-
269
- # These formula is provided by HISI profiling.
270
- # a cube_fp16 instruction has (16**3)*2 float point operation.
271
- # a cube_fp16 instruction has 16*16*32*2 float point operation.
272
- cube_fops = cube_fp16_exec * (16 ** 3) * 2 + cube_int8_exec * 16 * 16 * 32 * 2
273
- vec_fops = vec_fp32 * 32 + vec_fp16_128lane_exec * 128 + \
274
- vec_fp16_64lane_exec * 64 + vec_int32_exec * 64 + vec_misc_exec * 32
275
- task_fops = cube_fops + vec_fops
276
-
277
- return task_fops
278
-
279
- def _get_op_name(self, log_result):
280
- """Get the operator name for current task_id."""
281
- task_id = int(log_result[4].replace('0x', ''), self.HEX)
282
- stream_id = int(log_result[17].replace('0x', ''), self.HEX)
283
- if task_id < self._task_id_threshold:
284
- task_id = '_'.join([str(stream_id), str(task_id)])
285
- if str(task_id) not in self._op_task_dict:
286
- return ""
287
- op_name = self._op_task_dict[str(task_id)]
288
-
289
- return op_name
290
-
291
- def _get_op_avg_time_dict(self):
292
- """Get the op average execution time."""
293
- op_avg_time_dict = {}
294
- optime_file_path = os.path.join(self._output_dir, self._optime_filename)
295
-
296
- if not os.path.exists(optime_file_path):
297
- logger.critical(f'The {optime_file_path} file does not exist.')
298
- raise ProfilerFileNotFoundException(optime_file_path)
299
- optime_file_path = os.path.realpath(optime_file_path)
300
- try:
301
- with open(optime_file_path, 'r') as f:
302
- lines = f.readlines()
303
- op_avg_time_lines = lines[3:] # the first three lines are table header.
304
- for line in op_avg_time_lines:
305
- op_name, avg_time = line.split()[:2]
306
- op_avg_time_dict[op_name] = avg_time
307
- except (IOError, OSError) as err:
308
- logger.critical(f'Error occurred when read {optime_file_path} file: {err}')
309
- raise ProfilerIOException() from err
310
-
311
- return op_avg_time_dict
312
-
313
- def _add_flops_to_each_scope(self, op_name, task_fops):
314
- """
315
- Add task_fops to each scope of the op_name.
316
-
317
- The top-level scope name is "Default" or "recompute_Default" or "Gradients".
318
- To classify the same scope name under different top-level scope, a suffix name is added.
319
- For op_name like "Default/network", the "network" will be renamed as "network(Default)".
320
- For op_name like "recompute_Default/network", "network" --> "network(recompute_Default)".
321
- For op_name like "Gradients/network", "network" --> "network(Gradients)".
322
- For op_name like "Gradients/recompute_Default/network", "network" --> "network(recompute_Gradients)".
323
- """
324
- # Only extracts the scope name, remove the operator name.
325
- scope_list = op_name.split('/')[:-1]
326
- self._max_scope_num = max(self._max_scope_num, len(scope_list))
327
- top_level_scope = scope_list[0]
328
- suffix_name = ""
329
- if op_name.startswith("Gradients/recompute_Default"):
330
- suffix_name = "recompute_Gradients"
331
- else:
332
- suffix_name = top_level_scope
333
- # To distinguish the same scope name at different scope level and different top level scope,
334
- # the scope level and top level scope is added.
335
- for level, scope_name in enumerate(scope_list):
336
- scope_list[level] = scope_name + f"({level}_{suffix_name})"
337
- scope_list[0] = top_level_scope
338
-
339
- # Add root node (refers to total flops).
340
- scope_list.insert(0, "Total")
341
- scope_depth = len(scope_list)
342
- for idx in range(scope_depth - 1):
343
- key_name = '{} {}'.format(scope_list[idx], scope_list[idx + 1])
344
- self._flops_each_scope.setdefault(key_name, 0)
345
- self._flops_each_scope[key_name] += task_fops
346
-
347
- def _format_scope_flops(self):
348
- """
349
- Format the flops of each scope to a Sankey Diagram.
350
-
351
- The format of Sankey Diagram is:
352
- {"nodes": [
353
- {"name": "Default"},
354
- {"name": "network"}
355
- ],
356
- "links": [
357
- {"source": "Total", "target": "Default", "value": 555},
358
- {"source": "Default", "target": "network", "value": 555}
359
- ]
360
- }
361
- """
362
- nodes, links = [], []
363
- scope_name_set = set()
364
- for scope_link, task_fops in self._flops_each_scope.items():
365
- source, target = scope_link.split()
366
- scope_name_set.update({source, target})
367
- link = {
368
- "source": source,
369
- "target": target,
370
- "value": round(task_fops, 3)
371
- }
372
- links.append(link)
373
-
374
- for scope_name in scope_name_set:
375
- node = {"name": scope_name}
376
- nodes.append(node)
377
-
378
- sankey_diagram = {"nodes": nodes, "links": links}
379
- self._flops_sankey_diagram = {
380
- "data": sankey_diagram,
381
- "max_scope_num": self._max_scope_num
382
- }
383
-
384
- def _write_file(self, op_flops_list):
385
- """Write the operator's flops related information into file."""
386
- join_file_path = lambda x: os.path.join(self._output_dir, x)
387
- output_file_path = join_file_path(self._flops_filename)
388
- output_summary_file_path = join_file_path(self._flops_summary_filename)
389
- output_flops_scope_file_path = join_file_path(self._flops_scope_filename)
390
-
391
- try:
392
- with os.fdopen(os.open(output_file_path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600), 'w') as f:
393
- header = "op_full_name, MFLOPs(10^6), GFLOPS(10^9), FLOPS utilization(%) \n"
394
- f.writelines(header)
395
- for op_flops in op_flops_list:
396
- line = ", ".join(op_flops)
397
- f.writelines(line + '\n')
398
- os.chmod(output_file_path, stat.S_IREAD | stat.S_IWRITE)
399
- except (IOError, OSError) as err:
400
- logger.critical(f'Error occurred when writing {output_file_path} file: {err}')
401
- raise ProfilerIOException() from err
402
-
403
- for key in self._flops_summary:
404
- self._flops_summary[key] = round(self._flops_summary[key], 3)
405
- try:
406
- with os.fdopen(os.open(output_summary_file_path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600),
407
- 'w') as json_file:
408
- json.dump(self._flops_summary, json_file)
409
- os.chmod(output_summary_file_path, stat.S_IREAD | stat.S_IWRITE)
410
- except (IOError, OSError) as err:
411
- logger.critical(f'Error occurred when write {output_summary_file_path} file: {err}')
412
- raise ProfilerIOException() from err
413
-
414
- try:
415
- with os.fdopen(os.open(output_flops_scope_file_path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600),
416
- 'w') as json_file:
417
- json.dump(self._flops_sankey_diagram, json_file)
418
- os.chmod(output_flops_scope_file_path, stat.S_IREAD | stat.S_IWRITE)
419
- except (IOError, OSError) as err:
420
- logger.critical(f'Error occurred when write {output_flops_scope_file_path} file: {err}')
421
- raise ProfilerIOException() from err
422
-
423
- def _get_aicore_files(self, profiler_dir):
424
- """Get aicore files."""
425
- aicore_files = self._search_file(profiler_dir)
426
- if not aicore_files:
427
- logger.warning("Aicore file does not exist.")
428
- return[]
429
-
430
- return aicore_files
431
-
432
- def _search_file(self, input_dir):
433
- """Search aicore file under specific input directory."""
434
- # validate input_dir
435
- if not os.path.isdir(input_dir):
436
- raise ProfilerPathErrorException(
437
- '{} does not exist or is not a dir'.format(input_dir)
438
- )
439
- # get aicore files
440
- files = os.listdir(input_dir)
441
- aicore_files = list(
442
- filter(
443
- lambda file: file.startswith(self._aicore_filename_pref) and not file.endswith('.done'),
444
- files
445
- )
446
- )
447
- # validate result
448
- if len(aicore_files) > 1:
449
- # the format of file name is like `aicore.data.$id.slice_$number`.
450
- # use the $number as the sorted key
451
- try:
452
- aicore_files.sort(key=lambda path: int(path.rsplit('_', 1)[-1]))
453
- except ValueError as err:
454
- logger.warning("Unable to parse file names: %s. %s", aicore_files, err)
455
- aicore_files = []
456
- else:
457
- aicore_files = list(
458
- filter(
459
- lambda file: file.startswith(self._aicore_filename_pref) and not file.endswith('.done'),
460
- files
461
- )
462
- )
463
- if len(aicore_files) >= 1:
464
- logger.warning("The aicore file structure is changed, please upgrade " \
465
- "mindspore and regenerate profiling data")
466
-
467
- file_paths = [os.path.join(input_dir, file) for file in aicore_files]
468
- logger.info("Find %d aicore files.", len(file_paths))
469
- return file_paths
470
-
471
- def _get_all_step_time(self):
472
- """Get the op average execution time."""
473
- op_all_step_time = []
474
- op_all_step_comp = []
475
- _step_trace_file_path = os.path.join(self._output_dir, self._step_trace_filename)
476
-
477
- if not os.path.exists(_step_trace_file_path):
478
- logger.warning(f'The {_step_trace_file_path} file does not exist.')
479
- return op_all_step_time, op_all_step_comp
480
- try:
481
- with open(_step_trace_file_path, 'r') as f:
482
- lines = f.readlines()
483
- op_all_step_time, op_all_step_comp = \
484
- self._get_bp_fp_time_by_line(lines, op_all_step_time, op_all_step_comp)
485
- except (IOError, OSError) as err:
486
- logger.critical(f'Error occurred when read {_step_trace_file_path} file: {err}')
487
- raise ProfilerIOException() from err
488
- logger.info("the train step is %d .", len(op_all_step_time))
489
- if not op_all_step_time:
490
- logger.warning(f'Empty when read {_step_trace_file_path} file, please check the valid'
491
- 'data of this file.')
492
- return op_all_step_time, op_all_step_comp
493
-
494
- def _get_bp_fp_time_by_line(self, lines, op_all_step_time, op_all_step_comp):
495
- """Get the bp and fp time with lines."""
496
- # the last line is the average info.
497
- op_avg_time_lines = lines[1:-1]
498
- # train mode.
499
- if self.is_training_mode_flag:
500
- op_all_step_time, op_all_step_comp = \
501
- self._read_line(4, 5, op_avg_time_lines, op_all_step_time, op_all_step_comp)
502
- else:
503
- # eval mode.
504
- op_all_step_time, op_all_step_comp = \
505
- self._read_line(4, 2, op_avg_time_lines, op_all_step_time, op_all_step_comp)
506
- return op_all_step_time, op_all_step_comp
507
-
508
- def _get_op_start_time(self):
509
- """Get the op average execution time."""
510
- op_start_time = []
511
- _timeline_file_path = os.path.join(self._output_dir, self._timeline_data_filename)
512
-
513
- if not os.path.exists(_timeline_file_path):
514
- logger.critical(f'The {_timeline_file_path} file does not exist.')
515
- raise ProfilerFileNotFoundException(_timeline_file_path)
516
- try:
517
- with open(_timeline_file_path, 'r') as f:
518
- lines = f.readlines()
519
- op_avg_time_lines = lines[1:]
520
- for op_avg_idx in op_avg_time_lines:
521
- line = op_avg_idx.split(',')
522
- op_name = line[0]
523
- op_start = float(line[2])
524
- op_start_time.append([op_name, op_start])
525
- except (IOError, OSError) as err:
526
- logger.critical(f'Error occurred when read {_timeline_file_path} file: {err}')
527
- raise ProfilerIOException() from err
528
- if not op_start_time:
529
- logger.warning(f'Empty when read {_timeline_file_path} file, please check the valid'
530
- 'data of this file.')
531
- return op_start_time
@@ -1,111 +0,0 @@
1
- # Copyright 2021-2022 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
- """Define framework enum data."""
16
-
17
- from enum import Enum, IntEnum
18
-
19
-
20
- class FileDataType(Enum):
21
- """Define framework file data type."""
22
- STEP_INFO = 'step_info'
23
- HASH_DIC = 'hash_dic'
24
- TENSOR_DATA_INFO = 'tensor_data_info'
25
- TASK_DESC_INFO = 'task_desc_info'
26
-
27
- @classmethod
28
- def members(cls):
29
- """Initializes a value of an object."""
30
- return {member.value for member in cls}
31
-
32
-
33
- class VmDataType(IntEnum):
34
- """Definition of vm data type."""
35
- NUMBER_TYPE_BEGIN = 29
36
- BOOL = 30
37
- INT = 31
38
- INT8 = 32
39
- INT16 = 33
40
- INT32 = 34
41
- INT64 = 35
42
- UINT = 36
43
- UINT8 = 37
44
- UINT16 = 38
45
- UINT32 = 39
46
- UINT64 = 40
47
- FLOAT = 41
48
- FLOAT16 = 42
49
- FLOAT32 = 43
50
- FLOAT64 = 44
51
- COMPLEX = 45
52
- NUMBER_TYPE_END = 46
53
-
54
- @classmethod
55
- def get_data_type_name(cls, num):
56
- """
57
- Get the name of data type by enum number.
58
-
59
- Args:
60
- num (int): Enum number.
61
-
62
- Returns:
63
- str, the name of data type.
64
- """
65
- data_type = cls._value2member_map_.get(num)
66
- return 'UNKNOWN' if data_type is None else data_type.name
67
-
68
-
69
- class VmFormat(IntEnum):
70
- """Define mindspore data type."""
71
- UNKNOWN = 0
72
- DEFAULT = 1
73
- NC1KHKWHWC0 = 2
74
- ND = 3
75
- NCHW = 4
76
- NHWC = 5
77
- HWCN = 6
78
- NC1HWC0 = 7
79
- FRAC_Z = 8
80
- C1HWNCOC0 = 9
81
- FRAC_NZ = 10
82
- NC1HWC0_C04 = 11
83
- FRACTAL_Z_C04 = 12
84
- NDHWC = 13
85
- FRACTAL_ZN_LSTM = 14
86
- FRACTAL_ZN_RNN = 15
87
- ND_RNN_BIAS = 16
88
- NDC1HWC0 = 17
89
- NCDHW = 18
90
- FRACTAL_Z_3D = 19
91
- DHWNC = 20
92
- DHWCN = 21
93
-
94
- @classmethod
95
- def get_format_name(cls, num):
96
- """
97
- Get the name of format by enum number.
98
-
99
- Args:
100
- num (int): Enum number.
101
-
102
- Returns:
103
- str, the name of data type.
104
- """
105
- format_name = cls._value2member_map_.get(num)
106
- return 'UNKNOWN' if format_name is None else format_name.name
107
-
108
-
109
- MSPROF_DIFFERENCE = 200
110
- MSPROF_MIX_DATA_HASH_ID = 0
111
- MSPROF_MIX_DATA_STRING = 1