Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
2120f075
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
提交
2120f075
编写于
4月 15, 2019
作者:
S
SunGaofeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify infer shape in pad_op.cc, pad_constant_like_op.cc. No need in psroi_pool_op.cc, crop_op.cc
上级
eb02eb94
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
10 deletion
+20
-10
paddle/fluid/operators/pad_constant_like_op.cc
paddle/fluid/operators/pad_constant_like_op.cc
+12
-2
paddle/fluid/operators/pad_op.cc
paddle/fluid/operators/pad_op.cc
+8
-8
未找到文件。
paddle/fluid/operators/pad_constant_like_op.cc
浏览文件 @
2120f075
...
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/fluid/operators/pad_constant_like_op.h"
#include <memory>
namespace
paddle
{
namespace
operators
{
...
...
@@ -38,8 +39,13 @@ class PadConstantLikeOp : public framework::OperatorWithKernel {
"The dimention of X and Y should be the same."
);
for
(
int
i
=
0
;
i
<
x_dim
.
size
();
++
i
)
{
PADDLE_ENFORCE_GE
(
x_dim
[
i
],
y_dim
[
i
]);
if
((
!
ctx
->
IsRuntime
())
&&
((
x_dim
[
i
]
==
-
1
)
||
(
y_dim
[
i
]
==
-
1
)))
{
continue
;
}
else
{
PADDLE_ENFORCE_GE
(
x_dim
[
i
],
y_dim
[
i
]);
}
}
ctx
->
SetOutputDim
(
"Out"
,
x_dim
);
ctx
->
ShareLoD
(
"X"
,
/*->*/
"Out"
);
}
...
...
@@ -162,7 +168,11 @@ class PadConstantLikeOpGrad : public framework::OperatorWithKernel {
ctx
->
ShareLoD
(
"Y"
,
/*->*/
y_grad_name
);
for
(
int
i
=
0
;
i
<
y_dim
.
size
();
++
i
)
{
PADDLE_ENFORCE_GE
(
dout_dim
[
i
],
y_dim
[
i
]);
if
((
!
ctx
->
IsRuntime
())
&&
((
dout_dim
[
i
]
==
-
1
)
||
(
y_dim
[
i
]
==
-
1
)))
{
continue
;
}
else
{
PADDLE_ENFORCE_GE
(
dout_dim
[
i
],
y_dim
[
i
]);
}
}
}
}
...
...
paddle/fluid/operators/pad_op.cc
浏览文件 @
2120f075
...
...
@@ -36,7 +36,11 @@ class PadOp : public framework::OperatorWithKernel {
"of input tensor."
);
std
::
vector
<
int64_t
>
out_dims
(
x_dim
.
size
());
for
(
int
i
=
0
;
i
<
x_dim
.
size
();
++
i
)
{
out_dims
[
i
]
=
x_dim
[
i
]
+
paddings
[
i
*
2
]
+
paddings
[
i
*
2
+
1
];
if
((
!
ctx
->
IsRuntime
())
&&
(
x_dim
[
i
]
==
-
1
))
{
out_dims
[
i
]
=
-
1
;
}
else
{
out_dims
[
i
]
=
x_dim
[
i
]
+
paddings
[
i
*
2
]
+
paddings
[
i
*
2
+
1
];
}
}
ctx
->
SetOutputDim
(
"Out"
,
framework
::
make_ddim
(
out_dims
));
if
(
out_dims
[
0
]
==
x_dim
[
0
])
{
...
...
@@ -100,18 +104,14 @@ class PadOpGrad : public framework::OperatorWithKernel {
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
auto
dout_dims
=
ctx
->
GetInputDim
(
framework
::
GradVarName
(
"Out"
));
auto
&
paddings
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"paddings"
);
for
(
int
i
=
0
;
i
<
dout_dims
.
size
();
++
i
)
{
dout_dims
[
i
]
-=
(
paddings
[
i
*
2
]
+
paddings
[
i
*
2
+
1
]);
}
auto
x_grad_name
=
framework
::
GradVarName
(
"X"
);
if
(
ctx
->
HasOutput
(
x_grad_name
))
{
auto
dout_dims
=
ctx
->
GetInputDim
(
framework
::
GradVarName
(
"Out"
));
auto
&
paddings
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"paddings"
);
for
(
int
i
=
0
;
i
<
dout_dims
.
size
();
++
i
)
{
dout_dims
[
i
]
-=
(
paddings
[
i
*
2
]
+
paddings
[
i
*
2
+
1
]);
if
(
ctx
->
IsRuntime
()
||
(
dout_dims
[
i
]
!=
-
1
))
{
dout_dims
[
i
]
-=
(
paddings
[
i
*
2
]
+
paddings
[
i
*
2
+
1
]);
}
}
ctx
->
SetOutputDim
(
x_grad_name
,
dout_dims
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录