Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
c1b6692f
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c1b6692f
编写于
4月 08, 2018
作者:
G
gongweibao
提交者:
GitHub
4月 08, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix debuger bugs. (#9705)
Fix debuger bugs
上级
be853853
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
13 addition
and
15 deletion
+13
-15
python/paddle/fluid/debuger.py
python/paddle/fluid/debuger.py
+8
-7
python/paddle/fluid/graphviz.py
python/paddle/fluid/graphviz.py
+2
-7
python/paddle/fluid/tests/unittests/test_debugger.py
python/paddle/fluid/tests/unittests/test_debugger.py
+3
-1
未找到文件。
python/paddle/fluid/debuger.py
浏览文件 @
c1b6692f
...
...
@@ -16,6 +16,7 @@ import sys
import
re
from
graphviz
import
GraphPreviewGenerator
import
proto.framework_pb2
as
framework_pb2
from
google.protobuf
import
text_format
_vartype2str_
=
[
"UNK"
,
...
...
@@ -100,7 +101,7 @@ def repr_var(vardesc):
def
pprint_program_codes
(
program_desc
):
reprs
=
[]
for
block_idx
in
range
(
program_desc
.
num_blocks
()):
for
block_idx
in
range
(
program_desc
.
desc
.
num_blocks
()):
block_desc
=
program_desc
.
block
(
block_idx
)
block_repr
=
pprint_block_codes
(
block_desc
)
reprs
.
append
(
block_repr
)
...
...
@@ -127,7 +128,7 @@ def pprint_block_codes(block_desc, show_backward=False):
if
type
(
block_desc
)
is
not
framework_pb2
.
BlockDesc
:
block_desc
=
framework_pb2
.
BlockDesc
.
FromString
(
block_desc
.
serialize_to_string
())
block_desc
.
desc
.
serialize_to_string
())
var_reprs
=
[]
op_reprs
=
[]
for
var
in
block_desc
.
vars
:
...
...
@@ -237,13 +238,13 @@ def draw_block_graphviz(block, highlights=None, path="./temp.dot"):
# draw parameters and args
vars
=
{}
for
var
in
desc
.
vars
:
shape
=
[
str
(
i
)
for
i
in
var
.
lod_tensor
.
tensor
.
dims
]
if
not
shape
:
shape
=
[
'null'
]
# TODO(gongwb): format the var.type
# create var
if
var
.
persistable
:
varn
=
graph
.
add_param
(
var
.
name
,
var
.
type
,
shape
,
highlight
=
need_highlight
(
var
.
name
))
var
.
name
,
str
(
var
.
type
).
replace
(
"
\n
"
,
"<br />"
,
1
),
highlight
=
need_highlight
(
var
.
name
))
else
:
varn
=
graph
.
add_arg
(
var
.
name
,
highlight
=
need_highlight
(
var
.
name
))
vars
[
var
.
name
]
=
varn
...
...
@@ -268,4 +269,4 @@ def draw_block_graphviz(block, highlights=None, path="./temp.dot"):
for
var
in
op
.
outputs
:
add_op_link_var
(
opn
,
var
,
True
)
graph
(
path
,
show
=
Tru
e
)
graph
(
path
,
show
=
Fals
e
)
python/paddle/fluid/graphviz.py
浏览文件 @
c1b6692f
...
...
@@ -83,7 +83,7 @@ class Graph(object):
file
=
open
(
dot_path
,
'w'
)
file
.
write
(
self
.
__str__
())
image_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
dot_path
[:
-
3
]
+
"pdf"
)
os
.
path
.
dirname
(
dot_path
),
dot_path
[:
-
3
]
+
"pdf"
)
cmd
=
[
"dot"
,
"-Tpdf"
,
dot_path
,
"-o"
,
image_path
]
subprocess
.
Popen
(
cmd
,
...
...
@@ -199,7 +199,7 @@ class GraphPreviewGenerator(object):
else
:
self
.
graph
.
show
(
path
)
def
add_param
(
self
,
name
,
data_type
,
shape
,
highlight
=
False
):
def
add_param
(
self
,
name
,
data_type
,
highlight
=
False
):
label
=
'
\n
'
.
join
([
'<<table cellpadding="5">'
,
' <tr>'
,
...
...
@@ -214,11 +214,6 @@ class GraphPreviewGenerator(object):
str
(
data_type
),
' </td>'
' </tr>'
,
' <tr>'
,
' <td>'
,
'[%s]'
%
'x'
.
join
(
shape
),
' </td>'
' </tr>'
,
'</table>>'
,
])
return
self
.
graph
.
node
(
...
...
python/paddle/fluid/tests/unittests/test_debugger.py
浏览文件 @
c1b6692f
...
...
@@ -51,7 +51,9 @@ class TestDebugger(unittest.TestCase):
outputs
=
{
"Out"
:
mul_out
},
attrs
=
{
"x_num_col_dims"
:
1
})
print
(
debuger
.
pprint_program_codes
(
p
.
desc
))
print
(
debuger
.
pprint_program_codes
(
p
))
debuger
.
draw_block_graphviz
(
p
.
block
(
0
),
path
=
"./test.dot"
)
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录