quantize_model
产品支持情况
产品 |
是否支持 |
---|---|
√ |
|
√ |
|
√ |
|
√ |
功能说明
将输入的待量化的图结构按照给定的量化配置文件进行量化处理,在传入的图结构中插入权重量化,以及数据量化等相关的算子,生成量化因子记录文件record_file,返回修改后的ONNX校准模型。
函数原型
1 | quantize_model(config_file, model_file, modified_onnx_file, record_file) |
参数说明
参数名 |
输入/输出 |
说明 |
---|---|---|
config_file |
输入 |
含义:用户生成的量化配置文件,用于指定模型network中量化层的配置情况。 数据类型:string |
model_file |
输入 |
含义:用户原始onnx模型文件或者通过create_quant_config生成的updated模型。 数据类型:string |
modified_onnx_file |
输入 |
含义:文件名,用于存储待执行数据量化的ONNX校准模型。 数据类型:string |
record_file |
输入 |
含义:量化因子记录文件路径及名称。 数据类型:string |
返回值说明
无
调用示例
1 2 3 4 5 6 7 8 9 10 11 | import amct_onnx as amct model_file = "resnet101.onnx" scale_offset_record_file = os.path.join(TMP, 'scale_offset_record.txt') modified_model = os.path.join(TMP, 'modified_model.onnx') config_file="./configs/config.json" # 插入量化API amct.quantize_model(config_file, model_file, modified_model, scale_offset_record_file) |
父主题: 训练后量化接口