CMakeLists.txt 23.0 KB
Newer Older
1
if(LITE_WITH_LIGHT_WEIGHT_FRAMEWORK OR (NOT LITE_WITH_LOG))
Y
Yan Chunwei 已提交
2 3 4
  lite_cc_library(place SRCS paddle_place.cc DEPS logging)
else()
  lite_cc_library(place SRCS paddle_place.cc DEPS glog)
5
endif()
Y
Yan Chunwei 已提交
6

7
if (LITE_ON_TINY_PUBLISH)
8 9
    set(CMAKE_CXX_FLAGS_RELEASE "-Os -DNDEBUG")
    set(CMAKE_C_FLAGS_RELEASE "-Os -DNDEBUG")
10
endif()
11 12

set(light_lib_DEPS light_api paddle_api paddle_api_light)
H
huzhiqiang 已提交
13

14
if ((NOT LITE_ON_TINY_PUBLISH) AND (LITE_WITH_CUDA OR LITE_WITH_X86 OR LITE_WITH_BM OR LITE_WITH_HUAWEI_ASCEND_NPU OR ARM_TARGET_OS STREQUAL "android" OR ARM_TARGET_OS STREQUAL "armlinux"))
15
    #full api dynamic library
16 17
    lite_cc_library(paddle_full_api_shared SHARED SRCS paddle_api.cc light_api.cc cxx_api.cc cxx_api_impl.cc light_api_impl.cc
                  DEPS paddle_api paddle_api_light  paddle_api_full)
18
    target_sources(paddle_full_api_shared PUBLIC ${__lite_cc_files})
19
    add_dependencies(paddle_full_api_shared op_list_h kernel_list_h framework_proto op_registry fbs_headers)
20
    target_link_libraries(paddle_full_api_shared framework_proto op_registry)
H
huzhiqiang 已提交
21
    if(LITE_WITH_X86)
22 23
        add_dependencies(paddle_full_api_shared xxhash)
        target_link_libraries(paddle_full_api_shared xxhash)
24
        if (NOT LITE_ON_MODEL_OPTIMIZE_TOOL)
25 26
            add_dependencies(paddle_full_api_shared dynload_mklml)
        endif()
27 28 29
        if(WIN32)
             target_link_libraries(paddle_full_api_shared shlwapi.lib)
        endif()
H
huzhiqiang 已提交
30
    endif()
31 32
    if(LITE_WITH_CUDA)
        target_link_libraries(paddle_full_api_shared ${math_cuda} "-Wl,--whole-archive" ${cuda_kernels} "-Wl,--no-whole-archive")
33 34
    endif(LITE_WITH_CUDA)

35
    #light api dynamic library
36 37 38 39 40
    lite_cc_library(paddle_light_api_shared SHARED SRCS paddle_api.cc light_api.cc light_api_impl.cc
                  DEPS ${light_lib_DEPS}
                  ARM_DEPS ${arm_kernels}
                  CV_DEPS paddle_cv_arm
                  NPU_DEPS ${npu_kernels}
H
hong19860320 已提交
41
                  APU_DEPS ${apu_kernels}
42
                  RKNPU_DEPS ${rknpu_kernels}
43
                  HUAWEI_ASCEND_NPU_DEPS ${huawei_ascend_npu_kernels}
44
                  )
45

46
    add_dependencies(paddle_light_api_shared op_list_h kernel_list_h)
47 48 49
    if(WIN32)
        target_link_libraries(paddle_light_api_shared shlwapi.lib)
    endif()
50
    target_link_libraries(paddle_light_api_shared ${light_lib_DEPS} ${arm_kernels} ${npu_kernels} ${huawei_ascend_npu_kernels} ${rknpu_kernels} ${apu_kernels})
51 52 53 54 55 56 57 58
   if(APPLE)
        set(LINK_MAP_FILE "${PADDLE_SOURCE_DIR}/lite/core/exported_symbols.lds")
        set(LINK_FLAGS "-Wl,-exported_symbols_list, ${LINK_MAP_FILE}")
        add_custom_command(OUTPUT ${LINK_MAP_FILE} COMMAND ...)
        add_custom_target(custom_linker_map DEPENDS ${LINK_MAP_FILE})
        set_target_properties(paddle_full_api_shared PROPERTIES LINK_FLAGS ${LINK_FLAGS})
        add_dependencies(paddle_full_api_shared custom_linker_map)
   elseif(NOT WIN32)
