Skip to content
New issue

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

rknntoolkit2转换ONNX模型后,推理显示中间层超出FP16表示范围 #354

Open
Saikq2000 opened this issue Feb 18, 2025 · 0 comments

Comments

@Saikq2000
Copy link

您好,我想在开发板上部署一个自己训练的Convnext模型,但是在使用rknntoolkit2进行模型转换并推理时遇到了问题。在关闭量化(ret = rknn.build(do_quantization=False)的情况下,模型的输出会是NaN,并且有如下提示超出FP16的表示范围:
“W inference: The range [1.94334077835083, inf] of '/downsample_layers.3/downsample_layers.3.0/ReduceMean_1_output_0' is out of the float16!
W inference: The range [1.9433603286743164, inf] of '/downsample_layers.3/downsample_layers.3.0/Add_output_0' is out of the float16!”
我根据该信息定位了模型相关的层,由于我在rknntoolkit2的文档中没有找到在非量化模式下可以打印逐层详细数据的接口,所以我使用转换前的ONNX模型输出了提示溢出的两层的输出张量,但是发现并没有超出FP16表示范围的数值。
值得注意的是,提示溢出的reducemean层和add层,我在rknntoolkit2的运行日志中并没有找到reducemean算子,而多了一个ReduceMean_1_2avgpool的算子。
此外,如果开启量化,则不会有溢出的问题,但是rknn模型输出的结果和原始的onnx模型不一致(量化校正数据集不管只传入一张输入数据还是50-100张数据都不对)。自己训练的模型传入的是预处理后的(1,6,224,224)排布的npy文件,使用官方的convnext模型则不会出现溢出和数据不一致的问题。
目前对这个问题不知道该如何下手,请问能否给一些解决的方法或建议?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant