ModelTC/MQBench

onnx qnn 部署模型问题

wangshankun opened this issue · 7 comments

官方给的resnet50里面,QLinearConv 是包含了QuantizeLinear
image

而mqbench convert的模型中:多了一个QuantizeLinear ,
image

因为QuantizeLinear 输入是int32或者float的,这会导致onn qnn convert出来的模型不能用:

image

Tracin commented

这里应该是DequantizeLinear

嗯,不过maxpool也能支持uint8/int8吧,我把maxpool放到了qlinear_op_type里面,算是暂时绕开这个错误;

另外,onnx已经支持FC了,量化算子是QLinearMatMul; onnx_qnn应该要把这个算子加上了吧?

Tracin commented

嗯,不过maxpool也能支持uint8/int8吧,我把maxpool放到了qlinear_op_type里面,算是暂时绕开这个错误;

另外,onnx已经支持FC了,量化算子是QLinearMatMul; onnx_qnn应该要把这个算子加上了吧?

QLinearMatMul不完全是FC, 因为缺少bias add操作.

是的,但是onnx官方用QLinearMatMul + QLinearAdd方式实现的
image

或者用卷积代替

Tracin commented

是的, Pytorch实现的难点是无法统计MatMul和Add中间Tensor的数值范围, 给ONNX提了QLinearFC的issue.

是的, Pytorch实现的难点是无法统计MatMul和Add中间Tensor的数值范围, 给ONNX提了QLinearFC的issue.

Add要求bias 8bit,这个有点不符合部署实情,那我还是在deploy_onnx_qnn里面用1x1卷积代替FC吧;
别的不说,至少resnet18和50得支持了吧

FC变成1*1卷积,再和reshape掉个顺序就成了
image

This issue has not received any updates in 120 days. Please reply to this issue if this still unresolved!