59 60 61 62 63 64 65
        set(LINK_MAP_FILE "${PADDLE_SOURCE_DIR}/lite/core/lite.map")
        set(LINK_FLAGS "-Wl,--version-script ${LINK_MAP_FILE}")
        add_custom_command(OUTPUT ${LINK_MAP_FILE} COMMAND ...)
        add_custom_target(custom_linker_map DEPENDS ${LINK_MAP_FILE})
        set_target_properties(paddle_full_api_shared PROPERTIES LINK_FLAGS ${LINK_FLAGS})
        add_dependencies(paddle_full_api_shared custom_linker_map)
   endif()
66
else()
67
    if ((ARM_TARGET_OS STREQUAL "android") OR (ARM_TARGET_OS STREQUAL "armlinux"))
68 69
        add_library(paddle_light_api_shared SHARED "")
        target_sources(paddle_light_api_shared PUBLIC ${__lite_cc_files} paddle_api.cc light_api.cc light_api_impl.cc)
70 71 72
        set(TARGET_COMIPILE_FLAGS "-fdata-sections")
        if (NOT (ARM_TARGET_LANG STREQUAL "clang")) #gcc
            set(TARGET_COMIPILE_FLAGS "${TARGET_COMIPILE_FLAGS} -flto")
73 74 75 76
            # TODO (hong19860320): Disable lto temporarily since it causes fail to catch the exceptions in android when toolchain is gcc.
            if (ARM_TARGET_OS STREQUAL "android" AND LITE_WITH_EXCEPTION)
                set(TARGET_COMIPILE_FLAGS "")
            endif()
77
        endif()
78
        set_target_properties(paddle_light_api_shared PROPERTIES COMPILE_FLAGS "${TARGET_COMIPILE_FLAGS}")
79
        add_dependencies(paddle_light_api_shared op_list_h kernel_list_h fbs_headers)
80 81
        if (LITE_WITH_NPU)
            # Need to add HIAI runtime libs (libhiai.so) dependency
82
            target_link_libraries(paddle_light_api_shared ${npu_builder_libs} ${npu_runtime_libs})
83
        endif()
84 85 86 87 88
        if (LITE_WITH_RKNPU)
            # Need to add RKNPU runtime libs dependency
            target_link_libraries(paddle_light_api_shared ${rknpu_builder_libs} ${rknpu_runtime_libs})
        endif()

89 90 91
    endif()
endif()

Y
Yan Chunwei 已提交
92 93 94 95
if (WITH_TESTING)
    lite_cc_library(lite_api_test_helper SRCS lite_api_test_helper.cc
      DEPS scope optimizer target_wrapper_host model_parser program
           ${ops} ${host_kernels}
96
      CUDA_DEPS ${cuda_kernels}
97
      X86_DEPS ${x86_kernels}
98
      XPU_DEPS ${xpu_kernels}
99
      RKNPU_DEPS ${rknpu_kernels}
100
      BM_DEPS ${bm_kernels}
H
hong19860320 已提交
101
      MLU_DEPS ${mlu_kernels}
102
      HUAWEI_ASCEND_NPU_DEPS ${huawei_ascend_npu_kernels}
H
hong19860320 已提交
103 104
      APU_DEPS ${apu_kernels})

Y
Yan Chunwei 已提交
105 106 107 108 109 110
endif()
if(LITE_WITH_FPGA)
    set(light_api_deps ${light_api_deps} ${fpga_deps})
    set(cxx_api_deps ${cxx_api_deps} ${fpga_deps})
endif()

111 112 113 114 115
if(LITE_WITH_BM)
    set(light_api_deps ${light_api_deps} ${bm_deps})
    set(cxx_api_deps ${cxx_api_deps} ${bm_deps})
endif()

116 117 118 119 120
if(LITE_WITH_RKNPU)
    set(light_api_deps ${light_api_deps} ${rknpu_deps})
    set(cxx_api_deps ${cxx_api_deps} ${rknpu_deps})
endif()

121 122 123 124
if(LITE_WITH_HUAWEI_ASCEND_NPU)
    set(light_api_deps ${light_api_deps} ${huawei_ascend_npu_deps})
    set(cxx_api_deps ${cxx_api_deps} ${huawei_ascend_npu_deps})
endif()
125

