-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[Mobile] ONNXRuntime giving different outputs on NNAPI and CPU EP #19518
Comments
Is this a duplicate of #19507? Hard to tell from a subset of output in a screenshot. Which of the 1000 results have the highest probability if you apply softmax to the output to convert to percentage probabilities? Does the label with the highest probability differ between CPU and NNAPI? Does the percentage probability for the best match change significantly? We haven't changed anything about how NNAPI runs and I don't recall any other issue saying the output was completely incorrect. We test the NNAPI model generated for individual the operators using the same unit test code that tests the CPU EP implementations. If values were completely off those tests should fail. |
Does the label with the highest probability differ between CPU and NNAPI?
Does the percentage probability for the best match change significantly?
for the black image it was like ~3%(highest) probability on matchbox on CPU, on NNAPI it was something else with probability of ~0.17%. |
@skottmckay , the outputs of NNAPI EP and CPU EP differ on a few devices and NOT all of them. From our tests, were were able to replicate this issue while executing models with NNAPI using onnxruntime on devices with below mentioned chipsets : Majority of the mobile devices where we were able to reproduce the issue were based these chipsets:
You can try replicating these issues on the mobile device mentioned using BrowserStack or LambdaTest |
The black image doesn't seem like a good test. Neither 3% or 0.17% are good scores for a match - which isn't surprising as the model was not trained to detect black images. What about the goldfish? Different hardware will execute the model using different instructions/ordering. That results in differences in the floating point numbers. A matmul (used in Conv) is a lot of multiplications and additions. That may get batched differently or done in a different order. https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html |
For goldfish too. |
Moreover we experimented same thing with icons-50 model on the same mobile device as above (oneplus7 GM 1901) Below are the corresponding outputs on NNAPI and CPU on ORT and tflite for the image below. Clearly there is no disparity in outputs across EPs in tflite. |
@skottmckay |
### Description <!-- Describe your changes. --> A number of Qualcomm Snapdragon chipsets do not produce correct output if we skip the Reshape, which ironically was a performance optimization for Snapdragon chips. Perf testing showed that Squeeze also seems to execute on CPU so there's no benefit to using that as an alternative where possible e.g. Global*Pool -> Reshape to 2D -> Gemm could be potentially be replaced with Global*Pool -> Squeeze dims 2 and 3 -> Gemm if that offered better performance. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> #19518
This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details. |
Describe the issue
ONNX Model
MobileNetv2-FP32
gives different outputs on CPU and NNAPI EP.We observed this behaviour on multiple different mobile phones, to name a few:
The output Logits for the models are different on same sets of images:
Mobile : OnePlus 7
Model - GM 1901
Architecture - arm64-v8a
OS Version - Oxygen OS 12.1
Processor - Qualcomm Snapdragon 855 octa-core
Android Version - Android 12
Difference in Logits values can be seen in attached Logcat screenshot
To reproduce
ORTApp.zip
Urgency
HIGH
Platform
Android
OS Version
13
ONNX Runtime Installation
Released Package
Compiler Version (if 'Built from Source')
No response
Package Name (if 'Released Package')
onnxruntime-android
ONNX Runtime Version or Commit ID
1.16.3
ONNX Runtime API
Java/Kotlin
Architecture
ARM64
Execution Provider
Default CPU, NNAPI
Execution Provider Library Version
No response
The text was updated successfully, but these errors were encountered: