Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
9ba52165
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
9ba52165
编写于
3月 08, 2020
作者:
W
Wojciech Uss
提交者:
GitHub
3月 08, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added an option to use external FP32 model in QAT comparison test (#22858) (#22873)
上级
781f8b2f
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
12 addition
and
4 deletion
+12
-4
python/paddle/fluid/contrib/slim/tests/qat_int8_nlp_comparison.py
...addle/fluid/contrib/slim/tests/qat_int8_nlp_comparison.py
+12
-4
未找到文件。
python/paddle/fluid/contrib/slim/tests/qat_int8_nlp_comparison.py
浏览文件 @
9ba52165
...
...
@@ -48,9 +48,11 @@ def parse_args():
parser
.
add_argument
(
'--qat_model'
,
type
=
str
,
default
=
''
,
help
=
'A path to a QAT model.'
)
parser
.
add_argument
(
'--save_model'
,
action
=
'store_true'
,
help
=
'If used, the QAT model will be saved after all transformations'
)
'--fp32_model'
,
type
=
str
,
default
=
''
,
help
=
'A path to an FP32 model. If empty, the QAT model will be used for FP32 inference.'
)
parser
.
add_argument
(
'--infer_data'
,
type
=
str
,
default
=
''
,
help
=
'Data file.'
)
parser
.
add_argument
(
'--labels'
,
type
=
str
,
default
=
''
,
help
=
'File with labels.'
)
...
...
@@ -239,7 +241,10 @@ class QatInt8NLPComparisonTest(unittest.TestCase):
return
qat_model_path
=
test_case_args
.
qat_model
assert
qat_model_path
,
'The QAT model path cannot be empty. Please, use the --qat_model option.'
fp32_model_path
=
test_case_args
.
fp32_model
if
test_case_args
.
fp32_model
else
qat_model_path
data_path
=
test_case_args
.
infer_data
assert
data_path
,
'The dataset path cannot be empty. Please, use the --infer_data option.'
labels_path
=
test_case_args
.
labels
batch_size
=
test_case_args
.
batch_size
batch_num
=
test_case_args
.
batch_num
...
...
@@ -250,6 +255,7 @@ class QatInt8NLPComparisonTest(unittest.TestCase):
_logger
.
info
(
'QAT FP32 & INT8 prediction run.'
)
_logger
.
info
(
'QAT model: {0}'
.
format
(
qat_model_path
))
_logger
.
info
(
'FP32 model: {0}'
.
format
(
fp32_model_path
))
_logger
.
info
(
'Dataset: {0}'
.
format
(
data_path
))
_logger
.
info
(
'Labels: {0}'
.
format
(
labels_path
))
_logger
.
info
(
'Batch size: {0}'
.
format
(
batch_size
))
...
...
@@ -262,11 +268,12 @@ class QatInt8NLPComparisonTest(unittest.TestCase):
self
.
_reader_creator
(
data_path
,
labels_path
),
batch_size
=
batch_size
)
fp32_acc
,
fp32_pps
,
fp32_lat
=
self
.
_predict
(
val_reader
,
qat
_model_path
,
fp32
_model_path
,
batch_size
,
batch_num
,
skip_batch_num
,
transform_to_int8
=
False
)
_logger
.
info
(
'FP32: avg accuracy: {0:.6f}'
.
format
(
fp32_acc
))
_logger
.
info
(
'--- QAT INT8 prediction start ---'
)
val_reader
=
paddle
.
batch
(
self
.
_reader_creator
(
data_path
,
labels_path
),
batch_size
=
batch_size
)
...
...
@@ -277,6 +284,7 @@ class QatInt8NLPComparisonTest(unittest.TestCase):
batch_num
,
skip_batch_num
,
transform_to_int8
=
True
)
_logger
.
info
(
'INT8: avg accuracy: {0:.6f}'
.
format
(
int8_acc
))
self
.
_summarize_performance
(
fp32_pps
,
fp32_lat
,
int8_pps
,
int8_lat
)
self
.
_compare_accuracy
(
fp32_acc
,
int8_acc
,
acc_diff_threshold
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录