Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
86e58b23
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看板
未验证
提交
86e58b23
编写于
11月 08, 2017
作者:
C
chengduo
提交者:
GitHub
11月 08, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5457 from chengduoZH/fix_pool_attr_name
fix_pool_op_attr_name
上级
870650d8
cdf5e871
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
42 addition
and
41 deletion
+42
-41
paddle/operators/pool_cudnn_op.cu
paddle/operators/pool_cudnn_op.cu
+4
-4
paddle/operators/pool_op.cc
paddle/operators/pool_op.cc
+16
-15
paddle/operators/pool_op.h
paddle/operators/pool_op.h
+4
-4
paddle/operators/pool_with_index_op.cc
paddle/operators/pool_with_index_op.cc
+9
-9
paddle/operators/pool_with_index_op.h
paddle/operators/pool_with_index_op.h
+2
-2
python/paddle/v2/framework/layers.py
python/paddle/v2/framework/layers.py
+2
-2
python/paddle/v2/framework/tests/test_pool2d_op.py
python/paddle/v2/framework/tests/test_pool2d_op.py
+2
-2
python/paddle/v2/framework/tests/test_pool3d_op.py
python/paddle/v2/framework/tests/test_pool3d_op.py
+2
-2
python/paddle/v2/framework/tests/test_pool_max_op.py
python/paddle/v2/framework/tests/test_pool_max_op.py
+1
-1
未找到文件。
paddle/operators/pool_cudnn_op.cu
浏览文件 @
86e58b23
...
...
@@ -37,11 +37,11 @@ class PoolCudnnOpKernel : public framework::OpKernel<T> {
const
T
*
input_data
=
input
->
data
<
T
>
();
T
*
output_data
=
output
->
mutable_data
<
T
>
(
ctx
.
GetPlace
());
std
::
string
pooling_type
=
ctx
.
Attr
<
std
::
string
>
(
"pooling
T
ype"
);
std
::
string
pooling_type
=
ctx
.
Attr
<
std
::
string
>
(
"pooling
_t
ype"
);
std
::
vector
<
int
>
ksize
=
ctx
.
Attr
<
std
::
vector
<
int
>>
(
"ksize"
);
std
::
vector
<
int
>
strides
=
ctx
.
Attr
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
paddings
=
ctx
.
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
if
(
ctx
.
Attr
<
bool
>
(
"global
P
ooling"
))
{
if
(
ctx
.
Attr
<
bool
>
(
"global
_p
ooling"
))
{
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
{
paddings
[
i
]
=
0
;
ksize
[
i
]
=
static_cast
<
int
>
(
input
->
dims
()[
i
+
2
]);
...
...
@@ -92,12 +92,12 @@ class PoolCudnnGradOpKernel : public framework::OpKernel<T> {
ctx
.
Input
<
Tensor
>
(
framework
::
GradVarName
(
"Out"
));
Tensor
*
input_grad
=
ctx
.
Output
<
Tensor
>
(
framework
::
GradVarName
(
"X"
));
std
::
string
pooling_type
=
ctx
.
Attr
<
std
::
string
>
(
"pooling
T
ype"
);
std
::
string
pooling_type
=
ctx
.
Attr
<
std
::
string
>
(
"pooling
_t
ype"
);
std
::
vector
<
int
>
ksize
=
ctx
.
Attr
<
std
::
vector
<
int
>>
(
"ksize"
);
std
::
vector
<
int
>
strides
=
ctx
.
Attr
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
paddings
=
ctx
.
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
if
(
ctx
.
Attr
<
bool
>
(
"global
P
ooling"
))
{
if
(
ctx
.
Attr
<
bool
>
(
"global
_p
ooling"
))
{
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
{
paddings
[
i
]
=
0
;
ksize
[
i
]
=
static_cast
<
int
>
(
input
->
dims
()[
i
+
2
]);
...
...
paddle/operators/pool_op.cc
浏览文件 @
86e58b23
...
...
@@ -29,7 +29,7 @@ void PoolOp::InferShape(framework::InferShapeContext *ctx) const {
auto
in_x_dims
=
ctx
->
GetInputDim
(
"X"
);
std
::
string
pooling_type
=
ctx
->
Attrs
().
Get
<
std
::
string
>
(
"pooling
T
ype"
);
std
::
string
pooling_type
=
ctx
->
Attrs
().
Get
<
std
::
string
>
(
"pooling
_t
ype"
);
std
::
vector
<
int
>
ksize
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"ksize"
);
std
::
vector
<
int
>
strides
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
paddings
=
ctx
->
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"paddings"
);
...
...
@@ -37,7 +37,7 @@ void PoolOp::InferShape(framework::InferShapeContext *ctx) const {
PADDLE_ENFORCE
(
in_x_dims
.
size
()
==
4
||
in_x_dims
.
size
()
==
5
,
"Pooling intput should be 4-D or 5-D tensor."
);
if
(
ctx
->
Attrs
().
Get
<
bool
>
(
"global
P
ooling"
))
{
if
(
ctx
->
Attrs
().
Get
<
bool
>
(
"global
_p
ooling"
))
{
ksize
.
resize
(
static_cast
<
size_t
>
(
in_x_dims
.
size
())
-
2
);
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
{
paddings
[
i
]
=
0
;
...
...
@@ -83,20 +83,20 @@ Pool2dOpMaker::Pool2dOpMaker(framework::OpProto *proto,
"H is the height of the feature, "
"and W is the width of the feature."
);
AddAttr
<
std
::
string
>
(
"pooling
T
ype"
,
AddAttr
<
std
::
string
>
(
"pooling
_t
ype"
,
"(string), pooling type, can be
\"
max
\"
for max-pooling "
"and
\"
avg
\"
for average-pooling."
)
.
InEnum
({
"max"
,
"avg"
});
AddAttr
<
std
::
vector
<
int
>>
(
"ksize"
,
"(vector<int>) The pooling window "
"size(height, width) of the pooling operator. "
"If global
P
ooling = true, ksize and paddings will "
"If global
_p
ooling = true, ksize and paddings will "
"be ignored."
);
// TODO(Chengduo): Add checker.
// (Currently,
// TypedAttrChecker don't support vector type.)
AddAttr
<
bool
>
(
"global
P
ooling"
,
AddAttr
<
bool
>
(
"global
_p
ooling"
,
"(bool, default false) Whether to use the global pooling. "
"If global
P
ooling = true, ksize and paddings will be ignored."
)
"If global
_p
ooling = true, ksize and paddings will be ignored."
)
.
SetDefault
(
false
);
AddAttr
<
std
::
vector
<
int
>>
(
"strides"
,
"(vector<int>, default {1, 1}), strides(height, "
...
...
@@ -107,7 +107,7 @@ Pool2dOpMaker::Pool2dOpMaker(framework::OpProto *proto,
"paddings"
,
"(vector<int>, defalut {0,0}), paddings(height, width) of pooling "
"operator."
"If global
P
ooling = true, paddings and ksize will be ignored."
)
"If global
_p
ooling = true, paddings and ksize will be ignored."
)
.
SetDefault
({
0
,
0
});
// TODO(Chengduo): Add checker. (Currently,
// TypedAttrChecker don't support vector type.)
...
...
@@ -115,7 +115,7 @@ Pool2dOpMaker::Pool2dOpMaker(framework::OpProto *proto,
Pool2d Operator.
The pooling2d operation calculates the output based on
the input, pooling
T
ype and ksize, strides, paddings parameters.
the input, pooling
_t
ype and ksize, strides, paddings parameters.
Input(X) and output(Out) are in NCHW format, where N is batch size, C is the
number of channels, H is the height of the feature, and W is the width of the feature.
Parameters(ksize, strides, paddings) are two elements.
...
...
@@ -152,7 +152,7 @@ Pool3dOpMaker::Pool3dOpMaker(framework::OpProto *proto,
"the number of channels, and D, H and W is the depth, height and "
"width of the feature, respectively."
);
AddAttr
<
std
::
string
>
(
"pooling
T
ype"
,
AddAttr
<
std
::
string
>
(
"pooling
_t
ype"
,
"(string) Pooling type, can be
\"
max
\"
for max-pooling "
"and
\"
avg
\"
for average-pooling."
)
.
InEnum
({
"max"
,
"avg"
});
...
...
@@ -160,13 +160,14 @@ Pool3dOpMaker::Pool3dOpMaker(framework::OpProto *proto,
"ksize"
,
"(vector<int>) The pooling window size(depth, height, "
"width) of pooling operator. "
"If global
P
ooling = true, ksize and paddings will "
"If global
_p
ooling = true, ksize and paddings will "
"be ignored."
);
// TODO(Chengduo): Add checker.
// (Currently,
// TypedAttrChecker don't support vector type.)
AddAttr
<
bool
>
(
"globalPooling"
,
"(bool, default false) Whether to use the global pooling. "
"If globalPooling = true, ksize and paddings wille be ignored."
)
AddAttr
<
bool
>
(
"global_pooling"
,
"(bool, default false) Whether to use the global pooling. "
"If global_pooling = true, ksize and paddings wille be ignored."
)
.
SetDefault
(
false
);
AddAttr
<
std
::
vector
<
int
>>
(
"strides"
,
...
...
@@ -178,7 +179,7 @@ Pool3dOpMaker::Pool3dOpMaker(framework::OpProto *proto,
"paddings"
,
"(vector<int>, defalut {0,0,0}), paddings(depth, height, "
"width) of pooling operator. "
"If global
P
ooling = true, ksize and paddings will be ignored."
)
"If global
_p
ooling = true, ksize and paddings will be ignored."
)
.
SetDefault
({
0
,
0
,
0
});
// TODO(Chengduo): Add checker. (Currently,
// TypedAttrChecker don't support vector type.)
...
...
@@ -186,7 +187,7 @@ Pool3dOpMaker::Pool3dOpMaker(framework::OpProto *proto,
Pool3d Operator.
The pooling3d operation calculates the output based on
the input, pooling
T
ype, ksize, strides, and paddings parameters.
the input, pooling
_t
ype, ksize, strides, and paddings parameters.
Input(X) and output(Out) are in NCDHW format, where N is batch
size, C is the number of channels, and D, H and W are the depth, height and
width of the feature, respectively. Parameters(ksize, strides, paddings)
...
...
paddle/operators/pool_op.h
浏览文件 @
86e58b23
...
...
@@ -57,11 +57,11 @@ class PoolKernel : public framework::OpKernel<T> {
const
Tensor
*
in_x
=
context
.
Input
<
Tensor
>
(
"X"
);
Tensor
*
out
=
context
.
Output
<
Tensor
>
(
"Out"
);
std
::
string
pooling_type
=
context
.
Attr
<
std
::
string
>
(
"pooling
T
ype"
);
std
::
string
pooling_type
=
context
.
Attr
<
std
::
string
>
(
"pooling
_t
ype"
);
std
::
vector
<
int
>
ksize
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"ksize"
);
std
::
vector
<
int
>
strides
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
paddings
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
if
(
context
.
Attr
<
bool
>
(
"global
P
ooling"
))
{
if
(
context
.
Attr
<
bool
>
(
"global
_p
ooling"
))
{
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
{
paddings
[
i
]
=
0
;
ksize
[
i
]
=
static_cast
<
int
>
(
in_x
->
dims
()[
i
+
2
]);
...
...
@@ -119,12 +119,12 @@ class PoolGradKernel : public framework::OpKernel<T> {
context
.
Input
<
Tensor
>
(
framework
::
GradVarName
(
"Out"
));
Tensor
*
in_x_grad
=
context
.
Output
<
Tensor
>
(
framework
::
GradVarName
(
"X"
));
std
::
string
pooling_type
=
context
.
Attr
<
std
::
string
>
(
"pooling
T
ype"
);
std
::
string
pooling_type
=
context
.
Attr
<
std
::
string
>
(
"pooling
_t
ype"
);
std
::
vector
<
int
>
ksize
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"ksize"
);
std
::
vector
<
int
>
strides
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
paddings
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
if
(
context
.
Attr
<
bool
>
(
"global
P
ooling"
))
{
if
(
context
.
Attr
<
bool
>
(
"global
_p
ooling"
))
{
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
{
paddings
[
i
]
=
0
;
ksize
[
i
]
=
static_cast
<
int
>
(
in_x
->
dims
()[
i
+
2
]);
...
...
paddle/operators/pool_with_index_op.cc
浏览文件 @
86e58b23
...
...
@@ -44,7 +44,7 @@ class MaxPoolWithIndexOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE
(
in_x_dims
.
size
()
==
4
||
in_x_dims
.
size
()
==
5
,
"Pooling intput should be 4-D or 5-D tensor."
);
if
(
ctx
->
Attrs
().
Get
<
bool
>
(
"global
P
ooling"
))
{
if
(
ctx
->
Attrs
().
Get
<
bool
>
(
"global
_p
ooling"
))
{
ksize
.
resize
(
static_cast
<
size_t
>
(
in_x_dims
.
size
())
-
2
);
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
{
paddings
[
i
]
=
0
;
...
...
@@ -110,14 +110,14 @@ class MaxPool2dWithIndexOpMaker : public framework::OpProtoAndCheckerMaker {
AddAttr
<
std
::
vector
<
int
>>
(
"ksize"
,
"(vector<int>) The pooling window size(height, "
"width) of pooling operator. "
"If global
P
ooling = true, ksize and paddings "
"If global
_p
ooling = true, ksize and paddings "
"will be ignored."
);
// TODO(Chengduo): Add
// checker. (Currently,
// TypedAttrChecker don't support vector type.)
AddAttr
<
bool
>
(
"global
P
ooling"
,
"global
_p
ooling"
,
"(bool, default false) Whether to use the global pooling. "
"If global
P
ooling = true, ksize and paddings will be ignored."
)
"If global
_p
ooling = true, ksize and paddings will be ignored."
)
.
SetDefault
(
false
);
AddAttr
<
std
::
vector
<
int
>>
(
"strides"
,
"(vector<int>, default {1, 1}), strides(height, "
...
...
@@ -128,7 +128,7 @@ class MaxPool2dWithIndexOpMaker : public framework::OpProtoAndCheckerMaker {
"paddings"
,
"(vector<int>, defalut {0, 0}), paddings(height, width) of pooling "
"operator. "
"If global
P
ooling = true, paddings and will be ignored."
)
"If global
_p
ooling = true, paddings and will be ignored."
)
.
SetDefault
({
0
,
0
});
// TODO(Chengduo): Add checker. (Currently,
// TypedAttrChecker don't support vector type.)
...
...
@@ -188,14 +188,14 @@ class MaxPool3dWithIndexOpMaker : public framework::OpProtoAndCheckerMaker {
AddAttr
<
std
::
vector
<
int
>>
(
"ksize"
,
"(vector<int>) The pooling window size(depth, "
"height, width) of pooling operator. "
"If global
P
ooling = true, ksize and paddings "
"If global
_p
ooling = true, ksize and paddings "
"will be ignored."
);
// TODO(Chengduo): Add
// checker. (Currently,
// TypedAttrChecker don't support vector type.)
AddAttr
<
bool
>
(
"global
P
ooling"
,
"global
_p
ooling"
,
"(bool, default false) Whether to use the global pooling. "
"If global
P
ooling = true, ksize and paddings will be ignored."
)
"If global
_p
ooling = true, ksize and paddings will be ignored."
)
.
SetDefault
(
false
);
AddAttr
<
std
::
vector
<
int
>>
(
"strides"
,
"(vector<int>, default {1,1,1}), strides(depth, "
...
...
@@ -206,7 +206,7 @@ class MaxPool3dWithIndexOpMaker : public framework::OpProtoAndCheckerMaker {
"paddings"
,
"(vector, defalut {0,0,0}), paddings(depth, "
"height, width) of pooling operator. "
"If global
P
ooling = true, paddings and ksize will be ignored."
)
"If global
_p
ooling = true, paddings and ksize will be ignored."
)
.
SetDefault
({
0
,
0
,
0
});
// TODO(Chengduo): Add checker. (Currently,
// TypedAttrChecker don't support vector type.)
...
...
paddle/operators/pool_with_index_op.h
浏览文件 @
86e58b23
...
...
@@ -35,7 +35,7 @@ class MaxPoolWithIndexKernel : public framework::OpKernel<T> {
std
::
vector
<
int
>
ksize
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"ksize"
);
std
::
vector
<
int
>
strides
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
paddings
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
if
(
context
.
Attr
<
bool
>
(
"global
P
ooling"
))
{
if
(
context
.
Attr
<
bool
>
(
"global
_p
ooling"
))
{
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
{
paddings
[
i
]
=
0
;
ksize
[
i
]
=
static_cast
<
int
>
(
in_x
->
dims
()[
i
+
2
]);
...
...
@@ -72,7 +72,7 @@ class MaxPoolWithIndexGradKernel : public framework::OpKernel<T> {
std
::
vector
<
int
>
ksize
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"ksize"
);
std
::
vector
<
int
>
strides
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"strides"
);
std
::
vector
<
int
>
paddings
=
context
.
Attr
<
std
::
vector
<
int
>>
(
"paddings"
);
if
(
context
.
Attr
<
bool
>
(
"global
P
ooling"
))
{
if
(
context
.
Attr
<
bool
>
(
"global
_p
ooling"
))
{
for
(
size_t
i
=
0
;
i
<
ksize
.
size
();
++
i
)
{
paddings
[
i
]
=
0
;
ksize
[
i
]
=
static_cast
<
int
>
(
in_x_grad
->
dims
()[
i
+
2
]);
...
...
python/paddle/v2/framework/layers.py
浏览文件 @
86e58b23
...
...
@@ -440,9 +440,9 @@ def pool2d(input,
inputs
=
{
"X"
:
input
},
outputs
=
{
"Out"
:
pool_out
},
attrs
=
{
"pooling
T
ype"
:
pool_type
,
"pooling
_t
ype"
:
pool_type
,
"ksize"
:
pool_size
,
"global
P
ooling"
:
global_pooling
,
"global
_p
ooling"
:
global_pooling
,
"strides"
:
pool_stride
,
"paddings"
:
pool_padding
})
...
...
python/paddle/v2/framework/tests/test_pool2d_op.py
浏览文件 @
86e58b23
...
...
@@ -61,8 +61,8 @@ class TestPool2d_Op(OpTest):
'strides'
:
self
.
strides
,
'paddings'
:
self
.
paddings
,
'ksize'
:
self
.
ksize
,
'pooling
T
ype'
:
self
.
pool_type
,
'global
P
ooling'
:
self
.
global_pool
,
'pooling
_t
ype'
:
self
.
pool_type
,
'global
_p
ooling'
:
self
.
global_pool
,
}
self
.
outputs
=
{
'Out'
:
output
.
astype
(
'float32'
)}
...
...
python/paddle/v2/framework/tests/test_pool3d_op.py
浏览文件 @
86e58b23
...
...
@@ -67,8 +67,8 @@ class TestPool3d_Op(OpTest):
'strides'
:
self
.
strides
,
'paddings'
:
self
.
paddings
,
'ksize'
:
self
.
ksize
,
'pooling
T
ype'
:
self
.
pool_type
,
'global
P
ooling'
:
self
.
global_pool
,
'pooling
_t
ype'
:
self
.
pool_type
,
'global
_p
ooling'
:
self
.
global_pool
,
}
self
.
outputs
=
{
'Out'
:
output
.
astype
(
'float32'
)}
...
...
python/paddle/v2/framework/tests/test_pool_max_op.py
浏览文件 @
86e58b23
...
...
@@ -86,7 +86,7 @@ class TestMaxPoolWithIndex_Op(OpTest):
'strides'
:
self
.
strides
,
'paddings'
:
self
.
paddings
,
'ksize'
:
self
.
ksize
,
'global
P
ooling'
:
self
.
global_pool
,
'global
_p
ooling'
:
self
.
global_pool
,
}
self
.
inputs
=
{
'X'
:
input
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录