Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
5a2d6d6b
P
Paddle
项目概览
机器未来
/
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看板
未验证
提交
5a2d6d6b
编写于
4月 18, 2019
作者:
G
Guo Sheng
提交者:
GitHub
4月 18, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #16956 from guoshengCS/cherry-pick-infer-shape
cherry-pick #16898 and #16902 to release/1.4
上级
aa056e9e
a7f3450d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
21 addition
and
8 deletion
+21
-8
paddle/fluid/operators/controlflow/logical_op.cc
paddle/fluid/operators/controlflow/logical_op.cc
+10
-2
paddle/fluid/operators/gru_op.cc
paddle/fluid/operators/gru_op.cc
+5
-2
paddle/fluid/operators/lstm_unit_op.cc
paddle/fluid/operators/lstm_unit_op.cc
+6
-4
未找到文件。
paddle/fluid/operators/controlflow/logical_op.cc
浏览文件 @
5a2d6d6b
...
...
@@ -71,8 +71,16 @@ class BinaryLogicalOpInferShape : public framework::InferShapeBase {
"Input(Y) of %s operator must not be null"
,
comment
.
type
);
auto
dim_x
=
context
->
GetInputDim
(
"X"
);
auto
dim_y
=
context
->
GetInputDim
(
"Y"
);
PADDLE_ENFORCE_EQ
(
framework
::
product
(
dim_x
),
framework
::
product
(
dim_y
),
"The number of elements in X and Y should be same"
);
int
product_x
=
framework
::
product
(
dim_x
);
int
product_y
=
framework
::
product
(
dim_y
);
bool
check
=
context
->
IsRuntime
()
||
(
product_x
>=
0
&&
product_y
>=
0
);
if
(
check
)
{
PADDLE_ENFORCE_EQ
(
product_x
,
product_y
,
"The number of elements in X and Y should be same, %d != %d"
,
product_x
,
product_y
);
}
context
->
SetOutputDim
(
"Out"
,
context
->
GetInputDim
(
"X"
));
context
->
ShareLoD
(
"X"
,
"Out"
);
...
...
paddle/fluid/operators/gru_op.cc
浏览文件 @
5a2d6d6b
...
...
@@ -47,8 +47,11 @@ class GRUOp : public framework::OperatorWithKernel {
auto
weight_dims
=
ctx
->
GetInputDim
(
"Weight"
);
int
input_size
=
input_dims
[
1
];
int
frame_size
=
weight_dims
[
0
];
PADDLE_ENFORCE_EQ
(
input_size
,
frame_size
*
3
,
"The input_size must be 3 times of frame_size in GRUOp."
);
if
(
ctx
->
IsRuntime
())
{
PADDLE_ENFORCE_EQ
(
input_size
,
frame_size
*
3
,
"The input_size must be 3 times of frame_size in GRUOp."
);
}
PADDLE_ENFORCE_EQ
(
weight_dims
[
1
],
frame_size
*
3
,
"The shape of Weight matrix must be [frame_size, frame_size * 3]."
);
...
...
paddle/fluid/operators/lstm_unit_op.cc
浏览文件 @
5a2d6d6b
...
...
@@ -34,10 +34,12 @@ class LstmUnitOp : public framework::OperatorWithKernel {
auto
c_prev_dims
=
ctx
->
GetInputDim
(
"C_prev"
);
PADDLE_ENFORCE_EQ
(
x_dims
.
size
(),
2
,
"Input(X)'s rank must be 2."
);
PADDLE_ENFORCE_EQ
(
x_dims
[
0
],
c_prev_dims
[
0
],
"Batch size of inputs and states must be equal"
);
PADDLE_ENFORCE_EQ
(
x_dims
[
1
],
c_prev_dims
[
1
]
*
4
,
"Dimension of FC should equal to prev state * 4"
);
if
(
ctx
->
IsRuntime
())
{
PADDLE_ENFORCE_EQ
(
x_dims
[
0
],
c_prev_dims
[
0
],
"Batch size of inputs and states must be equal"
);
PADDLE_ENFORCE_EQ
(
x_dims
[
1
],
c_prev_dims
[
1
]
*
4
,
"Dimension of FC should equal to prev state * 4"
);
}
int
b_size
=
c_prev_dims
[
0
];
// batch size
int
s_dim
=
c_prev_dims
[
1
];
// state dim
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录