Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle-Lite
Browse files Browse the repository at this point in the history
…into pr/7348
  • Loading branch information
zhangjun committed Nov 3, 2021
2 parents bb1dbf0 + 3451cc1 commit 86a4e26
Show file tree
Hide file tree
Showing 94 changed files with 2,044 additions and 2,521 deletions.
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version: 2
build:
os: ubuntu-20.04
tools:
python: "3.4"
python: "3.6"
# You can also specify other tool versions:
# nodejs: "16"
# rust: "1.55"
Expand Down
189 changes: 35 additions & 154 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# c++ standard
if(LITE_WITH_XTCL OR LITE_WITH_METAL)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 14)
else()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)
endif()

# Host system configurations
Expand Down Expand Up @@ -97,10 +97,10 @@ lite_option(LITE_WITH_CODE_META_INFO "include git version in the heade

# Thirdparty
set(THIRD_PARTY_PATH "${CMAKE_BINARY_DIR}/third_party" CACHE STRING
"A path setting third party libraries download & build directories.")
"A path setting third party libraries download & build directories.")

if(NOT LITE_WITH_LIGHT_WEIGHT_FRAMEWORK)
find_package(CUDA QUIET)
find_package(CUDA QUIET)
endif()
find_package(Git REQUIRED)
find_package(Threads REQUIRED)
Expand All @@ -110,183 +110,64 @@ include(simd)

# CMAKE_BUILD_TYPE
if(NOT CMAKE_BUILD_TYPE)
if(WIN32)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel"
FORCE)
else()

if(WIN32)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel" FORCE)
else()
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel"
FORCE)
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel" FORCE)
endif()
endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")

# check options
if (LITE_ON_TINY_PUBLISH)
if (NOT (WITH_LITE AND LITE_WITH_LIGHT_WEIGHT_FRAMEWORK AND NOT WITH_TESTING))#LITE_WITH_JAVA AND
message(FATAL_ERROR "LITE_ON_TINY_PUBLISH=ON must be used with WITH_LITE=ON LITE_WITH_LIGHT_WEIGHT_FRAMEWORK=ON LITE_WITH_JAVA=ON WITH_TESTING=OFF")
return()
endif()
if(LITE_ON_TINY_PUBLISH)
if(NOT (WITH_LITE AND LITE_WITH_LIGHT_WEIGHT_FRAMEWORK AND NOT WITH_TESTING))#LITE_WITH_JAVA AND
message(FATAL_ERROR "LITE_ON_TINY_PUBLISH=ON must be used with WITH_LITE=ON LITE_WITH_LIGHT_WEIGHT_FRAMEWORK=ON LITE_WITH_JAVA=ON WITH_TESTING=OFF")
return()
endif()
endif()

include_directories("${PADDLE_SOURCE_DIR}")
# the generated header files.
set(LITE_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}")
include_directories("${LITE_GENERATED_INCLUDE_DIR}")

if (LITE_WITH_PYTHON)
include(external/python) # download, build, install python
include(external/pybind11) # download, build, install pybind11
endif()

if(LITE_WITH_RKNPU)
include(backends/rknpu)
endif()

if(LITE_WITH_IMAGINATION_NNA)
include(backends/imagination_nna)
endif()

if(LITE_WITH_INTEL_FPGA)
include(backends/intel_fpga)
if(LITE_WITH_PYTHON)
include(external/python) # download, build, install python
include(external/pybind11) # download, build, install pybind11
endif()

# flatbuffer module for loading model
if(LITE_UPDATE_FBS_HEAD)
include(external/flatbuffers)
include(external/flatbuffers)
else()
include_directories("${PADDLE_SOURCE_DIR}/third-party/flatbuffers/pre-build")
add_custom_target(fbs_headers ${TARGET}
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/third-party/flatbuffers/pre-build/framework_generated.h" "${CMAKE_SOURCE_DIR}/lite/model_parser/flatbuffers/"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/third-party/flatbuffers/pre-build/param_generated.h" "${CMAKE_SOURCE_DIR}/lite/model_parser/flatbuffers/"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/third-party/flatbuffers/pre-build/cache_generated.h" "${CMAKE_SOURCE_DIR}/lite/backends/opencl/utils/"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/third-party/flatbuffers/pre-build/tune_cache_generated.h" "${CMAKE_SOURCE_DIR}/lite/backends/opencl/utils/"
)
include_directories("${PADDLE_SOURCE_DIR}/third-party/flatbuffers/pre-build")
add_custom_target(fbs_headers ${TARGET}
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/third-party/flatbuffers/pre-build/framework_generated.h" "${CMAKE_SOURCE_DIR}/lite/model_parser/flatbuffers/"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/third-party/flatbuffers/pre-build/param_generated.h" "${CMAKE_SOURCE_DIR}/lite/model_parser/flatbuffers/"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/third-party/flatbuffers/pre-build/cache_generated.h" "${CMAKE_SOURCE_DIR}/lite/backends/opencl/utils/"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/third-party/flatbuffers/pre-build/tune_cache_generated.h" "${CMAKE_SOURCE_DIR}/lite/backends/opencl/utils/"
)
endif()

