Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
c1235c93
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c1235c93
编写于
1月 09, 2019
作者:
P
peizhilin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add the enable_debug flag
test=develop
上级
c783dd03
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
41 addition
and
11 deletion
+41
-11
paddle/fluid/framework/operator.cc
paddle/fluid/framework/operator.cc
+16
-6
paddle/fluid/framework/operator.h
paddle/fluid/framework/operator.h
+2
-2
paddle/fluid/platform/debug_support.cc
paddle/fluid/platform/debug_support.cc
+9
-0
paddle/fluid/platform/enforce.h
paddle/fluid/platform/enforce.h
+5
-0
python/paddle/fluid/framework.py
python/paddle/fluid/framework.py
+9
-3
未找到文件。
paddle/fluid/framework/operator.cc
浏览文件 @
c1235c93
...
@@ -32,6 +32,12 @@ DEFINE_bool(check_nan_inf, false,
...
@@ -32,6 +32,12 @@ DEFINE_bool(check_nan_inf, false,
"Checking whether operator produce NAN/INF or not. It will be "
"Checking whether operator produce NAN/INF or not. It will be "
"extremely slow so please use this flag wisely."
);
"extremely slow so please use this flag wisely."
);
DEFINE_bool
(
enable_debug
,
false
,
"The enable_debug indicate whether to give more detail information when, "
"use the paddlepaddle. However it may deduce the performance since it has"
"to record the information during runtime."
);
namespace
paddle
{
namespace
paddle
{
namespace
framework
{
namespace
framework
{
...
@@ -157,7 +163,7 @@ RuntimeContext::RuntimeContext(const VariableNameMap& innames,
...
@@ -157,7 +163,7 @@ RuntimeContext::RuntimeContext(const VariableNameMap& innames,
}
}
}
}
void
OperatorBase
::
PreHook
()
{
void
OperatorBase
::
PreHook
(
const
Scope
&
scope
,
const
platform
::
Place
&
place
)
{
auto
attrName
=
OpProtoAndCheckerMaker
::
OpCreationCallstackAttrName
();
auto
attrName
=
OpProtoAndCheckerMaker
::
OpCreationCallstackAttrName
();
if
(
HasAttr
(
attrName
))
{
if
(
HasAttr
(
attrName
))
{
auto
&
callstack
=
Attr
<
std
::
vector
<
std
::
string
>>
(
attrName
);
auto
&
callstack
=
Attr
<
std
::
vector
<
std
::
string
>>
(
attrName
);
...
@@ -166,8 +172,10 @@ void OperatorBase::PreHook() {
...
@@ -166,8 +172,10 @@ void OperatorBase::PreHook() {
}
}
void
OperatorBase
::
Run
(
const
Scope
&
scope
,
const
platform
::
Place
&
place
)
{
void
OperatorBase
::
Run
(
const
Scope
&
scope
,
const
platform
::
Place
&
place
)
{
if
(
FLAGS_enable_debug
)
{
VLOG
(
4
)
<<
"Call the prehook ... "
;
VLOG
(
4
)
<<
"Call the prehook ... "
;
PreHook
();
PreHook
(
scope
,
place
);
}
VLOG
(
4
)
<<
place
<<
" "
<<
DebugStringEx
(
&
scope
);
VLOG
(
4
)
<<
place
<<
" "
<<
DebugStringEx
(
&
scope
);
if
(
platform
::
is_gpu_place
(
place
))
{
if
(
platform
::
is_gpu_place
(
place
))
{
...
@@ -191,11 +199,13 @@ void OperatorBase::Run(const Scope& scope, const platform::Place& place) {
...
@@ -191,11 +199,13 @@ void OperatorBase::Run(const Scope& scope, const platform::Place& place) {
}
}
VLOG
(
3
)
<<
place
<<
" "
<<
DebugStringEx
(
&
scope
);
VLOG
(
3
)
<<
place
<<
" "
<<
DebugStringEx
(
&
scope
);
if
(
FLAGS_enable_debug
)
{
VLOG
(
4
)
<<
"Call the posthook ... "
;
VLOG
(
4
)
<<
"Call the posthook ... "
;
PostHook
();
PostHook
(
scope
,
place
);
}
}
}
void
OperatorBase
::
PostHook
()
{
void
OperatorBase
::
PostHook
(
const
Scope
&
scope
,
const
platform
::
Place
&
place
)
{
// do nothing here
// do nothing here
}
}
...
...
paddle/fluid/framework/operator.h
浏览文件 @
c1235c93
...
@@ -161,8 +161,8 @@ class OperatorBase {
...
@@ -161,8 +161,8 @@ class OperatorBase {
const
RuntimeContext
&
ctx
)
const
{}
const
RuntimeContext
&
ctx
)
const
{}
// Add the hooks
// Add the hooks
virtual
void
PreHook
();
virtual
void
PreHook
(
const
Scope
&
scope
,
const
platform
::
Place
&
place
);
virtual
void
PostHook
();
virtual
void
PostHook
(
const
Scope
&
scope
,
const
platform
::
Place
&
place
);
protected:
protected:
std
::
string
type_
;
std
::
string
type_
;
...
...
paddle/fluid/platform/debug_support.cc
浏览文件 @
c1235c93
...
@@ -27,6 +27,15 @@ std::string PythonDebugSupport::Format() const {
...
@@ -27,6 +27,15 @@ std::string PythonDebugSupport::Format() const {
for
(
auto
&
line
:
info
)
{
for
(
auto
&
line
:
info
)
{
sout
<<
line
;
sout
<<
line
;
}
}
}
else
{
#ifdef _WIN32
sout
<<
"please set FLAGS_enable_debug=True to get more details regard to "
"this failure.
\n
"
;
#else // _WIN32
sout
<<
"please export FLAGS_enable_debug=True to get more details regard "
"to "
"this failure.
\n
"
;
#endif // _WIN32
}
}
return
sout
.
str
();
return
sout
.
str
();
}
}
...
...
paddle/fluid/platform/enforce.h
浏览文件 @
c1235c93
...
@@ -265,6 +265,10 @@ inline void throw_on_error(T e) {
...
@@ -265,6 +265,10 @@ inline void throw_on_error(T e) {
#define __THROW_ON_ERROR_ONE_ARG(COND, ARG) \
#define __THROW_ON_ERROR_ONE_ARG(COND, ARG) \
::paddle::platform::throw_on_error(COND, ::paddle::string::Sprintf(ARG));
::paddle::platform::throw_on_error(COND, ::paddle::string::Sprintf(ARG));
#ifdef _WIN32
#define __PADDLE_THROW_ON_ERROR(COND, ...) \
__THROW_ON_ERROR_ONE_ARG(COND, __VA_ARGS__)
#else // _WIN32
#define __PADDLE_THROW_ON_ERROR(COND, ...) \
#define __PADDLE_THROW_ON_ERROR(COND, ...) \
__PADDLE_THROW_ERROR_I( \
__PADDLE_THROW_ERROR_I( \
__VA_ARGS__, ::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
__VA_ARGS__, ::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
...
@@ -276,6 +280,7 @@ inline void throw_on_error(T e) {
...
@@ -276,6 +280,7 @@ inline void throw_on_error(T e) {
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
__THROW_ON_ERROR_ONE_ARG(COND, __VA_ARGS__))
__THROW_ON_ERROR_ONE_ARG(COND, __VA_ARGS__))
#endif // _WIN32
#define __PADDLE_UNARY_COMPARE(COND, ...) \
#define __PADDLE_UNARY_COMPARE(COND, ...) \
do { \
do { \
...
...
python/paddle/fluid/framework.py
浏览文件 @
c1235c93
...
@@ -627,9 +627,15 @@ class Operator(object):
...
@@ -627,9 +627,15 @@ class Operator(object):
if
role_var_name
in
op_attrs
and
len
(
op_attrs
[
role_var_name
])
==
0
:
if
role_var_name
in
op_attrs
and
len
(
op_attrs
[
role_var_name
])
==
0
:
del
op_attrs
[
role_var_name
]
del
op_attrs
[
role_var_name
]
if
'FLAGS_enable_debug'
in
os
.
environ
and
os
.
environ
[
'FLAGS_enable_debug'
]:
callstack_var_name
=
op_maker
.
kOpCreationCallstackAttrName
()
callstack_var_name
=
op_maker
.
kOpCreationCallstackAttrName
()
op_attrs
[
callstack_var_name
]
=
list
(
op_attrs
[
callstack_var_name
]
=
list
(
reversed
(
traceback
.
format_stack
()))[
1
:]
reversed
(
traceback
.
format_stack
()))[
1
:]
op_attrs
[
callstack_var_name
].
insert
(
0
,
'Invoke operator '
+
(
''
if
type
is
None
else
type
)
+
' error.
\n
'
)
if
len
(
self
.
desc
.
type
())
!=
0
:
if
len
(
self
.
desc
.
type
())
!=
0
:
return
return
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录