tensorflow / tflite-support

TFLite Support is a toolkit that helps users to develop ML and deploy TFLite models onto mobile / ioT devices.
Apache License 2.0
370 stars 124 forks source link

Profiling a TFLite #628

Open roger-creus opened 3 years ago

roger-creus commented 3 years ago

Hello everybody :)

I am using a custom TFLite model in an Android Studio Application and want to profile it so I can see the resources spent in each layer of the model. I have followed https://www.tensorflow.org/lite/performance/measurement but I am not capable of seeing the layer-specific resources in the profiler window. I wonder what is the best way of profiling the TFLite model (I have seen that it can also be done directly with adb but I'm not sure the profiled results are consistent with the real ones obtained in Android Studio).

Thank you!

xunkai55 commented 3 years ago

Asking @multiverse-tf for help.

multiverse-tf commented 3 years ago

Hi @yuyecreus, could you provide the Android phone you've used for the profiling, and more details about the steps you've done to get the profiling results in Android Studio?

As you are aware of the cmdline-based benchmark tool, although the exact results you obtain might be different from what you'll obtain in Android Studio, both of them are expected to show same performance issues. In particular, see this part for details about obtaining per-op profiling info.

FYI, nightly-pre-built benchmark tools could be found here.

roger-creus commented 3 years ago

Hi @yuyecreus, could you provide the Android phone you've used for the profiling, and more details about the steps you've done to get the profiling results in Android Studio?

As you are aware of the cmdline-based benchmark tool, although the exact results you obtain might be different from what you'll obtain in Android Studio, both of them are expected to show same performance issues. In particular, see this part for details about obtaining per-op profiling info.

FYI, nightly-pre-built benchmark tools could be found here.

I have used a Xiaomi Poco X3 NFC. I have followed the steps for profiling in Android Studio https://www.tensorflow.org/lite/performance/measurement#android_studio_cpu_profiler. I can follow them but in the end I see no model related or per-op profilinig info as in the example under the recognizeImage() function. In fact, It does not appear any wrapper like the recognizeImage() function in the example.

Thank you!

lu-wang-g commented 3 years ago

@multiverse-tf can you please follow up with the questions above? Thanks!