Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
0575fd46
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看板
提交
0575fd46
编写于
2月 02, 2018
作者:
F
fengjiayi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
simplify shape inference code
上级
4e7e39b4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
22 addition
and
36 deletion
+22
-36
paddle/framework/op_desc.cc
paddle/framework/op_desc.cc
+0
-19
paddle/framework/operator.cc
paddle/framework/operator.cc
+0
-8
paddle/framework/shape_inference.cc
paddle/framework/shape_inference.cc
+19
-4
paddle/framework/shape_inference.h
paddle/framework/shape_inference.h
+3
-5
未找到文件。
paddle/framework/op_desc.cc
浏览文件 @
0575fd46
...
...
@@ -39,10 +39,6 @@ class CompileTimeInferShapeContext : public InferShapeContext {
bool
HasOutputs
(
const
std
::
string
&
name
)
const
override
;
DDim
GetInputDim
(
const
std
::
string
&
name
)
const
override
;
void
SetOutputDim
(
const
std
::
string
&
name
,
const
DDim
&
dim
)
override
;
AttrReader
Attrs
()
const
override
;
const
std
::
vector
<
std
::
string
>
&
Inputs
(
...
...
@@ -444,21 +440,6 @@ bool CompileTimeInferShapeContext::HasOutputs(const std::string &name) const {
return
true
;
}
DDim
CompileTimeInferShapeContext
::
GetInputDim
(
const
std
::
string
&
name
)
const
{
std
::
vector
<
DDim
>
ddims
=
GetInputsDim
(
name
);
auto
length
=
ddims
.
size
();
PADDLE_ENFORCE_EQ
(
length
,
1UL
,
"Input(%s) should have 1 value, "
"but it has %d now"
,
name
,
length
);
return
ddims
[
0
];
}
void
CompileTimeInferShapeContext
::
SetOutputDim
(
const
std
::
string
&
name
,
const
DDim
&
dim
)
{
SetOutputsDim
(
name
,
{
dim
});
}
AttrReader
CompileTimeInferShapeContext
::
Attrs
()
const
{
return
AttrReader
(
op_
.
GetAttrMap
());
}
...
...
paddle/framework/operator.cc
浏览文件 @
0575fd46
...
...
@@ -366,14 +366,6 @@ class RuntimeInferShapeContext : public InferShapeContext {
return
true
;
}
DDim
GetInputDim
(
const
std
::
string
&
name
)
const
override
{
return
GetDim
(
op_
.
Input
(
name
));
}
void
SetOutputDim
(
const
std
::
string
&
name
,
const
DDim
&
dim
)
override
{
SetDim
(
op_
.
Output
(
name
),
dim
);
}
AttrReader
Attrs
()
const
override
{
return
AttrReader
(
op_
.
Attrs
());
}
const
std
::
vector
<
std
::
string
>&
Inputs
(
...
...
paddle/framework/shape_inference.cc
浏览文件 @
0575fd46
...
...
@@ -18,10 +18,18 @@ limitations under the License. */
namespace
paddle
{
namespace
framework
{
framework
::
DDim
InferShapeContext
::
GetInputDim
(
const
std
::
string
&
name
)
const
{
const
std
::
vector
<
std
::
string
>
&
arg_names
=
Inputs
(
name
);
PADDLE_ENFORCE_EQ
(
arg_names
.
size
(),
1UL
,
"Input(%s) shoudl holds one element, but now it holds %d"
,
name
,
arg_names
.
size
());
return
this
->
GetDim
(
arg_names
[
0
]);
}
std
::
vector
<
framework
::
DDim
>
InferShapeContext
::
GetInputsDim
(
const
std
::
string
&
name
)
const
{
const
std
::
vector
<
std
::
string
>
&
names
=
Inputs
(
name
);
return
GetDims
(
names
);
const
std
::
vector
<
std
::
string
>
&
arg_
names
=
Inputs
(
name
);
return
GetDims
(
arg_
names
);
}
DDim
InferShapeContext
::
GetInputsElementDim
(
const
std
::
string
&
name
,
...
...
@@ -30,13 +38,21 @@ DDim InferShapeContext::GetInputsElementDim(const std::string &name,
return
this
->
GetDim
(
names
[
idx
]);
}
void
InferShapeContext
::
SetOutputDim
(
const
std
::
string
&
name
,
const
DDim
&
dim
)
{
auto
&
arg_names
=
Outputs
(
name
);
PADDLE_ENFORCE_EQ
(
arg_names
.
size
(),
1UL
,
"Output(%s) shoudl holds one element, but now it holds %d"
,
name
,
arg_names
.
size
());
SetDim
(
arg_names
[
0
],
dim
);
}
void
InferShapeContext
::
SetOutputsDim
(
const
std
::
string
&
name
,
const
std
::
vector
<
framework
::
DDim
>
&
dims
)
{
auto
&
names
=
Outputs
(
name
);
SetDims
(
names
,
dims
);
}
std
::
vector
<
framework
::
DDim
>
InferShapeContext
::
GetDims
(
std
::
vector
<
DDim
>
InferShapeContext
::
GetDims
(
const
std
::
vector
<
std
::
string
>
&
names
)
const
{
std
::
vector
<
framework
::
DDim
>
ret
;
ret
.
reserve
(
names
.
size
());
...
...
@@ -45,7 +61,6 @@ std::vector<framework::DDim> InferShapeContext::GetDims(
[
this
](
const
std
::
string
&
name
)
{
return
this
->
GetDim
(
name
);
});
return
ret
;
}
void
InferShapeContext
::
SetDims
(
const
std
::
vector
<
std
::
string
>
&
names
,
const
std
::
vector
<
framework
::
DDim
>
&
dims
)
{
size_t
length
=
names
.
size
();
...
...
paddle/framework/shape_inference.h
浏览文件 @
0575fd46
...
...
@@ -35,12 +35,12 @@ class InferShapeContext {
virtual
bool
HasInputs
(
const
std
::
string
&
name
)
const
=
0
;
virtual
bool
HasOutputs
(
const
std
::
string
&
name
)
const
=
0
;
virtual
framework
::
DDim
GetInputDim
(
const
std
::
string
&
name
)
const
=
0
;
framework
::
DDim
GetInputDim
(
const
std
::
string
&
name
)
const
;
std
::
vector
<
framework
::
DDim
>
GetInputsDim
(
const
std
::
string
&
name
)
const
;
DDim
GetInputsElementDim
(
const
std
::
string
&
name
,
int
idx
)
const
;
v
irtual
void
SetOutputDim
(
const
std
::
string
&
name
,
const
DDim
&
dim
)
=
0
;
v
oid
SetOutputDim
(
const
std
::
string
&
name
,
const
DDim
&
dim
)
;
void
SetOutputsDim
(
const
std
::
string
&
name
,
const
std
::
vector
<
framework
::
DDim
>
&
dims
);
...
...
@@ -63,9 +63,7 @@ class InferShapeContext {
virtual
framework
::
DDim
GetDim
(
const
std
::
string
&
name
)
const
=
0
;
virtual
void
SetDim
(
const
std
::
string
&
name
,
const
framework
::
DDim
&
dim
)
=
0
;
std
::
vector
<
framework
::
DDim
>
GetDims
(
const
std
::
vector
<
std
::
string
>
&
names
)
const
;
std
::
vector
<
DDim
>
GetDims
(
const
std
::
vector
<
std
::
string
>
&
names
)
const
;
std
::
vector
<
proto
::
VarDesc
::
VarType
>
GetVarTypes
(
const
std
::
vector
<
std
::
string
>
&
names
)
const
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录