:support vs build

This commit is contained in:
sunsuodong 2021-07-31 10:46:37 +08:00
parent c6dc35f510
commit ea93087683
19 changed files with 173 additions and 99 deletions

View File

@ -55,9 +55,15 @@ IF "%1%" == "lite" (
echo "======Start building MindSpore Lite %VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_REVISION%======" echo "======Start building MindSpore Lite %VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_REVISION%======"
rd /s /q "%BASE_PATH%\output" rd /s /q "%BASE_PATH%\output"
(git log -1 | findstr "^commit") > %BUILD_PATH%\.commit_id (git log -1 | findstr "^commit") > %BUILD_PATH%\.commit_id
cmake -DPLATFORM_X86_64=on -DBUILD_MINDDATA=off -DMSLITE_ENABLE_TRAIN=off ^ IF defined VisualStudioVersion (
-DMS_VERSION_MAJOR=%VERSION_MAJOR% -DMS_VERSION_MINOR=%VERSION_MINOR% -DMS_VERSION_REVISION=%VERSION_REVISION% ^ cmake -DBUILD_MINDDATA=off -DMSLITE_ENABLE_TRAIN=off ^
-DCMAKE_BUILD_TYPE=Release -G "CodeBlocks - MinGW Makefiles" "%BASE_PATH%/mindspore/lite" -DMS_VERSION_MAJOR=%VERSION_MAJOR% -DMS_VERSION_MINOR=%VERSION_MINOR% -DMS_VERSION_REVISION=%VERSION_REVISION% ^
-DCMAKE_BUILD_TYPE=Release -G "Ninja" "%BASE_PATH%/mindspore/lite"
) ELSE (
cmake -DBUILD_MINDDATA=off -DMSLITE_ENABLE_TRAIN=off ^
-DMS_VERSION_MAJOR=%VERSION_MAJOR% -DMS_VERSION_MINOR=%VERSION_MINOR% -DMS_VERSION_REVISION=%VERSION_REVISION% ^
-DCMAKE_BUILD_TYPE=Release -G "CodeBlocks - MinGW Makefiles" "%BASE_PATH%/mindspore/lite"
)
) ELSE ( ) ELSE (
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^ cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_CPU=ON -DENABLE_MINDDATA=ON -DUSE_GLOG=ON -DENABLE_GITEE=%ENABLE_GITEE% ^
-G "CodeBlocks - MinGW Makefiles" ../.. -G "CodeBlocks - MinGW Makefiles" ../..

View File

@ -1,5 +1,12 @@
set(flatbuffers_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") if(MSVC)
set(flatbuffers_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(flatbuffers_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(flatbuffers_CFLAGS "${CMAKE_CXX_FLAGS}")
set(flatbuffers_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
else()
set(flatbuffers_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(flatbuffers_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
endif()
if(WIN32) if(WIN32)
set(flatbuffers_USE_STATIC_LIBS ON) set(flatbuffers_USE_STATIC_LIBS ON)
endif() endif()
@ -30,7 +37,7 @@ else()
URL ${REQ_URL} URL ${REQ_URL}
MD5 ${MD5} MD5 ${MD5}
CMAKE_OPTION -DCMAKE_C_COMPILER=${FLATC_GCC_COMPILER} -DCMAKE_CXX_COMPILER=${FLATC_GXX_COMPILER} CMAKE_OPTION -DCMAKE_C_COMPILER=${FLATC_GCC_COMPILER} -DCMAKE_CXX_COMPILER=${FLATC_GXX_COMPILER}
-DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_INSTALL_LIBDIR=lib) -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release)
endif() endif()
include_directories(${flatbuffers_INC}) include_directories(${flatbuffers_INC})

View File

@ -1,5 +1,11 @@
set(nlohmann_json_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2") if(MSVC)
set(nlohmann_json_CFLAGS "-D_FORTIFY_SOURCE=2 -O2") set(flatbuffers_CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(flatbuffers_CFLAGS "${CMAKE_CXX_FLAGS}")
set(flatbuffers_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
else()
set(nlohmann_json_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(nlohmann_json_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
endif()
if(ENABLE_GITEE) if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/JSON-for-Modern-CPP/repository/archive/v3.6.1.zip") set(REQ_URL "https://gitee.com/mirrors/JSON-for-Modern-CPP/repository/archive/v3.6.1.zip")

View File

@ -359,13 +359,18 @@ elseif(WIN32)
__install_micro_codegen() __install_micro_codegen()
endif() endif()
if(MSLITE_ENABLE_TOOLS) if(MSLITE_ENABLE_TOOLS)
install(TARGETS ${BENCHMARK_NAME} RUNTIME DESTINATION ${BENCHMARK_ROOT_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME}) if(MSVC)
install(FILES ${TOP_DIR}/build/mindspore/tools/benchmark/${BENCHMARK_NAME}.exe
DESTINATION ${BENCHMARK_ROOT_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
else()
install(TARGETS ${BENCHMARK_NAME} RUNTIME DESTINATION ${BENCHMARK_ROOT_DIR}
COMPONENT ${RUNTIME_COMPONENT_NAME})
endif()
if(SUPPORT_TRAIN) if(SUPPORT_TRAIN)
install(TARGETS ${BENCHMARK_TRAIN_NAME} RUNTIME DESTINATION ${BENCHMARK_TRAIN_ROOT_DIR} COMPONENT install(TARGETS ${BENCHMARK_TRAIN_NAME} RUNTIME DESTINATION ${BENCHMARK_TRAIN_ROOT_DIR} COMPONENT
${RUNTIME_COMPONENT_NAME}) ${RUNTIME_COMPONENT_NAME})
endif() endif()
endif() endif()
install(FILES ${LIB_LIST} DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
if(SUPPORT_TRAIN) if(SUPPORT_TRAIN)
install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${RUNTIME_INC_DIR} install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${RUNTIME_INC_DIR}
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "*registry.h" EXCLUDE) COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "*registry.h" EXCLUDE)
@ -384,12 +389,22 @@ elseif(WIN32)
COMPONENT ${RUNTIME_COMPONENT_NAME}) COMPONENT ${RUNTIME_COMPONENT_NAME})
install(DIRECTORY ${TOP_DIR}/include/api/ DESTINATION ${RUNTIME_INC_DIR}/api install(DIRECTORY ${TOP_DIR}/include/api/ DESTINATION ${RUNTIME_INC_DIR}/api
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "ops*" EXCLUDE) COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "ops*" EXCLUDE)
install(FILES ${TOP_DIR}/build/mindspore/src/${MINDSPORE_LITE_LIB_NAME}.a DESTINATION ${RUNTIME_LIB_DIR} if(MSVC)
COMPONENT ${RUNTIME_COMPONENT_NAME}) install(FILES ${TOP_DIR}/build/mindspore/src/${MINDSPORE_LITE_LIB_NAME}.lib DESTINATION ${RUNTIME_LIB_DIR}
install(FILES ${TOP_DIR}/build/mindspore/src/${MINDSPORE_LITE_LIB_NAME}.dll.a DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
COMPONENT ${RUNTIME_COMPONENT_NAME}) install(FILES ${TOP_DIR}/build/mindspore/src/${MINDSPORE_LITE_LIB_NAME}.dll DESTINATION ${RUNTIME_LIB_DIR}
install(FILES ${TOP_DIR}/build/mindspore/src/${MINDSPORE_LITE_LIB_NAME}.dll DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
COMPONENT ${RUNTIME_COMPONENT_NAME}) install(FILES ${TOP_DIR}/build/mindspore/src/${MINDSPORE_LITE_LIB_NAME}.dll.lib DESTINATION ${RUNTIME_LIB_DIR}
COMPONENT ${RUNTIME_COMPONENT_NAME})
else()
install(FILES ${TOP_DIR}/build/mindspore/src/${MINDSPORE_LITE_LIB_NAME}.a DESTINATION ${RUNTIME_LIB_DIR}
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(FILES ${TOP_DIR}/build/mindspore/src/${MINDSPORE_LITE_LIB_NAME}.dll.a DESTINATION ${RUNTIME_LIB_DIR}
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(FILES ${TOP_DIR}/build/mindspore/src/${MINDSPORE_LITE_LIB_NAME}.dll DESTINATION ${RUNTIME_LIB_DIR}
COMPONENT ${RUNTIME_COMPONENT_NAME})
install(FILES ${LIB_LIST} DESTINATION ${RUNTIME_LIB_DIR} COMPONENT ${RUNTIME_COMPONENT_NAME})
endif()
else() else()
if(SUPPORT_TRAIN) if(SUPPORT_TRAIN)
install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${RUNTIME_INC_DIR} install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${RUNTIME_INC_DIR}

View File

@ -13,14 +13,17 @@ if(PLATFORM_ARM32 OR PLATFORM_ARM64)
-ffunction-sections -fdata-sections -ffast-math") -ffunction-sections -fdata-sections -ffast-math")
endif() endif()
endif() endif()
if("${X86_64_SIMD}" STREQUAL "avx")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1 -mavx -mavx2 -mfma") if(NOT MSVC)
endif() if("${X86_64_SIMD}" STREQUAL "avx")
if("${X86_64_SIMD}" STREQUAL "avx512") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1 -mavx -mavx2 -mfma")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1 -mavx -mavx2 -mfma") endif()
endif() if("${X86_64_SIMD}" STREQUAL "avx512")
if("${X86_64_SIMD}" STREQUAL "sse") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1 -mavx -mavx2 -mfma")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1") endif()
if("${X86_64_SIMD}" STREQUAL "sse")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
endif()
endif() endif()
########################### files ########################### ########################### files ###########################

View File

@ -1,10 +1,9 @@
cmake_minimum_required(VERSION 3.14) cmake_minimum_required(VERSION 3.12)
project(Lite) project(Lite)
set(BUILD_LITE "on") set(BUILD_LITE "on")
if(TOOLCHAIN_NAME STREQUAL "himix200") if(TOOLCHAIN_NAME STREQUAL "himix200")
set(TARGET_HIMIX200 on) set(TARGET_HIMIX200 on)
set(ENABLE_MINDRT off)
add_compile_definitions(SUPPORT_NNIE) add_compile_definitions(SUPPORT_NNIE)
elseif(TOOLCHAIN_NAME STREQUAL "ohos-lite") elseif(TOOLCHAIN_NAME STREQUAL "ohos-lite")
set(TARGET_OHOS_LITE on) set(TARGET_OHOS_LITE on)
@ -39,6 +38,8 @@ option(ENABLE_VERBOSE "" off)
option(ENABLE_MINDRT "if support mindrt" on) option(ENABLE_MINDRT "if support mindrt" on)
option(ENABLE_MODEL_OBF "if support model obfuscation" off) option(ENABLE_MODEL_OBF "if support model obfuscation" off)
option(ENABLE_V0 "support v0 schema" on) option(ENABLE_V0 "support v0 schema" on)
set(BUILD_MINDDATA "lite_cv" CACHE STRING "off, lite, lite_cv, wrapper or full")
if(APPLE) if(APPLE)
find_package(Patch) find_package(Patch)
if(NOT Patch_FOUND) if(NOT Patch_FOUND)
@ -134,6 +135,10 @@ if(MSLITE_ENABLE_NPU)
endif() endif()
endif() endif()
if(TARGET_HIMIX200 OR TARGET_OHOS_LITE)
set(ENABLE_MINDRT off)
endif()
message(STATUS "************MindSpore Lite Build Option:************") message(STATUS "************MindSpore Lite Build Option:************")
message(STATUS "\tMSLITE_GPU_BACKEND = \t${MSLITE_GPU_BACKEND}") message(STATUS "\tMSLITE_GPU_BACKEND = \t${MSLITE_GPU_BACKEND}")
message(STATUS "\tMSLITE_ENABLE_NPU = \t${MSLITE_ENABLE_NPU}") message(STATUS "\tMSLITE_ENABLE_NPU = \t${MSLITE_ENABLE_NPU}")
@ -153,8 +158,42 @@ if(ENABLE_ASAN)
endif() endif()
set(PKG_NAME_PREFIX mindspore-lite-${MS_VERSION_MAJOR}.${MS_VERSION_MINOR}.${MS_VERSION_REVISION}) set(PKG_NAME_PREFIX mindspore-lite-${MS_VERSION_MAJOR}.${MS_VERSION_MINOR}.${MS_VERSION_REVISION})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") set(CMAKE_SKIP_RPATH TURE)
set(BUILD_MINDDATA "lite_cv" CACHE STRING "off, lite, lite_cv, wrapper or full")
if(MSVC)
add_compile_definitions(SUPPORT_MSVC)
add_compile_definitions(_ENABLE_ATOMIC_ALIGNMENT_FIX)
set(CMAKE_C_FLAGS "/O2 /EHsc /GS /Zi /utf-8")
set(CMAKE_CXX_FLAGS "/O2 /EHsc /GS /Zi /utf-8 /std:c++17")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_SHARED_LINKER_FLAGS "/SAFESEH ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "/SAFESEH ${CMAKE_EXE_LINKER_FLAGS}")
endif()
set(CMAKE_SHARED_LINKER_FLAGS "/NXCOMPAT /DYNAMICBASE /DEBUG ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "/NXCOMPAT /DYNAMICBASE /DEBUG ${CMAKE_EXE_LINKER_FLAGS}")
else()
string(REPLACE "-g" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REPLACE "-g" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(LITE_COMPILE_FLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -O2 -Wall -Werror -fstack-protector-strong -Wno-attributes \
-Wno-deprecated-declarations -Wno-missing-braces")
set(CMAKE_C_FLAGS "${LITE_COMPILE_FLAGS} ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "-DDebug -g -fvisibility=default")
set(CMAKE_CXX_FLAGS "${LITE_COMPILE_FLAGS} -Wno-overloaded-virtual ${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_CXX_FLAGS_DEBUG "-DDebug -g -fvisibility=default")
if(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-seh ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-seh ${CMAKE_EXE_LINKER_FLAGS}")
endif()
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--nxcompat -Wl,--dynamicbase ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--nxcompat -Wl,--dynamicbase ${CMAKE_EXE_LINKER_FLAGS}")
else()
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-z,relro,-z,now -Wl,-z,noexecstack -s ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,relro,-z,now -Wl,-z,noexecstack -s -pie ${CMAKE_EXE_LINKER_FLAGS}")
endif()
endif()
if(SUPPORT_NPU) if(SUPPORT_NPU)
set(DDK_PATH "$ENV{HWHIAI_DDK}/ddk/ai_ddk_lib") set(DDK_PATH "$ENV{HWHIAI_DDK}/ddk/ai_ddk_lib")
@ -170,10 +209,6 @@ endif()
add_compile_definitions(NO_DLIB) add_compile_definitions(NO_DLIB)
add_compile_options(-fPIC) add_compile_options(-fPIC)
if(SUPPORT_TRAIN)
set(BUILD_MINDDATA "full")
endif()
if(PLATFORM_ARM64) if(PLATFORM_ARM64)
set(RUNTIME_COMPONENT_NAME "android-aarch64") set(RUNTIME_COMPONENT_NAME "android-aarch64")
elseif(PLATFORM_ARM32) elseif(PLATFORM_ARM32)
@ -237,32 +272,6 @@ ms_build_flatbuffers_lite(FBS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/schema/ fbs_src
ms_build_flatbuffers_lite(FBS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/schema/ fbs_inner_src ${CMAKE_BINARY_DIR}/schema/inner ms_build_flatbuffers_lite(FBS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/schema/ fbs_inner_src ${CMAKE_BINARY_DIR}/schema/inner
"inner") "inner")
string(REPLACE "-g" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REPLACE "-g" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDebug -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDebug -g")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=default")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default")
else()
## enable for binscope for release
set(CMAKE_C_FLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -O2 -Wall -Werror -fstack-protector-strong -Wno-attributes \
-Wno-deprecated-declarations -Wno-missing-braces ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-fPIC -fPIE -D_FORTIFY_SOURCE=2 -O2 -Wall -Werror -fstack-protector-strong -Wno-attributes \
-Wno-deprecated-declarations -Wno-missing-braces -Wno-overloaded-virtual ${CMAKE_CXX_FLAGS}")
if(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-seh ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-seh ${CMAKE_EXE_LINKER_FLAGS}")
endif()
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--nxcompat -Wl,--dynamicbase ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--nxcompat -Wl,--dynamicbase ${CMAKE_EXE_LINKER_FLAGS}")
else()
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-z,relro,-z,now -Wl,-z,noexecstack ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,relro,-z,now -Wl,-z,noexecstack ${CMAKE_EXE_LINKER_FLAGS}")
endif()
endif()
if(ENABLE_VERBOSE) if(ENABLE_VERBOSE)
set(CMAKE_VERBOSE_MAKEFILE on) set(CMAKE_VERBOSE_MAKEFILE on)
endif() endif()
@ -357,7 +366,7 @@ if(PLATFORM_ARM64)
add_compile_definitions(ENABLE_ARM) add_compile_definitions(ENABLE_ARM)
endif() endif()
if(NOT PLATFORM_ARM32 AND NOT PLATFORM_ARM64) if(NOT PLATFORM_ARM)
if(MSLITE_ENABLE_AVX) if(MSLITE_ENABLE_AVX)
set(X86_64_SIMD "avx") set(X86_64_SIMD "avx")
add_compile_definitions(ENABLE_SSE) add_compile_definitions(ENABLE_SSE)
@ -367,8 +376,10 @@ if(NOT PLATFORM_ARM32 AND NOT PLATFORM_ARM64)
elseif(MSLITE_ENABLE_SSE) elseif(MSLITE_ENABLE_SSE)
set(X86_64_SIMD "sse") set(X86_64_SIMD "sse")
add_compile_definitions(ENABLE_SSE) add_compile_definitions(ENABLE_SSE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1") if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
endif()
endif() endif()
endif() endif()
@ -390,24 +401,21 @@ add_subdirectory(${CCSRC_DIR}/backend/kernel_compiler/cpu/nnacl build)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/micro/coder) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/micro/coder)
if(NOT APPLE AND MSLITE_ENABLE_TOOLS) if(MSLITE_ENABLE_TOOLS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/benchmark)
if(SUPPORT_TRAIN) if(SUPPORT_TRAIN)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/benchmark_train) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/benchmark_train)
endif() endif()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/benchmark) if(NOT PLATFORM_ARM AND NOT WIN32)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/cropper)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/schema_gen)
add_dependencies(fbs_src gen_ops)
add_dependencies(fbs_inner_src gen_ops)
endif()
endif() endif()
if(NOT WIN32)
if(MSLITE_ENABLE_TOOLS) if(NOT WIN32 AND MSLITE_ENABLE_TESTCASES)
if(NOT PLATFORM_ARM32 AND NOT PLATFORM_ARM64) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/cropper)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/schema_gen)
add_dependencies(fbs_src gen_ops)
add_dependencies(fbs_inner_src gen_ops)
endif()
endif()
if(MSLITE_ENABLE_TESTCASES)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test)
endif()
endif() endif()
if(NOT APPLE) if(NOT APPLE)

View File

@ -20,7 +20,6 @@ set(CMAKE_CXX_LINK_EXECUTABLE
"${CMAKE_CXX_LINKER} ${MY_LINK_FLAGS} <FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") "${CMAKE_CXX_LINKER} ${MY_LINK_FLAGS} <FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
set(CMAKE_SYSROOT ${OHOS_SYSROOT_PATH}) set(CMAKE_SYSROOT ${OHOS_SYSROOT_PATH})
set(ENABLE_MINDRT "off")
find_path(GCC_PATH gcc) find_path(GCC_PATH gcc)
find_path(GXX_PATH g++) find_path(GXX_PATH g++)
if(NOT ${GCC_PATH} STREQUAL "GCC_PATH-NOTFOUND" AND NOT ${GXX_PATH} STREQUAL "GXX_PATH-NOTFOUND") if(NOT ${GCC_PATH} STREQUAL "GCC_PATH-NOTFOUND" AND NOT ${GXX_PATH} STREQUAL "GXX_PATH-NOTFOUND")

View File

@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.10)
project(Lite-java) project(Lite-java)
set(BUILD_LITE "on") set(BUILD_LITE "on")
set(CMAKE_SKIP_RPATH TURE)
if(PLATFORM_ARM64 OR PLATFORM_ARM32) if(PLATFORM_ARM64 OR PLATFORM_ARM32)
set(PLATFORM_ARM "on") set(PLATFORM_ARM "on")

View File

@ -15,17 +15,21 @@ endif()
#include 3rd #include 3rd
include_directories(${3RD_DIR}) include_directories(${3RD_DIR})
include_directories(${3RD_DIR}/flatbuffers/include) include_directories(${3RD_DIR}/flatbuffers/include)
#include ms #include ms
include_directories(${TOP_DIR}/) include_directories(${TOP_DIR}/)
include_directories(${TOP_DIR}/mindspore/core/) include_directories(${TOP_DIR}/mindspore/core/)
include_directories(${NNACL_DIR}/../) include_directories(${NNACL_DIR}/../)
include_directories(${LITE_DIR}) include_directories(${LITE_DIR})
include_directories(${MICRO_DIR}) include_directories(${MICRO_DIR})
#include coder #include coder
include(${TOP_DIR}/cmake/external_libs/cmsis.cmake) if(NOT MSVC)
include(${MICRO_DIR}/cmake/file_list.cmake) include(${TOP_DIR}/cmake/external_libs/cmsis.cmake)
include(${MICRO_DIR}/cmake/package_wrapper.cmake) include(${MICRO_DIR}/cmake/file_list.cmake)
add_subdirectory(wrapper) include(${MICRO_DIR}/cmake/package_wrapper.cmake)
add_subdirectory(wrapper)
endif()
if(MSLITE_ENABLE_CONVERTER) if(MSLITE_ENABLE_CONVERTER)
add_executable(codegen main.cc ${FILE_SET}) add_executable(codegen main.cc ${FILE_SET})

View File

@ -14,7 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */
#include "coder/coder.h" #include "coder/coder.h"
#include <getopt.h>
#include <iomanip> #include <iomanip>
#include <string> #include <string>
#include <vector> #include <vector>

View File

@ -66,10 +66,15 @@ class Generator {
int CodeSessionImplement(); int CodeSessionImplement();
std::string cmake_file_name_{"net.cmake"}; std::string cmake_file_name_{"net.cmake"};
#ifdef _MSC_VER
unsigned int user_umask_ = 18;
unsigned int origin_umask_ = 0;
#else
// the user's generated file's permission // the user's generated file's permission
mode_t user_umask_ = 0022; mode_t user_umask_ = 0022;
// the origin file's permission // the origin file's permission
mode_t origin_umask_ = 0000; mode_t origin_umask_ = 0000;
#endif
}; };
} // namespace mindspore::lite::micro } // namespace mindspore::lite::micro

View File

@ -35,6 +35,7 @@
#include "nnacl/fp32/exp_fp32.h" #include "nnacl/fp32/exp_fp32.h"
#include "nnacl/fp32/strided_slice_fp32.h" #include "nnacl/fp32/strided_slice_fp32.h"
#include "wrapper/fp32/arithmetic_fp32_wrapper.h" #include "wrapper/fp32/arithmetic_fp32_wrapper.h"
namespace mindspore::lite::micro::nnacl { namespace mindspore::lite::micro::nnacl {
class NNaclFp32Serializer : public Serializer { class NNaclFp32Serializer : public Serializer {

View File

@ -21,12 +21,17 @@
#endif #endif
#include <string> #include <string>
#include <fstream> #include <fstream>
#include <array>
#include "include/errorcode.h" #include "include/errorcode.h"
#include "src/common/log_adapter.h" #include "src/common/log_adapter.h"
namespace mindspore::lite::micro { namespace mindspore::lite::micro {
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
#ifdef _MSC_VER
constexpr unsigned int kMicroDirMode = 511;
#else
constexpr _mode_t kMicroDirMode = 0777; constexpr _mode_t kMicroDirMode = 0777;
#endif
#else #else
constexpr __mode_t kMicroDirMode = 0777; constexpr __mode_t kMicroDirMode = 0777;
#endif #endif

View File

@ -26,7 +26,7 @@ if(PLATFORM_ARM32 OR PLATFORM_ARM64)
-fdata-sections -ffast-math -fno-rtti -fno-exceptions -Wno-shorten-64-to-32 \ -fdata-sections -ffast-math -fno-rtti -fno-exceptions -Wno-shorten-64-to-32 \
-fno-aligned-allocation -DTARGET_OS_OSX") -fno-aligned-allocation -DTARGET_OS_OSX")
endif() endif()
else() elseif(NOT MSVC)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer -fstrict-aliasing -ffunction-sections \ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer -fstrict-aliasing -ffunction-sections \
-fdata-sections -ffast-math -fno-rtti") -fdata-sections -ffast-math -fno-rtti")
@ -195,7 +195,16 @@ endif()
set_target_properties(mindspore-lite_static PROPERTIES OUTPUT_NAME "mindspore-lite") set_target_properties(mindspore-lite_static PROPERTIES OUTPUT_NAME "mindspore-lite")
set_target_properties(mindspore-lite_static PROPERTIES CLEAN_DIRECT_OUTPUT 1) set_target_properties(mindspore-lite_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field") if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field")
endif()
if(MSVC)
set_target_properties(mindspore-lite PROPERTIES PREFIX lib)
set_target_properties(mindspore-lite PROPERTIES IMPORT_PREFIX lib)
set_target_properties(mindspore-lite PROPERTIES IMPORT_SUFFIX .dll.lib)
set_target_properties(mindspore-lite_static PROPERTIES PREFIX lib)
endif()
if(ENABLE_MINDRT) if(ENABLE_MINDRT)
target_link_libraries(mindspore-lite mindrt_mid) target_link_libraries(mindspore-lite mindrt_mid)

View File

@ -19,8 +19,9 @@
#include <asm/hwcap.h> #include <asm/hwcap.h>
#endif #endif
#include "src/common/utils.h" #include "src/common/utils.h"
#ifdef SUPPORT_MSVC #ifdef _MSC_VER
#include <windows.h> #include <windows.h>
#undef ERROR
#endif #endif
namespace mindspore { namespace mindspore {

View File

@ -21,6 +21,8 @@ if((PLATFORM_ARM32 OR PLATFORM_ARM64) AND NOT TARGET_HIMIX200 AND NOT TARGET_OHO
else() else()
target_link_libraries(benchmark mindspore-lite mindspore::json) target_link_libraries(benchmark mindspore-lite mindspore::json)
endif() endif()
elseif(MSVC)
target_link_libraries(benchmark mindspore-lite mindspore::json)
else() else()
target_link_libraries(benchmark mindspore-lite mindspore::json pthread) target_link_libraries(benchmark mindspore-lite mindspore::json pthread)
endif() endif()

View File

@ -38,8 +38,6 @@ using schema::FusedBatchNormT;
using schema::MetaGraphT; using schema::MetaGraphT;
using schema::QuantParamT; using schema::QuantParamT;
using schema::TensorT; using schema::TensorT;
using schema::Format::Format_NCHW;
using schema::Format::Format_NHWC;
std::unique_ptr<QuantParamT> GetTensorQuantParam(const std::unique_ptr<TensorT> &tensor); std::unique_ptr<QuantParamT> GetTensorQuantParam(const std::unique_ptr<TensorT> &tensor);
@ -77,7 +75,7 @@ std::unique_ptr<schema::QuantParamT> CopyQuantParamT(const std::unique_ptr<schem
std::unique_ptr<schema::QuantParamT> CopyQuantParamArrayT( std::unique_ptr<schema::QuantParamT> CopyQuantParamArrayT(
const std::unique_ptr<schema::QuantParamT> &srcQuantParamArray); const std::unique_ptr<schema::QuantParamT> &srcQuantParamArray);
enum Category { CONST = 0, GRAPH_INPUT = 1, OP_OUTPUT = 2, TF_CONST = 3 }; enum Category { CONSTANT = 0, GRAPH_INPUT = 1, OP_OUTPUT = 2, TF_CONST = 3 };
class TensorCache { class TensorCache {
public: public:
@ -87,7 +85,7 @@ class TensorCache {
int AddTensor(const std::string &name, TensorT *tensor, int Category) { int AddTensor(const std::string &name, TensorT *tensor, int Category) {
index++; index++;
if (Category == CONST || Category == TF_CONST || Category == GRAPH_INPUT) { if (Category == CONSTANT || Category == TF_CONST || Category == GRAPH_INPUT) {
tensor->refCount = 1; tensor->refCount = 1;
tensor->nodeType = NodeType_ValueNode; tensor->nodeType = NodeType_ValueNode;
} else { } else {

View File

@ -202,9 +202,12 @@ target_link_libraries(converter_lite PRIVATE
mindspore::glog mindspore::glog
mindspore::protobuf mindspore::protobuf
mindspore::flatbuffers mindspore::flatbuffers
pthread
) )
if(NOT MSVC)
target_link_libraries(converter_lite PRIVATE pthread)
endif()
if(NOT WIN32) if(NOT WIN32)
target_link_libraries(converter_lite PRIVATE dl) target_link_libraries(converter_lite PRIVATE dl)
endif() endif()

View File

@ -1,14 +1,16 @@
SET(CMAKE_BUILD_TYPE "Debug") if(NOT MSVC)
if(CMAKE_SYSTEM_NAME MATCHES "Windows") SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_C_FLAGS_DEBUG "$ENV{CFLAGS} -fPIC -O0 -Wall -Wno-deprecated-declarations -g2 -ggdb -fno-inline-functions -fno-omit-frame-pointer -fstack-protector-all") if(CMAKE_SYSTEM_NAME MATCHES "Windows")
else () SET(CMAKE_C_FLAGS_DEBUG "$ENV{CFLAGS} -fPIC -O0 -Wall -Wno-deprecated-declarations -g2 -ggdb -fno-inline-functions -fno-omit-frame-pointer -fstack-protector-all")
SET(CMAKE_C_FLAGS_DEBUG "$ENV{CFLAGS} -Wno-nullability-completeness -fPIC -O0 -Wall -Wno-deprecated-declarations -g2 -ggdb -fno-inline-functions -fno-omit-frame-pointer -fstack-protector-all -D_LIBCPP_INLINE_VISIBILITY='' -D'_LIBCPP_EXTERN_TEMPLATE(...)='") else ()
endif() SET(CMAKE_C_FLAGS_DEBUG "$ENV{CFLAGS} -Wno-nullability-completeness -fPIC -O0 -Wall -Wno-deprecated-declarations -g2 -ggdb -fno-inline-functions -fno-omit-frame-pointer -fstack-protector-all -D_LIBCPP_INLINE_VISIBILITY='' -D'_LIBCPP_EXTERN_TEMPLATE(...)='")
SET(CMAKE_C_FLAGS_RELEASE "$ENV{CFLAGS} -fPIC -O3 -Wall -Wno-deprecated-declarations -fstack-protector-all") endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) SET(CMAKE_C_FLAGS_RELEASE "$ENV{CFLAGS} -fPIC -O3 -Wall -Wno-deprecated-declarations -fstack-protector-all")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
#add flags #add flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include -Werror") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/usr/local/include -Werror")
endif()
include_directories(./include) include_directories(./include)
add_subdirectory(src) add_subdirectory(src)