Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
8c478b36
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2297
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8c478b36
编写于
9月 25, 2017
作者:
C
chengduoZH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix Atrr check
上级
b7285438
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
74 addition
and
7 deletion
+74
-7
paddle/operators/pool_op.cc
paddle/operators/pool_op.cc
+74
-7
未找到文件。
paddle/operators/pool_op.cc
浏览文件 @
8c478b36
...
...
@@ -101,7 +101,8 @@ class Pool2dOpMaker : public framework::OpProtoAndCheckerMaker {
"poolingType of pooling operator."
"str constant equal to 'max' or 'avg'"
);
AddAttr
<
std
::
vector
<
int
>>
(
"ksize"
,
"pooling size(height, width) of pooling operator."
);
"ksize"
,
"pooling size(height, width) of pooling operator."
)
.
AddCustomChecker
(
GreaterThanChecker_pool
({
0
,
0
}));
AddAttr
<
int
>
(
"globalPooling"
,
"whether to use the globalPooling."
...
...
@@ -112,17 +113,49 @@ class Pool2dOpMaker : public framework::OpProtoAndCheckerMaker {
AddAttr
<
std
::
vector
<
int
>>
(
"strides"
,
"strides(height, width) of pooling operator."
"default {1,1}"
)
.
SetDefault
({
1
,
1
});
.
SetDefault
({
1
,
1
})
.
AddCustomChecker
(
GreaterThanChecker_pool
({
0
,
0
}));
AddAttr
<
std
::
vector
<
int
>>
(
"paddings"
,
"paddings(height, width) of pooling operator."
"default {0,0}"
)
.
SetDefault
({
0
,
0
})
;
.
SetDefault
({
0
,
0
})
.
AddCustomChecker
(
EqualGreaterThanChecker_pool
({
0
,
0
}));
AddComment
(
R"DOC(
The pooling2d operation calculates the output based on
the input, poolingType and ksize, strides, paddings parameters.
)DOC"
);
}
private:
struct
GreaterThanChecker_pool
{
public:
explicit
GreaterThanChecker_pool
(
std
::
vector
<
int
>
lower_bound
)
:
lower_bound_
(
lower_bound
)
{}
void
operator
()(
std
::
vector
<
int
>
&
value
)
const
{
PADDLE_ENFORCE
(
value
.
size
()
==
lower_bound_
.
size
(),
"equal check fails."
);
for
(
size_t
i
=
0
;
i
<
value
.
size
();
++
i
)
{
PADDLE_ENFORCE
(
value
[
i
]
>
lower_bound_
[
i
],
"larger_than check fails."
);
}
}
private:
std
::
vector
<
int
>
lower_bound_
;
};
struct
EqualGreaterThanChecker_pool
{
public:
explicit
EqualGreaterThanChecker_pool
(
std
::
vector
<
int
>
lower_bound
)
:
lower_bound_
(
lower_bound
)
{}
void
operator
()(
std
::
vector
<
int
>
&
value
)
const
{
PADDLE_ENFORCE
(
value
.
size
()
==
lower_bound_
.
size
(),
"equal check fails."
);
for
(
size_t
i
=
0
;
i
<
value
.
size
();
++
i
)
{
PADDLE_ENFORCE
(
value
[
i
]
>=
lower_bound_
[
i
],
"larger_than check fails."
);
}
}
private:
std
::
vector
<
int
>
lower_bound_
;
};
};
class
Pool3dOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
public:
...
...
@@ -142,7 +175,8 @@ class Pool3dOpMaker : public framework::OpProtoAndCheckerMaker {
"poolingType of pooling operator."
"str constant equal to 'max' or 'avg'"
);
AddAttr
<
std
::
vector
<
int
>>
(
"ksize"
,
"pooling size(depth, height, width) of pooling operator."
);
"ksize"
,
"pooling size(depth, height, width) of pooling operator."
)
.
AddCustomChecker
(
GreaterThanChecker_pool
({
0
,
0
,
0
}));
AddAttr
<
int
>
(
"globalPooling"
,
"whether to use the globalPooling."
...
...
@@ -154,17 +188,50 @@ class Pool3dOpMaker : public framework::OpProtoAndCheckerMaker {
"strides"
,
"strides(depth, height, width) of pooling operator."
"default {1,1,1}"
)
.
SetDefault
({
1
,
1
,
1
});
.
SetDefault
({
1
,
1
,
1
})
.
AddCustomChecker
(
GreaterThanChecker_pool
({
0
,
0
,
0
}));
AddAttr
<
std
::
vector
<
int
>>
(
"paddings"
,
"paddings(depth, height, width) of pooling operator."
"default {0,0,0}"
)
.
SetDefault
({
0
,
0
,
0
});
.
SetDefault
({
0
,
0
,
0
})
.
AddCustomChecker
(
EqualGreaterThanChecker_pool
({
0
,
0
,
0
}));
AddComment
(
R"DOC(
The pooling3d operation calculates the output based on
the input, poolingType and ksize, strides, paddings parameters.
)DOC"
);
}
private:
struct
GreaterThanChecker_pool
{
public:
explicit
GreaterThanChecker_pool
(
std
::
vector
<
int
>
lower_bound
)
:
lower_bound_
(
lower_bound
)
{}
void
operator
()(
std
::
vector
<
int
>
&
value
)
const
{
PADDLE_ENFORCE
(
value
.
size
()
==
lower_bound_
.
size
(),
"equal check fails."
);
for
(
size_t
i
=
0
;
i
<
value
.
size
();
++
i
)
{
PADDLE_ENFORCE
(
value
[
i
]
>
lower_bound_
[
i
],
"larger_than check fails."
);
}
}
private:
std
::
vector
<
int
>
lower_bound_
;
};
struct
EqualGreaterThanChecker_pool
{
public:
explicit
EqualGreaterThanChecker_pool
(
std
::
vector
<
int
>
lower_bound
)
:
lower_bound_
(
lower_bound
)
{}
void
operator
()(
std
::
vector
<
int
>
&
value
)
const
{
PADDLE_ENFORCE
(
value
.
size
()
==
lower_bound_
.
size
(),
"equal check fails."
);
for
(
size_t
i
=
0
;
i
<
value
.
size
();
++
i
)
{
PADDLE_ENFORCE
(
value
[
i
]
>=
lower_bound_
[
i
],
"larger_than check fails."
);
}
}
private:
std
::
vector
<
int
>
lower_bound_
;
};
};
}
// namespace operators
}
// namespace paddle
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录