if (LITE_THREAD_POOL)
if(LITE_THREAD_POOL)
add_definitions(-DLITE_USE_THREAD_POOL)
endif()

if (LITE_THREAD_POOL OR ((ARM_TARGET_LANG STREQUAL "clang") AND (ARM_TARGET_ARCH_ABI STREQUAL "armv7")))
set(LITE_WITH_OPENMP OFF CACHE STRING "Disable OpenMP when Thread Pool is enabled" FORCE)
endif()

# for opencl
if (LITE_WITH_OPENCL)
include_directories("${PADDLE_SOURCE_DIR}/third-party/opencl/include")
set(LITE_WITH_OPENMP OFF CACHE STRING "Disable OpenMP when Thread Pool is enabled" FORCE)
endif()

# for mobile
if (WITH_LITE AND LITE_WITH_LIGHT_WEIGHT_FRAMEWORK)
message(STATUS "Building the mobile framework")
include(postproject)
include(backends/npu) # check and prepare NPU DDK
include(backends/xpu) # check and prepare XPU SDK
include(backends/apu) # check and prepare APU SDK
include(backends/huawei_ascend_npu) # check and prepare Ascend NPU SDK

# We compile the mobile deployment library when LITE_ON_TINY_PUBLISH=ON
# So the following third party dependencies are not needed.
if (NOT LITE_ON_TINY_PUBLISH)
# include the necessary thirdparty dependencies
include(external/gflags) # download, build, install gflags
# LITE_WITH_LIGHT_WEIGHT_FRAMEWORK=ON will disable glog
# TODO(sangoly): refine WITH_LITE and LITE_WITH_LIGHT_WEIGHT_FRAMEWORK
include(external/gtest) # download, build, install gtest
include(ccache) # set ccache for compilation
include(external/protobuf) # download, build, install protobuf
endif()

include(generic) # simplify cmake module
include(configure) # add paddle env configuration

add_subdirectory(lite)
return()
endif()
################################# End of mobile compile ##############################

set(WITH_MKLML ${WITH_MKL})
if (NOT DEFINED WITH_MKLDNN)
if (WITH_MKL AND AVX2_FOUND)
set(WITH_MKLDNN ON)
else()
message(STATUS "Do not have AVX2 intrinsics and disabled MKL-DNN")
set(WITH_MKLDNN OFF)
endif()
if(NOT DEFINED WITH_MKLDNN)
if(WITH_MKL AND AVX2_FOUND)
set(WITH_MKLDNN ON)
else()
message(STATUS "Do not have AVX2 intrinsics and disabled MKL-DNN")
set(WITH_MKLDNN OFF)
endif()
endif()

########################################################################################

if(LITE_WITH_XPU)
include(backends/xpu)
endif()

if(LITE_WITH_MLU)
include(mlu)
endif()

if(LITE_WITH_HUAWEI_ASCEND_NPU)
include(backends/huawei_ascend_npu)
endif()

include(coveralls)

include(external/mklml) # download mklml package
include(external/xbyak) # download xbyak package

include(external/libxsmm) # download, build, install libxsmm
include(external/gflags) # download, build, install gflags
include(external/glog) # download, build, install glog
include(external/gtest) # download, build, install gtest
include(external/protobuf) # download, build, install protobuf
include(external/openblas) # download, build, install openblas
include(external/mkldnn) # download, build, install mkldnn
include(external/eigen) # download eigen3
include(external/xxhash) # download install xxhash needed for x86 jit

