diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9276ed4dee42e43db7da79abc47c615031a18e11..24d4b494e5664470808831feb807ae7580573433 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -87,6 +87,25 @@ build:mobile_android: dependencies: - build:server +build:mobile_android_cl: + tags: + - lite + stage: build_mobile + image: $MOBILE_LITE_DOCKER_IMAGE + cache: + key: mobile_thirdparty + paths: + - build.lite.android.armv8.gcc.cl_enable/third_party + - build.lite.android.armv7.gcc.cl_enable/third_party + - ~/.ccache + - $CI_PROJECT_DIR/build_mobile_ccache_cl + script: + - export CCACHE_DIR=$CI_PROJECT_DIR/build_mobile_ccache_cl + - ./paddle/fluid/lite/tools/build.sh build_test_arm_opencl + + dependencies: + - build:server + build:mobile_armlinux: tags: - lite diff --git a/paddle/fluid/lite/api/CMakeLists.txt b/paddle/fluid/lite/api/CMakeLists.txt index 290cae8d136a5acec8936609aed709f9752812c5..f1c9e210021858948eb89eeb4ce2ae579ed852fb 100644 --- a/paddle/fluid/lite/api/CMakeLists.txt +++ b/paddle/fluid/lite/api/CMakeLists.txt @@ -97,10 +97,12 @@ endif() # TODO(Superjomn) support latter. lite_cc_test(test_light_api_lite SRCS light_api_test.cc DEPS light_api_lite program_lite mir_passes + CL_DEPS ${opencl_kernels} ARGS --optimized_model=${LITE_MODEL_DIR}/lite_naive_model_opt SERIAL) lite_cc_test(test_apis_lite SRCS apis_test.cc DEPS cxx_api_lite light_api_lite ${ops_lite} + CL_DEPS ${opencl_kernels} X86_DEPS ${x86_kernels} operator ARGS --model_dir=${LITE_MODEL_DIR}/lite_naive_model --optimized_model=${LITE_MODEL_DIR}/lite_naive_model_opt SERIAL) @@ -125,6 +127,7 @@ lite_cc_test(test_paddle_api_lite SRCS paddle_api_test.cc DEPS paddle_api_full p ${ops_lite} ARM_DEPS ${arm_kernels} X86_DEPS ${x86_kernels} + CL_DEPS ${opencl_kernels} ARGS --model_dir=${LITE_MODEL_DIR}/lite_naive_model SERIAL) lite_cc_test(test_model_bin SRCS model_test.cc DEPS paddle_api_full paddle_api_light @@ -152,5 +155,8 @@ lite_cc_binary(cxx_api_lite_bin SRCS cxx_api_bin_int8.cc target_wrapper_host mir_passes ${ops_lite} ${host_kernels} + CL_DEPS ${opencl_kernels} ARM_DEPS ${arm_kernels}) -lite_cc_binary(model_optimize_tool SRCS model_optimize_tool.cc DEPS paddle_api_full) +lite_cc_binary(model_optimize_tool SRCS model_optimize_tool.cc + DEPS paddle_api_full + CL_DEPS ${opencl_kernels}) diff --git a/paddle/fluid/lite/core/CMakeLists.txt b/paddle/fluid/lite/core/CMakeLists.txt index 0dbaa3e6c0cdfff96261618a797bc121b5b67c09..14ebe7a20732d43a84edd59a541336177566e5c0 100644 --- a/paddle/fluid/lite/core/CMakeLists.txt +++ b/paddle/fluid/lite/core/CMakeLists.txt @@ -19,12 +19,12 @@ endif() proto_library(framework_proto_lite SRCS framework.proto) -lite_cc_library(kernel_lite SRCS kernel.cc DEPS type_system target_wrapper_lite any_lite op_params_lite framework_proto_lite ${tensor_lite}) lite_cc_library(variable_lite SRCS variable.cc) lite_cc_library(op_registry_lite SRCS op_registry.cc DEPS framework_proto_lite) lite_cc_library(scope_lite SRCS scope.cc DEPS ${tensor_lite}) lite_cc_library(cpu_info_lite SRCS cpu_info.cc) lite_cc_library(context_lite SRCS context.cc DEPS ${tensor_lite} any_lite cpu_info_lite X86_DEPS eigen3 CL_DEPS cl_helper) +lite_cc_library(kernel_lite SRCS kernel.cc DEPS context_lite type_system target_wrapper_lite any_lite op_params_lite framework_proto_lite ${tensor_lite}) lite_cc_library(op_lite SRCS op_lite.cc DEPS scope_lite op_registry_lite target_wrapper_lite kernel_lite cpp_op_desc_lite ${tensor_lite}) lite_cc_library(types_lite SRCS types.cc) diff --git a/paddle/fluid/lite/tools/build.sh b/paddle/fluid/lite/tools/build.sh index c832c6304b5932b36be615aaa9d6515eb69f0270..84ed53b29b15c53ef2eaa36197216cc09f9b0b9c 100755 --- a/paddle/fluid/lite/tools/build.sh +++ b/paddle/fluid/lite/tools/build.sh @@ -33,23 +33,6 @@ function cmake_x86 { cmake .. -DWITH_GPU=OFF -DWITH_MKLDNN=OFF -DLITE_WITH_X86=ON ${common_flags} } -function cmake_opencl { - # $1: ARM_TARGET_OS in "android" , "armlinux" - # $2: ARM_TARGET_ARCH_ABI in "arm64-v8a", "armeabi-v7a" ,"armeabi-v7a-hf" - cmake .. \ - -DLITE_WITH_OPENCL=ON \ - -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 \ - -DARM_TARGET_OS=$1 -DARM_TARGET_ARCH_ABI=$2 -} - - # This method is only called in CI. function cmake_x86_for_CI { prepare_workspace # fake an empty __generated_code__.cc to pass cmake. @@ -221,25 +204,48 @@ function cmake_arm { # $1: ARM_TARGET_OS in "android" , "armlinux" # $2: ARM_TARGET_ARCH_ABI in "armv8", "armv7" ,"armv7hf" # $3: ARM_TARGET_LANG in "gcc" "clang" - 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 \ - -DARM_TARGET_OS=$1 -DARM_TARGET_ARCH_ABI=$2 -DARM_TARGET_LANG=$3 + # $4: LITE_WITH_OPENCL in ON OFF + os=$1 + abi=$2 + lang=$3 + opencl=$4 + + if [[ ${opencl} == "cl_enable" ]]; then + echo "-- Enable OpenCL --" + cmake .. \ + -DLITE_WITH_OPENCL=ON \ + -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 \ + -DARM_TARGET_OS=${os} -DARM_TARGET_ARCH_ABI=${abi} -DARM_TARGET_LANG=${lang} + else + 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 \ + -DARM_TARGET_OS=${os} -DARM_TARGET_ARCH_ABI=${abi} -DARM_TARGET_LANG=${lang} + fi } # $1: ARM_TARGET_OS in "android" , "armlinux" # $2: ARM_TARGET_ARCH_ABI in "armv8", "armv7" ,"armv7hf" # $3: ARM_TARGET_LANG in "gcc" "clang" +# $4: LITE_WITH_OPENCL in ON OFF function build_arm { os=$1 abi=$2 lang=$3 + opencl=$4 cur_dir=$(pwd) if [[ ${os} == "armlinux" ]]; then @@ -263,11 +269,11 @@ function build_arm { return 0 fi - build_dir=$cur_dir/build.lite.${os}.${abi}.${lang} + build_dir=$cur_dir/build.lite.${os}.${abi}.${lang}.${opencl} mkdir -p $build_dir cd $build_dir - cmake_arm ${os} ${abi} ${lang} + cmake_arm ${os} ${abi} ${lang} ${opencl} build $TESTS_FILE # test publish inference lib @@ -331,6 +337,21 @@ function arm_push_necessary_file { adb -s emulator-${port} push ${testpath} ${adb_work_dir} } +function build_test_arm_opencl { + ######################################################################## + # job 1-4 must be in one runner + cur=$PWD + + # job 5 + build_arm "android" "armv8" "gcc" "cl_enable" + cd $cur + + # job 6 + build_arm "android" "armv7" "gcc" "cl_enable" + cd $cur + + echo "Done" +} # We split the arm unittest into several sub-tasks to parallel and reduce the overall CI timetime. # sub-task1 @@ -378,17 +399,17 @@ function build_test_arm_subtask_armlinux { cur=$PWD # job 5 - build_arm "armlinux" "armv8" "gcc" $port_armv8 + build_arm "armlinux" "armv8" "gcc" test_arm "armlinux" "armv8" "gcc" $port_armv8 cd $cur # job 6 - build_arm "armlinux" "armv7" "gcc" $port_armv8 + build_arm "armlinux" "armv7" "gcc" test_arm "armlinux" "armv7" "gcc" $port_armv8 cd $cur # job 7 - build_arm "armlinux" "armv7hf" "gcc" $port_armv8 + build_arm "armlinux" "armv7hf" "gcc" test_arm "armlinux" "armv7hf" "gcc" $port_armv8 cd $cur @@ -498,6 +519,11 @@ function main { ARM_PORT="${i#*=}" shift ;; + --opencl=*) + OPENCL="${i#*=}" + shift + ;; + build) build $TESTS_FILE build $LIBS_FILE @@ -520,11 +546,11 @@ function main { shift ;; cmake_arm) - cmake_arm $ARM_OS $ARM_ABI $ARM_LANG + cmake_arm $ARM_OS $ARM_ABI $ARM_LANG $OPENCL shift ;; build_arm) - build_arm $ARM_OS $ARM_ABI $ARM_LANG + build_arm $ARM_OS $ARM_ABI $ARM_LANG $OPENCL shift ;; test_server) @@ -532,7 +558,7 @@ function main { shift ;; test_arm) - build_arm $ARM_OS $ARM_ABI $ARM_LANG $ARM_PORT + test_arm $ARM_OS $ARM_ABI $ARM_LANG $ARM_PORT shift ;; test_arm_android) @@ -547,6 +573,10 @@ function main { build_test_arm shift ;; + build_test_arm_opencl) + build_test_arm_opencl + shift + ;; build_test_arm_subtask_android) build_test_arm_subtask_android shift diff --git a/paddle/fluid/lite/tools/debug/CMakeLists.txt b/paddle/fluid/lite/tools/debug/CMakeLists.txt index 908a436e8bbc4689877f6cf3d2f2c6ebb4509ddc..fec4633d6a08b389855c33dfd9a56a83c2811adf 100644 --- a/paddle/fluid/lite/tools/debug/CMakeLists.txt +++ b/paddle/fluid/lite/tools/debug/CMakeLists.txt @@ -9,4 +9,5 @@ lite_cc_binary(lite_model_debug_tool SRCS model_debug_tool.cc mir_passes ${ops_lite} ${host_kernels} X86_DEPS ${x86_kernels} - ARM_DEPS ${arm_kernels}) + ARM_DEPS ${arm_kernels} + CL_DEPS ${opencl_kernels})