未验证 提交 51538a94 编写于 作者: G Guanghua Yu 提交者: GitHub

update full quant PTQ demo (#1512)

上级 e2f7e378
......@@ -7,11 +7,15 @@ Global:
model_filename: model.pdmodel
params_filename: model.pdiparams
Distillation:
alpha: 1.0
loss: l2
PTQ: # Post Training Quantization
quantizable_op_type: ["conv2d", "depthwise_conv2d"]
activation_quantize_type: 'moving_average_abs_max'
algo: avg
onnx_format: False
batch_size: 32
batch_nums: 10
Quantization:
Quantization: # Auto Compression
use_pact: true
activation_quantize_type: 'moving_average_abs_max'
weight_bits: 8
......@@ -20,6 +24,10 @@ Quantization:
- conv2d
- depthwise_conv2d
Distillation:
alpha: 1.0
loss: l2
TrainConfig:
train_iter: 8000
eval_iter: 1000
......
......@@ -7,11 +7,15 @@ Global:
model_filename: model.pdmodel
params_filename: model.pdiparams
Distillation:
alpha: 1.0
loss: l2
PTQ: # Post Training Quantization
quantizable_op_type: ["conv2d", "depthwise_conv2d"]
activation_quantize_type: 'moving_average_abs_max'
algo: avg
onnx_format: False
batch_size: 32
batch_nums: 10
Quantization:
Quantization: # Auto Compression
use_pact: true
activation_quantize_type: 'moving_average_abs_max'
weight_bits: 8
......@@ -20,6 +24,10 @@ Quantization:
- conv2d
- depthwise_conv2d
Distillation:
alpha: 1.0
loss: l2
TrainConfig:
train_iter: 8000
eval_iter: 1000
......
......@@ -41,8 +41,6 @@ def argsparser():
type=str,
default='gpu',
help="which device used to compress.")
parser.add_argument(
'--algo', type=str, default='avg', help="post quant algo.")
return parser
......@@ -71,6 +69,7 @@ def main():
reader_cfg['worker_num'],
return_list=True)
train_loader = reader_wrapper(train_loader, global_config['input_list'])
ptq_config = all_config['PTQ']
place = paddle.CUDAPlace(0) if FLAGS.devices == 'gpu' else paddle.CPUPlace()
exe = paddle.static.Executor(place)
......@@ -81,13 +80,15 @@ def main():
data_loader=train_loader,
model_filename=global_config["model_filename"],
params_filename=global_config["params_filename"],
batch_size=32,
batch_nums=10,
algo=FLAGS.algo,
quantizable_op_type=ptq_config['quantizable_op_type'],
activation_quantize_type=ptq_config['activation_quantize_type'],
batch_size=ptq_config['batch_size'],
batch_nums=ptq_config['batch_nums'],
algo=ptq_config['algo'],
hist_percent=0.999,
is_full_quantize=False,
bias_correction=False,
onnx_format=True,
onnx_format=ptq_config['onnx_format'],
skip_tensor_list=None)
......
......@@ -7,9 +7,10 @@ Global:
model_filename: model.pdmodel
params_filename: model.pdiparams
PTQ:
PTQ: # Post Training Quantization
quantizable_op_type: ["conv2d", "depthwise_conv2d"]
activation_quantize_type: 'moving_average_abs_max'
algo: avg
is_full_quantize: True
onnx_format: False
batch_size: 10
......@@ -19,7 +20,7 @@ Distillation:
alpha: 1.0
loss: soft_label
Quantization:
Quantization: # Auto Compression
onnx_format: true
use_pact: true
activation_quantize_type: 'moving_average_abs_max'
......
......@@ -7,19 +7,16 @@ Global:
model_filename: model.pdmodel
params_filename: model.pdiparams
PTQ:
PTQ: # Post Training Quantization
quantizable_op_type: ["conv2d", "depthwise_conv2d"]
activation_quantize_type: 'moving_average_abs_max'
algo: avg
is_full_quantize: True
onnx_format: False
batch_size: 10
batch_nums: 10
Distillation:
alpha: 1.0
loss: soft_label
Quantization:
Quantization: # Auto Compression
onnx_format: true
use_pact: true
activation_quantize_type: 'moving_average_abs_max'
......@@ -27,6 +24,10 @@ Quantization:
- conv2d
- depthwise_conv2d
Distillation:
alpha: 1.0
loss: soft_label
TrainConfig:
train_iter: 5000
eval_iter: 1000
......
......@@ -42,8 +42,6 @@ def argsparser():
type=str,
default='gpu',
help="which device used to compress.")
parser.add_argument(
'--algo', type=str, default='avg', help="post quant algo.")
return parser
......@@ -89,7 +87,7 @@ def main():
activation_quantize_type=ptq_config['activation_quantize_type'],
batch_size=ptq_config['batch_size'],
batch_nums=ptq_config['batch_nums'],
algo=FLAGS.algo,
algo=ptq_config['algo'],
hist_percent=0.999,
is_full_quantize=ptq_config['is_full_quantize'],
bias_correction=False,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册