Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
dc643a33
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看板
提交
dc643a33
编写于
9月 22, 2017
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Hot fix unittest
上级
bddb4060
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
4 addition
and
17 deletion
+4
-17
paddle/pybind/protobuf.cc
paddle/pybind/protobuf.cc
+4
-13
python/paddle/v2/framework/tests/test_protobuf_descs.py
python/paddle/v2/framework/tests/test_protobuf_descs.py
+0
-4
未找到文件。
paddle/pybind/protobuf.cc
浏览文件 @
dc643a33
...
@@ -59,14 +59,7 @@ public:
...
@@ -59,14 +59,7 @@ public:
BlockDescBind
(
ProgramDescBind
*
prog
,
BlockDesc
*
desc
)
BlockDescBind
(
ProgramDescBind
*
prog
,
BlockDesc
*
desc
)
:
prog_
(
prog
),
desc_
(
desc
),
need_update_
(
false
)
{}
:
prog_
(
prog
),
desc_
(
desc
),
need_update_
(
false
)
{}
~
BlockDescBind
()
{
int32_t
id
()
const
{
return
desc_
->
idx
();
}
std
::
cerr
<<
"dtor "
<<
this
<<
","
<<
desc_
<<
std
::
endl
;
}
int32_t
id
()
const
{
std
::
cerr
<<
"desc ptr "
<<
desc_
<<
std
::
endl
;
return
desc_
->
idx
();
}
int32_t
Parent
()
const
{
return
desc_
->
parent_idx
();
}
int32_t
Parent
()
const
{
return
desc_
->
parent_idx
();
}
...
@@ -114,11 +107,9 @@ public:
...
@@ -114,11 +107,9 @@ public:
return
*
ptr
;
return
*
ptr
;
}
}
BlockDescBind
*
AppendBlock
(
BlockDescBind
*
parent
)
{
BlockDescBind
*
AppendBlock
(
const
BlockDescBind
&
parent
)
{
auto
*
b
=
prog_
->
add_blocks
();
auto
*
b
=
prog_
->
add_blocks
();
std
::
cerr
<<
"block ptr "
<<
b
<<
std
::
endl
;
b
->
set_parent_idx
(
parent
.
id
());
std
::
cerr
<<
"pass ptr "
<<
parent
<<
std
::
endl
;
b
->
set_parent_idx
(
parent
->
id
());
b
->
set_idx
(
prog_
->
blocks_size
()
-
1
);
b
->
set_idx
(
prog_
->
blocks_size
()
-
1
);
blocks_
.
emplace_back
(
this
,
b
);
blocks_
.
emplace_back
(
this
,
b
);
return
&
blocks_
.
back
();
return
&
blocks_
.
back
();
...
@@ -141,6 +132,7 @@ public:
...
@@ -141,6 +132,7 @@ public:
private:
private:
explicit
ProgramDescBind
(
ProgramDesc
*
prog
)
:
prog_
(
prog
)
{
explicit
ProgramDescBind
(
ProgramDesc
*
prog
)
:
prog_
(
prog
)
{
blocks_
.
reserve
(
100
);
for
(
auto
&
block
:
*
prog
->
mutable_blocks
())
{
for
(
auto
&
block
:
*
prog
->
mutable_blocks
())
{
blocks_
.
emplace_back
(
this
,
&
block
);
blocks_
.
emplace_back
(
this
,
&
block
);
}
}
...
@@ -181,7 +173,6 @@ void BindProgramDesc(py::module &m) {
...
@@ -181,7 +173,6 @@ void BindProgramDesc(py::module &m) {
}
}
void
BindBlockDesc
(
py
::
module
&
m
)
{
void
BindBlockDesc
(
py
::
module
&
m
)
{
using
namespace
paddle
::
framework
;
// NOLINT
py
::
class_
<
BlockDescBind
>
(
m
,
"BlockDesc"
,
""
)
py
::
class_
<
BlockDescBind
>
(
m
,
"BlockDesc"
,
""
)
.
def_property_readonly
(
"id"
,
&
BlockDescBind
::
id
)
.
def_property_readonly
(
"id"
,
&
BlockDescBind
::
id
)
.
def_property_readonly
(
"parent"
,
&
BlockDescBind
::
Parent
)
.
def_property_readonly
(
"parent"
,
&
BlockDescBind
::
Parent
)
...
...
python/paddle/v2/framework/tests/test_protobuf_descs.py
浏览文件 @
dc643a33
...
@@ -17,16 +17,12 @@ class TestProgramDesc(unittest.TestCase):
...
@@ -17,16 +17,12 @@ class TestProgramDesc(unittest.TestCase):
self
.
assertIsNotNone
(
prog_desc
)
self
.
assertIsNotNone
(
prog_desc
)
block_root
=
prog_desc
.
block
(
0
)
block_root
=
prog_desc
.
block
(
0
)
self
.
assertIsNotNone
(
block_root
)
self
.
assertIsNotNone
(
block_root
)
print
'here'
self
.
assertEqual
(
block_root
.
id
,
0
)
self
.
assertEqual
(
block_root
.
id
,
0
)
block1
=
prog_desc
.
append_block
(
block_root
)
block1
=
prog_desc
.
append_block
(
block_root
)
block2
=
prog_desc
.
append_block
(
block1
)
block2
=
prog_desc
.
append_block
(
block1
)
self
.
assertIsNotNone
(
block1
)
self
.
assertIsNotNone
(
block1
)
print
'here'
self
.
assertEqual
(
block1
.
id
,
block2
.
parent
)
self
.
assertEqual
(
block1
.
id
,
block2
.
parent
)
print
'here'
self
.
assertEqual
(
block_root
.
id
,
block1
.
parent
)
self
.
assertEqual
(
block_root
.
id
,
block1
.
parent
)
print
'here'
block3
=
prog_desc
.
append_block
(
block_root
)
block3
=
prog_desc
.
append_block
(
block_root
)
self
.
assertEqual
(
block3
.
parent
,
block_root
.
id
)
self
.
assertEqual
(
block3
.
parent
,
block_root
.
id
)
self
.
assertEqual
(
prog_desc
.
block
(
1
).
id
,
1
)
self
.
assertEqual
(
prog_desc
.
block
(
1
).
id
,
1
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录