| @@ -1,7 +1,13 @@ | |||||
| if(BUILD_LITE) | if(BUILD_LITE) | ||||
| set(glog_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_CXX_FLAGS} -Dgoogle=mindspore_private") | |||||
| set(glog_CFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_C_FLAGS}") | |||||
| set(glog_LDFLAGS "${SECURE_SHARED_LINKER_FLAGS}") | |||||
| if(MSVC) | |||||
| set(flatbuffers_CXXFLAGS "${CMAKE_CXX_FLAGS}") | |||||
| set(flatbuffers_CFLAGS "${CMAKE_C_FLAGS}") | |||||
| set(flatbuffers_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}") | |||||
| else() | |||||
| set(glog_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_CXX_FLAGS} -Dgoogle=mindspore_private") | |||||
| set(glog_CFLAGS "-D_FORTIFY_SOURCE=2 -O2 ${SECURE_C_FLAGS}") | |||||
| set(glog_LDFLAGS "${SECURE_SHARED_LINKER_FLAGS}") | |||||
| endif() | |||||
| set(glog_patch "") | set(glog_patch "") | ||||
| set(glog_lib glog) | set(glog_lib glog) | ||||
| else() | else() | ||||
| @@ -23,9 +29,10 @@ else() | |||||
| set(MD5 "0daea8785e6df922d7887755c3d100d0") | set(MD5 "0daea8785e6df922d7887755c3d100d0") | ||||
| endif() | endif() | ||||
| set(glog_option -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON -DWITH_GFLAGS=OFF) | |||||
| set(glog_option -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON -DWITH_GFLAGS=OFF | |||||
| -DCMAKE_BUILD_TYPE=Release) | |||||
| if(WIN32) | |||||
| if(WIN32 AND NOT MSVC) | |||||
| execute_process(COMMAND "${CMAKE_C_COMPILER}" -dumpmachine | execute_process(COMMAND "${CMAKE_C_COMPILER}" -dumpmachine | ||||
| OUTPUT_VARIABLE i686_or_x86_64 | OUTPUT_VARIABLE i686_or_x86_64 | ||||
| ) | ) | ||||
| @@ -1,4 +1,8 @@ | |||||
| if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | |||||
| if(MSVC) | |||||
| set(opencv_CXXFLAGS "${CMAKE_CXX_FLAGS}") | |||||
| set(opencv_CFLAGS "${CMAKE_C_FLAGS}") | |||||
| set(opencv_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}") | |||||
| elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | |||||
| set(opencv_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2") | set(opencv_CXXFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2") | ||||
| set(opencv_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2") | set(opencv_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2") | ||||
| set(opencv_LDFLAGS "-Wl") | set(opencv_LDFLAGS "-Wl") | ||||
| @@ -41,7 +45,33 @@ else() | |||||
| endif() | endif() | ||||
| endif() | endif() | ||||
| if(WIN32) | |||||
| if(MSVC) | |||||
| mindspore_add_pkg(opencv | |||||
| VER 4.5.1 | |||||
| LIBS opencv_core451.lib opencv_imgcodecs451.lib opencv_imgproc451.lib | |||||
| LIB_PATH x64/vc15/lib | |||||
| URL ${REQ_URL} | |||||
| MD5 ${MD5} | |||||
| CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DWITH_PROTOBUF=OFF -DWITH_WEBP=OFF -DWITH_IPP=OFF | |||||
| -DWITH_ADE=OFF | |||||
| -DBUILD_ZLIB=ON | |||||
| -DBUILD_JPEG=ON | |||||
| -DBUILD_PNG=ON | |||||
| -DBUILD_OPENEXR=ON | |||||
| -DBUILD_TESTS=OFF | |||||
| -DBUILD_PERF_TESTS=OFF | |||||
| -DBUILD_opencv_apps=OFF | |||||
| -DCMAKE_SKIP_RPATH=TRUE | |||||
| -DBUILD_opencv_python3=OFF | |||||
| -DBUILD_opencv_videoio=OFF | |||||
| -DWITH_FFMPEG=OFF | |||||
| -DWITH_TIFF=ON | |||||
| -DBUILD_TIFF=OFF | |||||
| -DWITH_JASPER=OFF | |||||
| -DBUILD_JASPER=OFF | |||||
| -DTIFF_INCLUDE_DIR=${tiff_INC} | |||||
| -DTIFF_LIBRARY=${tiff_LIB}) | |||||
| elseif(WIN32) | |||||
| if("${BUILD_LITE}" STREQUAL "on" OR PYTHON_VERSION MATCHES "3.9") | if("${BUILD_LITE}" STREQUAL "on" OR PYTHON_VERSION MATCHES "3.9") | ||||
| mindspore_add_pkg(opencv | mindspore_add_pkg(opencv | ||||
| VER 4.5.1 | VER 4.5.1 | ||||
| @@ -149,7 +179,12 @@ else() | |||||
| endif() | endif() | ||||
| endif() | endif() | ||||
| if(WIN32) | |||||
| if(MSVC) | |||||
| include_directories(${opencv_INC}) | |||||
| add_library(mindspore::opencv_core ALIAS opencv::opencv_core451.lib) | |||||
| add_library(mindspore::opencv_imgcodecs ALIAS opencv::opencv_imgcodecs451.lib) | |||||
| add_library(mindspore::opencv_imgproc ALIAS opencv::opencv_imgproc451.lib) | |||||
| elseif(WIN32) | |||||
| if("${BUILD_LITE}" STREQUAL "on" OR PYTHON_VERSION MATCHES "3.9") | if("${BUILD_LITE}" STREQUAL "on" OR PYTHON_VERSION MATCHES "3.9") | ||||
| include_directories(${opencv_INC}) | include_directories(${opencv_INC}) | ||||
| add_library(mindspore::opencv_core ALIAS opencv::libopencv_core451.dll.a) | add_library(mindspore::opencv_core ALIAS opencv::libopencv_core451.dll.a) | ||||
| @@ -1,9 +1,18 @@ | |||||
| set(protobuf_USE_STATIC_LIBS ON) | set(protobuf_USE_STATIC_LIBS ON) | ||||
| if(BUILD_LITE) | if(BUILD_LITE) | ||||
| set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter \ | |||||
| -fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2") | |||||
| if(ENABLE_ACL) | |||||
| set(protobuf_CXXFLAGS "${protobuf_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0") | |||||
| if(MSVC) | |||||
| set(protobuf_CXXFLAGS "${CMAKE_CXX_FLAGS}") | |||||
| set(protobuf_CFLAGS "${CMAKE_C_FLAGS}") | |||||
| set(protobuf_LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}") | |||||
| set(_ms_tmp_CMAKE_STATIC_LIBRARY_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX}) | |||||
| set(CMAKE_STATIC_LIBRARY_PREFIX "lib") | |||||
| else() | |||||
| set(protobuf_CXXFLAGS "-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter \ | |||||
| -fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2") | |||||
| if(ENABLE_ACL) | |||||
| set(protobuf_CXXFLAGS "${protobuf_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0") | |||||
| endif() | |||||
| set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") | |||||
| endif() | endif() | ||||
| else() | else() | ||||
| if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||||
| @@ -19,9 +28,9 @@ else() | |||||
| set(protobuf_CXXFLAGS "${protobuf_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0") | set(protobuf_CXXFLAGS "${protobuf_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0") | ||||
| endif() | endif() | ||||
| endif() | endif() | ||||
| set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") | |||||
| endif() | endif() | ||||
| set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack") | |||||
| set(_ms_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) | set(_ms_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) | ||||
| set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS}) | set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS}) | ||||
| string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | ||||
| @@ -42,11 +51,14 @@ mindspore_add_pkg(protobuf | |||||
| URL ${REQ_URL} | URL ${REQ_URL} | ||||
| MD5 ${MD5} | MD5 ${MD5} | ||||
| CMAKE_PATH cmake/ | CMAKE_PATH cmake/ | ||||
| CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF) | |||||
| CMAKE_OPTION -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release) | |||||
| include_directories(${protobuf_INC}) | include_directories(${protobuf_INC}) | ||||
| add_library(mindspore::protobuf ALIAS protobuf::protobuf) | add_library(mindspore::protobuf ALIAS protobuf::protobuf) | ||||
| set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS}) | set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS}) | ||||
| if(MSVC) | |||||
| set(CMAKE_STATIC_LIBRARY_PREFIX, ${_ms_tmp_CMAKE_STATIC_LIBRARY_PREFIX}) | |||||
| endif() | |||||
| function(common_protobuf_generate path c_var h_var) | function(common_protobuf_generate path c_var h_var) | ||||
| if(NOT ARGN) | if(NOT ARGN) | ||||
| @@ -302,8 +302,8 @@ elseif(WIN32) | |||||
| file(GLOB LIB_LIST ${CXX_DIR}/libstdc++-6.dll ${CXX_DIR}/libwinpthread-1.dll | file(GLOB LIB_LIST ${CXX_DIR}/libstdc++-6.dll ${CXX_DIR}/libwinpthread-1.dll | ||||
| ${CXX_DIR}/libssp-0.dll ${CXX_DIR}/libgcc_s_*-1.dll) | ${CXX_DIR}/libssp-0.dll ${CXX_DIR}/libgcc_s_*-1.dll) | ||||
| if(MSLITE_ENABLE_CONVERTER) | if(MSLITE_ENABLE_CONVERTER) | ||||
| install(TARGETS converter_lite RUNTIME DESTINATION ${CONVERTER_ROOT_DIR}/converter | |||||
| COMPONENT ${RUNTIME_COMPONENT_NAME}) | |||||
| install(FILES ${TOP_DIR}/build/mindspore/tools/converter/converter_lite.exe | |||||
| DESTINATION ${CONVERTER_ROOT_DIR}/converter COMPONENT ${RUNTIME_COMPONENT_NAME}) | |||||
| install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${CONVERTER_ROOT_DIR}/include | install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${CONVERTER_ROOT_DIR}/include | ||||
| COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" | COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" | ||||
| PATTERN "train*" EXCLUDE PATTERN "delegate.h" EXCLUDE PATTERN "lite_session.h" EXCLUDE) | PATTERN "train*" EXCLUDE PATTERN "delegate.h" EXCLUDE PATTERN "lite_session.h" EXCLUDE) | ||||
| @@ -359,9 +359,10 @@ elseif(WIN32) | |||||
| ${opencv_LIBPATH}/../bin/libopencv_imgproc* | ${opencv_LIBPATH}/../bin/libopencv_imgproc* | ||||
| ) | ) | ||||
| install(FILES ${OPENCV_LIB_LIST} DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME}) | install(FILES ${OPENCV_LIB_LIST} DESTINATION ${CONVERTER_ROOT_DIR}/lib COMPONENT ${RUNTIME_COMPONENT_NAME}) | ||||
| __install_micro_wrapper() | |||||
| __install_micro_codegen() | |||||
| if(NOT MSVC) | |||||
| __install_micro_wrapper() | |||||
| __install_micro_codegen() | |||||
| endif() | |||||
| endif() | endif() | ||||
| if(MSLITE_ENABLE_TOOLS) | if(MSLITE_ENABLE_TOOLS) | ||||
| if(MSVC) | if(MSVC) | ||||
| @@ -27,16 +27,8 @@ | |||||
| #ifndef MS_API | #ifndef MS_API | ||||
| #ifdef _WIN32 | #ifdef _WIN32 | ||||
| #ifdef _MSC_VER | |||||
| #ifdef BUILDING_DLL | |||||
| #define MS_API __declspec(dllexport) | #define MS_API __declspec(dllexport) | ||||
| #else | #else | ||||
| #define MS_API __declspec(dllimport) | |||||
| #endif | |||||
| #else | |||||
| #define MS_API __declspec(dllexport) | |||||
| #endif | |||||
| #else | |||||
| #define MS_API __attribute__((visibility("default"))) | #define MS_API __attribute__((visibility("default"))) | ||||
| #endif | #endif | ||||
| #endif | #endif | ||||
| @@ -27,6 +27,10 @@ | |||||
| #include "utils/log_adapter.h" | #include "utils/log_adapter.h" | ||||
| #include "runtime/device/executor/dynamic_kernel.h" | #include "runtime/device/executor/dynamic_kernel.h" | ||||
| #ifdef _MSC_VER | |||||
| #undef OPAQUE | |||||
| #endif | |||||
| namespace mindspore { | namespace mindspore { | ||||
| enum KernelType : int { | enum KernelType : int { | ||||
| UNKNOWN_KERNEL_TYPE = 0, | UNKNOWN_KERNEL_TYPE = 0, | ||||
| @@ -3,7 +3,7 @@ include_directories(${CMAKE_BINARY_DIR}) | |||||
| include_directories(${CMAKE_SOURCE_DIR}/mindspore/core) | include_directories(${CMAKE_SOURCE_DIR}/mindspore/core) | ||||
| add_subdirectory(gvar) | add_subdirectory(gvar) | ||||
| if("${ENABLE_HIDDEN}" STREQUAL "OFF") | |||||
| if("${ENABLE_HIDDEN}" STREQUAL "OFF" AND NOT MSVC) | |||||
| string(REPLACE " -Werror " " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | string(REPLACE " -Werror " " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | ||||
| string(REPLACE " -fvisibility=hidden" " -fvisibility=default" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | string(REPLACE " -fvisibility=hidden" " -fvisibility=default" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | ||||
| endif() | endif() | ||||
| @@ -30,7 +30,7 @@ else() | |||||
| ms_protobuf_generate(PROTO_SRCS PROTO_HDRS ${PROTO_FILE}) | ms_protobuf_generate(PROTO_SRCS PROTO_HDRS ${PROTO_FILE}) | ||||
| endif() | endif() | ||||
| if(CMAKE_SYSTEM_NAME MATCHES "Windows") | |||||
| if(CMAKE_SYSTEM_NAME MATCHES "Windows" AND NOT MSVC) | |||||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes -DHAVE_SNPRINTF") | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes -DHAVE_SNPRINTF") | ||||
| add_compile_definitions(BUILDING_DLL) | add_compile_definitions(BUILDING_DLL) | ||||
| elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") | elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") | ||||
| @@ -51,13 +51,21 @@ class MS_CORE_API AbstractFuncUnion : public AbstractFunction { | |||||
| std::string ToString() const override; | std::string ToString() const override; | ||||
| AbstractFunctionPtr GetUnique() override { MS_LOG(EXCEPTION) << "Cannot get unique from AbstractFuncUnion"; } | |||||
| AbstractFunctionPtr GetUnique() override { | |||||
| MS_LOG(EXCEPTION) << "Cannot get unique from AbstractFuncUnion"; | |||||
| AbstractFunctionPtr result; | |||||
| return result; | |||||
| } | |||||
| bool IsSuperSet(const AbstractFunctionPtr &other); | bool IsSuperSet(const AbstractFunctionPtr &other); | ||||
| AbstractFunctionPtr Join(const AbstractFunctionPtr &other) final; | AbstractFunctionPtr Join(const AbstractFunctionPtr &other) final; | ||||
| void Visit(std::function<void(const AbstractFuncAtomPtr &)>) const final; | void Visit(std::function<void(const AbstractFuncAtomPtr &)>) const final; | ||||
| bool operator==(const AbstractFunction &other) const override; | bool operator==(const AbstractFunction &other) const override; | ||||
| std::size_t hash() const override; | std::size_t hash() const override; | ||||
| AbstractFunctionPtr Copy() const override { MS_LOG(EXCEPTION) << "Cannot Copy from AbstractFuncUnion"; } | |||||
| AbstractFunctionPtr Copy() const override { | |||||
| MS_LOG(EXCEPTION) << "Cannot Copy from AbstractFuncUnion"; | |||||
| AbstractFunctionPtr result; | |||||
| return result; | |||||
| } | |||||
| private: | private: | ||||
| AbstractFuncAtomPtrList func_list_; | AbstractFuncAtomPtrList func_list_; | ||||
| @@ -108,7 +108,8 @@ class Float16 { | |||||
| constexpr unsigned int exponent_bits = 13; | constexpr unsigned int exponent_bits = 13; | ||||
| constexpr unsigned int sign_bit_shift = 16; | constexpr unsigned int sign_bit_shift = 16; | ||||
| // Exponent/mantissa bits. | // Exponent/mantissa bits. | ||||
| Union32 f32{.u = (static_cast<uint32_t>(f16.value_ & value_mask) << exponent_bits)}; | |||||
| Union32 f32; | |||||
| f32.u = (static_cast<uint32_t>(f16.value_ & value_mask) << exponent_bits); | |||||
| // Just the exponent. | // Just the exponent. | ||||
| unsigned int exp = (shifted_exp & f32.u); | unsigned int exp = (shifted_exp & f32.u); | ||||
| f32.u += exponent_adjust; | f32.u += exponent_adjust; | ||||
| @@ -137,7 +138,8 @@ class Float16 { | |||||
| constexpr unsigned int sign_mask = 0x80000000u; | constexpr unsigned int sign_mask = 0x80000000u; | ||||
| constexpr uint32_t rouding_bias_part1 = ((unsigned int)(15 - 127) << 23) + 0xfff; | constexpr uint32_t rouding_bias_part1 = ((unsigned int)(15 - 127) << 23) + 0xfff; | ||||
| Union32 f{.f = f32}; | |||||
| Union32 f; | |||||
| f.f = f32; | |||||
| unsigned int sign = f.u & sign_mask; | unsigned int sign = f.u & sign_mask; | ||||
| f.u ^= sign; | f.u ^= sign; | ||||
| uint16_t result = 0; | uint16_t result = 0; | ||||
| @@ -1,12 +1,15 @@ | |||||
| file(GLOB_RECURSE MS_GVAR_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cc) | file(GLOB_RECURSE MS_GVAR_SRC_LIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cc) | ||||
| set_property(SOURCE ${MS_GVAR_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_COMMON) | set_property(SOURCE ${MS_GVAR_SRC_LIST} PROPERTY COMPILE_DEFINITIONS SUBMODULE_ID=mindspore::SubModuleId::SM_COMMON) | ||||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORTIFY_SOURCE=2 -O2") | |||||
| if(CMAKE_SYSTEM_NAME MATCHES "Windows") | |||||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes -DHAVE_SNPRINTF") | |||||
| add_compile_definitions(BUILDING_DLL) | |||||
| elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") | |||||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wuser-defined-warnings -Winconsistent-missing-override") | |||||
| if(NOT MSVC) | |||||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FORTIFY_SOURCE=2 -O2") | |||||
| if(CMAKE_SYSTEM_NAME MATCHES "Windows") | |||||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes -DHAVE_SNPRINTF") | |||||
| add_compile_definitions(BUILDING_DLL) | |||||
| elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") | |||||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wuser-defined-warnings -Winconsistent-missing-override") | |||||
| endif() | |||||
| endif() | endif() | ||||
| if(BUILD_LITE) | if(BUILD_LITE) | ||||
| @@ -13,8 +13,9 @@ | |||||
| * See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | ||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #ifndef _MSC_VER | |||||
| #include <sys/time.h> | #include <sys/time.h> | ||||
| #endif | |||||
| #include <string> | #include <string> | ||||
| #include "utils/log_adapter.h" | #include "utils/log_adapter.h" | ||||
| @@ -347,7 +347,7 @@ bool IsStateEquivalent(const AnfNodePtr &outer, const AnfNodePtr &inner) { | |||||
| outer_loads.merge(inner_loads); | outer_loads.merge(inner_loads); | ||||
| auto &monad = (*outer_loads.begin())->inputs().at(kMonadInput); | auto &monad = (*outer_loads.begin())->inputs().at(kMonadInput); | ||||
| return std::all_of(++outer_loads.begin(), outer_loads.end(), | return std::all_of(++outer_loads.begin(), outer_loads.end(), | ||||
| [&monad](const CNodePtr &load) { return load->inputs().at(kMonadInput) == monad; }); | |||||
| [&monad, kMonadInput](const CNodePtr &load) { return load->inputs().at(kMonadInput) == monad; }); | |||||
| } | } | ||||
| size_t NewSeenGeneration() { | size_t NewSeenGeneration() { | ||||
| @@ -452,7 +452,11 @@ class MS_CORE_API Value : public Base { | |||||
| MS_DECLARE_PARENT(Value, Base) | MS_DECLARE_PARENT(Value, Base) | ||||
| TypePtr type() const { return type_; } | TypePtr type() const { return type_; } | ||||
| virtual abstract::AbstractBasePtr ToAbstract() { MS_LOG(EXCEPTION) << "ToAbstract error"; } | |||||
| virtual abstract::AbstractBasePtr ToAbstract() { | |||||
| MS_LOG(EXCEPTION) << "ToAbstract error"; | |||||
| abstract::AbstractBasePtr result; | |||||
| return result; | |||||
| } | |||||
| virtual bool operator==(const Value &rhs) const = 0; | virtual bool operator==(const Value &rhs) const = 0; | ||||
| virtual Value &operator=(const Value &other) { | virtual Value &operator=(const Value &other) { | ||||
| @@ -47,7 +47,8 @@ Cloner::Cloner(const FuncGraphVector &func_graphs, bool clone_all_valuenodes, bo | |||||
| void Cloner::AddClone(const FuncGraphPtr &func_graph, const FuncGraphPtr &target_func_graph, | void Cloner::AddClone(const FuncGraphPtr &func_graph, const FuncGraphPtr &target_func_graph, | ||||
| const AnfNodePtrList ¶ms, CloneType type) { | const AnfNodePtrList ¶ms, CloneType type) { | ||||
| if (func_graph != nullptr) { | if (func_graph != nullptr) { | ||||
| todo_.push_back({.origin = func_graph, .target = target_func_graph, .params = params}); | |||||
| CloneInfo clone = {func_graph, target_func_graph, params}; | |||||
| todo_.push_back(clone); | |||||
| type_ = type; | type_ = type; | ||||
| } | } | ||||
| } | } | ||||
| @@ -112,7 +112,11 @@ class MS_CORE_API Primitive : public Named { | |||||
| void set_has_signature(bool has_signature) { has_signature_ = has_signature; } | void set_has_signature(bool has_signature) { has_signature_ = has_signature; } | ||||
| bool has_signature() const { return has_signature_; } | bool has_signature() const { return has_signature_; } | ||||
| bool is_base() const { return is_base_; } | bool is_base() const { return is_base_; } | ||||
| virtual BaseRef RunHookFunction(const VectorRef &args) const { MS_LOG(EXCEPTION) << "call a empty function!"; } | |||||
| virtual BaseRef RunHookFunction(const VectorRef &args) const { | |||||
| MS_LOG(EXCEPTION) << "call a empty function!"; | |||||
| BaseRef result; | |||||
| return result; | |||||
| } | |||||
| virtual void CopyHookFunction(const PrimitivePtr &primitive) { MS_LOG(EXCEPTION) << "call a empty function!"; } | virtual void CopyHookFunction(const PrimitivePtr &primitive) { MS_LOG(EXCEPTION) << "call a empty function!"; } | ||||
| void set_const_prim(bool is_const_prim) { is_const_prim_ = is_const_prim; } | void set_const_prim(bool is_const_prim) { is_const_prim_ = is_const_prim; } | ||||
| bool is_const_prim() const { return is_const_prim_; } | bool is_const_prim() const { return is_const_prim_; } | ||||
| @@ -15,7 +15,9 @@ | |||||
| */ | */ | ||||
| #include "utils/any.h" | #include "utils/any.h" | ||||
| #ifndef _MSC_VER | |||||
| #include <cxxabi.h> | #include <cxxabi.h> | ||||
| #endif | |||||
| #include <memory> | #include <memory> | ||||
| namespace mindspore { | namespace mindspore { | ||||
| @@ -142,7 +142,11 @@ class Any { | |||||
| } | } | ||||
| return buffer.str(); | return buffer.str(); | ||||
| } | } | ||||
| #ifdef _MSC_VER | |||||
| void dump() const { std::cout << ToString() << std::endl; } | |||||
| #else | |||||
| __attribute__((used)) void dump() const { std::cout << ToString() << std::endl; } | __attribute__((used)) void dump() const { std::cout << ToString() << std::endl; } | ||||
| #endif | |||||
| private: | private: | ||||
| struct Base; | struct Base; | ||||
| @@ -16,8 +16,10 @@ | |||||
| #include "utils/log_adapter.h" | #include "utils/log_adapter.h" | ||||
| #ifndef _MSC_VER | |||||
| #include <unistd.h> | #include <unistd.h> | ||||
| #include <sys/time.h> | #include <sys/time.h> | ||||
| #endif | |||||
| #include <map> | #include <map> | ||||
| #include <iomanip> | #include <iomanip> | ||||
| #include <thread> | #include <thread> | ||||
| @@ -119,7 +121,12 @@ void LogWriter::OutputLog(const std::ostringstream &msg) const { | |||||
| #define google mindspore_private | #define google mindspore_private | ||||
| auto submodule_name = GetSubModuleName(submodule_); | auto submodule_name = GetSubModuleName(submodule_); | ||||
| google::LogMessage("", 0, GetGlogLevel(log_level_)).stream() | google::LogMessage("", 0, GetGlogLevel(log_level_)).stream() | ||||
| #ifdef _MSC_VER | |||||
| << "[" << GetLogLevel(log_level_) << "] " << submodule_name << "(" | |||||
| << "," << std::hex | |||||
| #else | |||||
| << "[" << GetLogLevel(log_level_) << "] " << submodule_name << "(" << getpid() << "," << std::hex | << "[" << GetLogLevel(log_level_) << "] " << submodule_name << "(" << getpid() << "," << std::hex | ||||
| #endif | |||||
| << std::this_thread::get_id() << std::dec << "," << GetProcName() << "):" << GetTimeString() << " " | << std::this_thread::get_id() << std::dec << "," << GetProcName() << "):" << GetTimeString() << " " | ||||
| << "[" << location_.file_ << ":" << location_.line_ << "] " << location_.func_ << "] " << msg.str() << std::endl; | << "[" << location_.file_ << ":" << location_.line_ << "] " << location_.func_ << "] " << msg.str() << std::endl; | ||||
| #undef google | #undef google | ||||
| @@ -415,7 +422,11 @@ void InitSubModulesLogLevel() { | |||||
| extern "C" { | extern "C" { | ||||
| #if defined(_WIN32) || defined(_WIN64) | #if defined(_WIN32) || defined(_WIN64) | ||||
| #ifdef _MSC_VER | |||||
| void common_log_init(void) { | |||||
| #else | |||||
| __attribute__((constructor)) void common_log_init(void) { | __attribute__((constructor)) void common_log_init(void) { | ||||
| #endif | |||||
| #else | #else | ||||
| void common_log_init(void) { | void common_log_init(void) { | ||||
| #endif | #endif | ||||
| @@ -472,7 +483,11 @@ void common_log_init(void) { | |||||
| // shared lib init hook | // shared lib init hook | ||||
| #if defined(_WIN32) || defined(_WIN64) | #if defined(_WIN32) || defined(_WIN64) | ||||
| #ifdef _MSC_VER | |||||
| void mindspore_log_init(void) { | |||||
| #else | |||||
| __attribute__((constructor)) void mindspore_log_init(void) { | __attribute__((constructor)) void mindspore_log_init(void) { | ||||
| #endif | |||||
| #else | #else | ||||
| void mindspore_log_init(void) { | void mindspore_log_init(void) { | ||||
| #endif | #endif | ||||
| @@ -15,7 +15,9 @@ | |||||
| */ | */ | ||||
| #include "utils/misc.h" | #include "utils/misc.h" | ||||
| #ifndef _MSC_VER | |||||
| #include <cxxabi.h> | |||||
| #endif | |||||
| namespace mindspore { | namespace mindspore { | ||||
| const int RET_SUCCESS = 0; | const int RET_SUCCESS = 0; | ||||
| const int RET_FAILED = 1; | const int RET_FAILED = 1; | ||||
| @@ -23,8 +25,12 @@ const int RET_CONTINUE = 2; | |||||
| const int RET_BREAK = 3; | const int RET_BREAK = 3; | ||||
| std::string demangle(const char *name) { | std::string demangle(const char *name) { | ||||
| #ifdef _MSC_VER | |||||
| return name; | |||||
| #else | |||||
| int status = -1; | int status = -1; | ||||
| std::unique_ptr<char, void (*)(void *)> res{abi::__cxa_demangle(name, nullptr, nullptr, &status), std::free}; | std::unique_ptr<char, void (*)(void *)> res{abi::__cxa_demangle(name, nullptr, nullptr, &status), std::free}; | ||||
| return (status == 0) ? res.get() : name; | return (status == 0) ? res.get() : name; | ||||
| #endif | |||||
| } | } | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| @@ -17,7 +17,6 @@ | |||||
| #ifndef MINDSPORE_CORE_UTILS_MISC_H_ | #ifndef MINDSPORE_CORE_UTILS_MISC_H_ | ||||
| #define MINDSPORE_CORE_UTILS_MISC_H_ | #define MINDSPORE_CORE_UTILS_MISC_H_ | ||||
| #include <cxxabi.h> | |||||
| #include <list> | #include <list> | ||||
| #include <memory> | #include <memory> | ||||
| #include <string> | #include <string> | ||||
| @@ -15,8 +15,12 @@ | |||||
| */ | */ | ||||
| #include "utils/profile.h" | #include "utils/profile.h" | ||||
| #ifdef _MSC_VER | |||||
| #include <time.h> | |||||
| #else | |||||
| #include <sys/time.h> | #include <sys/time.h> | ||||
| #include <unistd.h> | #include <unistd.h> | ||||
| #endif | |||||
| #include <numeric> | #include <numeric> | ||||
| #include <cstdio> | #include <cstdio> | ||||
| #include <sstream> | #include <sstream> | ||||
| @@ -119,9 +123,13 @@ void PrintProfile(std::ostringstream &oss, const TimeInfo &time_info, int indent | |||||
| } // namespace | } // namespace | ||||
| double GetTime(void) { | double GetTime(void) { | ||||
| #ifdef _MSC_VER | |||||
| return time(NULL); | |||||
| #else | |||||
| struct timeval tv = {0, 0}; | struct timeval tv = {0, 0}; | ||||
| (void)gettimeofday(&tv, nullptr); | (void)gettimeofday(&tv, nullptr); | ||||
| return tv.tv_sec + tv.tv_usec * 1.0e-6; | return tv.tv_sec + tv.tv_usec * 1.0e-6; | ||||
| #endif | |||||
| } | } | ||||
| TimeInfo::~TimeInfo() { | TimeInfo::~TimeInfo() { | ||||
| @@ -34,16 +34,8 @@ | |||||
| #ifndef MS_API | #ifndef MS_API | ||||
| #ifdef _WIN32 | #ifdef _WIN32 | ||||
| #ifdef _MSC_VER | |||||
| #ifdef BUILDING_DLL | |||||
| #define MS_API __declspec(dllexport) | #define MS_API __declspec(dllexport) | ||||
| #else | #else | ||||
| #define MS_API __declspec(dllimport) | |||||
| #endif | |||||
| #else | |||||
| #define MS_API __declspec(dllexport) | |||||
| #endif | |||||
| #else | |||||
| #define MS_API __attribute__((visibility("default"))) | #define MS_API __attribute__((visibility("default"))) | ||||
| #endif | #endif | ||||
| #endif | #endif | ||||
| @@ -26,12 +26,12 @@ include_directories(${MICRO_DIR}) | |||||
| #include coder | #include coder | ||||
| if(NOT MSVC) | if(NOT MSVC) | ||||
| include(${TOP_DIR}/cmake/external_libs/cmsis.cmake) | include(${TOP_DIR}/cmake/external_libs/cmsis.cmake) | ||||
| include(${MICRO_DIR}/cmake/file_list.cmake) | |||||
| include(${MICRO_DIR}/cmake/package_wrapper.cmake) | include(${MICRO_DIR}/cmake/package_wrapper.cmake) | ||||
| add_subdirectory(wrapper) | add_subdirectory(wrapper) | ||||
| endif() | endif() | ||||
| if(MSLITE_ENABLE_CONVERTER) | if(MSLITE_ENABLE_CONVERTER) | ||||
| include(${MICRO_DIR}/cmake/file_list.cmake) | |||||
| add_executable(codegen main.cc ${FILE_SET}) | add_executable(codegen main.cc ${FILE_SET}) | ||||
| add_dependencies(codegen fbs_src) | add_dependencies(codegen fbs_src) | ||||
| add_dependencies(codegen fbs_inner_src) | add_dependencies(codegen fbs_inner_src) | ||||
| @@ -16,7 +16,9 @@ | |||||
| #include "tools/common/storage.h" | #include "tools/common/storage.h" | ||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||
| #ifndef _MSC_VER | |||||
| #include <unistd.h> | #include <unistd.h> | ||||
| #endif | |||||
| #include "flatbuffers/flatbuffers.h" | #include "flatbuffers/flatbuffers.h" | ||||
| #include "src/common/log_adapter.h" | #include "src/common/log_adapter.h" | ||||
| #include "src/common/file_utils.h" | #include "src/common/file_utils.h" | ||||
| @@ -38,9 +40,11 @@ int Storage::Save(const schema::MetaGraphT &graph, const std::string &outputPath | |||||
| if (filename.substr(filename.find_last_of(".") + 1) != "ms") { | if (filename.substr(filename.find_last_of(".") + 1) != "ms") { | ||||
| filename = filename + ".ms"; | filename = filename + ".ms"; | ||||
| } | } | ||||
| #ifndef _MSC_VER | |||||
| if (access(filename.c_str(), F_OK) == 0) { | if (access(filename.c_str(), F_OK) == 0) { | ||||
| chmod(filename.c_str(), S_IWUSR); | chmod(filename.c_str(), S_IWUSR); | ||||
| } | } | ||||
| #endif | |||||
| std::ofstream output(filename, std::ofstream::binary); | std::ofstream output(filename, std::ofstream::binary); | ||||
| if (!output.is_open()) { | if (!output.is_open()) { | ||||
| MS_LOG(ERROR) << "Can not open output file: " << filename; | MS_LOG(ERROR) << "Can not open output file: " << filename; | ||||
| @@ -49,7 +53,9 @@ int Storage::Save(const schema::MetaGraphT &graph, const std::string &outputPath | |||||
| output.write((const char *)content, size); | output.write((const char *)content, size); | ||||
| output.close(); | output.close(); | ||||
| #ifndef _MSC_VER | |||||
| chmod(filename.c_str(), S_IRUSR); | chmod(filename.c_str(), S_IRUSR); | ||||
| #endif | |||||
| return RET_OK; | return RET_OK; | ||||
| } | } | ||||
| @@ -21,7 +21,6 @@ | |||||
| #include <google/protobuf/io/zero_copy_stream_impl.h> | #include <google/protobuf/io/zero_copy_stream_impl.h> | ||||
| #include <google/protobuf/text_format.h> | #include <google/protobuf/text_format.h> | ||||
| #include <fcntl.h> | #include <fcntl.h> | ||||
| #include <unistd.h> | |||||
| #include <string> | #include <string> | ||||
| #include <vector> | #include <vector> | ||||
| #include <memory> | #include <memory> | ||||
| @@ -17,7 +17,9 @@ | |||||
| #ifndef MINDSPORE_LITE_TOOLS_CONVERTER_QUANTIZER_QUANTIZE_UTIL_H_ | #ifndef MINDSPORE_LITE_TOOLS_CONVERTER_QUANTIZER_QUANTIZE_UTIL_H_ | ||||
| #define MINDSPORE_LITE_TOOLS_CONVERTER_QUANTIZER_QUANTIZE_UTIL_H_ | #define MINDSPORE_LITE_TOOLS_CONVERTER_QUANTIZER_QUANTIZE_UTIL_H_ | ||||
| #ifndef _MSC_VER | |||||
| #include <dirent.h> | #include <dirent.h> | ||||
| #endif | |||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||
| #include <memory> | #include <memory> | ||||
| #include <string> | #include <string> | ||||
| @@ -3,6 +3,7 @@ file(GLOB CONVERT_REG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cc) | |||||
| file(GLOB KERNEL_REG_SRC ${KERNEL_REG_DIR}/*.cc) | file(GLOB KERNEL_REG_SRC ${KERNEL_REG_DIR}/*.cc) | ||||
| set(REG_SRC ${CONVERT_REG_SRC} | set(REG_SRC ${CONVERT_REG_SRC} | ||||
| ${KERNEL_REG_SRC} | ${KERNEL_REG_SRC} | ||||
| ${KERNEL_REG_DIR}/../cxx_api/context.cc | |||||
| ${KERNEL_REG_DIR}/../cxx_api/types.cc | ${KERNEL_REG_DIR}/../cxx_api/types.cc | ||||
| ${KERNEL_REG_DIR}/../cxx_api/tensor/tensor_impl.cc | ${KERNEL_REG_DIR}/../cxx_api/tensor/tensor_impl.cc | ||||
| ${KERNEL_REG_DIR}/../cxx_api/tensor_utils.cc | ${KERNEL_REG_DIR}/../cxx_api/tensor_utils.cc | ||||
| @@ -14,7 +14,9 @@ | |||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #include "backend/optimizer/common/pass_manager.h" | #include "backend/optimizer/common/pass_manager.h" | ||||
| #ifndef _MSC_VER | |||||
| #include <sys/time.h> | #include <sys/time.h> | ||||
| #endif | |||||
| #include <deque> | #include <deque> | ||||
| #include <string> | #include <string> | ||||
| #include <algorithm> | #include <algorithm> | ||||
| @@ -20,10 +20,10 @@ | |||||
| #include <vector> | #include <vector> | ||||
| #include <string> | #include <string> | ||||
| #include <unordered_map> | #include <unordered_map> | ||||
| #include "schema/model_generated.h" | |||||
| #include "backend/optimizer/common/optimizer.h" | #include "backend/optimizer/common/optimizer.h" | ||||
| #include "tools/optimizer/fisson/fisson_util.h" | #include "tools/optimizer/fisson/fisson_util.h" | ||||
| #include "tools/optimizer/parallel/split_strategy.h" | #include "tools/optimizer/parallel/split_strategy.h" | ||||
| #include "schema/model_generated.h" | |||||
| #include "tools/optimizer/parallel/multi_node_split.h" | #include "tools/optimizer/parallel/multi_node_split.h" | ||||
| using mindspore::schema::PrimitiveType; | using mindspore::schema::PrimitiveType; | ||||
| @@ -18,8 +18,8 @@ | |||||
| #define MINDSPORE_LITE_SRC_PASS_FUSION_AFFINE_ACTIVATION_FUSION_H_ | #define MINDSPORE_LITE_SRC_PASS_FUSION_AFFINE_ACTIVATION_FUSION_H_ | ||||
| #include <string> | #include <string> | ||||
| #include "backend/optimizer/common/optimizer.h" | |||||
| #include "schema/inner/model_generated.h" | #include "schema/inner/model_generated.h" | ||||
| #include "backend/optimizer/common/optimizer.h" | |||||
| namespace mindspore { | namespace mindspore { | ||||
| namespace opt { | namespace opt { | ||||
| @@ -13,13 +13,12 @@ | |||||
| * See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | ||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| #include "tools/optimizer/fusion/affine_fusion.h" | #include "tools/optimizer/fusion/affine_fusion.h" | ||||
| #include <memory> | #include <memory> | ||||
| #include <vector> | #include <vector> | ||||
| #include "schema/inner/model_generated.h" | |||||
| #include "ops/affine.h" | #include "ops/affine.h" | ||||
| #include "src/common/log_adapter.h" | #include "src/common/log_adapter.h" | ||||
| #include "schema/inner/model_generated.h" | |||||
| #include "ops/splice.h" | #include "ops/splice.h" | ||||
| #include "ops/mat_mul.h" | #include "ops/mat_mul.h" | ||||
| #include "tools/optimizer/common/gllo_utils.h" | #include "tools/optimizer/common/gllo_utils.h" | ||||
| @@ -18,6 +18,7 @@ | |||||
| #define MINDSPORE_LITE_SRC_PASS_FUSION_CONV_CONV_FUSION_H_ | #define MINDSPORE_LITE_SRC_PASS_FUSION_CONV_CONV_FUSION_H_ | ||||
| #include <string> | #include <string> | ||||
| #include "schema/inner/model_generated.h" | |||||
| #include "backend/optimizer/common/optimizer.h" | #include "backend/optimizer/common/optimizer.h" | ||||
| namespace mindspore { | namespace mindspore { | ||||
| @@ -18,8 +18,8 @@ | |||||
| #define MINDSPORE_LITE_SRC_PASS_GRAPH_ADD_TENSOR_ARRAY_H_ | #define MINDSPORE_LITE_SRC_PASS_GRAPH_ADD_TENSOR_ARRAY_H_ | ||||
| #include <string> | #include <string> | ||||
| #include "backend/optimizer/common/optimizer.h" | |||||
| #include "schema/inner/model_generated.h" | #include "schema/inner/model_generated.h" | ||||
| #include "backend/optimizer/common/optimizer.h" | |||||
| namespace mindspore { | namespace mindspore { | ||||
| namespace opt { | namespace opt { | ||||