Y
Yan Chunwei 已提交
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
list(LENGTH ops num_ops)
list(LENGTH x86_kernels num_x86_kernels)
list(LENGTH cuda_kernels num_cuda_kernels)
list(LENGTH host_kernels num_host_kernels)
list(LENGTH arm_kernels num_arm_kernels)
list(LENGTH opencl_kernels num_opencl_kernels)
list(LENGTH npu_kernels num_npu_kernels)
list(LENGTH apu_kernels num_apu_kernels)
list(LENGTH xpu_kernels num_xpu_kernels)
list(LENGTH rknpu_kernels num_rknpu_kernels)
list(LENGTH fpga_kernels num_fpga_kernels)
list(LENGTH bm_kernels num_bm_kernels)
list(LENGTH mlu_kernels num_mlu_kernels)
list(LENGTH huawei_ascend_npu_kernels num_huawei_ascend_npu_kernels)

message(STATUS "Collected ${num_ops} ops")
message(STATUS "Collected ${num_x86_kernels} X86 kernels")
message(STATUS "Collected ${num_cuda_kernels} CUDA kernels")
message(STATUS "Collected ${num_host_kernels} Host kernels")
message(STATUS "Collected ${num_arm_kernels} ARM kernels")
message(STATUS "Collected ${num_opencl_kernels} OpenCL kernels")
message(STATUS "Collected ${num_npu_kernels} NPU kernels")
message(STATUS "Collected ${num_apu_kernels} APU kernels")
message(STATUS "Collected ${num_xpu_kernels} XPU kernels")
message(STATUS "Collected ${num_rknpu_kernels} RKNPU kernels")
message(STATUS "Collected ${num_fpga_kernels} FPGA kernels")
message(STATUS "Collected ${num_bm_kernels} BM kernels")
message(STATUS "Collected ${num_mlu_kernels} MLU kernels")
message(STATUS "Collected ${num_huawei_ascend_npu_kernels} HUAWEI_ASCEND_NPU kernels")
Y
Yan Chunwei 已提交
155 156 157 158

# for full api
if (NOT LITE_ON_TINY_PUBLISH)
    set(cxx_api_deps
159
    scope optimizer target_wrapper_host model_parser program)
Y
Yan Chunwei 已提交
160
    lite_cc_library(cxx_api
161 162 163
                        SRCS cxx_api.cc
                        DEPS ${cxx_api_deps} ${ops} ${host_kernels} program
                        X86_DEPS ${x86_kernels}
164
                        CUDA_DEPS ${cuda_kernels}
165 166
                        ARM_DEPS ${arm_kernels}
                        CV_DEPS paddle_cv_arm
Z
zhupengyang 已提交
167 168
                        NPU_DEPS ${npu_kernels}
                        XPU_DEPS ${xpu_kernels}
H
hong19860320 已提交
169
                        APU_DEPS ${apu_kernels}
170
                        RKNPU_DEPS ${rknpu_kernels}
171
                        BM_DEPS ${bm_kernels}
172
                        CL_DEPS ${opencl_kernels}
173 174
                        FPGA_DEPS ${fpga_kernels}
                        HUAWEI_ASCEND_NPU_DEPS ${huawei_ascend_npu_kernels})
Y
Yan Chunwei 已提交
175 176 177 178 179 180
endif()

# for light api
set(light_api_deps
    scope target_wrapper_host model_parser program)
if(LITE_WITH_CUDA)
181
    get_property(cuda_deps GLOBAL PROPERTY CUDA_MODULES)
Y
Yan Chunwei 已提交
182 183 184 185 186
    set(light_api_deps ${light_api_deps} target_wrapper_cuda)
endif()
lite_cc_library(light_api SRCS light_api.cc
        DEPS scope target_wrapper_host model_parser
            ${light_api_deps} ${ops} ${host_kernels} program
187
        CUDA_DEPS ${cuda_kernels}
Y
Yan Chunwei 已提交
188 189
        X86_DEPS ${x86_kernels}
        ARM_DEPS ${arm_kernels}
190
        CV_DEPS paddle_cv_arm
191
        NPU_DEPS ${npu_kernels}
H
hong19860320 已提交
192
        APU_DEPS ${apu_kernels}
193
        XPU_DEPS ${xpu_kernels}
194
        RKNPU_DEPS ${rknpu_kernels}
195
        CL_DEPS ${opencl_kernels}
196
        FPGA_DEPS ${fpga_kernels}
197
        BM_DEPS ${bm_kernels}
198 199
        MLU_DEPS ${mlu_kernels}
        HUAWEI_ASCEND_NPU_DEPS ${huawei_ascend_npu_kernels})
Y
Yan Chunwei 已提交
200 201 202 203 204 205

