Browse Source

common log optimize

pull/1572/head
liyihan2@huawei.com 4 years ago
parent
commit
82f29c8aa6
8 changed files with 62 additions and 35 deletions
  1. +2
    -2
      ge/common/kernel_store.cc
  2. +4
    -4
      ge/common/model_parser/model_parser.cc
  3. +2
    -2
      ge/common/model_saver.cc
  4. +4
    -2
      ge/common/op/ge_op_utils.cc
  5. +2
    -1
      ge/common/profiling/ge_profiling.cc
  6. +1
    -1
      ge/common/profiling/profiling_manager.cc
  7. +8
    -4
      ge/common/properties_manager.cc
  8. +39
    -19
      ge/common/util.cc

+ 2
- 2
ge/common/kernel_store.cc View File

@@ -37,9 +37,9 @@ bool KernelStore::Build() {
try {
buffer_.resize(total_len);
} catch (std::bad_alloc &e) {
GELOGE(ge::MEMALLOC_FAILED, "[Malloc][Memmory]All build memory failed, memory size %zu, "
GELOGE(ge::MEMALLOC_FAILED, "[Malloc][Memmory]Resize buffer failed, memory size %zu, "
"exception %s", total_len, e.what());
REPORT_CALL_ERROR("E19999", "All build memory failed, memory size %zu, exception %s",
REPORT_CALL_ERROR("E19999", "Resize buffer failed, memory size %zu, exception %s",
total_len, e.what());
return false;
}


+ 4
- 4
ge/common/model_parser/model_parser.cc View File

@@ -33,7 +33,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::LoadFro
if (real_path.empty()) {
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "[Check][Param]Model file path %s is invalid",
model_path);
REPORT_INNER_ERROR("E19999", "Model file path %s is invalid", model_path);
REPORT_CALL_ERROR("E19999", "Model file path %s is invalid", model_path);
return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID;
}

@@ -108,14 +108,14 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::ParseMo
uint8_t *data = reinterpret_cast<uint8_t *>(model.model_data) + sizeof(ModelFileHeader);
if (file_header->is_encrypt == ModelEncryptType::UNENCRYPTED) { // Unencrypted model
GE_CHK_BOOL_RET_STATUS(model.key.empty(), ACL_ERROR_GE_PARAM_INVALID,
"Invalid param. model is unencrypted, but key is not empty.");
"[Check][Param]Invalid, model is unencrypted, but key is not empty");
REPORT_CALL_ERROR("E19999", "Invalid param, model is unencrypted, but key is not empty");
model_data = data;
model_len = file_header->length;
GELOGD("Model_len is %u, model_file_head_len is %zu.", model_len, sizeof(ModelFileHeader));
} else {
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Check][Param]Invalid, model encrypt type not supported");
REPORT_CALL_ERROR("E19999","Invalid model ,encrypt type not supported");
REPORT_CALL_ERROR("E19999","Invalid model, encrypt type not supported");
res = ACL_ERROR_GE_PARAM_INVALID;
}



+ 2
- 2
ge/common/model_saver.cc View File

@@ -77,8 +77,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi
}
// Close file
if (mmClose(fd) != EN_OK) {
GELOGE(FAILED, "[Close][File]Failed, file %s", file_path);
REPORT_CALL_ERROR("E19999", "Close file %s failed", file_path);
GELOGE(FAILED, "[Close][File]Failed, file %s, error %s", file_path, strerror(errno));
REPORT_CALL_ERROR("E19999", "Close file %s failed, error %s", file_path, strerror(errno));
ret = FAILED;
}
return ret;


+ 4
- 2
ge/common/op/ge_op_utils.cc View File

