Browse Source

!22261 [MS][LITE]modify benchmark dump output dir name && add -rdynamic flag

Merge pull request !22261 from jianghui58/add_rdynamic
tags/v1.5.0-rc1
i-robot Gitee 4 years ago
parent
commit
bec7d1273d
8 changed files with 24 additions and 16 deletions
  1. +2
    -2
      mindspore/lite/build_lite.sh
  2. +4
    -0
      mindspore/lite/src/common/dynamic_library_loader.cc
  3. +3
    -3
      mindspore/lite/src/common/file_utils.cc
  4. +4
    -4
      mindspore/lite/tools/benchmark/benchmark.cc
  5. +3
    -3
      mindspore/lite/tools/benchmark/benchmark_base.cc
  6. +2
    -2
      mindspore/lite/tools/benchmark/benchmark_base.h
  7. +2
    -2
      mindspore/lite/tools/benchmark/benchmark_unified_api.cc
  8. +4
    -0
      mindspore/lite/tools/converter/CMakeLists.txt

+ 2
- 2
mindspore/lite/build_lite.sh View File

@@ -234,13 +234,13 @@ build_lite() {
compile_nnie_script=${BASEPATH}/mindspore/lite/tools/providers/NNIE/Hi3516D/compile_nnie.sh
cd ${BASEPATH}/../
if [[ "${local_lite_platform}" == "x86_64" ]]; then
sh ${compile_nnie_script} -I x86_64 -b nnie_master -j $THREAD_NUM
sh ${compile_nnie_script} -I x86_64 -b nnie_3516_master -j $THREAD_NUM
if [[ $? -ne 0 ]]; then
echo "compile x86_64 for nnie failed."
exit 1
fi
elif [[ "${local_lite_platform}" == "arm32" ]]; then
sh ${compile_nnie_script} -I arm32 -b nnie_master -j $THREAD_NUM
sh ${compile_nnie_script} -I arm32 -b nnie_3516_master -j $THREAD_NUM
if [[ $? -ne 0 ]]; then
echo "compile arm32 for nnie failed."
exit 1


+ 4
- 0
mindspore/lite/src/common/dynamic_library_loader.cc View File

@@ -35,7 +35,11 @@ int DynamicLibraryLoader::Open(const std::string &lib_path) {
std::string real_path = RealPath(lib_path.c_str());

#ifndef _WIN32
#ifndef ENABLE_ARM
handler_ = dlopen(real_path.c_str(), RTLD_LAZY | RTLD_DEEPBIND);
#else
handler_ = dlopen(real_path.c_str(), RTLD_LAZY);
#endif
#else
handler_ = LoadLibrary(real_path.c_str());
#endif


+ 3
- 3
mindspore/lite/src/common/file_utils.cc View File

@@ -147,11 +147,11 @@ int CreateOutputDir(std::string *file_path) {
}
}

int count = 1;
int count = 0;
while (AccessFile((*file_path + "/" + std::to_string(count)), F_OK) == 0) {
MS_LOG(DEBUG) << "current file_path has existed, file_path cnt plus 1."; // such as: /xxx/1 ==> /xxx/2
MS_LOG(INFO) << "current file_path has existed, file_path cnt plus 1."; // such as: /xxx/0 ==> /xxx/1
count++;
if (count > MAXIMUM_NUMBERS_OF_FOLDER) {
if (count >= MAXIMUM_NUMBERS_OF_FOLDER) {
MS_LOG(ERROR) << "the number of file folders exceeds the upper limit.";
return RET_ERROR;
}


+ 4
- 4
mindspore/lite/tools/benchmark/benchmark.cc View File

@@ -731,12 +731,12 @@ std::string GenerateOutputFileName(tensor::MSTensor *tensor, const std::string &
for (const auto &dim : tensor->shape()) {
file_name += std::to_string(dim) + "_";
}
if (TYPE_ID_MAP.find(tensor->data_type()) != TYPE_ID_MAP.end()) {
file_name += TYPE_ID_MAP.at(tensor->data_type());
if (kTypeIdMap.find(tensor->data_type()) != kTypeIdMap.end()) {
file_name += kTypeIdMap.at(tensor->data_type());
}
auto tensor_format = static_cast<schema::Format>(static_cast<lite::Tensor *>(tensor)->format());
if (TENSOR_FORMAT_MAP.find(tensor_format) != TENSOR_FORMAT_MAP.end()) {
file_name += "_" + TENSOR_FORMAT_MAP.at(tensor_format) + ".bin";
if (kTensorFormatMap.find(tensor_format) != kTensorFormatMap.end()) {
file_name += "_" + kTensorFormatMap.at(tensor_format) + ".bin";
}
return file_name;
}


+ 3
- 3
mindspore/lite/tools/benchmark/benchmark_base.cc View File

@@ -58,13 +58,13 @@ constexpr int16_t kInputDataInt8Max = 127;
constexpr int16_t kInputDataUint8Min = 0;
constexpr int16_t kInputDataUint8Max = 254;

const std::unordered_map<int, std::string> TYPE_ID_MAP{
const std::unordered_map<int, std::string> kTypeIdMap{
{kNumberTypeFloat16, "Float16"}, {kNumberTypeFloat, "Float32"}, {kNumberTypeFloat32, "Float32"},
{kNumberTypeInt8, "Int8"}, {kNumberTypeInt16, "Int16"}, {kNumberTypeInt, "Int32"},
{kNumberTypeInt32, "Int32"}, {kNumberTypeUInt8, "UInt8"}, {kNumberTypeUInt16, "UInt16"},
{kNumberTypeUInt, "UInt32"}, {kNumberTypeUInt32, "UInt32"}, {kObjectTypeString, "String"},
{kNumberTypeBool, "Bool"}, {kObjectTypeTensorType, "Tensor"}};
const std::unordered_map<schema::Format, std::string> TENSOR_FORMAT_MAP{
const std::unordered_map<schema::Format, std::string> kTensorFormatMap{
{schema::Format_NCHW, "NCHW"}, {schema::Format_NHWC, "NHWC"}, {schema::Format_NHWC4, "NHWC4"},
{schema::Format_HWKC, "HWKC"}, {schema::Format_HWCK, "HWCK"}, {schema::Format_KCHW, "KCHW"},
{schema::Format_CKHW, "CKHW"}, {schema::Format_KHWC, "KHWC"}, {schema::Format_CHWK, "CHWK"},
@@ -270,7 +270,7 @@ int BenchmarkBase::InitDumpConfigFromJson(char *path) {
return RET_ERROR;
}
if (dump_cfg_json_[dump::kSettings][dump::kNetName] == nullptr) {
dump_cfg_json_[dump::kSettings][dump::kNetName] = "Default";
dump_cfg_json_[dump::kSettings][dump::kNetName] = "default";
}
if (dump_cfg_json_[dump::kSettings][dump::kInputOutput] == nullptr) {
dump_cfg_json_[dump::kSettings][dump::kInputOutput] = 0;


+ 2
- 2
mindspore/lite/tools/benchmark/benchmark_base.h View File

@@ -59,8 +59,8 @@ constexpr const char *DELIM_COLON = ":";
constexpr const char *DELIM_COMMA = ",";
constexpr const char *DELIM_SLASH = "/";

extern const std::unordered_map<int, std::string> TYPE_ID_MAP;
extern const std::unordered_map<schema::Format, std::string> TENSOR_FORMAT_MAP;
extern const std::unordered_map<int, std::string> kTypeIdMap;
extern const std::unordered_map<schema::Format, std::string> kTensorFormatMap;

//
namespace dump {


+ 2
- 2
mindspore/lite/tools/benchmark/benchmark_unified_api.cc View File

@@ -722,8 +722,8 @@ std::string GenerateOutputFileName(mindspore::MSTensor *tensor, const std::strin
for (const auto &dim : tensor->Shape()) {
file_name += std::to_string(dim) + "_";
}
if (TYPE_ID_MAP.find(static_cast<int>(tensor->DataType())) != TYPE_ID_MAP.end()) {
file_name += TYPE_ID_MAP.at(static_cast<int>(tensor->DataType()));
if (kTypeIdMap.find(static_cast<int>(tensor->DataType())) != kTypeIdMap.end()) {
file_name += kTypeIdMap.at(static_cast<int>(tensor->DataType()));
}

file_name += +".bin";


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

@@ -11,6 +11,10 @@ include(${TOP_DIR}/cmake/external_libs/opencv.cmake)
include(${TOP_DIR}/cmake/external_libs/glog.cmake)
include_directories(${TOP_DIR}/mindspore/ccsrc/backend/kernel_compiler/cpu)

if(NOT WIN32)
set(CMAKE_EXE_LINKER_FLAGS "-rdynamic")
endif()

file(GLOB_RECURSE CONVERTER_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/ops/*.cc
${CMAKE_CURRENT_SOURCE_DIR}/../flag/flag_parser.cc


Loading…
Cancel
Save