The file size of dynamic libraries for android generated under pytorch/build_android/install/lib are very large. Here is the detail:
-rw-r–r-- 1 ultraz ultraz 5.7M Jun 30 23:17 build_android/install/lib/libc10.so
-rw-r–r-- 1 ultraz ultraz 82M Jun 30 23:19 build_android/install/lib/libtorch_cpu.so
-rw-r–r-- 1 ultraz ultraz 7.4K Jun 30 23:17 build_android/install/lib/libtorch_global_deps.so
-rw-r–r-- 1 ultraz ultraz 7.4K Jun 30 23:19 build_android/install/lib/libtorch.so
For libtorch_cpu, it is 82M, which is considerably large once integrated into a mobile app. I see the script/build_android.sh has already disabled a lot of features. I would like to ask if it is possible to further reduce the size of libs?
From the number, this libtorch_cpu.so includes all 4 android abis (armeabi-v7a, arm64-v8a, x86, x86_64). For one device, only one abi is needed and size should be much less. Select build is another way to bring down. the size.
I have tested a couple of cases for ANDROID_ABI=arm64-v8a, and here is the result:
BUILD_LITE_INTERPRETER=0 ./script/build_android.sh → libtorch_cpu.so is 89M
BUILD_LITE_INTERPRETER=1 ./script/build_android.sh → libtorch_cpu.so is 81M
BUILD_LITE_INTERPRETER=1 .SELECTED_OP_LIST=scripted_lenet_model.yaml /script/build_android.sh → libtorch_cpu.so is 75M
@cccclai Can you clarify that I am using the new interpreter? For your second point, I think it only builds one specific ABI because I have declared before compiling.