Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
f09cb657
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
接近 2 年 前同步成功
通知
707
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看板
提交
f09cb657
编写于
8月 14, 2017
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Follow comments from WangYi
上级
ef29b522
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
48 addition
and
45 deletion
+48
-45
paddle/framework/backward_test.cc
paddle/framework/backward_test.cc
+6
-6
paddle/framework/grad_op_builder_test.cc
paddle/framework/grad_op_builder_test.cc
+6
-6
paddle/framework/op_registry.h
paddle/framework/op_registry.h
+6
-3
paddle/framework/op_registry_test.cc
paddle/framework/op_registry_test.cc
+14
-14
paddle/framework/operator_test.cc
paddle/framework/operator_test.cc
+12
-12
paddle/operators/mean_op.cc
paddle/operators/mean_op.cc
+1
-1
paddle/operators/recurrent_op.cc
paddle/operators/recurrent_op.cc
+3
-3
未找到文件。
paddle/framework/backward_test.cc
浏览文件 @
f09cb657
...
...
@@ -39,9 +39,9 @@ class RowWiseAddOpMaker : public OpProtoAndCheckerMaker {
public:
RowWiseAddOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"Input X of Add"
).
NoGradient
();
AddInput
(
"b"
,
"Bias of Add"
).
NoGradient
();
AddOutput
(
"Out"
,
"Out of Add"
).
NoGradient
();
AddInput
(
"X"
,
"Input X of Add"
).
As
NoGradient
();
AddInput
(
"b"
,
"Bias of Add"
).
As
NoGradient
();
AddOutput
(
"Out"
,
"Out of Add"
).
As
NoGradient
();
AddComment
(
"Add Op"
);
}
};
...
...
@@ -111,8 +111,8 @@ class FcOpMaker : public OpProtoAndCheckerMaker {
AddInput
(
"X"
,
"x"
);
AddInput
(
"W"
,
"w"
);
AddInput
(
"b"
,
"b"
);
AddOutput
(
"mul_result"
,
""
).
Set
Intermediate
();
AddOutput
(
"add_result"
,
""
).
Set
Intermediate
();
AddOutput
(
"mul_result"
,
""
).
As
Intermediate
();
AddOutput
(
"add_result"
,
""
).
As
Intermediate
();
AddOutput
(
"Out"
,
""
);
AddComment
(
""
);
}
...
...
@@ -143,7 +143,7 @@ class AddOpMaker : public OpProtoAndCheckerMaker {
public:
AddOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"x"
).
Set
Duplicable
();
AddInput
(
"X"
,
"x"
).
As
Duplicable
();
AddOutput
(
"Y"
,
"y"
);
AddComment
(
""
);
}
...
...
paddle/framework/grad_op_builder_test.cc
浏览文件 @
f09cb657
...
...
@@ -21,10 +21,10 @@ class MutiInOutOpMaker : public OpProtoAndCheckerMaker {
MutiInOutOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"In1"
,
"a single input"
);
AddInput
(
"In2_mult"
,
"a multiple input"
).
Set
Duplicable
();
AddInput
(
"In2_mult"
,
"a multiple input"
).
As
Duplicable
();
AddInput
(
"In3"
,
"another single input"
);
AddOutput
(
"Out1"
,
"a single output"
);
AddOutput
(
"Out2_mult"
,
"a multiple output"
).
Set
Duplicable
();
AddOutput
(
"Out2_mult"
,
"a multiple output"
).
As
Duplicable
();
AddComment
(
"test op with multiple inputs and outputs"
);
}
};
...
...
@@ -34,10 +34,10 @@ class IOIgnoredOpMaker : public OpProtoAndCheckerMaker {
IOIgnoredOpMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"In1"
,
"a single input"
);
AddInput
(
"In2_mult"
,
"a multiple input"
).
SetDuplicable
().
NoGradient
();
AddInput
(
"In3_mult"
,
"another multiple input"
).
Set
Duplicable
();
AddOutput
(
"Out1_mult"
,
"a multiple output"
).
Set
Duplicable
();
AddOutput
(
"Out2"
,
"a single output"
).
NoGradient
();
AddInput
(
"In2_mult"
,
"a multiple input"
).
AsDuplicable
().
As
NoGradient
();
AddInput
(
"In3_mult"
,
"another multiple input"
).
As
Duplicable
();
AddOutput
(
"Out1_mult"
,
"a multiple output"
).
As
Duplicable
();
AddOutput
(
"Out2"
,
"a single output"
).
As
NoGradient
();
AddComment
(
"op with inputs and outputs ignored in gradient calculating"
);
}
};
...
...
paddle/framework/op_registry.h
浏览文件 @
f09cb657
...
...
@@ -47,17 +47,20 @@ class OpProtoAndCheckerMaker {
struct
VariableBuilder
{
OpProto
::
Var
*
var_
;
VariableBuilder
&
Set
Duplicable
()
{
VariableBuilder
&
As
Duplicable
()
{
var_
->
set_duplicable
(
true
);
return
*
this
;
}
VariableBuilder
&
Set
Intermediate
()
{
VariableBuilder
&
As
Intermediate
()
{
var_
->
set_intermediate
(
true
);
return
*
this
;
}
VariableBuilder
&
NoGradient
()
{
// TODO(FengJiayi, yuyang18): `AsNoGradient` is a very bad name, because it
// means that input/output is not needed when calculate gradient. It does
// not mean no gradient when backward. It should be changed soon.
VariableBuilder
&
AsNoGradient
()
{
var_
->
set_no_gradient
(
true
);
return
*
this
;
}
...
...
paddle/framework/op_registry_test.cc
浏览文件 @
f09cb657
...
...
@@ -38,8 +38,8 @@ class MyTestOpProtoAndCheckerMaker : public OpProtoAndCheckerMaker {
public:
MyTestOpProtoAndCheckerMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"input"
,
"input of cosine op"
).
Set
Duplicable
();
AddOutput
(
"output"
,
"output of cosine op"
).
Set
Intermediate
();
AddInput
(
"input"
,
"input of cosine op"
).
As
Duplicable
();
AddOutput
(
"output"
,
"output of cosine op"
).
As
Intermediate
();
auto
my_checker
=
[](
int
i
)
{
PADDLE_ENFORCE
(
i
%
2
==
0
,
"'test_attr' must be even!"
);
};
...
...
@@ -51,12 +51,12 @@ class MyTestOpProtoAndCheckerMaker : public OpProtoAndCheckerMaker {
}
// namespace framework
}
// namespace paddle
static
void
ConstructVars
(
const
std
::
string
&
param_name
,
std
::
initializer_list
<
const
char
*>
arguments
,
paddle
::
framework
::
OpDesc
::
Var
*
var
)
{
static
void
BuildVar
(
const
std
::
string
&
param_name
,
std
::
initializer_list
<
const
char
*>
arguments
,
paddle
::
framework
::
OpDesc
::
Var
*
var
)
{
var
->
set_parameter
(
param_name
);
for
(
auto
&
arg_name
:
arguments
)
{
*
var
->
mutable_arguments
()
->
Add
()
=
arg_name
;
var
->
add_arguments
(
arg_name
)
;
}
}
...
...
@@ -68,8 +68,8 @@ REGISTER_OP(my_test_op, paddle::framework::MyTestOp,
TEST
(
OpRegistry
,
CreateOp
)
{
paddle
::
framework
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"cos_sim"
);
ConstructVars
(
"input"
,
{
"aa"
},
op_desc
.
add_inputs
());
ConstructVars
(
"output"
,
{
"bb"
},
op_desc
.
add_outputs
());
BuildVar
(
"input"
,
{
"aa"
},
op_desc
.
add_inputs
());
BuildVar
(
"output"
,
{
"bb"
},
op_desc
.
add_outputs
());
float
scale
=
3.3
;
auto
attr
=
op_desc
.
mutable_attrs
()
->
Add
();
...
...
@@ -89,8 +89,8 @@ TEST(OpRegistry, CreateOp) {
TEST
(
OpRegistry
,
IllegalAttr
)
{
paddle
::
framework
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"cos_sim"
);
ConstructVars
(
"input"
,
{
"aa"
},
op_desc
.
add_inputs
());
ConstructVars
(
"output"
,
{
"bb"
},
op_desc
.
add_outputs
());
BuildVar
(
"input"
,
{
"aa"
},
op_desc
.
add_inputs
());
BuildVar
(
"output"
,
{
"bb"
},
op_desc
.
add_outputs
());
auto
attr
=
op_desc
.
mutable_attrs
()
->
Add
();
attr
->
set_name
(
"scale"
);
...
...
@@ -114,8 +114,8 @@ TEST(OpRegistry, IllegalAttr) {
TEST
(
OpRegistry
,
DefaultValue
)
{
paddle
::
framework
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"cos_sim"
);
ConstructVars
(
"input"
,
{
"aa"
},
op_desc
.
add_inputs
());
ConstructVars
(
"output"
,
{
"bb"
},
op_desc
.
add_outputs
());
BuildVar
(
"input"
,
{
"aa"
},
op_desc
.
add_inputs
());
BuildVar
(
"output"
,
{
"bb"
},
op_desc
.
add_outputs
());
ASSERT_TRUE
(
op_desc
.
IsInitialized
());
...
...
@@ -130,8 +130,8 @@ TEST(OpRegistry, DefaultValue) {
TEST
(
OpRegistry
,
CustomChecker
)
{
paddle
::
framework
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"my_test_op"
);
ConstructVars
(
"input"
,
{
"ii"
},
op_desc
.
add_inputs
());
ConstructVars
(
"output"
,
{
"oo"
},
op_desc
.
add_outputs
());
BuildVar
(
"input"
,
{
"ii"
},
op_desc
.
add_inputs
());
BuildVar
(
"output"
,
{
"oo"
},
op_desc
.
add_outputs
());
// attr 'test_attr' is not set
bool
caught
=
false
;
...
...
paddle/framework/operator_test.cc
浏览文件 @
f09cb657
...
...
@@ -56,9 +56,9 @@ class OpeWithoutKernelTestProtoAndCheckerMaker : public OpProtoAndCheckerMaker {
}
// namespace framework
}
// namespace paddle
static
void
ConstructVars
(
const
std
::
string
&
param_name
,
std
::
initializer_list
<
const
char
*>
arguments
,
paddle
::
framework
::
OpDesc
::
Var
*
var
)
{
static
void
BuildVar
(
const
std
::
string
&
param_name
,
std
::
initializer_list
<
const
char
*>
arguments
,
paddle
::
framework
::
OpDesc
::
Var
*
var
)
{
var
->
set_parameter
(
param_name
);
for
(
auto
&
arg_name
:
arguments
)
{
*
var
->
mutable_arguments
()
->
Add
()
=
arg_name
;
...
...
@@ -71,8 +71,8 @@ REGISTER_OP(test_operator, paddle::framework::OpWithoutKernelTest,
TEST
(
OperatorBase
,
all
)
{
paddle
::
framework
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"test_operator"
);
ConstructVars
(
"IN1"
,
{
"input"
},
op_desc
.
add_inputs
());
ConstructVars
(
"OUT1"
,
{
"output"
},
op_desc
.
add_outputs
());
BuildVar
(
"IN1"
,
{
"input"
},
op_desc
.
add_inputs
());
BuildVar
(
"OUT1"
,
{
"output"
},
op_desc
.
add_outputs
());
auto
attr
=
op_desc
.
mutable_attrs
()
->
Add
();
attr
->
set_name
(
"scale"
);
...
...
@@ -132,9 +132,9 @@ class OpKernelTestMultiInputsProtoAndCheckerMaker
OpKernelTestMultiInputsProtoAndCheckerMaker
(
OpProto
*
proto
,
OpAttrChecker
*
op_checker
)
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"xs"
,
"inputs of test op"
).
Set
Duplicable
();
AddInput
(
"xs"
,
"inputs of test op"
).
As
Duplicable
();
AddInput
(
"k"
,
"input of test op"
);
AddOutput
(
"ys"
,
"outputs of test op"
).
Set
Duplicable
();
AddOutput
(
"ys"
,
"outputs of test op"
).
As
Duplicable
();
AddAttr
<
float
>
(
"scale"
,
"scale of cosine op"
)
.
SetDefault
(
1.0
)
.
LargerThan
(
0.0
);
...
...
@@ -191,8 +191,8 @@ REGISTER_OP_CPU_KERNEL(op_with_kernel,
TEST
(
OpKernel
,
all
)
{
paddle
::
framework
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"op_with_kernel"
);
ConstructVars
(
"IN1"
,
{
"x"
},
op_desc
.
add_inputs
());
ConstructVars
(
"OUT1"
,
{
"y"
},
op_desc
.
add_outputs
());
BuildVar
(
"IN1"
,
{
"x"
},
op_desc
.
add_inputs
());
BuildVar
(
"OUT1"
,
{
"y"
},
op_desc
.
add_outputs
());
auto
attr
=
op_desc
.
mutable_attrs
()
->
Add
();
attr
->
set_name
(
"scale"
);
...
...
@@ -219,9 +219,9 @@ TEST(OpKernel, multi_inputs) {
OpDesc
op_desc
;
op_desc
.
set_type
(
"op_multi_inputs_with_kernel"
);
ConstructVars
(
"xs"
,
{
"x0"
,
"x1"
,
"x2"
},
op_desc
.
add_inputs
());
ConstructVars
(
"k"
,
{
"k0"
},
op_desc
.
add_inputs
());
ConstructVars
(
"ys"
,
{
"y0"
,
"y1"
},
op_desc
.
add_outputs
());
BuildVar
(
"xs"
,
{
"x0"
,
"x1"
,
"x2"
},
op_desc
.
add_inputs
());
BuildVar
(
"k"
,
{
"k0"
},
op_desc
.
add_inputs
());
BuildVar
(
"ys"
,
{
"y0"
,
"y1"
},
op_desc
.
add_outputs
());
auto
attr
=
op_desc
.
mutable_attrs
()
->
Add
();
attr
->
set_name
(
"scale"
);
...
...
paddle/operators/mean_op.cc
浏览文件 @
f09cb657
...
...
@@ -32,7 +32,7 @@ class MeanOpMaker : public framework::OpProtoAndCheckerMaker {
MeanOpMaker
(
framework
::
OpProto
*
proto
,
framework
::
OpAttrChecker
*
op_checker
)
:
OpProtoAndCheckerMaker
(
proto
,
op_checker
)
{
AddInput
(
"X"
,
"The input of mean op"
);
AddOutput
(
"Out"
,
"The output of mean op"
).
NoGradient
();
AddOutput
(
"Out"
,
"The output of mean op"
).
As
NoGradient
();
AddComment
(
"Mean Operator"
);
}
};
...
...
paddle/operators/recurrent_op.cc
浏览文件 @
f09cb657
...
...
@@ -152,13 +152,13 @@ class RecurrentAlgorithmProtoAndCheckerMaker
// inputs and outputs stored in proto
AddInput
(
name
.
inlinks
,
"the inputs that need to be segmented for each step."
)
.
Set
Duplicable
();
.
As
Duplicable
();
AddInput
(
name
.
boot_memories
,
"variables to initialize memories."
)
.
Set
Duplicable
();
.
As
Duplicable
();
AddInput
(
name
.
step_net
,
"network shared by all steps."
);
AddOutput
(
name
.
outlinks
,
"the outputs that need to concated for all steps."
)
.
Set
Duplicable
();
.
As
Duplicable
();
AddOutput
(
name
.
step_scopes
,
"step scopes"
);
// Attributes stored in AttributeMap
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录