include(ExternalProject)
set(LITE_DEMO_INSTALL_DIR "${THIRD_PARTY_PATH}/inference_demo" CACHE STRING
        "A path setting inference demo download directories.")

if(WITH_TESTING)
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
    if(NOT WITH_COVERAGE)
        lite_cc_test(test_cxx_api SRCS cxx_api_test.cc
           DEPS cxx_api mir_passes lite_api_test_helper
           ${ops} ${host_kernels}
           X86_DEPS ${x86_kernels}
           CUDA_DEPS ${cuda_kernels}
           ARM_DEPS ${arm_kernels}
           CV_DEPS paddle_cv_arm
           NPU_DEPS ${npu_kernels}
           APU_DEPS ${apu_kernels}
           XPU_DEPS ${xpu_kernels}
           RKNPU_DEPS ${rknpu_kernels}
           CL_DEPS ${opencl_kernels}
           FPGA_DEPS ${fpga_kernels}
           BM_DEPS ${bm_kernels}
           MLU_DEPS ${mlu_kernels}
222
           HUAWEI_ASCEND_NPU_DEPS ${huawei_ascend_npu_kernels}
223 224 225 226 227
           EXCLUDE_COMPILE_DEPS "ON"
           ARGS --model_dir=${LITE_MODEL_DIR}/lite_naive_model
                --optimized_model=${LITE_MODEL_DIR}/lite_naive_model_opt SERIAL)
        add_dependencies(test_cxx_api extern_lite_download_lite_naive_model_tar_gz)
    endif()
Y
Yan Chunwei 已提交
228
    if(NOT LITE_WITH_LIGHT_WEIGHT_FRAMEWORK)
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
        if(LITE_WITH_X86)
            lite_cc_test(test_googlenet SRCS test_googlenet_lite.cc
               DEPS mir_passes lite_api_test_helper paddle_api_full paddle_api_light gflags utils
               ${ops} ${host_kernels} ${x86_kernels}
               ARGS --model_dir=${LITE_MODEL_DIR}/googlenet)
            add_dependencies(test_googlenet extern_lite_download_GoogleNet_inference_tar_gz)
            lite_cc_test(test_mobilenetv1_lite_x86 SRCS test_mobilenetv1_lite_x86.cc
               DEPS mir_passes lite_api_test_helper paddle_api_full paddle_api_light gflags utils
               ${ops} ${host_kernels} ${x86_kernels}
               ARGS --model_dir=${LITE_MODEL_DIR}/mobilenet_v1)
            add_dependencies(test_mobilenetv1_lite_x86 extern_lite_download_mobilenet_v1_tar_gz)
            lite_cc_test(test_mobilenetv2_lite_x86 SRCS test_mobilenetv2_lite_x86.cc
               DEPS mir_passes lite_api_test_helper paddle_api_full paddle_api_light gflags utils
               ${ops} ${host_kernels} ${x86_kernels}
               ARGS --model_dir=${LITE_MODEL_DIR}/mobilenet_v2_relu)
            add_dependencies(test_mobilenetv2_lite_x86 extern_lite_download_mobilenet_v2_relu_tar_gz)
            lite_cc_test(test_inceptionv4_lite_x86 SRCS test_inceptionv4_lite_x86.cc
               DEPS mir_passes lite_api_test_helper paddle_api_full paddle_api_light gflags utils
               ${ops} ${host_kernels} ${x86_kernels}
               ARGS --model_dir=${LITE_MODEL_DIR}/inception_v4_simple)
            add_dependencies(test_inceptionv4_lite_x86 extern_lite_download_inception_v4_simple_tar_gz)
            lite_cc_test(test_resnet50_lite_x86 SRCS test_resnet50_lite_x86.cc
               DEPS mir_passes lite_api_test_helper paddle_api_full paddle_api_light gflags utils
               ${ops} ${host_kernels} ${x86_kernels}
               ARGS --model_dir=${LITE_MODEL_DIR}/resnet50)
            add_dependencies(test_resnet50_lite_x86 extern_lite_download_resnet50_tar_gz)
            lite_cc_test(test_step_rnn_lite_x86 SRCS test_step_rnn_lite_x86.cc
               DEPS mir_passes lite_api_test_helper paddle_api_full paddle_api_light gflags utils
               ${ops} ${host_kernels} ${x86_kernels}
               ARGS --model_dir=${LITE_MODEL_DIR}/step_rnn)
            add_dependencies(test_step_rnn_lite_x86 extern_lite_download_step_rnn_tar_gz)
        endif()
261
        if(LITE_WITH_BM)
