diff --git a/VERSION b/MS_VERSION similarity index 100% rename from VERSION rename to MS_VERSION diff --git a/cmake/external_libs/flatbuffers.cmake b/cmake/external_libs/flatbuffers.cmake index 8ec9d6730f6..53855203207 100644 --- a/cmake/external_libs/flatbuffers.cmake +++ b/cmake/external_libs/flatbuffers.cmake @@ -12,14 +12,26 @@ else() set(MD5 "02c64880acb89dbd57eebacfd67200d8") endif() -mindspore_add_pkg(flatbuffers - VER 1.11.0 - LIBS flatbuffers - EXE flatc - URL ${REQ_URL} - MD5 ${MD5} - CMAKE_OPTION -DCMAKE_C_COMPILER=${FLATC_GCC_COMPILER} -DCMAKE_CXX_COMPILER=${FLATC_GXX_COMPILER} - -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_INSTALL_LIBDIR=lib) +if(APPLE) + set(FLATBUFFERS_PATCH ${TOP_DIR}/third_party/patch/flatbuffers/flatbuffers.patch001) + mindspore_add_pkg(flatbuffers + VER 1.11.0 + LIBS flatbuffers + EXE flatc + URL ${REQ_URL} + MD5 ${MD5} + PATCHES ${FLATBUFFERS_PATCH} + CMAKE_OPTION -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_INSTALL_LIBDIR=lib) +else() + mindspore_add_pkg(flatbuffers + VER 1.11.0 + LIBS flatbuffers + EXE flatc + URL ${REQ_URL} + MD5 ${MD5} + CMAKE_OPTION -DCMAKE_C_COMPILER=${FLATC_GCC_COMPILER} -DCMAKE_CXX_COMPILER=${FLATC_GXX_COMPILER} + -DFLATBUFFERS_BUILD_TESTS=OFF -DCMAKE_INSTALL_LIBDIR=lib) +endif() include_directories(${flatbuffers_INC}) add_library(mindspore::flatbuffers ALIAS flatbuffers::flatbuffers) diff --git a/cmake/package_tar.cmake b/cmake/package_tar.cmake index fe53a468142..6cf9afa52f7 100644 --- a/cmake/package_tar.cmake +++ b/cmake/package_tar.cmake @@ -7,7 +7,7 @@ file(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/output) file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/output) # cpack variables -file(READ ${CMAKE_SOURCE_DIR}/VERSION VERSION_NUMBER) +file(READ ${CMAKE_SOURCE_DIR}/MS_VERSION VERSION_NUMBER) string(TOLOWER linux_${CMAKE_HOST_SYSTEM_PROCESSOR} PLATFORM_NAME) set(CPACK_PACKAGE_FILE_NAME mindspore_ascend-${VERSION_NUMBER}-${PLATFORM_NAME}) set(CPACK_GENERATOR "TGZ") diff --git a/cmake/utils.cmake b/cmake/utils.cmake index ed9882a5957..1911ad93480 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -352,16 +352,18 @@ function(mindspore_add_pkg pkg_name) set(${pkg_name}_CMAKE_LDFLAGS "-DCMAKE_SHARED_LINKER_FLAGS=${${pkg_name}_LDFLAGS}") endif() endif() - - __exec_cmd(COMMAND ${CMAKE_COMMAND} ${PKG_CMAKE_OPTION} -G ${CMAKE_GENERATOR} - ${${pkg_name}_CMAKE_CFLAGS} ${${pkg_name}_CMAKE_CXXFLAGS} ${${pkg_name}_CMAKE_LDFLAGS} - -DCMAKE_INSTALL_PREFIX=${${pkg_name}_BASE_DIR} ${${pkg_name}_SOURCE_DIR}/${PKG_CMAKE_PATH} - WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build) - if(APPLE) + __exec_cmd(COMMAND ${CMAKE_COMMAND} ${PKG_CMAKE_OPTION} + ${${pkg_name}_CMAKE_CFLAGS} ${${pkg_name}_CMAKE_CXXFLAGS} ${${pkg_name}_CMAKE_LDFLAGS} + -DCMAKE_INSTALL_PREFIX=${${pkg_name}_BASE_DIR} ${${pkg_name}_SOURCE_DIR}/${PKG_CMAKE_PATH} + WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build) __exec_cmd(COMMAND ${CMAKE_COMMAND} --build . --target install -- WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build) else() + __exec_cmd(COMMAND ${CMAKE_COMMAND} ${PKG_CMAKE_OPTION} -G ${CMAKE_GENERATOR} + ${${pkg_name}_CMAKE_CFLAGS} ${${pkg_name}_CMAKE_CXXFLAGS} ${${pkg_name}_CMAKE_LDFLAGS} + -DCMAKE_INSTALL_PREFIX=${${pkg_name}_BASE_DIR} ${${pkg_name}_SOURCE_DIR}/${PKG_CMAKE_PATH} + WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build) __exec_cmd(COMMAND ${CMAKE_COMMAND} --build . --target install -- -j${THNUM} WORKING_DIRECTORY ${${pkg_name}_SOURCE_DIR}/_build) endif() diff --git a/mindspore/lite/CMakeLists.txt b/mindspore/lite/CMakeLists.txt index be24ce056f4..e051711c945 100644 --- a/mindspore/lite/CMakeLists.txt +++ b/mindspore/lite/CMakeLists.txt @@ -34,7 +34,14 @@ option(ENABLE_VERBOSE "" off) option(ENABLE_MINDRT "if support mindrt" on) option(ENABLE_MODEL_OBF "if support model obfuscation" off) option(ENABLE_V0 "support v0 schema" on) - +if(APPLE) + find_package(Patch) + if(NOT Patch_FOUND) + message(FATAL_ERROR "Patch not found, " + "please set environment variable MS_PATCH_PATH to path where Patch is located," + "usually found in GIT_PATH/usr/bin on Windows") + endif() +endif() if(DEFINED ENV{MSLITE_GPU_BACKEND}) set(MSLITE_GPU_BACKEND $ENV{MSLITE_GPU_BACKEND}) endif() diff --git a/mindspore/lite/include/context.h b/mindspore/lite/include/context.h index 35d74d92243..c1beedd72fe 100644 --- a/mindspore/lite/include/context.h +++ b/mindspore/lite/include/context.h @@ -23,18 +23,18 @@ namespace mindspore::lite { /// \brief CpuDeviceInfo defined for CPU's configuration information. -typedef struct { +typedef struct CpuDeviceInfo { bool enable_float16_ = false; /**< prior enable float16 inference */ CpuBindMode cpu_bind_mode_ = MID_CPU; } CpuDeviceInfo; /// \brief GpuDeviceInfo defined for GPU's configuration information. -typedef struct { +typedef struct GpuDeviceInfo { bool enable_float16_ = false; /**< prior enable float16 inference */ } GpuDeviceInfo; /// \brief NpuDeviceInfo defined for NPU's configuration information. -typedef struct { +typedef struct NpuDeviceInfo { int frequency_ = 3; /**< npu frequency inference, low 1, medium 2, high 3, extreme 4, other values will be set to 3 */ } NpuDeviceInfo; diff --git a/mindspore/lite/src/common/string_util.h b/mindspore/lite/src/common/string_util.h index cb242864036..fb64a04f212 100644 --- a/mindspore/lite/src/common/string_util.h +++ b/mindspore/lite/src/common/string_util.h @@ -28,7 +28,7 @@ namespace mindspore { namespace lite { -typedef struct { +typedef struct StringPack { int len = 0; const char *data = nullptr; } StringPack; diff --git a/setup.py b/setup.py index 24058b2f189..7deeb763785 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,7 @@ def _read_file(filename): return f.read() -version = _read_file('VERSION').replace("\n", "") +version = _read_file('MS_VERSION').replace("\n", "") readme = _read_file('README.md') diff --git a/third_party/patch/flatbuffers/flatbuffers.patch001 b/third_party/patch/flatbuffers/flatbuffers.patch001 new file mode 100644 index 00000000000..4300e4286fe --- /dev/null +++ b/third_party/patch/flatbuffers/flatbuffers.patch001 @@ -0,0 +1,12 @@ +diff -Npur flatbuffers-src/CMakeLists.txt flatbuffers-src_patch/CMakeLists.txt +--- flatbuffers-src/CMakeLists.txt 2019-04-25 02:34:53.000000000 +0800 ++++ flatbuffers-src_patch/CMakeLists.txt 2021-06-28 11:37:12.922988687 +0800 +@@ -161,7 +161,7 @@ + message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.") + elseif(APPLE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Wno-unused-parameter") ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Wno-unused-parameter -Wno-deprecated") + set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast") + elseif(CMAKE_COMPILER_IS_GNUCXX) + if(CYGWIN)