Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
8938a9b0
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看板
提交
8938a9b0
编写于
10月 17, 2017
作者:
Y
Yu Yang
提交者:
GitHub
10月 17, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Correct implement BlockDesc destructor (#4882)
上级
521514da
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
2 deletion
+27
-2
paddle/framework/block_desc.cc
paddle/framework/block_desc.cc
+18
-2
paddle/framework/block_desc.h
paddle/framework/block_desc.h
+9
-0
未找到文件。
paddle/framework/block_desc.cc
浏览文件 @
8938a9b0
...
@@ -72,13 +72,13 @@ std::vector<OpDescBind *> BlockDescBind::AllOps() const {
...
@@ -72,13 +72,13 @@ std::vector<OpDescBind *> BlockDescBind::AllOps() const {
void
BlockDescBind
::
Flush
()
{
void
BlockDescBind
::
Flush
()
{
if
(
need_update_
)
{
if
(
need_update_
)
{
auto
&
op_field
=
*
this
->
desc_
->
mutable_ops
();
auto
&
op_field
=
*
this
->
desc_
->
mutable_ops
();
op_field
.
Clear
();
this
->
ClearPBOps
();
op_field
.
Reserve
(
static_cast
<
int
>
(
ops_
.
size
()));
op_field
.
Reserve
(
static_cast
<
int
>
(
ops_
.
size
()));
for
(
auto
&
op_desc
:
ops_
)
{
for
(
auto
&
op_desc
:
ops_
)
{
op_field
.
AddAllocated
(
op_desc
->
Proto
());
op_field
.
AddAllocated
(
op_desc
->
Proto
());
}
}
auto
&
var_field
=
*
this
->
desc_
->
mutable_vars
();
auto
&
var_field
=
*
this
->
desc_
->
mutable_vars
();
var_field
.
Clear
();
this
->
ClearPBVars
();
var_field
.
Reserve
(
static_cast
<
int
>
(
vars_
.
size
()));
var_field
.
Reserve
(
static_cast
<
int
>
(
vars_
.
size
()));
for
(
auto
&
var_desc
:
vars_
)
{
for
(
auto
&
var_desc
:
vars_
)
{
var_field
.
AddAllocated
(
var_desc
.
second
->
Proto
());
var_field
.
AddAllocated
(
var_desc
.
second
->
Proto
());
...
@@ -99,5 +99,21 @@ BlockDesc *BlockDescBind::Proto() {
...
@@ -99,5 +99,21 @@ BlockDesc *BlockDescBind::Proto() {
return
desc_
;
return
desc_
;
}
}
void
BlockDescBind
::
ClearPBOps
()
{
auto
ops
=
this
->
desc_
->
mutable_ops
();
while
(
!
ops
->
empty
())
{
// we do not own the OpDesc, so release the ownership.
ops
->
ReleaseLast
();
}
}
void
BlockDescBind
::
ClearPBVars
()
{
auto
vars
=
this
->
desc_
->
mutable_vars
();
while
(
!
vars
->
empty
())
{
// we do not own the VarDesc, so release the ownership.
vars
->
ReleaseLast
();
}
}
}
// namespace framework
}
// namespace framework
}
// namespace paddle
}
// namespace paddle
paddle/framework/block_desc.h
浏览文件 @
8938a9b0
...
@@ -36,6 +36,11 @@ class BlockDescBind {
...
@@ -36,6 +36,11 @@ class BlockDescBind {
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
()
{
this
->
ClearPBVars
();
this
->
ClearPBOps
();
}
int32_t
ID
()
const
{
return
desc_
->
idx
();
}
int32_t
ID
()
const
{
return
desc_
->
idx
();
}
int32_t
Parent
()
const
{
return
desc_
->
parent_idx
();
}
int32_t
Parent
()
const
{
return
desc_
->
parent_idx
();
}
...
@@ -60,6 +65,10 @@ class BlockDescBind {
...
@@ -60,6 +65,10 @@ class BlockDescBind {
BlockDesc
*
Proto
();
BlockDesc
*
Proto
();
private:
void
ClearPBOps
();
void
ClearPBVars
();
// FIXME(yuyang18): backward will access private data of BlockDesc.
// FIXME(yuyang18): backward will access private data of BlockDesc.
// Mark it public temporary. We can fix it later.
// Mark it public temporary. We can fix it later.
public:
public:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录