提交 eba924ba 编写于 作者: T tensor-tang 提交者: Yan Chunwei

enbale lite ci mobile (#17760)

上级 740c1b91
......@@ -63,14 +63,14 @@ ENV NDK_ROOT /opt/android-ndk-r17c
RUN cd /opt && unzip /tmp/android-ndk-r17c-linux-x86_64.zip
# for android simulator
ENV ANDROID_HOME /opt/android_sdk
ENV PATH $PATH:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools/bin
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"
......@@ -82,9 +82,9 @@ EXPOSE 5557
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
RUN apt-get autoremove -y && apt-get clean
RUN rm -rf /sdk-tools-linux-4333796.zip /tmp/android-ndk-r17c-linux-x86_64.zip /cmake-3.10.3-Linux-x86_64.tar.gz
......@@ -17,45 +17,18 @@ 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
# $1: ARM_TARGET_OS in "android" , "armlinux"
# $2: ARM_TARGET_ARCH_ABI in "arm64-v8a", "armeabi-v7a" ,"armeabi-v7a-hf"
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 \
-DWITH_TESTING=ON \
-DWITH_MKL=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
-DARM_TARGET_OS=$1 -DARM_TARGET_ARCH_ABI=$2
}
function build {
......@@ -74,10 +47,37 @@ function test_lite {
done
}
# Run test on mobile
function test_mobile {
# TODO(XXX) Implement this
port_armv8=5554
port_armv7=5556
# Run test on android
function test_lite_android {
local file=$1
local adb_abi=$2
local port=
if [[ ${adb_abi} == "armeabi-v7a" ]]; then
port=${port_armv7}
fi
if [[ ${adb_abi} == "arm64-v8a" ]]; then
port=${port_armv8}
fi
if [[ "${port}x" == "x" ]]; then
echo "Port can not be empty"
exit 1
fi
echo "file: ${file}"
# push all to adb and test
adb_work_dir="/data/local/tmp"
skip_list="test_model_parser_lite"
for _test in $(cat $file); do
[[ $skip_list =~ (^|[[:space:]])$_test($|[[:space:]]) ]] && continue || echo 'skip $_test'
testpath=$(find ./paddle/fluid -name ${_test})
adb -s emulator-${port} push ${testpath} ${adb_work_dir}
adb -s emulator-${port} shell chmod +x "${adb_work_dir}/${_test}"
adb -s emulator-${port} shell "./${adb_work_dir}/${_test}"
done
}
# Build the code and run lite server tests. This is executed in the CI system.
......@@ -90,6 +90,55 @@ function build_test_server {
test_lite $TESTS_FILE
}
# Build the code and run lite server tests. This is executed in the CI system.
function build_test_arm {
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
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
build_dir=build.lite.${os}.${abi}
mkdir -p $build_dir
cd $build_dir
cmake_arm ${os} ${abi}
build $TESTS_FILE
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 v7 tests
continue
fi
test_lite_android $TESTS_FILE ${adb_abi}
# armlinux need in another docker
fi
cd -
done
done
adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done
echo "Done"
}
############################# MAIN #################################
function print_usage {
echo -e "\nUSAGE:"
......@@ -143,6 +192,10 @@ function main {
build_test_server
shift
;;
build_test_arm)
build_test_arm
shift
;;
*)
# unknown option
print_usage
......
......@@ -55,14 +55,18 @@ make test_fc_compute_arm -j
```shell
# 创建Android avd (armv8)
$ echo n | avdmanager create avd -f -n myarmv8 -k "system-images;android-24;google_apis;arm64-v8a"
$ echo n | avdmanager create avd -f -n paddle-armv8 -k "system-images;android-24;google_apis;arm64-v8a"
# 启动Android armv8 emulator
$ ${ANDROID_HOME}/emulator/emulator -avd myarmv8 -noaudio -no-window -gpu off -verbose &
$ ${ANDROID_HOME}/emulator/emulator -avd paddle-armv8 -noaudio -no-window -gpu off -verbose &
# armv7版本如下:
# $ echo n | avdmanager create avd -f -n myarmv7 -k "system-images;android-24;google_apis;armeabi-v7a"
# $ ${ANDROID_HOME}/emulator/emulator -avd myarmv7 -noaudio -no-window -gpu off -verbose &
# 如果需要执行armv7版本,如下:
# $ echo n | avdmanager create avd -f -n paddle-armv7 -k "system-images;android-24;google_apis;armeabi-v7a"
# $ ${ANDROID_HOME}/emulator/emulator -avd paddle-armv7 -noaudio -no-window -gpu off -verbose &
# 退出所有模拟器
adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done
```
#### 2. 上传编译文件到手机上
键盘上`crtl+q+p`同时摁下,切换到容器外(容器还在后台运行),将刚刚编译出的程序`adb push`到手机上。USB线连接手机,确保`adb devices`可以找到手机设备。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册