Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
e7f62703
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看板
提交
e7f62703
编写于
10月 21, 2017
作者:
Q
Qiao Longfei
提交者:
GitHub
10月 21, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix InferShapeContext Has interface (#4994)
上级
d0cfbba4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
28 addition
and
4 deletion
+28
-4
paddle/framework/operator.h
paddle/framework/operator.h
+28
-4
未找到文件。
paddle/framework/operator.h
浏览文件 @
e7f62703
...
@@ -327,6 +327,9 @@ class CompileTimeInferShapeContext : public InferShapeContext {
...
@@ -327,6 +327,9 @@ class CompileTimeInferShapeContext : public InferShapeContext {
bool
HasInput
(
const
std
::
string
&
name
)
const
override
{
bool
HasInput
(
const
std
::
string
&
name
)
const
override
{
const
std
::
vector
<
std
::
string
>&
input_names
=
op_
.
Input
(
name
);
const
std
::
vector
<
std
::
string
>&
input_names
=
op_
.
Input
(
name
);
auto
length
=
input_names
.
size
();
auto
length
=
input_names
.
size
();
if
(
length
==
0
)
{
return
false
;
}
PADDLE_ENFORCE_EQ
(
length
,
1UL
,
PADDLE_ENFORCE_EQ
(
length
,
1UL
,
"Input(%s) should have only one value, "
"Input(%s) should have only one value, "
"but it have %d now"
,
"but it have %d now"
,
...
@@ -337,6 +340,9 @@ class CompileTimeInferShapeContext : public InferShapeContext {
...
@@ -337,6 +340,9 @@ class CompileTimeInferShapeContext : public InferShapeContext {
bool
HasOutput
(
const
std
::
string
&
name
)
const
override
{
bool
HasOutput
(
const
std
::
string
&
name
)
const
override
{
const
std
::
vector
<
std
::
string
>&
output_names
=
op_
.
Output
(
name
);
const
std
::
vector
<
std
::
string
>&
output_names
=
op_
.
Output
(
name
);
auto
length
=
output_names
.
size
();
auto
length
=
output_names
.
size
();
if
(
length
==
0
)
{
return
false
;
}
PADDLE_ENFORCE_EQ
(
length
,
1UL
,
PADDLE_ENFORCE_EQ
(
length
,
1UL
,
"Output(%s) should have only one value, "
"Output(%s) should have only one value, "
"but it have %d now"
,
"but it have %d now"
,
...
@@ -346,7 +352,9 @@ class CompileTimeInferShapeContext : public InferShapeContext {
...
@@ -346,7 +352,9 @@ class CompileTimeInferShapeContext : public InferShapeContext {
bool
HasInputs
(
const
std
::
string
&
name
)
const
override
{
bool
HasInputs
(
const
std
::
string
&
name
)
const
override
{
const
std
::
vector
<
std
::
string
>&
input_names
=
op_
.
Input
(
name
);
const
std
::
vector
<
std
::
string
>&
input_names
=
op_
.
Input
(
name
);
PADDLE_ENFORCE
(
!
input_names
.
empty
(),
"Inputs(%s) length is 0"
,
name
);
if
(
input_names
.
empty
())
{
return
false
;
}
for
(
auto
&
input
:
input_names
)
{
for
(
auto
&
input
:
input_names
)
{
if
(
!
block_
.
HasVar
(
input
))
return
false
;
if
(
!
block_
.
HasVar
(
input
))
return
false
;
}
}
...
@@ -355,7 +363,9 @@ class CompileTimeInferShapeContext : public InferShapeContext {
...
@@ -355,7 +363,9 @@ class CompileTimeInferShapeContext : public InferShapeContext {
bool
HasOutputs
(
const
std
::
string
&
name
)
const
override
{
bool
HasOutputs
(
const
std
::
string
&
name
)
const
override
{
const
std
::
vector
<
std
::
string
>&
output_names
=
op_
.
Output
(
name
);
const
std
::
vector
<
std
::
string
>&
output_names
=
op_
.
Output
(
name
);
PADDLE_ENFORCE
(
!
output_names
.
empty
(),
"Inputs(%s) length is 0"
,
name
);
if
(
output_names
.
empty
())
{
return
false
;
}
for
(
auto
&
output
:
output_names
)
{
for
(
auto
&
output
:
output_names
)
{
if
(
!
block_
.
HasVar
(
output
))
return
false
;
if
(
!
block_
.
HasVar
(
output
))
return
false
;
}
}
...
@@ -421,13 +431,27 @@ class RuntimeInferShapeContext : public InferShapeContext {
...
@@ -421,13 +431,27 @@ class RuntimeInferShapeContext : public InferShapeContext {
:
op_
(
op
),
scope_
(
scope
)
{}
:
op_
(
op
),
scope_
(
scope
)
{}
bool
HasInput
(
const
std
::
string
&
name
)
const
override
{
bool
HasInput
(
const
std
::
string
&
name
)
const
override
{
auto
ipt
=
op_
.
Input
(
name
);
auto
&
ins
=
Inputs
(
name
);
size_t
length
=
ins
.
size
();
if
(
length
==
0
)
{
return
false
;
}
PADDLE_ENFORCE_EQ
(
length
,
1UL
,
"Input %s should have more than one inputs"
,
name
);
auto
ipt
=
ins
[
0
];
auto
*
var
=
ipt
==
kEmptyVarName
?
nullptr
:
scope_
.
FindVar
(
ipt
);
auto
*
var
=
ipt
==
kEmptyVarName
?
nullptr
:
scope_
.
FindVar
(
ipt
);
return
var
!=
nullptr
;
return
var
!=
nullptr
;
}
}
bool
HasOutput
(
const
std
::
string
&
name
)
const
override
{
bool
HasOutput
(
const
std
::
string
&
name
)
const
override
{
auto
ipt
=
op_
.
Output
(
name
);
auto
&
outs
=
Outputs
(
name
);
size_t
length
=
outs
.
size
();
if
(
length
==
0
)
{
return
false
;
}
PADDLE_ENFORCE_EQ
(
length
,
1UL
,
"Output %s should have more than one inputs"
,
name
);
auto
ipt
=
outs
[
0
];
auto
*
var
=
ipt
==
kEmptyVarName
?
nullptr
:
scope_
.
FindVar
(
ipt
);
auto
*
var
=
ipt
==
kEmptyVarName
?
nullptr
:
scope_
.
FindVar
(
ipt
);
return
var
!=
nullptr
;
return
var
!=
nullptr
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录