Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
2ed7982d
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
2ed7982d
编写于
9月 11, 2018
作者:
K
Krzysztof Binias
提交者:
GitHub
9月 11, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13327 from kbinias/kbinias/conv-weights-converted-once
[MKLDNN] Reusing once reordered convolution weights in test mode
上级
b681537e
accdecc6
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
10 addition
and
5 deletion
+10
-5
paddle/fluid/operators/conv_mkldnn_op.cc
paddle/fluid/operators/conv_mkldnn_op.cc
+6
-3
paddle/fluid/operators/conv_op.cc
paddle/fluid/operators/conv_op.cc
+1
-0
paddle/fluid/platform/mkldnn_helper.h
paddle/fluid/platform/mkldnn_helper.h
+3
-2
未找到文件。
paddle/fluid/operators/conv_mkldnn_op.cc
浏览文件 @
2ed7982d
...
@@ -130,12 +130,13 @@ class ConvMKLDNNHandler : public platform::MKLDNNHandler {
...
@@ -130,12 +130,13 @@ class ConvMKLDNNHandler : public platform::MKLDNNHandler {
std
::
shared_ptr
<
mkldnn
::
memory
>
AcquireWeightsMemoryFromPrimitive
(
std
::
shared_ptr
<
mkldnn
::
memory
>
AcquireWeightsMemoryFromPrimitive
(
const
std
::
shared_ptr
<
mkldnn
::
memory
>
user_weights_memory_p
,
const
std
::
shared_ptr
<
mkldnn
::
memory
>
user_weights_memory_p
,
std
::
vector
<
mkldnn
::
primitive
>&
pipeline
)
{
// NOLINT
std
::
vector
<
mkldnn
::
primitive
>&
pipeline
,
// NOLINT
bool
is_persistent
=
false
)
{
auto
user_weights_pd
=
user_weights_memory_p
->
get_primitive_desc
();
auto
user_weights_pd
=
user_weights_memory_p
->
get_primitive_desc
();
auto
weights_pd
=
conv_pd_
->
weights_primitive_desc
();
auto
weights_pd
=
conv_pd_
->
weights_primitive_desc
();
return
this
->
AcquireMemory
(
weights_pd
,
user_weights_pd
,
return
this
->
AcquireMemory
(
weights_pd
,
user_weights_pd
,
user_weights_memory_p
,
"@weights_mem_p"
,
user_weights_memory_p
,
"@weights_mem_p"
,
pipeline
);
pipeline
,
is_persistent
);
}
}
std
::
shared_ptr
<
mkldnn
::
memory
>
AcquireBiasMemoryFromPrimitive
(
std
::
shared_ptr
<
mkldnn
::
memory
>
AcquireBiasMemoryFromPrimitive
(
...
@@ -266,6 +267,8 @@ class ConvMKLDNNOpKernel : public paddle::framework::OpKernel<T> {
...
@@ -266,6 +267,8 @@ class ConvMKLDNNOpKernel : public paddle::framework::OpKernel<T> {
PADDLE_ENFORCE
(
paddle
::
platform
::
is_cpu_place
(
ctx
.
GetPlace
()),
PADDLE_ENFORCE
(
paddle
::
platform
::
is_cpu_place
(
ctx
.
GetPlace
()),
"It must use CPUPlace."
);
"It must use CPUPlace."
);
const
bool
is_test
=
ctx
.
Attr
<
bool
>
(
"is_test"
);
auto
&
dev_ctx
=
auto
&
dev_ctx
=
ctx
.
template
device_context
<
paddle
::
platform
::
MKLDNNDeviceContext
>();
ctx
.
template
device_context
<
paddle
::
platform
::
MKLDNNDeviceContext
>();
const
auto
&
mkldnn_engine
=
dev_ctx
.
GetEngine
();
const
auto
&
mkldnn_engine
=
dev_ctx
.
GetEngine
();
...
@@ -371,7 +374,7 @@ class ConvMKLDNNOpKernel : public paddle::framework::OpKernel<T> {
...
@@ -371,7 +374,7 @@ class ConvMKLDNNOpKernel : public paddle::framework::OpKernel<T> {
auto
src_memory_p
=
auto
src_memory_p
=
handler
.
AcquireSrcMemoryFromPrimitive
(
user_src_memory_p
,
pipeline
);
handler
.
AcquireSrcMemoryFromPrimitive
(
user_src_memory_p
,
pipeline
);
auto
weights_memory_p
=
handler
.
AcquireWeightsMemoryFromPrimitive
(
auto
weights_memory_p
=
handler
.
AcquireWeightsMemoryFromPrimitive
(
user_weights_memory_p
,
pipeline
);
user_weights_memory_p
,
pipeline
,
is_test
);
auto
dst_memory_p
=
auto
dst_memory_p
=
handler
.
AcquireDstMemoryFromPrimitive
(
to_void_cast
<
T
>
(
output_data
));
handler
.
AcquireDstMemoryFromPrimitive
(
to_void_cast
<
T
>
(
output_data
));
...
...
paddle/fluid/operators/conv_op.cc
浏览文件 @
2ed7982d
...
@@ -109,6 +109,7 @@ framework::OpKernelType ConvOp::GetExpectedKernelType(
...
@@ -109,6 +109,7 @@ framework::OpKernelType ConvOp::GetExpectedKernelType(
}
}
void
Conv2DOpMaker
::
Make
()
{
void
Conv2DOpMaker
::
Make
()
{
AddAttr
<
bool
>
(
"is_test"
,
""
).
SetDefault
(
false
);
AddInput
(
AddInput
(
"Input"
,
"Input"
,
"(Tensor) The input tensor of convolution operator. "
"(Tensor) The input tensor of convolution operator. "
...
...
paddle/fluid/platform/mkldnn_helper.h
浏览文件 @
2ed7982d
...
@@ -192,7 +192,8 @@ class MKLDNNHandler {
...
@@ -192,7 +192,8 @@ class MKLDNNHandler {
mkldnn
::
memory
::
primitive_desc
&
user_mpd
,
// NOLINT
mkldnn
::
memory
::
primitive_desc
&
user_mpd
,
// NOLINT
const
std
::
shared_ptr
<
mkldnn
::
memory
>
user_memory_p
,
const
std
::
shared_ptr
<
mkldnn
::
memory
>
user_memory_p
,
const
std
::
string
&
suffix
,
const
std
::
string
&
suffix
,
std
::
vector
<
mkldnn
::
primitive
>&
pipeline
)
{
// NOLINT
std
::
vector
<
mkldnn
::
primitive
>&
pipeline
,
// NOLINT
bool
is_persistent
=
false
)
{
// create reorder primitive if the input format is not the preferred one
// create reorder primitive if the input format is not the preferred one
auto
local_key
=
key_
+
suffix
;
auto
local_key
=
key_
+
suffix
;
auto
key_reorder_p
=
key_
+
suffix
+
"reorder_p"
;
auto
key_reorder_p
=
key_
+
suffix
+
"reorder_p"
;
...
@@ -213,7 +214,7 @@ class MKLDNNHandler {
...
@@ -213,7 +214,7 @@ class MKLDNNHandler {
pipeline
.
push_back
(
*
reorder_p
);
pipeline
.
push_back
(
*
reorder_p
);
}
}
dev_ctx_
.
SetBlob
(
local_key
,
target_memory_p
);
dev_ctx_
.
SetBlob
(
local_key
,
target_memory_p
);
}
else
{
}
else
if
(
!
is_persistent
)
{
// Make reorder if needed
// Make reorder if needed
auto
reorder_p
=
std
::
static_pointer_cast
<
mkldnn
::
reorder
>
(
auto
reorder_p
=
std
::
static_pointer_cast
<
mkldnn
::
reorder
>
(
dev_ctx_
.
GetBlob
(
key_reorder_p
));
dev_ctx_
.
GetBlob
(
key_reorder_p
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录