|
|
|
@ -8,6 +8,18 @@ endif ()
|
|
|
|
|
option(MS_VERSION_MAJOR "major version" 0)
|
|
|
|
|
option(MS_VERSION_MINOR "minor version" 7)
|
|
|
|
|
option(MS_VERSION_REVISION "revision version" 0)
|
|
|
|
|
option(CMAKE_BUILD_TYPE "build type" Release)
|
|
|
|
|
option(SUPPORT_TRAIN "if build for on-device train" off)
|
|
|
|
|
option(PLATFORM_ARM64 "if build device for arm64" off)
|
|
|
|
|
option(PLATFORM_ARM32 "if build device for arm32" off)
|
|
|
|
|
option(ENABLE_CONVERTER "if build converter" on)
|
|
|
|
|
option(ENABLE_FP16 "if build fp16 ops" off)
|
|
|
|
|
option(ENABLE_TOOLS "if build tools" on)
|
|
|
|
|
option(BUILD_TESTCASES "if build testcase" on)
|
|
|
|
|
option(SUPPORT_GPU "if support gpu" off)
|
|
|
|
|
option(OFFLINE_COMPILE "if offline compile OpenCL kernel" off)
|
|
|
|
|
option(BUILD_MINDDATA_EXAMPLE "" on)
|
|
|
|
|
option(ENABLE_VERBOSE "" off)
|
|
|
|
|
|
|
|
|
|
set(DIR_PREFIX mindspore-lite)
|
|
|
|
|
set(MS_VERSION ${MS_VERSION_MAJOR}.${MS_VERSION_MINOR}.${MS_VERSION_REVISION})
|
|
|
|
@ -15,6 +27,12 @@ set(MAIN_DIR ${DIR_PREFIX}-${MS_VERSION})
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMS_VERSION_MAJOR=${MS_VERSION_MAJOR} -DMS_VERSION_MINOR=${MS_VERSION_MINOR} -DMS_VERSION_REVISION=${MS_VERSION_REVISION}")
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMS_VERSION_MAJOR=${MS_VERSION_MAJOR} -DMS_VERSION_MINOR=${MS_VERSION_MINOR} -DMS_VERSION_REVISION=${MS_VERSION_REVISION}")
|
|
|
|
|
set(BUILD_MINDDATA "lite_cv" CACHE STRING "off, lite, lite_cv or full")
|
|
|
|
|
set(BUILD_LITE "on")
|
|
|
|
|
set(PLATFORM_ARM "off")
|
|
|
|
|
if (PLATFORM_ARM64 OR PLATFORM_ARM32)
|
|
|
|
|
set(PLATFORM_ARM "on")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if (SUPPORT_GPU)
|
|
|
|
|
set(PROCESS_UNIT gpu)
|
|
|
|
@ -22,6 +40,9 @@ else ()
|
|
|
|
|
set(PROCESS_UNIT cpu)
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
add_compile_definitions(NO_DLIB)
|
|
|
|
|
add_compile_options(-fPIC)
|
|
|
|
|
|
|
|
|
|
if (SUPPORT_TRAIN)
|
|
|
|
|
if (PLATFORM_ARM64)
|
|
|
|
|
set(COMPONENT_NAME runtime-arm64-${PROCESS_UNIT}-train)
|
|
|
|
@ -59,31 +80,20 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/kernel/arm)
|
|
|
|
|
include_directories(${TOP_DIR}/third_party)
|
|
|
|
|
include_directories(${TOP_DIR}/third_party/flatbuffers/include)
|
|
|
|
|
include_directories(${CMAKE_BINARY_DIR})
|
|
|
|
|
|
|
|
|
|
include(${TOP_DIR}/cmake/utils.cmake)
|
|
|
|
|
include(${TOP_DIR}/cmake/dependency_utils.cmake)
|
|
|
|
|
include(${TOP_DIR}/cmake/dependency_securec.cmake)
|
|
|
|
|
if (WIN32)
|
|
|
|
|
include(${TOP_DIR}/cmake/external_libs/protobuf.cmake)
|
|
|
|
|
include(${TOP_DIR}/cmake/external_libs/flatbuffers.cmake)
|
|
|
|
|
endif()
|
|
|
|
|
include(${TOP_DIR}/cmake/external_libs/flatbuffers.cmake)
|
|
|
|
|
|
|
|
|
|
set(FBS_FILES
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/schema/model.fbs
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/schema/ops.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")
|
|
|
|
|
|
|
|
|
|
option(CMAKE_BUILD_TYPE "build type" Release)
|
|
|
|
|
option(BUILD_DEVICE "if build device" on)
|
|
|
|
|
option(SUPPORT_TRAIN "if build for on-device train" off)
|
|
|
|
|
option(PLATFORM_ARM64 "if build device for arm64" off)
|
|
|
|
|
option(PLATFORM_ARM32 "if build device for arm32" off)
|
|
|
|
|
option(ENABLE_CONVERTER "if build converter" on)
|
|
|
|
|
option(ENABLE_TOOLS "if build tools" on)
|
|
|
|
|
option(BUILD_TESTCASES "if build testcase" on)
|
|
|
|
|
option(ENABLE_FP16 "if build fp16 ops" off)
|
|
|
|
|
option(SUPPORT_GPU "if support gpu" off)
|
|
|
|
|
option(OFFLINE_COMPILE "if offline compile OpenCL kernel" off)
|
|
|
|
|
set(BUILD_MINDDATA "lite_cv" CACHE STRING "off, lite, lite_cv or full")
|
|
|
|
|
option(BUILD_MINDDATA_EXAMPLE "" on)
|
|
|
|
|
option(ENABLE_VERBOSE "" off)
|
|
|
|
|
add_compile_definitions(NO_DLIB)
|
|
|
|
|
add_compile_options(-fPIC)
|
|
|
|
|
string(REPLACE "-g" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
|
|
|
|
string(REPLACE "-g" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
|
|
|
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
|
|
|
@ -103,9 +113,6 @@ endif ()
|
|
|
|
|
if (ENABLE_VERBOSE)
|
|
|
|
|
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
|
|
|
endif ()
|
|
|
|
|
if (BUILD_DEVICE)
|
|
|
|
|
add_compile_definitions(BUILD_DEVICE)
|
|
|
|
|
endif ()
|
|
|
|
|
if (SUPPORT_TRAIN)
|
|
|
|
|
add_compile_definitions(SUPPORT_TRAIN)
|
|
|
|
|
endif()
|
|
|
|
@ -133,7 +140,7 @@ if (WIN32)
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
if (ENABLE_CONVERTER)
|
|
|
|
|
if (PLATFORM_ARM64 OR PLATFORM_ARM32)
|
|
|
|
|
if (PLATFORM_ARM)
|
|
|
|
|
MESSAGE(FATAL_ERROR "Cannot build converter in arm platform")
|
|
|
|
|
endif()
|
|
|
|
|
find_package(Python3 3.7 COMPONENTS Interpreter Development)
|
|
|
|
@ -161,27 +168,24 @@ if (ENABLE_CONVERTER)
|
|
|
|
|
include(${TOP_DIR}/cmake/external_libs/json.cmake)
|
|
|
|
|
include(${TOP_DIR}/cmake/external_libs/pybind11.cmake)
|
|
|
|
|
include(${TOP_DIR}/cmake/external_libs/eigen.cmake)
|
|
|
|
|
include_directories(${TOP_DIR}/third_party/protobuf/build/include)
|
|
|
|
|
link_directories(${TOP_DIR}/third_party/protobuf/build/lib)
|
|
|
|
|
include(${TOP_DIR}/cmake/external_libs/protobuf.cmake)
|
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/converter)
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
if (BUILD_DEVICE)
|
|
|
|
|
if (PLATFORM_ARM32 OR PLATFORM_ARM64)
|
|
|
|
|
if (NOT DEFINED ENV{ANDROID_NDK})
|
|
|
|
|
message(FATAL_ERROR "env ANDROID_NDK should be setted for ARM compile")
|
|
|
|
|
endif ()
|
|
|
|
|
add_compile_definitions(ENABLE_ARM)
|
|
|
|
|
if (PLATFORM_ARM32 OR PLATFORM_ARM64)
|
|
|
|
|
if (NOT DEFINED ENV{ANDROID_NDK})
|
|
|
|
|
message(FATAL_ERROR "env ANDROID_NDK should be setted for ARM compile")
|
|
|
|
|
endif ()
|
|
|
|
|
if (PLATFORM_ARM32)
|
|
|
|
|
add_definitions(-mfloat-abi=softfp -mfpu=neon)
|
|
|
|
|
add_compile_definitions(ENABLE_ARM32)
|
|
|
|
|
endif ()
|
|
|
|
|
if (PLATFORM_ARM64)
|
|
|
|
|
add_compile_definitions(ENABLE_ARM64)
|
|
|
|
|
if (ENABLE_FP16)
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv8.2-a+dotprod+fp16")
|
|
|
|
|
endif ()
|
|
|
|
|
add_compile_definitions(ENABLE_ARM)
|
|
|
|
|
endif ()
|
|
|
|
|
if (PLATFORM_ARM32)
|
|
|
|
|
add_definitions(-mfloat-abi=softfp -mfpu=neon)
|
|
|
|
|
add_compile_definitions(ENABLE_ARM32)
|
|
|
|
|
endif ()
|
|
|
|
|
if (PLATFORM_ARM64)
|
|
|
|
|
add_compile_definitions(ENABLE_ARM64)
|
|
|
|
|
if (ENABLE_FP16)
|
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv8.2-a+dotprod+fp16")
|
|
|
|
|
endif ()
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
@ -218,20 +222,17 @@ if (BUILD_MINDDATA STREQUAL "lite_cv")
|
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/minddata)
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
if (BUILD_DEVICE)
|
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src)
|
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/internal)
|
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/nnacl)
|
|
|
|
|
if (NOT WIN32)
|
|
|
|
|
if (ENABLE_TOOLS)
|
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/benchmark)
|
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/time_profiler)
|
|
|
|
|
endif()
|
|
|
|
|
if (BUILD_TESTCASES)
|
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test)
|
|
|
|
|
endif()
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src)
|
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/internal)
|
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/nnacl)
|
|
|
|
|
if (NOT WIN32)
|
|
|
|
|
if (ENABLE_TOOLS)
|
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/benchmark)
|
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/time_profiler)
|
|
|
|
|
endif()
|
|
|
|
|
if (BUILD_TESTCASES)
|
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test)
|
|
|
|
|
endif()
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
|
include(${TOP_DIR}/cmake/package_lite.cmake)
|
|
|
|
|