support windows benchmark dynalic link

This commit is contained in:
liuyu 2020-10-30 09:46:53 +08:00
parent 9fc0218c56
commit 73718f2681
8 changed files with 45 additions and 61 deletions

View File

@ -20,11 +20,6 @@ set(OPENCV_DIR_RUN_X86 ${MAIN_DIR}-${RUN_X86_COMPONENT_NAME}/minddata/third_part
set(PROTOBF_DIR_RUN_X86 ${MAIN_DIR}-${RUN_X86_COMPONENT_NAME}/third_party/protobuf)
set(FLATBF_DIR_RUN_X86 ${MAIN_DIR}-${RUN_X86_COMPONENT_NAME}/third_party/flatbuffers)
set(WIN_INC_DIR_RUN_X86 ${MAIN_DIR}-${WIN_RUN_X86_NAME}/include)
set(WIN_X86_BENCHMARK_DIR ${MAIN_DIR}-${WIN_RUN_X86_NAME}/benchmark)
set(WIN_FLATBF_DIR_RUN_X86 ${MAIN_DIR}-${WIN_RUN_X86_NAME}/third_party/flatbuffers)
set(WIN_LIB_DIR_RUN_X86 ${MAIN_DIR}-${WIN_RUN_X86_NAME}/lib)
if (BUILD_MINDDATA STREQUAL "full")
install(DIRECTORY ${TOP_DIR}/mindspore/ccsrc/minddata/dataset/include/ DESTINATION ${MIND_DATA_INC_DIR} COMPONENT ${COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
if (PLATFORM_ARM64)
@ -81,6 +76,9 @@ if (PLATFORM_ARM64)
install(FILES ${TOP_DIR}/mindspore/lite/build/src/libmindspore-lite-optimize.so DESTINATION ${LIB_DIR} COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/mindspore/lite/build/src/libmindspore-lite-fp16.so DESTINATION ${LIB_DIR} COMPONENT ${COMPONENT_NAME})
install(DIRECTORY ${flatbuffers_INC} DESTINATION ${FLATBF_DIR} COMPONENT ${COMPONENT_NAME})
if (ENABLE_TOOLS)
install(TARGETS benchmark RUNTIME DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/benchmark COMPONENT ${COMPONENT_NAME})
endif()
elseif (PLATFORM_ARM32)
install(FILES ${TOP_DIR}/mindspore/lite/build/src/libmindspore-lite.so DESTINATION ${LIB_DIR} COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/mindspore/lite/build/src/libmindspore-lite.a DESTINATION ${LIB_DIR} COMPONENT ${COMPONENT_NAME})
@ -88,25 +86,32 @@ elseif (PLATFORM_ARM32)
install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${INC_DIR} COMPONENT ${COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${TOP_DIR}/mindspore/lite/build/schema/ DESTINATION ${INC_DIR}/schema COMPONENT ${COMPONENT_NAME} FILES_MATCHING PATTERN "*.h" PATTERN "inner" EXCLUDE)
install(DIRECTORY ${flatbuffers_INC} DESTINATION ${FLATBF_DIR} COMPONENT ${COMPONENT_NAME})
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
if (ENABLE_TOOLS)
install(TARGETS benchmark RUNTIME DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/benchmark COMPONENT ${COMPONENT_NAME})
endif()
elseif (WIN32)
get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH)
file(GLOB LIB_LIST ${CXX_DIR}/libstdc++-6.dll ${CXX_DIR}/libwinpthread-1.dll ${CXX_DIR}/libssp-0.dll ${CXX_DIR}/libgcc_s_seh-1.dll)
install(FILES ${LIB_LIST} DESTINATION ${TOP_DIR}/build/mindspore/package COMPONENT ${COMPONENT_NAME})
if (ENABLE_CONVERTER)
install(TARGETS converter_lite RUNTIME DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/converter COMPONENT ${COMPONENT_NAME})
install(FILES ${LIB_LIST} DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/converter COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/build/mindspore/tools/converter/mindspore_core/gvar/libmindspore_gvar.dll DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/converter COMPONENT ${COMPONENT_NAME})
install(FILES ${glog_LIBPATH}/../bin/libglog.dll DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/converter COMPONENT ${COMPONENT_NAME})
endif ()
install(FILES ${LIB_LIST} DESTINATION ${WIN_X86_BENCHMARK_DIR} COMPONENT ${WIN_RUN_X86_NAME})
install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${WIN_INC_DIR_RUN_X86} COMPONENT ${WIN_RUN_X86_NAME} FILES_MATCHING PATTERN "*.h")
install(FILES ${TOP_DIR}/build/mindspore/schema/model_generated.h DESTINATION ${WIN_INC_DIR_RUN_X86}/schema COMPONENT ${WIN_RUN_X86_NAME})
install(FILES ${TOP_DIR}/build/mindspore/schema/ops_generated.h DESTINATION ${WIN_INC_DIR_RUN_X86}/schema COMPONENT ${WIN_RUN_X86_NAME})
install(FILES ${TOP_DIR}/mindspore/core/ir/dtype/type_id.h DESTINATION ${WIN_INC_DIR_RUN_X86}/ir/dtype COMPONENT ${WIN_RUN_X86_NAME})
install(DIRECTORY ${flatbuffers_INC} DESTINATION ${WIN_FLATBF_DIR_RUN_X86} COMPONENT ${WIN_RUN_X86_NAME})
install(FILES ${TOP_DIR}/build/mindspore/src/libmindspore-lite.a DESTINATION ${WIN_LIB_DIR_RUN_X86} COMPONENT ${WIN_RUN_X86_NAME})
install(FILES ${TOP_DIR}/build/mindspore/src/libmindspore-lite.dll.a DESTINATION ${WIN_LIB_DIR_RUN_X86} COMPONENT ${WIN_RUN_X86_NAME})
install(FILES ${TOP_DIR}/build/mindspore/src/libmindspore-lite.dll DESTINATION ${WIN_LIB_DIR_RUN_X86} COMPONENT ${WIN_RUN_X86_NAME})
if (ENABLE_TOOLS)
install(TARGETS benchmark RUNTIME DESTINATION ${MAIN_DIR}-${WIN_RUN_X86_NAME}/benchmark COMPONENT ${WIN_RUN_X86_NAME})
install(FILES ${LIB_LIST} DESTINATION ${MAIN_DIR}-${WIN_RUN_X86_NAME}/benchmark COMPONENT ${WIN_RUN_X86_NAME})
install(DIRECTORY ${flatbuffers_INC} DESTINATION ${MAIN_DIR}-${WIN_RUN_X86_NAME}/third_party/flatbuffers COMPONENT ${WIN_RUN_X86_NAME})
set(WIN_INC_DIR_RUN_X86 ${MAIN_DIR}-${WIN_RUN_X86_NAME}/include)
install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${WIN_INC_DIR_RUN_X86} COMPONENT ${WIN_RUN_X86_NAME} FILES_MATCHING PATTERN "*.h")
install(FILES ${TOP_DIR}/build/mindspore/schema/model_generated.h DESTINATION ${WIN_INC_DIR_RUN_X86}/schema COMPONENT ${WIN_RUN_X86_NAME})
install(FILES ${TOP_DIR}/build/mindspore/schema/ops_generated.h DESTINATION ${WIN_INC_DIR_RUN_X86}/schema COMPONENT ${WIN_RUN_X86_NAME})
install(FILES ${TOP_DIR}/mindspore/core/ir/dtype/type_id.h DESTINATION ${WIN_INC_DIR_RUN_X86}/ir/dtype COMPONENT ${WIN_RUN_X86_NAME})
set(WIN_LIB_DIR_RUN_X86 ${MAIN_DIR}-${WIN_RUN_X86_NAME}/benchmark)
install(FILES ${TOP_DIR}/build/mindspore/src/libmindspore-lite.a DESTINATION ${WIN_LIB_DIR_RUN_X86} COMPONENT ${WIN_RUN_X86_NAME})
install(FILES ${TOP_DIR}/build/mindspore/src/libmindspore-lite.dll.a DESTINATION ${WIN_LIB_DIR_RUN_X86} COMPONENT ${WIN_RUN_X86_NAME})
install(FILES ${TOP_DIR}/build/mindspore/src/libmindspore-lite.dll DESTINATION ${WIN_LIB_DIR_RUN_X86} COMPONENT ${WIN_RUN_X86_NAME})
endif()
else ()
install(DIRECTORY ${TOP_DIR}/mindspore/lite/include/ DESTINATION ${INC_DIR_RUN_X86} COMPONENT ${RUN_X86_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h")
install(FILES ${TOP_DIR}/mindspore/lite/build/schema/model_generated.h DESTINATION ${INC_DIR_RUN_X86}/schema COMPONENT ${RUN_X86_COMPONENT_NAME})
@ -115,6 +120,14 @@ else ()
install(DIRECTORY ${flatbuffers_INC} DESTINATION ${FLATBF_DIR_RUN_X86} COMPONENT ${RUN_X86_COMPONENT_NAME})
install(FILES ${TOP_DIR}/mindspore/lite/build/src/libmindspore-lite.so DESTINATION ${LIB_DIR_RUN_X86} COMPONENT ${RUN_X86_COMPONENT_NAME})
install(FILES ${TOP_DIR}/mindspore/lite/build/src/libmindspore-lite.a DESTINATION ${LIB_DIR_RUN_X86} COMPONENT ${RUN_X86_COMPONENT_NAME})
if (ENABLE_CONVERTER)
install(TARGETS converter_lite RUNTIME DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/converter COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/mindspore/lite/build/tools/converter/mindspore_core/gvar/libmindspore_gvar.so DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${glog_LIBPATH}/libglog.so.0.4.0 DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/third_party/glog/lib RENAME libglog.so.0 COMPONENT ${COMPONENT_NAME})
endif()
if (ENABLE_TOOLS)
install(TARGETS benchmark RUNTIME DESTINATION ${MAIN_DIR}-${RUN_X86_COMPONENT_NAME}/benchmark COMPONENT ${RUN_X86_COMPONENT_NAME})
endif()
endif ()
if (CMAKE_SYSTEM_NAME MATCHES "Windows")

View File

@ -44,7 +44,7 @@ using AllocatorPtr = std::shared_ptr<Allocator>;
/// \param[out] MSTensor.
///
/// \return STATUS as an error code of this interface, STATUS is defined in errorcode.h.
int StringsToMSTensor(const std::vector<std::string> &inputs, tensor::MSTensor *tensor);
int MS_API StringsToMSTensor(const std::vector<std::string> &inputs, tensor::MSTensor *tensor);
/// \brief Get string vector from MSTensor.
/// \param[in] MSTensor.

View File

@ -20,7 +20,7 @@
namespace mindspore::lite {
class PrimitiveC;
struct Model {
struct MS_API Model {
struct Node {
String name_;
NodeType node_type_;

View File

@ -24,8 +24,13 @@
#include <vector>
#include "ir/dtype/type_id.h"
namespace mindspore {
#ifdef _WIN32
#define MS_API __declspec(dllexport)
#else
#define MS_API __attribute__((visibility("default")))
#endif
namespace mindspore {
namespace tensor {
/// \brief MSTensor defined tensor in MindSpore Lite.
class MS_API MSTensor {

View File

@ -81,7 +81,11 @@ class LogWriter {
~LogWriter() = default;
#ifdef _WIN32
void operator<(const LogStream &stream) const noexcept __declspec(dllexport);
#else
void operator<(const LogStream &stream) const noexcept __attribute__((visibility("default")));
#endif
private:
void OutputLog(const std::ostringstream &msg) const;

View File

@ -24,6 +24,7 @@
#include "src/common/log_adapter.h"
#include "tools/common/option.h"
#include "include/errorcode.h"
#include "include/lite_utils.h"
namespace mindspore {
namespace lite {

View File

@ -9,30 +9,11 @@ add_executable(benchmark
${CMAKE_CURRENT_SOURCE_DIR}/main.cc
${CMAKE_CURRENT_SOURCE_DIR}/benchmark.cc
${COMMON_SRC})
if (WIN32)
add_dependencies(benchmark fbs_src mindspore-lite_static)
else ()
add_dependencies(benchmark fbs_src)
endif ()
add_dependencies(benchmark fbs_src)
if (PLATFORM_ARM32 OR PLATFORM_ARM64)
target_link_libraries(benchmark mindspore-lite)
else()
if (WIN32)
target_link_libraries(benchmark mindspore-lite_static pthread cpu_kernel_mid nnacl_mid cpu_ops_mid)
else ()
target_link_libraries(benchmark mindspore-lite pthread)
endif ()
endif()
if (PLATFORM_ARM32 OR PLATFORM_ARM64)
install(TARGETS benchmark
RUNTIME DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/benchmark COMPONENT ${COMPONENT_NAME})
else()
if (WIN32)
install(TARGETS benchmark
RUNTIME DESTINATION ${MAIN_DIR}-${WIN_RUN_X86_NAME}/benchmark COMPONENT ${WIN_RUN_X86_NAME})
else ()
install(TARGETS benchmark
RUNTIME DESTINATION ${MAIN_DIR}-${RUN_X86_COMPONENT_NAME}/benchmark COMPONENT ${RUN_X86_COMPONENT_NAME})
endif ()
target_link_libraries(benchmark mindspore-lite pthread)
endif()

View File

@ -150,23 +150,3 @@ target_link_libraries(converter_lite PRIVATE
mindspore::flatbuffers
pthread
)
if (NOT PLATFORM_ARM64 AND NOT PLATFORM_ARM32)
install(TARGETS converter_lite
RUNTIME DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/converter COMPONENT ${COMPONENT_NAME})
if (WIN32)
get_filename_component(CXX_DIR ${CMAKE_CXX_COMPILER} PATH)
file(GLOB LIB_LIST ${CXX_DIR}/libstdc++-6.dll ${CXX_DIR}/libwinpthread-1.dll ${CXX_DIR}/libssp-0.dll ${CXX_DIR}/libgcc_s_seh-1.dll)
install(FILES ${LIB_LIST} DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/converter COMPONENT ${COMPONENT_NAME})
install(FILES ${TOP_DIR}/build/mindspore/tools/converter/mindspore_core/gvar/libmindspore_gvar.dll
DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/converter COMPONENT ${COMPONENT_NAME})
install(FILES ${glog_LIBPATH}/../bin/libglog.dll
DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/converter COMPONENT ${COMPONENT_NAME})
else ()
install(FILES ${TOP_DIR}/mindspore/lite/build/tools/converter/mindspore_core/gvar/libmindspore_gvar.so
DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/lib COMPONENT ${COMPONENT_NAME})
install(FILES ${glog_LIBPATH}/libglog.so.0.4.0
DESTINATION ${MAIN_DIR}-${COMPONENT_NAME}/third_party/glog/lib RENAME libglog.so.0 COMPONENT ${COMPONENT_NAME})
endif ()
endif ()