Browse Source

vs build converter

tags/v1.5.0-rc1
sunsuodong 4 years ago
parent
commit
062dcaaaa1
33 changed files with 171 additions and 61 deletions
  1. +12
    -5
      cmake/external_libs/glog.cmake
  2. +38
    -3
      cmake/external_libs/opencv.cmake
  3. +18
    -6
      cmake/external_libs/protobuf.cmake
  4. +6
    -5
      cmake/package_lite.cmake
  5. +0
    -8
      include/api/types.h
  6. +4
    -0
      mindspore/ccsrc/backend/kernel_compiler/kernel.h
  7. +2
    -2
      mindspore/core/CMakeLists.txt
  8. +10
    -2
      mindspore/core/abstract/abstract_function.h
  9. +4
    -2
      mindspore/core/base/float16.h
  10. +9
    -6
      mindspore/core/gvar/CMakeLists.txt
  11. +2
    -1
      mindspore/core/gvar/log_adapter_common.cc
  12. +1
    -1
      mindspore/core/ir/anf.cc
  13. +5
    -1
      mindspore/core/ir/anf.h
  14. +2
    -1
      mindspore/core/ir/func_graph_cloner.cc
  15. +5
    -1
      mindspore/core/ir/primitive.h
  16. +2
    -0
      mindspore/core/utils/any.cc
  17. +4
    -0
      mindspore/core/utils/any.h
  18. +15
    -0
      mindspore/core/utils/log_adapter.cc
  19. +7
    -1
      mindspore/core/utils/misc.cc
  20. +0
    -1
      mindspore/core/utils/misc.h
  21. +8
    -0
      mindspore/core/utils/profile.cc
  22. +0
    -8
      mindspore/lite/include/lite_utils.h
  23. +1
    -1
      mindspore/lite/micro/coder/CMakeLists.txt
  24. +6
    -0
      mindspore/lite/tools/common/storage.cc
  25. +0
    -1
      mindspore/lite/tools/converter/parser/onnx/onnx_model_parser.h
  26. +2
    -0
      mindspore/lite/tools/converter/quantizer/quantize_util.h
  27. +1
    -0
      mindspore/lite/tools/converter/registry/CMakeLists.txt
  28. +2
    -0
      mindspore/lite/tools/optimizer/common/pass_manager_extends.cc
  29. +1
    -1
      mindspore/lite/tools/optimizer/fisson/multi_conv_split_pass.h
  30. +1
    -1
      mindspore/lite/tools/optimizer/fusion/affine_activation_fusion.h
  31. +1
    -2
      mindspore/lite/tools/optimizer/fusion/affine_fusion.cc
  32. +1
    -0
      mindspore/lite/tools/optimizer/fusion/conv_conv_fusion.h
  33. +1
    -1
      mindspore/lite/tools/optimizer/graph/add_tensor_array.h

+ 12
- 5
cmake/external_libs/glog.cmake View File

@@ -1,7 +1,13 @@
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_lib glog)
else()
@@ -23,9 +29,10 @@ else()
set(MD5 "0daea8785e6df922d7887755c3d100d0")
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
OUTPUT_VARIABLE i686_or_x86_64
)


+ 38
- 3
cmake/external_libs/opencv.cmake View File

@@ -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_CFLAGS "-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2")
set(opencv_LDFLAGS "-Wl")
@@ -41,7 +45,33 @@ else()
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")
mindspore_add_pkg(opencv
VER 4.5.1
@@ -149,7 +179,12 @@ else()
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")
include_directories(${opencv_INC})
add_library(mindspore::opencv_core ALIAS opencv::libopencv_core451.dll.a)


+ 18
- 6
cmake/external_libs/protobuf.cmake View File

@@ -1,9 +1,18 @@
set(protobuf_USE_STATIC_LIBS ON)
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()
else()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
@@ -19,9 +28,9 @@ else()
set(protobuf_CXXFLAGS "${protobuf_CXXFLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
endif()
endif()
set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
endif()

set(protobuf_LDFLAGS "-Wl,-z,relro,-z,now,-z,noexecstack")
set(_ms_tmp_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS ${_ms_tmp_CMAKE_CXX_FLAGS})
string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
@@ -42,11 +51,14 @@ mindspore_add_pkg(protobuf
URL ${REQ_URL}
MD5 ${MD5}
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})
add_library(mindspore::protobuf ALIAS protobuf::protobuf)
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)
if(NOT ARGN)


+ 6
- 5
cmake/package_lite.cmake View File

