pytorch/binaries
Priya Ramani 78209b93b3 Don't build shared library for AOT Compiler (#66227)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/66227

Building a shared library for AOT Compiler is not necessary as it's included in libtorch. Also having this built as a shared library was affecting android builds and we don't need to build AOT Compiler for mobile builds

Before fix:
```
(pytorch)  ~/local/pytorch master
└─ $ ANDROID_NDK=/opt/android_ndk/r20/ BUILD_PYTORCH_MOBILE=1 ANDROID_ABI=armeabi-v7a ./scripts/build_android.sh -DBUILD_BINARY=ON
Build with ANDROID_ABI[armeabi-v7a], ANDROID_NATIVE_API_LEVEL[21]
Bash: GNU bash, version 5.0.11(1)-release (x86_64-redhat-linux-gnu)
Python: 3.9.7 (default, Sep 16 2021, 13:09:58)
[GCC 7.5.0]
Caffe2 path: /data/users/priyaramani/pytorch
Using Android NDK at /opt/android_ndk/r20/
.
.
FAILED: lib/libaot_compiler.so
: && /opt/android_ndk/r20/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=armv7-none-linux-androideabi21 --gcc-toolchain=/opt/android_ndk/r20/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/opt/and
roid_ndk/r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -march=armv7-a -mt
humb -Wa,--noexecstack -Wformat -Werror=format-security -frtti -fexceptions  -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DUSE_KINETO -DLIBKINETO_NOCUPTI -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -
DBUILD_LITE_INTERPRETER -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bound
s -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -W
no-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -Wno-invalid-partial-specialization -Wno-typedef-redefinition -Wno-unknown-warning-option -Wno-unused-private-field -Wno-inconsistent-miss
ing-override -Wno-aligned-allocation-unavailable -Wno-c++14-extensions -Wno-constexpr-not-const -Wno-missing-braces -Qunused-arguments -fcolor-diagnostics -Wno-unused-but-set-variable -Wno-maybe-uninitialized
-fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -g0 -Oz -DNDEBUG  -Wl,--exclude-libs,libgcc.a -Wl,--exclude-libs,libatomic.a -static-libstdc++ -Wl,--build-id -Wl,--warn-shared-text
rel -Wl,--fatal-warnings -Wl,--exclude-libs,libunwind.a -Wl,--no-undefined -Qunused-arguments -Wl,-z,noexecstack  -rdynamic -shared -Wl,-soname,libaot_compiler.so -o lib/libaot_compiler.so caffe2/torch/CMakeFi
les/aot_compiler.dir/csrc/jit/mobile/nnc/aot_compiler.cpp.o  -latomic -lm && :
caffe2/torch/CMakeFiles/aot_compiler.dir/csrc/jit/mobile/nnc/aot_compiler.cpp.o:aot_compiler.cpp:function at::from_blob(void*, c10::ArrayRef<long long>, c10::TensorOptions const&): error: undefined reference t
o 'at::TensorMaker::make_tensor()'
.
.
caffe2/torch/CMakeFiles/aot_compiler.dir/csrc/jit/mobile/nnc/aot_compiler.cpp.o:aot_compiler.cpp:function torch::jit::mobile::nnc::Function::Function(): error: undefined reference to 'c10::AnyType::get()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
```

After fix:
```
(pytorch)  ~/local/pytorch master
└─ $ ANDROID_NDK=/opt/android_ndk/r20/ BUILD_PYTORCH_MOBILE=1 ANDROID_ABI=armeabi-v7a ./scripts/build_android.sh -DBUILD_BINARY=ON
Build with ANDROID_ABI[armeabi-v7a], ANDROID_NATIVE_API_LEVEL[21]
Bash: GNU bash, version 5.0.11(1)-release (x86_64-redhat-linux-gnu)
Python: 3.9.7 (default, Sep 16 2021, 13:09:58)
[GCC 7.5.0]
Caffe2 path: /data/users/priyaramani/pytorch
Using Android NDK at /opt/android_ndk/r20/
.
.
-- Build files have been written to: /data/users/priyaramani/pytorch/build_android
Will install headers and libs to /data/users/priyaramani/pytorch/build_android/install for further Android project usage.
[2/3] Install the project...
-- Install configuration: "Release"
Installation completed, now you can copy the headers/libs from /data/users/priyaramani/pytorch/build_android/install to your Android project directory.
```

Test Plan: Imported from OSS

Reviewed By: ljk53, axitkhurana

Differential Revision: D31450970

Pulled By: priyaramani

fbshipit-source-id: 87e48033f1db46fef112bae1239a09a2365620d2
2021-10-06 15:57:32 -07:00
..
bench_gen Revert D30279364: [codemod][lint][fbcode/c*] Enable BLACK by default 2021-08-12 11:45:01 -07:00
aot_model_compiler.cc Refactor AotCompile to return a pair (#65707) 2021-09-27 18:56:04 -07:00
at_launch_benchmark.cc
benchmark_args.h
benchmark_helper.cc [easy]Unbreak caffe2benchmarking build (#63655) 2021-08-20 12:57:27 -07:00
benchmark_helper.h
caffe2_benchmark.cc
CMakeLists.txt Don't build shared library for AOT Compiler (#66227) 2021-10-06 15:57:32 -07:00
compare_models_torch.cc Small improvements to compare_models_torch binary (#65171) 2021-09-17 08:32:45 -07:00
convert_and_benchmark.cc
convert_caffe_image_db.cc
convert_db.cc
convert_encoded_to_raw_leveldb.cc
convert_image_to_tensor.cc
core_overhead_benchmark.cc
core_overhead_benchmark_gpu.cc
db_throughput.cc
dump_operator_names.cc
inspect_gpu.cc
intra_inter_benchmark.cc
lite_interpreter_model_load.cc
make_cifar_db.cc
make_image_db.cc
make_mnist_db.cc
optimize_for_mobile.cc
parallel_info.cc
predictor_verifier.cc
print_core_object_sizes_gpu.cc
print_registered_core_operators.cc
record_function_benchmark.cc
run_plan.cc
run_plan_mpi.cc
speed_benchmark.cc
speed_benchmark_torch.cc Update Vulkan runner in benchmark binary to handle non-tensor inputs (#66123) 2021-10-05 07:59:56 -07:00
split_db.cc
tsv_2_proto.cc
tutorial_blob.cc
zmq_feeder.cc