diff --git a/mindspore/lite/CMakeLists.txt b/mindspore/lite/CMakeLists.txt index 8c391432ff5..6b812caaa36 100644 --- a/mindspore/lite/CMakeLists.txt +++ b/mindspore/lite/CMakeLists.txt @@ -29,6 +29,7 @@ option(MSLITE_ENABLE_CONVERTER "enable converter, only x86_64 support" on) option(MSLITE_ENABLE_TOOLS "enable tools" on) option(MSLITE_ENABLE_TESTCASES "enable testcase" off) option(MSLITE_ENABLE_NNIE "enable NNIE" off) +option(MSLITE_COMPILE_NNIE "compile NNIE" off) # Option that can be configured through manually option(ENABLE_VERBOSE "" off) @@ -70,6 +71,9 @@ endif() if(DEFINED ENV{MSLITE_ENABLE_NNIE}) set(MSLITE_ENABLE_NNIE $ENV{MSLITE_ENABLE_NNIE}) endif() +if(DEFINED ENV{MSLITE_COMPILE_NNIE}) + set(MSLITE_COMPILE_NNIE $ENV{MSLITE_COMPILE_NNIE}) +endif() if(PLATFORM_ARM64) if(MSLITE_GPU_BACKEND STREQUAL "") @@ -179,6 +183,10 @@ else() set(RUNTIME_COMPONENT_NAME "linux-x64") endif() +if(MSLITE_COMPILE_NNIE AND (NOT PLATFORM_ARM)) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tools/converter/nnie) +endif() + string(REPLACE "/mindspore/lite" "" TOP_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(CORE_DIR ${TOP_DIR}/mindspore/core) set(CCSRC_DIR ${TOP_DIR}/mindspore/ccsrc) diff --git a/mindspore/lite/src/CMakeLists.txt b/mindspore/lite/src/CMakeLists.txt index 641546e35e1..a8ad3729163 100644 --- a/mindspore/lite/src/CMakeLists.txt +++ b/mindspore/lite/src/CMakeLists.txt @@ -251,9 +251,12 @@ if(SUPPORT_TRAIN) target_link_libraries(mindspore-lite-train_static minddata-lite mindspore-lite) endif() -if(NOT APPLE AND PLATFORM_ARM AND NOT TARGET_HIMIX200) +if(NOT APPLE AND PLATFORM_ARM) set(NDK_STRIP "${ANDROID_NDK}/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/aarch64-linux-android/bin/strip") + if(TARGET_HIMIX200) + set(NDK_STRIP "arm-himix200-linux-strip") + endif() endif() if(NOT APPLE AND "${CMAKE_BUILD_TYPE}" STREQUAL "Release") diff --git a/mindspore/lite/tools/benchmark/CMakeLists.txt b/mindspore/lite/tools/benchmark/CMakeLists.txt index 2473a61b760..e9bb70b6888 100644 --- a/mindspore/lite/tools/benchmark/CMakeLists.txt +++ b/mindspore/lite/tools/benchmark/CMakeLists.txt @@ -30,3 +30,20 @@ if(NOT TARGET_HIMIX200) endif() endif() +if(MSLITE_COMPILE_NNIE AND TARGET_HIMIX200 AND PLATFORM_ARM) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/nnie/third_patry/hi3516_sdk) + link_directories(${CMAKE_CURRENT_SOURCE_DIR}/nnie/third_patry/hi3516_sdk/lib) + set(CMAKE_SKIP_BUILD_RPATH on) + add_subdirectory(nnie) + add_subdirectory(nnie_proposal) + + add_executable(benchmark + ${CMAKE_CURRENT_SOURCE_DIR}/main.cc + ${CMAKE_CURRENT_SOURCE_DIR}/benchmark.cc + ${COMMON_SRC}) + + add_dependencies(benchmark fbs_src) + + target_link_libraries(benchmark mindspore-lite mindspore::json pthread nnie_proposal + mslite_nnie dl nnie mpi VoiceEngine upvqe dnvqe securec) +endif() diff --git a/mindspore/lite/tools/benchmark/benchmark.cc b/mindspore/lite/tools/benchmark/benchmark.cc index a42361ae42e..e9aeb7d21c1 100644 --- a/mindspore/lite/tools/benchmark/benchmark.cc +++ b/mindspore/lite/tools/benchmark/benchmark.cc @@ -33,6 +33,12 @@ #include #include #endif +#ifdef SUPPORT_NNIE +#include "include/hi_common.h" +#include "include/hi_comm_vb.h" +#include "include/mpi_sys.h" +#include "include/mpi_vb.h" +#endif namespace mindspore { namespace lite { @@ -1350,18 +1356,76 @@ int Benchmark::PrintPerfResult(const std::vector &title, } #endif +#ifdef SUPPORT_NNIE +int SvpSysInit() { + HI_S32 ret = HI_SUCCESS; + VB_CONFIG_S struVbConf; + + HI_MPI_SYS_Exit(); + HI_MPI_VB_Exit(); + + memset(&struVbConf, 0, sizeof(VB_CONFIG_S)); + struVbConf.u32MaxPoolCnt = 2; + struVbConf.astCommPool[1].u64BlkSize = 768 * 576 * 2; + struVbConf.astCommPool[1].u32BlkCnt = 1; + + ret = HI_MPI_VB_SetConfig((const VB_CONFIG_S *)&struVbConf); + if (HI_SUCCESS != ret) { + MS_LOG(ERROR) << "Error:HI_MPI_VB_SetConf failed!"; + return RET_ERROR; + } + + ret = HI_MPI_VB_Init(); + if (HI_SUCCESS != ret) { + MS_LOG(ERROR) << "Error:HI_MPI_VB_Init failed!"; + return RET_ERROR; + } + + ret = HI_MPI_SYS_Init(); + if (HI_SUCCESS != ret) { + MS_LOG(ERROR) << "Error:HI_MPI_SYS_Init failed!"; + return RET_ERROR; + } + + return RET_OK; +} + +int SvpSysExit() { + HI_S32 ret = HI_SUCCESS; + + ret = HI_MPI_SYS_Exit(); + if (HI_SUCCESS != ret) { + MS_LOG(ERROR) << "Error:HI_MPI_SYS_Exit failed!"; + return RET_ERROR; + } + + ret = HI_MPI_VB_Exit(); + if (HI_SUCCESS != ret) { + MS_LOG(ERROR) << "Error:HI_MPI_VB_Exit failed!"; + return RET_ERROR; + } + + return RET_OK; +} +#endif + Benchmark::~Benchmark() { for (const auto &iter : this->benchmark_data_) { delete (iter.second); } this->benchmark_data_.clear(); delete (session_); +#ifdef SUPPORT_NNIE + SvpSysExit(); +#endif } int RunBenchmark(int argc, const char **argv) { BenchmarkFlags flags; Option err = flags.ParseFlags(argc, argv); - +#ifdef SUPPORT_NNIE + SvpSysInit(); +#endif if (err.IsSome()) { std::cerr << err.Get() << std::endl; std::cerr << flags.Usage() << std::endl; diff --git a/mindspore/lite/tools/converter/converter.cc b/mindspore/lite/tools/converter/converter.cc index 3c886ec1f4a..5242bb6d814 100644 --- a/mindspore/lite/tools/converter/converter.cc +++ b/mindspore/lite/tools/converter/converter.cc @@ -82,7 +82,7 @@ schema::MetaGraphT *Converter::Convert(const std::unique_ptr & for (auto &path : flag->pluginsPath) { auto status = dynamic_library_loader.Open(path.c_str()); if (status != RET_OK) { - MS_LOG(ERROR) << "open dynamic library failed."; + MS_LOG(ERROR) << "open dynamic library failed. " << path; return nullptr; } dynamic_library_loader.Close();