Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_52226395
Paddle
提交
ef29b522
P
Paddle
项目概览
weixin_52226395
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ef29b522
编写于
8月 14, 2017
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify unit test code
上级
4a604c26
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
37 deletion
+15
-37
paddle/framework/op_registry_test.cc
paddle/framework/op_registry_test.cc
+8
-20
paddle/framework/operator_test.cc
paddle/framework/operator_test.cc
+7
-17
未找到文件。
paddle/framework/op_registry_test.cc
浏览文件 @
ef29b522
...
...
@@ -68,11 +68,8 @@ REGISTER_OP(my_test_op, paddle::framework::MyTestOp,
TEST
(
OpRegistry
,
CreateOp
)
{
paddle
::
framework
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"cos_sim"
);
auto
*
input
=
op_desc
.
add_inputs
();
ConstructVars
(
"input"
,
{
"aa"
},
input
);
auto
*
output
=
op_desc
.
add_outputs
();
ConstructVars
(
"output"
,
{
"bb"
},
output
);
ConstructVars
(
"input"
,
{
"aa"
},
op_desc
.
add_inputs
());
ConstructVars
(
"output"
,
{
"bb"
},
op_desc
.
add_outputs
());
float
scale
=
3.3
;
auto
attr
=
op_desc
.
mutable_attrs
()
->
Add
();
...
...
@@ -92,11 +89,8 @@ TEST(OpRegistry, CreateOp) {
TEST
(
OpRegistry
,
IllegalAttr
)
{
paddle
::
framework
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"cos_sim"
);
auto
*
input
=
op_desc
.
add_inputs
();
ConstructVars
(
"input"
,
{
"aa"
},
input
);
auto
*
output
=
op_desc
.
add_outputs
();
ConstructVars
(
"output"
,
{
"bb"
},
output
);
ConstructVars
(
"input"
,
{
"aa"
},
op_desc
.
add_inputs
());
ConstructVars
(
"output"
,
{
"bb"
},
op_desc
.
add_outputs
());
auto
attr
=
op_desc
.
mutable_attrs
()
->
Add
();
attr
->
set_name
(
"scale"
);
...
...
@@ -120,11 +114,8 @@ TEST(OpRegistry, IllegalAttr) {
TEST
(
OpRegistry
,
DefaultValue
)
{
paddle
::
framework
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"cos_sim"
);
auto
*
input
=
op_desc
.
add_inputs
();
ConstructVars
(
"input"
,
{
"aa"
},
input
);
auto
*
output
=
op_desc
.
add_outputs
();
ConstructVars
(
"output"
,
{
"bb"
},
output
);
ConstructVars
(
"input"
,
{
"aa"
},
op_desc
.
add_inputs
());
ConstructVars
(
"output"
,
{
"bb"
},
op_desc
.
add_outputs
());
ASSERT_TRUE
(
op_desc
.
IsInitialized
());
...
...
@@ -139,11 +130,8 @@ TEST(OpRegistry, DefaultValue) {
TEST
(
OpRegistry
,
CustomChecker
)
{
paddle
::
framework
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"my_test_op"
);
auto
*
input
=
op_desc
.
add_inputs
();
ConstructVars
(
"input"
,
{
"ii"
},
input
);
auto
*
output
=
op_desc
.
add_outputs
();
ConstructVars
(
"output"
,
{
"oo"
},
output
);
ConstructVars
(
"input"
,
{
"ii"
},
op_desc
.
add_inputs
());
ConstructVars
(
"output"
,
{
"oo"
},
op_desc
.
add_outputs
());
// attr 'test_attr' is not set
bool
caught
=
false
;
...
...
paddle/framework/operator_test.cc
浏览文件 @
ef29b522
...
...
@@ -71,12 +71,8 @@ REGISTER_OP(test_operator, paddle::framework::OpWithoutKernelTest,
TEST
(
OperatorBase
,
all
)
{
paddle
::
framework
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"test_operator"
);
auto
*
ipt
=
op_desc
.
mutable_inputs
()
->
Add
();
ConstructVars
(
"IN1"
,
{
"input"
},
ipt
);
auto
*
output
=
op_desc
.
mutable_outputs
()
->
Add
();
ConstructVars
(
"OUT1"
,
{
"output"
},
output
);
ConstructVars
(
"IN1"
,
{
"input"
},
op_desc
.
add_inputs
());
ConstructVars
(
"OUT1"
,
{
"output"
},
op_desc
.
add_outputs
());
auto
attr
=
op_desc
.
mutable_attrs
()
->
Add
();
attr
->
set_name
(
"scale"
);
...
...
@@ -195,11 +191,8 @@ REGISTER_OP_CPU_KERNEL(op_with_kernel,
TEST
(
OpKernel
,
all
)
{
paddle
::
framework
::
OpDesc
op_desc
;
op_desc
.
set_type
(
"op_with_kernel"
);
auto
*
ipt
=
op_desc
.
mutable_inputs
()
->
Add
();
ConstructVars
(
"IN1"
,
{
"x"
},
ipt
);
auto
*
output
=
op_desc
.
mutable_outputs
()
->
Add
();
ConstructVars
(
"OUT1"
,
{
"y"
},
output
);
ConstructVars
(
"IN1"
,
{
"x"
},
op_desc
.
add_inputs
());
ConstructVars
(
"OUT1"
,
{
"y"
},
op_desc
.
add_outputs
());
auto
attr
=
op_desc
.
mutable_attrs
()
->
Add
();
attr
->
set_name
(
"scale"
);
...
...
@@ -226,12 +219,9 @@ TEST(OpKernel, multi_inputs) {
OpDesc
op_desc
;
op_desc
.
set_type
(
"op_multi_inputs_with_kernel"
);
auto
*
x
=
op_desc
.
mutable_inputs
()
->
Add
();
ConstructVars
(
"xs"
,
{
"x0"
,
"x1"
,
"x2"
},
x
);
auto
*
k
=
op_desc
.
mutable_inputs
()
->
Add
();
ConstructVars
(
"k"
,
{
"k0"
},
k
);
auto
*
y
=
op_desc
.
mutable_outputs
()
->
Add
();
ConstructVars
(
"ys"
,
{
"y0"
,
"y1"
},
y
);
ConstructVars
(
"xs"
,
{
"x0"
,
"x1"
,
"x2"
},
op_desc
.
add_inputs
());
ConstructVars
(
"k"
,
{
"k0"
},
op_desc
.
add_inputs
());
ConstructVars
(
"ys"
,
{
"y0"
,
"y1"
},
op_desc
.
add_outputs
());
auto
attr
=
op_desc
.
mutable_attrs
()
->
Add
();
attr
->
set_name
(
"scale"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录