!19383 [MS][LITE] modify cmakelists for nnie compile

Merge pull request !19383 from jianghui58/nnie_to_Master
This commit is contained in:
i-robot 2021-07-06 01:47:12 +00:00 committed by Gitee
commit 281bce69e6
5 changed files with 95 additions and 3 deletions

View File

@ -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)

View File

@ -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")

View File

@ -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()

View File

@ -33,6 +33,12 @@
#include <asm/unistd.h>
#include <unistd.h>
#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<std::string> &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<std::string> 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;

View File

@ -82,7 +82,7 @@ schema::MetaGraphT *Converter::Convert(const std::unique_ptr<converter::Flags> &
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();