Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
70981f5d
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
提交
70981f5d
编写于
12月 18, 2018
作者:
X
Xin Pan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean
test=develop
上级
fb8ae303
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
31 deletion
+23
-31
paddle/fluid/framework/operator.cc
paddle/fluid/framework/operator.cc
+14
-22
paddle/fluid/framework/operator.h
paddle/fluid/framework/operator.h
+8
-8
paddle/fluid/operators/prelu_op.cc
paddle/fluid/operators/prelu_op.cc
+1
-1
未找到文件。
paddle/fluid/framework/operator.cc
浏览文件 @
70981f5d
...
...
@@ -143,14 +143,12 @@ RuntimeContext::RuntimeContext(const VariableNameMap& innames,
for
(
auto
&
var_name_item
:
innames
)
{
std
::
vector
<
Variable
*>&
input_vars
=
inputs
[
var_name_item
.
first
];
for
(
auto
&
var_name
:
var_name_item
.
second
)
{
LOG
(
ERROR
)
<<
"first in "
<<
var_name_item
.
first
<<
":"
<<
var_name
;
input_vars
.
push_back
(
scope
.
FindVar
(
var_name
));
}
}
for
(
auto
&
var_name_item
:
outnames
)
{
std
::
vector
<
Variable
*>&
output_vars
=
outputs
[
var_name_item
.
first
];
for
(
auto
&
var_name
:
var_name_item
.
second
)
{
LOG
(
ERROR
)
<<
"first out "
<<
var_name_item
.
first
<<
":"
<<
var_name
;
output_vars
.
push_back
(
scope
.
FindVar
(
var_name
));
}
}
...
...
@@ -441,22 +439,13 @@ const Variable* ExecutionContext::InputVar(const std::string& name) const {
return
it
->
second
.
empty
()
?
nullptr
:
it
->
second
[
0
];
}
Variable
*
ExecutionContext
::
OutputVar
(
const
std
::
string
&
name
)
const
{
auto
opt
=
op_
.
Output
(
name
);
return
opt
==
kEmptyVarName
?
nullptr
:
scope_
.
FindVar
(
opt
);
}
const
Variable
*
ExecutionContext
::
FastInputVar
(
const
std
::
string
&
name
)
const
{
auto
it
=
ctx_
.
inputs
.
find
(
name
);
if
(
it
==
ctx_
.
inputs
.
end
())
return
nullptr
;
PADDLE_ENFORCE_LE
(
it
->
second
.
size
(),
1UL
,
"Operator %s's input %s should contain only one variable."
,
op_
.
Type
(),
name
);
return
it
->
second
.
empty
()
?
nullptr
:
it
->
second
[
0
];
const
Variable
*
ExecutionContext
::
LegacyInputVar
(
const
std
::
string
&
name
)
const
{
auto
ipt
=
op_
.
Input
(
name
);
return
ipt
==
kEmptyVarName
?
nullptr
:
scope_
.
FindVar
(
ipt
);
}
Variable
*
ExecutionContext
::
Fast
OutputVar
(
const
std
::
string
&
name
)
const
{
Variable
*
ExecutionContext
::
OutputVar
(
const
std
::
string
&
name
)
const
{
auto
it
=
ctx_
.
outputs
.
find
(
name
);
if
(
it
==
ctx_
.
outputs
.
end
())
return
nullptr
;
...
...
@@ -466,15 +455,20 @@ Variable* ExecutionContext::FastOutputVar(const std::string& name) const {
return
it
->
second
.
empty
()
?
nullptr
:
it
->
second
[
0
];
}
Variable
*
ExecutionContext
::
LegacyOutputVar
(
const
std
::
string
&
name
)
const
{
auto
opt
=
op_
.
Output
(
name
);
return
opt
==
kEmptyVarName
?
nullptr
:
scope_
.
FindVar
(
opt
);
}
template
<
>
const
Tensor
*
ExecutionContext
::
Input
<
Tensor
>
(
const
std
::
string
&
name
)
const
{
return
Input
<
LoDTensor
>
(
name
);
}
template
<
>
const
Tensor
*
ExecutionContext
::
Fast
Input
<
Tensor
>
(
const
Tensor
*
ExecutionContext
::
Legacy
Input
<
Tensor
>
(
const
std
::
string
&
name
)
const
{
return
Fast
Input
<
LoDTensor
>
(
name
);
return
Legacy
Input
<
LoDTensor
>
(
name
);
}
template
<
>
...
...
@@ -502,8 +496,8 @@ Tensor* ExecutionContext::Output<Tensor>(const std::string& name) const {
}
template
<
>
Tensor
*
ExecutionContext
::
Fast
Output
<
Tensor
>
(
const
std
::
string
&
name
)
const
{
return
Fast
Output
<
LoDTensor
>
(
name
);
Tensor
*
ExecutionContext
::
Legacy
Output
<
Tensor
>
(
const
std
::
string
&
name
)
const
{
return
Legacy
Output
<
LoDTensor
>
(
name
);
}
template
<
>
...
...
@@ -870,7 +864,6 @@ Scope* OperatorWithKernel::PrepareData(
auto
&
var_name
=
var_name_item
.
second
[
i
];
auto
*
var
=
scope
.
FindVar
(
var_name
);
input_vars
[
i
]
=
var
;
LOG
(
ERROR
)
<<
"second in "
<<
var_name_item
.
first
<<
":"
<<
var_name
;
// Only tensor can be tranfer to another device.
if
(
var
==
nullptr
||
!
VarIsTensor
(
*
var
))
{
...
...
@@ -931,7 +924,6 @@ Scope* OperatorWithKernel::PrepareData(
for
(
size_t
i
=
0
;
i
<
var_name_item
.
second
.
size
();
++
i
)
{
auto
&
var_name
=
var_name_item
.
second
[
i
];
output_vars
[
i
]
=
scope
.
FindVar
(
var_name
);
LOG
(
ERROR
)
<<
"second out "
<<
var_name_item
.
first
<<
":"
<<
var_name
;
}
}
...
...
paddle/fluid/framework/operator.h
浏览文件 @
70981f5d
...
...
@@ -233,20 +233,20 @@ class ExecutionContext {
}
template
<
typename
T
>
const
T
*
Fast
Input
(
const
std
::
string
&
name
)
const
{
auto
*
var
=
Fast
InputVar
(
name
);
const
T
*
Legacy
Input
(
const
std
::
string
&
name
)
const
{
auto
*
var
=
Legacy
InputVar
(
name
);
return
var
==
nullptr
?
nullptr
:
&
var
->
Get
<
T
>
();
}
template
<
typename
T
>
T
*
Fast
Output
(
const
std
::
string
&
name
)
const
{
auto
var
=
Fast
OutputVar
(
name
);
T
*
Legacy
Output
(
const
std
::
string
&
name
)
const
{
auto
var
=
Legacy
OutputVar
(
name
);
return
var
==
nullptr
?
nullptr
:
var
->
GetMutable
<
T
>
();
}
const
Variable
*
Fast
InputVar
(
const
std
::
string
&
name
)
const
;
const
Variable
*
Legacy
InputVar
(
const
std
::
string
&
name
)
const
;
Variable
*
Fast
OutputVar
(
const
std
::
string
&
name
)
const
;
Variable
*
Legacy
OutputVar
(
const
std
::
string
&
name
)
const
;
template
<
typename
T
>
const
std
::
vector
<
const
T
*>
MultiInput
(
const
std
::
string
&
name
)
const
{
...
...
@@ -314,7 +314,7 @@ template <>
const
Tensor
*
ExecutionContext
::
Input
<
Tensor
>
(
const
std
::
string
&
name
)
const
;
template
<>
const
Tensor
*
ExecutionContext
::
Fast
Input
<
Tensor
>
(
const
Tensor
*
ExecutionContext
::
Legacy
Input
<
Tensor
>
(
const
std
::
string
&
name
)
const
;
template
<>
...
...
@@ -325,7 +325,7 @@ template <>
Tensor
*
ExecutionContext
::
Output
<
Tensor
>
(
const
std
::
string
&
name
)
const
;
template
<>
Tensor
*
ExecutionContext
::
Fast
Output
<
Tensor
>
(
const
std
::
string
&
name
)
const
;
Tensor
*
ExecutionContext
::
Legacy
Output
<
Tensor
>
(
const
std
::
string
&
name
)
const
;
template
<>
std
::
vector
<
Tensor
*>
ExecutionContext
::
MultiOutput
<
Tensor
>
(
...
...
paddle/fluid/operators/prelu_op.cc
浏览文件 @
70981f5d
...
...
@@ -56,7 +56,7 @@ class PReluOp : public framework::OperatorWithKernel {
protected:
framework
::
OpKernelType
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
return
framework
::
OpKernelType
(
ctx
.
Fast
Input
<
Tensor
>
(
"X"
)
->
type
(),
return
framework
::
OpKernelType
(
ctx
.
Input
<
Tensor
>
(
"X"
)
->
type
(),
ctx
.
device_context
());
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录