include(cudnn)
include(configure) # add paddle env configuration

if(LITE_WITH_CUDA)
include(cuda)
endif()

if(LITE_WITH_BM)
include(bm)
endif()
include(generic) # simplify cmake module
include(ccache) # set ccache for compilation
include(util) # set unittest and link libs
include(version) # set PADDLE_VERSION
if(NOT APPLE)
include(flags)
endif()

set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")


if(APPLE)
if(NOT DEFINED ENABLE_ARC)
# Unless specified, enable ARC support by default
set(ENABLE_ARC TRUE)
message(STATUS "Enabling ARC support by default. ENABLE_ARC not provided!")
endif()

set(ENABLE_ARC_INT ${ENABLE_ARC} CACHE BOOL "Whether or not to enable ARC" ${FORCE_CACHE})
if(ENABLE_ARC_INT)
set(FOBJC_ARC "-fobjc-arc")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES CACHE INTERNAL "")
message(STATUS "Enabling ARC support.")
else()
set(FOBJC_ARC "-fno-objc-arc")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC NO CACHE INTERNAL "")
message(STATUS "Disabling ARC support.")
endif()
set(CMAKE_C_FLAGS "${FOBJC_ARC} ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${FOBJC_ARC} ${CMAKE_CXX_FLAGS}")
endif ()
include(backends/common)
add_subdirectory(lite)
108 changes: 108 additions & 0 deletions cmake/backends/common.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# for opencl
if (LITE_WITH_OPENCL)
include_directories("${PADDLE_SOURCE_DIR}/third-party/opencl/include")
endif()

if(LITE_WITH_RKNPU)
include(backends/rknpu)
endif()

if(LITE_WITH_INTEL_FPGA)
include(backends/intel_fpga)
endif()

if(LITE_WITH_IMAGINATION_NNA)
include(backends/imagination_nna)
endif()

# for mobile
if (WITH_LITE AND LITE_WITH_LIGHT_WEIGHT_FRAMEWORK)
message(STATUS "Building the mobile framework")
include(postproject)
include(backends/npu) # check and prepare NPU DDK
include(backends/xpu) # check and prepare XPU
include(backends/apu) # check and prepare APU SDK
include(backends/huawei_ascend_npu) # check and prepare Ascend NPU SDK

# We compile the mobile deployment library when LITE_ON_TINY_PUBLISH=ON
# So the following third party dependencies are not needed.
if (NOT LITE_ON_TINY_PUBLISH)
# include the necessary thirdparty dependencies
include(external/gflags) # download, build, install gflags
# LITE_WITH_LIGHT_WEIGHT_FRAMEWORK=ON will disable glog
# TODO(sangoly): refine WITH_LITE and LITE_WITH_LIGHT_WEIGHT_FRAMEWORK
include(external/gtest) # download, build, install gtest
include(ccache) # set ccache for compilation
include(external/protobuf) # download, build, install protobuf
endif()

include(generic) # simplify cmake module
include(configure) # add paddle env configuration

return()
endif()
################################# End of mobile compile ##############################

################################# Server compile ##############################

if(LITE_WITH_XPU)
include(backends/xpu)
endif()

if(LITE_WITH_MLU)
include(mlu)
endif()

if(LITE_WITH_HUAWEI_ASCEND_NPU)
include(backends/huawei_ascend_npu)
endif()

include(coveralls)

include(external/mklml) # download mklml package
include(external/xbyak) # download xbyak package

include(external/libxsmm) # download, build, install libxsmm
include(external/gflags) # download, build, install gflags
include(external/glog) # download, build, install glog
include(external/gtest) # download, build, install gtest
include(external/protobuf) # download, build, install protobuf
include(external/openblas) # download, build, install openblas
include(external/mkldnn) # download, build, install mkldnn
include(external/eigen) # download eigen3
include(external/xxhash) # download install xxhash needed for x86 jit

include(cudnn)
include(configure) # add paddle env configuration

if(LITE_WITH_CUDA)
include(cuda)
endif()

if(LITE_WITH_BM)
include(bm)
endif()
include(generic) # simplify cmake module
include(ccache) # set ccache for compilation
include(util) # set unittest and link libs
include(version) # set PADDLE_VERSION
if(NOT APPLE)
include(flags)
endif()

set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
Loading

0 comments on commit 86a4e26

Please sign in to comment.