Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
c7b34788
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c7b34788
编写于
9月 11, 2017
作者:
W
wanghaoshuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix variable names and comments
上级
d960cbdc
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
14 addition
and
10 deletion
+14
-10
paddle/operators/pad_op.cc
paddle/operators/pad_op.cc
+14
-10
未找到文件。
paddle/operators/pad_op.cc
浏览文件 @
c7b34788
...
...
@@ -25,16 +25,16 @@ class PadOp : public framework::OperatorWithKernel {
protected:
void
InferShape
(
const
framework
::
InferShapeContext
&
ctx
)
const
override
{
auto
dim0
=
ctx
.
Input
<
Tensor
>
(
"X"
)
->
dims
();
auto
paddings
=
Get
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
PADDLE_ENFORCE_EQ
(
dim0
.
size
(),
(
int
)(
paddings
.
size
()
/
2
),
auto
x_dim
=
ctx
.
Input
<
Tensor
>
(
"X"
)
->
dims
();
auto
paddings
=
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
PADDLE_ENFORCE_EQ
(
x_dim
.
size
()
*
2
,
int
(
paddings
.
size
()
),
"Size of paddings should be equal to 2 * dimension size "
"of input tensor."
);
std
::
vector
<
int
>
dim1
(
dim0
.
size
());
for
(
int
i
=
0
;
i
<
dim0
.
size
();
++
i
)
{
dim1
[
i
]
=
dim0
[
i
]
+
paddings
[
i
*
2
]
+
paddings
[
i
*
2
+
1
];
std
::
vector
<
int
>
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
];
}
ctx
.
Output
<
Tensor
>
(
"Out"
)
->
Resize
(
paddle
::
framework
::
make_ddim
(
dim1
));
ctx
.
Output
<
Tensor
>
(
"Out"
)
->
Resize
(
framework
::
make_ddim
(
out_dims
));
}
};
...
...
@@ -42,8 +42,12 @@ class PadOpMaker : public framework::OpProtoAndCheckerMaker {
public:
PadOpMaker
(
framework
::
OpProto
*
proto
,
framework
::
OpAttrChecker
*
op_checker
)
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"The input of pad op."
);
AddOutput
(
"Out"
,
"The output of pad op."
);
AddInput
(
"X"
,
"The input of pad op. "
"The input should be a k-D tensor(k > 0 and k < 7)"
);
AddOutput
(
"Out"
,
"The output of pad op."
"A tensor with the same shape as X."
);
AddComment
(
R"DOC(
Pad input into output, as specified by paddings and pad_value. The input should be a k-D tensor(k > 0 and k < 7). As an example:
...
...
@@ -75,7 +79,7 @@ Out = [[0, 1, 2, 0, 0]
" 2 * dimension size of input tensor."
);
AddAttr
<
float
>
(
"pad_value"
,
"(float) default to 0; "
"The value to
be padded into tensor.
"
)
"The value to
fill padded areas.
"
)
.
SetDefault
(
0.0
f
);
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录