CMakeLists.txt 6.9 KB
Newer Older
Y
Yan Chunwei 已提交
1 2 3 4 5 6 7
if (WITH_TESTING)
    lite_cc_library(lite_gtest_main SRCS lite_gtest_main.cc DEPS gtest gflags)
endif()
lite_cc_library(target_wrapper SRCS target_wrapper.cc
  DEPS target_wrapper_host place
  X86_DEPS target_wrapper_x86
  CUDA_DEPS target_wrapper_cuda
8
  XPU_DEPS target_wrapper_xpu
Y
Yan Chunwei 已提交
9
  CL_DEPS cl_target_wrapper
10
  FPGA_DEPS fpga_target_wrapper
11 12
  BM_DEPS target_wrapper_bm
  MLU_DEPS target_wrapper_mlu)
Y
Yan Chunwei 已提交
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

lite_cc_library(memory SRCS memory.cc DEPS target_wrapper CL_DEPS cl_target_wrapper)

set(tensor_extra_deps "")
if (LITE_WITH_FPGA)
    set(tensor_extra_deps lite_tensor_fpga)
endif()
lite_cc_library(tensor SRCS tensor.cc DEPS memory ${tensor_extra_deps})


if (NOT LITE_ON_TINY_PUBLISH)
    proto_library(framework_proto SRCS framework.proto)
endif()

lite_cc_library(variable SRCS variable.cc DEPS tensor)
lite_cc_library(types SRCS types.cc)
lite_cc_library(op_registry SRCS op_registry.cc DEPS kernel)
lite_cc_library(scope SRCS scope.cc DEPS tensor)
31
lite_cc_library(device_info SRCS device_info.cc DEPS tensor)
Y
Yan Chunwei 已提交
32 33

if (LITE_WITH_ARM)
34
lite_cc_library(context SRCS context.cc DEPS tensor any device_info CL_DEPS cl_context)
Y
Yan Chunwei 已提交
35
else()
36
lite_cc_library(context SRCS context.cc DEPS tensor any device_info eigen3 CL_DEPS cl_context CUDA_DEPS cuda_context)
Y
Yan Chunwei 已提交
37
endif()
38

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
#-------------------------------------------- GET CODE META INFO ------------------------------------------
execute_process(
  COMMAND git describe --tags --exact-match
  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  OUTPUT_VARIABLE PADDLE_LITE_TAG
  OUTPUT_STRIP_TRAILING_WHITESPACE
)

execute_process(
  COMMAND git rev-parse --abbrev-ref HEAD
  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  OUTPUT_VARIABLE PADDLE_LITE_BRANCH
  OUTPUT_STRIP_TRAILING_WHITESPACE
)

execute_process(
  COMMAND git log -1 --format=%h
  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  OUTPUT_VARIABLE PADDLE_LITE_COMMIT
  OUTPUT_STRIP_TRAILING_WHITESPACE
)

message(STATUS "tag: ${PADDLE_LITE_TAG}")
message(STATUS "branch: ${PADDLE_LITE_BRANCH}")
message(STATUS "commit: ${PADDLE_LITE_COMMIT}")

configure_file(version.h.in version.h)
66
#----------------------------------------------- NOT CHANGE -----------------------------------------------
67 68 69 70 71 72 73
# A trick to generate the opencl_kernels_source.cc
#add_custom_command(
#  COMMAND python ${CMAKE_SOURCE_DIR}/lite/tools/cmake_tools/gen_opencl_code.py
#  ${CMAKE_SOURCE_DIR}/lite/backends/opencl/cl_kernel
#  ${CMAKE_BINARY_DIR}/lite/backends/opencl/opencl_kernels_source.cc
#  OUTPUT opencl_kernels_source.cc # not a real path to the output to force it execute every time.
#  )
74 75 76 77 78
# A trick to generate the paddle_use_kernels.h
add_custom_command(
  COMMAND python ${CMAKE_SOURCE_DIR}/lite/tools/cmake_tools/parse_kernel_registry.py
  ${kernels_src_list}
  ${CMAKE_SOURCE_DIR}/lite/api/paddle_use_kernels.h
79 80
  "${LITE_OPTMODEL_DIR}/.tailored_kernels_list"
  LITE_BUILD_TAILOR
81
  OUTPUT kernels.h # not a real path to the output to force it execute every time.
82 83 84 85 86 87
  )
# A trick to generate the paddle_use_ops.h
add_custom_command(
  COMMAND python ${CMAKE_SOURCE_DIR}/lite/tools/cmake_tools/parse_op_registry.py
  ${ops_src_list}
  ${CMAKE_SOURCE_DIR}/lite/api/paddle_use_ops.h
88 89
  "${LITE_OPTMODEL_DIR}/.tailored_ops_list"
  LITE_BUILD_TAILOR
90
  OUTPUT ops.h # not a real path to the output to force it execute every time.
91
  )
92
# generate fake kernels for memory_optimize_tool
93 94 95

