Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
1dcb9961
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1dcb9961
编写于
8月 26, 2019
作者:
J
Jiaying Zhao
提交者:
GitHub
8月 26, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Catch mobile exceptions test=develop (#1867)
* Catch mobile exceptions test=develop * code style format test=develop
上级
d85fcc1f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
54 addition
and
30 deletion
+54
-30
mobile/src/common/enforce.h
mobile/src/common/enforce.h
+0
-2
mobile/src/common/types.h
mobile/src/common/types.h
+2
-1
mobile/src/framework/executor.cpp
mobile/src/framework/executor.cpp
+39
-26
mobile/src/framework/executor.h
mobile/src/framework/executor.h
+2
-0
mobile/src/io/paddle_mobile.cpp
mobile/src/io/paddle_mobile.cpp
+10
-1
mobile/src/io/paddle_mobile.h
mobile/src/io/paddle_mobile.h
+1
-0
未找到文件。
mobile/src/common/enforce.h
浏览文件 @
1dcb9961
...
...
@@ -43,7 +43,6 @@ struct PaddleMobileException : public std::exception {
{ \
char buffer[1000]; \
snprintf(buffer, sizeof(buffer), __VA_ARGS__); \
std::string detail(buffer); \
throw paddle_mobile::PaddleMobileException("Custom Exception", buffer, \
__FILE__, __LINE__); \
} \
...
...
@@ -55,7 +54,6 @@ struct PaddleMobileException : public std::exception {
} else { \
char buffer[1000]; \
snprintf(buffer, sizeof(buffer), __VA_ARGS__); \
std::string detail(buffer); \
throw paddle_mobile::PaddleMobileException("paddle-mobile enforce", \
buffer, __FILE__, __LINE__); \
} \
...
...
mobile/src/common/types.h
浏览文件 @
1dcb9961
...
...
@@ -83,7 +83,8 @@ enum PMStatus {
PMOutOfAuthority
=
0x05
,
/*!< Try to modified data not your own*/
PMOutOfMem
=
0x06
,
/*!< OOM error*/
PMUnImplError
=
0x07
,
/*!< Unimplement error. */
PMWrongDevice
=
0x08
/*!< un-correct device. */
PMWrongDevice
=
0x08
,
/*!< un-correct device. */
PMException
=
0x09
/*!< throw exception. */
};
enum
RoundType
{
...
...
mobile/src/framework/executor.cpp
浏览文件 @
1dcb9961
...
...
@@ -480,44 +480,52 @@ const CLImage *Executor<Device, T>::GetOutputImage(
template
<
typename
Device
,
typename
T
>
PMStatus
Executor
<
Device
,
T
>::
Predict
()
{
try
{
#if _OPENMP
omp_set_num_threads
(
CPUContext
::
Context
()
->
get_thread_num
());
omp_set_num_threads
(
CPUContext
::
Context
()
->
get_thread_num
());
#endif
// clear all no persistable tensor array since write_to_array
// is always push back a new tensor in the array
ClearNoPersistableTensorArray
(
program_desc_
.
get
(),
program_
.
scope
.
get
());
// clear all no persistable tensor array since write_to_array
// is always push back a new tensor in the array
ClearNoPersistableTensorArray
(
program_desc_
.
get
(),
program_
.
scope
.
get
());
#ifdef PADDLE_MOBILE_PROFILE
std
::
vector
<
ProfInfo
>
profile
(
ops_of_block0_
.
size
());
struct
timespec
ts
;
int
op_index
=
0
;
std
::
vector
<
ProfInfo
>
profile
(
ops_of_block0_
.
size
());
struct
timespec
ts
;
int
op_index
=
0
;
#endif
for
(
int
i
=
0
;
i
<
ops_of_block0_
.
size
();
++
i
)
{
auto
&
op_handler
=
ops_of_block0_
[
i
];
for
(
int
i
=
0
;
i
<
ops_of_block0_
.
size
();
++
i
)
{
auto
&
op_handler
=
ops_of_block0_
[
i
];
#ifdef PADDLE_MOBILE_PROFILE
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
);
profile
[
op_index
].
runBegin
=
(
uint64_t
)
ts
.
tv_sec
*
1e9
+
ts
.
tv_nsec
;
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
);
profile
[
op_index
].
runBegin
=
(
uint64_t
)
ts
.
tv_sec
*
1e9
+
ts
.
tv_nsec
;
#endif
DLOG
<<
i
<<
"th, "
<<
"run op: "
<<
op_handler
->
Type
();
if
(
lod_mode_
&&
input_dim_has_changed_
)
{
op_handler
->
InferShape
();
}
op_handler
->
Run
();
DLOG
<<
i
<<
"th, "
<<
"run op: "
<<
op_handler
->
Type
();
if
(
lod_mode_
&&
input_dim_has_changed_
)
{
op_handler
->
InferShape
();
}
op_handler
->
Run
();
#ifdef PADDLE_MOBILE_PROFILE
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
);
profile
[
op_index
].
runEnd
=
(
uint64_t
)
ts
.
tv_sec
*
1e9
+
ts
.
tv_nsec
;
++
op_index
;
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
);
profile
[
op_index
].
runEnd
=
(
uint64_t
)
ts
.
tv_sec
*
1e9
+
ts
.
tv_nsec
;
++
op_index
;
#endif
}
if
(
feed_indices_
.
size
()
==
1
)
{
input_dim_has_changed_
=
false
;
}
}
if
(
feed_indices_
.
size
()
==
1
)
{
input_dim_has_changed_
=
false
;
}
#ifdef PADDLE_MOBILE_PROFILE
PrintProfile
(
profile
);
PrintProfile
(
profile
);
#endif
return
PMSuccess
;
return
PMSuccess
;
}
catch
(
PaddleMobileException
&
e
)
{
exception_msg_
=
e
.
what
();
return
PMException
;
}
catch
(
std
::
exception
&
e
)
{
exception_msg_
=
e
.
what
();
return
PMException
;
}
}
#ifdef PADDLE_MOBILE_PROFILE
...
...
@@ -588,6 +596,11 @@ void Executor<Device, T>::GetTensorResults(
}
}
template
<
typename
Device
,
typename
T
>
std
::
string
Executor
<
Device
,
T
>::
GetExceptionMsg
()
{
return
exception_msg_
;
}
#ifdef PADDLE_MOBILE_FPGA
template
<
typename
Device
,
typename
T
>
void
Executor
<
Device
,
T
>::
InjectVariable
(
const
Tensor
&
t
,
...
...
mobile/src/framework/executor.h
浏览文件 @
1dcb9961
...
...
@@ -60,6 +60,7 @@ class Executor {
void
FeedTensorData
(
const
std
::
vector
<
framework
::
Tensor
>
&
v
);
void
GetTensorResults
(
std
::
vector
<
framework
::
Tensor
*>
*
v
);
std
::
string
GetExceptionMsg
();
#ifdef PADDLE_MOBILE_FPGA
void
InjectVariable
(
const
Tensor
&
t
,
std
::
string
var_name
);
...
...
@@ -100,6 +101,7 @@ class Executor {
std
::
vector
<
std
::
shared_ptr
<
OperatorBase
<
Device
>>>
ops_of_block0_
;
std
::
unordered_map
<
std
::
string
,
int
>
feed_indices_
;
std
::
unordered_map
<
std
::
string
,
int
>
fetch_indices_
;
std
::
string
exception_msg_
;
// for super resoltion
DDim
input_dim_last_
;
...
...
mobile/src/io/paddle_mobile.cpp
浏览文件 @
1dcb9961
...
...
@@ -20,7 +20,7 @@ limitations under the License. */
#endif // _OPENMP
#ifdef PADDLE_MOBILE_CL
#include <CL/cl.h>
#include <mutex>
#include <mutex>
// NOLINT
#include "framework/cl/cl_engine.h"
#include "framework/cl/cl_tensor.h"
#endif
...
...
@@ -64,6 +64,7 @@ PMStatus PaddleMobile<Device, T>::Load(const std::string &model_path,
loader_
=
std
::
make_shared
<
framework
::
Loader
<
Device
,
T
>>
();
}
else
{
LOG
(
kLOG_INFO
)
<<
"loader inited"
;
LOG
(
kLOG_INFO
)
<<
"loader inited"
;
}
if
(
executor_
.
get
()
==
nullptr
)
{
...
...
@@ -187,6 +188,14 @@ void PaddleMobile<Device, T>::Clear() {
template
<
typename
Device
,
typename
T
>
double
PaddleMobile
<
Device
,
T
>::
GetPredictTime
()
{}
template
<
typename
Device
,
typename
T
>
std
::
string
PaddleMobile
<
Device
,
T
>::
GetExceptionMsg
()
{
if
(
executor_
.
get
()
!=
nullptr
)
{
return
executor_
->
GetExceptionMsg
();
}
return
""
;
}
#ifdef PADDLE_MOBILE_CPU
template
<
>
double
PaddleMobile
<
CPU
,
float
>::
GetPredictTime
()
{
...
...
mobile/src/io/paddle_mobile.h
浏览文件 @
1dcb9961
...
...
@@ -90,6 +90,7 @@ class PaddleMobile {
PowerMode
power_mode
=
PERFORMANCE_PRIORITY
);
void
Clear
();
double
GetPredictTime
();
std
::
string
GetExceptionMsg
();
#ifdef PADDLE_MOBILE_FPGA
void
InjectVariable
(
const
framework
::
Tensor
&
t
,
std
::
string
var_name
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录