262
           lite_cc_test(test_classify_lite_bm SRCS test_classify_lite_bm.cc
263 264
              DEPS mir_passes lite_api_test_helper paddle_api_full paddle_api_light gflags utils
              ${ops} ${host_kernels} ${bm_kernels} ${bm_bridges}
265 266 267 268 269
              ARGS --model_dir=${LITE_MODEL_DIR}/classify)
           lite_cc_test(test_yolov3_lite_bm SRCS test_yolov3_lite_bm.cc
              DEPS mir_passes lite_api_test_helper paddle_api_full paddle_api_light gflags utils
              ${ops} ${host_kernels} ${bm_kernels} ${bm_bridges}
              ARGS --model_dir=${LITE_MODEL_DIR}/yolov3)
270
        endif()
Y
Yan Chunwei 已提交
271 272 273 274
    endif()
endif()

if(LITE_WITH_LIGHT_WEIGHT_FRAMEWORK AND WITH_TESTING)
H
hong19860320 已提交
275
    set(lite_model_test_DEPS cxx_api mir_passes ${ops} ${host_kernels} ${arm_kernels} ${npu_kernels} ${apu_kernels} ${fpga_kernels})
Y
Yan Chunwei 已提交
276 277 278 279

    lite_cc_test(test_mobilenetv1_int8 SRCS mobilenetv1_int8_test.cc
       DEPS ${lite_model_test_DEPS}
       CL_DEPS ${opencl_kernels}
280
       ARGS --cl_path=${CMAKE_SOURCE_DIR}/lite/backends/opencl
Y
Yan Chunwei 已提交
281 282 283 284 285 286 287
        --model_dir=${LITE_MODEL_DIR}/MobilenetV1_quant SERIAL)
    add_dependencies(test_mobilenetv1_int8 extern_lite_download_MobileNetV1_quant_tar_gz)

    lite_cc_test(test_mobilenetv1 SRCS mobilenetv1_test.cc
       DEPS ${lite_model_test_DEPS}
       CL_DEPS ${opencl_kernels}
       NPU_DEPS ${npu_kernels} ${npu_bridges}
288
       ARGS --cl_path=${CMAKE_SOURCE_DIR}/lite/backends/opencl
Y
Yan Chunwei 已提交
289 290
            --model_dir=${LITE_MODEL_DIR}/mobilenet_v1 SERIAL)
    add_dependencies(test_mobilenetv1 extern_lite_download_mobilenet_v1_tar_gz)
