diff --git a/mindspore/lite/CMakeLists.txt b/mindspore/lite/CMakeLists.txt index 21744aec2ea2bdf565456200297d1a002dc5569d..37decbb3e8b7a2b361cedd9475cb79783900646f 100644 --- a/mindspore/lite/CMakeLists.txt +++ b/mindspore/lite/CMakeLists.txt @@ -6,31 +6,21 @@ set(BUILD_LITE "on") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/secure_option.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/compile_link_option.cmake) -if(TOOLCHAIN_NAME STREQUAL "himix200") - set(TARGET_HIMIX200 on) - add_compile_definitions(SUPPORT_NNIE) -elseif(TOOLCHAIN_NAME STREQUAL "ohos-lite") - set(TARGET_OHOS_LITE on) - SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) -endif() - -if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3.0 AND NOT TARGET_HIMIX200) - message(FATAL_ERROR "GCC version ${CMAKE_CXX_COMPILER_VERSION} must not be less than 7.3.0") -endif() - #Options that can be configured through environment variables or manually set(MSLITE_GPU_BACKEND "" CACHE STRING "enable gpu backend, \ - only arm64 support opencl, only x86_64 support tensorrt, opencl/cuda/tensorrt/off") + opencl only support arm64 and x86_64 , tensorrt only support x86_64, opencl/cuda/tensorrt/off") +set(MSLITE_REGISTRY_DEVICE "off" CACHE STRING "Compile Mindspore Lite that supports specific devices, \ + currently supported devices: Hi3516D/Hi3519A/Hi3559A/SD3403") +set(MSLITE_MINDDATA_IMPLEMENT "lite_cv" CACHE STRING "off, lite_cv, cloud, or full") option(MSLITE_ENABLE_NPU "enable npu, only arm64 or arm32 support" off) option(MSLITE_ENABLE_TRAIN "enable train" on) option(MSLITE_ENABLE_SSE "enable SSE instruction set, only x86_64 support" off) option(MSLITE_ENABLE_AVX "enable AVX instruction set, only x86_64 support" off) +option(MSLITE_ENABLE_AVX512 "enable AVX512 instruction set, only x86_64 support" off) option(MSLITE_ENABLE_CONVERTER "enable converter, only x86_64 support" on) option(MSLITE_ENABLE_TOOLS "enable tools" on) option(MSLITE_ENABLE_TESTCASES "enable testcase" off) -option(MSLITE_ENABLE_NNIE "enable NNIE" off) option(MSLITE_ENABLE_RUNTIME_PASS "enable runtime pass" on) -option(MSLITE_COMPILE_NNIE "compile NNIE" off) option(MSLITE_ENABLE_HIGH_PERFORMANCE "enable high performance" off) option(MSLITE_ENABLE_STRING_KERNEL "enable string kernel" on) option(MSLITE_ENABLE_CONTROLFLOW "enable control and tensorlist" on) @@ -41,17 +31,29 @@ option(MSLITE_ENABLE_MINDRT "enable mindrt use" on) option(MSLITE_ENABLE_DELEGATE "enable delegate use" on) option(MSLITE_ENABLE_V0 "support v0 schema" on) option(MSLITE_ENABLE_FP16 "Whether to compile Fp16 operator" off) +option(MSLITE_ENABLE_INT8 "Whether to compile Int8 operator" on) option(MSLITE_ENABLE_ACL "enable ACL" off) option(MSLITE_ENABLE_MODEL_ENCRYPTION "enable model encryption, only converter support" on) +option(MSLITE_ENABLE_SPARSE_COMPUTE "enable sparse kernel" off) +option(MSLITE_ENABLE_RUNTIME_CONVERT "enable runtime convert" off) +option(MSLITE_ENABLE_RUNTIME_GLOG "enable runtime glog" off) +option(MSLITE_ENABLE_COVERAGE "enable code coverage" off) +option(MSLITE_ENABLE_SHARING_MEM_WITH_OPENGL "enable sharing memory with OpenGL" off) #Option that can be configured through manually option(ENABLE_VERBOSE "" off) option(ENABLE_MODEL_OBF "if support model obfuscation" off) -set(BUILD_MINDDATA "lite_cv" CACHE STRING "off, lite, lite_cv, wrapper or full") +if(MACHINE_LINUX_ARM64) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8.2-a+fp16") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv8.2-a+fp16") +endif() if(DEFINED ENV{MSLITE_GPU_BACKEND}) set(MSLITE_GPU_BACKEND $ENV{MSLITE_GPU_BACKEND}) endif() +if(DEFINED ENV{MSLITE_REGISTRY_DEVICE}) + set(MSLITE_REGISTRY_DEVICE $ENV{MSLITE_REGISTRY_DEVICE}) +endif() if(DEFINED ENV{MSLITE_ENABLE_NPU}) set(MSLITE_ENABLE_NPU $ENV{MSLITE_ENABLE_NPU}) endif() @@ -64,6 +66,9 @@ endif() if(DEFINED ENV{MSLITE_ENABLE_AVX}) set(MSLITE_ENABLE_AVX $ENV{MSLITE_ENABLE_AVX}) endif() +if(DEFINED ENV{MSLITE_ENABLE_AVX512}) + set(MSLITE_ENABLE_AVX512 $ENV{MSLITE_ENABLE_AVX512}) +endif() if(DEFINED ENV{MSLITE_ENABLE_CONVERTER}) set(MSLITE_ENABLE_CONVERTER $ENV{MSLITE_ENABLE_CONVERTER}) endif() @@ -73,12 +78,6 @@ endif() if(DEFINED ENV{MSLITE_ENABLE_TESTCASES}) set(MSLITE_ENABLE_TESTCASES $ENV{MSLITE_ENABLE_TESTCASES}) endif() -if(DEFINED ENV{MSLITE_ENABLE_NNIE}) - set(MSLITE_ENABLE_NNIE $ENV{MSLITE_ENABLE_NNIE}) -endif() -if(DEFINED ENV{MSLITE_COMPILE_NNIE}) - set(MSLITE_COMPILE_NNIE $ENV{MSLITE_COMPILE_NNIE}) -endif() if(DEFINED ENV{MSLITE_ENABLE_RUNTIME_PASS}) set(MSLITE_ENABLE_RUNTIME_PASS $ENV{MSLITE_ENABLE_RUNTIME_PASS}) endif() @@ -112,15 +111,64 @@ endif() if(DEFINED ENV{MSLITE_ENABLE_FP16}) set(MSLITE_ENABLE_FP16 $ENV{MSLITE_ENABLE_FP16}) endif() +if(DEFINED ENV{MSLITE_ENABLE_INT8}) + set(MSLITE_ENABLE_INT8 $ENV{MSLITE_ENABLE_INT8}) +endif() +if(DEFINED ENV{MSLITE_ENABLE_SPARSE_COMPUTE}) + set(MSLITE_ENABLE_SPARSE_COMPUTE $ENV{MSLITE_ENABLE_SPARSE_COMPUTE}) +endif() if(DEFINED ENV{MSLITE_ENABLE_ACL}) set(MSLITE_ENABLE_ACL $ENV{MSLITE_ENABLE_ACL}) endif() +if(DEFINED ENV{MSLITE_MINDDATA_IMPLEMENT}) + set(MSLITE_MINDDATA_IMPLEMENT $ENV{MSLITE_MINDDATA_IMPLEMENT}) +endif() if(DEFINED ENV{MSLITE_ENABLE_MODEL_ENCRYPTION}) set(MSLITE_ENABLE_MODEL_ENCRYPTION $ENV{MSLITE_ENABLE_MODEL_ENCRYPTION}) endif() +if(DEFINED ENV{MSLITE_ENABLE_RUNTIME_CONVERT}) + set(MSLITE_ENABLE_RUNTIME_CONVERT $ENV{MSLITE_ENABLE_RUNTIME_CONVERT}) +endif() +if(DEFINED ENV{MSLITE_ENABLE_RUNTIME_GLOG}) + set(MSLITE_ENABLE_RUNTIME_GLOG $ENV{MSLITE_ENABLE_RUNTIME_GLOG}) +endif() + +if(DEFINED ENV{MSLITE_ENABLE_COVERAGE}) + set(MSLITE_ENABLE_COVERAGE $ENV{MSLITE_ENABLE_COVERAGE}) +endif() +if(DEFINED ENV{MSLITE_ENABLE_SHARING_MEM_WITH_OPENGL}) + set(MSLITE_ENABLE_SHARING_MEM_WITH_OPENGL $ENV{MSLITE_ENABLE_SHARING_MEM_WITH_OPENGL}) +endif() + +if(MACHINE_LINUX_ARM64) + add_compile_definitions(MACHINE_LINUX_ARM64) +endif() +if(TOOLCHAIN_NAME STREQUAL "himix200") + set(TARGET_HIMIX on) + set(TARGET_HIMIX200 on) + add_compile_definitions(SUPPORT_NNIE) +elseif(TOOLCHAIN_NAME STREQUAL "himix100") + set(TARGET_HIMIX on) + set(TARGET_HIMIX100 on) + add_compile_definitions(SUPPORT_NNIE) +elseif(TOOLCHAIN_NAME STREQUAL "mix210") + set(TARGET_MIX210 on) + add_compile_definitions(SUPPORT_34XX) +elseif(TOOLCHAIN_NAME STREQUAL "ohos-lite") + set(TARGET_OHOS_LITE on) + SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) +endif() + +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3.0 + AND NOT TARGET_HIMIX AND NOT TARGET_MIX210) + message(FATAL_ERROR "GCC version ${CMAKE_CXX_COMPILER_VERSION} must not be less than 7.3.0") +endif() + if(NOT MSLITE_ENABLE_ACL) set(ENABLE_GLIBCXX ON) +else() + set(MSLITE_ENABLE_TRAIN off) endif() if(PLATFORM_ARM64) @@ -140,10 +188,14 @@ elseif(PLATFORM_ARM32) elseif(WIN32) set(MSLITE_GPU_BACKEND "off") else() + if(${MSLITE_REGISTRY_DEVICE} STREQUAL "SD3403") + set(MSLITE_ENABLE_DPICO_ATC_ADAPTER on) + endif() if(MSLITE_GPU_BACKEND STREQUAL "") set(MSLITE_GPU_BACKEND "off") endif() - if((NOT MSLITE_GPU_BACKEND STREQUAL "tensorrt") AND (NOT MSLITE_GPU_BACKEND STREQUAL "off")) + if((NOT MSLITE_GPU_BACKEND STREQUAL "tensorrt") AND (NOT MSLITE_GPU_BACKEND STREQUAL "off") AND + (NOT MSLITE_GPU_BACKEND STREQUAL "opencl")) message("invalid MSLITE_GPU_BACKEND value ${MSLITE_GPU_BACKEND} for x86_64, MSLITE_GPU_BACKEND is set to off.") set(MSLITE_GPU_BACKEND "off") endif() @@ -153,7 +205,10 @@ if(PLATFORM_ARM64 OR PLATFORM_ARM32) set(PLATFORM_ARM "on") set(MSLITE_ENABLE_SSE off) set(MSLITE_ENABLE_AVX off) + set(MSLITE_ENABLE_AVX512 off) set(MSLITE_ENABLE_CONVERTER off) + set(MSLITE_ENABLE_RUNTIME_GLOG off) + set(MSLITE_ENABLE_RUNTIME_CONVERT off) #set for cross - compiling toolchain set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) @@ -162,9 +217,30 @@ else() set(MSLITE_ENABLE_NPU off) endif() +if(MSLITE_ENABLE_SSE OR MSLITE_ENABLE_AVX OR MSLITE_ENABLE_AVX512 OR WIN32) + set(MSLITE_ENABLE_RUNTIME_CONVERT off) +endif() + +if(MSLITE_ENABLE_TRAIN AND NOT MSLITE_ENABLE_WEIGHT_DECODE) + message(FATAL_ERROR "If MSLITE_ENABLE_WEIGHT_DECODE use if configured as off, " + "MSLITE_ENABLE_TRAIN must also be configured as off") +endif() + +if(MSLITE_ENABLE_CONTROLFLOW AND NOT MSLITE_ENABLE_MINDRT) + message(FATAL_ERROR "If MSLITE_ENABLE_MINDRT use if configured as off, " + "MSLITE_ENABLE_CONTROLFLOW must also be configured as off") +endif() + +if(MSLITE_ENABLE_RUNTIME_CONVERT) + set(MSLITE_ENABLE_RUNTIME_GLOG on) + set(MSLITE_ENABLE_CONVERTER on) +endif() + if(MSLITE_ENABLE_TRAIN) set(SUPPORT_TRAIN on) - set(BUILD_MINDDATA full) + if(NOT MSLITE_MINDDATA_IMPLEMENT STREQUAL "off" OR NOT PLATFORM_ARM) + set(MSLITE_MINDDATA_IMPLEMENT full) + endif() endif() if(MSLITE_ENABLE_NPU) @@ -179,7 +255,7 @@ if(MSLITE_ENABLE_NPU) endif() endif() -if(TARGET_HIMIX200 OR TARGET_OHOS_LITE) +if(TARGET_HIMIX OR TARGET_OHOS_LITE) set(MSLITE_ENABLE_MINDRT off) endif() @@ -187,6 +263,38 @@ if(MSVC) set(MSLITE_ENABLE_CONVERTER off) endif() +message(STATUS "************MindSpore Lite Build Option:************") +message(STATUS "\tMSLITE_GPU_BACKEND = \t${MSLITE_GPU_BACKEND}") +message(STATUS "\tMSLITE_REGISTRY_DEVICE = \t${MSLITE_REGISTRY_DEVICE}") +message(STATUS "\tMSLITE_ENABLE_NPU = \t${MSLITE_ENABLE_NPU}") +message(STATUS "\tMSLITE_ENABLE_TRAIN = \t${MSLITE_ENABLE_TRAIN}") +message(STATUS "\tMSLITE_ENABLE_SSE = \t${MSLITE_ENABLE_SSE}") +message(STATUS "\tMSLITE_ENABLE_AVX = \t${MSLITE_ENABLE_AVX}") +message(STATUS "\tMSLITE_ENABLE_AVX512 = \t${MSLITE_ENABLE_AVX512}") +message(STATUS "\tMSLITE_ENABLE_CONVERTER = \t${MSLITE_ENABLE_CONVERTER}") +message(STATUS "\tMSLITE_ENABLE_TOOLS = \t${MSLITE_ENABLE_TOOLS}") +message(STATUS "\tMSLITE_ENABLE_TESTCASES = \t${MSLITE_ENABLE_TESTCASES}") +message(STATUS "\tMSLITE_ENABLE_HIGH_PERFORMANCE = \t${MSLITE_ENABLE_HIGH_PERFORMANCE}") +message(STATUS "\tMSLITE_ENABLE_RUNTIME_PASS = \t${MSLITE_ENABLE_RUNTIME_PASS}") +message(STATUS "\tMSLITE_ENABLE_STRING_KERNEL = \t${MSLITE_ENABLE_STRING_KERNEL}") +message(STATUS "\tMSLITE_ENABLE_CONTROLFLOW = \t${MSLITE_ENABLE_CONTROLFLOW}") +message(STATUS "\tMSLITE_ENABLE_AUTO_PARALLEL = \t${MSLITE_ENABLE_AUTO_PARALLEL}") +message(STATUS "\tMSLITE_ENABLE_WEIGHT_DECODE = \t${MSLITE_ENABLE_WEIGHT_DECODE}") +message(STATUS "\tMSLITE_ENABLE_CUSTOM_KERNEL = \t${MSLITE_ENABLE_CUSTOM_KERNEL}") +message(STATUS "\tMSLITE_ENABLE_MINDRT = \t${MSLITE_ENABLE_MINDRT}") +message(STATUS "\tMSLITE_ENABLE_V0 = \t${MSLITE_ENABLE_V0}") +message(STATUS "\tMSLITE_MINDDATA_IMPLEMENT = \t${MSLITE_MINDDATA_IMPLEMENT}") +message(STATUS "\tMSLITE_ENABLE_DELEGATE = \t${MSLITE_ENABLE_DELEGATE}") +message(STATUS "\tMSLITE_ENABLE_ACL = \t${MSLITE_ENABLE_ACL}") +message(STATUS "\tMSLITE_ENABLE_FP16 = \t${MSLITE_ENABLE_FP16}") +message(STATUS "\tMSLITE_ENABLE_INT8 = \t${MSLITE_ENABLE_INT8}") +message(STATUS "\tMSLITE_ENABLE_MODEL_ENCRYPTION = \t${MSLITE_ENABLE_MODEL_ENCRYPTION}") +message(STATUS "\tMSLITE_ENABLE_SPARSE_COMPUTE = \t${MSLITE_ENABLE_SPARSE_COMPUTE}") +message(STATUS "\tMSLITE_ENABLE_RUNTIME_CONVERT = \t${MSLITE_ENABLE_RUNTIME_CONVERT}") +message(STATUS "\tMSLITE_ENABLE_RUNTIME_GLOG = \t${MSLITE_ENABLE_RUNTIME_GLOG}") +message(STATUS "\tMSLITE_ENABLE_COVERAGE = \t${MSLITE_ENABLE_COVERAGE}") +message(STATUS "\tMSLITE_ENABLE_SHARING_MEM_WITH_OPENGL = \t${MSLITE_ENABLE_SHARING_MEM_WITH_OPENGL}") + if((MSLITE_ENABLE_CONVERTER OR MSLITE_ENABLE_TESTCASES) AND ( NOT MSLITE_ENABLE_MINDRT OR NOT MSLITE_ENABLE_STRING_KERNEL @@ -211,29 +319,6 @@ if(MSLITE_ENABLE_FP16 AND PLATFORM_ARM32 AND CMAKE_CXX_COMPILER_ID STREQUAL "Cla set(MSLITE_ENABLE_FP16 off) endif() -message(STATUS "************MindSpore Lite Build Option:************") -message(STATUS "\tMSLITE_GPU_BACKEND = \t${MSLITE_GPU_BACKEND}") -message(STATUS "\tMSLITE_ENABLE_NPU = \t${MSLITE_ENABLE_NPU}") -message(STATUS "\tMSLITE_ENABLE_TRAIN = \t${MSLITE_ENABLE_TRAIN}") -message(STATUS "\tMSLITE_ENABLE_SSE = \t${MSLITE_ENABLE_SSE}") -message(STATUS "\tMSLITE_ENABLE_AVX = \t${MSLITE_ENABLE_AVX}") -message(STATUS "\tMSLITE_ENABLE_CONVERTER = \t${MSLITE_ENABLE_CONVERTER}") -message(STATUS "\tMSLITE_ENABLE_TOOLS = \t${MSLITE_ENABLE_TOOLS}") -message(STATUS "\tMSLITE_ENABLE_TESTCASES = \t${MSLITE_ENABLE_TESTCASES}") -message(STATUS "\tMSLITE_ENABLE_HIGH_PERFORMANCE = \t${MSLITE_ENABLE_HIGH_PERFORMANCE}") -message(STATUS "\tMSLITE_ENABLE_RUNTIME_PASS = \t${MSLITE_ENABLE_RUNTIME_PASS}") -message(STATUS "\tMSLITE_ENABLE_STRING_KERNEL = \t${MSLITE_ENABLE_STRING_KERNEL}") -message(STATUS "\tMSLITE_ENABLE_CONTROLFLOW = \t${MSLITE_ENABLE_CONTROLFLOW}") -message(STATUS "\tMSLITE_ENABLE_AUTO_PARALLEL = \t${MSLITE_ENABLE_AUTO_PARALLEL}") -message(STATUS "\tMSLITE_ENABLE_WEIGHT_DECODE = \t${MSLITE_ENABLE_WEIGHT_DECODE}") -message(STATUS "\tMSLITE_ENABLE_CUSTOM_KERNEL = \t${MSLITE_ENABLE_CUSTOM_KERNEL}") -message(STATUS "\tMSLITE_ENABLE_MINDRT = \t${MSLITE_ENABLE_MINDRT}") -message(STATUS "\tMSLITE_ENABLE_V0 = \t${MSLITE_ENABLE_V0}") -message(STATUS "\tBUILD_MINDDATA = \t${BUILD_MINDDATA}") -message(STATUS "\tMSLITE_ENABLE_DELEGATE = \t${MSLITE_ENABLE_DELEGATE}") -message(STATUS "\tMSLITE_ENABLE_FP16 = \t${MSLITE_ENABLE_FP16}") -message(STATUS "\tMSLITE_ENABLE_MODEL_ENCRYPTION = \t${MSLITE_ENABLE_MODEL_ENCRYPTION}") - if(MSLITE_ENABLE_HIGH_PERFORMANCE) add_compile_definitions(ENABLE_HIGH_PERFORMANCE) endif() @@ -246,9 +331,16 @@ if(ENABLE_ASAN) add_link_options(-fsanitize=address) endif() +if(MSLITE_ENABLE_COVERAGE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g --coverage -fprofile-arcs -ftest-coverage") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g --coverage -fprofile-arcs -ftest-coverage") +endif() + if(MSLITE_ENABLE_ACL) - add_definitions(-D ENABLE_LITE_ACL) + add_definitions(-D ENABLE_LITE_ASCEND) add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--allow-shlib-undefined") + if(DEFINED ENV{ASCEND_CUSTOM_PATH}) set(ASCEND_PATH $ENV{ASCEND_CUSTOM_PATH}) else() @@ -278,7 +370,11 @@ if(NOT MSVC) endif() if(PLATFORM_ARM64) - set(RUNTIME_COMPONENT_NAME "android-aarch64") + if(TARGET_HIMIX100 OR TARGET_MIX210 OR MACHINE_LINUX_ARM64) + set(RUNTIME_COMPONENT_NAME "linux-aarch64") + else() + set(RUNTIME_COMPONENT_NAME "android-aarch64") + endif() elseif(PLATFORM_ARM32) set(RUNTIME_COMPONENT_NAME "android-aarch32") if(TARGET_HIMIX200) @@ -296,10 +392,6 @@ else() set(RUNTIME_COMPONENT_NAME "linux-x64") endif() -if(MSLITE_COMPILE_NNIE AND (NOT PLATFORM_ARM)) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/converter/nnie) -endif() - string(REPLACE "/mindspore/lite" "" TOP_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(CORE_DIR ${TOP_DIR}/mindspore/core) set(CCSRC_DIR ${TOP_DIR}/mindspore/ccsrc) @@ -324,8 +416,8 @@ if(MSLITE_GPU_BACKEND STREQUAL opencl) include(${TOP_DIR}/cmake/external_libs/opencl.cmake) endif() -if(MSLITE_ENABLE_CONVERTER OR BUILD_MINDDATA STREQUAL "full" OR BUILD_MINDDATA STREQUAL "wrapper" OR - MSLITE_ENABLE_TOOLS) +if(MSLITE_ENABLE_CONVERTER OR MSLITE_MINDDATA_IMPLEMENT STREQUAL "full" OR MSLITE_MINDDATA_IMPLEMENT STREQUAL "wrapper" + OR MSLITE_ENABLE_TOOLS) include(${TOP_DIR}/cmake/external_libs/json.cmake) endif() @@ -365,6 +457,9 @@ if(MSLITE_GPU_BACKEND STREQUAL opencl) add_compile_definitions(SUPPORT_GPU) include_directories(${CMAKE_BINARY_DIR}/_deps/opencl-headers-src/) include_directories(${CMAKE_BINARY_DIR}/_deps/opencl-clhpp-src/include) + if(MSLITE_ENABLE_SHARING_MEM_WITH_OPENGL) + add_definitions(-DENABLE_OPENGL_TEXTURE) + endif() endif() if(MSLITE_GPU_BACKEND STREQUAL cuda) @@ -410,12 +505,15 @@ if(ENABLE_MODEL_OBF) set(OBF_LIBS libmsdeobfuscator-lite.so) endif() +if(MSLITE_ENABLE_CONVERTER OR MSLITE_ENABLE_RUNTIME_GLOG) + include(${TOP_DIR}/cmake/external_libs/glog.cmake) +endif() + if(MSLITE_ENABLE_CONVERTER) include(${TOP_DIR}/cmake/external_libs/opencv.cmake) include_directories(${PYTHON_INCLUDE_DIRS}) include(${TOP_DIR}/cmake/external_libs/eigen.cmake) include(${TOP_DIR}/cmake/external_libs/protobuf.cmake) - include(${TOP_DIR}/cmake/external_libs/glog.cmake) if(MSLITE_ENABLE_MODEL_ENCRYPTION) find_package(Patch) include(${TOP_DIR}/cmake/external_libs/openssl.cmake) @@ -438,7 +536,16 @@ if(PLATFORM_ARM64) endif() if(NOT PLATFORM_ARM) - if(MSLITE_ENABLE_AVX) + if(MSLITE_ENABLE_AVX512) + set(X86_64_SIMD "avx512") + add_compile_definitions(ENABLE_SSE) + add_compile_definitions(ENABLE_AVX) + add_compile_definitions(ENABLE_AVX512) + if(NOT MSVC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mavx -mfma -mavx512f") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx -mfma -mavx512f") + endif() + elseif(MSLITE_ENABLE_AVX) set(X86_64_SIMD "avx") add_compile_definitions(ENABLE_SSE) add_compile_definitions(ENABLE_AVX) @@ -456,7 +563,8 @@ if(NOT PLATFORM_ARM) endif() endif() -if(BUILD_MINDDATA STREQUAL "lite" OR BUILD_MINDDATA STREQUAL "full" OR BUILD_MINDDATA STREQUAL "wrapper") +if(MSLITE_MINDDATA_IMPLEMENT STREQUAL "lite" OR MSLITE_MINDDATA_IMPLEMENT STREQUAL "full" + OR MSLITE_MINDDATA_IMPLEMENT STREQUAL "wrapper") add_compile_definitions(ENABLE_ANDROID) if(NOT PLATFORM_ARM32 AND NOT PLATFORM_ARM64) add_compile_definitions(ENABLE_MD_LITE_X86_64) @@ -464,18 +572,21 @@ if(BUILD_MINDDATA STREQUAL "lite" OR BUILD_MINDDATA STREQUAL "full" OR BUILD_MIN add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/minddata) endif() -if(BUILD_MINDDATA STREQUAL "lite_cv") +if(MSLITE_MINDDATA_IMPLEMENT STREQUAL "lite_cv") add_compile_definitions(ENABLE_ANDROID) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/minddata) endif() +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/ops) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/micro/coder) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src) add_subdirectory(${CCSRC_DIR}/backend/kernel_compiler/cpu/nnacl build) -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/micro/coder) - if(MSLITE_ENABLE_TOOLS) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/benchmark) + if(NOT MSLITE_COMPILE_TWICE) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/benchmark) + endif() if(SUPPORT_TRAIN) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/benchmark_train) endif() diff --git a/mindspore/lite/test/CMakeLists.txt b/mindspore/lite/test/CMakeLists.txt index a67d81a356d4be9eb988b147409dc533a0dcb1e8..7fcd8a2e5f693359615a7d222b2eb0fb278bc6b6 100644 --- a/mindspore/lite/test/CMakeLists.txt +++ b/mindspore/lite/test/CMakeLists.txt @@ -12,6 +12,10 @@ if(MSLITE_ENABLE_V0) add_definitions(-DENABLE_V0) endif() +if(MSLITE_ENABLE_RUNTIME_CONVERT) + add_definitions(-DRUNTIME_CONVERT) +endif() + file(GLOB_RECURSE TEST_UT_SRC ${TEST_DIR}/main.cc ${TEST_DIR}/common/common_test.cc @@ -20,17 +24,24 @@ file(GLOB_RECURSE TEST_UT_SRC ${TEST_DIR}/ut/src/scheduler_test.cc ${TEST_DIR}/ut/src/registry/registry_test.cc ${TEST_DIR}/ut/src/registry/registry_custom_op_test.cc - ${TEST_DIR}/ut/src/runtime/runtime_pass_tests.cc ${TEST_DIR}/st/multiple_device_test.cc ${TEST_DIR}/st/mindrt_parallel_runtime_test.cc ${TEST_DIR}/st/mix_data_type_test.cc ${TEST_DIR}/ut/nnacl/infer/*.cc ${TEST_DIR}/ut/src/runtime/kernel/arm/common/*.cc ${TEST_DIR}/ut/src/runtime/kernel/arm/fp32/*.cc - ${TEST_DIR}/ut/src/runtime/kernel/arm/int8/*.cc ${TEST_DIR}/ut/src/runtime/kernel/arm/string/*.cc + ${TEST_DIR}/ut/src/api/*.cc ) +if(MSLITE_ENABLE_RUNTIME_CONVERT) + list(APPEND TEST_UT_SRC ${TEST_DIR}/ut/src/runtime/runtime_convert_tests.cc) +endif() + +if(MSLITE_ENABLE_RUNTIME_PASS) + list(APPEND TEST_UT_SRC ${TEST_DIR}/ut/src/runtime/runtime_pass_tests.cc) +endif() + if(MSLITE_ENABLE_TRAIN) file(GLOB_RECURSE TEST_TRAIN_UT_SRC ${TEST_DIR}/ut/src/runtime/kernel/arm/fp32_grad/*.cc @@ -39,12 +50,29 @@ if(MSLITE_ENABLE_TRAIN) list(APPEND TEST_UT_SRC ${TEST_TRAIN_UT_SRC}) endif() +if(MSLITE_ENABLE_SPARSE_COMPUTE) + file(GLOB_RECURSE SPARSE_KERNEL_UT + ${TEST_DIR}/ut/src/runtime/kernel/arm/fp32-sparsity/*.cc + ) + list(APPEND TEST_UT_SRC ${SPARSE_KERNEL_UT}) +endif() + if(MSLITE_GPU_BACKEND STREQUAL opencl) - file(GLOB_RECURSE TEST_GPU_UT_SRC - ${TEST_DIR}/ut/src/runtime/kernel/opencl/*.cc - ${TEST_DIR}/ut/src/registry/registry_gpu_custom_op_test.cc + if(PLATFORM_ARM) + file(GLOB_RECURSE TEST_GPU_UT_SRC + ${TEST_DIR}/ut/src/runtime/kernel/opencl/*.cc + ${TEST_DIR}/ut/src/registry/registry_gpu_custom_op_test.cc + ) + list(APPEND TEST_UT_SRC ${TEST_GPU_UT_SRC}) + endif() +endif() + +if(MSLITE_ENABLE_INT8) + file(GLOB_RECURSE TEST_INT8_UT_SRC + ${TEST_DIR}/ut/src/runtime/kernel/arm/int8/*.cc + ${TEST_DIR}/ut/nnacl/int8/*.cc ) - list(APPEND TEST_UT_SRC ${TEST_GPU_UT_SRC}) + list(APPEND TEST_UT_SRC ${TEST_INT8_UT_SRC}) endif() if(MSLITE_ENABLE_FP16) @@ -69,6 +97,7 @@ if(MSLITE_ENABLE_CONVERTER) ${LITE_DIR}/tools/benchmark/run_benchmark.cc ${LITE_DIR}/tools/benchmark/benchmark_base.cc ${LITE_DIR}/tools/benchmark/benchmark_unified_api.cc + ${LITE_DIR}/tools/benchmark/benchmark_c_api.cc ${LITE_DIR}/tools/benchmark/benchmark.cc ) endif() @@ -83,11 +112,7 @@ if(MSLITE_ENABLE_CONVERTER) ${TEST_DIR}/st/graph_test.cc ${TEST_DIR}/st/sub_graph_test.cc ${TEST_DIR}/ut/src/dynamic_library_loader_test.cc - ${TEST_DIR}/ut/tools/optimizer/fusion/conv_biasadd_fusion_test.cc - ${TEST_DIR}/ut/tools/optimizer/fusion/conv_bn_fusion_test.cc - ${TEST_DIR}/ut/tools/optimizer/fusion/conv_scale_fusion_test.cc - ${TEST_DIR}/ut/tools/optimizer/fusion/conv_activation_fusion_test.cc - ${TEST_DIR}/ut/tools/optimizer/fusion/constant_folding_fusion_test.cc + ${TEST_DIR}/ut/tools/optimizer/fusion/*.cc ) list(APPEND TEST_UT_SRC ${TEST_CONVERTER_UT_SRC}) @@ -97,6 +122,7 @@ if(MSLITE_ENABLE_CONVERTER) ${LITE_DIR}/src/ops/ops_utils.cc ${LITE_DIR}/src/ops/ops_def.cc ${LITE_DIR}/src/tensor.cc + ${LITE_DIR}/src/schema_tensor_wrapper.cc ) endif() @@ -110,8 +136,19 @@ add_dependencies(lite-test fbs_src fbs_inner_src) target_link_libraries(lite-test mindspore-lite dl mindspore::gtest) +# test file using gmock +target_link_libraries(lite-test mindspore::gmock) +add_library(gmock_tests OBJECT ${TEST_DIR}/st/optimize_allocator_test.cc) +add_dependencies(gmock_tests fbs_src fbs_inner_src) +target_compile_options(gmock_tests PRIVATE -fno-rtti) +target_link_libraries(lite-test gmock_tests) + if(MSLITE_ENABLE_TRAIN) - target_link_libraries(lite-test mindspore-lite-train minddata-lite) + if(MSLITE_MINDDATA_IMPLEMENT STREQUAL "off") + target_link_libraries(lite-test mindspore-lite-train) + else() + target_link_libraries(lite-test mindspore-lite-train minddata-lite) + endif() endif() if(PLATFORM_ARM) @@ -134,13 +171,14 @@ if(MSLITE_ENABLE_MINDRT) endif() if(MSLITE_ENABLE_CONVERTER) + target_link_libraries(lite-test tflite_parser_mid caffe_parser_mid + onnx_parser_mid tf_parser_mid) +endif() + +if(MSLITE_ENABLE_CONVERTER AND (NOT MSLITE_ENABLE_RUNTIME_CONVERT)) target_link_libraries(lite-test anf_exporter_mid mslite_converter_plugin - tflite_parser_mid - caffe_parser_mid - onnx_parser_mid - tf_parser_mid graph_pass_mid fusion_mid quantizer_mid @@ -148,7 +186,6 @@ if(MSLITE_ENABLE_CONVERTER) ccsrc_src_mid converter_src_mid mindspore::protobuf - mindspore::eigen mindspore::json -Wl,--whole-archive mindspore_core -Wl,--no-whole-archive mindspore::glog