Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
3fb6451c
P
Paddle
项目概览
BaiXuePrincess
/
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看板
提交
3fb6451c
编写于
11月 02, 2017
作者:
T
tensor-tang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add mkldnn_addto unit test and pass it
上级
8ff34368
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
9 deletion
+42
-9
paddle/gserver/layers/MKLDNNLayer.cpp
paddle/gserver/layers/MKLDNNLayer.cpp
+1
-1
paddle/gserver/tests/MKLDNNTester.cpp
paddle/gserver/tests/MKLDNNTester.cpp
+3
-3
paddle/gserver/tests/test_MKLDNN.cpp
paddle/gserver/tests/test_MKLDNN.cpp
+38
-5
未找到文件。
paddle/gserver/layers/MKLDNNLayer.cpp
浏览文件 @
3fb6451c
...
...
@@ -77,7 +77,7 @@ void MKLDNNLayer::forward(PassType passType) {
needResetBwd_
=
true
;
}
if
(
inputLayers_
[
0
]
->
getType
()
==
"data"
)
{
if
(
inputLayers_
[
0
]
->
getType
()
==
"data"
&&
inputLayers_
.
size
()
==
1
)
{
// Update input value data when input layer is "data" type,
// since the input value data address might be changed.
CHECK
(
extInVal_
);
...
...
paddle/gserver/tests/MKLDNNTester.cpp
浏览文件 @
3fb6451c
...
...
@@ -132,7 +132,7 @@ void MKLDNNTester::checkForward() {
VLOG
(
MKLDNN_TESTS
)
<<
"Check Forward"
;
printTopDatas
();
double
delta
=
compareMatrix
(
dnnLayer_
->
getOutputValue
(),
ref
Layer_
->
getOutputValue
());
compareMatrix
(
refLayer_
->
getOutputValue
(),
dnn
Layer_
->
getOutputValue
());
EXPECT_LE
(
fabs
(
delta
),
eps_
);
}
...
...
@@ -147,7 +147,7 @@ void MKLDNNTester::checkBackwardData() {
VLOG
(
MKLDNN_ALL
)
<<
"Reference Backward Result: InputGrad "
<<
i
;
printMatrix
(
refDiff
);
double
delta
=
compareMatrix
(
dnnDiff
,
ref
Diff
);
double
delta
=
compareMatrix
(
refDiff
,
dnn
Diff
);
EXPECT_LE
(
fabs
(
delta
),
eps_
);
if
(
isBN
)
{
// the other two inputs in batch norm are for moving mean and var
...
...
@@ -177,7 +177,7 @@ void MKLDNNTester::checkBackwardWgts() {
<<
parameters_
[
REF
][
i
]
->
getName
();
printVector
(
ref
);
double
delta
=
compareVector
(
dnn
,
ref
);
double
delta
=
compareVector
(
ref
,
dnn
);
EXPECT_LE
(
fabs
(
delta
),
eps_
);
}
...
...
paddle/gserver/tests/test_MKLDNN.cpp
浏览文件 @
3fb6451c
...
...
@@ -271,20 +271,53 @@ TEST(MKLDNNLayer, BatchNormLayer) {
testBatchNormLayer
({
16
,
32
,
16
,
16
});
}
struct
test
Act
Desc
{
struct
test
Image
Desc
{
int
bs
,
ic
,
ih
,
iw
;
};
static
void
getAddtoConfig
(
TestConfig
&
cfg
,
const
testActDesc
&
pm
)
{
static
void
getAddtoConfig
(
TestConfig
&
cfg
,
const
testImageDesc
&
pm
,
const
size_t
nInputs
=
1
)
{
cfg
.
biasSize
=
0
;
cfg
.
layerConfig
.
set_type
(
"addto"
);
size_t
layerSize
=
pm
.
ic
*
pm
.
ih
*
pm
.
iw
;
cfg
.
layerConfig
.
set_size
(
layerSize
);
cfg
.
inputDefs
.
push_back
({
INPUT_DATA
,
"layer_0"
,
layerSize
,
0
});
cfg
.
layerConfig
.
add_inputs
();
cfg
.
layerConfig
.
set_active_type
(
"relu"
);
for
(
size_t
i
=
0
;
i
<
nInputs
;
++
i
)
{
std
::
stringstream
ss
;
ss
<<
"layer_"
<<
i
;
cfg
.
inputDefs
.
push_back
({
INPUT_DATA
,
ss
.
str
(),
layerSize
,
0
});
LayerInputConfig
*
input
=
cfg
.
layerConfig
.
add_inputs
();
ImageConfig
*
img_conf
=
input
->
mutable_image_conf
();
img_conf
->
set_channels
(
pm
.
ic
);
img_conf
->
set_img_size_y
(
pm
.
ih
);
img_conf
->
set_img_size
(
pm
.
iw
);
}
}
void
testAddtoLayer
(
const
testImageDesc
&
pm
,
const
size_t
nInputs
)
{
CHECK_GE
(
nInputs
,
1
);
TestConfig
dnnConfig
;
getAddtoConfig
(
dnnConfig
,
pm
,
nInputs
);
dnnConfig
.
layerConfig
.
set_type
(
"mkldnn_addto"
);
// TODO(TJ): test with bias
for
(
auto
withBias
:
{
false
})
{
if
(
withBias
)
{
dnnConfig
.
biasSize
=
pm
.
ic
*
pm
.
ih
*
pm
.
iw
;
}
else
{
dnnConfig
.
biasSize
=
0
;
}
RUN_MKLDNN_TEST_LAYER
(
dnnConfig
,
"addto"
,
pm
)
}
}
TEST
(
MKLDNNLayer
,
AddtoLayer
)
{
testAddtoLayer
({
16
,
5
,
14
,
14
},
1
);
testAddtoLayer
({
8
,
10
,
8
,
8
},
2
);
testAddtoLayer
({
4
,
12
,
1
,
1
},
3
);
}
void
testActivation
(
std
::
string
actType
,
const
test
Act
Desc
&
pm
)
{
void
testActivation
(
std
::
string
actType
,
const
test
Image
Desc
&
pm
)
{
// TODO(TJ): remove me when paddle support elu activation
if
(
actType
==
"mkldnn_elu"
)
{
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录