Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
mindinsight
提交
8ae4b36f
M
mindinsight
项目概览
MindSpore
/
mindinsight
通知
8
Star
3
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindinsight
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8ae4b36f
编写于
5月 23, 2020
作者:
R
root
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix the data don't have the session issue
上级
a7c0e021
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
49 addition
and
41 deletion
+49
-41
mindinsight/profiler/parser/aicpu_data_parser.py
mindinsight/profiler/parser/aicpu_data_parser.py
+49
-41
未找到文件。
mindinsight/profiler/parser/aicpu_data_parser.py
浏览文件 @
8ae4b36f
...
...
@@ -13,12 +13,14 @@
# limitations under the License.
# ============================================================================
"""
P
arser for AI CPU preprocess data.
The p
arser for AI CPU preprocess data.
"""
from
mindinsight.profiler.common._utils
import
fwrite_format
,
get_file_join_name
from
tabulate
import
tabulate
from
mindinsight.profiler.common._utils
import
fwrite_format
,
get_file_join_name
from
mindinsight.profiler.common.log
import
logger
_source_file_target
=
'DATA_PREPROCESS.dev.AICPU'
_dst_file_title
=
'title:DATA_PREPROCESS AICPU'
_dst_file_column_title
=
[
'serial_number'
,
'node_name'
,
'total_time(us)'
,
'dispatch_time(us)'
,
...
...
@@ -41,48 +43,54 @@ class DataPreProcessParser:
self
.
_source_file_name
=
self
.
_get_source_file
()
def
_get_source_file
(
self
):
"""
get log file name, which was created by ada service
"""
"""
Get log file name, which was created by ada service.
"""
return
get_file_join_name
(
self
.
_input_path
,
_source_file_target
)
def
execute
(
self
):
"""execute the parser, get result data, and write it to the output file"""
ai_cpu_lines
=
list
()
"""Execute the parser, get result data, and write it to the output file."""
if
self
.
_source_file_name
is
None
:
logger
.
info
(
"Did not find the aicpu profiling source file"
)
return
with
open
(
self
.
_source_file_name
,
'rb'
)
as
ai_cpu_data
:
ai_cpu_str
=
str
(
ai_cpu_data
.
read
().
replace
(
b
'
\n\x00
'
,
b
' ___ '
)
.
replace
(
b
'
\x00
'
,
b
' ___ '
))[
2
:
-
1
]
ai_cpu_lines
=
ai_cpu_str
.
split
(
" ___ "
)
create_session_cnt
=
0
for
line
in
ai_cpu_lines
:
if
"Create session start"
in
line
:
create_session_cnt
+=
1
start_idx
=
create_session_cnt
*
2
ai_cpu_lines
=
ai_cpu_lines
[
start_idx
:
-
3
]
node_list
=
list
()
ai_cpu_total_time_summary
=
0
if
start_idx
>
0
:
# node serial number
serial_number
=
1
for
line
in
ai_cpu_lines
:
if
"Node"
in
line
:
node_name
=
line
.
split
(
','
)[
0
].
split
(
':'
)[
-
1
]
run_v2_start
=
line
.
split
(
','
)[
1
].
split
(
':'
)[
-
1
]
compute_start
=
line
.
split
(
','
)[
2
].
split
(
':'
)[
-
1
]
mercy_start
=
line
.
split
(
','
)[
3
].
split
(
':'
)[
-
1
]
mercy_end
=
line
.
split
(
','
)[
4
].
split
(
':'
)[
-
1
]
run_v2_end
=
line
.
split
(
','
)[
5
].
split
(
':'
)[
-
1
]
node_data
=
[
serial_number
,
node_name
,
run_v2_start
,
compute_start
,
for
i
in
range
(
len
(
ai_cpu_lines
)
-
1
):
node_line
=
ai_cpu_lines
[
i
]
thread_line
=
ai_cpu_lines
[
i
+
1
]
if
"Node"
in
node_line
and
"Thread"
in
thread_line
:
# get the node data from node_line
node_name
=
node_line
.
split
(
','
)[
0
].
split
(
':'
)[
-
1
]
run_v2_start
=
node_line
.
split
(
','
)[
1
].
split
(
':'
)[
-
1
]
compute_start
=
node_line
.
split
(
','
)[
2
].
split
(
':'
)[
-
1
]
mercy_start
=
node_line
.
split
(
','
)[
3
].
split
(
':'
)[
-
1
]
mercy_end
=
node_line
.
split
(
','
)[
4
].
split
(
':'
)[
-
1
]
run_v2_end
=
node_line
.
split
(
','
)[
5
].
split
(
':'
)[
-
1
]
# get total_time and dispatch_time from thread line
total_time
=
thread_line
.
split
(
','
)[
-
1
].
split
(
'='
)[
-
1
].
split
()[
0
]
dispatch_time
=
thread_line
.
split
(
','
)[
-
2
].
split
(
'='
)[
-
1
].
split
()[
0
]
node_data
=
[
serial_number
,
node_name
,
total_time
,
dispatch_time
,
run_v2_start
,
compute_start
,
mercy_start
,
mercy_end
,
run_v2_end
]
node_list
.
append
(
node_data
)
serial_number
+=
1
elif
"Thread"
in
line
:
# total_time and dispatch_time joins node list
total_time
=
line
.
split
(
','
)[
-
1
].
split
(
'='
)[
-
1
].
split
()[
0
]
dispatch_time
=
line
.
split
(
','
)[
-
2
].
split
(
'='
)[
-
1
].
split
()[
0
]
if
node_list
:
node_list
[
-
1
][
2
:
2
]
=
[
total_time
,
dispatch_time
]
# calculate the total time
ai_cpu_total_time_summary
+=
int
(
total_time
)
node_list
.
append
([
"AI CPU Total Time:"
,
ai_cpu_total_time_summary
])
# increase node serial number
serial_number
+=
1
elif
"Node"
in
node_line
and
"Thread"
not
in
thread_line
:
node_name
=
node_line
.
split
(
','
)[
0
].
split
(
':'
)[
-
1
]
logger
.
warning
(
"The node:%s cannot find thread data"
,
node_name
)
node_list
.
append
([
"AI CPU Total Time(us):"
,
ai_cpu_total_time_summary
])
if
node_list
:
fwrite_format
(
self
.
_output_filename
,
data_source
=
_dst_file_title
,
is_print
=
True
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录