Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
9b54bf93
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
9b54bf93
编写于
4月 19, 2022
作者:
C
chenjian
提交者:
GitHub
4月 19, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rebase for profiler statistic ratio (#41939)
* fix according to suggestion * add kernel summary * improve coverage
上级
2b55290e
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
273 addition
and
45 deletion
+273
-45
python/paddle/fluid/tests/unittests/test_profiler_statistic.py
...n/paddle/fluid/tests/unittests/test_profiler_statistic.py
+92
-10
python/paddle/profiler/profiler_statistic.py
python/paddle/profiler/profiler_statistic.py
+181
-35
未找到文件。
python/paddle/fluid/tests/unittests/test_profiler_statistic.py
浏览文件 @
9b54bf93
...
...
@@ -51,8 +51,9 @@ class TestProfilerStatistic(unittest.TestCase):
profilerstep_node
=
HostPythonNode
(
'ProfileStep#1'
,
profiler
.
TracerEventType
.
ProfileStep
,
0
,
400
,
1000
,
1001
)
dataloader_node
=
HostPythonNode
(
'Dataloader'
,
profiler
.
TracerEventType
.
Forward
,
5
,
15
,
1000
,
1001
)
dataloader_node
=
HostPythonNode
(
'Dataloader'
,
profiler
.
TracerEventType
.
Dataloader
,
5
,
15
,
1000
,
1001
)
mobilenet_node
=
HostPythonNode
(
'MobileNet'
,
profiler
.
TracerEventType
.
Forward
,
20
,
50
,
1000
,
1001
)
yolonet_node
=
HostPythonNode
(
...
...
@@ -155,7 +156,7 @@ class TestProfilerStatistic(unittest.TestCase):
profiler
.
TracerEventType
.
ProfileStep
),
400
)
self
.
assertEqual
(
time_range_summary
.
get_cpu_range_sum
(
profiler
.
TracerEventType
.
Forward
),
10
0
)
profiler
.
TracerEventType
.
Forward
),
9
0
)
self
.
assertEqual
(
time_range_summary
.
get_cpu_range_sum
(
profiler
.
TracerEventType
.
Backward
),
80
)
...
...
@@ -185,12 +186,12 @@ class TestProfilerStatistic(unittest.TestCase):
profiler
.
TracerEventType
.
Communication
),
5
)
self
.
assertEqual
(
len
(
event_summary
.
items
),
2
)
self
.
assertEqual
(
len
(
event_summary
.
userdefined_items
),
1
)
self
.
assertEqual
(
len
(
event_summary
.
model_perspective_items
),
4
)
self
.
assertEqual
(
len
(
event_summary
.
model_perspective_items
),
5
)
self
.
assertEqual
(
len
(
event_summary
.
memory_manipulation_items
),
1
)
self
.
assertEqual
(
event_summary
.
items
[
'conv2d'
].
cpu_time
,
15
)
self
.
assertEqual
(
event_summary
.
items
[
'conv2d'
].
general_gpu_time
,
25
)
self
.
assertEqual
(
event_summary
.
model_perspective_items
[
'Forward'
].
cpu_time
,
10
0
)
event_summary
.
model_perspective_items
[
'Forward'
].
cpu_time
,
9
0
)
self
.
assertEqual
(
event_summary
.
model_perspective_items
[
'Forward'
].
general_gpu_time
,
135
)
...
...
@@ -217,8 +218,9 @@ class TestProfilerStatistic(unittest.TestCase):
profiler
.
TracerEventType
.
ProfileStep
,
0
,
400
,
1000
,
1001
)
dataloader_node
=
HostPythonNode
(
'Dataloader'
,
profiler
.
TracerEventType
.
Forward
,
5
,
15
,
1000
,
1001
)
dataloader_node
=
HostPythonNode
(
'Dataloader'
,
profiler
.
TracerEventType
.
Dataloader
,
5
,
15
,
1000
,
1001
)
mobilenet_node
=
HostPythonNode
(
'MobileNet'
,
profiler
.
TracerEventType
.
Forward
,
20
,
50
,
1000
,
1001
)
...
...
@@ -372,7 +374,7 @@ class TestProfilerStatistic(unittest.TestCase):
profiler
.
TracerEventType
.
ProfileStep
),
400
)
self
.
assertEqual
(
time_range_summary
.
get_cpu_range_sum
(
profiler
.
TracerEventType
.
Forward
),
10
0
)
profiler
.
TracerEventType
.
Forward
),
9
0
)
self
.
assertEqual
(
time_range_summary
.
get_cpu_range_sum
(
profiler
.
TracerEventType
.
Backward
),
80
)
...
...
@@ -417,12 +419,12 @@ class TestProfilerStatistic(unittest.TestCase):
distributed_summary
.
overlap_range
),
85
)
self
.
assertEqual
(
len
(
event_summary
.
items
),
4
)
self
.
assertEqual
(
len
(
event_summary
.
userdefined_items
),
1
)
self
.
assertEqual
(
len
(
event_summary
.
model_perspective_items
),
4
)
self
.
assertEqual
(
len
(
event_summary
.
model_perspective_items
),
5
)
self
.
assertEqual
(
len
(
event_summary
.
memory_manipulation_items
),
1
)
self
.
assertEqual
(
event_summary
.
items
[
'conv2d'
].
cpu_time
,
15
)
self
.
assertEqual
(
event_summary
.
items
[
'conv2d'
].
general_gpu_time
,
25
)
self
.
assertEqual
(
event_summary
.
model_perspective_items
[
'Forward'
].
cpu_time
,
10
0
)
event_summary
.
model_perspective_items
[
'Forward'
].
cpu_time
,
9
0
)
self
.
assertEqual
(
event_summary
.
model_perspective_items
[
'Forward'
].
general_gpu_time
,
315
)
...
...
@@ -441,6 +443,86 @@ class TestProfilerStatistic(unittest.TestCase):
thread_sep
=
False
,
time_unit
=
'ms'
))
def
test_statistic_case3
(
self
):
# for coverage, test all time is 0
root_node
=
HostPythonNode
(
'Root Node'
,
profiler
.
TracerEventType
.
UserDefined
,
0
,
float
(
'inf'
),
1000
,
1001
)
profilerstep_node
=
HostPythonNode
(
'ProfileStep#1'
,
profiler
.
TracerEventType
.
ProfileStep
,
0
,
400
,
1000
,
1001
)
dataloader_node
=
HostPythonNode
(
'Dataloader'
,
profiler
.
TracerEventType
.
Dataloader
,
5
,
15
,
1000
,
1001
)
mobilenet_node
=
HostPythonNode
(
'MobileNet'
,
profiler
.
TracerEventType
.
Forward
,
20
,
50
,
1000
,
1001
)
backward_node
=
HostPythonNode
(
'Gradient Backward'
,
profiler
.
TracerEventType
.
Backward
,
120
,
200
,
1000
,
1001
)
optimization_node
=
HostPythonNode
(
'Optimization'
,
profiler
.
TracerEventType
.
Optimization
,
220
,
300
,
1000
,
1001
)
userdefined_node
=
HostPythonNode
(
'Communication Time'
,
profiler
.
TracerEventType
.
UserDefined
,
60
,
70
,
1000
,
1001
)
conv2d_node
=
HostPythonNode
(
'conv2d'
,
profiler
.
TracerEventType
.
Operator
,
25
,
25
,
1000
,
1001
)
conv2d_infer_shape
=
HostPythonNode
(
'conv2d::infer_shape'
,
profiler
.
TracerEventType
.
OperatorInner
,
25
,
25
,
1000
,
1001
)
conv2d_compute
=
HostPythonNode
(
'conv2d::compute'
,
profiler
.
TracerEventType
.
OperatorInner
,
25
,
25
,
1000
,
1001
)
conv2d_launchkernel
=
HostPythonNode
(
'cudalaunchkernel'
,
profiler
.
TracerEventType
.
CudaRuntime
,
25
,
25
,
1000
,
1001
)
conv2d_kernel
=
DevicePythonNode
(
'conv2d_kernel'
,
profiler
.
TracerEventType
.
Kernel
,
35
,
35
,
0
,
0
,
0
)
another_kernel
=
DevicePythonNode
(
'void phi::funcs::VectorizedBroadcastKernel<float, float, phi::funcs::AddFunctor<float>, phi::funcs::AddFunctor<float>>()'
,
profiler
.
TracerEventType
.
Kernel
,
35
,
35
,
0
,
0
,
0
)
root_node
.
children_node
.
append
(
profilerstep_node
)
profilerstep_node
.
children_node
.
extend
([
dataloader_node
,
mobilenet_node
,
userdefined_node
,
backward_node
,
optimization_node
])
mobilenet_node
.
children_node
.
append
(
conv2d_node
)
conv2d_node
.
children_node
.
extend
([
conv2d_infer_shape
,
conv2d_compute
])
conv2d_compute
.
runtime_node
.
append
(
conv2d_launchkernel
)
conv2d_launchkernel
.
device_node
.
append
(
conv2d_kernel
)
conv2d_launchkernel
.
device_node
.
append
(
another_kernel
)
thread_tree
=
{
'thread1001'
:
root_node
}
extra_info
=
{
'Process Cpu Utilization'
:
'1.02'
,
'System Cpu Utilization'
:
'0.68'
}
statistic_data
=
profiler
.
profiler_statistic
.
StatisticData
(
thread_tree
,
extra_info
)
time_range_summary
=
statistic_data
.
time_range_summary
event_summary
=
statistic_data
.
event_summary
self
.
assertEqual
(
event_summary
.
items
[
'conv2d'
].
cpu_time
,
0
)
self
.
assertEqual
(
event_summary
.
items
[
'conv2d'
].
general_gpu_time
,
0
)
self
.
assertEqual
(
event_summary
.
userdefined_items
[
'Communication Time'
]
.
general_gpu_time
,
0
)
for
sort_key
in
[
profiler
.
SortedKeys
.
CPUTotal
,
profiler
.
SortedKeys
.
CPUMax
,
profiler
.
SortedKeys
.
CPUMin
,
profiler
.
SortedKeys
.
CPUAvg
,
profiler
.
SortedKeys
.
GPUTotal
,
profiler
.
SortedKeys
.
GPUMax
,
profiler
.
SortedKeys
.
GPUMin
,
profiler
.
SortedKeys
.
GPUAvg
]:
print
(
profiler
.
profiler_statistic
.
_build_table
(
statistic_data
,
sorted_by
=
sort_key
,
op_detail
=
True
,
thread_sep
=
False
,
time_unit
=
'ms'
))
if
__name__
==
'__main__'
:
unittest
.
main
()
python/paddle/profiler/profiler_statistic.py
浏览文件 @
9b54bf93
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录