未验证 提交 b5af2eac 编写于 作者: T tensor-tang 提交者: GitHub

Lite enable armlinux compile and android simulator (#17752)

* enable armlinux compile

* fix deps and skip some build

* update doc and script

* add android simulator

test=develop
上级 0fb65651
......@@ -21,15 +21,32 @@ include(system)
if(LITE_WITH_LIGHT_WEIGHT_FRAMEWORK)
cmake_minimum_required(VERSION 3.10)
# only android yet
set(ANDROID TRUE)
include(cross_compiling/android)
# TODO(TJ): make as function check_default
if(NOT DEFINED ARM_TARGET_OS)
set(ARM_TARGET_OS "android" CACHE STRING "Choose ARM Target OS")
endif()
set(ARM_TARGET_OS_LIST "android" "armlinux") # TODO: "ios"
set_property(CACHE ARM_TARGET_OS PROPERTY STRINGS ${ARM_TARGET_OS_LIST})
if (NOT ARM_TARGET_OS IN_LIST ARM_TARGET_OS_LIST)
message(FATAL_ERROR "ARM_TARGET_OS must be in one of ${ARM_TARGET_OS_LIST}")
endif()
if(NOT DEFINED ARM_TARGET_ARCH_ABI)
set(ARM_TARGET_ARCH_ABI "arm64-v8a" 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_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()
include(cross_compiling/host)
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_SYSTEM_VERSION ${ANDROID_API_LEVEL})
set(CMAKE_ANDROID_ARCH_ABI ${ANDROID_ARCH_ABI})
set(CMAKE_ANDROID_NDK ${ANDROID_NDK})
set(CMAKE_ANDROID_STL_TYPE ${ANDROID_STL_TYPE})
include(cross_compiling/armlinux)
include(cross_compiling/android)
endif()
project(paddle CXX C)
......@@ -94,7 +111,7 @@ option(PY_VERSION "Compile PaddlePaddle with python3 support" ${PY_VER
option(WITH_FAST_MATH "Make use of fast math library, might affect the precision to some extent" ON)
option(WITH_DGC "Use DGC(Deep Gradient Compression) or not" ON)
if(ANDROID OR IOS)
if(ANDROID OR IOS OR ARMLINUX)
set(WITH_GPU OFF CACHE STRING
"Disable GPU when cross-compiling for Android and iOS" FORCE)
set(WITH_DSO OFF CACHE STRING
......
......@@ -12,11 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if(NOT ANDROID)
if(NOT ARM_TARGET_OS STREQUAL "android")
return()
endif()
add_definitions(-DLITE_WITH_ANDROID)
set(ANDROID TRUE)
add_definitions(-DLITE_WITH_LINUX)
if(NOT DEFINED ANDROID_NDK)
set(ANDROID_NDK $ENV{NDK_ROOT})
......@@ -25,9 +26,6 @@ if(NOT DEFINED ANDROID_NDK)
endif()
endif()
if(NOT DEFINED ANDROID_ARCH_ABI)
set(ANDROID_ARCH_ABI "arm64-v8a" CACHE STRING "Choose android platform")
endif()
if(NOT DEFINED ANDROID_API_LEVEL)
set(ANDROID_API_LEVEL "22")
......@@ -37,22 +35,45 @@ 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")
endif()
set(ANDROID_ARCH_ABI ${ARM_TARGET_ARCH_ABI} CACHE STRING "Choose Android Arch ABI")
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")
"mips" "mips64" "x86" "x86_64" "armeabi-v7a-hf")
set_property(CACHE ANDROID_ARCH_ABI PROPERTY STRINGS ${ANDROID_ARCH_ABI_LIST})
if (NOT ANDROID_ARCH_ABI IN_LIST 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}")
endif()
if(ANDROID_ARCH_ABI STREQUAL "armeabi-v7a")
message(STATUS "armeabi-v7a default use softfp")
set(CMAKE_ANDROID_ARM_NEON ON)
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)
message(FATAL_ERROR "ANDROID_STL_TYPE must be in one of ${ANDROID_STL_TYPE_LITS}")
endif()
set(ANDROID_PIE TRUE)
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_SYSTEM_VERSION ${ANDROID_API_LEVEL})
set(CMAKE_ANDROID_ARCH_ABI ${ANDROID_ARCH_ABI})
set(CMAKE_ANDROID_NDK ${ANDROID_NDK})
set(CMAKE_ANDROID_STL_TYPE ${ANDROID_STL_TYPE})
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if(NOT ARM_TARGET_OS STREQUAL "armlinux")
return()
endif()
set(ARMLINUX TRUE)
add_definitions(-DLITE_WITH_LINUX)
set(CMAKE_SYSTEM_NAME Linux)
if(ARM_TARGET_ARCH_ABI STREQUAL "arm64-v8a")
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_C_COMPILER "aarch64-linux-gnu-gcc")
set(CMAKE_CXX_COMPILER "aarch64-linux-gnu-g++")
set(CMAKE_CXX_FLAGS "-march=armv8-a ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "-march=armv8-a ${CMAKE_C_FLAGS}")
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")
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")
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER "arm-linux-gnueabi-gcc")
set(CMAKE_CXX_COMPILER "arm-linux-gnueabi-g++")
set(CMAKE_CXX_FLAGS "-march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4 ${CMAKE_CXX_FLAGS}")
set(CMAKE_C_FLAGS "-march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4 ${CMAKE_C_FLAGS}")
message(STATUS "NEON is enabled on arm-v7a with softfp")
endif()
if(ARM_TARGET_ARCH_ABI STREQUAL "armeabi-v7a-hf")
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER "arm-linux-gnueabihf-gcc")
set(CMAKE_CXX_COMPILER "arm-linux-gnueabihf-g++")
set(CMAKE_CXX_FLAGS "-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()
if(NOT (LITE_WITH_LIGHT_WEIGHT_FRAMEWORK AND LITE_WITH_ARM))
return()
endif()
if(NOT (LITE_WITH_LIGHT_WEIGHT_FRAMEWORK AND LITE_WITH_ARM))
return()
......
......@@ -19,7 +19,7 @@ endif()
proto_library(framework_proto_lite SRCS framework.proto)
cc_library(kernel_lite SRCS kernel.cc DEPS type_system target_wrapper_lite any_lite op_params_lite)
cc_library(kernel_lite SRCS kernel.cc DEPS type_system target_wrapper_lite any_lite op_params_lite framework_proto_lite)
cc_library(variable_lite SRCS variable.cc)
cc_library(op_registry_lite SRCS op_registry.cc DEPS framework_proto_lite)
cc_library(scope_lite SRCS scope.cc DEPS ${tensor_lite})
......
......@@ -15,7 +15,7 @@
#include "paddle/fluid/lite/core/context.h"
#include "paddle/fluid/lite/core/cpu_info.h"
#ifdef LITE_WITH_ANDROID
#ifdef LITE_WITH_LINUX
#include <sys/syscall.h>
#include <unistd.h>
#endif
......@@ -87,7 +87,7 @@ void ARMContext::BindDev() {
#ifdef USE_OPENMP
int num_threads = active_ids_.size();
omp_set_num_threads(num_threads);
#ifdef LITE_WITH_ANDROID
#ifdef LITE_WITH_LINUX
std::vector<int> ssarets;
for (int j = 0; j < num_threads; ++j) {
ssarets.push_back(0);
......@@ -102,9 +102,9 @@ void ARMContext::BindDev() {
return;
}
}
#endif // LITE_WITH_ANDROID
#endif // LITE_WITH_LINUX
#else // USE_OPENMP
#ifdef LITE_WITH_ANDROID
#ifdef LITE_WITH_LINUX
std::vector<int> cpuid1;
cpuid1.push_back(active_ids_[0]);
int ssaret = set_sched_affinity(cpuid1);
......@@ -112,7 +112,7 @@ void ARMContext::BindDev() {
printf("set cpu affinity failed, cpuID: %d\n", active_ids_[0]);
return;
}
#endif // LITE_WITH_ANDROID
#endif // LITE_WITH_LINUX
#endif // USE_OPENMP
}
......
......@@ -26,7 +26,7 @@ void DeviceInfo::InitInternal(DeviceInfo* dev) {
dev->max_memory_ = arm_get_meminfo();
// get max freq
#ifdef LITE_WITH_ANDROID
#ifdef LITE_WITH_LINUX
std::vector<int> max_freq(dev->compute_core_num_);
for (int i = 0; i < dev->compute_core_num_; ++i) {
max_freq[i] = get_max_freq_khz(i) / 1000;
......@@ -311,7 +311,7 @@ bool get_cpu_info_from_name(DeviceInfo* cpu_info, std::string hardware_name) {
}
size_t arm_get_meminfo() {
#ifdef LITE_WITH_ANDROID
#ifdef LITE_WITH_LINUX
// get cpu count from /proc/cpuinfo
FILE* fp = fopen("/proc/meminfo", "rb");
if (!fp) {
......@@ -339,7 +339,7 @@ size_t arm_get_meminfo() {
}
int arm_get_cpucount() {
#ifdef LITE_WITH_ANDROID
#ifdef LITE_WITH_LINUX
// get cpu count from /sys/devices/system/cpu/cpunum/uevent
int max_cpu_count = 20;
int count = 0;
......@@ -371,7 +371,7 @@ int arm_get_cpucount() {
}
void arm_get_cpu_arch(std::vector<ARMArch>* archs) {
#ifdef LITE_WITH_ANDROID
#ifdef LITE_WITH_LINUX
archs->clear();
//! get CPU ARCH
FILE* fp = fopen("/proc/cpuinfo", "rb");
......@@ -436,7 +436,7 @@ void arm_get_cpu_arch(std::vector<ARMArch>* archs) {
#endif
}
#ifdef LITE_WITH_ANDROID
#ifdef LITE_WITH_LINUX
void set_default_cache(DeviceInfo* dev) {
int cpu_count = arm_get_cpucount();
......@@ -621,7 +621,7 @@ int set_sched_affinity(const std::vector<int>& cpuids) {
return 0;
}
#endif // LITE_WITH_ANDROID
#endif // LITE_WITH_LINUX
#endif // LITE_WITH_ARM
......
......@@ -18,7 +18,7 @@
#include <vector>
#include "paddle/fluid/lite/utils/cp_logging.h"
#ifdef LITE_WITH_ANDROID
#ifdef LITE_WITH_LINUX
#include <sys/syscall.h>
#include <unistd.h>
#endif
......@@ -103,7 +103,7 @@ void arm_get_cpu_arch(std::vector<ARMArch>* archs);
bool get_cpu_info_from_name(DeviceInfo* cpu_info, std::string hardware_name);
#ifdef LITE_WITH_ANDROID
#ifdef LITE_WITH_LINUX
void set_default_cache(DeviceInfo* dev);
......@@ -117,7 +117,7 @@ int arm_sort_cpuid_by_max_frequency(int cpu_count, std::vector<int>* cpuids,
int check_online(const std::vector<int>& core_ids);
int set_sched_affinity(const std::vector<int>& cpuids);
#endif // LITE_WITH_ANDROID
#endif // LITE_WITH_LINUX
#endif // LITE_WITH_ARM
......
# A image for building paddle cross compile
# A image for paddle lite mobile cross compile and simulator on android
FROM ubuntu:16.04
MAINTAINER PaddlePaddle Authors <paddle-dev@baidu.com>
# change name to cross compile
ARG UBUNTU_MIRROR
RUN /bin/bash -c '\
if [[ -n ${UBUNTU_MIRROR} ]]; then \
sed -i 's#http://archive.ubuntu.com/ubuntu#${UBUNTU_MIRROR}#g' /etc/apt/sources.list; fi'
RUN echo '\
deb <mirror> <version> main restricted universe multiverse\n\
deb <mirror> <version>-updates main restricted universe multiverse\n\
deb <mirror> <version>-backports main restricted universe multiverse\n\
deb <mirror> <version>-security main restricted universe multiverse\n'\
> /etc/apt/sources.list
RUN sed -ie 's|<mirror>|http://mirrors.tuna.tsinghua.edu.cn/ubuntu/|' /etc/apt/sources.list
RUN sed -ie 's|<version>|xenial|' /etc/apt/sources.list
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y --no-install-recommends \
......@@ -29,10 +33,13 @@ RUN apt-get install -y --no-install-recommends \
vim \
wget
RUN apt-get autoremove -y && apt-get clean
RUN ln -s clang-format-3.8 /usr/bin/clang-format
RUN pip install --upgrade pip
RUN pip install pre-commit wheel
# for android simulator
RUN apt-get install -y --no-install-recommends \
libc6-i386 \
lib32stdc++6 \
redir \
iptables \
openjdk-8-jre
# for cmake 3.10
RUN curl -O https://mms-res.cdn.bcebos.com/cmake-3.10.3-Linux-x86_64.tar.gz && \
......@@ -40,9 +47,8 @@ RUN curl -O https://mms-res.cdn.bcebos.com/cmake-3.10.3-Linux-x86_64.tar.gz && \
mv cmake-3.10.3-Linux-x86_64 /opt/cmake-3.10 && \
mv /usr/bin/cmake /usr/bin/cmake.bak && ln -s /opt/cmake-3.10/bin/cmake /usr/bin/cmake && \
mv /usr/bin/ccmake /usr/bin/ccmake.bak && ln -s /opt/cmake-3.10/bin/ccmake /usr/bin/ccmake
RUN cd /opt && unzip /tmp/android-ndk-r17c-linux-x86_64.zip
# for arm linux
# for arm linux compile
RUN apt-get install -y --no-install-recommends \
g++-arm-linux-gnueabi \
gcc-arm-linux-gnueabi \
......@@ -51,11 +57,34 @@ RUN apt-get install -y --no-install-recommends \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu
# for android
# for android ndk17c
RUN cd /tmp && curl -O https://dl.google.com/android/repository/android-ndk-r17c-linux-x86_64.zip
ENV NDK_ROOT /opt/android-ndk-r17c
RUN cd /opt && unzip /tmp/android-ndk-r17c-linux-x86_64.zip
# for android simulator
RUN wget "https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip" && \
unzip sdk-tools-linux-4333796.zip -d /opt/android_sdk && \
mkdir /root/.android && touch /root/.android/repositories.cfg && \
echo y | sdkmanager "platform-tools" "emulator" && \
echo y | sdkmanager "platforms;android-24" && \
echo y | sdkmanager "system-images;android-24;google_apis;arm64-v8a" "system-images;android-24;google_apis;armeabi-v7a"
ENV ANDROID_HOME /opt/android_sdk
ENV PATH $PATH:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools/bin
# this will install the ndk19c and only use clang to compile, then can replace the ndk17c
# echo y | sdkmanager "ndk;19.2.5345600"
# Expose android port
EXPOSE 5555
EXPOSE 5557
# VNC port
EXPOSE 5900
# clean
RUN rm -rf /tmp/android-ndk-r17c-linux-x86_64.zip /cmake-3.10.3-Linux-x86_64.tar.gz
RUN apt-get autoremove -y && apt-get clean
RUN ln -s clang-format-3.8 /usr/bin/clang-format
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple wheel
RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pre-commit
\ No newline at end of file
......@@ -13,15 +13,45 @@ function cmake_gpu {
}
function cmake_arm {
# ARM_TARGET_OS="android" , "armlinux"
# ARM_TARGET_ARCH_ABI = "arm64-v8a", "armeabi-v7a" ,"armeabi-v7a-hf"
for os in "android" "armlinux" ; do
for abi in "arm64-v8a" "armeabi-v7a" "armeabi-v7a-hf" ; do
if [[ ${abi} == "armeabi-v7a-hf" ]]; then
echo "armeabi-v7a-hf is not supported on both android and armlinux"
continue
fi
if [[ ${os} == "armlinux" && ${abi} == "armeabi-v7a" ]]; then
echo "armeabi-v7a is not supported on armlinux yet"
continue
fi
echo "Build for ${os} ${abi}"
build_dir=build.lite.${os}.${abi}
mkdir -p $build_dir
cd $build_dir
cmake .. \
-DWITH_GPU=OFF \
-DWITH_LITE=ON \
-DLITE_WITH_X86=OFF \
-DLITE_WITH_CUDA=OFF \
-DLITE_WITH_X86=OFF \
-DLITE_WITH_ARM=ON \
-DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK=ON \
-DWITH_TESTING=ON \
-DWITH_MKL=OFF \
-DWITH_MKLDNN=OFF
-DARM_TARGET_OS=${os} -DARM_TARGET_ARCH_ABI=${abi}
make test_fc_compute_arm -j
make test_softmax_compute_arm -j
make cxx_api_lite_bin -j
cd -
done
done
}
function build {
......
# Paddle-lite-mobile交叉编译指导
# Paddle-lite-mobile开发指南
Paddle-lite-mobile开发环境目前推荐在Docker容器里,在容器里进行交叉编译安卓版本的Native C/C++代码,然后将可执行程序`adb push`到安卓手机上进行调试。
## Android
## 交叉编译
TBD
Paddle-lite-mobile 推荐在我们的Docker环境下交叉编译,减少环境配置上的不必要问题。
### 1. 拉取代码创建容器
```shell
$ git clone --recursive https://github.com/PaddlePaddle/Paddle.git
$ git clone https://github.com/PaddlePaddle/Paddle.git
$ git checkout incubate/lite
```
先根据仓库下的`Dockerfile.cross_compile`文件生成对应的环境镜像。
编译docker环境:
`docker build --file paddle/fluid/lite/tools/Dockerfile.mobile --tag paddle-lite-mobile:latest . `
```shell
$ cd <paddle-repo>
$ mkdir android-docker
$ cp Dockerfile.android ./android-docker/Dockerfile
$ cd android-docker
$ docker build -t paddle/paddle-lite-mobile .
```
### 主要cmake选项
完成后,可以看到:
```shell
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
paddle/paddle-lite-mobile latest 9c2000469891 5 hours ago 3.88GB
```
- `ARM_TARGET_OS` 代表目标操作系统, 目前支持 "android" "armlinux", 模型是Android
- `ARM_TARGET_ARCH_ABI` 代表ARCH, 目前支持 "arm64-v8a" "armeabi-v7a"。 模型是arm64-v8a
基于`paddle/paddle-lite`镜像创建容器,并在容器内外建立目录映射关系:
### 编译
```shell
$ ddocker run -v <your-directory-path>:<your-directory-path> -tdi paddle/paddle-lite-mobile
# 启动成功会显示container_id
```
基于`paddle-lite-mobile`镜像创建容器,并在容器内外建立目录映射关系:
进入容器并切换到Paddle仓库目录:
```shell
$ docker exec -it <container_id> bash
$ cd <paddle-repo>
$ docker run -it --name <yourname> --net=host --privileged -v <your-directory-path>:<your-directory-path> paddle-lite-mobile bash
```
### 2. 交叉编译Paddle-lite-mobile的Native C/C++程序
创建名为`make_paddle_lite_mobile.sh`的文件:
参考build.sh下的 cmake arm编译需要的平台。
```shell
$ touch make_paddle_lite_mobile.sh
$ chmod +x make_paddle_lite_mobile.sh
```
参考示例:
打开`make_paddle_lite_mobile.sh`文件然后将以下内容复制到该文件中,保存并退出:
```shell
#!/usr/bin/env bash
# build mobile
mkdir build
cd build
# cross-compile native cpp
#!/bin/bash
cmake .. \
-DWITH_GPU=OFF \
-DWITH_MKL=OFF \
-DWITH_LITE=ON \
-DLITE_WITH_CUDA=OFF \
-DLITE_WITH_X86=OFF \
-DLITE_WITH_ARM=ON \
-DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK=ON \
-DLITE_WITH_CUDA=OFF \
-DWITH_TESTING=ON
-DWITH_TESTING=ON \
-DWITH_MKL=OFF \
-DARM_TARGET_OS="android" -DARM_TARGET_ARCH_ABI="arm64-v8a"
# fc层单测
make test_fc_compute_arm -j
# 小模型单测
#make cxx_api_lite_bin
```
### 在Android上执行
### 3. 上传编译文件到手机上
#### 1. 在模拟器上执行
#### 2. 上传编译文件到手机上
键盘上`crtl+q+p`同时摁下,切换到容器外(容器还在后台运行),将刚刚编译出的程序`adb push`到手机上。USB线连接手机,确保`adb devices`可以找到手机设备。
```shell
$ cd <paddle-repo>
$ adb push ./build/paddle/fluid/lite/api/test_cxx_api_lite /data/local/tmp/
$ adb push ./build/paddle/fluid/lite/kernels/arm/test_fc_compute_arm /data/local/tmp/
# 进入手机
$ adb shell # 若多台手机设备先用命令adb devices查看目标手机的序列码
$ cd /data/local/tmp
# 执行编译的程序
$ ./test_cxx_api_lite
$ ./test_fc_compute_arm
```
## ARM Linux
# 在模拟器中运
### 在ARM LINUX下执
TBD
## Android
## ARM Linux
# Q&A
......@@ -128,4 +97,3 @@ $ adb devices
List of devices attached
5cb00b6 device
```
#
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册