Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
513641e1
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看板
未验证
提交
513641e1
编写于
3月 23, 2021
作者:
T
tianshuo78520a
提交者:
GitHub
3月 23, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Delete fast_check_nan_inf (#31788)
* Delete fast_check_nan_inf * Delete run_fast_nan_inf_debug
上级
9d04ef73
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
0 addition
and
108 deletion
+0
-108
paddle/fluid/framework/operator.cc
paddle/fluid/framework/operator.cc
+0
-22
python/paddle/fluid/__init__.py
python/paddle/fluid/__init__.py
+0
-1
python/paddle/fluid/debugger.py
python/paddle/fluid/debugger.py
+0
-85
未找到文件。
paddle/fluid/framework/operator.cc
浏览文件 @
513641e1
...
...
@@ -47,9 +47,6 @@ DECLARE_bool(benchmark);
DECLARE_bool
(
check_nan_inf
);
DECLARE_bool
(
enable_unused_var_check
);
DEFINE_int32
(
inner_op_parallelism
,
0
,
"number of threads for inner op"
);
DEFINE_bool
(
fast_check_nan_inf
,
false
,
"Fast checking NAN/INF after each operation. It will be a little"
"bit slow, much faster than check_nan_inf"
);
namespace
paddle
{
namespace
framework
{
...
...
@@ -1173,25 +1170,6 @@ void OperatorWithKernel::RunImpl(const Scope& scope,
#endif
}
if
(
FLAGS_fast_check_nan_inf
)
{
for
(
auto
&
vname
:
OutputVars
(
true
))
{
// only check inserted vars,
// please see executor.py for details of fast_check_nan_inf
if
(
vname
.
rfind
(
"debug_var"
)
==
0
)
{
VLOG
(
3
)
<<
"debugging nan/inf in var "
<<
vname
;
auto
*
var
=
exec_scope
.
FindVar
(
vname
);
if
(
var
==
nullptr
)
continue
;
if
(
var
->
IsType
<
framework
::
LoDTensor
>
())
{
CheckTensorNANOrInf
(
type_
,
vname
,
var
->
Get
<
framework
::
LoDTensor
>
());
}
else
if
(
var
->
IsType
<
framework
::
SelectedRows
>
())
{
CheckTensorNANOrInf
(
type_
,
vname
,
var
->
Get
<
framework
::
SelectedRows
>
().
value
());
}
}
}
}
if
(
FLAGS_check_nan_inf
)
{
framework
::
details
::
CheckOpHasNanOrInf
(
*
this
,
exec_scope
,
place
);
}
...
...
python/paddle/fluid/__init__.py
浏览文件 @
513641e1
...
...
@@ -175,7 +175,6 @@ def __bootstrap__():
sysstr
=
platform
.
system
()
read_env_flags
=
[
'check_nan_inf'
,
'fast_check_nan_inf'
,
'benchmark'
,
'eager_delete_scope'
,
'fraction_of_cpu_memory_to_use'
,
...
...
python/paddle/fluid/debugger.py
浏览文件 @
513641e1
...
...
@@ -280,88 +280,3 @@ def draw_block_graphviz(block, highlights=None, path="./temp.dot"):
add_op_link_var
(
opn
,
var
,
True
)
graph
(
path
,
show
=
False
)
def
prepare_fast_nan_inf_debug
(
_program
):
"""
Given a program to run, insert a (reduce) sum op for every var in that program.
Instead of checking all vars originally defined in the program,
only those inserted ops will be checked in the c++ end, to detect if it contains NAN or INF.
Thereforce, the speed of nan/inf checking could be improved.
Please set ``FLAGS_fast_check_nan_inf" to open the fast nan/inf feature.
"""
helper
=
LayerHelper
(
'reduce_sum'
,
**
locals
())
if
_program
is
None
:
_program
=
default_main_program
()
for
_block
in
_program
.
blocks
:
# fetch vars in the current block
_vars_in_prog
=
[]
for
_var_name
in
_block
.
vars
:
_vars_in_prog
.
append
((
_var_name
,
_block
.
vars
[
_var_name
]))
# append sum_op in the current block
for
_var_name
,
_var
in
_vars_in_prog
:
try
:
if
_var
.
dtype
==
-
1
:
continue
## create a var for holding sum output
_output_var
=
_block
.
create_var
(
name
=
unique_name
.
generate
(
"debug_var_"
+
_var_name
),
dtype
=
_var
.
dtype
,
type
=
core
.
VarDesc
.
VarType
.
LOD_TENSOR
,
persistable
=
False
,
stop_gradient
=
True
)
## create a sum op, input each existing var in the block
_block
.
append_op
(
type
=
'sum'
,
outputs
=
{
'Out'
:
_output_var
},
inputs
=
{
'X'
:
[
_var
]})
except
Exception
as
e
:
pass
def
run_fast_nan_inf_debug
(
executor
,
program
=
None
,
feed
=
None
,
fetch_list
=
None
,
feed_var_name
=
'feed'
,
fetch_var_name
=
'fetch'
,
scope
=
None
,
return_numpy
=
True
,
use_program_cache
=
False
,
dump_core
=
True
):
"""
Run a program by the given executor. Catch the exception of NAN and INF, and save persistables into the dumped core.
"""
assert
(
executor
is
not
None
)
try
:
output
=
executor
.
run
(
program
=
program
,
feed
=
feed
,
fetch_list
=
fetch_list
,
feed_var_name
=
feed_var_name
,
fetch_var_name
=
fetch_var_name
,
scope
=
scope
,
return_numpy
=
return_numpy
,
use_program_cache
=
use_program_cache
)
return
output
except
Exception
as
e
:
print
(
"catch an exception:"
)
print
(
e
)
core_filename
=
"core"
+
str
(
int
(
random
.
random
()
*
10000
))
+
".pdckpt"
io
.
save_persistables
(
executor
,
"./"
,
main_program
=
program
,
filename
=
core_filename
)
print
(
"dumping a core into ./%s"
%
core_filename
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录