perf_based_auto_calibration
Applicable Products
Product |
Supported |
|---|---|
x |
|
x |
|
x |
|
x |
|
x |
|
x |
Description
Searches for a mixed-precision quantized model with better performance based on the original dequantized model, quantized model, and performance sampler configuration file input by the user, and outputs a fake-quantized model that can be used for accuracy simulation in the TensorFlow environment and a deployable model that can be used for inference on the AI processor.
Prototype
1 | perf_based_auto_calibration(original_model_file, quantize_model_file, outputs, sampler_config_file, save_dir, strategy='BatchRollBack') |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
original_model_file |
Input |
Definition file (.pb) of the dequantized TensorFlow model. A string. |
quantize_model_file |
Input |
Definition file (.pb) of the quantized TensorFlow model. A string. |
outputs |
Input |
String list of the output node. A string. |
sampler_config_file |
Input |
Performance sampler configuration file provided by users. For details about this file and the configuration example, see Performance Sampler Configuration File. A string. |
save_dir |
Input |
Path for saving the model after performance unquantization. A string. |
strategy |
Input |
Policy for searching for quantization configurations that meet performance requirements. A string or a Python instance (PerfStrategyBase). Default: BatchRollBack |
Returns
None
Example
1 2 3 4 5 6 7 8 9 10 11 | import amct_tensorflow as amct def main(): args_check(args) model_file = args.model_file_name quant_model_file = args.quant_model_file_name outputs = args.save_outputs save_dir = args.path_dir sampler_config_file = args.sampler_config_file amct.perf_based_auto_calibration( model_file, quant_model_file, outputs[:], sampler_config_file, save_dir) |
Flush files:
- A .pb model file that can be used for accuracy simulation in the TensorFlow environment or inference on the AI processor.
- A quantization factor record file, a quantization configuration file, a performance comparison file, and an automatic unquantization history file.