@@ -302,8 +302,8 @@ elseif(WIN32)
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)
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
COMPONENT ${RUNTIME_COMPONENT_NAME} FILES_MATCHING PATTERN "*.h"
PATTERN "train*" EXCLUDE PATTERN "delegate.h" EXCLUDE PATTERN "lite_session.h" EXCLUDE)
@@ -359,9 +359,10 @@ elseif(WIN32)
${opencv_LIBPATH}/../bin/libopencv_imgproc*
)
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()
if(MSLITE_ENABLE_TOOLS)
if(MSVC)


+ 0
- 8
include/api/types.h View File

@@ -27,16 +27,8 @@

#ifndef MS_API
#ifdef _WIN32
#ifdef _MSC_VER
#ifdef BUILDING_DLL
#define MS_API __declspec(dllexport)
#else
#define MS_API __declspec(dllimport)
#endif
#else
#define MS_API __declspec(dllexport)
#endif
#else
#define MS_API __attribute__((visibility("default")))
#endif
#endif


+ 4
- 0
mindspore/ccsrc/backend/kernel_compiler/kernel.h View File

@@ -27,6 +27,10 @@
#include "utils/log_adapter.h"
#include "runtime/device/executor/dynamic_kernel.h"

#ifdef _MSC_VER
#undef OPAQUE
#endif

