We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
为了避免类似 #3911 一天白干的事再发生,写一下 FQ-ViT 方案。
目前 mmdeploy merge 这个 PR 之后,已经可以生成很漂亮的 ViT.onnx 5 月份的 FQ-ViT 论文很好, 源码 repo 俺也熟悉了 ppq 搞量化表很方便,已经根据 FQ-ViT 的思路改得差不多了,WIP openppl-public/ppq#154
现在就差动 ncnn 了。
原始 fp32 的结构这样:
flowchart TD; add0-->layernorm; add0-->nop; nop-->add1; layernorm-->mha; mha-->add1;
论文是这么计算 scale 的:
flowchart TD; add0-->perchannel0; perchannel0-->layernorm; perchannel0-->add1; layernorm-->perlayer0; perlayer0-->mha; mha-->perlayer1; perlayer1-->add1; add1-->perchannel1;
实际推理的时候,计算过程是这样:
flowchart TD; add0.fp32-->quant; quant-->int_tensor0; int_tensor0-->layernorm.int; int_tensor0-->requant0; requant0-->add1; layernorm.int-->int8_tensor; int8_tensor-->mha.int; mha.int-->requant1; requant1-->add1; add1-->int_tensor1;
ppq 的量化结果,ncnn 怎么吃掉? 使用 .ini 格式,写了个 reader/writer。已完成 refactor quant table #3911
add/mha/layernorm 要支持 int8 打算把 naive 版本的写了,把量化模型精度验了就提 PR。 论文用的是 [-128, 127],有的地方还是 [0, 255] 。和推理并不完全一致。
cc @nihui @BUG1989
The text was updated successfully, but these errors were encountered:
No branches or pull requests
为了避免类似 #3911 一天白干的事再发生,写一下 FQ-ViT 方案。
背景
目前 mmdeploy merge 这个 PR 之后,已经可以生成很漂亮的 ViT.onnx
5 月份的 FQ-ViT 论文很好, 源码 repo 俺也熟悉了
ppq 搞量化表很方便,已经根据 FQ-ViT 的思路改得差不多了,WIP openppl-public/ppq#154
现在就差动 ncnn 了。
量化部分
原始 fp32 的结构这样:
论文是这么计算 scale 的:
实际推理的时候,计算过程是这样:
修改内容
ppq 的量化结果,ncnn 怎么吃掉?
使用 .ini 格式,写了个 reader/writer。已完成 refactor quant table #3911
add/mha/layernorm 要支持 int8
打算把 naive 版本的写了,把量化模型精度验了就提 PR。
论文用的是 [-128, 127],有的地方还是 [0, 255] 。和推理并不完全一致。
注意事项
cc @nihui @BUG1989
The text was updated successfully, but these errors were encountered: