forked from huawei-noah/bolt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
117 lines (110 loc) · 4.36 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
cmake_minimum_required(VERSION 3.2)
include(common/cmakes/bolt.cmake)
project(cheetah C CXX)
set_policy()
set(BOLT_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${BOLT_ROOT}/common/cmakes")
if (USE_CAFFE OR USE_ONNX OR USE_FLOW)
find_package(Protobuf)
endif()
if (USE_TFLITE)
find_package(TFLite)
endif (USE_TFLITE)
if (USE_TENSORFLOW)
find_package(jsoncpp)
endif (USE_TENSORFLOW)
if (USE_GPU)
find_package(Gcl)
endif(USE_GPU)
if (NOT "$ENV{JNI_ROOT}" STREQUAL "")
find_package(JNI)
if (JNI_FOUND)
set(USE_JNI ON)
endif(JNI_FOUND)
endif ()
if (USE_SECURE_C)
find_package(SecureC)
endif ()
if (BUILD_TEST)
find_package(jpeg)
if (EXISTS ${OpenCV_CMAKE_PATH})
include(${OpenCV_CMAKE_PATH})
endif()
endif (BUILD_TEST)
add_subdirectory(common)
if (USE_CAFFE OR USE_ONNX OR USE_TFLITE OR USE_TENSORFLOW OR USE_MINDSPORE)
add_subdirectory(model_tools)
endif()
add_subdirectory(compute)
add_subdirectory(inference)
set_c_cxx_flags()
set_test_c_cxx_flags()
message(STATUS "CFLAGS: ${CMAKE_C_FLAGS}")
message(STATUS "CXXFLAGS: ${CMAKE_CXX_FLAGS}")
add_custom_target(bolt_library ALL
COMMAND bash ./scripts/build_light_bolt.sh ${CMAKE_SYSTEM_NAME} ${CMAKE_CXX_COMPILER} ${CMAKE_AR} ${CMAKE_STRIP} ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_OUTPUT_EXTENSION} ${CMAKE_SHARED_LIBRARY_PREFIX} ${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_STATIC_LIBRARY_PREFIX} ${CMAKE_STATIC_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}
WORKING_DIRECTORY ${BOLT_ROOT})
if (USE_TRAINING)
set(TRAINING_BUILD_C_API ON)
set(TRAINING_BUILD_DEMO ON)
add_subdirectory(training)
add_dependencies(Raul blas_enhance uni)
add_dependencies(Raul blas_enhance_static uni_static)
endif (USE_TRAINING)
add_dependencies(bolt_library engine model_spec tensor image blas_enhance uni)
add_dependencies(bolt_library engine_static model_spec_static tensor_static image_static blas_enhance_static uni_static)
# install section
install(FILES ${CMAKE_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}bolt${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}bolt${CMAKE_STATIC_LIBRARY_SUFFIX}
${CMAKE_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}BoltModel${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION lib)
# generate *.lib library for Microsoft VS
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
install(FILES ${CMAKE_BINARY_DIR}/BoltModel.lib ${CMAKE_BINARY_DIR}/bolt.lib
DESTINATION lib)
endif ()
#find_program (DOXYGEN_PROGRAM doxygen)
#if (DOXYGEN_PROGRAM)
# execute_process(COMMAND doxygen .Doxyfile WORKING_DIRECTORY ${BOLT_ROOT})
#else ()
# message(WARNING "Can not find doxygen tools to generate code documents in docs/API/html/index.html!\
# If you dont't want to use these documents, you can skip this warning message.")
#endif ()
enable_testing()
find_program (BASH_PROGRAM bash)
if (BASH_PROGRAM AND USE_GENERAL)
file(GLOB CPUINFO_CMAKE_FILE $ENV{BOLT_ROOT}/common/cmakes/cpuinfo.cmake ${BOLT_ROOT}/common/cmakes/cpuinfo.cmake)
include(${CPUINFO_CMAKE_FILE})
set(parameters --host_dir=${CMAKE_INSTALL_PREFIX})
if (ANDROID)
set(parameters ${parameters} -d android --device_dir=/data/local/tmp/uldra)
elseif("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "${CMAKE_SYSTEM_PROCESSOR}" AND "${CMAKE_HOST_SYSTEM}" MATCHES "${CMAKE_SYSTEM_NAME}*")
if ("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "aarch64" OR "${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "armv7")
set(parameters ${parameters} -d host)
elseif (USE_X86)
set(x86_test ${cpuinfo_avx2})
if (USE_INT8)
set(x86_test ${cpuinfo_avx512})
endif ()
if (USE_AVX512_VNNI)
set(x86_test ${cpuinfo_avx512_vnni})
endif()
if (x86_test)
set(parameters ${parameters} -d host)
else ()
set(parameters ${parameters} -d unknown)
endif ()
else ()
set(parameters ${parameters} -d unknown)
endif()
else()
set(parameters ${parameters} -d unknown)
endif()
if (USE_GPU)
set(parameters ${parameters} -g)
endif(USE_GPU)
if (USE_DYNAMIC_LIBRARY)
set(parameters ${parameters} --shared)
endif(USE_DYNAMIC_LIBRARY)
add_test (NAME quick_benchmark COMMAND bash ${BOLT_ROOT}/scripts/quick_benchmark.sh ${parameters})
endif (BASH_PROGRAM AND USE_GENERAL)