namespace mindspore {
enum KernelType : int {
UNKNOWN_KERNEL_TYPE = 0,


+ 2
- 2
mindspore/core/CMakeLists.txt View File

@@ -3,7 +3,7 @@ include_directories(${CMAKE_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/mindspore/core)
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 " -fvisibility=hidden" " -fvisibility=default" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
@@ -30,7 +30,7 @@ else()
ms_protobuf_generate(PROTO_SRCS PROTO_HDRS ${PROTO_FILE})
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")
add_compile_definitions(BUILDING_DLL)
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")


+ 10
- 2
mindspore/core/abstract/abstract_function.h View File

@@ -51,13 +51,21 @@ class MS_CORE_API AbstractFuncUnion : public AbstractFunction {

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);
AbstractFunctionPtr Join(const AbstractFunctionPtr &other) final;
void Visit(std::function<void(const AbstractFuncAtomPtr &)>) const final;
bool operator==(const AbstractFunction &other) 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:
AbstractFuncAtomPtrList func_list_;


+ 4
- 2
mindspore/core/base/float16.h View File

@@ -108,7 +108,8 @@ class Float16 {
constexpr unsigned int exponent_bits = 13;
constexpr unsigned int sign_bit_shift = 16;
// 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.
unsigned int exp = (shifted_exp & f32.u);
f32.u += exponent_adjust;
@@ -137,7 +138,8 @@ class Float16 {
constexpr unsigned int sign_mask = 0x80000000u;
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;
f.u ^= sign;
uint16_t result = 0;


+ 9
- 6
mindspore/core/gvar/CMakeLists.txt View File

@@ -1,12 +1,15 @@
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(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()

if(BUILD_LITE)


+ 2
- 1
mindspore/core/gvar/log_adapter_common.cc View File

@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _MSC_VER
#include <sys/time.h>
#endif
#include <string>
#include "utils/log_adapter.h"



+ 1
- 1
mindspore/core/ir/anf.cc View File

@@ -347,7 +347,7 @@ bool IsStateEquivalent(const AnfNodePtr &outer, const AnfNodePtr &inner) {
outer_loads.merge(inner_loads);
auto &monad = (*outer_loads.begin())->inputs().at(kMonadInput);
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() {


+ 5
- 1
mindspore/core/ir/anf.h View File

@@ -452,7 +452,11 @@ class MS_CORE_API Value : public Base {
MS_DECLARE_PARENT(Value, Base)

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 Value &operator=(const Value &other) {


+ 2
- 1
mindspore/core/ir/func_graph_cloner.cc View File

@@ -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,
const AnfNodePtrList &params, CloneType type) {
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;
}
}


+ 5
- 1
mindspore/core/ir/primitive.h View File

@@ -112,7 +112,11 @@ class MS_CORE_API Primitive : public Named {
void set_has_signature(bool has_signature) { has_signature_ = has_signature; }
bool has_signature() const { return has_signature_; }
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!"; }
void set_const_prim(bool is_const_prim) { is_const_prim_ = is_const_prim; }
bool is_const_prim() const { return is_const_prim_; }


+ 2
- 0
mindspore/core/utils/any.cc View File

@@ -15,7 +15,9 @@
*/

#include "utils/any.h"
#ifndef _MSC_VER
#include <cxxabi.h>
#endif
#include <memory>

namespace mindspore {


+ 4
- 0
mindspore/core/utils/any.h View File

@@ -142,7 +142,11 @@ class Any {
}
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; }
#endif

private:
struct Base;


+ 15
- 0
mindspore/core/utils/log_adapter.cc View File

@@ -16,8 +16,10 @@

#include "utils/log_adapter.h"

#ifndef _MSC_VER
#include <unistd.h>
#include <sys/time.h>
#endif
#include <map>
#include <iomanip>
#include <thread>
@@ -119,7 +121,12 @@ void LogWriter::OutputLog(const std::ostringstream &msg) const {
#define google mindspore_private
auto submodule_name = GetSubModuleName(submodule_);
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
#endif
<< std::this_thread::get_id() << std::dec << "," << GetProcName() << "):" << GetTimeString() << " "
<< "[" << location_.file_ << ":" << location_.line_ << "] " << location_.func_ << "] " << msg.str() << std::endl;
#undef google
@@ -415,7 +422,11 @@ void InitSubModulesLogLevel() {

extern "C" {
#if defined(_WIN32) || defined(_WIN64)
#ifdef _MSC_VER
void common_log_init(void) {
#else
__attribute__((constructor)) void common_log_init(void) {
#endif
#else
void common_log_init(void) {
#endif
@@ -472,7 +483,11 @@ void common_log_init(void) {

// shared lib init hook
#if defined(_WIN32) || defined(_WIN64)
#ifdef _MSC_VER
void mindspore_log_init(void) {
#else
__attribute__((constructor)) void mindspore_log_init(void) {
#endif
#else
void mindspore_log_init(void) {
#endif


+ 7
- 1
mindspore/core/utils/misc.cc View File

@@ -15,7 +15,9 @@
*/

#include "utils/misc.h"

#ifndef _MSC_VER
#include <cxxabi.h>
#endif
namespace mindspore {
const int RET_SUCCESS = 0;
const int RET_FAILED = 1;
@@ -23,8 +25,12 @@ const int RET_CONTINUE = 2;
const int RET_BREAK = 3;

std::string demangle(const char *name) {
#ifdef _MSC_VER
return name;
#else
int status = -1;
std::unique_ptr<char, void (*)(void *)> res{abi::__cxa_demangle(name, nullptr, nullptr, &status), std::free};
return (status == 0) ? res.get() : name;
#endif
}
} // namespace mindspore

+ 0
- 1
mindspore/core/utils/misc.h View File

@@ -17,7 +17,6 @@
#ifndef MINDSPORE_CORE_UTILS_MISC_H_
#define MINDSPORE_CORE_UTILS_MISC_H_

#include <cxxabi.h>
#include <list>
#include <memory>
#include <string>


+ 8
- 0
mindspore/core/utils/profile.cc View File

@@ -15,8 +15,12 @@
*/

#include "utils/profile.h"
#ifdef _MSC_VER
#include <time.h>
#else
#include <sys/time.h>
#include <unistd.h>
#endif
#include <numeric>
#include <cstdio>
#include <sstream>
@@ -119,9 +123,13 @@ void PrintProfile(std::ostringstream &oss, const TimeInfo &time_info, int indent
} // namespace

double GetTime(void) {
#ifdef _MSC_VER
return time(NULL);
#else
struct timeval tv = {0, 0};
(void)gettimeofday(&tv, nullptr);
return tv.tv_sec + tv.tv_usec * 1.0e-6;
#endif
}

TimeInfo::~TimeInfo() {


+ 0
- 8
mindspore/lite/include/lite_utils.h View File

@@ -34,16 +34,8 @@

#ifndef MS_API
#ifdef _WIN32
#ifdef _MSC_VER
#ifdef BUILDING_DLL
#define MS_API __declspec(dllexport)
#else
#define MS_API __declspec(dllimport)
#endif
#else
#define MS_API __declspec(dllexport)
#endif
#else
#define MS_API __attribute__((visibility("default")))
#endif
#endif


+ 1
- 1
mindspore/lite/micro/coder/CMakeLists.txt View File

@@ -26,12 +26,12 @@ include_directories(${MICRO_DIR})
#include coder
if(NOT MSVC)
include(${TOP_DIR}/cmake/external_libs/cmsis.cmake)
include(${MICRO_DIR}/cmake/file_list.cmake)
include(${MICRO_DIR}/cmake/package_wrapper.cmake)
add_subdirectory(wrapper)
endif()

if(MSLITE_ENABLE_CONVERTER)
include(${MICRO_DIR}/cmake/file_list.cmake)
add_executable(codegen main.cc ${FILE_SET})
add_dependencies(codegen fbs_src)
add_dependencies(codegen fbs_inner_src)


+ 6
- 0
mindspore/lite/tools/common/storage.cc View File

@@ -16,7 +16,9 @@

#include "tools/common/storage.h"
#include <sys/stat.h>
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include "flatbuffers/flatbuffers.h"
#include "src/common/log_adapter.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") {
filename = filename + ".ms";
}
#ifndef _MSC_VER
if (access(filename.c_str(), F_OK) == 0) {
chmod(filename.c_str(), S_IWUSR);
}
#endif
std::ofstream output(filename, std::ofstream::binary);
if (!output.is_open()) {
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.close();
#ifndef _MSC_VER
chmod(filename.c_str(), S_IRUSR);
#endif
return RET_OK;
}



+ 0
- 1
mindspore/lite/tools/converter/parser/onnx/onnx_model_parser.h View File

@@ -21,7 +21,6 @@
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/text_format.h>
#include <fcntl.h>
#include <unistd.h>
#include <string>
#include <vector>
#include <memory>


+ 2
- 0
mindspore/lite/tools/converter/quantizer/quantize_util.h View File

@@ -17,7 +17,9 @@
#ifndef MINDSPORE_LITE_TOOLS_CONVERTER_QUANTIZER_QUANTIZE_UTIL_H_
#define MINDSPORE_LITE_TOOLS_CONVERTER_QUANTIZER_QUANTIZE_UTIL_H_

#ifndef _MSC_VER
#include <dirent.h>
#endif
#include <sys/stat.h>
#include <memory>
#include <string>


+ 1
- 0
mindspore/lite/tools/converter/registry/CMakeLists.txt View File

@@ -3,6 +3,7 @@ file(GLOB CONVERT_REG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
file(GLOB KERNEL_REG_SRC ${KERNEL_REG_DIR}/*.cc)
set(REG_SRC ${CONVERT_REG_SRC}
${KERNEL_REG_SRC}
${KERNEL_REG_DIR}/../cxx_api/context.cc
${KERNEL_REG_DIR}/../cxx_api/types.cc
${KERNEL_REG_DIR}/../cxx_api/tensor/tensor_impl.cc
${KERNEL_REG_DIR}/../cxx_api/tensor_utils.cc


+ 2
- 0
mindspore/lite/tools/optimizer/common/pass_manager_extends.cc View File

@@ -14,7 +14,9 @@
* limitations under the License.
*/
#include "backend/optimizer/common/pass_manager.h"
#ifndef _MSC_VER
#include <sys/time.h>
#endif
#include <deque>
#include <string>
#include <algorithm>


+ 1
- 1
mindspore/lite/tools/optimizer/fisson/multi_conv_split_pass.h View File

@@ -20,10 +20,10 @@
#include <vector>
#include <string>
#include <unordered_map>
#include "schema/model_generated.h"
#include "backend/optimizer/common/optimizer.h"
#include "tools/optimizer/fisson/fisson_util.h"
#include "tools/optimizer/parallel/split_strategy.h"
#include "schema/model_generated.h"
#include "tools/optimizer/parallel/multi_node_split.h"

using mindspore::schema::PrimitiveType;


+ 1
- 1
mindspore/lite/tools/optimizer/fusion/affine_activation_fusion.h View File

@@ -18,8 +18,8 @@
#define MINDSPORE_LITE_SRC_PASS_FUSION_AFFINE_ACTIVATION_FUSION_H_

#include <string>
#include "backend/optimizer/common/optimizer.h"
#include "schema/inner/model_generated.h"
#include "backend/optimizer/common/optimizer.h"

namespace mindspore {
namespace opt {


+ 1
- 2
mindspore/lite/tools/optimizer/fusion/affine_fusion.cc View File

@@ -13,13 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "tools/optimizer/fusion/affine_fusion.h"
#include <memory>
#include <vector>
#include "schema/inner/model_generated.h"
#include "ops/affine.h"
#include "src/common/log_adapter.h"
#include "schema/inner/model_generated.h"
#include "ops/splice.h"
#include "ops/mat_mul.h"
#include "tools/optimizer/common/gllo_utils.h"


+ 1
- 0
mindspore/lite/tools/optimizer/fusion/conv_conv_fusion.h View File

@@ -18,6 +18,7 @@
#define MINDSPORE_LITE_SRC_PASS_FUSION_CONV_CONV_FUSION_H_

#include <string>
#include "schema/inner/model_generated.h"
#include "backend/optimizer/common/optimizer.h"

namespace mindspore {


+ 1
- 1
mindspore/lite/tools/optimizer/graph/add_tensor_array.h View File

@@ -18,8 +18,8 @@
#define MINDSPORE_LITE_SRC_PASS_GRAPH_ADD_TENSOR_ARRAY_H_

#include <string>
#include "backend/optimizer/common/optimizer.h"
#include "schema/inner/model_generated.h"
#include "backend/optimizer/common/optimizer.h"

namespace mindspore {
namespace opt {


Loading…
Cancel
Save