diff --git a/CMakeLists.txt b/CMakeLists.txt index 312bdb7f1ae11576abf6f5ec222bae72bcd67bb5..bd25403836ea4055e546236258ca6d331d30c1e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ include(system) if(LITE_WITH_LIGHT_WEIGHT_FRAMEWORK) cmake_minimum_required(VERSION 3.10) # TODO(TJ): make as function check_default + # check os if(NOT DEFINED ARM_TARGET_OS) set(ARM_TARGET_OS "android" CACHE STRING "Choose ARM Target OS") endif() @@ -31,19 +32,17 @@ if(LITE_WITH_LIGHT_WEIGHT_FRAMEWORK) message(FATAL_ERROR "ARM_TARGET_OS must be in one of ${ARM_TARGET_OS_LIST}") endif() + # check arch abi if(NOT DEFINED ARM_TARGET_ARCH_ABI) - set(ARM_TARGET_ARCH_ABI "arm64-v8a" CACHE STRING "Choose ARM Target ARCH ABI") + set(ARM_TARGET_ARCH_ABI "armv8" CACHE STRING "Choose ARM Target ARCH ABI") endif() - set(ARM_TARGET_ARCH_ABI_LIST "arm64-v8a" "armeabi-v7a" "armeabi-v7a-softfp" "armeabi-v7a-hf") + set(ARM_TARGET_ARCH_ABI_LIST "armv8" "armv7" "armv7hf" "arm64-v8a" "armeabi-v7a") set_property(CACHE ARM_TARGET_ARCH_ABI PROPERTY STRINGS ${ARM_TARGET_ARCH_ABI_LIST}) if (NOT ARM_TARGET_ARCH_ABI IN_LIST ARM_TARGET_ARCH_ABI_LIST) message(FATAL_ERROR "ARM_TARGET_ARCH_ABI must be in one of ${ARM_TARGET_ARCH_ABI_LIST}") endif() - if(NOT DEFINED TARGET_ARCH_ABI) - set(ARCH_ABI "arm64-v8a" CACHE STRING "Choose android platform") - endif() - + message(STATUS "Lite ARM Compile ${ARM_TARGET_OS} with ${ARM_TARGET_ARCH_ABI}") include(cross_compiling/host) include(cross_compiling/armlinux) include(cross_compiling/android) @@ -171,8 +170,20 @@ if (WITH_LITE AND LITE_WITH_LIGHT_WEIGHT_FRAMEWORK) include(generic) # simplify cmake module include(configure) # add paddle env configuration - add_definitions(-std=c++11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + find_package(OpenMP REQUIRED) + if(OPENMP_FOUND OR OpenMP_CXX_FOUND) + add_definitions(-DARM_WITH_OMP) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + message(STATUS "Found OpenMP ${OpenMP_VERSION} ${OpenMP_CXX_VERSION}") + message(STATUS " |-- OpenMP C flags: ${OpenMP_C_FLAGS}") + message(STATUS " |-- OpenMP CXX flags: ${OpenMP_CXX_FLAGS}") + message(STATUS " |-- OpenMP OpenMP_CXX_LIB_NAMES: ${OpenMP_CXX_LIB_NAMES}") + message(STATUS " `-- OpenMP OpenMP_CXX_LIBRARIES: ${OpenMP_CXX_LIBRARIES}") + else() + message(FATAL_ERROR "Could not found openmp !") + endif() add_subdirectory(paddle) return() diff --git a/cmake/cross_compiling/android.cmake b/cmake/cross_compiling/android.cmake index e57f32aae7c1d59696ce0b49e3add0ff4c51da0e..24f2bf676d358ea96d14fb4233ca7fd8b27709f9 100644 --- a/cmake/cross_compiling/android.cmake +++ b/cmake/cross_compiling/android.cmake @@ -26,7 +26,6 @@ if(NOT DEFINED ANDROID_NDK) endif() endif() - if(NOT DEFINED ANDROID_API_LEVEL) set(ANDROID_API_LEVEL "22") endif() @@ -35,19 +34,26 @@ if(NOT DEFINED ANDROID_STL_TYPE) set(ANDROID_STL_TYPE "c++_static" CACHE STRING "stl type") endif() -# TODO(TJ): enable me -if(ARM_TARGET_ARCH_ABI STREQUAL "armeabi-v7a-hf") - message(FATAL_ERROR "Not supported building android armeabi-v7a-hf yet") +if(ARM_TARGET_ARCH_ABI STREQUAL "armv7hf") + message(FATAL_ERROR "ANDROID does not support hardfp on v7 use armv7 instead.") endif() set(ANDROID_ARCH_ABI ${ARM_TARGET_ARCH_ABI} CACHE STRING "Choose Android Arch ABI") +if(ARM_TARGET_ARCH_ABI STREQUAL "armv8") + set(ANDROID_ARCH_ABI "arm64-v8a") +endif() + +if(ARM_TARGET_ARCH_ABI STREQUAL "armv7") + set(ANDROID_ARCH_ABI "armeabi-v7a") +endif() + if(ANDROID_ARCH_ABI STREQUAL "armeabi-v7a-softfp") set(ANDROID_ARCH_ABI "armeabi-v7a") endif() set(ANDROID_ARCH_ABI_LIST "arm64-v8a" "armeabi-v7a" "armeabi-v6" "armeabi" - "mips" "mips64" "x86" "x86_64" "armeabi-v7a-hf") + "mips" "mips64" "x86" "x86_64") set_property(CACHE ANDROID_ARCH_ABI PROPERTY STRINGS ${ANDROID_ARCH_ABI_LIST}) if(NOT ANDROID_ARCH_ABI IN_LIST ANDROID_ARCH_ABI_LIST) message(FATAL_ERROR "ANDROID_ARCH_ABI must be in one of ${ANDROID_ARCH_ABI_LIST}") @@ -59,13 +65,6 @@ if(ANDROID_ARCH_ABI STREQUAL "armeabi-v7a") message(STATUS "NEON is enabled on arm-v7a with softfp") endif() -if(ANDROID_ARCH_ABI STREQUAL "armeabi-v7a-hf") - set(ANDROID_ARCH_ABI "armeabi-v7a") - set(CMAKE_CXX_FLAGS "-std=c++11 -march=armv7-a -mfloat-abi=hard -mfpu=neon-vfpv4 ${CMAKE_CXX_FLAGS}" ) - set(CMAKE_C_FLAGS "-march=armv7-a -mfloat-abi=hard -mfpu=neon-vfpv4 ${CMAKE_C_FLAGS}" ) - message(STATUS "NEON is enabled on arm-v7a with hard float") -endif() - set(ANDROID_STL_TYPE_LITS "gnustl_static" "c++_static") set_property(CACHE ANDROID_STL_TYPE PROPERTY STRINGS ${ANDROID_STL_TYPE_LITS}) if (NOT ANDROID_STL_TYPE IN_LIST ANDROID_STL_TYPE_LITS) diff --git a/cmake/cross_compiling/armlinux.cmake b/cmake/cross_compiling/armlinux.cmake index 1d752075cca2d48d19016999a60c45d9882b1f73..f0fd26804e19f9dba8f515251c625c0e68933512 100644 --- a/cmake/cross_compiling/armlinux.cmake +++ b/cmake/cross_compiling/armlinux.cmake @@ -20,7 +20,15 @@ set(ARMLINUX TRUE) add_definitions(-DLITE_WITH_LINUX) set(CMAKE_SYSTEM_NAME Linux) -if(ARM_TARGET_ARCH_ABI STREQUAL "arm64-v8a") +set(ARMLINUX_ARCH_ABI ${ARM_TARGET_ARCH_ABI} CACHE STRING "Choose Android Arch ABI") + +set(ARMLINUX_ARCH_ABI_LIST "armv8" "armv7" "armv7hf") +set_property(CACHE ARMLINUX_ARCH_ABI PROPERTY STRINGS ${ARMLINUX_ARCH_ABI_LIST}) +if(NOT ARMLINUX_ARCH_ABI IN_LIST ARMLINUX_ARCH_ABI_LIST) + message(FATAL_ERROR "ARMLINUX_ARCH_ABI(${ARMLINUX_ARCH_ABI}) must be in one of ${ARMLINUX_ARCH_ABI_LIST}") +endif() + +if(ARMLINUX_ARCH_ABI STREQUAL "armv8") set(CMAKE_SYSTEM_PROCESSOR aarch64) set(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc") set(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++") @@ -30,13 +38,12 @@ if(ARM_TARGET_ARCH_ABI STREQUAL "arm64-v8a") message(STATUS "NEON is enabled on arm64-v8a") endif() -if(ARM_TARGET_ARCH_ABI STREQUAL "armeabi-v7a" - OR ARM_TARGET_ARCH_ABI STREQUAL "armeabi-v7a-hf") +if(ARMLINUX_ARCH_ABI STREQUAL "armv7" OR ARMLINUX_ARCH_ABI STREQUAL "armv7hf") message(FATAL_ERROR "Not supported building arm linux arm-v7 yet") endif() # TODO(TJ): make sure v7 works -if(ARM_TARGET_ARCH_ABI STREQUAL "armeabi-v7a") +if(ARMLINUX_ARCH_ABI STREQUAL "armv7") set(CMAKE_SYSTEM_PROCESSOR arm) set(CMAKE_C_COMPILER "arm-linux-gnueabi-gcc") set(CMAKE_CXX_COMPILER "arm-linux-gnueabi-g++") @@ -46,7 +53,7 @@ if(ARM_TARGET_ARCH_ABI STREQUAL "armeabi-v7a") message(STATUS "NEON is enabled on arm-v7a with softfp") endif() -if(ARM_TARGET_ARCH_ABI STREQUAL "armeabi-v7a-hf") +if(ARMLINUX_ARCH_ABI STREQUAL "armv7hf") set(CMAKE_SYSTEM_PROCESSOR arm) set(CMAKE_C_COMPILER "arm-linux-gnueabihf-gcc") set(CMAKE_CXX_COMPILER "arm-linux-gnueabihf-g++") diff --git a/paddle/fluid/lite/api/cxx_api_bin.cc b/paddle/fluid/lite/api/cxx_api_bin.cc index dec0b65eb2791b45bdf3fa54715af97a844342fc..f1a9a23e8d034be6c863a1c29ff19a3e831f35a2 100644 --- a/paddle/fluid/lite/api/cxx_api_bin.cc +++ b/paddle/fluid/lite/api/cxx_api_bin.cc @@ -13,7 +13,7 @@ // limitations under the License. #include "paddle/fluid/lite/api/cxx_api.h" -#include +#include // NOLINT #include "paddle/fluid/lite/core/mir/passes.h" #include "paddle/fluid/lite/core/op_registry.h" namespace paddle { @@ -66,8 +66,8 @@ void Run(const char* model_dir, int repeat) { } // namespace paddle int main(int argc, char** argv) { - CHECK_EQ(argc, 2) << "usage: ./cmd "; - paddle::lite::Run(argv[1], 1); + CHECK_EQ(argc, 3) << "usage: ./cmd "; + paddle::lite::Run(argv[1], std::stoi(argv[2])); return 0; } diff --git a/paddle/fluid/lite/core/context.cc b/paddle/fluid/lite/core/context.cc index cd7006f4724ccaa7d8733caff2ed4ef8c5d01f2f..89ec7278c1aaf8e372c45f24a32525df4f223418 100644 --- a/paddle/fluid/lite/core/context.cc +++ b/paddle/fluid/lite/core/context.cc @@ -28,6 +28,10 @@ #endif // TARGET_OS_IPHONE #endif // __APPLE__ +#ifdef ARM_WITH_OMP +#include +#endif + namespace paddle { namespace lite { @@ -84,7 +88,7 @@ ARMContext& Context::operator=(const ARMContext& ctx) { } void Context::BindDev() { -#ifdef USE_OPENMP +#ifdef ARM_WITH_OMP int num_threads = active_ids_.size(); omp_set_num_threads(num_threads); #ifdef LITE_WITH_LINUX @@ -98,12 +102,12 @@ void Context::BindDev() { } for (int i = 0; i < num_threads; i++) { if (ssarets[i] != 0) { - LOGE("set cpu affinity failed, cpuID: %d\n", active_ids_[i]); + LOG(ERROR) << "set cpu affinity failed, cpuID: " << active_ids_[i]; return; } } #endif // LITE_WITH_LINUX -#else // USE_OPENMP +#else // ARM_WITH_OMP #ifdef LITE_WITH_LINUX std::vector cpuid1; cpuid1.push_back(active_ids_[0]); @@ -113,7 +117,7 @@ void Context::BindDev() { return; } #endif // LITE_WITH_LINUX -#endif // USE_OPENMP +#endif // ARM_WITH_OMP } void Context::SetRunMode(PowerMode mode, int threads) { @@ -123,7 +127,7 @@ void Context::SetRunMode(PowerMode mode, int threads) { if (threads > big_core_size + small_core_size) { threads = big_core_size + small_core_size; } -#ifdef USE_OPENMP +#ifdef ARM_WITH_OMP count_++; int shift_num = (count_ / 10) % big_core_size; switch (mode) { @@ -146,8 +150,8 @@ void Context::SetRunMode(PowerMode mode, int threads) { if (big_core_size > 0) { mode_ = LITE_POWER_HIGH; if (threads > big_core_size) { - LOGE("threads: %d, exceed the big cores size: %d\n", threads, - big_core_size); + LOG(ERROR) << "threads: " << threads + << ", exceed the big cores size: " << big_core_size; active_ids_ = dev.big_core_ids_; } else { for (int i = 0; i < threads; ++i) { @@ -156,7 +160,7 @@ void Context::SetRunMode(PowerMode mode, int threads) { } } else { mode_ = LITE_POWER_LOW; - LOGE("HIGH POWER MODE is not support, switch to little cores\n"); + LOG(ERROR) << "HIGH POWER MODE is not support, switch to little cores"; if (threads > small_core_size) { active_ids_ = dev.little_core_ids_; } else { @@ -174,8 +178,8 @@ void Context::SetRunMode(PowerMode mode, int threads) { if (small_core_size > 0) { mode_ = LITE_POWER_LOW; if (threads > small_core_size) { - LOGW("threads: %d, exceed the little cores size: %d\n", threads, - small_core_size); + LOG(WARNING) << "threads: " << threads + << ", exceed the little cores size: " << small_core_size; active_ids_ = dev.little_core_ids_; } else { for (int i = 0; i < threads; ++i) { @@ -184,7 +188,7 @@ void Context::SetRunMode(PowerMode mode, int threads) { } } else { mode_ = LITE_POWER_HIGH; - LOGW("LOW POWER MODE is not support, switch to big cores\n"); + LOG(WARNING) << "LOW POWER MODE is not support, switch to big cores"; if (threads > big_core_size) { active_ids_ = dev.big_core_ids_; } else { @@ -211,8 +215,8 @@ void Context::SetRunMode(PowerMode mode, int threads) { if (big_core_size > 0) { mode_ = LITE_POWER_RAND_HIGH; if (threads > big_core_size) { - LOGW("threads: %d, exceed the big cores size: %d\n", threads, - big_core_size); + LOG(WARNING) << "threads: " << threads + << ", exceed the big cores size: " << big_core_size; active_ids_ = dev.big_core_ids_; } else { for (int i = 0; i < threads; ++i) { @@ -222,7 +226,8 @@ void Context::SetRunMode(PowerMode mode, int threads) { } } else { mode_ = LITE_POWER_LOW; - LOGW("HIGH POWER MODE is not support, switch to little cores\n"); + LOG(WARNING) + << "HIGH POWER MODE is not support, switch to little cores"; if (threads > small_core_size) { active_ids_ = dev.little_core_ids_; } else { @@ -240,8 +245,8 @@ void Context::SetRunMode(PowerMode mode, int threads) { if (small_core_size > 0) { mode_ = LITE_POWER_RAND_LOW; if (threads > small_core_size) { - LOGW("threads: %d, exceed the little cores size: %d\n", threads, - small_core_size); + LOG(WARNING) << "threads: " << threads + << ", exceed the little cores size: " << small_core_size; active_ids_ = dev.little_core_ids_; } else { for (int i = 0; i < threads; ++i) { @@ -251,7 +256,7 @@ void Context::SetRunMode(PowerMode mode, int threads) { } } else { mode_ = LITE_POWER_HIGH; - LOGW("LOW POWER MODE is not support, switch to big cores\n"); + LOG(WARNING) << "LOW POWER MODE is not support, switch to big cores"; if (threads > big_core_size) { active_ids_ = dev.big_core_ids_; } else { diff --git a/paddle/fluid/lite/kernels/arm/conv_compute.cc b/paddle/fluid/lite/kernels/arm/conv_compute.cc index a8a2ac790a3c045642277ef75367bbdd878f0d6d..e5988a3bb6f269d41a1fe083415c3ff6a3456847 100644 --- a/paddle/fluid/lite/kernels/arm/conv_compute.cc +++ b/paddle/fluid/lite/kernels/arm/conv_compute.cc @@ -28,6 +28,8 @@ void ConvCompute::PrepareForRun() { auto o_dims = param.output->dims(); auto& ctx = this->ctx_->template As(); + // TODO(xxx): make api and expose it + ctx.SetRunMode(LITE_POWER_HIGH, 4); int win = x_dims[3]; // nchw int hin = x_dims[2]; diff --git a/paddle/fluid/lite/kernels/arm/fc_compute.cc b/paddle/fluid/lite/kernels/arm/fc_compute.cc index e31c36d91dbb6cb38fd963510f779df754ec3434..c7a9269b5f9af40e89a8e58e1363c1b131f81ac4 100644 --- a/paddle/fluid/lite/kernels/arm/fc_compute.cc +++ b/paddle/fluid/lite/kernels/arm/fc_compute.cc @@ -27,6 +27,9 @@ void FcCompute::PrepareForRun() { auto x_dims = param.input->dims(); auto w_dims = param.w->dims(); + auto& ctx = this->ctx_->template As(); + ctx.SetRunMode(LITE_POWER_HIGH, 4); + CHECK_GE(x_dims.size(), 2UL); CHECK_EQ(w_dims.size(), 2UL); CHECK_EQ(param.output->dims().size(), 2UL); diff --git a/paddle/fluid/lite/kernels/arm/mul_compute.cc b/paddle/fluid/lite/kernels/arm/mul_compute.cc index 269e4842252c2a88f33c8faf6666d139e36e49f3..a176086a4cae61e2dc4ab2dec035c25a6df4b512 100644 --- a/paddle/fluid/lite/kernels/arm/mul_compute.cc +++ b/paddle/fluid/lite/kernels/arm/mul_compute.cc @@ -23,7 +23,8 @@ namespace kernels { namespace arm { void MulCompute::PrepareForRun() { - // TODO(TJ): transpose x or y if necessary + auto& ctx = this->ctx_->template As(); + ctx.SetRunMode(LITE_POWER_HIGH, 4); } void MulCompute::Run() { diff --git a/paddle/fluid/lite/kernels/arm/pool_compute.cc b/paddle/fluid/lite/kernels/arm/pool_compute.cc index 168b0e50c98bcf8eab324b627478a7790e665b82..ea3d47a268588f7d593f0c3ac58f3421d9456fa8 100644 --- a/paddle/fluid/lite/kernels/arm/pool_compute.cc +++ b/paddle/fluid/lite/kernels/arm/pool_compute.cc @@ -24,6 +24,11 @@ namespace lite { namespace kernels { namespace arm { +void PoolCompute::PrepareForRun() { + auto& ctx = this->ctx_->template As(); + ctx.SetRunMode(LITE_POWER_HIGH, 4); +} + void PoolCompute::Run() { auto& param = Param(); auto& in_dims = param.x->dims(); diff --git a/paddle/fluid/lite/kernels/arm/pool_compute.h b/paddle/fluid/lite/kernels/arm/pool_compute.h index 76dedbc3132405cd70d74e233619572f97dc07e0..3a8b0f99c5b8292ec845f00383c4751079db2c77 100644 --- a/paddle/fluid/lite/kernels/arm/pool_compute.h +++ b/paddle/fluid/lite/kernels/arm/pool_compute.h @@ -26,6 +26,7 @@ class PoolCompute : public KernelLite { public: using param_t = operators::PoolParam; + void PrepareForRun() override; void Run() override; TargetType target() const override; diff --git a/paddle/fluid/lite/tools/build.sh b/paddle/fluid/lite/tools/build.sh index a02cdc0385dfc50374cf99e4e0759717ff00092f..f197d8882193f935c8aacb43d3e4984ad9d18ab0 100755 --- a/paddle/fluid/lite/tools/build.sh +++ b/paddle/fluid/lite/tools/build.sh @@ -56,7 +56,7 @@ function check_style { function cmake_arm { # $1: ARM_TARGET_OS in "android" , "armlinux" - # $2: ARM_TARGET_ARCH_ABI in "arm64-v8a", "armeabi-v7a" ,"armeabi-v7a-hf" + # $2: ARM_TARGET_ARCH_ABI in "armv8", "armv7" ,"armv7hf" cmake .. \ -DWITH_GPU=OFF \ -DWITH_MKL=OFF \ @@ -123,31 +123,24 @@ function test_arm_android { # Build the code and run lite arm tests. This is executed in the CI system. function build_test_arm { - port_armv8=5554 - port_armv7=5556 - - adb kill-server - adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done - # start android arm64-v8a armeabi-v7a emulators first - echo n | avdmanager create avd -f -n paddle-armv8 -k "system-images;android-24;google_apis;arm64-v8a" - echo -ne '\n' | ${ANDROID_HOME}/emulator/emulator -avd paddle-armv8 -noaudio -no-window -gpu off -verbose -port ${port_armv8} & - sleep 1m - echo n | avdmanager create avd -f -n paddle-armv7 -k "system-images;android-24;google_apis;armeabi-v7a" - echo -ne '\n' | ${ANDROID_HOME}/emulator/emulator -avd paddle-armv7 -noaudio -no-window -gpu off -verbose -port ${port_armv7} & - sleep 1m - + # 1. Build goes first cur_dir=$(pwd) - for os in "android" "armlinux" ; do - for abi in "arm64-v8a" "armeabi-v7a" "armeabi-v7a-hf" ; do - # TODO(TJ): enable compile on v7-hf on andorid and all v7 on armlinux - if [[ ${abi} == "armeabi-v7a-hf" ]]; then - echo "armeabi-v7a-hf is not supported on both android and armlinux" + for abi in "armv8" "armv7" "armv7hf"; do + # TODO(hongming): enable compile armv7 and armv7hf on armlinux + if [[ ${abi} == "armv7hf" ]]; then + echo "armv7hf is not supported on both android and armlinux yet" + continue + fi + + # TODO(hongming): enable armv7 on armlinux + if [[ ${os} == "armlinux" && ${abi} == "armv7" ]]; then + echo "armv7 is not supported on armlinux yet" continue fi - if [[ ${os} == "armlinux" && ${abi} == "armeabi-v7a" ]]; then - echo "armeabi-v7a is not supported on armlinux yet" + if [[ ${os} == "android" && ${abi} == "armv7hf" ]]; then + echo "android do not need armv7hf" continue fi @@ -157,34 +150,50 @@ function build_test_arm { cmake_arm ${os} ${abi} build $TESTS_FILE + done + done - # armlinux need in another docker - # TODO(TJ): enable test with armlinux - if [[ ${os} == "android" ]]; then - adb_abi=${abi} - if [[ ${adb_abi} == "armeabi-v7a-hf" ]]; then - adb_abi="armeabi-v7a" - fi - if [[ ${adb_abi} == "armeabi-v7a" ]]; then - # skip all armv7 tests - # TODO(TJ): enable test with armv7 - continue - fi - local port= - if [[ ${adb_abi} == "armeabi-v7a" ]]; then - port=${port_armv7} - fi - - if [[ ${adb_abi} == "arm64-v8a" ]]; then - port=${port_armv8} - fi - echo "test file: ${TESTS_FILE}" - for _test in $(cat $TESTS_FILE); do - test_arm_android $_test $port - done - fi + # 2. Then test + port_armv8=5554 + port_armv7=5556 + + adb kill-server + adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done + # start android armv8 and armv7 emulators first + echo n | avdmanager create avd -f -n paddle-armv8 -k "system-images;android-24;google_apis;arm64-v8a" + echo -ne '\n' | ${ANDROID_HOME}/emulator/emulator -avd paddle-armv8 -noaudio -no-window -gpu off -verbose -port ${port_armv8} & + sleep 1m + echo n | avdmanager create avd -f -n paddle-armv7 -k "system-images;android-24;google_apis;armeabi-v7a" + echo -ne '\n' | ${ANDROID_HOME}/emulator/emulator -avd paddle-armv7 -noaudio -no-window -gpu off -verbose -port ${port_armv7} & + sleep 1m + + # now can only test android. + for abi in "armv8" "armv7" ; do + # TODO(yuanshuai): enable armv7 on android + if [[ ${abi} == "armv7" ]]; then + continue + fi + + build_dir=$cur_dir/build.lite.android.${abi} + cd $build_dir + + local port= + if [[ ${abi} == "armv7" ]]; then + port=${port_armv7} + fi + + if [[ ${abi} == "armv8" ]]; then + port=${port_armv8} + fi + echo "test file: ${TESTS_FILE}" + for _test in $(cat $TESTS_FILE); do + test_arm_android $_test $port done done + + # armlinux need in another docker + # TODO(hongming): enable test armlinux on armv8, armv7 and armv7hf + adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done echo "Done" } diff --git a/paddle/fluid/lite/tools/mobile_readme.md b/paddle/fluid/lite/tools/mobile_readme.md index b7ffbe6faa34860d029064246121e76c80fc06f0..1d866cbb8226bf56944a2f084432cd3a16a30475 100644 --- a/paddle/fluid/lite/tools/mobile_readme.md +++ b/paddle/fluid/lite/tools/mobile_readme.md @@ -17,8 +17,15 @@ $ git checkout incubate/lite ### 主要cmake选项 -- `ARM_TARGET_OS` 代表目标操作系统, 目前支持 "android" "armlinux", 模型是Android -- `ARM_TARGET_ARCH_ABI` 代表ARCH, 目前支持 "arm64-v8a" "armeabi-v7a"。 模型是arm64-v8a +- `ARM_TARGET_OS` 代表目标操作系统, 目前支持 "android" "armlinux", 默认是Android +- `ARM_TARGET_ARCH_ABI` 代表ARCH,支持输入"armv8"和"armv7",针对OS不一样选择不一样。 + - `-DARM_TARGET_OS="android"` 时 + - "armv8", 等效于 "arm64-v8a"。 default值为这个。 + - "armv7", 等效于 "armeabi-v7a"。 + - `-DARM_TARGET_OS="armlinux"` 时 + - "armv8", 等效于 "arm64"。 default值为这个。 + - "armv7hf", 等效于使用`eabihf`且`-march=armv7-a -mfloat-abi=hard -mfpu=neon-vfpv4 `。 + - "armv7", 等效于使用`eabi`且`-march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4`。 ### 编译