@@ -313,7 +313,9 @@ def quant_post_static(
313
313
batch_size = 16 ,
314
314
batch_nums = None ,
315
315
scope = None ,
316
- algo = 'KL' ,
316
+ algo = 'hist' ,
317
+ hist_percent = 0.9999 ,
318
+ bias_correction = False ,
317
319
quantizable_op_type = ["conv2d" , "depthwise_conv2d" , "mul" ],
318
320
is_full_quantize = False ,
319
321
weight_bits = 8 ,
@@ -358,9 +360,15 @@ def quant_post_static(
358
360
generated by sample_generator as calibrate data.
359
361
scope(paddle.static.Scope, optional): The scope to run program, use it to load
360
362
and save variables. If scope is None, will use paddle.static.global_scope().
361
- algo(str, optional): If algo=KL, use KL-divergenc method to
362
- get the more precise scale factor. If algo='direct', use
363
- abs_max method to get the scale factor. Default: 'KL'.
363
+ algo(str, optional): If algo='KL', use KL-divergenc method to
364
+ get the scale factor. If algo='hist', use the hist_percent of histogram
365
+ to get the scale factor. If algo='mse', search for the best scale factor which
366
+ makes the mse loss minimal. Use one batch of data for mse is enough. If
367
+ algo='avg', use the average of abs_max values to get the scale factor. If
368
+ algo='abs_max', use abs_max method to get the scale factor. Default: 'hist'.
369
+ hist_percent(float, optional): The percentile of histogram for algo hist.Default:0.9999.
370
+ bias_correction(bool, optional): Bias correction method of https://arxiv.org/abs/1810.05723.
371
+ Default: False.
364
372
quantizable_op_type(list[str], optional): The list of op types
365
373
that will be quantized. Default: ["conv2d", "depthwise_conv2d",
366
374
"mul"].
@@ -397,6 +405,8 @@ def quant_post_static(
397
405
batch_nums = batch_nums ,
398
406
scope = scope ,
399
407
algo = algo ,
408
+ hist_percent = hist_percent ,
409
+ bias_correction = bias_correction ,
400
410
quantizable_op_type = quantizable_op_type ,
401
411
is_full_quantize = is_full_quantize ,
402
412
weight_bits = weight_bits ,
0 commit comments