Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
8e005407
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2292
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,发现更多精彩内容 >>
未验证
提交
8e005407
编写于
4月 20, 2018
作者:
T
Tao Luo
提交者:
GitHub
4月 20, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10058 from Xreki/core_fix_flush
Add flush of program desc to update the proto information.
上级
cec4e6ed
7ffbcbca
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
13 addition
and
3 deletion
+13
-3
paddle/fluid/framework/block_desc.cc
paddle/fluid/framework/block_desc.cc
+1
-0
paddle/fluid/framework/program_desc.cc
paddle/fluid/framework/program_desc.cc
+5
-1
paddle/fluid/framework/program_desc.h
paddle/fluid/framework/program_desc.h
+2
-0
paddle/fluid/pybind/protobuf.cc
paddle/fluid/pybind/protobuf.cc
+1
-0
python/paddle/fluid/io.py
python/paddle/fluid/io.py
+4
-2
未找到文件。
paddle/fluid/framework/block_desc.cc
浏览文件 @
8e005407
...
...
@@ -146,6 +146,7 @@ void BlockDesc::RemoveOp(size_t s, size_t e) {
if
(
ops_
.
begin
()
+
s
==
ops_
.
end
()
||
ops_
.
begin
()
+
e
==
ops_
.
end
())
{
return
;
}
need_update_
=
true
;
ops_
.
erase
(
ops_
.
begin
()
+
s
,
ops_
.
begin
()
+
e
);
}
...
...
paddle/fluid/framework/program_desc.cc
浏览文件 @
8e005407
...
...
@@ -27,10 +27,14 @@ BlockDesc *ProgramDesc::AppendBlock(const BlockDesc &parent) {
return
blocks_
.
back
().
get
();
}
proto
::
ProgramDesc
*
ProgramDesc
::
Proto
()
{
void
ProgramDesc
::
Flush
()
{
for
(
auto
&
block
:
blocks_
)
{
block
->
Flush
();
}
}
proto
::
ProgramDesc
*
ProgramDesc
::
Proto
()
{
Flush
();
return
&
desc_
;
}
...
...
paddle/fluid/framework/program_desc.h
浏览文件 @
8e005407
...
...
@@ -51,6 +51,8 @@ class ProgramDesc {
size_t
Size
()
const
{
return
blocks_
.
size
();
}
void
Flush
();
proto
::
ProgramDesc
*
Proto
();
// The output variable of feed_op is referenced as feed_target.
...
...
paddle/fluid/pybind/protobuf.cc
浏览文件 @
8e005407
...
...
@@ -127,6 +127,7 @@ void BindProgramDesc(pybind11::module *m) {
.
def
(
"block"
,
&
pd
::
ProgramDesc
::
MutableBlock
,
pybind11
::
return_value_policy
::
reference
)
.
def
(
"num_blocks"
,
&
pd
::
ProgramDesc
::
Size
)
.
def
(
"flush"
,
&
pd
::
ProgramDesc
::
Flush
)
.
def
(
"get_feed_target_names"
,
&
pd
::
ProgramDesc
::
GetFeedTargetNames
)
.
def
(
"get_fetch_target_names"
,
&
pd
::
ProgramDesc
::
GetFetchTargetNames
)
.
def
(
"serialize_to_string"
,
SerializeMessage
<
pd
::
ProgramDesc
>
)
...
...
python/paddle/fluid/io.py
浏览文件 @
8e005407
...
...
@@ -336,18 +336,20 @@ def save_inference_model(dirname,
if
main_program
is
None
:
main_program
=
default_main_program
()
copy_program
=
main_program
if
not
os
.
path
.
isdir
(
dirname
):
os
.
makedirs
(
dirname
)
# Clear the is_target information and remove the existed feed and fetch op
global_block
=
main
_program
.
global_block
()
global_block
=
copy
_program
.
global_block
()
for
i
,
op
in
enumerate
(
global_block
.
ops
):
op
.
desc
.
set_is_target
(
False
)
if
op
.
type
==
"feed"
or
op
.
type
==
"fetch"
:
global_block
.
remove_op
(
i
)
copy_program
.
desc
.
flush
()
pruned_program
=
main
_program
.
prune
(
targets
=
target_vars
)
pruned_program
=
copy
_program
.
prune
(
targets
=
target_vars
)
inference_program
=
pruned_program
.
inference_optimize
()
fetch_var_names
=
[
v
.
name
for
v
in
target_vars
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录