#-------------------------------opt----------------------------------------------------------------
# tricks to create headfiles for opt
96 97 98
add_custom_command(
  COMMAND python ${CMAKE_SOURCE_DIR}/lite/tools/cmake_tools/create_fake_kernel_registry.py
  ${kernels_src_list}
99
  ${fake_kernels_src_list}
100
  ${CMAKE_BINARY_DIR}/all_kernel_faked.cc
101
  ${CMAKE_BINARY_DIR}/kernel_src_map.h
102
  OUTPUT all_kernel_faked.cc # not a real path to the output to force it execute every time.
103
  )
104 105 106
add_custom_target(op_list_h DEPENDS ops.h)
add_custom_target(kernel_list_h DEPENDS kernels.h)
add_custom_target(all_kernel_faked_cc DEPENDS all_kernel_faked.cc)
107

108 109 110 111
# create headfile to restore ops info sorted by suppported platforms
add_custom_command(
  COMMAND python ${CMAKE_SOURCE_DIR}/lite/tools/cmake_tools/record_supported_kernel_op.py
  ${kernels_src_list}
112
  ${fake_kernels_src_list}
113 114 115 116 117
  ${ops_src_list}
  ${CMAKE_BINARY_DIR}/supported_kernel_op_info.h
  OUTPUT supported_kernel_op_info.h # not a real path to the output to force it execute every time.
  )
  add_custom_target(supported_kernel_op_info_h DEPENDS supported_kernel_op_info.h)
118
#----------------------------------------------- NOT CHANGE -----------------------------------------------
119 120
lite_cc_library(kernel SRCS kernel.cc
        DEPS context type_system target_wrapper any op_params tensor
121
        PROFILE_DEPS lite_profiler
122
  )
Y
Yan Chunwei 已提交
123
lite_cc_library(op SRCS op_lite.cc DEPS scope op_registry target_wrapper kernel
124
  cpp_op_desc tensor utils
125 126 127 128 129 130
  )

add_dependencies(kernel kernel_list_h)
add_dependencies(op op_list_h)


Y
Yan Chunwei 已提交
131 132 133 134
lite_cc_library(type_system SRCS type_system.cc DEPS tensor target_wrapper)

lite_cc_library(program SRCS program.cc
    DEPS op kernel model_parser ${ops} ${cpp_wrapper}
135
    PROFILE_DEPS lite_profiler
W
Wilber 已提交
136
    CUDA_DEPS nvtx_wrapper cuda_type_trans)
Y
Yan Chunwei 已提交
137 138 139 140 141 142 143 144

if (NOT LITE_ON_TINY_PUBLISH)
  lite_cc_library(optimizer SRCS optimizer.cc DEPS mir_pass_manager model_parser program)
  add_subdirectory(mir)
  add_subdirectory(profile)
  add_subdirectory(arena)
endif()

145 146 147 148 149 150 151 152 153
if(LITE_WITH_NPU OR LITE_WITH_XTCL OR LITE_WITH_BM OR LITE_WITH_RKNPU OR LITE_WITH_MLU OR LITE_WITH_APU OR LITE_WITH_HUAWEI_ASCEND_NPU)
    lite_cc_library(subgraph_bridge_registry
      SRCS subgraph_bridge_registry.cc
      DEPS op)
   lite_cc_library(subgraph_engine_base
      SRCS subgraph_engine_base.cc
      DEPS tensor op scope program)
endif()

Y
Yan Chunwei 已提交
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
# for mobile, unnecessary to compile the following testings.
if (LITE_WITH_LIGHT_WEIGHT_FRAMEWORK)
    return()
endif()

# lite_cc_library(program_fake_utils SRCS program_fake_utils.cc DEPS mir_ssa_graph
#         scope op_registry proto_desc op
#         ${ops}
#         ${host_kernels}
#         )

lite_cc_test(test_scope SRCS scope_test.cc DEPS scope)
lite_cc_test(test_kernel SRCS kernel_test.cc DEPS kernel target_wrapper any)
lite_cc_test(test_op SRCS op_lite_test.cc DEPS op)
lite_cc_test(test_tensor SRCS lite_tensor_test.cc DEPS tensor)
lite_cc_test(test_type_system SRCS type_system_test.cc DEPS type_system utils)
#lite_cc_test(test_optimizer SRCS optimizer_test.cc DEPS mir_pass_manager program_fake_utils mir_passes optimizer fc_op)
lite_cc_test(test_types SRCS types_test.cc DEPS types)
lite_cc_test(test_memory SRCS memory_test.cc DEPS memory)
lite_cc_test(test_context SRCS context_test.cc DEPS context)
174 175 176 177 178 179 180 181 182 183 184 185 186 187


# # A trick to generate the paddle_use_kernels.h
# execute_process(
#   COMMAND python ${CMAKE_SOURCE_DIR}/lite/tools/cmake_tools/parse_kernel_registry.py
#   ${kernels_src_list}
#   ${CMAKE_SOURCE_DIR}/lite/api/paddle_use_kernels.h
#   )
# # A trick to generate the paddle_use_ops.h
# execute_process(
#   COMMAND python ${CMAKE_SOURCE_DIR}/lite/tools/cmake_tools/parse_op_registry.py
#   ${ops_src_list}
#   ${CMAKE_SOURCE_DIR}/lite/api/paddle_use_ops.h
#   )