提交 de9a6056 编写于 作者: C Chunwei

Merge branch 'chunwei/lite/enhance-gitlab' into 'incubate/lite'

make lite CI compile faster

See merge request inference/paddlelite!12
before_script: before_script:
- env - env
- export CI_USER_DIR=$(pwd)
image: $SERVER_LITE_DOCKER_IMAGE image: $SERVER_LITE_DOCKER_IMAGE
...@@ -14,6 +15,8 @@ check:prebuilt: ...@@ -14,6 +15,8 @@ check:prebuilt:
stage: ci stage: ci
script: script:
- rm -rf ~/.pip - rm -rf ~/.pip
- export http_proxy=$CI_PROXY
- export https_proxy=$CI_PROXY
- pip install pre-commit - pip install pre-commit
- pre-commit install - pre-commit install
...@@ -27,7 +30,7 @@ check:prebuilt: ...@@ -27,7 +30,7 @@ check:prebuilt:
cache: cache:
key: check_style key: check_style
paths: paths:
- /root/.cache - $CI_USER_DIR/.cache
build:server: build:server:
tags: tags:
...@@ -38,7 +41,7 @@ build:server: ...@@ -38,7 +41,7 @@ build:server:
key: server_thirdparty key: server_thirdparty
paths: paths:
- build/third_party - build/third_party
- /root/.ccache - ~/.ccache
script: script:
- apt install ccache - apt install ccache
- export http_proxy=$CI_PROXY - export http_proxy=$CI_PROXY
...@@ -73,7 +76,7 @@ build:mobile: ...@@ -73,7 +76,7 @@ build:mobile:
paths: paths:
- $MOBILE_LITE_CACHE0 - $MOBILE_LITE_CACHE0
- $MOBILE_LITE_CACHE1 - $MOBILE_LITE_CACHE1
- /root/.ccache - ~/.ccache
script: script:
- apt install ccache - apt install ccache
- export http_proxy=$CI_PROXY - export http_proxy=$CI_PROXY
......
...@@ -80,6 +80,9 @@ function (lite_deps TARGET) ...@@ -80,6 +80,9 @@ function (lite_deps TARGET)
endfunction() endfunction()
# A fake target to include all the libraries and tests the lite module depends.
add_custom_target(lite_compile_deps COMMAND echo 1)
# Add names for lite libraries for latter compile. We use this name list to avoid compiling # Add names for lite libraries for latter compile. We use this name list to avoid compiling
# the whole fluid project to accelerate the compile speed. # the whole fluid project to accelerate the compile speed.
set(offline_lib_registry_file "${CMAKE_BINARY_DIR}/lite_libs.txt") set(offline_lib_registry_file "${CMAKE_BINARY_DIR}/lite_libs.txt")
...@@ -112,6 +115,9 @@ function(lite_cc_library TARGET) ...@@ -112,6 +115,9 @@ function(lite_cc_library TARGET)
cc_library(${TARGET} SRCS ${args_SRCS} DEPS ${deps} ${args_DEPS}) cc_library(${TARGET} SRCS ${args_SRCS} DEPS ${deps} ${args_DEPS})
# collect targets need to compile for lite
add_dependencies(lite_compile_deps ${TARGET})
# register a library name. # register a library name.
file(APPEND ${offline_lib_registry_file} "${TARGET}\n") file(APPEND ${offline_lib_registry_file} "${TARGET}\n")
endfunction() endfunction()
...@@ -160,6 +166,9 @@ function(lite_cc_test TARGET) ...@@ -160,6 +166,9 @@ function(lite_cc_test TARGET)
) )
_lite_cc_test(${TARGET} SRCS ${args_SRCS} DEPS ${deps} ARGS ${args_ARGS}) _lite_cc_test(${TARGET} SRCS ${args_SRCS} DEPS ${deps} ARGS ${args_ARGS})
file(APPEND ${offline_test_registry_file} "${TARGET}\n") file(APPEND ${offline_test_registry_file} "${TARGET}\n")
# collect targets need to compile for lite
add_dependencies(lite_compile_deps ${TARGET})
endfunction() endfunction()
add_subdirectory(operators) add_subdirectory(operators)
...@@ -173,4 +182,3 @@ add_subdirectory(model_parser) ...@@ -173,4 +182,3 @@ add_subdirectory(model_parser)
add_subdirectory(utils) add_subdirectory(utils)
add_subdirectory(api) add_subdirectory(api)
add_subdirectory(gen_code) add_subdirectory(gen_code)
...@@ -18,11 +18,11 @@ if (NOT LITE_WITH_LIGHT_WEIGHT_FRAMEWORK) ...@@ -18,11 +18,11 @@ if (NOT LITE_WITH_LIGHT_WEIGHT_FRAMEWORK)
DEPS scope_lite op_lite kernel_lite paddle_infer_gencode DEPS scope_lite op_lite kernel_lite paddle_infer_gencode
) )
# lite_cc_test(test_generated_code SRCS generated_code_test.cc DEPS __generated_code__ lite_cc_test(test_generated_code SRCS generated_code_test.cc DEPS __generated_code__
# ${ops_lite} ${host_kernels} ${ops_lite} ${host_kernels}
# X86_DEPS ${x86_kernels} X86_DEPS ${x86_kernels}
# ) )
# add_dependencies(__generated_code__ test_gen_code_lite) add_dependencies(__generated_code__ test_gen_code_lite)
add_dependencies(__generated_code__ extern_lite_download_lite_naive_model_tar_gz)
endif() endif()
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "paddle/fluid/lite/kernels/arm/split_compute.h" #include "paddle/fluid/lite/kernels/arm/split_compute.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <cstring>
#include <limits> #include <limits>
#include <vector> #include <vector>
#include "paddle/fluid/lite/core/op_registry.h" #include "paddle/fluid/lite/core/op_registry.h"
......
...@@ -6,6 +6,8 @@ LIBS_FILE="./lite_libs.txt" ...@@ -6,6 +6,8 @@ LIBS_FILE="./lite_libs.txt"
readonly common_flags="-DWITH_LITE=ON -DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK=OFF -DWITH_PYTHON=OFF -DWITH_TESTING=ON -DLITE_WITH_ARM=OFF" readonly common_flags="-DWITH_LITE=ON -DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK=OFF -DWITH_PYTHON=OFF -DWITH_TESTING=ON -DLITE_WITH_ARM=OFF"
NUM_CORES_FOR_COMPILE=8
# for code gen, a source file is generated after a test, but is dependended by some targets in cmake. # for code gen, a source file is generated after a test, but is dependended by some targets in cmake.
# here we fake an empty file to make cmake works. # here we fake an empty file to make cmake works.
function prepare_for_codegen { function prepare_for_codegen {
...@@ -23,9 +25,17 @@ function cmake_x86 { ...@@ -23,9 +25,17 @@ function cmake_x86 {
cmake .. -DWITH_GPU=OFF -DWITH_MKLDNN=OFF -DLITE_WITH_X86=ON ${common_flags} cmake .. -DWITH_GPU=OFF -DWITH_MKLDNN=OFF -DLITE_WITH_X86=ON ${common_flags}
} }
# This method is only called in CI.
function cmake_x86_for_CI { function cmake_x86_for_CI {
prepare_for_codegen prepare_for_codegen # fake an empty __generated_code__.cc to pass cmake.
cmake .. -DWITH_GPU=OFF -DWITH_MKLDNN=OFF -DLITE_WITH_X86=ON ${common_flags} -DLITE_WITH_PROFILE=ON cmake .. -DWITH_GPU=OFF -DWITH_MKLDNN=OFF -DLITE_WITH_X86=ON ${common_flags} -DLITE_WITH_PROFILE=ON
# Compile and execute the gen_code related test, so it will generate some code, and make the compilation reasonable.
make test_gen_code_lite -j$NUM_CORES_FOR_COMPILE
make test_cxx_api_lite -j$NUM_CORES_FOR_COMPILE
ctest -R test_cxx_api_lite
ctest -R test_gen_code_lite
make test_generated_code -j$NUM_CORES_FOR_COMPILE
} }
function cmake_gpu { function cmake_gpu {
...@@ -61,14 +71,11 @@ function cmake_arm { ...@@ -61,14 +71,11 @@ function cmake_arm {
function build_single { function build_single {
#make $1 -j$(expr $(nproc) - 2) #make $1 -j$(expr $(nproc) - 2)
make $1 -j8 make $1 -j$NUM_CORES_FOR_COMPILE
} }
function build { function build {
file=$1 make lite_compile_deps -j $NUM_CORES_FOR_COMPILE
for _test in $(cat $file); do
build_single $_test
done
} }
# It will eagerly test all lite related unittests. # It will eagerly test all lite related unittests.
...@@ -77,10 +84,6 @@ function test_lite { ...@@ -77,10 +84,6 @@ function test_lite {
echo "file: ${file}" echo "file: ${file}"
for _test in $(cat $file); do for _test in $(cat $file); do
# We move the build phase here to make the 'gen_code' test compiles after the
# corresponding test is executed and the C++ code generates.
#make $_test -j$(expr $(nproc) - 2)
make $_test -j8
ctest -R $_test -V ctest -R $_test -V
done done
} }
...@@ -91,10 +94,8 @@ function build_test_server { ...@@ -91,10 +94,8 @@ function build_test_server {
cd ./build cd ./build
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/paddle/build/third_party/install/mklml/lib" export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/paddle/build/third_party/install/mklml/lib"
cmake_x86_for_CI cmake_x86_for_CI
# compile the tests and execute them. build
test_lite $TESTS_FILE test_lite $TESTS_FILE
# build the remaining libraries to check compiling error.
build $LIBS_FILE
} }
# test_arm_android <some_test_name> <adb_port_number> # test_arm_android <some_test_name> <adb_port_number>
...@@ -135,6 +136,8 @@ function build_test_arm { ...@@ -135,6 +136,8 @@ function build_test_arm {
echo -ne '\n' | ${ANDROID_HOME}/emulator/emulator -avd paddle-armv7 -noaudio -no-window -gpu off -verbose -port ${port_armv7} & echo -ne '\n' | ${ANDROID_HOME}/emulator/emulator -avd paddle-armv7 -noaudio -no-window -gpu off -verbose -port ${port_armv7} &
sleep 1m sleep 1m
cur_dir=$(pwd)
for os in "android" "armlinux" ; do for os in "android" "armlinux" ; do
for abi in "arm64-v8a" "armeabi-v7a" "armeabi-v7a-hf" ; 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 # TODO(TJ): enable compile on v7-hf on andorid and all v7 on armlinux
...@@ -148,9 +151,10 @@ function build_test_arm { ...@@ -148,9 +151,10 @@ function build_test_arm {
continue continue
fi fi
build_dir=build.lite.${os}.${abi} build_dir=$cur_dir/build.lite.${os}.${abi}
mkdir -p $build_dir mkdir -p $build_dir
cd $build_dir cd $build_dir
cmake_arm ${os} ${abi} cmake_arm ${os} ${abi}
build $TESTS_FILE build $TESTS_FILE
...@@ -179,7 +183,6 @@ function build_test_arm { ...@@ -179,7 +183,6 @@ function build_test_arm {
test_arm_android $_test $port test_arm_android $_test $port
done done
fi fi
cd -
done done
done done
adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册