How to append float32 operator to quantized graph
Created by: wanghaoshuang
from paddleslim.quant import quant_aware, convert
quantized_graph = convert(infer_prog, place, config=config)
quantized_program = quantized_graph.to_program()
for var in quantized_program.list_vars():
print(var.name)
with fluid.program_guard(quantized_program):
out = quantized_program.global_block().var("your_var_name")
out = fluid.layers.some_op(out)
fluid.io.save_inference_model(main_program=quantized_program, ...)
Some API docs:
- program_guard: https://www.paddlepaddle.org.cn/documentation/docs/zh/api_cn/fluid_cn/program_guard_cn.html#program-guard
- Program: https://www.paddlepaddle.org.cn/documentation/docs/zh/api_cn/fluid_cn/Program_cn.html#program
- save-inference-model: https://www.paddlepaddle.org.cn/documentation/docs/zh/api_cn/io_cn/save_inference_model_cn.html#save-inference-model
- IrGraph.to_porgram: https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/fluid/framework.py#L3803