Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
1650212a
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1650212a
编写于
11月 06, 2019
作者:
S
sangoly
提交者:
GitHub
11月 06, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[profile] fix profile count bug & exclude warmup profile monitor test=develop (#2374)
上级
c0e45193
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
42 addition
and
10 deletion
+42
-10
lite/api/model_test.cc
lite/api/model_test.cc
+7
-0
lite/core/kernel.h
lite/core/kernel.h
+3
-1
lite/core/profile/basic_profiler.cc
lite/core/profile/basic_profiler.cc
+11
-2
lite/core/profile/basic_profiler.h
lite/core/profile/basic_profiler.h
+21
-7
未找到文件。
lite/api/model_test.cc
浏览文件 @
1650212a
...
@@ -24,6 +24,9 @@
...
@@ -24,6 +24,9 @@
#include "lite/tests/utils/timer.h"
#include "lite/tests/utils/timer.h"
#include "lite/utils/cp_logging.h"
#include "lite/utils/cp_logging.h"
#include "lite/utils/string.h"
#include "lite/utils/string.h"
#ifdef LITE_WITH_PROFILE
#include "lite/core/profile/basic_profiler.h"
#endif // LITE_WITH_PROFILE
using
paddle
::
lite
::
Timer
;
using
paddle
::
lite
::
Timer
;
...
@@ -69,6 +72,10 @@ void Run(const std::vector<std::vector<int64_t>>& input_shapes,
...
@@ -69,6 +72,10 @@ void Run(const std::vector<std::vector<int64_t>>& input_shapes,
const
int
thread_num
,
const
int
thread_num
,
const
int
repeat
,
const
int
repeat
,
const
int
warmup_times
=
0
)
{
const
int
warmup_times
=
0
)
{
#ifdef LITE_WITH_PROFILE
lite
::
profile
::
BasicProfiler
<
lite
::
profile
::
BasicTimer
>::
Global
().
SetWarmup
(
warmup_times
);
#endif
lite_api
::
MobileConfig
config
;
lite_api
::
MobileConfig
config
;
config
.
set_model_dir
(
model_dir
);
config
.
set_model_dir
(
model_dir
);
config
.
set_power_mode
(
power_mode
);
config
.
set_power_mode
(
power_mode
);
...
...
lite/core/kernel.h
浏览文件 @
1650212a
...
@@ -84,9 +84,11 @@ class KernelBase {
...
@@ -84,9 +84,11 @@ class KernelBase {
#ifdef LITE_WITH_PROFILE
#ifdef LITE_WITH_PROFILE
if
(
profile_id_
>=
0
)
{
if
(
profile_id_
>=
0
)
{
profile
::
ProfileBlock
x
(
profile_id_
,
"kernel"
);
profile
::
ProfileBlock
x
(
profile_id_
,
"kernel"
);
Run
();
}
}
#e
ndif
#e
lse
Run
();
Run
();
#endif
}
}
void
SetContext
(
std
::
unique_ptr
<
KernelContext
>&&
ctx
)
{
void
SetContext
(
std
::
unique_ptr
<
KernelContext
>&&
ctx
)
{
...
...
lite/core/profile/basic_profiler.cc
浏览文件 @
1650212a
...
@@ -91,12 +91,21 @@ const TimerInfo& BasicTimer::GetTimerInfo(const std::string& key) const {
...
@@ -91,12 +91,21 @@ const TimerInfo& BasicTimer::GetTimerInfo(const std::string& key) const {
return
iter
->
second
;
return
iter
->
second
;
}
}
void
BasicTimer
::
Log
(
TimerInfo
*
timer_info
,
uint32_t
timespan
)
{
void
BasicTimer
::
SetWarmup
(
int
warmup_times
)
{
CHECK_GE
(
warmup_times
,
0
)
<<
"warmup times must >= 0"
;
warmup_
=
warmup_times
;
}
void
BasicTimer
::
Log
(
TimerInfo
*
timer_info
,
uint64_t
timespan
)
{
if
(
warmup_
>
0
)
{
--
warmup_
;
return
;
}
CHECK
(
timer_info
);
CHECK
(
timer_info
);
timer_info
->
count_
++
;
timer_info
->
total_
+=
timespan
;
timer_info
->
total_
+=
timespan
;
timer_info
->
max_
=
std
::
max
(
timer_info
->
max_
,
timespan
);
timer_info
->
max_
=
std
::
max
(
timer_info
->
max_
,
timespan
);
timer_info
->
min_
=
std
::
min
(
timer_info
->
min_
,
timespan
);
timer_info
->
min_
=
std
::
min
(
timer_info
->
min_
,
timespan
);
timer_info
->
count_
++
;
}
}
std
::
string
BasicTimer
::
basic_repr_header
()
{
std
::
string
BasicTimer
::
basic_repr_header
()
{
...
...
lite/core/profile/basic_profiler.h
浏览文件 @
1650212a
...
@@ -37,11 +37,11 @@ namespace lite {
...
@@ -37,11 +37,11 @@ namespace lite {
namespace
profile
{
namespace
profile
{
struct
TimerInfo
{
struct
TimerInfo
{
uint64_t
total_
{};
uint64_t
total_
{
0
};
uint64_t
count_
{};
uint64_t
count_
{
0
};
uint
32_t
max_
{
std
::
numeric_limits
<
uint32
_t
>::
min
()};
uint
64_t
max_
{
std
::
numeric_limits
<
uint64
_t
>::
min
()};
uint
32_t
min_
{
std
::
numeric_limits
<
uint32
_t
>::
max
()};
uint
64_t
min_
{
std
::
numeric_limits
<
uint64
_t
>::
max
()};
uint64_t
timer_
{};
uint64_t
timer_
{
0
};
double
ave
()
const
{
return
total_
*
1.
/
count_
;
}
double
ave
()
const
{
return
total_
*
1.
/
count_
;
}
double
max
()
const
{
return
max_
;
}
double
max
()
const
{
return
max_
;
}
...
@@ -56,7 +56,7 @@ class TimerBase {
...
@@ -56,7 +56,7 @@ class TimerBase {
public:
public:
void
Start
(
const
std
::
string
&
key
)
{
self
()
->
Start
(
key
);
}
void
Start
(
const
std
::
string
&
key
)
{
self
()
->
Start
(
key
);
}
void
Stop
(
const
std
::
string
&
key
)
{
self
()
->
Stop
(
key
);
}
void
Stop
(
const
std
::
string
&
key
)
{
self
()
->
Stop
(
key
);
}
void
Log
(
TimerInfo
*
timer_info
,
uint
32
_t
x
)
{
void
Log
(
TimerInfo
*
timer_info
,
uint
64
_t
x
)
{
return
self
()
->
Log
(
timer_info
,
x
);
return
self
()
->
Log
(
timer_info
,
x
);
}
}
std
::
string
basic_repr
()
const
{
return
const_self
()
->
basic_repr
();
}
std
::
string
basic_repr
()
const
{
return
const_self
()
->
basic_repr
();
}
...
@@ -75,6 +75,7 @@ class TimerBase {
...
@@ -75,6 +75,7 @@ class TimerBase {
class
BasicTimer
:
TimerBase
<
BasicTimer
>
{
class
BasicTimer
:
TimerBase
<
BasicTimer
>
{
int
id_
{
-
1
};
int
id_
{
-
1
};
int
warmup_
{
0
};
std
::
string
key_
;
std
::
string
key_
;
std
::
map
<
std
::
string
,
TimerInfo
>
timer_infos_
;
std
::
map
<
std
::
string
,
TimerInfo
>
timer_infos_
;
std
::
map
<
std
::
string
,
std
::
string
>
custom_infos_
;
std
::
map
<
std
::
string
,
std
::
string
>
custom_infos_
;
...
@@ -100,7 +101,7 @@ class BasicTimer : TimerBase<BasicTimer> {
...
@@ -100,7 +101,7 @@ class BasicTimer : TimerBase<BasicTimer> {
void
Start
(
const
std
::
string
&
timer_key
);
void
Start
(
const
std
::
string
&
timer_key
);
void
Stop
(
const
std
::
string
&
timer_key
);
void
Stop
(
const
std
::
string
&
timer_key
);
void
Log
(
TimerInfo
*
timer_info
,
uint
32
_t
timespan
);
void
Log
(
TimerInfo
*
timer_info
,
uint
64
_t
timespan
);
void
SetCustomInfo
(
const
std
::
string
&
key
,
const
std
::
string
&
value
);
void
SetCustomInfo
(
const
std
::
string
&
key
,
const
std
::
string
&
value
);
std
::
string
GetCustomInfo
(
const
std
::
string
&
key
)
const
;
std
::
string
GetCustomInfo
(
const
std
::
string
&
key
)
const
;
...
@@ -112,6 +113,8 @@ class BasicTimer : TimerBase<BasicTimer> {
...
@@ -112,6 +113,8 @@ class BasicTimer : TimerBase<BasicTimer> {
// BasicRecord(const BasicRecord &) = delete;
// BasicRecord(const BasicRecord &) = delete;
void
operator
=
(
const
BasicTimer
&
)
=
delete
;
void
operator
=
(
const
BasicTimer
&
)
=
delete
;
void
SetWarmup
(
int
warmup_times
);
};
};
/*
/*
...
@@ -132,6 +135,7 @@ class BasicProfiler {
...
@@ -132,6 +135,7 @@ class BasicProfiler {
records_
.
emplace_back
();
records_
.
emplace_back
();
records_
.
back
().
SetId
(
records_
.
size
()
-
1
);
records_
.
back
().
SetId
(
records_
.
size
()
-
1
);
records_
.
back
().
SetKey
(
key
);
records_
.
back
().
SetKey
(
key
);
records_
.
back
().
SetWarmup
(
warmup_
);
return
records_
.
back
();
return
records_
.
back
();
}
}
...
@@ -158,11 +162,21 @@ class BasicProfiler {
...
@@ -158,11 +162,21 @@ class BasicProfiler {
std
::
string
summary_repr_header
()
const
;
std
::
string
summary_repr_header
()
const
;
std
::
string
summary_repr
()
const
;
std
::
string
summary_repr
()
const
;
void
SetWarmup
(
int
warmup_times
)
{
CHECK_GE
(
warmup_times
,
0
)
<<
"warmup times must >= 0"
;
// Instruction and kernel share the common BasicTimer instance, so the
// warmup count
// will be decrease twice when instruction execute once
// TODO(sangoly): fix the ugly code.
warmup_
=
warmup_times
*
2
;
}
~
BasicProfiler
();
~
BasicProfiler
();
private:
private:
std
::
string
name_
;
std
::
string
name_
;
std
::
vector
<
record_t
>
records_
;
std
::
vector
<
record_t
>
records_
;
int
warmup_
{
0
};
};
};
struct
ProfileBlock
{
struct
ProfileBlock
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录