291 292 293 294
    if(NOT WIN32)
       set(LINK_FLAGS "-Wl,--version-script ${PADDLE_SOURCE_DIR}/lite/core/lite.map")
       set_target_properties(test_mobilenetv1 PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
    endif()
295

Y
Yan Chunwei 已提交
296 297 298
    lite_cc_test(test_mobilenetv2 SRCS mobilenetv2_test.cc
       DEPS ${lite_model_test_DEPS}
       CL_DEPS ${opencl_kernels}
299
       ARGS --cl_path=${CMAKE_SOURCE_DIR}/lite/backends/opencl
Y
Yan Chunwei 已提交
300 301
            --model_dir=${LITE_MODEL_DIR}/mobilenet_v2_relu SERIAL)
    add_dependencies(test_mobilenetv2 extern_lite_download_mobilenet_v2_relu_tar_gz)
302 303 304
    if(NOT WIN32)
        set_target_properties(test_mobilenetv2 PROPERTIES LINK_FLAGS "${LINK_FLAGS}")
    endif()
305

Y
Yan Chunwei 已提交
306
    lite_cc_test(test_resnet50 SRCS resnet50_test.cc
307
       DEPS ${lite_model_test_DEPS} paddle_api_light
Y
Yan Chunwei 已提交
308 309
       CL_DEPS ${opencl_kernels}
       FPGA_DEPS ${fpga_kernels}
310
       ARGS --cl_path=${CMAKE_SOURCE_DIR}/lite/backends/opencl
Y
Yan Chunwei 已提交
311 312 313 314 315 316 317 318 319 320 321
            --model_dir=${LITE_MODEL_DIR}/resnet50 SERIAL)
    add_dependencies(test_resnet50 extern_lite_download_resnet50_tar_gz)

    lite_cc_test(test_resnet50_fpga SRCS resnet50_test_fpga.cc
       DEPS ${lite_model_test_DEPS}
       CL_DEPS ${opencl_kernels}
       FPGA_DEPS ${fpga_kernels})

    lite_cc_test(test_inceptionv4 SRCS inceptionv4_test.cc
       DEPS ${lite_model_test_DEPS}
       CL_DEPS ${opencl_kernels}
322
       ARGS --cl_path=${CMAKE_SOURCE_DIR}/lite/backends/opencl
Y
Yan Chunwei 已提交
323
            --model_dir=${LITE_MODEL_DIR}/inception_v4 SERIAL)
324
    add_dependencies(test_inceptionv4 extern_lite_download_inception_v4_simple_tar_gz)
325

X
xiaogang 已提交
326
   # brief: we comment ocr_test_ut because we do not supply ocr model to test, it is the reference to infer nlp model
T
TianXiaogang 已提交
327 328 329 330 331 332 333
   # lite_cc_test(test_ocr_attention SRCS ocr_attention_test.cc
   #    DEPS ${lite_model_test_DEPS})

   # lite_cc_test(model_run_test_image SRCS model_run_test_image.cc
   #    DEPS ${lite_model_test_DEPS}
   #    CL_DEPS ${opencl_kernels}
   #    FPGA_DEPS ${fpga_kernels})
Y
Yan Chunwei 已提交
334 335
endif()

336
lite_cc_library(paddle_api SRCS paddle_api.cc DEPS op_params tensor device_info)
Y
Yan Chunwei 已提交
337 338 339

#-----------------------------------------------------------------------------------------------------
# The final inference library for both CxxConfig and MobileConfig.
340 341 342 343 344
if (LITE_ON_TINY_PUBLISH)
    lite_cc_library(paddle_api_light SRCS light_api_impl.cc DEPS light_api paddle_api stream)
else()
    lite_cc_library(paddle_api_light SRCS light_api_impl.cc DEPS light_api paddle_api)
endif()
Y
Yan Chunwei 已提交
345
if (NOT LITE_ON_TINY_PUBLISH)
346
    lite_cc_library(paddle_api_full SRCS cxx_api_impl.cc DEPS cxx_api paddle_api_light
347 348 349 350
        ${ops}
        ARM_DEPS ${arm_kernels}
        CV_DEPS paddle_cv_arm
        NPU_DEPS ${npu_kernels}
H
hong19860320 已提交
351
        APU_DEPS ${apu_kernels}
352
        CL_DEPS ${opencl_kernels}
353
        FPGA_DEPS ${fpga_kernels}
354 355
        BM_DEPS ${bm_kernels}
        HUAWEI_ASCEND_NPU_DEPS ${huawei_ascend_npu_kernels})
Y
Yan Chunwei 已提交
356 357
    # The final inference library for just MobileConfig.
    bundle_static_library(paddle_api_full paddle_api_full_bundled bundle_full_api)
358
    target_link_libraries(paddle_api_full ${cuda_deps})
359
    get_property(fluid_modules GLOBAL PROPERTY FLUID_MODULES)
Y
Yan Chunwei 已提交
360
endif()
361

Y
Yan Chunwei 已提交
362 363 364
bundle_static_library(paddle_api_light paddle_api_light_bundled bundle_light_api)
#-----------------------------------------------------------------------------------------------------

365 366
# These tests needs CLI arguments, and is not supported in ARM CI.
# TODO(Superjomn) support latter.
367 368
if(NOT WITH_COVERAGE)
    lite_cc_test(test_light_api SRCS light_api_test.cc
369 370 371
        DEPS light_api program mir_passes paddle_api_light
        CL_DEPS ${opencl_kernels}
        FPGA_DEPS ${fpga_kernels}
372
        RKNPU_DEPS ${rknpu_kernels}
373
        BM_DEPS ${bm_kernels}
374 375
        ARGS --optimized_model=${LITE_MODEL_DIR}/lite_naive_model_opt SERIAL)

376
    lite_cc_test(test_apis SRCS apis_test.cc
377 378 379
        DEPS cxx_api light_api ${ops} paddle_api_light
        CL_DEPS ${opencl_kernels}
        X86_DEPS ${x86_kernels}
380
        XPU_DEPS ${xpu_kernels}
381
        FPGA_DEPS ${fpga_kernels}
382
        RKNPU_DEPS ${rknpu_kernels}
383
        BM_DEPS ${bm_kernels}
384
        MLU_DEPS ${mlu_kernels}
385 386
        ARGS --model_dir=${LITE_MODEL_DIR}/lite_naive_model
        --optimized_model=${LITE_MODEL_DIR}/lite_naive_model_opt SERIAL)
387
endif()
388

Y
Yan Chunwei 已提交
389 390 391 392
if (LITE_WITH_JAVA AND LITE_WITH_ARM)
    add_subdirectory(android)
endif()

393
if (LITE_WITH_PYTHON)
S
sangoly 已提交
394
    add_subdirectory(python)
395 396 397
    # add library for opt_base
    lite_cc_library(opt_base SRCS opt_base.cc cxx_api_impl.cc paddle_api.cc cxx_api.cc DEPS kernel op optimizer mir_passes utils)
    add_dependencies(opt_base supported_kernel_op_info_h framework_proto all_kernel_faked_cc kernel_list_h)
S
sangoly 已提交
398 399
endif()

Y
Yan Chunwei 已提交
400 401 402
if (LITE_ON_TINY_PUBLISH)
    return()
endif()
403

404 405


406
if (LITE_ON_MODEL_OPTIMIZE_TOOL)
407 408
    message(STATUS "Compiling opt")
    lite_cc_binary(opt SRCS opt.cc cxx_api_impl.cc paddle_api.cc cxx_api.cc
409
        DEPS gflags kernel op optimizer mir_passes utils ${host_kernels})
410
    add_dependencies(opt op_list_h kernel_list_h all_kernel_faked_cc supported_kernel_op_info_h)
411 412
endif(LITE_ON_MODEL_OPTIMIZE_TOOL)

413 414 415 416 417 418 419 420 421 422 423 424 425 426
if(NOT WITH_COVERAGE)
    lite_cc_test(test_paddle_api SRCS paddle_api_test.cc DEPS paddle_api_full paddle_api_light
      ${ops}
      ARM_DEPS ${arm_kernels}
      CV_DEPS paddle_cv_arm
      NPU_DEPS ${npu_kernels}
      XPU_DEPS ${xpu_kernels}
      APU_DEPS ${apu_kernels}
      RKNPU_DEPS ${rknpu_kernels}
      CL_DEPS ${opencl_kernels}
      X86_DEPS ${x86_kernels}
      FPGA_DEPS ${fpga_kernels}
      BM_DEPS ${bm_kernels}
      MLU_DEPS ${mlu_kernels}
427
      HUAWEI_ASCEND_NPU_DEPS ${huawei_ascend_npu_kernels}
428 429 430 431
      ARGS --model_dir=${LITE_MODEL_DIR}/lite_naive_model SERIAL)
    if (WITH_TESTING)
        add_dependencies(test_paddle_api extern_lite_download_lite_naive_model_tar_gz)
    endif()
Y
Yan Chunwei 已提交
432 433 434 435
endif()

# Some bins
if(NOT IOS)
436 437 438 439 440 441
    lite_cc_binary(test_model_bin SRCS model_test.cc DEPS paddle_api_full paddle_api_light gflags utils
        ${ops} ${host_kernels}
        ARM_DEPS ${arm_kernels}
        CV_DEPS paddle_cv_arm
        NPU_DEPS ${npu_kernels}
        XPU_DEPS ${xpu_kernels}
442
        MLU_DEPS ${mlu_kernels}
H
hong19860320 已提交
443
        APU_DEPS ${apu_kernels}
444
        CL_DEPS ${opencl_kernels}
445
        BM_DEPS ${bm_kernels}
446
        RKNPU_DEPS ${rknpu_kernels}
447 448
        FPGA_DEPS ${fpga_kernels}
        X86_DEPS ${x86_kernels}
449 450
        CUDA_DEPS ${cuda_kernels}
        HUAWEI_ASCEND_NPU_DEPS ${huawei_ascend_npu_kernels})
451 452 453 454 455 456 457
    
    lite_cc_binary(test_model_detection_bin SRCS model_test_detection.cc DEPS paddle_api_full paddle_api_light gflags utils
        ${ops} ${host_kernels}
        ARM_DEPS ${arm_kernels}
        CV_DEPS paddle_cv_arm
        NPU_DEPS ${npu_kernels}
        XPU_DEPS ${xpu_kernels}
458
        MLU_DEPS ${mlu_kernels}
H
hong19860320 已提交
459
        APU_DEPS ${apu_kernels}
460 461
        CL_DEPS ${opencl_kernels}
        BM_DEPS ${bm_kernels}
462
        RKNPU_DEPS ${rknpu_kernels}
463 464
        FPGA_DEPS ${fpga_kernels}
        X86_DEPS ${x86_kernels}
465 466
        CUDA_DEPS ${cuda_kernels}
        HUAWEI_ASCEND_NPU_DEPS ${huawei_ascend_npu_kernels})
467 468 469 470 471 472 473
    
    lite_cc_binary(test_model_classify_bin SRCS model_test_classify.cc DEPS paddle_api_full paddle_api_light gflags utils
        ${ops} ${host_kernels}
        ARM_DEPS ${arm_kernels}
        CV_DEPS paddle_cv_arm
        NPU_DEPS ${npu_kernels}
        XPU_DEPS ${xpu_kernels}
474
        MLU_DEPS ${mlu_kernels}
H
hong19860320 已提交
475
        APU_DEPS ${apu_kernels}
476 477
        CL_DEPS ${opencl_kernels}
        BM_DEPS ${bm_kernels}
478
        RKNPU_DEPS ${rknpu_kernels}
479 480
        FPGA_DEPS ${fpga_kernels}
        X86_DEPS ${x86_kernels}
481 482
        CUDA_DEPS ${cuda_kernels}
        HUAWEI_ASCEND_NPU_DEPS ${huawei_ascend_npu_kernels})
H
HappyAngel 已提交
483

484 485 486
    lite_cc_binary(benchmark_bin SRCS benchmark.cc DEPS paddle_api_full paddle_api_light gflags utils
        ${ops} ${host_kernels}
        ARM_DEPS ${arm_kernels}
H
HappyAngel 已提交
487
        CV_DEPS paddle_cv_arm
488 489
        NPU_DEPS ${npu_kernels}
        XPU_DEPS ${xpu_kernels}
490
        RKNPU_DEPS ${rknpu_kernels}
491
        MLU_DEPS ${mlu_kernels}
H
hong19860320 已提交
492
        APU_DEPS ${apu_kernels}
493 494 495
        CL_DEPS ${opencl_kernels}
        FPGA_DEPS ${fpga_kernels}
        X86_DEPS ${x86_kernels}
496 497
        CUDA_DEPS ${cuda_kernels}
        HUAWEI_ASCEND_NPU_DEPS ${huawei_ascend_npu_kernels})
498
    
X
xiaogang 已提交
499 500 501 502 503
    lite_cc_binary(multithread_test SRCS lite_multithread_test.cc DEPS paddle_api_full paddle_api_light gflags utils
        ${ops} ${host_kernels}
        ARM_DEPS ${arm_kernels}
        CV_DEPS paddle_cv_arm
        NPU_DEPS ${npu_kernels}
H
hong19860320 已提交
504
        APU_DEPS ${apu_kernels}
X
xiaogang 已提交
505
        XPU_DEPS ${xpu_kernels}
506
        RKNPU_DEPS ${rknpu_kernels}
507
        MLU_DEPS ${mlu_kernels}
508
        HUAWEI_ASCEND_NPU_DEPS ${huawei_ascend_npu_kernels}
X
xiaogang 已提交
509
        CL_DEPS ${opencl_kernels}
510
        BM_DEPS ${bm_kernels}
X
xiaogang 已提交
511 512 513
        FPGA_DEPS ${fpga_kernels}
        X86_DEPS ${x86_kernels}
        CUDA_DEPS ${cuda_kernels})
514

X
xiaogang 已提交
515 516 517 518 519
    lite_cc_binary(test_transformer SRCS transform_test.cc DEPS paddle_api_full paddle_api_light gflags utils
        ${ops} ${host_kernels}
        ARM_DEPS ${arm_kernels}
        CV_DEPS paddle_cv_arm
        NPU_DEPS ${npu_kernels}
520
        RKNPU_DEPS ${npu_kernels}
X
xiaogang 已提交
521
        XPU_DEPS ${xpu_kernels}
H
hong19860320 已提交
522
        APU_DEPS ${apu_kernels}
X
xiaogang 已提交
523 524 525
        CL_DEPS ${opencl_kernels}
        FPGA_DEPS ${fpga_kernels}
        X86_DEPS ${x86_kernels}
526 527
        CUDA_DEPS ${cuda_kernels}
        HUAWEI_ASCEND_NPU_DEPS ${huawei_ascend_npu_kernels})
Y
Yan Chunwei 已提交
528 529 530 531 532 533
endif()

#lite_cc_binary(cxx_api_bin SRCS cxx_api_bin.cc
    #X86_DEPS operator
    #DEPS light_api model_parser target_wrapper_host mir_passes
    #ARM_DEPS ${arm_kernels}) NPU_DEPS ${npu_kernels})