forked from mindspore-Ecosystem/mindspore
mindspore lite: add extendrt and opt cmake
This commit is contained in:
parent
8167c4dbe4
commit
e0ecc973ff
|
@ -4,6 +4,10 @@ if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
|||
set(libevent_LDFLAGS "-Wl,-z,now")
|
||||
endif()
|
||||
|
||||
if(NOT MINDSPORE_PROJECT_DIR)
|
||||
set(MINDSPORE_PROJECT_DIR ${CMAKE_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
if(ENABLE_GITEE)
|
||||
set(REQ_URL "https://gitee.com/mirrors/libevent/repository/archive/release-2.1.12-stable.tar.gz")
|
||||
set(MD5 "0d5a27436bf7ff8253420c8cf09f47ca")
|
||||
|
@ -20,7 +24,7 @@ mindspore_add_pkg(libevent
|
|||
LIBS event event_pthreads event_core event_openssl
|
||||
URL ${REQ_URL}
|
||||
MD5 ${MD5}
|
||||
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/libevent/libevent.patch001
|
||||
PATCHES ${MINDSPORE_PROJECT_DIR}/third_party/patch/libevent/libevent.patch001
|
||||
CMAKE_OPTION -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_TESTING=OFF -DOPENSSL_ROOT_DIR:PATH=${openssl_ROOT}
|
||||
-DEVENT__LIBRARY_TYPE:STRING=STATIC)
|
||||
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
set(onednn_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
|
||||
set(onednn_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
|
||||
|
||||
if(NOT MINDSPORE_PROJECT_DIR)
|
||||
set(MINDSPORE_PROJECT_DIR ${CMAKE_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
if(USE_MS_THREADPOOL_FOR_DNNL)
|
||||
set(USE_MS_THREADPOOL "-DDNNL_CPU_RUNTIME=THREADPOOL")
|
||||
else()
|
||||
|
@ -34,9 +39,9 @@ else()
|
|||
LIBS dnnl mkldnn
|
||||
URL ${REQ_URL}
|
||||
MD5 ${MD5}
|
||||
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/onednn/0001-fix-user-threadpool-bug.patch
|
||||
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/onednn/0002-fix-pool-nthr-bug.patch
|
||||
PATCHES ${CMAKE_SOURCE_DIR}/third_party/patch/onednn/0003-fix-zero-threads-identified-on-AMD.patch
|
||||
PATCHES ${MINDSPORE_PROJECT_DIR}/third_party/patch/onednn/0001-fix-user-threadpool-bug.patch
|
||||
PATCHES ${MINDSPORE_PROJECT_DIR}/third_party/patch/onednn/0002-fix-pool-nthr-bug.patch
|
||||
PATCHES ${MINDSPORE_PROJECT_DIR}/third_party/patch/onednn/0003-fix-zero-threads-identified-on-AMD.patch
|
||||
CMAKE_OPTION -DDNNL_ARCH_OPT_FLAGS='' -DDNNL_BUILD_EXAMPLES=OFF -DDNNL_BUILD_TESTS=OFF
|
||||
${USE_MS_THREADPOOL} -DDNNL_ENABLE_CONCURRENT_EXEC=ON)
|
||||
endif()
|
||||
|
|
|
@ -528,6 +528,7 @@ else()
|
|||
endif()
|
||||
|
||||
string(REPLACE "/mindspore/lite" "" TOP_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(LITE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(CORE_DIR ${TOP_DIR}/mindspore/core)
|
||||
set(CCSRC_DIR ${TOP_DIR}/mindspore/ccsrc)
|
||||
set(NNACL_DIR ${CCSRC_DIR}/plugin/device/cpu/kernel/nnacl)
|
||||
|
@ -554,17 +555,20 @@ include(${TOP_DIR}/cmake/utils.cmake)
|
|||
include(${TOP_DIR}/cmake/dependency_utils.cmake)
|
||||
include(${TOP_DIR}/cmake/dependency_securec.cmake)
|
||||
if(NOT ENABLE_CLOUD_AND_LITE)
|
||||
include(${TOP_DIR}/cmake/external_libs/flatbuffers.cmake)
|
||||
# include(${TOP_DIR}/cmake/external_libs/flatbuffers.cmake)
|
||||
set(MSLITE_DEPS_FLATBUFFERS on)
|
||||
endif()
|
||||
|
||||
if(MSLITE_GPU_BACKEND STREQUAL opencl)
|
||||
include(${TOP_DIR}/cmake/external_libs/opencl.cmake)
|
||||
# include(${TOP_DIR}/cmake/external_libs/opencl.cmake)
|
||||
set(MSLITE_DEPS_OPENCL on)
|
||||
endif()
|
||||
|
||||
if(MSLITE_ENABLE_CONVERTER OR MSLITE_MINDDATA_IMPLEMENT STREQUAL "full" OR MSLITE_MINDDATA_IMPLEMENT STREQUAL "wrapper"
|
||||
OR MSLITE_ENABLE_TOOLS OR MSLITE_ENABLE_KERNEL_EXECUTOR)
|
||||
if(NOT ENABLE_CLOUD_AND_LITE)
|
||||
include(${TOP_DIR}/cmake/external_libs/json.cmake)
|
||||
# include(${TOP_DIR}/cmake/external_libs/json.cmake)
|
||||
set(MSLITE_DEPS_JSON on)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -572,11 +576,6 @@ if(DEFINED ARCHS)
|
|||
add_definitions(-DMS_COMPILE_IOS)
|
||||
endif()
|
||||
|
||||
file(GLOB FBS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/schema/*.fbs)
|
||||
ms_build_flatbuffers_lite(FBS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/schema/ fbs_src ${CMAKE_BINARY_DIR}/schema "")
|
||||
ms_build_flatbuffers_lite(FBS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/schema/ fbs_inner_src ${CMAKE_BINARY_DIR}/schema/inner
|
||||
"inner")
|
||||
|
||||
if(ENABLE_VERBOSE)
|
||||
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||
endif()
|
||||
|
@ -587,19 +586,6 @@ if(ENABLE_NEON)
|
|||
add_compile_definitions(ENABLE_NEON)
|
||||
endif()
|
||||
|
||||
if(MSLITE_GPU_BACKEND STREQUAL opencl)
|
||||
add_definitions(-DGPU_OPENCL)
|
||||
gene_opencl(${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/kernel/opencl/cl)
|
||||
gene_opencl(${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/kernel/opencl/cl/int8)
|
||||
add_definitions(-DUSE_OPENCL_WRAPPER)
|
||||
add_definitions(-DMS_OPENCL_PROFILE=false)
|
||||
add_definitions(-DCL_TARGET_OPENCL_VERSION=200)
|
||||
add_definitions(-DCL_HPP_TARGET_OPENCL_VERSION=120)
|
||||
add_definitions(-DCL_HPP_MINIMUM_OPENCL_VERSION=120)
|
||||
add_compile_definitions(SUPPORT_GPU)
|
||||
include_directories(${CMAKE_BINARY_DIR}/_deps/opencl-headers-src/)
|
||||
include_directories(${CMAKE_BINARY_DIR}/_deps/opencl-clhpp-src/include)
|
||||
endif()
|
||||
|
||||
if(MSLITE_GPU_BACKEND STREQUAL cuda)
|
||||
# add_definitions(-DGPU_CUDA)
|
||||
|
@ -654,7 +640,8 @@ if(ENABLE_MODEL_OBF)
|
|||
endif()
|
||||
|
||||
if((MSLITE_ENABLE_CONVERTER OR MSLITE_ENABLE_RUNTIME_GLOG) AND NOT ENABLE_CLOUD_AND_LITE)
|
||||
include(${TOP_DIR}/cmake/external_libs/glog.cmake)
|
||||
# include(${TOP_DIR}/cmake/external_libs/glog.cmake)
|
||||
set(MSLITE_DEPS_GLOG on)
|
||||
endif()
|
||||
|
||||
function(find_required_package pkg_name)
|
||||
|
@ -668,21 +655,58 @@ endfunction()
|
|||
if(MSLITE_ENABLE_CONVERTER OR MSLITE_ENABLE_KERNEL_EXECUTOR)
|
||||
find_required_package(Patch)
|
||||
if(NOT ENABLE_CLOUD_AND_LITE)
|
||||
include(${TOP_DIR}/cmake/external_libs/protobuf.cmake)
|
||||
# include(${TOP_DIR}/cmake/external_libs/protobuf.cmake)
|
||||
set(MSLITE_DEPS_PROTOBUF on)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MSLITE_ENABLE_CONVERTER)
|
||||
if(NOT ENABLE_CLOUD_AND_LITE)
|
||||
set(MSLITE_DEPS_OPENCV on)
|
||||
set(MSLITE_DEPS_EIGEN on)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MSLITE_ENABLE_CLOUD_FUSION_INFERENCE)
|
||||
if(NOT ENABLE_CLOUD_AND_LITE)
|
||||
set(MSLITE_DEPS_MKLDNN on)
|
||||
set(MSLITE_DEPS_LIBEVENT on)
|
||||
set(MSLITE_DEPS_PYBIND11 on)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(${LITE_DIR}/cmake/lite_dependences.cmake)
|
||||
|
||||
if(MSLITE_GPU_BACKEND STREQUAL opencl)
|
||||
add_definitions(-DGPU_OPENCL)
|
||||
gene_opencl(${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/kernel/opencl/cl)
|
||||
gene_opencl(${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/kernel/opencl/cl/int8)
|
||||
add_definitions(-DUSE_OPENCL_WRAPPER)
|
||||
add_definitions(-DMS_OPENCL_PROFILE=false)
|
||||
add_definitions(-DCL_TARGET_OPENCL_VERSION=200)
|
||||
add_definitions(-DCL_HPP_TARGET_OPENCL_VERSION=120)
|
||||
add_definitions(-DCL_HPP_MINIMUM_OPENCL_VERSION=120)
|
||||
add_compile_definitions(SUPPORT_GPU)
|
||||
include_directories(${CMAKE_BINARY_DIR}/_deps/opencl-headers-src/)
|
||||
include_directories(${CMAKE_BINARY_DIR}/_deps/opencl-clhpp-src/include)
|
||||
endif()
|
||||
|
||||
file(GLOB FBS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/schema/*.fbs)
|
||||
ms_build_flatbuffers_lite(FBS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/schema/ fbs_src ${CMAKE_BINARY_DIR}/schema "")
|
||||
ms_build_flatbuffers_lite(FBS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/schema/ fbs_inner_src ${CMAKE_BINARY_DIR}/schema/inner
|
||||
"inner")
|
||||
|
||||
if(MSLITE_ENABLE_CONVERTER)
|
||||
if(ENABLE_FAST_HASH_TABLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_FAST_HASH_TABLE=1")
|
||||
include_directories(${TOP_DIR}/third_party/robin_hood/include)
|
||||
endif()
|
||||
find_required_package(Patch)
|
||||
include_directories(${PYTHON_INCLUDE_DIRS})
|
||||
if(NOT ENABLE_CLOUD_AND_LITE)
|
||||
include(${TOP_DIR}/cmake/external_libs/opencv.cmake)
|
||||
include(${TOP_DIR}/cmake/external_libs/eigen.cmake)
|
||||
endif()
|
||||
# find_required_package(Patch)
|
||||
# include_directories(${PYTHON_INCLUDE_DIRS})
|
||||
# if(NOT ENABLE_CLOUD_AND_LITE)
|
||||
# include(${TOP_DIR}/cmake/external_libs/opencv.cmake)
|
||||
# include(${TOP_DIR}/cmake/external_libs/eigen.cmake)
|
||||
# endif()
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/converter)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
set(ENABLE_CPU on)
|
||||
add_definitions(-DUSE_GLOG)
|
||||
string(REPLACE "-fno-rtti" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
||||
string(REPLACE "-fno-rtti" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
set(MINDSPORE_PROJECT_DIR ${TOP_DIR})
|
||||
|
||||
set(SERVER_FLATBUFFER_OUTPUT "${CMAKE_BINARY_DIR}/schema")
|
||||
set(FBS_FILES
|
||||
${TOP_DIR}/mindspore/schema/cipher.fbs
|
||||
${TOP_DIR}/mindspore/schema/fl_job.fbs
|
||||
)
|
||||
ms_build_flatbuffers(FBS_FILES ${CMAKE_CURRENT_SOURCE_DIR}../../schema generated_fbs_files ${SERVER_FLATBUFFER_OUTPUT})
|
||||
|
||||
file(GLOB_RECURSE COMM_PROTO_IN RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CCSRC_DIR}/ps/core/protos/*.proto")
|
||||
message(${COMM_PROTO_IN})
|
||||
ms_protobuf_generate(COMM_PROTO_SRCS COMM_PROTO_HDRS ${COMM_PROTO_IN})
|
||||
list(APPEND MINDSPORE_PROTO_LIST ${COMM_PROTO_SRCS})
|
||||
|
||||
include(${TOP_DIR}/cmake/external_libs/eigen.cmake)
|
||||
include(${TOP_DIR}/cmake/external_libs/mkl_dnn.cmake)
|
||||
|
||||
find_package(Python3 COMPONENTS Interpreter Development)
|
||||
if(Python3_FOUND)
|
||||
find_package(Python3 COMPONENTS NumPy Development)
|
||||
|
||||
if(Python3_NumPy_FOUND)
|
||||
include_directories(${Python3_INCLUDE_DIRS})
|
||||
include_directories(${Python3_NumPy_INCLUDE_DIRS})
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../core/)
|
||||
include(${TOP_DIR}/cmake/external_libs/pybind11.cmake)
|
||||
endif()
|
||||
endif()
|
||||
include(${TOP_DIR}/cmake/external_libs/libevent.cmake)
|
||||
|
||||
# add_subdirectory(${CCSRC_DIR}/plugin/device/cpu/kernel mindspore_ccsrc_plugin_device_cpu_kernel)
|
||||
add_subdirectory(${CCSRC_DIR}/backend/common/session mindspore_ccsrc_backend_common_session)
|
|
@ -0,0 +1,53 @@
|
|||
set(MINDSPORE_PROJECT_DIR ${TOP_DIR})
|
||||
|
||||
find_required_package(Patch)
|
||||
|
||||
if(MSLITE_DEPS_FLATBUFFERS)
|
||||
include(${TOP_DIR}/cmake/external_libs/flatbuffers.cmake)
|
||||
endif()
|
||||
|
||||
if(MSLITE_DEPS_OPENCL)
|
||||
include(${TOP_DIR}/cmake/external_libs/opencl.cmake)
|
||||
endif()
|
||||
|
||||
if(MSLITE_DEPS_JSON)
|
||||
include(${TOP_DIR}/cmake/external_libs/json.cmake)
|
||||
endif()
|
||||
|
||||
if(MSLITE_DEPS_GLOG)
|
||||
include(${TOP_DIR}/cmake/external_libs/glog.cmake)
|
||||
endif()
|
||||
|
||||
if(MSLITE_DEPS_PROTOBUF)
|
||||
include(${TOP_DIR}/cmake/external_libs/protobuf.cmake)
|
||||
endif()
|
||||
|
||||
if(MSLITE_DEPS_EIGEN)
|
||||
include(${TOP_DIR}/cmake/external_libs/eigen.cmake)
|
||||
endif()
|
||||
|
||||
if(MSLITE_DEPS_OPENCV)
|
||||
include(${TOP_DIR}/cmake/external_libs/opencv.cmake)
|
||||
endif()
|
||||
|
||||
if(MSLITE_DEPS_MKLDNN)
|
||||
include(${TOP_DIR}/cmake/external_libs/mkl_dnn.cmake)
|
||||
endif()
|
||||
|
||||
if(MSLITE_DEPS_LIBEVENT)
|
||||
include(${TOP_DIR}/cmake/external_libs/libevent.cmake)
|
||||
endif()
|
||||
|
||||
if(MSLITE_DEPS_PYBIND11)
|
||||
find_package(Python3 COMPONENTS Interpreter Development)
|
||||
if(Python3_FOUND)
|
||||
find_package(Python3 COMPONENTS NumPy Development)
|
||||
if(Python3_NumPy_FOUND)
|
||||
include_directories(${Python3_INCLUDE_DIRS})
|
||||
include_directories(${Python3_NumPy_INCLUDE_DIRS})
|
||||
include_directories(${TOP_DIR})
|
||||
include_directories(${CORE_DIR})
|
||||
include(${TOP_DIR}/cmake/external_libs/pybind11.cmake)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
|
@ -17,8 +17,10 @@ if(Python3_FOUND)
|
|||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../core/)
|
||||
|
||||
if(NOT ENABLE_CLOUD_AND_LITE)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/utils.cmake)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/external_libs/pybind11.cmake)
|
||||
if(NOT MSLITE_ENABLE_CLOUD_FUSION_INFERENCE)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/utils.cmake)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/external_libs/pybind11.cmake)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file(GLOB_RECURSE PY_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cc")
|
||||
|
|
|
@ -146,13 +146,14 @@ set(MODEL_LOADER_FRAMEWORK_SRC
|
|||
)
|
||||
|
||||
if(MSLITE_ENABLE_CLOUD_FUSION_INFERENCE)
|
||||
add_compile_definitions(ENABLE_CLOUD_FUSION_INFERENCE)
|
||||
remove_definitions(-DBUILD_LITE_INFERENCE)
|
||||
# add_compile_definitions(ENABLE_CLOUD_FUSION_INFERENCE)
|
||||
# remove_definitions(-DBUILD_LITE_INFERENCE)
|
||||
|
||||
# string(REPLACE "-Werror" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
||||
# string(REPLACE "-Werror" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=return-type")
|
||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=return-type")
|
||||
# # include(${LITE_DIR}/cmake/ccsrc_module.cmake)
|
||||
# # string(REPLACE "-Werror" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
||||
# # string(REPLACE "-Werror" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
# # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=return-type")
|
||||
# # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=return-type")
|
||||
|
||||
set(MINDIR_MODEL_SRC
|
||||
${MINDIR_MODEL_SRC}
|
||||
|
@ -167,17 +168,25 @@ set(MINDIR_KERNEL_SRC
|
|||
${MINDIR_KERNEL_SRC}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extendrt/mindir_loader/mindir_model/inner_kernel.cc)
|
||||
|
||||
set(LITE_SRC
|
||||
${LITE_SRC}
|
||||
# set(LITE_SRC
|
||||
# ${LITE_SRC}
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/extendrt/mindir_loader/mindir_model/less_test_kernel_mod.cc
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/extendrt/mindir_loader/mindir_model/kernel_mod_mock.cc)
|
||||
|
||||
set(MSLITE_EXTEND_RUNTIME_SRC ${MSLITE_EXTEND_RUNTIME_SRC}
|
||||
${MINDIR_MODEL_SRC}
|
||||
${MINDIR_KERNEL_SRC}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extendrt/mindir_loader/mindir_model/less_test_kernel_mod.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extendrt/mindir_loader/mindir_model/kernel_mod_mock.cc)
|
||||
|
||||
add_subdirectory(extendrt)
|
||||
endif()
|
||||
|
||||
set(LITE_SRC
|
||||
${LITE_SRC}
|
||||
${MODEL_LOADER_FRAMEWORK_SRC}
|
||||
${MINDIR_MODEL_SRC}
|
||||
${MINDIR_KERNEL_SRC}
|
||||
# ${MINDIR_MODEL_SRC}
|
||||
# ${MINDIR_KERNEL_SRC}
|
||||
)
|
||||
|
||||
if(MSLITE_ENABLE_MODEL_ENCRYPTION)
|
||||
|
@ -410,7 +419,7 @@ add_subdirectory(runtime/kernel/cpu)
|
|||
add_library(lite_src_mid OBJECT ${LITE_SRC})
|
||||
add_dependencies(lite_src_mid fbs_src)
|
||||
|
||||
if(MSLITE_ENABLE_ACL)
|
||||
if(MSLITE_ENABLE_ACL AND NOT MSLITE_ENABLE_CLOUD_FUSION_INFERENCE)
|
||||
include_directories(${TOP_DIR}/graphengine/inc/external)
|
||||
add_subdirectory(extendrt/kernel/ascend)
|
||||
link_directories(${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH} ${ASCEND_CANN_RUNTIME_PATH})
|
||||
|
@ -472,21 +481,25 @@ if(MSLITE_ENABLE_MINDRT)
|
|||
endif()
|
||||
|
||||
if(SUPPORT_TENSORRT)
|
||||
add_compile_definitions(GPU_TENSORRT)
|
||||
set(TENSORRT_PATH $ENV{TENSORRT_PATH})
|
||||
set(CUDA_PATH $ENV{CUDA_HOME})
|
||||
set(TENSORRT_LIB_PATH ${TENSORRT_PATH}/lib)
|
||||
set(CUDA_LIB_PATH ${CUDA_PATH}/lib64)
|
||||
include_directories(${TENSORRT_PATH}/include)
|
||||
include_directories(${CUDA_PATH}/include)
|
||||
add_subdirectory(extendrt/delegate/tensorrt)
|
||||
if(NOT MSLITE_ENABLE_CLOUD_FUSION_INFERENCE)
|
||||
add_compile_definitions(GPU_TENSORRT)
|
||||
set(TENSORRT_PATH $ENV{TENSORRT_PATH})
|
||||
set(CUDA_PATH $ENV{CUDA_HOME})
|
||||
set(TENSORRT_LIB_PATH ${TENSORRT_PATH}/lib)
|
||||
set(CUDA_LIB_PATH ${CUDA_PATH}/lib64)
|
||||
include_directories(${TENSORRT_PATH}/include)
|
||||
include_directories(${CUDA_PATH}/include)
|
||||
add_subdirectory(extendrt/delegate/tensorrt)
|
||||
endif()
|
||||
target_link_libraries(mindspore-lite tensorrt_kernel_mid cuda_kernel_mid gpu_distribution_collective)
|
||||
target_link_libraries(mindspore-lite_static tensorrt_kernel_mid cuda_kernel_mid gpu_distribution_collective)
|
||||
else()
|
||||
set(TENSORRT_STUB
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extendrt/delegate/tensorrt/distribution/distribution_base.cc
|
||||
)
|
||||
add_library(tensorrt_stub OBJECT ${TENSORRT_STUB})
|
||||
if(NOT MSLITE_ENABLE_CLOUD_FUSION_INFERENCE)
|
||||
set(TENSORRT_STUB
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/extendrt/delegate/tensorrt/distribution/distribution_base.cc
|
||||
)
|
||||
add_library(tensorrt_stub OBJECT ${TENSORRT_STUB})
|
||||
endif()
|
||||
target_link_libraries(mindspore-lite tensorrt_stub)
|
||||
target_link_libraries(mindspore-lite_static tensorrt_stub)
|
||||
endif()
|
||||
|
@ -576,7 +589,7 @@ if(MSLITE_ENABLE_RUNTIME_CONVERT)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
if(SUPPORT_CUDA)
|
||||
if(SUPPORT_CUDA AND NOT MSLITE_ENABLE_CLOUD_FUSION_INFERENCE)
|
||||
set(CUDA_PATH $ENV{CUDA_HOME})
|
||||
include_directories(${CCSRC_DIR}/plugin/device/gpu/kernel)
|
||||
set(ENABLE_GPU on)
|
||||
|
@ -585,7 +598,7 @@ if(SUPPORT_CUDA)
|
|||
include_directories(${CUDA_PATH})
|
||||
include_directories(${CUDA_PATH}/include)
|
||||
find_package(CUDA)
|
||||
add_subdirectory(runtime/kernel/cuda)
|
||||
add_subdirectory(extendrt/kernel/cuda)
|
||||
list(APPEND CUDA_NVCC_FLAGS -arch=sm_53 --expt-relaxed-constexpr)
|
||||
add_subdirectory(${CCSRC_DIR}/plugin/device/gpu/kernel/cuda_impl/cuda_ops cuda_ops)
|
||||
target_link_libraries(mindspore-lite cuda_lite_kernel_mid cuda_ops mindspore_core)
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
|
||||
set(ENABLE_CPU on)
|
||||
add_compile_definitions(USE_GLOG)
|
||||
string(REPLACE "-fno-rtti" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
||||
string(REPLACE "-fno-rtti" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
|
||||
add_compile_definitions(ENABLE_CLOUD_FUSION_INFERENCE)
|
||||
remove_definitions(-DBUILD_LITE_INFERENCE)
|
||||
|
||||
set(MSLITE_EXTEND_RUNTIME_SRC ${MSLITE_EXTEND_RUNTIME_SRC})
|
||||
|
||||
add_library(mindspore-extendrt SHARED ${MSLITE_EXTEND_RUNTIME_SRC})
|
||||
|
||||
add_subdirectory(${CCSRC_DIR}/backend/common/session mindspore_ccsrc)
|
||||
|
||||
if(MSLITE_ENABLE_ACL)
|
||||
include_directories(${TOP_DIR}/graphengine/inc/external)
|
||||
add_subdirectory(kernel/ascend)
|
||||
link_directories(${ASCEND_RUNTIME_PATH} ${ASCEND_TOOLKIT_RUNTIME_PATH} ${ASCEND_CANN_RUNTIME_PATH})
|
||||
endif()
|
||||
|
||||
if(SUPPORT_CUDA)
|
||||
set(CUDA_PATH $ENV{CUDA_HOME})
|
||||
include_directories(${CCSRC_DIR}/plugin/device/gpu/kernel)
|
||||
set(ENABLE_GPU on)
|
||||
add_definitions(-DENABLE_GPU)
|
||||
set(CUDA_VERSION 11.1)
|
||||
include_directories(${CUDA_PATH})
|
||||
include_directories(${CUDA_PATH}/include)
|
||||
find_package(CUDA)
|
||||
add_subdirectory(kernel/cuda)
|
||||
list(APPEND CUDA_NVCC_FLAGS -arch=sm_53 --expt-relaxed-constexpr)
|
||||
add_subdirectory(${CCSRC_DIR}/plugin/device/gpu/kernel/cuda_impl/cuda_ops cuda_ops)
|
||||
target_link_libraries(mindspore-extendrt cuda_lite_kernel_mid cuda_ops mindspore_core)
|
||||
endif()
|
||||
|
||||
if(SUPPORT_TENSORRT)
|
||||
add_compile_definitions(GPU_TENSORRT)
|
||||
set(TENSORRT_PATH $ENV{TENSORRT_PATH})
|
||||
set(CUDA_PATH $ENV{CUDA_HOME})
|
||||
set(TENSORRT_LIB_PATH ${TENSORRT_PATH}/lib)
|
||||
set(CUDA_LIB_PATH ${CUDA_PATH}/lib64)
|
||||
include_directories(${TENSORRT_PATH}/include)
|
||||
include_directories(${CUDA_PATH}/include)
|
||||
add_subdirectory(delegate/tensorrt)
|
||||
target_link_libraries(mindspore-extendrt tensorrt_kernel_mid cuda_kernel_mid gpu_distribution_collective)
|
||||
# target_link_libraries(mindspore-lite tensorrt_kernel_mid cuda_kernel_mid gpu_distribution_collective)
|
||||
# target_link_libraries(mindspore-lite_static tensorrt_kernel_mid cuda_kernel_mid gpu_distribution_collective)
|
||||
else()
|
||||
set(TENSORRT_STUB
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/delegate/tensorrt/distribution/distribution_base.cc
|
||||
)
|
||||
add_library(tensorrt_stub OBJECT ${TENSORRT_STUB})
|
||||
target_link_libraries(mindspore-extendrt tensorrt_stub)
|
||||
# target_link_libraries(mindspore-lite tensorrt_stub)
|
||||
# target_link_libraries(mindspore-lite_static tensorrt_stub)
|
||||
endif()
|
Loading…
Reference in New Issue