Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
b68bb428
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
b68bb428
编写于
4月 12, 2022
作者:
J
joanna.wozna.intel
提交者:
GitHub
4月 12, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add possibility to test native config in mkldnn tests (#41562)
上级
51cae7f7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
24 addition
and
13 deletion
+24
-13
paddle/fluid/inference/tests/api/analyzer_bfloat16_image_classification_tester.cc
...ests/api/analyzer_bfloat16_image_classification_tester.cc
+4
-2
paddle/fluid/inference/tests/api/analyzer_int8_image_classification_tester.cc
...ce/tests/api/analyzer_int8_image_classification_tester.cc
+4
-2
paddle/fluid/inference/tests/api/analyzer_int8_object_detection_tester.cc
...erence/tests/api/analyzer_int8_object_detection_tester.cc
+13
-8
paddle/fluid/inference/tests/api/analyzer_quant_image_classification_tester.cc
...e/tests/api/analyzer_quant_image_classification_tester.cc
+3
-1
未找到文件。
paddle/fluid/inference/tests/api/analyzer_bfloat16_image_classification_tester.cc
浏览文件 @
b68bb428
...
@@ -16,6 +16,8 @@ limitations under the License. */
...
@@ -16,6 +16,8 @@ limitations under the License. */
#include "paddle/fluid/inference/tests/api/tester_helper.h"
#include "paddle/fluid/inference/tests/api/tester_helper.h"
#include "paddle/fluid/platform/cpu_info.h"
#include "paddle/fluid/platform/cpu_info.h"
DEFINE_bool
(
enable_mkldnn
,
true
,
"Enable MKLDNN"
);
namespace
paddle
{
namespace
paddle
{
namespace
inference
{
namespace
inference
{
namespace
analysis
{
namespace
analysis
{
...
@@ -31,7 +33,7 @@ void SetConfig(AnalysisConfig *cfg) {
...
@@ -31,7 +33,7 @@ void SetConfig(AnalysisConfig *cfg) {
cfg
->
SwitchIrOptim
();
cfg
->
SwitchIrOptim
();
cfg
->
SwitchSpecifyInputNames
();
cfg
->
SwitchSpecifyInputNames
();
cfg
->
SetCpuMathLibraryNumThreads
(
FLAGS_num_threads
);
cfg
->
SetCpuMathLibraryNumThreads
(
FLAGS_num_threads
);
cfg
->
EnableMKLDNN
();
if
(
FLAGS_enable_mkldnn
)
cfg
->
EnableMKLDNN
();
}
}
TEST
(
Analyzer_bfloat16_image_classification
,
bfloat16
)
{
TEST
(
Analyzer_bfloat16_image_classification
,
bfloat16
)
{
...
@@ -44,7 +46,7 @@ TEST(Analyzer_bfloat16_image_classification, bfloat16) {
...
@@ -44,7 +46,7 @@ TEST(Analyzer_bfloat16_image_classification, bfloat16) {
// read data from file and prepare batches with test data
// read data from file and prepare batches with test data
std
::
vector
<
std
::
vector
<
PaddleTensor
>>
input_slots_all
;
std
::
vector
<
std
::
vector
<
PaddleTensor
>>
input_slots_all
;
SetInputs
(
&
input_slots_all
);
SetInputs
(
&
input_slots_all
);
if
(
FLAGS_enable_bf16
&&
if
(
FLAGS_enable_
mkldnn
&&
FLAGS_enable_
bf16
&&
platform
::
MayIUse
(
platform
::
cpu_isa_t
::
avx512_bf16
))
{
platform
::
MayIUse
(
platform
::
cpu_isa_t
::
avx512_bf16
))
{
b_cfg
.
EnableMkldnnBfloat16
();
b_cfg
.
EnableMkldnnBfloat16
();
}
else
{
}
else
{
...
...
paddle/fluid/inference/tests/api/analyzer_int8_image_classification_tester.cc
浏览文件 @
b68bb428
...
@@ -17,6 +17,8 @@ limitations under the License. */
...
@@ -17,6 +17,8 @@ limitations under the License. */
#include "paddle/fluid/inference/api/paddle_analysis_config.h"
#include "paddle/fluid/inference/api/paddle_analysis_config.h"
#include "paddle/fluid/inference/tests/api/tester_helper.h"
#include "paddle/fluid/inference/tests/api/tester_helper.h"
DEFINE_bool
(
enable_mkldnn
,
true
,
"Enable MKLDNN"
);
namespace
paddle
{
namespace
paddle
{
namespace
inference
{
namespace
inference
{
namespace
analysis
{
namespace
analysis
{
...
@@ -32,7 +34,7 @@ void SetConfig(AnalysisConfig *cfg) {
...
@@ -32,7 +34,7 @@ void SetConfig(AnalysisConfig *cfg) {
cfg
->
SwitchIrOptim
();
cfg
->
SwitchIrOptim
();
cfg
->
SwitchSpecifyInputNames
();
cfg
->
SwitchSpecifyInputNames
();
cfg
->
SetCpuMathLibraryNumThreads
(
FLAGS_cpu_num_threads
);
cfg
->
SetCpuMathLibraryNumThreads
(
FLAGS_cpu_num_threads
);
cfg
->
EnableMKLDNN
();
if
(
FLAGS_enable_mkldnn
)
cfg
->
EnableMKLDNN
();
}
}
TEST
(
Analyzer_int8_image_classification
,
quantization
)
{
TEST
(
Analyzer_int8_image_classification
,
quantization
)
{
...
@@ -46,7 +48,7 @@ TEST(Analyzer_int8_image_classification, quantization) {
...
@@ -46,7 +48,7 @@ TEST(Analyzer_int8_image_classification, quantization) {
std
::
vector
<
std
::
vector
<
PaddleTensor
>>
input_slots_all
;
std
::
vector
<
std
::
vector
<
PaddleTensor
>>
input_slots_all
;
SetInputs
(
&
input_slots_all
);
SetInputs
(
&
input_slots_all
);
if
(
FLAGS_enable_int8
)
{
if
(
FLAGS_enable_
mkldnn
&&
FLAGS_enable_
int8
)
{
// prepare warmup batch from input data read earlier
// prepare warmup batch from input data read earlier
// warmup batch size can be different than batch size
// warmup batch size can be different than batch size
std
::
shared_ptr
<
std
::
vector
<
PaddleTensor
>>
warmup_data
=
std
::
shared_ptr
<
std
::
vector
<
PaddleTensor
>>
warmup_data
=
...
...
paddle/fluid/inference/tests/api/analyzer_int8_object_detection_tester.cc
浏览文件 @
b68bb428
...
@@ -17,6 +17,8 @@ limitations under the License. */
...
@@ -17,6 +17,8 @@ limitations under the License. */
#include "paddle/fluid/inference/api/paddle_analysis_config.h"
#include "paddle/fluid/inference/api/paddle_analysis_config.h"
#include "paddle/fluid/inference/tests/api/tester_helper.h"
#include "paddle/fluid/inference/tests/api/tester_helper.h"
DEFINE_bool
(
enable_mkldnn
,
true
,
"Enable MKLDNN"
);
// setting iterations to 0 means processing the whole dataset
// setting iterations to 0 means processing the whole dataset
namespace
paddle
{
namespace
paddle
{
namespace
inference
{
namespace
inference
{
...
@@ -28,7 +30,7 @@ void SetConfig(AnalysisConfig *cfg) {
...
@@ -28,7 +30,7 @@ void SetConfig(AnalysisConfig *cfg) {
cfg
->
SwitchIrOptim
(
true
);
cfg
->
SwitchIrOptim
(
true
);
cfg
->
SwitchSpecifyInputNames
(
false
);
cfg
->
SwitchSpecifyInputNames
(
false
);
cfg
->
SetCpuMathLibraryNumThreads
(
FLAGS_cpu_num_threads
);
cfg
->
SetCpuMathLibraryNumThreads
(
FLAGS_cpu_num_threads
);
cfg
->
EnableMKLDNN
();
if
(
FLAGS_enable_mkldnn
)
cfg
->
EnableMKLDNN
();
}
}
std
::
vector
<
size_t
>
ReadObjectsNum
(
std
::
ifstream
&
file
,
size_t
offset
,
std
::
vector
<
size_t
>
ReadObjectsNum
(
std
::
ifstream
&
file
,
size_t
offset
,
...
@@ -268,13 +270,16 @@ TEST(Analyzer_int8_mobilenet_ssd, quantization) {
...
@@ -268,13 +270,16 @@ TEST(Analyzer_int8_mobilenet_ssd, quantization) {
GetWarmupData
(
input_slots_all
);
GetWarmupData
(
input_slots_all
);
// configure quantizer
// configure quantizer
q_cfg
.
EnableMkldnnQuantizer
();
if
(
FLAGS_enable_mkldnn
)
{
q_cfg
.
mkldnn_quantizer_config
();
q_cfg
.
EnableMkldnnQuantizer
();
std
::
unordered_set
<
std
::
string
>
quantize_operators
(
q_cfg
.
mkldnn_quantizer_config
();
{
"conv2d"
,
"depthwise_conv2d"
,
"prior_box"
,
"transpose2"
,
"reshape2"
});
std
::
unordered_set
<
std
::
string
>
quantize_operators
(
q_cfg
.
mkldnn_quantizer_config
()
->
SetEnabledOpTypes
(
quantize_operators
);
{
"conv2d"
,
"depthwise_conv2d"
,
"prior_box"
,
"transpose2"
,
"reshape2"
});
q_cfg
.
mkldnn_quantizer_config
()
->
SetWarmupData
(
warmup_data
);
q_cfg
.
mkldnn_quantizer_config
()
->
SetEnabledOpTypes
(
quantize_operators
);
q_cfg
.
mkldnn_quantizer_config
()
->
SetWarmupBatchSize
(
FLAGS_warmup_batch_size
);
q_cfg
.
mkldnn_quantizer_config
()
->
SetWarmupData
(
warmup_data
);
q_cfg
.
mkldnn_quantizer_config
()
->
SetWarmupBatchSize
(
FLAGS_warmup_batch_size
);
}
// 0 is avg_cost, 1 is top1_acc, 2 is top5_acc or mAP
// 0 is avg_cost, 1 is top1_acc, 2 is top5_acc or mAP
CompareQuantizedAndAnalysis
(
&
cfg
,
&
q_cfg
,
input_slots_all
,
2
);
CompareQuantizedAndAnalysis
(
&
cfg
,
&
q_cfg
,
input_slots_all
,
2
);
...
...
paddle/fluid/inference/tests/api/analyzer_quant_image_classification_tester.cc
浏览文件 @
b68bb428
...
@@ -17,6 +17,8 @@ limitations under the License. */
...
@@ -17,6 +17,8 @@ limitations under the License. */
#include "paddle/fluid/inference/api/paddle_analysis_config.h"
#include "paddle/fluid/inference/api/paddle_analysis_config.h"
#include "paddle/fluid/inference/tests/api/tester_helper.h"
#include "paddle/fluid/inference/tests/api/tester_helper.h"
DEFINE_bool
(
enable_mkldnn
,
true
,
"Enable MKLDNN"
);
namespace
paddle
{
namespace
paddle
{
namespace
inference
{
namespace
inference
{
namespace
analysis
{
namespace
analysis
{
...
@@ -27,7 +29,7 @@ void SetConfig(AnalysisConfig *cfg, std::string model_path) {
...
@@ -27,7 +29,7 @@ void SetConfig(AnalysisConfig *cfg, std::string model_path) {
cfg
->
SwitchIrOptim
(
false
);
cfg
->
SwitchIrOptim
(
false
);
cfg
->
SwitchSpecifyInputNames
();
cfg
->
SwitchSpecifyInputNames
();
cfg
->
SetCpuMathLibraryNumThreads
(
FLAGS_cpu_num_threads
);
cfg
->
SetCpuMathLibraryNumThreads
(
FLAGS_cpu_num_threads
);
cfg
->
EnableMKLDNN
();
if
(
FLAGS_enable_mkldnn
)
cfg
->
EnableMKLDNN
();
}
}
template
<
typename
T
>
template
<
typename
T
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录