3

using the Qualcomm NeturalNetwork SDK. i can run the SNPE SDK Example and change to inception_v3 model, works fine.

but snpe will block-ui thread in the execute();

i have no way to stop this. android user will get bad UX.

i have tryed: low priority thread, job scheduler, etc

when i execute snpe with GPU, it always block the UI.

How can i config the SNPE, the Android UI is the high priority, SNPE is the lower priority, so we can get result quickly and do not block the UI

thank you.

3 Answers3

3

The bulk operation on GPU blocks the rendering of new frames. It's hard to solve this problem and it actually have nothing to do with SNPE, because we can reproduce this issue using non-SNPE implementation (in-house OpenCL-based framework). You can simply change the placement of tensor operations to mitigate this problem. For example, you can do the computation on CPU (e.g.: tensorflow mobile), and the UI can be rendered properly while being much slower and CPU-hunger.

It's possible to visualize my explanation by on-device developer options. For more information, follow this link: https://developer.android.com/studio/profile/inspect-gpu-rendering#profile_rendering. You'll be able to see that several "Swap Buffer"1 operations could take unusually long intervals.

The best solution is to do computation on DSP with quantized network, but there are many limitations on the available operators and memory.

It's possible that Android 8.1 could solve these issues with NN-API abstraction and OS-level scheduling of GPU-resource, but I would not expect too much from Google.

BTW: I have a hypothetical scheme to mitigate this issue by fragmenting the bulk operations. In theory, if the worker-thread would sleep for 20ms between sub-50ms operations so that UI thread could render properly, the user experience should be tolerable since the FPS could be maintained above 15. We'll try this scheme because this handicapped scheme should still be much faster than schemes based on CPU.

Droidberg
  • 31
  • 2
  • the DSP solution is Qualcomm only? the Google Pixel2 has no SNPE GPU & DSP Support but is 835 CPU, There is no Document about what hardware support Non-CPU mode in NN-API or Tensorflow-lite (f you google) so i can't make real CNN app with Android. do you have real GPU solution/github ref for Android Phones? ( is Open CL?) – SomeOneNewbid May 26 '18 at 08:22
0

You should be able to use an AsyncTask to run your inference on a background thread. See 'ClassifyImageTask' in the SNPE SDK for an example of this.

Nic Dahlquist
  • 1,005
  • 12
  • 15
  • this is not working, the snpe use the GPU resources, i can run SNPE in any thread but it still block the ui, i have set the thread low priority or use jobscheduler, not working at all. – SomeOneNewbid Mar 25 '18 at 06:54
0

For SNPE GPU runtime, you can use low execution hint, which will set SNPE to lowest GPU priority.

By setting ExecutionPriorityHint_t::Low thru SNPEBuilder::setExecutionPriorityHint()

Quanlong
  • 24,028
  • 16
  • 69
  • 79