Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
mindinsight
提交
61185d99
M
mindinsight
项目概览
MindSpore
/
mindinsight
通知
7
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看板
提交
61185d99
编写于
9月 08, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
9月 08, 2020
浏览文件
操作
浏览文件
下载
差异文件
!595 Optimize aicpu display method
Merge pull request !595 from 张毅辉/zyh_aicpu
上级
a171ba42
54682901
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
97 addition
and
8 deletion
+97
-8
mindinsight/profiler/analyser/analyser.py
mindinsight/profiler/analyser/analyser.py
+88
-1
mindinsight/profiler/common/validator/validate.py
mindinsight/profiler/common/validator/validate.py
+9
-7
未找到文件。
mindinsight/profiler/analyser/analyser.py
浏览文件 @
61185d99
...
@@ -19,6 +19,7 @@ import os
...
@@ -19,6 +19,7 @@ import os
from
mindinsight.profiler.analyser.base_analyser
import
BaseAnalyser
from
mindinsight.profiler.analyser.base_analyser
import
BaseAnalyser
from
mindinsight.profiler.common.log
import
logger
from
mindinsight.profiler.common.log
import
logger
from
mindinsight.profiler.common.validator.validate_path
import
validate_and_normalize_path
class
AicoreTypeAnalyser
(
BaseAnalyser
):
class
AicoreTypeAnalyser
(
BaseAnalyser
):
...
@@ -42,6 +43,11 @@ class AicoreTypeAnalyser(BaseAnalyser):
...
@@ -42,6 +43,11 @@ class AicoreTypeAnalyser(BaseAnalyser):
self
.
_profiling_dir
,
self
.
_profiling_dir
,
self
.
_file_name_aicore_type_time
.
format
(
self
.
_device_id
)
self
.
_file_name_aicore_type_time
.
format
(
self
.
_device_id
)
)
)
op_type_file_path
=
validate_and_normalize_path
(
op_type_file_path
,
raise_key
=
'Invalid aicore_type file path.'
)
if
not
os
.
path
.
isfile
(
op_type_file_path
):
if
not
os
.
path
.
isfile
(
op_type_file_path
):
logger
.
warning
(
'The file <%s> does not exist.'
,
op_type_file_path
)
logger
.
warning
(
'The file <%s> does not exist.'
,
op_type_file_path
)
return
return
...
@@ -161,6 +167,13 @@ class AicoreDetailAnalyser(BaseAnalyser):
...
@@ -161,6 +167,13 @@ class AicoreDetailAnalyser(BaseAnalyser):
self
.
_profiling_dir
,
self
.
_profiling_dir
,
self
.
_file_name_framework_info
.
format
(
self
.
_device_id
)
self
.
_file_name_framework_info
.
format
(
self
.
_device_id
)
)
)
op_detail_file_path
=
validate_and_normalize_path
(
op_detail_file_path
,
raise_key
=
'Invalid aicore_detail file path.'
)
framework_file_path
=
validate_and_normalize_path
(
framework_file_path
,
raise_key
=
'Invalid framework file path.'
)
if
not
os
.
path
.
isfile
(
op_detail_file_path
):
if
not
os
.
path
.
isfile
(
op_detail_file_path
):
logger
.
warning
(
'The file <%s> does not exist.'
,
op_detail_file_path
)
logger
.
warning
(
'The file <%s> does not exist.'
,
op_detail_file_path
)
return
return
...
@@ -261,7 +274,78 @@ class AicoreDetailAnalyser(BaseAnalyser):
...
@@ -261,7 +274,78 @@ class AicoreDetailAnalyser(BaseAnalyser):
framework_info
[
3
],
framework_info
[
0
],
framework_info
[
4
]]
framework_info
[
3
],
framework_info
[
0
],
framework_info
[
4
]]
class
AicpuAnalyser
(
BaseAnalyser
):
class
AicpuTypeAnalyser
(
BaseAnalyser
):
"""
The analyser for analyzing all the AICPU operators.
Args:
profiling_dir (str): The directory where the parsed profiling files are
located.
device_id (str): The device ID.
Raises:
ProfilerPathErrorException: If the profiling dir is invalid.
"""
_col_names
=
[
'op_type'
,
'execution_time'
,
'execution_frequency'
,
'percent'
]
_file_name_aicpu_time
=
'aicpu_intermediate_{}.csv'
def
_load
(
self
):
"""Load data according to the parsed AICPU operator file."""
aicpu_file_path
=
os
.
path
.
join
(
self
.
_profiling_dir
,
self
.
_file_name_aicpu_time
.
format
(
self
.
_device_id
)
)
aicpu_file_path
=
validate_and_normalize_path
(
aicpu_file_path
,
raise_key
=
'Invalid aicpu file path.'
)
if
not
os
.
path
.
isfile
(
aicpu_file_path
):
logger
.
warning
(
'The file <%s> does not exist.'
,
aicpu_file_path
)
return
type_detail_cache
=
dict
()
with
open
(
aicpu_file_path
,
'r'
)
as
file
:
csv_reader
=
csv
.
reader
(
file
)
_
=
next
(
csv_reader
)
for
item
in
csv_reader
:
op_type
=
item
[
1
]
info
=
type_detail_cache
.
get
(
op_type
)
if
info
:
info
.
append
(
item
)
else
:
type_detail_cache
[
op_type
]
=
[
item
]
type_temp_detail_cache
=
dict
()
total_avg_time
=
0
result
=
[]
for
key
,
value
in
type_detail_cache
.
items
():
exec_frequency
=
len
(
value
)
total_time_index
=
2
exec_avg_time
=
sum
([
float
(
i
[
total_time_index
])
for
i
in
value
])
/
exec_frequency
exec_avg_time
=
round
(
exec_avg_time
,
6
)
total_avg_time
+=
exec_avg_time
type_temp_detail_cache
[
key
]
=
[
key
,
exec_avg_time
,
exec_frequency
]
for
key
,
value
in
type_temp_detail_cache
.
items
():
execution_time_index
=
1
percent
=
round
((
value
[
execution_time_index
]
/
total_avg_time
)
*
100
,
2
)
value
.
append
(
percent
)
result
.
append
(
value
)
self
.
_data
=
result
def
_filter
(
self
,
filter_condition
):
"""
Filter the profiling data according to the filter condition.
Args:
filter_condition (dict): The filter condition.
"""
def
_inner_filter
(
item
:
list
):
return
self
.
_default_filter
(
item
,
filter_condition
)
self
.
_result
=
list
(
filter
(
_inner_filter
,
self
.
_data
))
class
AicpuDetailAnalyser
(
BaseAnalyser
):
"""
"""
The analyser for analyzing all the AICPU operators.
The analyser for analyzing all the AICPU operators.
...
@@ -283,6 +367,9 @@ class AicpuAnalyser(BaseAnalyser):
...
@@ -283,6 +367,9 @@ class AicpuAnalyser(BaseAnalyser):
self
.
_profiling_dir
,
self
.
_profiling_dir
,
self
.
_file_name_aicpu_time
.
format
(
self
.
_device_id
)
self
.
_file_name_aicpu_time
.
format
(
self
.
_device_id
)
)
)
aicpu_file_path
=
validate_and_normalize_path
(
aicpu_file_path
,
raise_key
=
'Invalid aicpu file path.'
)
if
not
os
.
path
.
isfile
(
aicpu_file_path
):
if
not
os
.
path
.
isfile
(
aicpu_file_path
):
logger
.
warning
(
'The file <%s> does not exist.'
,
aicpu_file_path
)
logger
.
warning
(
'The file <%s> does not exist.'
,
aicpu_file_path
)
return
return
...
...
mindinsight/profiler/common/validator/validate.py
浏览文件 @
61185d99
...
@@ -23,10 +23,10 @@ from mindinsight.profiler.common.exceptions.exceptions import ProfilerParamTypeE
...
@@ -23,10 +23,10 @@ from mindinsight.profiler.common.exceptions.exceptions import ProfilerParamTypeE
ProfilerGroupConditionException
,
ProfilerParamValueErrorException
ProfilerGroupConditionException
,
ProfilerParamValueErrorException
from
mindinsight.profiler.common.log
import
logger
as
log
from
mindinsight.profiler.common.log
import
logger
as
log
AICORE_TYPE_COL
=
[
"op_type"
,
"execution_time"
,
"execution_frequency"
,
"p
re
cent"
]
AICORE_TYPE_COL
=
[
"op_type"
,
"execution_time"
,
"execution_frequency"
,
"p
er
cent"
]
AICORE_DETAIL_COL
=
[
"op_name"
,
"op_type"
,
"avg_execution_time"
,
"subgraph"
,
"full_op_name"
]
AICORE_DETAIL_COL
=
[
"op_name"
,
"op_type"
,
"avg_execution_time"
,
"subgraph"
,
"full_op_name"
]
AICPU_
COL
=
[
"serial_number"
,
"op_type"
,
"total_time"
,
"dispatch_time"
,
"run_start"
,
AICPU_
TYPE_COL
=
[
"op_type"
,
"execution_time"
,
"execution_frequency"
,
"percent"
]
"run_end"
]
AICPU_DETAIL_COL
=
[
"serial_number"
,
"op_type"
,
"total_time"
,
"dispatch_time"
,
"run_start"
,
"run_end"
]
GPU_TYPE_COL
=
[
"op_type"
,
"type_occurrences"
,
"total_time"
,
"proportion"
,
"avg_time"
]
GPU_TYPE_COL
=
[
"op_type"
,
"type_occurrences"
,
"total_time"
,
"proportion"
,
"avg_time"
]
GPU_ACTIVITY_COL
=
[
"name"
,
"type"
,
"op_full_name"
,
"stream_id"
,
GPU_ACTIVITY_COL
=
[
"name"
,
"type"
,
"op_full_name"
,
"stream_id"
,
"block_dim"
,
"grid_dim"
,
"occurrences"
,
"total_duration"
,
"block_dim"
,
"grid_dim"
,
"occurrences"
,
"total_duration"
,
...
@@ -68,8 +68,10 @@ def validate_condition(search_condition):
...
@@ -68,8 +68,10 @@ def validate_condition(search_condition):
if
"op_type"
in
search_condition
:
if
"op_type"
in
search_condition
:
op_type
=
search_condition
.
get
(
"op_type"
)
op_type
=
search_condition
.
get
(
"op_type"
)
if
op_type
==
"aicpu"
:
if
op_type
==
"aicpu_type"
:
search_scope
=
AICPU_COL
search_scope
=
AICPU_TYPE_COL
elif
op_type
==
"aicpu_detail"
:
search_scope
=
AICPU_DETAIL_COL
elif
op_type
==
"aicore_type"
:
elif
op_type
==
"aicore_type"
:
search_scope
=
AICORE_TYPE_COL
search_scope
=
AICORE_TYPE_COL
elif
op_type
==
"aicore_detail"
:
elif
op_type
==
"aicore_detail"
:
...
@@ -82,11 +84,11 @@ def validate_condition(search_condition):
...
@@ -82,11 +84,11 @@ def validate_condition(search_condition):
search_scope
=
GPU_ACTIVITY_COL
search_scope
=
GPU_ACTIVITY_COL
else
:
else
:
raise
ProfilerOpTypeException
(
raise
ProfilerOpTypeException
(
"The op_type must in ['aicpu', 'aicore_type', 'aicore_detail', "
"The op_type must in ['aicpu
_type','aicpu_detail
', 'aicore_type', 'aicore_detail', "
"'gpu_op_type', 'gpu_op_info', 'gpu_cuda_activity']"
)
"'gpu_op_type', 'gpu_op_info', 'gpu_cuda_activity']"
)
else
:
else
:
raise
ProfilerOpTypeException
(
raise
ProfilerOpTypeException
(
"The op_type must in ['aicpu', 'aicore_type', 'aicore_detail', "
"The op_type must in ['aicpu
_type','aicpu_detail
', 'aicore_type', 'aicore_detail', "
"'gpu_op_type', 'gpu_op_info', 'gpu_cuda_activity']"
)
"'gpu_op_type', 'gpu_op_info', 'gpu_cuda_activity']"
)
if
"group_condition"
in
search_condition
:
if
"group_condition"
in
search_condition
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录