Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
f40d5f58
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看板
提交
f40d5f58
编写于
9月 11, 2017
作者:
T
tensor-tang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove syncOutputGrad, rename syncInputValue to updateInputData
上级
d4c07348
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
32 deletion
+20
-32
paddle/gserver/layers/MKLDNNFcLayer.cpp
paddle/gserver/layers/MKLDNNFcLayer.cpp
+12
-6
paddle/gserver/layers/MKLDNNFcLayer.h
paddle/gserver/layers/MKLDNNFcLayer.h
+2
-0
paddle/gserver/layers/MKLDNNLayer.h
paddle/gserver/layers/MKLDNNLayer.h
+6
-26
未找到文件。
paddle/gserver/layers/MKLDNNFcLayer.cpp
浏览文件 @
f40d5f58
...
@@ -220,13 +220,12 @@ void MKLDNNFcLayer::resetBwd() {
...
@@ -220,13 +220,12 @@ void MKLDNNFcLayer::resetBwd() {
pipelineBwd_
.
push_back
(
*
bwdWgt_
);
pipelineBwd_
.
push_back
(
*
bwdWgt_
);
/// backward data
/// backward data
device
=
inputIsOnlyMKLDNN
()
?
MKLDNN_DEVICE
:
CPU_DEVICE
;
const
MatrixPtr
&
in
=
inputLayers_
[
0
]
->
getOutput
().
grad
;
const
MatrixPtr
&
in
=
getInputGrad
(
0
,
device
);
if
(
in
==
nullptr
)
{
if
(
in
==
nullptr
)
{
return
;
return
;
}
}
if
(
getInput
(
0
,
device
).
getAllCount
()
>
1
)
{
if
(
getInput
(
0
,
MKLDNN_DEVICE
).
getAllCount
()
>
1
)
{
// TODO(TJ): use outputMaps_ ways when merge outgrad done
// TODO(TJ): use outputMaps_ ways
to get the inGrad_
when merge outgrad done
}
else
{
}
else
{
inGrad_
=
MKLDNNMatrix
::
create
(
in
,
inVal_
->
getPrimitiveDesc
());
inGrad_
=
MKLDNNMatrix
::
create
(
in
,
inVal_
->
getPrimitiveDesc
());
}
}
...
@@ -243,13 +242,21 @@ void MKLDNNFcLayer::resetBwd() {
...
@@ -243,13 +242,21 @@ void MKLDNNFcLayer::resetBwd() {
pipelineBwd_
.
push_back
(
*
bwdData_
);
pipelineBwd_
.
push_back
(
*
bwdData_
);
}
}
void
MKLDNNFcLayer
::
updateInputData
()
{
if
(
inputLayers_
[
0
]
->
getType
()
!=
"data"
)
{
return
;
}
real
*
iData
=
getInputValue
(
0
,
CPU_DEVICE
)
->
getData
();
inVal_
->
setData
(
iData
);
}
void
MKLDNNFcLayer
::
forward
(
PassType
passType
)
{
void
MKLDNNFcLayer
::
forward
(
PassType
passType
)
{
Layer
::
forward
(
passType
);
Layer
::
forward
(
passType
);
reshape
();
reshape
();
{
{
REGISTER_TIMER_INFO
(
"mkldnn_FwdTimer"
,
getName
().
c_str
());
REGISTER_TIMER_INFO
(
"mkldnn_FwdTimer"
,
getName
().
c_str
());
syncInputValue
();
updateInputData
();
// just submit forward pipeline
// just submit forward pipeline
stream_
->
submit
(
pipelineFwd_
);
stream_
->
submit
(
pipelineFwd_
);
...
@@ -271,7 +278,6 @@ void MKLDNNFcLayer::backward(const UpdateCallback& callback) {
...
@@ -271,7 +278,6 @@ void MKLDNNFcLayer::backward(const UpdateCallback& callback) {
REGISTER_TIMER_INFO
(
"mkldnn_bwdTimer"
,
getName
().
c_str
());
REGISTER_TIMER_INFO
(
"mkldnn_bwdTimer"
,
getName
().
c_str
());
resetBwd
();
resetBwd
();
syncOutputGrad
();
// just sumbmit backward pipeline
// just sumbmit backward pipeline
stream_
->
submit
(
pipelineBwd_
);
stream_
->
submit
(
pipelineBwd_
);
}
}
...
...
paddle/gserver/layers/MKLDNNFcLayer.h
浏览文件 @
f40d5f58
...
@@ -53,6 +53,8 @@ public:
...
@@ -53,6 +53,8 @@ public:
void
backward
(
const
UpdateCallback
&
callback
)
override
;
void
backward
(
const
UpdateCallback
&
callback
)
override
;
void
updateInputData
()
override
;
protected:
protected:
/**
/**
* reshape the input image sizes
* reshape the input image sizes
...
...
paddle/gserver/layers/MKLDNNLayer.h
浏览文件 @
f40d5f58
...
@@ -113,6 +113,12 @@ public:
...
@@ -113,6 +113,12 @@ public:
*/
*/
virtual
void
convertWeightsToPaddle
()
{}
virtual
void
convertWeightsToPaddle
()
{}
/**
* Update input value data when input layer is "data" type.
* Since the input value data address might be changed.
*/
virtual
void
updateInputData
()
{}
/**
/**
* print info about sizes
* print info about sizes
*/
*/
...
@@ -194,32 +200,6 @@ protected:
...
@@ -194,32 +200,6 @@ protected:
return
outputOtherDevice_
.
size
()
==
0
;
return
outputOtherDevice_
.
size
()
==
0
;
}
}
/**
* Sync input value data
*/
void
syncInputValue
()
{
if
(
inputIsOnlyMKLDNN
())
{
return
;
}
real
*
iData
=
getInputValue
(
0
,
CPU_DEVICE
)
->
getData
();
// update input data
// since it might be changed if this is after data layer
inVal_
->
setData
(
iData
);
}
/**
* Sync output grad data
*/
void
syncOutputGrad
()
{
if
(
outputIsOnlyMKLDNN
())
{
return
;
}
// update diff
real
*
oDiff
=
getOutput
(
CPU_DEVICE
).
grad
->
getData
();
outGrad_
->
setData
(
oDiff
);
}
/**
/**
* Set deviceId of this layer.
* Set deviceId of this layer.
*/
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录