@@ -276,8 +276,10 @@ Status OpUtils::SetOutputSliceDataByDataType(void *data, int64_t data_size, cons
int64_t dim_i = input_dims[i];
int64_t stride_i = stride[i];
if (dim_i == 0) {
GELOGE(PARAM_INVALID, "[Check][Param]Invalid, Dim_i of size tensor is 0");
REPORT_INNER_ERROR("E19999", "Dim_i of size tensor is 0, invalid");
GELOGE(PARAM_INVALID, "[Check][Param]Invalid, Dim_i %s of size tensor is 0",
ShapeToString(input_dims[i]).c_str());
REPORT_INNER_ERROR("E19999", "Dim_i %s of size tensor is 0, invalid",
ShapeToString(input_dims[i]).c_str());
return PARAM_INVALID;
}
chunk_size = chunk_size / dim_i;


+ 2
- 1
ge/common/profiling/ge_profiling.cc View File

@@ -133,7 +133,8 @@ ge::Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func) {
// Pass MsprofSetDeviceCallback to runtime
ge::Status rt_ret = rtRegDeviceStateCallback(kRtSetDeviceRegName.c_str(), static_cast<rtDeviceStateCallback>(func));
if (rt_ret != ge::SUCCESS) {
GELOGE(rt_ret, "[Pass][MsprofSetDeviceCallback]Pass it to runtime failed!");
GELOGE(rt_ret, "[Pass][MsprofSetDeviceCallback]To runtime failed, error_code %u", rt_ret);
REPORT_CALL_ERROR("E19999", "Pass msprofSetDeviceCallback to runtime failed, error_code %u", rt_ret);
return rt_ret;
}
return ge::SUCCESS;


+ 1
- 1
ge/common/profiling/profiling_manager.cc View File

@@ -219,7 +219,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::StopProf
auto device_id_ptr = std::unique_ptr<uint32_t[]>(new (std::nothrow) uint32_t[device_num]);
if (device_id_ptr == nullptr) {
GELOGE(FAILED, "[Stop][Profiling]Device id ptr is null.");
REPORT_INNER_ERROR("E19999", "Stop profiling, device id ptr is null");
REPORT_CALL_ERROR("E19999", "Stop profiling, device id ptr is null");
return;
}
for (int32_t i = 0; i < device_num; i++) {


+ 8
- 4
ge/common/properties_manager.cc View File

@@ -69,7 +69,8 @@ bool PropertiesManager::LoadFileContent(const std::string &file_path) {
std::ifstream fs(resolved_file_path, std::ifstream::in);

if (!fs.is_open()) {
GELOGE(PARAM_INVALID, "Open %s failed.", file_path.c_str());
GELOGE(PARAM_INVALID, "[Open][File]Failed, file path %s invalid", file_path.c_str());
REPORT_CALL_ERROR("E19999", "Open file failed, path %s invalid", file_path.c_str());
return false;
}

@@ -77,7 +78,8 @@ bool PropertiesManager::LoadFileContent(const std::string &file_path) {

while (getline(fs, line)) { // line not with \n
if (!ParseLine(line)) {
GELOGE(PARAM_INVALID, "Parse line failed. content is [%s].", line.c_str());
GELOGE(PARAM_INVALID, "[Parse][Line]Failed, content is %s", line.c_str());
REPORT_CALL_ERROR("E19999", "Parse line failed, content is %s", line.c_str());
fs.close();
return false;
}
@@ -100,15 +102,17 @@ bool PropertiesManager::ParseLine(const std::string &line) {
if (!temp.empty()) {
std::string::size_type pos = temp.find_first_of(delimiter);
if (pos == std::string::npos) {
GELOGE(PARAM_INVALID, "Incorrect line [%s], it must include [%s].Perhaps you use illegal chinese symbol",
GELOGE(PARAM_INVALID, "[Check][Param]Incorrect line %s, it must include %s",
line.c_str(), delimiter.c_str());
REPORT_CALL_ERROR("E19999", "Incorrect line %s, it must include %s", line.c_str(), delimiter.c_str());
return false;
}

std::string map_key = Trim(temp.substr(0, pos));
std::string value = Trim(temp.substr(pos + 1));
if (map_key.empty() || value.empty()) {
GELOGE(PARAM_INVALID, "Map_key or value empty. %s", line.c_str());
GELOGE(PARAM_INVALID, "[Check][Param]Map_key or value empty, line %s", line.c_str());
REPORT_CALL_ERROR("E19999", "Map_key or value empty, line %s", line.c_str());
return false;
}



+ 39
- 19
ge/common/util.cc View File

@@ -83,7 +83,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromBinaryFile(co
std::ifstream fs(real_path, std::ifstream::in | std::ifstream::binary);
if (!fs.is_open()) {
ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file, "ifstream is_open failed"});
GELOGE(ge::FAILED, "Open real path[%s] failed.", file);
GELOGE(ge::FAILED, "[Open][File]Failed, real path %s", file);
return false;
}

@@ -96,7 +96,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromBinaryFile(co

if (!ret) {
ErrorManager::GetInstance().ATCReportErrMessage("E19005", {"file"}, {file});
GELOGE(ge::FAILED, "Parse file[%s] failed.", file);
GELOGE(ge::FAILED, "[Parse][File]Failed, file %s", file);
return ret;
}

@@ -155,7 +155,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(co

std::ifstream file(real_path.c_str(), std::ios::binary | std::ios::ate);
if (!file.is_open()) {
GELOGE(ge::FAILED, "Read file %s failed.", file_name);
GELOGE(ge::FAILED, "[Read][File]Failed, file %s", file_name);
REPORT_CALL_ERROR("E19999", "Read file %s failed", file_name);
return false;
}

@@ -182,7 +183,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadBytesFromBinaryFile(co

std::ifstream file(real_path.c_str(), std::ios::binary | std::ios::ate);
if (!file.is_open()) {
GELOGE(ge::FAILED, "Read file %s failed.", file_name);
GELOGE(ge::FAILED, "[Read][File]Failed, file %s", file_name);
REPORT_CALL_ERROR("E19999", "Read file %s failed", file_name);
return false;
}

@@ -248,7 +250,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY std::string CurrentTimeInStr()
std::time_t now = std::time(nullptr);
std::tm *ptm = std::localtime(&now);
if (ptm == nullptr) {
GELOGE(ge::FAILED, "Localtime failed.");
GELOGE(ge::FAILED, "[Check][Param]Localtime incorrect");
REPORT_CALL_ERROR("E19999", "Localtime incorrect");
return "";
}

@@ -488,7 +491,8 @@ FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::str
ret = regexec(&reg, str.c_str(), 0, NULL, 0);
if (ret) {
regerror(ret, &reg, ebuff, kMaxBuffSize);
GELOGE(ge::PARAM_INVALID, "regexec failed, reason: %s", ebuff);
GELOGE(ge::PARAM_INVALID, "[Rgexec][Param]Failed, reason %s", ebuff);
REPORT_CALL_ERROR("E19999", "Rgexec failed, reason %s", ebuff);
regfree(&reg);
return false;
}
@@ -516,35 +520,44 @@ FMK_FUNC_HOST_VISIBILITY bool ValidateStr(const std::string &str, const std::str

FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) {
if (file_path == nullptr) {
GELOGE(PARAM_INVALID, "Config path is null.");
GELOGE(PARAM_INVALID, "[Check][Param]Config path is null");
REPORT_INNER_ERROR("E19999", "Config path is null");
return false;
}
if (!CheckInputPathValid(file_path)) {
GELOGE(PARAM_INVALID, "Config path is invalid: %s", file_path);
GELOGE(PARAM_INVALID, "[Check][Param]Config path %s is invalid", file_path);
REPORT_CALL_ERROR("E19999", "Config path %s is invalid", file_path);
return false;
}
// Normalize the path
std::string resolved_file_path = RealPath(file_path);
if (resolved_file_path.empty()) {
GELOGE(PARAM_INVALID, "Invalid input file path [%s], make sure that the file path is correct.", file_path);
GELOGE(PARAM_INVALID, "[Check][Param]Invalid input file path %s", file_path);
REPORT_CALL_ERROR("E19999", "Invalid input file path %s", file_path);
return false;
}

mmStat_t stat = {0};
int32_t ret = mmStatGet(resolved_file_path.c_str(), &stat);
if (ret != EN_OK) {
GELOGE(PARAM_INVALID, "cannot get config file status, which path is %s, maybe not exist, return %d, errcode %d",
resolved_file_path.c_str(), ret, mmGetErrorCode());
GELOGE(PARAM_INVALID, "[Get][FileStatus]Failed, which path %s maybe not exist, "
"return %d, errcode %d", resolved_file_path.c_str(), ret, mmGetErrorCode());
REPORT_CALL_ERROR("E19999", "Get config file status failed, which path %s maybe not exist, "
"return %d, errcode %d", resolved_file_path.c_str(), ret, mmGetErrorCode());
return false;
}
if ((stat.st_mode & S_IFMT) != S_IFREG) {
GELOGE(PARAM_INVALID, "config file is not a common file, which path is %s, mode is %u", resolved_file_path.c_str(),
stat.st_mode);
GELOGE(PARAM_INVALID, "[Check][Param]Config file is not a common file, which path is %s, "
"mode is %u", resolved_file_path.c_str(), stat.st_mode);
REPORT_CALL_ERROR("E19999", "Config file is not a common file, which path is %s, "
"mode is %u", resolved_file_path.c_str(), stat.st_mode);
return false;
}
if (stat.st_size > kMaxConfigFileByte) {
GELOGE(PARAM_INVALID, "config file %s size[%ld] is larger than max config file Bytes[%u]",
GELOGE(PARAM_INVALID, "[Check][Param]Config file %s size %ld is larger than max config file Bytes %u",
resolved_file_path.c_str(), stat.st_size, kMaxConfigFileByte);
REPORT_CALL_ERROR("E19999", "Config file %s size %ld is larger than max config file Bytes %u",
resolved_file_path.c_str(), stat.st_size, kMaxConfigFileByte);
return false;
}
return true;
@@ -552,28 +565,35 @@ FMK_FUNC_HOST_VISIBILITY bool IsValidFile(const char *file_path) {

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status CheckPath(const char *path, size_t length) {
if (path == nullptr) {
GELOGE(PARAM_INVALID, "Config path is invalid.");
GELOGE(PARAM_INVALID, "[Check][Param]Config path is invalid");
REPORT_CALL_ERROR("E19999", "Config path is invalid");
return PARAM_INVALID;
}

if (strlen(path) != length) {
GELOGE(PARAM_INVALID, "Path is invalid or length of config path is not equal to given length.");
GELOGE(PARAM_INVALID, "[Check][Param]Path %s is invalid or length %zu "
"not equal to given length %zu", path, strlen(path), length);
REPORT_CALL_ERROR("E19999", "Path %s is invalid or length %zu "
"not equal to given length %zu", path, strlen(path), length);
return PARAM_INVALID;
}

if (length == 0 || length > MMPA_MAX_PATH) {
GELOGE(PARAM_INVALID, "Length of config path is invalid.");
GELOGE(PARAM_INVALID, "[Check][Param]Length of config path %zu is invalid", length);
REPORT_INNER_ERROR("E19999", "Length of config path %zu is invalid", length);
return PARAM_INVALID;
}

INT32 is_dir = mmIsDir(path);
if (is_dir != EN_OK) {
GELOGE(PATH_INVALID, "Open directory %s failed, maybe it is not exit or not a dir", path);
GELOGE(PATH_INVALID, "[Open][Directory]Failed, directory path %s", path);
REPORT_CALL_ERROR("E19999", "Open directory %s failed", path);
return PATH_INVALID;
}

if (mmAccess2(path, M_R_OK) != EN_OK) {
GELOGE(PATH_INVALID, "Read path[%s] failed, errmsg[%s]", path, strerror(errno));
GELOGE(PATH_INVALID, "[Read][Path]Failed, path %s, errmsg %s", path, strerror(errno));
REPORT_CALL_ERROR("E19999", "Read path %s failed, errmsg %s", path, strerror(errno));
return PATH_INVALID;
}
return SUCCESS;


Loading…
Cancel
Save