Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
d83d0f33
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d83d0f33
编写于
12月 24, 2018
作者:
X
xiaoli.liu@intel.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
extract templated function
test=develop
上级
019dbf7f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
18 deletion
+23
-18
paddle/fluid/operators/quantize_mkldnn_op.cc
paddle/fluid/operators/quantize_mkldnn_op.cc
+7
-18
paddle/fluid/platform/mkldnn_reuse.h
paddle/fluid/platform/mkldnn_reuse.h
+16
-0
未找到文件。
paddle/fluid/operators/quantize_mkldnn_op.cc
浏览文件 @
d83d0f33
...
@@ -16,6 +16,7 @@ limitations under the License. */
...
@@ -16,6 +16,7 @@ limitations under the License. */
#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/operators/quantize_op.h"
#include "paddle/fluid/operators/quantize_op.h"
#include "paddle/fluid/platform/mkldnn_helper.h"
#include "paddle/fluid/platform/mkldnn_helper.h"
#include "paddle/fluid/platform/mkldnn_reuse.h"
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
...
@@ -59,37 +60,25 @@ class QuantOpKernel : public framework::OpKernel<T> {
...
@@ -59,37 +60,25 @@ class QuantOpKernel : public framework::OpKernel<T> {
std
::
shared_ptr
<
primitive
::
at
>
(
new
primitive
::
at
(
*
src_memory
));
std
::
shared_ptr
<
primitive
::
at
>
(
new
primitive
::
at
(
*
src_memory
));
bool
is_negative
=
ctx
.
Attr
<
bool
>
(
"is_negative_input"
);
bool
is_negative
=
ctx
.
Attr
<
bool
>
(
"is_negative_input"
);
mkldnn
::
memory
::
primitive_desc
dst_pd
;
std
::
shared_ptr
<
mkldnn
::
memory
::
primitive_desc
>
dst_pd
;
std
::
shared_ptr
<
mkldnn
::
memory
>
dst_memory
;
std
::
shared_ptr
<
mkldnn
::
memory
>
dst_memory
;
if
(
is_negative
)
{
if
(
is_negative
)
{
int8_t
*
output_data
=
output
->
mutable_data
<
int8_t
>
(
ctx
.
GetPlace
());
platform
::
ConvMKLDNNHandler
::
SetDstMemory
<
int8_t
>
(
auto
dst_md
=
platform
::
MKLDNNMemDesc
({
dst_tz
},
memory
::
data_type
::
s8
,
ctx
,
output
,
dst_tz
,
engine
,
dst_pd
,
dst_memory
);
memory
::
format
::
nhwc
);
dst_pd
=
mkldnn
::
memory
::
primitive_desc
(
dst_md
,
engine
);
dst_memory
.
reset
(
new
mkldnn
::
memory
(
dst_pd
,
to_void_cast
<
int8_t
>
(
output_data
)));
}
else
{
}
else
{
uint8_t
*
output_data
=
output
->
mutable_data
<
uint8_t
>
(
ctx
.
GetPlace
());
platform
::
ConvMKLDNNHandler
::
SetDstMemory
<
uint8_t
>
(
auto
dst_md
=
platform
::
MKLDNNMemDesc
({
dst_tz
},
memory
::
data_type
::
u8
,
ctx
,
output
,
dst_tz
,
engine
,
dst_pd
,
dst_memory
);
memory
::
format
::
nhwc
);
dst_pd
=
mkldnn
::
memory
::
primitive_desc
(
dst_md
,
engine
);
dst_memory
.
reset
(
new
mkldnn
::
memory
(
dst_pd
,
to_void_cast
<
uint8_t
>
(
output_data
)));
}
}
auto
reorder_pd
=
std
::
shared_ptr
<
reorder
::
primitive_desc
>
(
auto
reorder_pd
=
std
::
shared_ptr
<
reorder
::
primitive_desc
>
(
new
reorder
::
primitive_desc
(
src_pd
,
dst_pd
,
attri
));
new
reorder
::
primitive_desc
(
src_pd
,
*
dst_pd
,
attri
));
auto
reorder_p
=
std
::
shared_ptr
<
reorder
>
(
auto
reorder_p
=
std
::
shared_ptr
<
reorder
>
(
new
reorder
(
*
reorder_pd
,
*
src_memory_p
,
*
dst_memory
));
new
reorder
(
*
reorder_pd
,
*
src_memory_p
,
*
dst_memory
));
pipeline
.
push_back
(
*
reorder_p
);
pipeline
.
push_back
(
*
reorder_p
);
stream
(
stream
::
kind
::
eager
).
submit
(
pipeline
).
wait
();
stream
(
stream
::
kind
::
eager
).
submit
(
pipeline
).
wait
();
output
->
set_layout
(
DataLayout
::
kMKLDNN
);
output
->
set_layout
(
DataLayout
::
kMKLDNN
);
output
->
set_format
(
GetMKLDNNFormat
(
*
dst_memory
));
output
->
set_format
(
GetMKLDNNFormat
(
*
dst_memory
));
}
}
};
};
}
// namespace operators
}
// namespace operators
}
// namespace paddle
}
// namespace paddle
namespace
ops
=
paddle
::
operators
;
namespace
ops
=
paddle
::
operators
;
...
...
paddle/fluid/platform/mkldnn_reuse.h
浏览文件 @
d83d0f33
...
@@ -15,6 +15,7 @@ limitations under the License. */
...
@@ -15,6 +15,7 @@ limitations under the License. */
#include <string>
#include <string>
#include <vector>
#include <vector>
#include "paddle/fluid/framework/data_layout_transform.h"
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/platform/mkldnn_helper.h"
#include "paddle/fluid/platform/mkldnn_helper.h"
#include "paddle/fluid/platform/place.h"
#include "paddle/fluid/platform/place.h"
...
@@ -181,6 +182,21 @@ class MKLDNNHandler {
...
@@ -181,6 +182,21 @@ class MKLDNNHandler {
return
dims2str
(
operand_dims
)
+
suffix
;
return
dims2str
(
operand_dims
)
+
suffix
;
}
}
template
<
typename
M
>
static
void
SetDstMemory
(
const
framework
::
ExecutionContext
&
ctx
,
framework
::
Tensor
*
output
,
std
::
vector
<
int
>
dst_tz
,
const
mkldnn
::
engine
&
engine
,
std
::
shared_ptr
<
mkldnn
::
memory
::
primitive_desc
>&
dst_pd
,
// NOLINT
std
::
shared_ptr
<
mkldnn
::
memory
>&
dst_memory
)
{
// NOLINT
M
*
output_data
=
output
->
mutable_data
<
M
>
(
ctx
.
GetPlace
());
auto
dst_md
=
platform
::
MKLDNNMemDesc
(
{
dst_tz
},
paddle
::
framework
::
ToMKLDNNDataType
(
framework
::
DataTypeTrait
<
M
>::
DataType
),
mkldnn
::
memory
::
format
::
nhwc
);
dst_pd
.
reset
(
new
mkldnn
::
memory
::
primitive_desc
(
dst_md
,
engine
));
dst_memory
.
reset
(
new
mkldnn
::
memory
(
*
dst_pd
,
to_void_cast
<
M
>
(
output_data
)));
}
protected:
protected:
static
std
::
string
dims2str
(
const
mkldnn
::
memory
::
dims
&
operand_dims
)
{
static
std
::
string
dims2str
(
const
mkldnn
::
memory
::
dims
&
operand_dims
)
{
std
::
string
dstr
=
""
;
std
::
string
dstr
=
""
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录