Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
3099d9d4
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看板
提交
3099d9d4
编写于
1月 25, 2020
作者:
J
joanna.wozna.intel
提交者:
Tao Luo
1月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Restore requantize squash (#22399)
上级
92462e94
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
46 addition
and
7 deletion
+46
-7
paddle/fluid/framework/ir/mkldnn/cpu_quantize_squash_pass.cc
paddle/fluid/framework/ir/mkldnn/cpu_quantize_squash_pass.cc
+1
-0
paddle/fluid/framework/ir/mkldnn/cpu_quantize_squash_pass_tester.cc
...id/framework/ir/mkldnn/cpu_quantize_squash_pass_tester.cc
+30
-3
paddle/fluid/inference/tests/api/CMakeLists.txt
paddle/fluid/inference/tests/api/CMakeLists.txt
+7
-2
paddle/fluid/inference/tests/test.cmake
paddle/fluid/inference/tests/test.cmake
+1
-0
python/paddle/fluid/contrib/slim/tests/CMakeLists.txt
python/paddle/fluid/contrib/slim/tests/CMakeLists.txt
+7
-2
未找到文件。
paddle/fluid/framework/ir/mkldnn/cpu_quantize_squash_pass.cc
浏览文件 @
3099d9d4
...
@@ -294,6 +294,7 @@ void CPUQuantizeSquashPass::ApplyImpl(ir::Graph* graph) const {
...
@@ -294,6 +294,7 @@ void CPUQuantizeSquashPass::ApplyImpl(ir::Graph* graph) const {
std
::
unordered_map
<
const
Node
*
,
int
>
nodes_keep_counter
;
std
::
unordered_map
<
const
Node
*
,
int
>
nodes_keep_counter
;
FindNodesToKeep
(
graph
,
&
nodes_keep_counter
);
FindNodesToKeep
(
graph
,
&
nodes_keep_counter
);
DequantQuantSquash
(
graph
,
&
nodes_keep_counter
);
DequantQuantSquash
(
graph
,
&
nodes_keep_counter
);
ConvRequantSquash
(
graph
);
ConvDequantSquash
(
graph
);
ConvDequantSquash
(
graph
);
FcDequantSquash
(
graph
);
FcDequantSquash
(
graph
);
MultipleQuantizeSquash
(
graph
);
MultipleQuantizeSquash
(
graph
);
...
...
paddle/fluid/framework/ir/mkldnn/cpu_quantize_squash_pass_tester.cc
浏览文件 @
3099d9d4
...
@@ -355,18 +355,45 @@ TEST(CpuQuantizeSquashPass, equal_scales) {
...
@@ -355,18 +355,45 @@ TEST(CpuQuantizeSquashPass, equal_scales) {
// From Conv1->d->Dequant->e->Quant->f->Conv2
// From Conv1->d->Dequant->e->Quant->f->Conv2
// First change to Conv1->d->Requant->f->Conv2
// First change to Conv1->d->Requant->f->Conv2
// Then Conv1->f->Conv2
TEST
(
CpuQuantizeSquashPass
,
unequal_scales
)
{
TEST
(
CpuQuantizeSquashPass
,
unequal_scales
)
{
auto
scale_out
=
1.0
f
;
auto
scale_out
=
1.0
f
;
auto
scale1
=
1.2345
f
;
auto
scale1
=
1.2345
f
;
auto
scale2
=
21.0
f
;
auto
scale2
=
21.0
f
;
auto
use_mkldnn
=
true
;
auto
use_mkldnn
=
true
;
// Remove 3 nodes: Dequant, Quant, e
// Remove 4 nodes: Dequant, Quant, e, d
// Insert 1 node: Requant
auto
remove_nodes
=
4
;
auto
remove_nodes
=
2
;
CountNodeTest
(
CountNodeTest
(
BuildConvRequantProgramDesc
(
use_mkldnn
,
scale_out
,
scale1
,
scale2
),
BuildConvRequantProgramDesc
(
use_mkldnn
,
scale_out
,
scale1
,
scale2
),
remove_nodes
);
remove_nodes
);
EqualScaleOutTest
(
BuildConvRequantProgramDesc
(
use_mkldnn
,
scale_out
,
scale1
,
scale2
),
"Conv1"
,
scale2
);
}
// a->Conv1->b->Requant->c
// d->Conv2->e->Requant->f
// {c,f}->Concat
TEST
(
CpuQuantizeSquashPass
,
equal_scales_squash_requantize
)
{
// Delete both requantize op
auto
scale_out
=
1.0
f
;
auto
scale
=
1.2345
f
;
auto
use_mkldnn
=
true
;
// Remove 4 nodes: b, Requant1, e, Requant2
auto
remove_nodes
=
4
;
CountNodeTest
(
BuildConvsRequantConcatProgramDesc
(
use_mkldnn
,
scale_out
,
scale
,
scale
),
remove_nodes
);
// check equal scale conv->scale_out and requant->scale_out
EqualScaleOutTest
(
BuildConvsRequantConcatProgramDesc
(
use_mkldnn
,
scale_out
,
scale
,
scale
),
"Conv1"
,
scale
);
EqualScaleOutTest
(
BuildConvsRequantConcatProgramDesc
(
use_mkldnn
,
scale_out
,
scale
,
scale
),
"Conv2"
,
scale
);
}
}
// from
// from
...
...
paddle/fluid/inference/tests/api/CMakeLists.txt
浏览文件 @
3099d9d4
...
@@ -47,12 +47,17 @@ function(inference_analysis_api_int8_test_run TARGET_NAME test_binary model_dir
...
@@ -47,12 +47,17 @@ function(inference_analysis_api_int8_test_run TARGET_NAME test_binary model_dir
COMMAND
${
test_binary
}
COMMAND
${
test_binary
}
ARGS --infer_model=
${
model_dir
}
/model
ARGS --infer_model=
${
model_dir
}
/model
--infer_data=
${
data_path
}
--infer_data=
${
data_path
}
--warmup_batch_size=
100
--warmup_batch_size=
${
WARMUP_BATCH_SIZE
}
--batch_size=50
--batch_size=50
--paddle_num_threads=
${
CPU_NUM_THREADS_ON_CI
}
--paddle_num_threads=
${
CPU_NUM_THREADS_ON_CI
}
--iterations=2
)
--iterations=2
)
endfunction
()
endfunction
()
function
(
inference_analysis_api_int8_test_run_custom_warmup_batch_size TARGET_NAME test_binary model_dir data_path warmup_batch_size
)
set
(
WARMUP_BATCH_SIZE
${
warmup_batch_size
}
)
inference_analysis_api_int8_test_run
(
${
TARGET_NAME
}
${
test_binary
}
${
model_dir
}
${
data_path
}
)
endfunction
()
function
(
inference_analysis_api_object_dection_int8_test_run TARGET_NAME test_binary model_dir data_path
)
function
(
inference_analysis_api_object_dection_int8_test_run TARGET_NAME test_binary model_dir data_path
)
inference_analysis_test_run
(
${
TARGET_NAME
}
inference_analysis_test_run
(
${
TARGET_NAME
}
COMMAND
${
test_binary
}
COMMAND
${
test_binary
}
...
@@ -268,7 +273,7 @@ if(WITH_MKLDNN)
...
@@ -268,7 +273,7 @@ if(WITH_MKLDNN)
# googlenet int8
# googlenet int8
set
(
INT8_GOOGLENET_MODEL_DIR
"
${
INT8_DATA_DIR
}
/googlenet"
)
set
(
INT8_GOOGLENET_MODEL_DIR
"
${
INT8_DATA_DIR
}
/googlenet"
)
download_int8_data
(
${
INT8_GOOGLENET_MODEL_DIR
}
"GoogleNet_int8_model.tar.gz"
)
download_int8_data
(
${
INT8_GOOGLENET_MODEL_DIR
}
"GoogleNet_int8_model.tar.gz"
)
inference_analysis_api_int8_test_run
(
test_analyzer_int8_googlenet
${
INT8_IMG_CLASS_TEST_APP
}
${
INT8_GOOGLENET_MODEL_DIR
}
${
IMAGENET_DATA_PATH
}
)
inference_analysis_api_int8_test_run
_custom_warmup_batch_size
(
test_analyzer_int8_googlenet
${
INT8_IMG_CLASS_TEST_APP
}
${
INT8_GOOGLENET_MODEL_DIR
}
${
IMAGENET_DATA_PATH
}
10
)
### Object detection models
### Object detection models
set
(
PASCALVOC_DATA_PATH
"
${
INT8_DATA_DIR
}
/pascalvoc_val_head_300.bin"
)
set
(
PASCALVOC_DATA_PATH
"
${
INT8_DATA_DIR
}
/pascalvoc_val_head_300.bin"
)
...
...
paddle/fluid/inference/tests/test.cmake
浏览文件 @
3099d9d4
...
@@ -3,6 +3,7 @@ set(INFERENCE_URL "http://paddle-inference-dist.bj.bcebos.com" CACHE STRING "inf
...
@@ -3,6 +3,7 @@ set(INFERENCE_URL "http://paddle-inference-dist.bj.bcebos.com" CACHE STRING "inf
set
(
INFERENCE_DEMO_INSTALL_DIR
"
${
THIRD_PARTY_PATH
}
/inference_demo"
CACHE STRING
set
(
INFERENCE_DEMO_INSTALL_DIR
"
${
THIRD_PARTY_PATH
}
/inference_demo"
CACHE STRING
"A path setting inference demo download directories."
)
"A path setting inference demo download directories."
)
set
(
CPU_NUM_THREADS_ON_CI 4 CACHE STRING
"Run multi-threads on CI to reduce CI time."
)
set
(
CPU_NUM_THREADS_ON_CI 4 CACHE STRING
"Run multi-threads on CI to reduce CI time."
)
set
(
WARMUP_BATCH_SIZE 100 CACHE STRING
"Default warmup_batch_size."
)
function
(
inference_download INSTALL_DIR URL FILENAME
)
function
(
inference_download INSTALL_DIR URL FILENAME
)
message
(
STATUS
"Download inference test stuff from
${
URL
}
/
${
FILENAME
}
"
)
message
(
STATUS
"Download inference test stuff from
${
URL
}
/
${
FILENAME
}
"
)
...
...
python/paddle/fluid/contrib/slim/tests/CMakeLists.txt
浏览文件 @
3099d9d4
...
@@ -8,7 +8,7 @@ function(_inference_analysis_python_api_int8_test target model_dir data_dir file
...
@@ -8,7 +8,7 @@ function(_inference_analysis_python_api_int8_test target model_dir data_dir file
ARGS --infer_model
${
model_dir
}
/model
ARGS --infer_model
${
model_dir
}
/model
--infer_data
${
data_dir
}
/data.bin
--infer_data
${
data_dir
}
/data.bin
--int8_model_save_path int8_models/
${
target
}
--int8_model_save_path int8_models/
${
target
}
--warmup_batch_size
100
--warmup_batch_size
${
WARMUP_BATCH_SIZE
}
--batch_size 50
)
--batch_size 50
)
endfunction
()
endfunction
()
...
@@ -20,6 +20,11 @@ function(inference_analysis_python_api_int8_test_mkldnn target model_dir data_di
...
@@ -20,6 +20,11 @@ function(inference_analysis_python_api_int8_test_mkldnn target model_dir data_di
_inference_analysis_python_api_int8_test
(
${
target
}
${
model_dir
}
${
data_dir
}
${
filename
}
True
)
_inference_analysis_python_api_int8_test
(
${
target
}
${
model_dir
}
${
data_dir
}
${
filename
}
True
)
endfunction
()
endfunction
()
function
(
inference_analysis_python_api_int8_test_custom_warmup_batch_size target model_dir data_dir filename warmup_batch_size
)
set
(
WARMUP_BATCH_SIZE
${
warmup_batch_size
}
)
inference_analysis_python_api_int8_test
(
${
target
}
${
model_dir
}
${
data_dir
}
${
filename
}
)
endfunction
()
function
(
inference_qat_int8_test target model_dir data_dir test_script use_mkldnn
)
function
(
inference_qat_int8_test target model_dir data_dir test_script use_mkldnn
)
py_test
(
${
target
}
SRCS
${
test_script
}
py_test
(
${
target
}
SRCS
${
test_script
}
ENVS FLAGS_OMP_NUM_THREADS=
${
CPU_NUM_THREADS_ON_CI
}
ENVS FLAGS_OMP_NUM_THREADS=
${
CPU_NUM_THREADS_ON_CI
}
...
@@ -68,7 +73,7 @@ if(LINUX AND WITH_MKLDNN)
...
@@ -68,7 +73,7 @@ if(LINUX AND WITH_MKLDNN)
# googlenet int8
# googlenet int8
set
(
INT8_GOOGLENET_MODEL_DIR
"
${
INT8_DATA_DIR
}
/googlenet"
)
set
(
INT8_GOOGLENET_MODEL_DIR
"
${
INT8_DATA_DIR
}
/googlenet"
)
inference_analysis_python_api_int8_test
(
test_slim_int8_googlenet
${
INT8_GOOGLENET_MODEL_DIR
}
${
INT8_DATA_DIR
}
${
MKLDNN_INT8_TEST_FILE_PATH
}
)
inference_analysis_python_api_int8_test
_custom_warmup_batch_size
(
test_slim_int8_googlenet
${
INT8_GOOGLENET_MODEL_DIR
}
${
INT8_DATA_DIR
}
${
MKLDNN_INT8_TEST_FILE_PATH
}
10
)
# mobilenet int8
# mobilenet int8
set
(
INT8_MOBILENET_MODEL_DIR
"
${
INT8_DATA_DIR
}
/mobilenetv1"
)
set
(
INT8_MOBILENET_MODEL_DIR
"
${
INT8_DATA_DIR
}
/mobilenetv1"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录