Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
62eb43ba
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
62eb43ba
编写于
12月 18, 2018
作者:
X
Xin Pan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
convert more
test=develop
上级
dfcf746e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
19 deletion
+16
-19
paddle/fluid/framework/operator.cc
paddle/fluid/framework/operator.cc
+16
-19
未找到文件。
paddle/fluid/framework/operator.cc
浏览文件 @
62eb43ba
...
@@ -142,12 +142,14 @@ RuntimeContext::RuntimeContext(const VariableNameMap& innames,
...
@@ -142,12 +142,14 @@ RuntimeContext::RuntimeContext(const VariableNameMap& innames,
const
Scope
&
scope
)
{
const
Scope
&
scope
)
{
for
(
auto
&
var_name_item
:
innames
)
{
for
(
auto
&
var_name_item
:
innames
)
{
std
::
vector
<
Variable
*>&
input_vars
=
inputs
[
var_name_item
.
first
];
std
::
vector
<
Variable
*>&
input_vars
=
inputs
[
var_name_item
.
first
];
input_vars
.
reserve
(
var_name_item
.
second
.
size
());
for
(
auto
&
var_name
:
var_name_item
.
second
)
{
for
(
auto
&
var_name
:
var_name_item
.
second
)
{
input_vars
.
push_back
(
scope
.
FindVar
(
var_name
));
input_vars
.
push_back
(
scope
.
FindVar
(
var_name
));
}
}
}
}
for
(
auto
&
var_name_item
:
outnames
)
{
for
(
auto
&
var_name_item
:
outnames
)
{
std
::
vector
<
Variable
*>&
output_vars
=
outputs
[
var_name_item
.
first
];
std
::
vector
<
Variable
*>&
output_vars
=
outputs
[
var_name_item
.
first
];
output_vars
.
reserve
(
var_name_item
.
second
.
size
());
for
(
auto
&
var_name
:
var_name_item
.
second
)
{
for
(
auto
&
var_name
:
var_name_item
.
second
)
{
output_vars
.
push_back
(
scope
.
FindVar
(
var_name
));
output_vars
.
push_back
(
scope
.
FindVar
(
var_name
));
}
}
...
@@ -556,30 +558,28 @@ class RuntimeInferShapeContext : public InferShapeContext {
...
@@ -556,30 +558,28 @@ class RuntimeInferShapeContext : public InferShapeContext {
bool
HasOutput
(
const
std
::
string
&
name
)
const
override
{
bool
HasOutput
(
const
std
::
string
&
name
)
const
override
{
// has only one output
// has only one output
const
auto
&
outs
=
op_
.
Outputs
()
;
const
auto
&
outs
=
ctx_
.
outputs
;
auto
it
=
outs
.
find
(
name
);
auto
it
=
outs
.
find
(
name
);
if
(
it
==
outs
.
end
())
{
if
(
it
==
outs
.
end
())
{
return
false
;
return
false
;
}
}
const
auto
&
out
=
it
->
second
;
const
auto
&
out
=
it
->
second
;
if
(
out
.
size
()
==
0
||
out
[
0
]
==
kEmptyVarName
)
{
if
(
out
.
size
()
==
0
)
{
return
false
;
return
false
;
}
}
PADDLE_ENFORCE_EQ
(
out
.
size
(),
1UL
,
PADDLE_ENFORCE_EQ
(
out
.
size
(),
1UL
,
"Output %s should not have more than one outputs"
,
name
);
"Output %s should not have more than one outputs"
,
name
);
return
scope_
.
FindVar
(
out
[
0
])
!=
nullptr
;
return
out
[
0
]
!=
nullptr
;
}
}
bool
HasInputs
(
const
std
::
string
&
name
)
const
override
{
bool
HasInputs
(
const
std
::
string
&
name
)
const
override
{
if
(
!
op_
.
HasInputs
(
name
))
{
const
auto
&
ins
=
ctx_
.
inputs
;
return
false
;
auto
it
=
ins
.
find
(
name
);
}
if
(
it
==
ins
.
end
())
{
auto
inputs
=
op_
.
Inputs
(
name
);
if
(
inputs
.
empty
())
{
return
false
;
return
false
;
}
}
for
(
auto
&
input
:
i
nputs
)
{
for
(
auto
&
input
:
i
t
->
second
)
{
if
(
scope_
.
FindVar
(
input
)
==
nullptr
)
{
if
(
input
==
nullptr
)
{
return
false
;
return
false
;
}
}
}
}
...
@@ -587,15 +587,13 @@ class RuntimeInferShapeContext : public InferShapeContext {
...
@@ -587,15 +587,13 @@ class RuntimeInferShapeContext : public InferShapeContext {
}
}
bool
HasOutputs
(
const
std
::
string
&
name
)
const
override
{
bool
HasOutputs
(
const
std
::
string
&
name
)
const
override
{
if
(
!
op_
.
HasOutputs
(
name
))
{
const
auto
&
outs
=
ctx_
.
outputs
;
return
false
;
auto
it
=
outs
.
find
(
name
);
}
if
(
it
==
outs
.
end
())
{
auto
outputs
=
op_
.
Outputs
(
name
);
if
(
outputs
.
empty
())
{
return
false
;
return
false
;
}
}
for
(
auto
&
output
:
outputs
)
{
for
(
auto
&
output
:
it
->
second
)
{
if
(
scope_
.
FindVar
(
output
)
==
nullptr
)
{
if
(
output
==
nullptr
)
{
return
false
;
return
false
;
}
}
}
}
...
@@ -864,8 +862,7 @@ Scope* OperatorWithKernel::PrepareData(
...
@@ -864,8 +862,7 @@ Scope* OperatorWithKernel::PrepareData(
for
(
size_t
i
=
0
;
i
<
var_name_item
.
second
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
var_name_item
.
second
.
size
();
++
i
)
{
auto
&
var_name
=
var_name_item
.
second
[
i
];
auto
&
var_name
=
var_name_item
.
second
[
i
];
auto
*
var
=
scope
.
FindVar
(
var_name
);
auto
*
var
=
input_vars
[
i
];
input_vars
[
i
]
=
var
;
// Only tensor can be tranfer to another device.
// Only tensor can be tranfer to another device.
if
(
var
==
nullptr
||
!
VarIsTensor
(
*
var
))
{
if
(
var
==
nullptr
||
!
VarIsTensor
(
*
var
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录