alibaba / MNN

MNN is a blazing fast, lightweight deep learning framework, battle-tested by business-critical use cases in Alibaba
http://www.mnn.zone/
8.72k stars 1.67k forks source link

Wrong result Android openCL #1736

Closed gasgallo closed 1 year ago

gasgallo commented 3 years ago

I'm using MNN 1.2.2 to run my model on Android. When using openCL backend, I get some errors from openCL and the result from the model is incorrect. When using CPU backend, everything works fine.

I get errors like:

CL ERROR CODE : -52, info:convertBufferToImage 
...
CL ERROR CODE : -52, info:run2d 

Sample output from CPU backend (correct):

[0.018049, -0.011520, -0.015695, -0.025913, 0.018867 ...]

And openCL backend (wrong):

[0.019774, 0.037925, -0.075156, -0.024256, -0.080709 ...]

If I use MNN_GPU_MEMORY_BUFFER, there are no openCL errors, but output is all NaNs:

[nan nan nan nan nan ...]

This is the model that you guys can test to reproduce the problem. This problem happens for other similar models as well.

Thanks for the help!

jxt1234 commented 3 years ago

What's your machine?

jxt1234 commented 3 years ago

The model don't has weight and can't be run. Could you upload a correct one?

gasgallo commented 3 years ago

@jxt1234 I'm using Xiaomi mi9 for my deployment.

Here's another model (with weights), the architecture is a bit different, but the error/problem is exactly the same: link

gasgallo commented 3 years ago

@jxt1234 any update?

I've also noticed that MNN_GPU_MEMORY_BUFFER gives wrong results on other devices as well. For example with rk3399 (with MALI GPU), MNN_GPU_MEMORY_BUFFER is picked by default but the model output is always wrong and not only with the model that I've already shared, but also with all the other different models that I've tested as well. This happens only with Precision_Low, if I set Precision_High, then the results are correct, but the inference time is very slow.

I hope this information can help finding the issue, feel free to let me know if I can help in any other way.

jxt1234 commented 3 years ago

Sorry. Your model link I can't open. Could you send it to my email?

gasgallo commented 3 years ago

@jxt1234 the file is too big for email. I've uploaded in my github: https://github.com/gasgallo/model-zoo/blob/master/MNN/test.mnn. You should be able to download it from there.

kevinmgyu commented 1 year ago

这个问题解决了吗? @wangzhaode