Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
406c1dd1
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
1 年多 前同步成功
通知
696
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
406c1dd1
编写于
5月 22, 2018
作者:
T
tensor-tang
提交者:
GitHub
5月 22, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10701 from tensor-tang/usemkldnn
enable MKLDNN inference test
上级
d54ad9f1
b5de21e8
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
28 addition
and
8 deletion
+28
-8
CMakeLists.txt
CMakeLists.txt
+7
-6
paddle/fluid/inference/tests/book/test_inference_image_classification.cc
...ference/tests/book/test_inference_image_classification.cc
+4
-1
paddle/fluid/inference/tests/test_helper.h
paddle/fluid/inference/tests/test_helper.h
+17
-1
未找到文件。
CMakeLists.txt
浏览文件 @
406c1dd1
...
...
@@ -117,13 +117,14 @@ else()
endif
()
set
(
WITH_MKLML
${
WITH_MKL
}
)
if
(
WITH_MKL AND AVX2_FOUND
)
if
(
NOT DEFINED WITH_MKLDNN
)
if
(
WITH_MKL AND AVX2_FOUND
)
set
(
WITH_MKLDNN ON
)
else
()
else
()
message
(
STATUS
"Do not have AVX2 intrinsics and disabled MKL-DNN"
)
set
(
WITH_MKLDNN OFF
)
endif
()
endif
()
########################################################################################
include
(
external/mklml
)
# download mklml package
...
...
paddle/fluid/inference/tests/book/test_inference_image_classification.cc
浏览文件 @
406c1dd1
...
...
@@ -21,6 +21,7 @@ DEFINE_string(fp16_dirname, "", "Directory of the float16 inference model.");
DEFINE_int32
(
batch_size
,
1
,
"Batch size of input data"
);
DEFINE_int32
(
repeat
,
1
,
"Running the inference program repeat times"
);
DEFINE_bool
(
skip_cpu
,
false
,
"Skip the cpu test"
);
DEFINE_bool
(
use_mkldnn
,
false
,
"Use MKLDNN to run inference"
);
TEST
(
inference
,
image_classification
)
{
if
(
FLAGS_dirname
.
empty
()
||
FLAGS_batch_size
<
1
||
FLAGS_repeat
<
1
)
{
...
...
@@ -58,8 +59,10 @@ TEST(inference, image_classification) {
// Run inference on CPU
LOG
(
INFO
)
<<
"--- CPU Runs: ---"
;
LOG
(
INFO
)
<<
"Batch size is "
<<
FLAGS_batch_size
;
LOG
(
INFO
)
<<
"FLAGS_use_mkldnn: "
<<
FLAGS_use_mkldnn
;
TestInference
<
paddle
::
platform
::
CPUPlace
,
false
,
true
>
(
dirname
,
cpu_feeds
,
cpu_fetchs1
,
FLAGS_repeat
,
is_combined
);
dirname
,
cpu_feeds
,
cpu_fetchs1
,
FLAGS_repeat
,
is_combined
,
FLAGS_use_mkldnn
);
LOG
(
INFO
)
<<
output1
.
dims
();
}
...
...
paddle/fluid/inference/tests/test_helper.h
浏览文件 @
406c1dd1
...
...
@@ -133,11 +133,24 @@ std::vector<std::vector<int64_t>> GetFeedTargetShapes(
return
feed_target_shapes
;
}
void
EnableMKLDNN
(
const
std
::
unique_ptr
<
paddle
::
framework
::
ProgramDesc
>&
program
)
{
for
(
size_t
bid
=
0
;
bid
<
program
->
Size
();
++
bid
)
{
auto
*
block
=
program
->
MutableBlock
(
bid
);
for
(
auto
*
op
:
block
->
AllOps
())
{
if
(
op
->
HasAttr
(
"use_mkldnn"
))
{
op
->
SetAttr
(
"use_mkldnn"
,
true
);
}
}
}
}
template
<
typename
Place
,
bool
CreateVars
=
true
,
bool
PrepareContext
=
false
>
void
TestInference
(
const
std
::
string
&
dirname
,
const
std
::
vector
<
paddle
::
framework
::
LoDTensor
*>&
cpu_feeds
,
const
std
::
vector
<
paddle
::
framework
::
LoDTensor
*>&
cpu_fetchs
,
const
int
repeat
=
1
,
const
bool
is_combined
=
false
)
{
const
int
repeat
=
1
,
const
bool
is_combined
=
false
,
const
bool
use_mkldnn
=
false
)
{
// 1. Define place, executor, scope
auto
place
=
Place
();
auto
executor
=
paddle
::
framework
::
Executor
(
place
);
...
...
@@ -169,6 +182,9 @@ void TestInference(const std::string& dirname,
"init_program"
,
paddle
::
platform
::
DeviceContextPool
::
Instance
().
Get
(
place
));
inference_program
=
InitProgram
(
&
executor
,
scope
,
dirname
,
is_combined
);
if
(
use_mkldnn
)
{
EnableMKLDNN
(
inference_program
);
}
}
// Disable the profiler and print the timing information
paddle
::
platform
::
DisableProfiler
(
paddle
::
platform
::
EventSortingKey
::
kDefault
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录