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

Build with XNNPACK #36

Closed
asus4 opened this issue Jul 20, 2020 · 11 comments · Fixed by #214
Closed

Build with XNNPACK #36

asus4 opened this issue Jul 20, 2020 · 11 comments · Fixed by #214
Labels
enhancement New feature or request

Comments

@asus4
Copy link
Owner

asus4 commented Jul 20, 2020

https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/delegates/xnnpack

XNNPACK is a highly optimized library of floating-point neural network inference operators for ARM, x86, and WebAssembly architectures in Android, iOS, Windows, Linux, macOS, and Emscripten environments. This document describes how to use the XNNPACK library as an inference engine for TensorFlow Lite.

@asus4 asus4 added the enhancement New feature or request label Jul 20, 2020
@TheBricktop
Copy link

Could this boost the performance?
I've tried mediapipe hands on gpu on android (s8) and they get about 20-25 fps but current hands implementation are very slow on pc. (i7 16 gb ram gti 960 ti)

@asus4
Copy link
Owner Author

asus4 commented Oct 28, 2020

Hi @TheBricktop, This is because the GPU delegate (a GPU acceleration feature of the TensorFlow Lite) is not supported on Window at the moment. I would like to support it eventually.

@TheBricktop
Copy link

What ones should do to implement it? Recompile tf lite library?

@asus4
Copy link
Owner Author

asus4 commented Oct 28, 2020

It looks like to be not officially supported.
tensorflow/tensorflow#40325

@TheBricktop
Copy link

So on android the performance would be higher?

@asus4
Copy link
Owner Author

asus4 commented Oct 28, 2020

Yes, if you are interested in using MediaPipe without the GPU delegate, please refer XNNPACK(this issue) or the integer quantized model

@TheBricktop
Copy link

Would exporting tflite models to onnx and running in barracuda improve the performance?

@asus4
Copy link
Owner Author

asus4 commented Nov 2, 2020

Yes, if all ops are supported in Barracuda, could improve it. Please refer to the supported ops in Barracuda

@asus4
Copy link
Owner Author

asus4 commented Feb 3, 2021

Now, XNNPACK options are enabled in v2.4 libraries

@asus4 asus4 closed this as completed Feb 3, 2021
@tonysung
Copy link

@asus4 I suspect XNNPACK is not correctly enabled based on the following observations:

  1. Currently the CPU mode performance of tf-lite-unity-sample is closer to what I get from the official benchmark tool (https://www.tensorflow.org/lite/performance/measurement) with use_xnnpack=false.
  2. From Tensorflow source code, I think TfLiteXNNPackDelegateCreate must be called in order for XNNPACK to be actually enabled. I don't see it being called anywhere in tf-lite-unity-sample.
  3. When running the official benchmark tool with use_xnnpack=true, there will be a line in log that says Created TensorFlow Lite XNNPACK delegate for CPU. It's missing when tf-lite-unity-sample is run.

Would you like to take a look?

@asus4
Copy link
Owner Author

asus4 commented May 2, 2022

Thanks, @tonysung

I mistakenly thought it would be automatically enabled on the CPU mode. I will add XNNPack delegate.

https://github.com/tensorflow/tensorflow/blob/3f878cff5b698b82eea85db2b60d65a2e320850e/tensorflow/lite/delegates/xnnpack/xnnpack_delegate.h#L48

@asus4 asus4 reopened this May 2, 2022
@asus4 asus4 closed this as completed in #214 May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants