perf_based_auto_calibration
产品支持情况
产品 |
是否支持 |
|---|---|
Atlas 350 加速卡 |
x |
x |
|
x |
|
x |
|
x |
|
x |
功能说明
根据用户输入的原始未量化模型、量化后的模型以及性能采样的配置文件,经过上板性能测试,搜索得到性能较优的混合精度的量化模型,输出既可以在TensorFlow环境下做精度仿真的fake_quant模型又可在AI处理器上做推理的deploy模型。
函数原型
1 | perf_based_auto_calibration(original_model_file, quantize_model_file, outputs, sampler_config_file, save_dir, strategy='BatchRollBack') |
参数说明
参数名 |
输入/输出 |
说明 |
|---|---|---|
original_model_file |
输入 |
含义:用户未量化的TensorFlow模型的定义文件,格式为.pb。 数据类型:string |
quantize_model_file |
输入 |
含义:用户量化的TensorFlow模型的定义文件,格式为.pb。 数据类型:string |
outputs |
输入 |
含义:输出节点的字符串列表。 数据类型:string |
sampler_config_file |
输入 |
含义:用户提供的性能采样配置文件。关于该文件详细说明以及配置示例请参见性能采样配置文件。 数据类型:string |
save_dir |
输入 |
含义:性能量化回退后模型保存路径。 数据类型:string |
strategy |
输入 |
含义:搜索满足性能要求的量化配置的策略。 数据类型:string或Python实例(PerfStrategyBase) 默认值:BatchRollBack |
返回值说明
无
调用示例
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) |
落盘文件说明:
- 既可以在TensorFlow环境进行精度仿真又可以在AI处理器做推理的pb模型文件。
- 量化因子记录文件、量化配置文件、性能数据对比文件以及自动量化回退历史记录文件。
父主题: 训练后量化接口