Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
cbfd15f9
P
Paddle
项目概览
机器未来
/
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看板
未验证
提交
cbfd15f9
编写于
3月 13, 2018
作者:
G
gongweibao
提交者:
GitHub
3月 13, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix debugger bugs. (#9025)
上级
e13aec60
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
74 addition
and
8 deletion
+74
-8
python/paddle/fluid/debuger.py
python/paddle/fluid/debuger.py
+16
-8
python/paddle/fluid/tests/unittests/test_debugger.py
python/paddle/fluid/tests/unittests/test_debugger.py
+58
-0
未找到文件。
python/paddle/fluid/debuger.py
浏览文件 @
cbfd15f9
...
...
@@ -16,6 +16,7 @@ import sys
import
re
from
graphviz
import
GraphPreviewGenerator
import
proto.framework_pb2
as
framework_pb2
import
paddle.fluid.core
as
core
_vartype2str_
=
[
"UNK"
,
...
...
@@ -52,9 +53,11 @@ reprtpl = "{ttype} {name} ({reprs})"
def
repr_lodtensor
(
proto
):
if
not
proto
.
lod_tensor
:
return
level
=
proto
.
lod_tensor
.
lod_level
reprs
=
repr_tensor
(
proto
.
lod_tensor
.
tensor
)
if
proto
.
type
.
type
!=
framework_pb2
.
VarType
.
LOD_TENSOR
:
return
level
=
proto
.
type
.
lod_tensor
.
lod_level
reprs
=
repr_tensor
(
proto
.
type
.
lod_tensor
.
tensor
)
return
reprtpl
.
format
(
ttype
=
"LoDTensor"
if
level
>
0
else
"Tensor"
,
name
=
proto
.
name
,
...
...
@@ -62,20 +65,24 @@ def repr_lodtensor(proto):
def
repr_selected_rows
(
proto
):
if
not
proto
.
selected_rows
:
return
if
proto
.
type
.
type
!=
framework_pb2
.
VarType
.
SELECTED_ROWS
:
return
return
reprtpl
.
format
(
ttype
=
"SelectedRows"
,
name
=
proto
.
name
,
reprs
=
repr_tensor
(
proto
.
selected_rows
))
reprs
=
repr_tensor
(
proto
.
type
.
selected_rows
))
def
repr_tensor_array
(
proto
):
if
not
proto
.
tensor_array
:
return
if
proto
.
type
.
type
!=
framework_pb2
.
VarType
.
LOD_TENSOR_ARRAY
:
return
return
reprtpl
.
format
(
ttype
=
"TensorArray"
,
name
=
proto
.
name
,
reprs
=
"level=%d, %s"
%
(
proto
.
tensor_array
.
lod_level
,
repr_tensor
(
proto
.
lod_
tensor
)))
reprs
=
"level=%d, %s"
%
(
proto
.
t
ype
.
t
ensor_array
.
lod_level
,
repr_tensor
(
proto
.
type
.
lod_tensor
.
tensor
)))
type_handlers
=
[
...
...
@@ -119,6 +126,7 @@ def pprint_block_codes(block_desc, show_backward=False):
def
is_var_backward
(
var_desc
):
return
"@GRAD"
in
var_desc
.
name
#print(type(block_desc))
if
type
(
block_desc
)
is
not
framework_pb2
.
BlockDesc
:
block_desc
=
framework_pb2
.
BlockDesc
.
FromString
(
block_desc
.
serialize_to_string
())
...
...
python/paddle/fluid/tests/unittests/test_debugger.py
0 → 100644
浏览文件 @
cbfd15f9
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
unittest
import
paddle.fluid
as
fluid
import
paddle.fluid.core
as
core
from
paddle.fluid
import
debuger
from
paddle.fluid.framework
import
Program
class
TestDebugger
(
unittest
.
TestCase
):
def
test_debug_str
(
self
):
p
=
Program
()
b
=
p
.
current_block
()
#selected_rows
b
.
create_var
(
name
=
'selected_rows'
,
dtype
=
"float32"
,
shape
=
[
5
,
10
],
type
=
core
.
VarDesc
.
VarType
.
SELECTED_ROWS
)
#tensor array
b
.
create_var
(
name
=
'tensor_array'
,
shape
=
[
5
,
10
],
type
=
core
.
VarDesc
.
VarType
.
LOD_TENSOR_ARRAY
)
#operator
mul_x
=
b
.
create_parameter
(
dtype
=
"float32"
,
shape
=
[
5
,
10
],
lod_level
=
0
,
name
=
"mul.x"
)
mul_y
=
b
.
create_var
(
dtype
=
"float32"
,
shape
=
[
10
,
8
],
lod_level
=
0
,
name
=
"mul.y"
)
mul_out
=
b
.
create_var
(
dtype
=
"float32"
,
shape
=
[
5
,
8
],
lod_level
=
0
,
name
=
"mul.out"
)
b
.
append_op
(
type
=
"mul"
,
inputs
=
{
"X"
:
mul_x
,
"Y"
:
mul_y
},
outputs
=
{
"Out"
:
mul_out
},
attrs
=
{
"x_num_col_dims"
:
1
})
print
(
debuger
.
pprint_program_codes
(
p
.
desc
))
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录