tensorflow / tensorflow

An Open Source Machine Learning Framework for Everyone
https://tensorflow.org
Apache License 2.0
185.43k stars 74.17k forks source link

How to reduce the size of the shared library #72878

Closed saad-koukous closed 3 weeks ago

saad-koukous commented 1 month ago

System information

processor : 0 model name : ARMv7 Processor rev 2 (v7l) BogoMIPS : 995.32 Features : half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpd32 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x3 CPU part : 0xc08 CPU revision : 2

Hardware : Generic AM33XX (Flattened Device Tree) Revision : 0000 Serial : 2218SBB15982 ldd (Debian GLIBC 2.28-10) 2.28 gcc version 8.3.0

i'm trying to build the library using this toolchain : gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf I successfully built a shared library, but the size of the .so file is 4 MB, which is too big for me. How can I reduce it? is there any way to limit the operators and types required by my model

Venkat6871 commented 1 month ago

Hi @saad-koukous ,

bazel build --config=elinux_armhf --cpu=armhf //tensorflow/lite:libtensorflowlite_c.so

Thank you!

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you.

github-actions[bot] commented 3 weeks ago

This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further.

saad-koukous commented 5 days ago

Hi @Venkat6871 I tried using the strip command as you suggested to remove unnecessary symbols from the libtensorflowlite_c.so However, the size of the library did not change after stripping.

Additionally, I tried compiling the library specifically for the ARMv7 architecture Unfortunately, the file size remained the same even after these attempts. It seems that there might not be any significant symbols or unnecessary code that can be stripped from the library.

If you have any other suggestions or further optimizations to try, please let me know!

Thank you!