Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
8ecad985
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8ecad985
编写于
3月 14, 2018
作者:
L
Liu Yiqun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add the bool variable to decide whether to have a copy of the program in ExecutorPrepareContext.
上级
c0a9aebe
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
8 deletion
+23
-8
paddle/fluid/framework/executor.cc
paddle/fluid/framework/executor.cc
+22
-7
paddle/fluid/framework/executor.h
paddle/fluid/framework/executor.h
+1
-1
未找到文件。
paddle/fluid/framework/executor.cc
浏览文件 @
8ecad985
...
...
@@ -35,11 +35,26 @@ namespace paddle {
namespace
framework
{
struct
ExecutorPrepareContext
{
ExecutorPrepareContext
(
const
framework
::
ProgramDesc
&
prog
,
size_t
block_id
)
:
prog_
(
prog
),
block_id_
(
block_id
)
{}
ExecutorPrepareContext
(
const
framework
::
ProgramDesc
*
prog
,
size_t
block_id
,
bool
own_program
=
true
)
:
block_id_
(
block_id
),
own_program_
(
own_program
)
{
if
(
own_program_
)
{
prog_
=
new
ProgramDesc
(
*
prog
);
}
else
{
// If own_program_ is false, we can avoid a clone of the program.
prog_
=
prog
;
}
}
~
ExecutorPrepareContext
()
{
if
(
own_program_
)
{
delete
prog_
;
}
}
framework
::
ProgramDesc
prog_
;
const
framework
::
ProgramDesc
*
prog_
;
size_t
block_id_
;
bool
own_program_
;
std
::
vector
<
std
::
unique_ptr
<
OperatorBase
>>
ops_
;
};
...
...
@@ -94,7 +109,7 @@ static void CheckTensorNANOrInf(const std::string& name,
void
Executor
::
Run
(
const
ProgramDesc
&
pdesc
,
Scope
*
scope
,
int
block_id
,
bool
create_local_scope
,
bool
create_vars
)
{
auto
*
ctx
=
Prepare
(
pdesc
,
block_id
);
auto
*
ctx
=
Prepare
(
pdesc
,
block_id
,
false
);
RunPreparedContext
(
ctx
,
scope
,
create_local_scope
,
create_vars
);
delete
ctx
;
}
...
...
@@ -267,8 +282,8 @@ void Executor::Run(const ProgramDesc& program, Scope* scope,
}
ExecutorPrepareContext
*
Executor
::
Prepare
(
const
ProgramDesc
&
program
,
int
block_id
)
{
auto
*
ctx
=
new
ExecutorPrepareContext
(
program
,
block_id
);
int
block_id
,
bool
own_program
)
{
auto
*
ctx
=
new
ExecutorPrepareContext
(
&
program
,
block_id
,
own_program
);
PADDLE_ENFORCE_LT
(
static_cast
<
size_t
>
(
block_id
),
program
.
Size
());
auto
&
block
=
program
.
Block
(
block_id
);
for
(
auto
&
op_desc
:
block
.
AllOps
())
{
...
...
@@ -279,7 +294,7 @@ ExecutorPrepareContext* Executor::Prepare(const ProgramDesc& program,
void
Executor
::
RunPreparedContext
(
ExecutorPrepareContext
*
ctx
,
Scope
*
scope
,
bool
create_local_scope
,
bool
create_vars
)
{
auto
&
block
=
ctx
->
prog_
.
Block
(
ctx
->
block_id_
);
auto
&
block
=
ctx
->
prog_
->
Block
(
ctx
->
block_id_
);
Scope
*
local_scope
=
scope
;
if
(
create_vars
)
{
...
...
paddle/fluid/framework/executor.h
浏览文件 @
8ecad985
...
...
@@ -48,7 +48,7 @@ class Executor {
const
std
::
string
&
fetch_holder_name
=
"fetch"
);
static
ExecutorPrepareContext
*
Prepare
(
const
ProgramDesc
&
program
,
int
block_id
);
int
block_id
,
bool
own_program
=
true
);
void
RunPreparedContext
(
ExecutorPrepareContext
*
ctx
,
Scope
*
scope
,
bool
create_local_scope
=
true
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录