mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
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
114 lines
3.5 KiB
CMake
114 lines
3.5 KiB
CMake
if(INTERN_BUILD_MOBILE)
|
|
if(BUILD_CAFFE2_MOBILE)
|
|
caffe2_binary_target("predictor_verifier.cc")
|
|
caffe2_binary_target("speed_benchmark.cc")
|
|
else()
|
|
caffe2_binary_target("speed_benchmark_torch.cc")
|
|
if(NOT BUILD_LITE_INTERPRETER)
|
|
caffe2_binary_target("compare_models_torch.cc")
|
|
endif()
|
|
endif()
|
|
return()
|
|
endif()
|
|
|
|
caffe2_binary_target("convert_caffe_image_db.cc")
|
|
caffe2_binary_target("convert_db.cc")
|
|
caffe2_binary_target("make_cifar_db.cc")
|
|
caffe2_binary_target("make_mnist_db.cc")
|
|
caffe2_binary_target("parallel_info.cc")
|
|
target_include_directories(parallel_info PUBLIC
|
|
${CMAKE_BINARY_DIR}/aten/src) # provides "ATen/TypeExtendedInterface.h" to ATen.h
|
|
|
|
caffe2_binary_target("intra_inter_benchmark.cc")
|
|
target_include_directories(intra_inter_benchmark PUBLIC
|
|
${CMAKE_BINARY_DIR}/aten/src)
|
|
|
|
caffe2_binary_target("at_launch_benchmark.cc")
|
|
target_include_directories(at_launch_benchmark PUBLIC
|
|
${CMAKE_BINARY_DIR}/aten/src)
|
|
|
|
caffe2_binary_target("record_function_benchmark.cc")
|
|
target_include_directories(record_function_benchmark PUBLIC
|
|
${CMAKE_BINARY_DIR}/aten/src)
|
|
|
|
caffe2_binary_target("predictor_verifier.cc")
|
|
caffe2_binary_target("print_registered_core_operators.cc")
|
|
caffe2_binary_target("run_plan.cc")
|
|
caffe2_binary_target("speed_benchmark.cc")
|
|
caffe2_binary_target("speed_benchmark_torch.cc")
|
|
caffe2_binary_target("compare_models_torch.cc")
|
|
caffe2_binary_target("split_db.cc")
|
|
|
|
caffe2_binary_target("db_throughput.cc")
|
|
|
|
if(BUILD_TEST)
|
|
# Core overhead benchmark
|
|
caffe2_binary_target("core_overhead_benchmark.cc")
|
|
target_link_libraries(core_overhead_benchmark benchmark)
|
|
endif()
|
|
|
|
if(USE_CUDA)
|
|
caffe2_binary_target("inspect_gpu.cc")
|
|
target_link_libraries(inspect_gpu ${CUDA_LIBRARIES})
|
|
caffe2_binary_target("print_core_object_sizes_gpu.cc")
|
|
|
|
if(BUILD_TEST)
|
|
# Core overhead benchmark
|
|
caffe2_binary_target("core_overhead_benchmark_gpu.cc")
|
|
target_link_libraries(core_overhead_benchmark_gpu benchmark ${CUDA_curand_LIBRARY})
|
|
endif()
|
|
endif()
|
|
|
|
if(USE_ROCM)
|
|
caffe2_hip_binary_target("hip/inspect_gpu.cc")
|
|
caffe2_hip_binary_target("hip/print_core_object_sizes_gpu.cc")
|
|
|
|
if(BUILD_TEST)
|
|
# Core overhead benchmark
|
|
caffe2_hip_binary_target("hip/core_overhead_benchmark_gpu.cc")
|
|
target_link_libraries(core_overhead_benchmark_gpu benchmark)
|
|
endif()
|
|
endif()
|
|
|
|
if(USE_ZMQ)
|
|
caffe2_binary_target("zmq_feeder.cc")
|
|
target_link_libraries(zmq_feeder ${ZMQ_LIBRARIES})
|
|
endif()
|
|
|
|
if(USE_MPI)
|
|
caffe2_binary_target("run_plan_mpi.cc")
|
|
target_link_libraries(run_plan_mpi ${MPI_CXX_LIBRARIES})
|
|
endif()
|
|
|
|
if(USE_OPENCV AND USE_LEVELDB)
|
|
caffe2_binary_target("convert_encoded_to_raw_leveldb.cc")
|
|
target_link_libraries(
|
|
convert_encoded_to_raw_leveldb
|
|
${OpenCV_LIBS} ${LevelDB_LIBRARIES} ${Snappy_LIBRARIES})
|
|
endif()
|
|
|
|
if(USE_OPENCV)
|
|
caffe2_binary_target("make_image_db.cc")
|
|
target_link_libraries(make_image_db ${OpenCV_LIBS})
|
|
caffe2_binary_target("convert_image_to_tensor.cc")
|
|
target_link_libraries(convert_image_to_tensor ${OpenCV_LIBS})
|
|
endif()
|
|
|
|
if(USE_OBSERVERS)
|
|
caffe2_binary_target(caffe2_benchmark "caffe2_benchmark.cc" "benchmark_helper.cc")
|
|
endif()
|
|
|
|
if(USE_OBSERVERS AND USE_OPENCV)
|
|
caffe2_binary_target("convert_and_benchmark.cc")
|
|
target_link_libraries(convert_and_benchmark ${OpenCV_LIBS})
|
|
endif()
|
|
|
|
# ---[ tutorials
|
|
caffe2_binary_target("tutorial_blob.cc")
|
|
|
|
caffe2_binary_target("dump_operator_names.cc")
|
|
caffe2_binary_target("optimize_for_mobile.cc")
|
|
|
|
caffe2_binary_target(aot_model_compiler "aot_model_compiler.cc")
|
|
target_link_libraries(aot_model_compiler torch)
|