create_quant_retrain_config
Applicability
Product |
Supported |
|---|---|
|
|
|
|
|
|
|
|
|
Description
Finds all quantizable layers in a graph, creates a quantization configuration file, and writes the quantization configuration of the quantizable layers to the configuration file.
Prototype
1 | create_quant_retrain_config(config_file, graph, config_defination=None) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
config_file |
Input |
Path (including the file name) of the QAT configuration file. The existing file (if any) in the path will be overwritten upon this API call. A string. |
graph |
Input |
tf.Graph of the model for quantization. A tf.Graph. |
config_defination |
Input |
Simplified QAT configuration file. The simplified configuration file quant.cfg is generated based on the retrain_config_tf.proto file. The *.proto file is stored in /amct_tensorflow/proto/ under the AMCT installation directory. For details about the parameters in the *.proto file and the generated simplified quantization configuration file quant.cfg, see Simplified QAT Configuration File. A string. Default: None |
Returns
None
Example
1 2 3 4 5 | PATH, _ = os.path.split(os.path.realpath(__file__)) config_path = os.path.join(PATH, 'resnet50_config.json') simple_config = './retrain/retrain.cfg' graph = tf.compat.v1.get_default_graph() amct.create_quant_retrain_config(config_path, graph, simple_config) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | { "version":1, "batch_num":1, "conv1":{ "retrain_enable":true, "retrain_data_config":{ "algo":"ulq_quantize", "dst_type":"INT8" }, "retrain_weight_config":{ "algo":"arq_retrain", "channel_wise":true, "dst_type":"INT8" } }, "conv2_1/expand":{ "retrain_enable":true, "retrain_data_config":{ "algo":"ulq_quantize", "dst_type":"INT8" }, "retrain_weight_config":{ "algo":"arq_retrain", "channel_wise":true, "dst_type":"INT8" } } } |