Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
dc8eca82
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
dc8eca82
编写于
12月 26, 2018
作者:
T
tangwei12
提交者:
GitHub
12月 26, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code style fix, test=develop (#15045)
* code style fix, test=develop
上级
55e3c651
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
16 deletion
+17
-16
paddle/fluid/framework/attribute.h
paddle/fluid/framework/attribute.h
+14
-13
paddle/fluid/framework/op_desc.cc
paddle/fluid/framework/op_desc.cc
+1
-1
paddle/fluid/framework/op_registry.cc
paddle/fluid/framework/op_registry.cc
+1
-1
paddle/fluid/operators/sequence_ops/sequence_mask_op.h
paddle/fluid/operators/sequence_ops/sequence_mask_op.h
+1
-1
未找到文件。
paddle/fluid/framework/attribute.h
浏览文件 @
dc8eca82
...
...
@@ -165,7 +165,7 @@ template <typename T>
class
GreaterThanChecker
{
public:
explicit
GreaterThanChecker
(
T
lower_bound
)
:
lower_bound_
(
lower_bound
)
{}
void
operator
()(
T
&
value
)
const
{
void
operator
()(
const
T
&
value
)
const
{
PADDLE_ENFORCE
(
value
>
lower_bound_
,
"larger_than check fails."
);
}
...
...
@@ -177,7 +177,7 @@ template <typename T>
class
EqualGreaterThanChecker
{
public:
explicit
EqualGreaterThanChecker
(
T
lower_bound
)
:
lower_bound_
(
lower_bound
)
{}
void
operator
()(
T
&
value
)
const
{
void
operator
()(
const
T
&
value
)
const
{
PADDLE_ENFORCE_GE
(
value
,
lower_bound_
,
"equal_larger_than check fails."
);
}
...
...
@@ -193,7 +193,7 @@ class DefaultValueSetter {
public:
explicit
DefaultValueSetter
(
T
default_value
)
:
default_value_
(
default_value
)
{}
void
operator
()(
T
&
value
)
const
{
value
=
default_value_
;
}
// NOLINT
void
operator
()(
T
*
value
)
const
{
*
value
=
default_value_
;
}
private:
T
default_value_
;
...
...
@@ -203,7 +203,7 @@ template <typename T>
class
EnumInContainer
{
public:
explicit
EnumInContainer
(
const
std
::
unordered_set
<
T
>&
c
)
:
container_
(
c
)
{}
void
operator
()(
T
&
val
)
const
{
void
operator
()(
const
T
&
val
)
const
{
PADDLE_ENFORCE
(
container_
.
find
(
val
)
!=
container_
.
end
(),
"Value %s is not in enum container %s"
,
val
,
ContainerDebugString
());
...
...
@@ -232,7 +232,8 @@ class EnumInContainer {
// an attribute can have more than one limits
template
<
typename
T
>
class
TypedAttrChecker
{
typedef
std
::
function
<
void
(
T
&
)
>
ValueChecker
;
typedef
std
::
function
<
void
(
T
*
)
>
DefaultValueChecker
;
typedef
std
::
function
<
void
(
const
T
&
)
>
ValueChecker
;
public:
explicit
TypedAttrChecker
(
const
std
::
string
&
attr_name
)
...
...
@@ -268,17 +269,17 @@ class TypedAttrChecker {
return
*
this
;
}
void
operator
()(
AttributeMap
&
attr_map
)
const
{
// NOLINT
if
(
!
attr_map
.
count
(
attr_name_
))
{
void
operator
()(
AttributeMap
*
attr_map
)
const
{
if
(
!
attr_map
->
count
(
attr_name_
))
{
// user do not set this attr
PADDLE_ENFORCE
(
!
default_value_setter_
.
empty
(),
"Attribute '%s' is required!"
,
attr_name_
);
// default_value_setter_ has no more than one element
T
val
;
(
default_value_setter_
[
0
])(
val
);
attr_map
[
attr_name_
]
=
val
;
(
default_value_setter_
[
0
])(
&
val
);
(
*
attr_map
)
[
attr_name_
]
=
val
;
}
Attribute
&
attr
=
attr_map
.
at
(
attr_name_
);
Attribute
&
attr
=
attr_map
->
at
(
attr_name_
);
ExtractAttribute
<
T
>
extract_attr
(
attr_name_
);
T
*
attr_value
=
extract_attr
(
attr
);
for
(
const
auto
&
checker
:
value_checkers_
)
{
...
...
@@ -289,12 +290,12 @@ class TypedAttrChecker {
private:
std
::
string
attr_name_
;
std
::
vector
<
ValueChecker
>
value_checkers_
;
std
::
vector
<
ValueChecker
>
default_value_setter_
;
std
::
vector
<
Default
ValueChecker
>
default_value_setter_
;
};
// check whether op's all attributes fit their own limits
class
OpAttrChecker
{
typedef
std
::
function
<
void
(
AttributeMap
&
)
>
AttrChecker
;
typedef
std
::
function
<
void
(
AttributeMap
*
)
>
AttrChecker
;
public:
template
<
typename
T
>
...
...
@@ -304,7 +305,7 @@ class OpAttrChecker {
return
*
(
checker
.
target
<
TypedAttrChecker
<
T
>>
());
}
void
Check
(
AttributeMap
&
attr_map
)
const
{
// NOLINT
void
Check
(
AttributeMap
*
attr_map
)
const
{
for
(
const
auto
&
checker
:
attr_checkers_
)
{
checker
(
attr_map
);
}
...
...
paddle/fluid/framework/op_desc.cc
浏览文件 @
dc8eca82
...
...
@@ -643,7 +643,7 @@ void OpDesc::CheckAttrs() {
// not by users.
return
;
}
checker
->
Check
(
attrs_
);
checker
->
Check
(
&
attrs_
);
}
void
OpDesc
::
InferShape
(
const
BlockDesc
&
block
)
const
{
...
...
paddle/fluid/framework/op_registry.cc
浏览文件 @
dc8eca82
...
...
@@ -24,7 +24,7 @@ std::unique_ptr<OperatorBase> OpRegistry::CreateOp(
const
VariableNameMap
&
outputs
,
AttributeMap
attrs
)
{
auto
&
info
=
OpInfoMap
::
Instance
().
Get
(
type
);
if
(
info
.
Checker
()
!=
nullptr
)
{
info
.
Checker
()
->
Check
(
attrs
);
info
.
Checker
()
->
Check
(
&
attrs
);
}
auto
op
=
info
.
Creator
()(
type
,
inputs
,
outputs
,
attrs
);
return
std
::
unique_ptr
<
OperatorBase
>
(
op
);
...
...
paddle/fluid/operators/sequence_ops/sequence_mask_op.h
浏览文件 @
dc8eca82
...
...
@@ -52,7 +52,7 @@ class SequenceMaskOpMaker : public framework::OpProtoAndCheckerMaker {
"The maximum length of the sequence. If maxlen < 0, maxlen "
"= max(Input(X))."
)
.
SetDefault
(
-
1
)
.
AddCustomChecker
([](
int
&
v
)
{
.
AddCustomChecker
([](
const
int
&
v
)
{
PADDLE_ENFORCE
(
v
<
0
||
v
>=
1
,
"Attr(maxlen) must be less than 0 or larger than 1"
);
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录