Browse Source

!1480 ge log optimize

Merge pull request !1480 from liyihan123/master
tags/v1.3.0
计晨 Gitee 4 years ago
parent
commit
7dddb4c9f8
11 changed files with 377 additions and 145 deletions
  1. +27
    -9
      ge/analyzer/analyzer.cc
  2. +41
    -15
      ge/client/ge_api.cc
  3. +34
    -19
      ge/common/auth/file_saver.cc
  4. +6
    -3
      ge/common/debug/memory_dumper.cc
  5. +6
    -2
      ge/common/dump/dump_manager.cc
  6. +43
    -16
      ge/common/dump/dump_op.cc
  7. +14
    -6
      ge/common/dump/opdebug_register.cc
  8. +1
    -1
      ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc
  9. +5
    -2
      ge/common/ge/op_tiling_manager.cc
  10. +4
    -3
      ge/common/ge/plugin_manager.cc
  11. +196
    -69
      ge/common/helper/model_helper.cc

+ 27
- 9
ge/analyzer/analyzer.cc View File

@@ -104,6 +104,7 @@ ge::Status Analyzer::Initialize() {
string real_path = RealPath(kFilePath.c_str());
if (real_path.empty()) {
GELOGE(FAILED, "[Check][AnalyzeFilePath]File path is empty, Path invalid.");
REPORT_CALL_ERROR("E19999", "Analyze file path check invalid, it is empty");
return FAILED;
}
json_file_name_ = real_path + "/" + kAnalyzeFile;
@@ -155,12 +156,18 @@ std::shared_ptr<GraphInfo> Analyzer::GetJsonObject(uint64_t session_id, uint64_t
std::lock_guard<std::recursive_mutex> lg(mutex_);
auto iter = graph_infos_.find(session_id);
if (iter == graph_infos_.end()) {
GELOGE(PARAM_INVALID, "[Check][SessionId]session_id:%lu does not exist! graph_id:%lu", session_id, graph_id);
GELOGE(PARAM_INVALID, "[Check][SessionId]session_id:%lu does not exist! "
"graph_id:%lu", session_id, graph_id);
REPORT_INNER_ERROR("E19999", "Sessin_id %lu does not exist, graph_id %lu",
session_id, graph_id);
return nullptr;
} else {
auto iter1 = (iter->second).find(graph_id);
if (iter1 == (iter->second).end()) {
GELOGE(PARAM_INVALID, "[Check][GraphId]graph_id:%lu does not exist! session_id:%lu.", graph_id, session_id);
GELOGE(PARAM_INVALID, "[Check][GraphId]graph_id:%lu does not exist! "
"session_id:%lu.", graph_id, session_id);
REPORT_INNER_ERROR("E19999", "Graph_id %lu does not exist, session_id %lu",
graph_id, session_id);
return nullptr;
}
GELOGI("GetJsonObject Success!session_id:%lu graph_id:%lu", session_id, graph_id);
@@ -186,11 +193,15 @@ ge::Status Analyzer::CreateAnalyzerFile() {
std::lock_guard<std::mutex> lg(file_mutex_);
int fd = open(json_file_name_.c_str(), O_WRONLY | O_CREAT | O_TRUNC, kFileAuthority);
if (fd < 0) {
GELOGE(INTERNAL_ERROR, "[FileOpen][AnalyzeFile]Fail to open the analyze file: %s.", json_file_name_.c_str());
GELOGE(INTERNAL_ERROR, "[FileOpen][AnalyzeFile]Fail to open the analyze file: %s.",
json_file_name_.c_str());
REPORT_INNER_ERROR("E19999", "Failed to open analyze file %s", json_file_name_.c_str());
return INTERNAL_ERROR;
}
if (close(fd) != 0) {
GELOGE(INTERNAL_ERROR, "[FileClose][AnalyzeFile]Fail to close the analyze file: %s.", json_file_name_.c_str());
GELOGE(INTERNAL_ERROR, "[FileClose][AnalyzeFile]Fail to close the analyze file: %s.",
json_file_name_.c_str());
REPORT_INNER_ERROR("E19999", "Failed to clsoe analyze file %s", json_file_name_.c_str());
return INTERNAL_ERROR;
}
is_json_file_create_ = true;
@@ -211,7 +222,9 @@ ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_
std::lock_guard<std::mutex> lg(file_mutex_);
json_file_.open(json_file_name_, std::ios::app);
if (!json_file_.is_open()) {
GELOGE(FAILED, "[Check][AnalyzeFile]analyze file does not exist[%s]", json_file_name_.c_str());
GELOGE(FAILED, "[Check][AnalyzeFile]analyze file does not exist[%s]",
json_file_name_.c_str());
REPORT_INNER_ERROR("E19999", "Analyze file %s dose not exist", json_file_name_.c_str());
return PARAM_INVALID;
}

@@ -221,10 +234,13 @@ ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_
try {
json_file_ << jsn.dump(kJsonDumpLevel) << std::endl;
} catch (nlohmann::detail::type_error &e) {
GELOGE(FAILED,
"[Json.dump][GraphInfo]json.dump to analyze file [%s] failed because [%s],"
"session_id:%lu, graph_id:%lu",
GELOGE(FAILED,
"[Json.dump][GraphInfo]Dump analyze file [%s] failed because [%s],"
"session_id:%lu, graph_id:%lu",
json_file_name_.c_str(), e.what(), session_id, graph_id);
REPORT_INNER_ERROR("E19999", "Dump analyze file %s failed because %s, "
"session_id %lu, graph_id %lu",
json_file_name_.c_str(), e.what(), session_id, graph_id);
ret_failed = true;
}
json_file_.close();
@@ -244,9 +260,11 @@ ge::Status Analyzer::DoAnalyze(DataInfo &data_info) {
GE_CHECK_NOTNULL(graph_info);
auto status = SaveOpInfo(desc, data_info, graph_info);
if (status != SUCCESS) {
GELOGE(status,
GELOGE(status,
"[Check][SaveOpInfo]save op info: desc_name [%s] desc_type [%s] failed!",
desc->GetName().c_str(), desc->GetType().c_str());
REPORT_CALL_ERROR("E19999", "Save op info: desc_name %s, desc_type %s failed",
desc->GetName().c_str(), desc->GetType().c_str());
return FAILED;
}
// create json file


+ 41
- 15
ge/client/ge_api.cc View File

@@ -73,7 +73,8 @@ Status CheckOptionsValid(const std::map<string, string> &options) {
"the job_id [%s] string length: %zu > max string length: %d",
job_id_iter->second.c_str(), job_id_iter->second.length(), kMaxStrLen);
REPORT_INPUT_ERROR("E10051", std::vector<std::string>({"id","length"}),
std::vector<std::string>({job_id_iter->second, std::to_string(kMaxStrLen)}));
std::vector<std::string>({job_id_iter->second,
std::to_string(kMaxStrLen)}));
return FAILED;
}
}
@@ -90,6 +91,7 @@ Status GEInitializeImpl(const std::map<string, string> &options) {
if (ret != SUCCESS) {
GELOGE(GE_CLI_INIT_FAILED,
"[Init][PathBase]Init failed when pass param path_base:%s", path_base.c_str());
REPORT_CALL_ERROR("E19999", "Init failed when pass param path_base:%s", path_base.c_str());
return ret;
}

@@ -111,7 +113,9 @@ Status GEInitializeImpl(const std::map<string, string> &options) {
if (!is_proto_init) {
GELOGE(GE_CLI_INIT_FAILED,
"[Init][OpsProtoPath]Loading OpsProto lib plugin failed, OpsProtoPath:%s invalid.",
opsproto_path.c_str());
opsproto_path.c_str());
REPORT_CALL_ERROR("E19999", "Loading OpsProto lib plugin failed, OpsProtoPath:%s invalid",
opsproto_path.c_str());
return FAILED;
}

@@ -319,6 +323,7 @@ Session::Session(const std::map<AscendString, AscendString> &options) {
sessionId_ = session_id;
} else {
GELOGE(ret, "[Construct][Session]Failed, error code:%u.", ret);
REPORT_CALL_ERROR("E19999", "Construct session failed, error code:%u.", ret);
return;
}
GELOGT(TRACE_STOP, "Session Constructor finished");
@@ -350,12 +355,15 @@ Session::~Session() {

ret = instance_ptr->SessionManagerObj().DestroySession(session_id);
} catch (google::protobuf::FatalException &e) {
GELOGE(GE_CLI_SESS_DESTROY_FAILED, "[Destruct][Session]Failed because get fatalException.");
GELOGE(GE_CLI_SESS_DESTROY_FAILED, "[Destruct][Session]Failed "
"because get fatalException.");
REPORT_CALL_ERROR("E19999", "Destruct session failed, get fatal exception");
}

// check return status, return, update session id if success
if (ret != SUCCESS) {
GELOGE(ret, "[Destruct][Session]Failed, error code:%u.", ret);
REPORT_CALL_ERROR("E19999", "Destruct session failed, error code:%u.", ret);
}

GELOGT(TRACE_STOP, "Session Destructor finished");
@@ -479,9 +487,11 @@ Status Session::RemoveGraph(uint32_t graph_id) {
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if (!instance_ptr || !instance_ptr->InitFlag()) {
GELOGE(GE_CLI_GE_NOT_INITIALIZED,
"[Remove][Graph]Failed, GELib instance is nullptr or is not InitFlag ");
"[Remove][Graph]Failed, GELib instance is nullptr or is not InitFlag, "
"session_id %lu, graph_id %u", sessionId_, graph_id);
REPORT_INNER_ERROR("E19999",
"RemoveGraph Failed, GELib instance is nullptr or is not InitFlag.");
"RemoveGraph Failed, GELib instance is nullptr or is not InitFlag, "
"session_id %lu, graph_id %u", sessionId_, graph_id);
return FAILED;
}

@@ -491,7 +501,9 @@ Status Session::RemoveGraph(uint32_t graph_id) {
if (ret != SUCCESS) {
GELOGE(ret,
"[Remove][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.",
ret, sessionId_, graph_id);
ret, sessionId_, graph_id);
REPORT_CALL_ERROR("E19999", "Remove graph failed, error code:%u, "
"session_id:%lu, graph_id:%u", ret, sessionId_, graph_id);
return FAILED;
}
GELOGT(TRACE_STOP, "Session RemoveGraph finished");
@@ -557,9 +569,11 @@ Status Session::RunGraph(uint32_t graph_id, const std::vector<Tensor> &inputs, s
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) {
GELOGE(GE_CLI_GE_NOT_INITIALIZED,
"[Run][Graph]Failed, GELib instance is nullptr or is not InitFlag.");
"[Run][Graph]Failed, GELib instance is nullptr or is not InitFlag, "
"session_id %lu, graph_id %u", sessionId_, graph_id);
REPORT_INNER_ERROR("E19999",
"RunGraph Failed, GELib instance is nullptr or is not InitFlag.");
"RunGraph Failed, GELib instance is nullptr or is not InitFlag, "
"session_id %lu, graph_id %u", sessionId_, graph_id);
return FAILED;
}
GELOGT(TRACE_RUNNING, "Running Graph");
@@ -568,7 +582,9 @@ Status Session::RunGraph(uint32_t graph_id, const std::vector<Tensor> &inputs, s
if (ret != SUCCESS) {
GELOGE(ret,
"[Run][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.",
ret, sessionId_, graph_id);
ret, sessionId_, graph_id);
REPORT_CALL_ERROR("E19999", "Remove graph failed, error code:%u, "
"session_id:%lu, graph_id:%u", ret, sessionId_, graph_id);
return FAILED;
}

@@ -603,10 +619,12 @@ Status Session::BuildGraph(uint32_t graph_id, const std::vector<InputTensorInfo>
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id);
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) {
GELOGE(GE_CLI_GE_NOT_INITIALIZED,
"[Build][Graph]Failed, the GELib instance is nullptr or is not InitFlag.");
GELOGE(GE_CLI_GE_NOT_INITIALIZED,
"[Build][Graph]Failed, the GELib instance is nullptr or is not InitFlag, "
"session_id %lu, graph_id %u", sessionId_, graph_id);
REPORT_INNER_ERROR("E19999",
"Build graph failed, the GELib instance is nullptr or is not InitFlag.");
"Build graph failed, the GELib instance is nullptr or is not InitFlag, "
"session_id %lu, graph_id %u", sessionId_, graph_id);
return FAILED;
}
GELOGT(TRACE_RUNNING, "Building Graph");
@@ -614,7 +632,9 @@ Status Session::BuildGraph(uint32_t graph_id, const std::vector<InputTensorInfo>
if (ret != SUCCESS) {
GELOGE(ret,
"[Build][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.",
ret, sessionId_, graph_id);
ret, sessionId_, graph_id);
REPORT_CALL_ERROR("E19999", "Build graph failed , error code:%u, "
"session_id:%lu, graph_id:%u", ret, sessionId_, graph_id);
return FAILED;
}
return SUCCESS;
@@ -628,9 +648,11 @@ Status Session::RunGraphAsync(uint32_t graph_id, const std::vector<InputTensorIn
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) {
GELOGE(GE_CLI_GE_NOT_INITIALIZED,
"[Run][Graph]RunGraphAsyncFailed, the GELib instance is nullptr or is not InitFlag.");
"[Run][Graph]RunGraphAsyncFailed, the GELib instance is nullptr or is not InitFlag, "
"session_id %lu, graph_id %u", sessionId_, graph_id);
REPORT_INNER_ERROR("E19999",
"RunGraphAsync Failed, the GELib instance is nullptr or is not InitFlag.");
"RunGraphAsync Failed, the GELib instance is nullptr or is not InitFlag, "
"session_id %lu, graph_id %u", sessionId_, graph_id);
return FAILED;
}
GELOGT(TRACE_RUNNING, "Run Graph Asynchronously");
@@ -641,6 +663,8 @@ Status Session::RunGraphAsync(uint32_t graph_id, const std::vector<InputTensorIn
if (ret != SUCCESS) {
GELOGE(ret, "[Run][Graph]RunGraphAsync Failed, error code:%u, session_id:%lu, graph_id:%u.",
ret, sessionId_, graph_id);
REPORT_CALL_ERROR("E19999", "RunGraphAsync Failed, error code:%u, session_id:%lu, "
"graph_id:%u", ret, sessionId_, graph_id);
return FAILED;
}
return SUCCESS;
@@ -692,6 +716,8 @@ Status Session::GetVariables(const std::vector<AscendString> &var_names, std::ve
Status ret = ge::GELib::GetInstance()->SessionManagerObj().GetVariables(sessionId_, str_var_names, var_values);
if (ret != SUCCESS) {
GELOGE(ret, "[Get][Variables]Failed, error code:%u, session_id:%lu.", ret, sessionId_);
REPORT_CALL_ERROR("E19999", "Get variables failed, error code:%u, session_id:%lu.",
ret, sessionId_);
return FAILED;
}
return SUCCESS;


+ 34
- 19
ge/common/auth/file_saver.cc View File

@@ -33,8 +33,10 @@ const int kFileOpSuccess = 0;
namespace ge {
Status FileSaver::OpenFile(int32_t &fd, const std::string &file_path) {
if (CheckPath(file_path) != SUCCESS) {
GELOGE(FAILED, "[Check][FilePath]Check output file failed, file_path:%s.", file_path.c_str());
REPORT_CALL_ERROR("E19999", "Check output file failed, file_path:%s.", file_path.c_str());
GELOGE(FAILED, "[Check][FilePath]Check output file failed, file_path:%s.",
file_path.c_str());
REPORT_CALL_ERROR("E19999", "Check output file failed, file_path:%s.",
file_path.c_str());
return FAILED;
}

@@ -47,7 +49,8 @@ Status FileSaver::OpenFile(int32_t &fd, const std::string &file_path) {
if (fd == EN_INVALID_PARAM || fd == EN_ERROR) {
// -1: Failed to open file; - 2: Illegal parameter
GELOGE(FAILED, "[Open][File]Failed. mmpa_errno = %d, %s", fd, strerror(errno));
REPORT_INNER_ERROR("E19999", "Open file failed, mmpa_errno = %d, error:%s.", fd, strerror(errno));
REPORT_INNER_ERROR("E19999", "Open file failed, mmpa_errno = %d, error:%s.",
fd, strerror(errno));
return FAILED;
}
return SUCCESS;
@@ -64,9 +67,10 @@ Status FileSaver::WriteData(const void *data, uint32_t size, int32_t fd) {
while (size > size_1g) {
write_count = mmWrite(fd, reinterpret_cast<void *>(seek), size_1g);
if (write_count == EN_INVALID_PARAM || write_count == EN_ERROR) {
GELOGE(FAILED, "[Write][Data]Failed, mmpa_errorno = %ld, error:%s", write_count, strerror(errno));
REPORT_INNER_ERROR("E19999", "Write data failed, mmpa_errorno = %ld, error:%s.",
write_count, strerror(errno));
GELOGE(FAILED, "[Write][Data]Failed, mmpa_errorno = %ld, error:%s",
write_count, strerror(errno));
REPORT_INNER_ERROR("E19999", "Write data failed, mmpa_errorno = %ld, error:%s.",
write_count, strerror(errno));
return FAILED;
}
size -= size_1g;
@@ -79,7 +83,8 @@ Status FileSaver::WriteData(const void *data, uint32_t size, int32_t fd) {

// -1: Failed to write to file; - 2: Illegal parameter
if (write_count == EN_INVALID_PARAM || write_count == EN_ERROR) {
GELOGE(FAILED, "[Write][Data]Failed. mmpa_errorno = %ld, error:%s", write_count, strerror(errno));
GELOGE(FAILED, "[Write][Data]Failed. mmpa_errorno = %ld, error:%s",
write_count, strerror(errno));
REPORT_INNER_ERROR("E19999", "Write data failed, mmpa_errorno = %ld, error:%s.",
write_count, strerror(errno));
return FAILED;
@@ -91,8 +96,10 @@ Status FileSaver::WriteData(const void *data, uint32_t size, int32_t fd) {
Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFileHeader &file_header, const void *data,
int len) {
if (data == nullptr || len <= 0) {
GELOGE(FAILED, "[Check][Param]Failed, model_data is null or the length[%d] is less than 1.", len);
REPORT_INNER_ERROR("E19999", "Save file failed, model_data is null or the length:%d is less than 1.", len);
GELOGE(FAILED, "[Check][Param]Failed, model_data is null or the "
"length[%d] is less than 1.", len);
REPORT_INNER_ERROR("E19999", "Save file failed, model_data is null or the "
"length:%d is less than 1.", len);
return FAILED;
}

@@ -112,7 +119,8 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi
// Close file
if (mmClose(fd) != 0) { // mmClose 0: success
GELOGE(FAILED, "[Close][File]Failed, error_code:%u errmsg:%s", ret, strerror(errno));
REPORT_INNER_ERROR("E19999", "Close file failed, error_code:%u errmsg:%s", ret, strerror(errno));
REPORT_INNER_ERROR("E19999", "Close file failed, error_code:%u errmsg:%s",
ret, strerror(errno));
ret = FAILED;
}
return ret;
@@ -150,7 +158,8 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi
// Close file
if (mmClose(fd) != EN_OK) {
GELOGE(FAILED, "[Close][File]Failed, error_code:%u errmsg:%s", ret, strerror(errno));
REPORT_CALL_ERROR("E19999", "Close file failed, error_code:%u errmsg:%s", ret, strerror(errno));
REPORT_CALL_ERROR("E19999", "Close file failed, error_code:%u errmsg:%s",
ret, strerror(errno));
ret = FAILED;
}
return ret;
@@ -235,8 +244,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::CheckPath(con
if (file_path.size() >= MMPA_MAX_PATH) {
GELOGE(FAILED, "[Check][FilePath]Failed, file path's length:%zu > mmpa_max_path:%d",
file_path.size(), MMPA_MAX_PATH);
REPORT_INNER_ERROR("E19999", "Check file path failed, file path's length:%zu > mmpa_max_path:%d",
file_path.size(), MMPA_MAX_PATH);
REPORT_INNER_ERROR("E19999", "Check file path failed, file path's length:%zu > "
"mmpa_max_path:%d", file_path.size(), MMPA_MAX_PATH);
return FAILED;
}

@@ -266,8 +275,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::CheckPath(con
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status
FileSaver::SaveToFile(const string &file_path, const ge::ModelData &model, const ModelFileHeader *model_file_header) {
if (file_path.empty() || model.model_data == nullptr || model.model_len == 0) {
GELOGE(FAILED, "[Save][File]Incorrect input param, file_path is empty or model_data is nullptr or model_len is 0");
REPORT_INNER_ERROR("E19999", "Save file failed, at least one of the input parameters(file_path, model_data, model_len) is incorrect");
GELOGE(FAILED, "[Save][File]Incorrect input param, "
"file_path is empty or model_data is nullptr or model_len is 0");
REPORT_INNER_ERROR("E19999", "Save file failed, at least one of the "
"input parameters(file_path, model_data, model_len) is incorrect");
return FAILED;
}

@@ -360,7 +371,8 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi
// Close file
if (mmClose(fd) != 0) { // mmClose 0: success
GELOGE(FAILED, "[Close][File]Failed, error_code:%u errmsg:%s", ret, strerror(errno));
REPORT_CALL_ERROR("E19999", "Close file failed, error_code:%u errmsg:%s", ret, strerror(errno));
REPORT_CALL_ERROR("E19999", "Close file failed, error_code:%u errmsg:%s",
ret, strerror(errno));
ret = FAILED;
}
return ret;
@@ -369,8 +381,10 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::SaveToFile(const string &file_path, const void *data,
int len) {
if (data == nullptr || len <= 0) {
GELOGE(FAILED, "[Check][Param]Failed, model_data is null or the length[%d] is less than 1.", len);
REPORT_INNER_ERROR("E19999", "Save file failed, the model_data is null or its length:%d is less than 1.", len);
GELOGE(FAILED, "[Check][Param]Failed, model_data is null or the "
"length[%d] is less than 1.", len);
REPORT_INNER_ERROR("E19999", "Save file failed, the model_data is null or "
"its length:%d is less than 1.", len);
return FAILED;
}

@@ -386,7 +400,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::SaveToFile(co
// Close file
if (mmClose(fd) != 0) { // mmClose 0: success
GELOGE(FAILED, "[Close][File]Failed, error_code:%u errmsg:%s", ret, strerror(errno));
REPORT_CALL_ERROR("E19999", "Close file failed, error_code:%u errmsg:%s", ret, strerror(errno));
REPORT_CALL_ERROR("E19999", "Close file failed, error_code:%u errmsg:%s",
ret, strerror(errno));
ret = FAILED;
}
return ret;


+ 6
- 3
ge/common/debug/memory_dumper.cc View File

@@ -60,14 +60,16 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::DumpToFile
// mmWrite return -1:Failed to write data to file;return -2:Invalid parameter
if (mmpa_ret == EN_ERROR || mmpa_ret == EN_INVALID_PARAM) {
GELOGE(FAILED, "[Write][Data]Failed, errno = %d, error:%s", mmpa_ret, strerror(errno));
REPORT_INNER_ERROR("E19999", "Write data failed, errno = %d, error:%s.", mmpa_ret, strerror(errno));
REPORT_INNER_ERROR("E19999", "Write data failed, errno = %d, error:%s.",
mmpa_ret, strerror(errno));
ret = FAILED;
}

// Close the file
if (mmClose(fd) != EN_OK) { // mmClose return 0: success
GELOGE(FAILED, "[Close][File]Failed, error_code:%u, filename:%s.", ret, filename);
REPORT_INNER_ERROR("E19999", "Close file failed, error_code:%u, filename:%s.", ret, filename);
REPORT_INNER_ERROR("E19999", "Close file failed, error_code:%u, filename:%s.",
ret, filename);
ret = FAILED;
}

@@ -110,7 +112,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status MemoryDumper::Dump(void
// mmWrite return -1:failed to write data to file;return -2:invalid parameter
if (mmpa_ret == EN_ERROR || mmpa_ret == EN_INVALID_PARAM) {
GELOGE(FAILED, "[Write][Data]Failed, errno = %d, error:%s", mmpa_ret, strerror(errno));
REPORT_INNER_ERROR("E19999", "Write data to file failed, errno = %d, error:%s.", mmpa_ret, strerror(errno));
REPORT_INNER_ERROR("E19999", "Write data to file failed, errno = %d, error:%s.",
mmpa_ret, strerror(errno));
return FAILED;
}



+ 6
- 2
ge/common/dump/dump_manager.cc View File

@@ -56,7 +56,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpManager::SetDumpConf
dump_properties.SetDumpOpSwitch(dump_op_switch);
if (dump_op_switch == kDumpoff && dump_config.dump_list.empty()) {
dump_properties_map_.emplace(kInferSessionId, dump_properties);
GELOGE(PARAM_INVALID, "Dump list is invalid,dump_op_switch is %s", dump_op_switch.c_str());
GELOGE(PARAM_INVALID, "[Check][DumpList]Invalid, dump_op_switch is %s",
dump_op_switch.c_str());
REPORT_INNER_ERROR("E19999", "Dump list check invalid, dump_op_switch is %s",
dump_op_switch.c_str());
return PARAM_INVALID;
}

@@ -82,7 +85,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpManager::SetDumpConf

dump_path = dump_config.dump_path;
if (dump_path.empty()) {
GELOGE(PARAM_INVALID, "Dump path is empty");
GELOGE(PARAM_INVALID, "[Check][DumpPath]It is empty");
REPORT_INNER_ERROR("E19999", "Dump path check is empty");
return PARAM_INVALID;
}



+ 43
- 16
ge/common/dump/dump_op.cc View File

@@ -102,7 +102,10 @@ Status DumpOp::DumpOutput(aicpu::dump::Task &task) {
}
int64_t output_size = 0;
if (TensorUtils::GetTensorSizeInBytes(output_descs.at(i), output_size) != SUCCESS) {
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "Get output size filed");
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Get][TensorSize]Failed, output %zu, node %s(%s),",
i, op_desc_->GetName().c_str(), op_desc_->GetType().c_str());
REPORT_CALL_ERROR("E19999", "Get output %zu tensor size of node %s(%s) failed",
i, op_desc_->GetName().c_str(), op_desc_->GetType().c_str());
return ACL_ERROR_GE_INTERNAL_ERROR;
}
GELOGD("Get output size in lanch dump op is %ld", output_size);
@@ -129,7 +132,10 @@ Status DumpOp::DumpInput(aicpu::dump::Task &task) {
}
int64_t input_size = 0;
if (TensorUtils::GetTensorSizeInBytes(input_descs.at(i), input_size) != SUCCESS) {
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "Get output size filed");
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Get][TensorSize]Failed, input %zu, node %s(%s)",
i, op_desc_->GetName().c_str(), op_desc_->GetType().c_str());
REPORT_CALL_ERROR("E19999", "Get input %zu tensor size of node %s(%s) failed",
i, op_desc_->GetName().c_str(), op_desc_->GetType().c_str());
return ACL_ERROR_GE_INTERNAL_ERROR;
}
GELOGD("Get input size in lanch dump op is %ld", input_size);
@@ -154,30 +160,36 @@ Status DumpOp::ExecutorDumpOp(aicpu::dump::OpMappingInfo &op_mapping_info) {
size_t proto_size = op_mapping_info.ByteSizeLong();
bool ret = op_mapping_info.SerializeToString(&proto_msg);
if (!ret || proto_size == 0) {
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "Protobuf serialize failed, proto_size is %zu", proto_size);
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Serialize][Protobuf]Failed, proto_size is %zu",
proto_size);
REPORT_CALL_ERROR("E19999", "[Serialize][Protobuf]Failed, proto_size is %zu", proto_size);
return ACL_ERROR_GE_INTERNAL_ERROR;
}

rtError_t rt_ret = rtMalloc(&proto_dev_mem_, proto_size, RT_MEMORY_HBM);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(rt_ret, "Call rtMalloc failed, ret: 0x%X", rt_ret);
GELOGE(rt_ret, "[Call][rtMalloc]Failed, ret: 0x%X", rt_ret);
REPORT_CALL_ERROR("E19999", "Call rtMalloc failed, ret: 0x%X", rt_ret);
return RT_ERROR_TO_GE_STATUS(rt_ret);
}

rt_ret = rtMemcpy(proto_dev_mem_, proto_size, proto_msg.c_str(), proto_size, RT_MEMCPY_HOST_TO_DEVICE);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(rt_ret, "Call rtMemcpy failed, ret: 0x%X", rt_ret);
GELOGE(rt_ret, "[Call][rtMemcpy]Failed, ret: 0x%X", rt_ret);
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, ret: 0x%X", rt_ret);
return RT_ERROR_TO_GE_STATUS(rt_ret);
}

rt_ret = rtMalloc(&proto_size_dev_mem_, sizeof(size_t), RT_MEMORY_HBM);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(rt_ret, "Call rtMalloc failed, ret: 0x%X", rt_ret);
GELOGE(rt_ret, "[Call][rtMalloc]Failed, ret: 0x%X", rt_ret);
REPORT_CALL_ERROR("E19999", "Call rtMalloc failed, ret: 0x%X", rt_ret);
return RT_ERROR_TO_GE_STATUS(rt_ret);
}
rt_ret = rtMemcpy(proto_size_dev_mem_, sizeof(size_t), &proto_size, sizeof(size_t), RT_MEMCPY_HOST_TO_DEVICE);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(rt_ret, "Call rtMemcpy failed, ret: 0x%X", rt_ret);
GELOGE(rt_ret, "[Call][rtMemcpy]Failed, ret 0x%X", rt_ret);
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, ret 0x%X", rt_ret);
return RT_ERROR_TO_GE_STATUS(rt_ret);
}

@@ -196,7 +208,8 @@ Status DumpOp::ExecutorDumpOp(aicpu::dump::OpMappingInfo &op_mapping_info) {
nullptr, // no need smDesc
stream_);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(rt_ret, "Call rtCpuKernelLaunch failed,rt_ret:0x%X", rt_ret);
GELOGE(rt_ret, "[Call][rtCpuKernelLaunch]Failed, ret 0x%X", rt_ret);
REPORT_CALL_ERROR("E19999", "Call rtCpuKernelLaunch failed, ret 0x%X", rt_ret);
return RT_ERROR_TO_GE_STATUS(rt_ret);
}
GELOGI("Kernel launch dump op success");
@@ -234,12 +247,13 @@ Status DumpOp::LaunchDumpOp() {
int32_t device_id = 0;
rtError_t rt_ret = rtGetDevice(&device_id);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(rt_ret, "Call rtGetDevice failed, ret = 0x%X, device_id = %d.", rt_ret, device_id);
GELOGE(rt_ret, "[Call][rtGetDevice]Failed, ret 0x%X", rt_ret);
REPORT_CALL_ERROR("E19999", "[Call][rtGetDevice]Failed, ret 0x%X", rt_ret);
return RT_ERROR_TO_GE_STATUS(rt_ret);
}
if (device_id < 0) {
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "Check device_id failed, device_id = %d, which should be not less than 0.",
device_id);
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Check][DeviceId]Failed, device_id %d", device_id);
REPORT_INNER_ERROR("E19999","Check device_id %d failed", device_id);
return ACL_ERROR_GE_INTERNAL_ERROR;
}
aicpu::dump::OpMappingInfo op_mapping_info;
@@ -269,7 +283,10 @@ Status DumpOp::LaunchDumpOp() {
if (dump_properties_.GetDumpMode() == kDumpOutput) {
auto ret = DumpOutput(task);
if (ret != SUCCESS) {
GELOGE(ret, "Dump output failed");
GELOGE(ret, "[Dump][Output]Failed, node %s(%s), ret 0x%X",
op_desc_->GetName().c_str(), op_desc_->GetType().c_str(), ret);
REPORT_CALL_ERROR("E19999", "Dump Output failed, node %s(%s), ret 0x%X",
op_desc_->GetName().c_str(), op_desc_->GetType().c_str(), ret);
return ret;
}
op_mapping_info.mutable_task()->Add(std::move(task));
@@ -277,7 +294,10 @@ Status DumpOp::LaunchDumpOp() {
if (dump_properties_.GetDumpMode() == kDumpInput) {
auto ret = DumpInput(task);
if (ret != SUCCESS) {
GELOGE(ret, "Dump input failed");
GELOGE(ret, "[Dump][Input]Failed, node %s(%s), ret 0x%X",
op_desc_->GetName().c_str(), op_desc_->GetType().c_str(), ret);
REPORT_CALL_ERROR("E19999", "Dump Input failed, node %s(%s), ret 0x%X",
op_desc_->GetName().c_str(), op_desc_->GetType().c_str(), ret);
return ret;
}
op_mapping_info.mutable_task()->Add(std::move(task));
@@ -285,19 +305,26 @@ Status DumpOp::LaunchDumpOp() {
if (dump_properties_.GetDumpMode() == kDumpAll || dump_properties_.IsOpDebugOpen()) {
auto ret = DumpOutput(task);
if (ret != SUCCESS) {
GELOGE(ret, "Dump output failed when in dumping all");
GELOGE(ret, "[Dump][Output]Failed when in dumping all, node %s(%s), ret 0x%X",
op_desc_->GetName().c_str(), op_desc_->GetType().c_str(), ret);
REPORT_CALL_ERROR("E19999", "Dump Output failed when in dumping all, node %s(%s), ret 0x%X",
op_desc_->GetName().c_str(), op_desc_->GetType().c_str(), ret);
return ret;
}
ret = DumpInput(task);
if (ret != SUCCESS) {
GELOGE(ret, "Dump input failed when in dumping all");
GELOGE(ret, "[Dump][Input]Failed when in dumping all, node %s(%s), ret 0x%X",
op_desc_->GetName().c_str(), op_desc_->GetType().c_str(), ret);
REPORT_CALL_ERROR("E19999", "Dump Input failed when in dumping all, node %s(%s), ret 0x%X",
op_desc_->GetName().c_str(), op_desc_->GetType().c_str(), ret);
return ret;
}
op_mapping_info.mutable_task()->Add(std::move(task));
}
auto ret = ExecutorDumpOp(op_mapping_info);
if (ret != SUCCESS) {
GELOGE(ret, "Executor dump op failed");
GELOGE(ret, "[Dump][Op]Failed, ret 0x%X", ret);
REPORT_CALL_ERROR("E19999", "Executor dump op failed, ret 0x%X", ret);
return ret;
}
return SUCCESS;


+ 14
- 6
ge/common/dump/opdebug_register.cc View File

@@ -27,7 +27,9 @@ Status OpdebugRegister::RegisterDebugForModel(rtModel_t model_handle, uint32_t o
GELOGD("Start to register debug for model in overflow");
auto ret = MallocMemForOpdebug();
if (ret != SUCCESS) {
GELOGE(ret, "Malloc memory for opdebug in model overflow failed ,ret:0x%X", ret);
GELOGE(ret, "[Malloc][MemForOpdebug]Failed when debug for model overflow, ret:0x%X", ret);
REPORT_CALL_ERROR("E19999", "Malloc memory for opdebug failed when debug "
"for model in overflow, ret 0x%X", ret);
return ret;
}
uint32_t debug_stream_id = 0;
@@ -74,7 +76,9 @@ Status OpdebugRegister::RegisterDebugForStream(rtStream_t stream, uint32_t op_de
GELOGD("Start to register debug for stream in stream overflow");
auto ret = MallocMemForOpdebug();
if (ret != SUCCESS) {
GELOGE(ret, "Malloc memory for opdebug in stream overflow ,ret:0x%X", ret);
GELOGE(ret, "[Malloc][MemForOpdebug]Failed when debug for stream in overflow, ret:0x%X", ret);
REPORT_CALL_ERROR("E19999", "Malloc memory for opdebug failed when debug "
"for stream in overflow, ret:0x%X", ret);
return ret;
}

@@ -82,7 +86,8 @@ Status OpdebugRegister::RegisterDebugForStream(rtStream_t stream, uint32_t op_de
uint32_t debug_task_id = 0;
auto rt_ret = rtDebugRegisterForStream(stream, op_debug_mode, op_debug_addr_, &debug_stream_id, &debug_task_id);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "rtDebugRegisterForStream error, ret: 0x%X", rt_ret);
GELOGE(RT_FAILED, "[Call][rtDebugRegisterForStream]Failed, ret 0x%X", rt_ret);
REPORT_CALL_ERROR("E19999", "Call rtDebugRegisterForStream failed, ret 0x%X", rt_ret);
return RT_ERROR_TO_GE_STATUS(rt_ret);
}
GELOGD("debug_task_id:%u, debug_stream_id:%u in stream overflow.", debug_task_id, debug_stream_id);
@@ -121,7 +126,8 @@ void OpdebugRegister::UnregisterDebugForStream(rtStream_t stream) {
Status OpdebugRegister::MallocMemForOpdebug() {
rtError_t rt_ret = rtMalloc(&op_debug_addr_, kOpDebugMemorySize, RT_MEMORY_DDR);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "rtMalloc error, ret: 0x%X", rt_ret);
GELOGE(RT_FAILED, "[Call][rtMalloc]Failed, ret 0x%X", rt_ret);
REPORT_CALL_ERROR("E19999", "Call rtMalloc failed, ret 0x%X", rt_ret);
return RT_ERROR_TO_GE_STATUS(rt_ret);
}

@@ -129,12 +135,14 @@ Status OpdebugRegister::MallocMemForOpdebug() {
// For data dump, aicpu needs the pointer to pointer that save the real debug address.
rt_ret = rtMalloc(&p2p_debug_addr_, kDebugP2pSize, RT_MEMORY_HBM);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "rtMalloc error, ret: 0x%X", rt_ret);
GELOGE(RT_FAILED, "[Call][rtMalloc]Failed, ret 0x%X", rt_ret);
REPORT_CALL_ERROR("E19999", "Call rtMalloc failed, ret 0x%X", rt_ret);
return RT_ERROR_TO_GE_STATUS(rt_ret);
}
rt_ret = rtMemcpy(p2p_debug_addr_, sizeof(uint64_t), &debug_addrs_tmp, sizeof(uint64_t), RT_MEMCPY_HOST_TO_DEVICE);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "rtMemcpy to p2p_addr error: 0x%X", rt_ret);
GELOGE(RT_FAILED, "[Call][rtMemcpy]To p2p_addr error 0x%X", rt_ret);
REPORT_CALL_ERROR("E19999", "Call rtMemcpy to p2p_addr error 0x%X", rt_ret);
return RT_ERROR_TO_GE_STATUS(rt_ret);
}



+ 1
- 1
ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc View File

@@ -187,7 +187,7 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in
}
}
}
}
}
}
}
}


+ 5
- 2
ge/common/ge/op_tiling_manager.cc View File

@@ -33,7 +33,9 @@ void OpTilingManager::ClearHandles() noexcept {
if (mmDlclose(handle.second) != 0) {
const char *error = mmDlerror();
GE_IF_BOOL_EXEC(error == nullptr, error = "");
GELOGE(FAILED, "Failed to close handle of %s: %s", handle.first.c_str(), error);
GELOGE(FAILED, "[Close][Handle]Failed, handle of %s: %s", handle.first.c_str(), error);
REPORT_CALL_ERROR("E19999", "Failed to close handle of %s: %s",
handle.first.c_str(), error);
}
}
handles_.clear();
@@ -50,7 +52,8 @@ std::string OpTilingManager::GetPath() {
if (mmRealPath(opp_path_env, resolved_path, MMPA_MAX_PATH) != EN_OK) {
ErrorManager::GetInstance().ATCReportErrMessage(
"E19024", {"env", "value", "situation"}, {"ASCEND_OPP_PATH", opp_path_env, "loading the tiling lib"});
GELOGE(PARAM_INVALID, "Failed load tiling lib as env 'ASCEND_OPP_PATH'[%s] is invalid path.", opp_path_env);
GELOGE(PARAM_INVALID, "[Load][TilingLib]Failed, as env 'ASCEND_OPP_PATH'[%s] "
"is invalid path.", opp_path_env);
return std::string();
}
opp_path = resolved_path;


+ 4
- 3
ge/common/ge/plugin_manager.cc View File

@@ -127,7 +127,7 @@ Status PluginManager::LoadSo(const string &path, const vector<string> &func_chec
ErrorManager::GetInstance().ATCReportErrMessage("E19012", {"function", "reason"},
{"mmDlopen", "shared library path is " + FmtToStr(file_path_dlopen) + ". Errormessage" + FmtToStr(error)});
GELOGE(ACL_ERROR_GE_PLGMGR_PATH_INVALID,
"Failed to dlopen the shared library path[%s]. Errormessage[%s]!",
"[DLOpen][SharedLibraryPath]Failed, path[%s]. Errormessage[%s]!",
file_path_dlopen.c_str(), error);
continue;
}
@@ -140,14 +140,15 @@ Status PluginManager::LoadSo(const string &path, const vector<string> &func_chec
ErrorManager::GetInstance().ATCReportErrMessage("E19012", {"function", "reason"},
{"mmDlsym", FmtToStr(func_name) + " is skipped since function" +
FmtToStr(func_name) + " is not existed!"});
GELOGE(ACL_ERROR_GE_PLGMGR_PATH_INVALID, "%s is skipped since function %s is not existed!",
GELOGE(ACL_ERROR_GE_PLGMGR_PATH_INVALID,
"[Check][So]%s is skipped since function %s is not existed!",
func_name.c_str(), func_name.c_str());
is_valid = false;
break;
}
}
if (!is_valid) {
GE_LOGE_IF(mmDlclose(handle), "Failed to dlclose.");
GE_LOGE_IF(mmDlclose(handle), "[DLClose][Handle]Failed.");
continue;
}



+ 196
- 69
ge/common/helper/model_helper.cc View File

@@ -37,7 +37,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelHelper::~ModelHelper() { (
Status ModelHelper::SaveModelPartition(std::shared_ptr<OmFileSaveHelper> &om_file_save_helper, ModelPartitionType type,
const uint8_t *data, size_t size, size_t model_index) {
if (size < 1 || size > UINT32_MAX) {
GELOGE(PARAM_INVALID, "Add model partition failed, partition size %zu invalid", size);
GELOGE(PARAM_INVALID, "[Add][ModelPartition]Failed, partition size %zu invalid", size);
REPORT_INNER_ERROR("E19999", "Add model partition failed, partition size %zu "
"invalid", size);
if (size > UINT32_MAX) {
string item = "item";
if (type == MODEL_DEF) {
@@ -57,7 +59,8 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr<OmFileSaveHelper> &om_fil
return PARAM_INVALID;
}
if (data == nullptr) {
GELOGE(PARAM_INVALID, "Add model partition failed, data is null");
GELOGE(PARAM_INVALID, "[Add][ModelPartition]Failed, data is null");
REPORT_INNER_ERROR("E19999", "Add model partition failed, data is null");
return PARAM_INVALID;
}
ModelPartition partition_model;
@@ -65,7 +68,8 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr<OmFileSaveHelper> &om_fil
partition_model.size = static_cast<uint32_t>(size);
partition_model.type = type;
if (om_file_save_helper->AddPartition(partition_model, model_index) != SUCCESS) {
GELOGE(PARAM_INVALID, "Add model partition failed, partition size %zu", size);
GELOGE(PARAM_INVALID, "[Add][ModelPartition]Failed, partition size %zu", size);
REPORT_CALL_ERROR("E19999", "Add model partition failed, partition size %zu", size);
return PARAM_INVALID;
}
return SUCCESS;
@@ -106,7 +110,8 @@ Status ModelHelper::SaveModelDef(std::shared_ptr<OmFileSaveHelper> &om_file_save
const GeModelPtr &ge_model, ge::Buffer &model_buffer, size_t model_index) {
ModelPtr model_tmp = ge::MakeShared<ge::Model>(ge_model->GetName(), ge_model->GetPlatformVersion());
if (model_tmp == nullptr) {
GELOGE(FAILED, "Create Model %s Ptr failed", ge_model->GetName().c_str());
GELOGE(FAILED, "[Creat][Model]Failed, Model %s Ptr", ge_model->GetName().c_str());
REPORT_CALL_ERROR("E19999", "Create Model %s Ptr failed", ge_model->GetName().c_str());
return FAILED;
}
model_tmp->SetGraph(ge_model->GetGraph());
@@ -114,7 +119,10 @@ Status ModelHelper::SaveModelDef(std::shared_ptr<OmFileSaveHelper> &om_file_save
model_tmp->SetAttr(ge_model->MutableAttrMap());
Status ret = SaveSizeToModelDef(ge_model);
if (ret != SUCCESS) {
GELOGE(ret, "SaveSizeToModelDef failed");
GELOGE(ret, "[Save][SizeToModelDef]Failed, model %s, error_code %u",
ge_model->GetName().c_str(), ret);
REPORT_CALL_ERROR("E19999", "Save SizeToModelDef failed, model %s, error_code %u",
ge_model->GetName().c_str(), ret);
return ret;
}

@@ -123,7 +131,10 @@ Status ModelHelper::SaveModelDef(std::shared_ptr<OmFileSaveHelper> &om_file_save
if (model_buffer.GetSize() > 0) {
if (SaveModelPartition(om_file_save_helper, ModelPartitionType::MODEL_DEF, model_buffer.GetData(),
model_buffer.GetSize(), model_index) != SUCCESS) {
GELOGE(PARAM_INVALID, "Add model graph partition failed");
GELOGE(PARAM_INVALID, "[Add][ModelPartition]Failed, model %s, model_def size %zu, model_index %zu",
ge_model->GetName().c_str(), model_buffer.GetSize(), model_index);
REPORT_CALL_ERROR("E19999", "Add model graph partititon failed, model %s, model_def %zu, "
"model_index %zu", ge_model->GetName().c_str(), model_buffer.GetSize(), model_index);
return PARAM_INVALID;
}
}
@@ -178,17 +189,26 @@ Status ModelHelper::SaveModelTaskDef(std::shared_ptr<OmFileSaveHelper> &om_file_
const GeModelPtr &ge_model, ge::Buffer &task_buffer, size_t model_index) {
std::shared_ptr<ModelTaskDef> model_task_def = ge_model->GetModelTaskDefPtr();
if (model_task_def == nullptr) {
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Create model task def ptr failed");
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "[Creat][ModelTaskDef]Failed, it is nullptr, "
"model %s", ge_model->GetName().c_str());
REPORT_CALL_ERROR("E19999", "Creat model task def failed, it is nullptr, model %s",
ge_model->GetName().c_str());
return ACL_ERROR_GE_MEMORY_ALLOCATION;
}
size_t partition_task_size = model_task_def->ByteSizeLong();
GE_IF_BOOL_EXEC(partition_task_size == 0 || partition_task_size > INT_MAX,
GELOGE(FAILED, "Model_def's byte size (%zu) is invalid!", partition_task_size);
GELOGE(FAILED, "[Check][ModelDefSize]Invalid, size %zu, model %s",
partition_task_size, ge_model->GetName().c_str());
REPORT_CALL_ERROR("E19999", "Model def size %zu check invalid, model %s",
partition_task_size, ge_model->GetName().c_str());
return FAILED);

task_buffer = ge::Buffer(partition_task_size);
if (task_buffer.GetSize() == 0) {
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Alloc model task def buffer failed");
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "[Allocate][ModelTaskDefBuffer]Failed, "
"model def size %zu, model %s", partition_task_size, ge_model->GetName().c_str());
REPORT_CALL_ERROR("E19999", "Allocate model task def buffer failed, model def size %zu "
"model %s", partition_task_size, ge_model->GetName().c_str());
return ACL_ERROR_GE_MEMORY_ALLOCATION;
}
(void)model_task_def->SerializePartialToArray(task_buffer.GetData(), static_cast<int>(partition_task_size));
@@ -198,7 +218,12 @@ Status ModelHelper::SaveModelTaskDef(std::shared_ptr<OmFileSaveHelper> &om_file_

if (SaveModelPartition(om_file_save_helper, ModelPartitionType::TASK_INFO, task_buffer.GetData(),
partition_task_size, model_index) != SUCCESS) {
GELOGE(PARAM_INVALID, "Add model task def partition failed");
GELOGE(PARAM_INVALID, "[Add][ModelTaskDefPartition]Failed, model def size %zu, "
"model_index %zu, model %s",
partition_task_size, model_index, ge_model->GetName().c_str());
REPORT_CALL_ERROR("E19999", "Add model task def partition failed, model def size %zu "
"model_index %zu, model %s",
partition_task_size, model_index, ge_model->GetName().c_str());
return PARAM_INVALID;
}
return SUCCESS;
@@ -218,7 +243,11 @@ Status ModelHelper::SaveModelHeader(std::shared_ptr<OmFileSaveHelper> &om_file_s
platform_version.size() + 1);
if (err != EOK) {
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION,
"ModelHelper SaveModel failed while allocating memory for platform_version.");
"[Save][Model]Failed while allocating memory for platform_version %s, model %s, "
"errno %d", platform_version.c_str(), ge_model->GetName().c_str(), err);
REPORT_CALL_ERROR("E19999", "ModelHelper save model %s failed while "
"allocating memory for platform_version %s, errno %d",
ge_model->GetName().c_str(), platform_version.c_str(), err);
return ACL_ERROR_GE_MEMORY_ALLOCATION;
}
string version = reinterpret_cast<char *>(model_header.platform_version);
@@ -228,7 +257,11 @@ Status ModelHelper::SaveModelHeader(std::shared_ptr<OmFileSaveHelper> &om_file_s
name_size = name_size > (MODEL_NAME_LENGTH - 1) ? (MODEL_NAME_LENGTH - 1) : name_size;
err = memcpy_s(model_header.name, MODEL_NAME_LENGTH, ge_model->GetName().c_str(), name_size);
if (err != EOK) {
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "ModelHelper SaveModel failed while allocating memory for name");
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION,
"[Save][Model]Failed while allocating memory for model %s, errno %d",
ge_model->GetName().c_str(), err);
REPORT_CALL_ERROR("E19999", "ModelHelper save model failed while allocating memory "
"for model %s,errno %d", ge_model->GetName().c_str(), err);
return ACL_ERROR_GE_MEMORY_ALLOCATION;
}
string model_name = reinterpret_cast<char *>(model_header.name);
@@ -240,28 +273,43 @@ Status ModelHelper::SaveAllModelPartiton(std::shared_ptr<OmFileSaveHelper>& om_f
const GeModelPtr &ge_model, ge::Buffer &model_buffer,
ge::Buffer &task_buffer, size_t model_index) {
if (SaveModelDef(om_file_save_helper, ge_model, model_buffer, model_index) != SUCCESS) {
GELOGE(FAILED, "save model def failed");
GELOGE(FAILED, "[Save][ModelDef]Failed, model %s, model index %zu",
ge_model->GetName().c_str(), model_index);
REPORT_CALL_ERROR("E19999", "ModelHelper save model def failed, model %s, model index %zu",
ge_model->GetName().c_str(), model_index);
return FAILED;
}

if (SaveModelWeights(om_file_save_helper, ge_model, model_index) != SUCCESS) {
GELOGE(FAILED, "save model weights failed");
GELOGE(FAILED, "[Save][ModelWeights]Failed, model %s, model index %zu",
ge_model->GetName().c_str(), model_index);
REPORT_CALL_ERROR("E19999","ModelHelper save mode weights failed, model %s, model index %zu",
ge_model->GetName().c_str(), model_index);
return FAILED;
}

if (SaveModelTbeKernel(om_file_save_helper, ge_model, model_index) != SUCCESS) {
GELOGE(FAILED, "save model tbe kernel failed");
GELOGE(FAILED, "[Save][ModelTbeKernel]Failed, model %s, model index %zu",
ge_model->GetName().c_str(), model_index);
REPORT_CALL_ERROR("E19999", "ModelHelper save model tbe kernel failed, model %s, "
"model index %zu", ge_model->GetName().c_str(), model_index);
return FAILED;
}

if (SaveModelCustAICPU(om_file_save_helper, ge_model, model_index) != SUCCESS) {
GELOGE(FAILED, "save model cust ai cpu failed");
GELOGE(FAILED, "[Save][ModelCustAICPU]Failed, model %s, model index %zu",
ge_model->GetName().c_str(), model_index);
REPORT_CALL_ERROR("E19999", "ModelHelper save model cust aicpu failed, model %s "
"model index %zu", ge_model->GetName().c_str(), model_index);
return FAILED;
}


if (SaveModelTaskDef(om_file_save_helper, ge_model, task_buffer, model_index) != SUCCESS) {
GELOGE(FAILED, "save task def failed");
GELOGE(FAILED, "[Save][TaskDef]Failed, model %s, model index %zu",
ge_model->GetName().c_str(), model_index);
REPORT_CALL_ERROR("E19999", "ModelHelper save task def failed, model %s, model index %zu",
ge_model->GetName().c_str(), model_index);
return FAILED;
}
return SUCCESS;
@@ -272,7 +320,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod
const std::string &output_file,
ModelBufferData& model) {
if (output_file.empty()) {
GELOGE(FAILED, "GraphBuilder SaveModel received invalid file name prefix");
GELOGE(FAILED, "[Save][Model]GraphBuilder SaveModel received invalid file name prefix, "
"model %s", ge_model->GetName().c_str());
REPORT_CALL_ERROR("E19999", "GraphBuilder SaveModel received invalid file name prefix, "
"model %s", ge_model->GetName().c_str());
return FAILED;
}

@@ -284,19 +335,28 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod

auto ret = SaveAllModelPartiton(om_file_save_helper, ge_model, model_buffer, task_buffer);
if (ret != SUCCESS) {
GELOGE(ret, "save all model partition failed");
GELOGE(ret, "[Save][AllModelPartition]Failed, model %s, error_code %u",
ge_model->GetName().c_str(), ret);
REPORT_CALL_ERROR("E19999", "OmFileSaveHelper save all model partition failed, model %s "
"error_code %u", ge_model->GetName().c_str(), ret);
return ret;
}

ret = SaveModelHeader(om_file_save_helper, ge_model);
if (ret != SUCCESS) {
GELOGE(ret, "save model header failed");
GELOGE(ret, "[Save][ModelHeader]Failed, model %s, error_code %u",
ge_model->GetName().c_str(), ret);
REPORT_CALL_ERROR("E19999", "OmFileSaveHelper save model header failed, model %s "
"error_code %u", ge_model->GetName().c_str(), ret);
return ret;
}

ret = om_file_save_helper->SaveModel(save_param, output_file.c_str(), model, is_offline_);
if (ret != SUCCESS) {
GELOGE(FAILED, "OmFileSaveHelper SaveModel return fail.");
GELOGE(FAILED, "[Save][Model]Failed, model %s, output file %s",
ge_model->GetName().c_str(), output_file.c_str());
REPORT_CALL_ERROR("E19999", "OmFileSaveHelper save model failed, model %s, "
"output file %s", ge_model->GetName().c_str(), output_file.c_str());
return ret;
}
return SUCCESS;
@@ -310,12 +370,21 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmRoo
bool is_unknown_shape) {

GE_CHECK_NOTNULL(ge_root_model);
GE_IF_BOOL_EXEC(ge_root_model == nullptr, GELOGE(FAILED, "Ge_root_model is nullptr"); return FAILED);
GE_IF_BOOL_EXEC(ge_root_model == nullptr,
GELOGE(FAILED, "[Check][GERootModel]Ge_root_model is nullptr");
REPORT_INNER_ERROR("E19999", "Ge_root_model check failed, it is nullptr");
return FAILED);

auto &name_to_ge_model = ge_root_model->GetSubgraphInstanceNameToModel();
GE_IF_BOOL_EXEC(name_to_ge_model.empty(), GELOGE(FAILED, "Ge_root_model has no sub model"); return FAILED);
GE_IF_BOOL_EXEC(name_to_ge_model.empty(),
GELOGE(FAILED, "[Get][SubModel]Ge_root_model has no sub model");
REPORT_INNER_ERROR("E19999", "Ge_root_model has no sub model");
return FAILED);
GE_IF_BOOL_EXEC(output_file.empty(),
GELOGE(FAILED, "GraphBuilder SaveModel received invalid file name prefix");
GELOGE(FAILED, "[Save][Model]GraphBuilder SaveModel received invalid "
"file name prefix");
REPORT_INNER_ERROR("E19999", "GraphBuilder SaveModel received invalid "
"file name prefix");
return FAILED);

if (!is_unknown_shape) {
@@ -344,7 +413,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmRoo
if (model_names.size() > 1) {
GELOGD("only save first model MODEL_DEF");
if (SaveModelDef(om_file_save_helper, first_ge_model, model_buffers[cur_index], cur_index) != SUCCESS) {
GELOGE(FAILED, "save model def failed");
GELOGE(FAILED, "[Save][ModelDef]Failed, cur_index %zu", cur_index);
REPORT_INNER_ERROR("E19999", "Save model def failed, cur_index %zu", cur_index);
return FAILED;
}
++cur_index;
@@ -357,20 +427,28 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmRoo
auto ret = SaveAllModelPartiton(om_file_save_helper, ge_model, model_buffers[cur_index],
task_buffers[cur_index], cur_index);
if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Save model %s failed", model_name.c_str());
GELOGE(INTERNAL_ERROR, "[Save][AllModelPartition]Failed, model name %s, cur_index %zu",
model_name.c_str(), cur_index);
REPORT_CALL_ERROR("E19999", "Save all model %s partition failed, cur_index %zu",
model_name.c_str(), cur_index);
return INTERNAL_ERROR;
}
}

auto ret = SaveModelHeader(om_file_save_helper, first_ge_model, model_names.size());
if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Save model %s header failed", first_ge_model->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Save][ModelHeader]Failed, model name %s",
first_ge_model->GetName().c_str());
REPORT_CALL_ERROR("E19999", "Save model %s header failed", first_ge_model->GetName().c_str());
return INTERNAL_ERROR;
}

ret = om_file_save_helper->SaveRootModel(save_param, output_file.c_str(), model, is_offline_);
if (ret != SUCCESS) {
GELOGE(FAILED, "OmFileSaveHelper SaveModel return fail.");
GELOGE(FAILED, "[Save][Model]OmFileSaveHelper save model eturn fail, output_file %s",
output_file.c_str());
REPORT_CALL_ERROR("E19999", "OmFileSaveHelper save model return fail, output_file %s",
output_file.c_str());
return FAILED;
}
return SUCCESS;
@@ -379,13 +457,17 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmRoo
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status
ModelHelper::SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::string &output_file) {
if (output_file.empty()) {
GELOGE(FAILED, "SaveModel received invalid file name prefix");
GELOGE(FAILED, "[Save][Model]Received invalid file name prefix, output_file %s",
output_file.c_str());
REPORT_INNER_ERROR("E19999", "Save model received invalid file name prefix, output_file %s",
output_file.c_str());
return FAILED;
}
// Get computegraph from graph
auto compute_graph = ge::GraphUtils::GetComputeGraph(graph);
if (compute_graph == nullptr) {
GELOGE(FAILED, "SaveModel fail for compute_graph null");
GELOGE(FAILED, "[Save][Model]Failed for compute_graph null");
REPORT_INNER_ERROR("E19999", "Save model failed for compute_graph null");
return FAILED;
}
GE_DUMP(compute_graph, "OriginalGraph");
@@ -407,7 +489,10 @@ ModelHelper::SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::strin
ge::Buffer model_buffer;
ge::graphStatus status = model_ptr->Save(model_buffer);
if (status != ge::GRAPH_SUCCESS) {
GELOGE(FAILED, "SaveModel fail for save buffer fail");
GELOGE(FAILED, "[Save][Model]Failed for save buffer fail, model %s",
model_ptr->GetName().c_str());
REPORT_CALL_ERROR("E19999", "Save model %s failed for save buffer fail",
model_ptr->GetName().c_str());
return FAILED;
}
std::shared_ptr<OmFileSaveHelper> om_file_save_helper = ge::MakeShared<OmFileSaveHelper>();
@@ -429,14 +514,20 @@ ModelHelper::SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::strin
errno_t err = memcpy_s(model_header.platform_version, PLATFORM_VERSION_LEN, platform_version.c_str(),
platform_version.size() + 1);
if (err != EOK) {
GELOGE(FAILED, "ModelHelper SaveModel failed for platform_version");
GELOGE(FAILED, "[Save][Model]Failed for platform_version %s, model %s, errno %d",
platform_version.c_str(), model_ptr->GetName().c_str(), err);
REPORT_CALL_ERROR("E19999", "Save model %s failed for platform_version %s, errno %d",
model_ptr->GetName().c_str(), platform_version.c_str(), err);
return FAILED;
}
size_t name_size = model_ptr->GetName().size();
name_size = name_size > (MODEL_NAME_LENGTH - 1) ? (MODEL_NAME_LENGTH - 1) : name_size;
err = memcpy_s(model_header.name, MODEL_NAME_LENGTH, model_ptr->GetName().c_str(), name_size);
if (err != EOK) {
GELOGE(FAILED, "ModelHelper SaveModel memory copy failed");
GELOGE(FAILED, "[Save][Model]Failed for memory copy %s failed, errno %d",
model_ptr->GetName().c_str(), err);
REPORT_CALL_ERROR("E19999", "Save model failed for memory copy %s failed, errno %d",
model_ptr->GetName().c_str(), err);
return FAILED;
}
ModelBufferData model;
@@ -446,23 +537,26 @@ ModelHelper::SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::strin

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadModel(const ge::ModelData &model_data) {
if (model_data.model_data == nullptr || model_data.model_len == 0) {
GELOGE(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID, "Model_data is nullptr, or model_data_size is 0");
GELOGE(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID,
"[Load][Model]Model_data is nullptr or model_data_size is 0");
REPORT_INNER_ERROR("E19999", "Load model failed, "
"Model_data is nullptr or model_data_size is 0");
return ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID;
}

if (is_assign_model_) {
GELOGE(ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED, "Model helper has already loaded!");
GELOGE(ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED, "[Load][Model]Model helper has already loaded!");
return ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED;
}

if (ReleaseLocalModelData() != SUCCESS) {
GELOGE(ACL_ERROR_GE_EXEC_RELEASE_MODEL_DATA, "ReleaseLocalModelData failed.");
GELOGE(ACL_ERROR_GE_EXEC_RELEASE_MODEL_DATA, "[Release][ModelData]Failed.");
return ACL_ERROR_GE_EXEC_RELEASE_MODEL_DATA;
}

Status status = ModelParserBase::ParseModelContent(model_data, model_addr_tmp_, model_len_tmp_);
if (status != SUCCESS) {
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Parse model content failed!");
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Parse][ModelContent]Failed!");
return ACL_ERROR_GE_PARAM_INVALID;
}

@@ -470,14 +564,14 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadModel(c
OmFileLoadHelper om_load_helper;
status = om_load_helper.Init(model_addr_tmp_, model_len_tmp_);
if (status != SUCCESS) {
GELOGE(status, "Om_load_helper init failed");
GELOGE(status, "[Init][OmLoadHelper]Failed");
model_addr_tmp_ = nullptr;
return status;
}
auto partition_table = reinterpret_cast<ModelPartitionTable *>(model_addr_tmp_);
if (partition_table->num == kOriginalOmPartitionNum) {
model_addr_tmp_ = nullptr;
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "om model is error,please use executable om model");
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Check][OmModel]Error, please use executable om model");
return ACL_ERROR_GE_PARAM_INVALID;
}
// Encrypt model need to del temp model/no encrypt model don't need to del model
@@ -485,7 +579,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadModel(c

status = GenerateGeModel(om_load_helper);
if (status != SUCCESS) {
GELOGE(status, "GenerateGeModel failed");
GELOGE(status, "[Generate][GEModel]Failed");
return status;
}
GELOGD("in ModelHelper::LoadModel, is_assign_model_ is setted to true!");
@@ -495,23 +589,26 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadModel(c

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadRootModel(const ge::ModelData &model_data) {
if (model_data.model_data == nullptr || model_data.model_len == 0) {
GELOGE(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID, "Model_data is nullptr, or model_data_size is 0");
GELOGE(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID, "[Load][RootModel] "
"Model_data is nullptr or model_data_size is 0");
REPORT_INNER_ERROR("E19999", "Load root model failed, model_data is nullptr or its size is 0");
return ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID;
}

if (is_assign_model_) {
GELOGE(ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED, "Model helper has already loaded!");
GELOGE(ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED,
"[Load][RootModel]Model helper has already loaded!");
return ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED;
}

if (ReleaseLocalModelData() != SUCCESS) {
GELOGE(INTERNAL_ERROR, "ReleaseLocalModelData failed.");
GELOGE(INTERNAL_ERROR, "[Release][ModelData]Failed.");
return INTERNAL_ERROR;
}

Status status = ModelParserBase::ParseModelContent(model_data, model_addr_tmp_, model_len_tmp_);
if (status != SUCCESS) {
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Parse model content failed!");
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Parse][RootModelContent]Failed!");
return ACL_ERROR_GE_PARAM_INVALID;
}

@@ -530,7 +627,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadRootMod
status = om_load_helper.Init(model_addr_tmp_, model_len_tmp_);
}
if (status != SUCCESS) {
GELOGE(status, "Om_load_helper init failed");
GELOGE(status, "[Init][OmLoadHelper]Failed");
model_addr_tmp_ = nullptr;
return status;
}
@@ -539,7 +636,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadRootMod

status = GenerateGeRootModel(om_load_helper);
if (status != SUCCESS) {
GELOGE(status, "GenerateGeRootModel failed");
GELOGE(status, "[Generate][GERootModel]Failed");
return status;
}
GELOGD("in ModelHelper::LoadRootModel, is_assign_model_ is setted to true!");
@@ -579,7 +676,8 @@ Status ModelHelper::GenerateGeRootModel(OmFileLoadHelper &om_load_helper) {
GE_CHECK_NOTNULL(root_model_);
if (!is_unknown_shape_model_) {
if (GenerateGeModel(om_load_helper) != SUCCESS) {
GELOGE(FAILED, "GenerateGeModel failed");
GELOGE(FAILED, "[Generate][GERootModel]Failed");
REPORT_CALL_ERROR("E19999", "Generate GE root model failed");
return FAILED;
}
GE_CHECK_NOTNULL(model_);
@@ -637,7 +735,10 @@ Status ModelHelper::LoadModelData(OmFileLoadHelper &om_load_helper) {

ge::Model model;
if (ge::Model::Load(partition_model_def.data, partition_model_def.size, model) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Load model failed.");
GELOGE(INTERNAL_ERROR, "[Load][Model]Failed, model_def partition addr:%p, size:%u",
partition_model_def.data, partition_model_def.size);
REPORT_CALL_ERROR("E19999", "Load model failed, model_def partition addr:%p, size:%u",
partition_model_def.data, partition_model_def.size);
return INTERNAL_ERROR;
}

@@ -661,7 +762,10 @@ Status ModelHelper::LoadModelData(OmFileLoadHelper &om_load_helper, GeModelPtr &

ge::Model model;
if (ge::Model::Load(partition_model_def.data, partition_model_def.size, model) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Load model failed.");
GELOGE(INTERNAL_ERROR, "[Load][Model]Failed, model_def partition addr:%p, size:%u",
partition_model_def.data, partition_model_def.size);
REPORT_CALL_ERROR("E19999", "Load model failed, model_def partition addr:%p, size:%u",
partition_model_def.data, partition_model_def.size);
return INTERNAL_ERROR;
}

@@ -673,7 +777,9 @@ Status ModelHelper::LoadModelData(OmFileLoadHelper &om_load_helper, GeModelPtr &
Status ModelHelper::LoadWeights(OmFileLoadHelper &om_load_helper) {
ModelPartition partition;
if (om_load_helper.GetModelPartition(ModelPartitionType::WEIGHTS_DATA, partition) != SUCCESS) {
GELOGE(FAILED, "Get weight model partition failed.");
GELOGE(FAILED, "[Get][ModelWeightPartition]Failed, GetWeight size:%u", partition.size);
REPORT_CALL_ERROR("E19999", "[Get][ModelPartition]Failed, GetWeight size:%u",
partition.size);
return FAILED;
}
ge::Buffer weight = ge::Buffer::CopyFrom(partition.data, partition.size);
@@ -686,7 +792,9 @@ Status ModelHelper::LoadWeights(OmFileLoadHelper &om_load_helper) {
Status ModelHelper::LoadWeights(OmFileLoadHelper &om_load_helper, GeModelPtr &cur_model, size_t mode_index) {
ModelPartition partition;
if (om_load_helper.GetModelPartition(ModelPartitionType::WEIGHTS_DATA, partition, mode_index) != SUCCESS) {
GELOGE(FAILED, "Get weight model partition failed.");
GELOGE(FAILED, "[Get][ModelPartition]Failed, GetWeight size:%u", partition.size);
REPORT_CALL_ERROR("E19999", "[Get][ModelPartition]Failed, GetWeight size:%u",
partition.size);
return FAILED;
}
ge::Buffer weight = ge::Buffer::CopyFrom(partition.data, partition.size);
@@ -699,14 +807,19 @@ Status ModelHelper::LoadWeights(OmFileLoadHelper &om_load_helper, GeModelPtr &cu
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadTask(OmFileLoadHelper &om_load_helper) {
ModelPartition task_partition;
if (om_load_helper.GetModelPartition(ModelPartitionType::TASK_INFO, task_partition) != SUCCESS) {
GELOGE(FAILED, "Get task model partition failed.");
GELOGE(FAILED, "[Get][ModelTaskPartition]Failed, task_partition size:%u", task_partition.size);
REPORT_CALL_ERROR("E19999", "Get model task partition failed, task_partition size %u",
task_partition.size);
return FAILED;
}
std::shared_ptr<ModelTaskDef> task = ge::MakeShared<ModelTaskDef>();
GE_CHECK_NOTNULL(task);
if (task_partition.size != 0) {
if (!ReadProtoFromArray(task_partition.data, task_partition.size, task.get())) {
GELOGE(INTERNAL_ERROR, "ReadProtoFromArray failed.");
GELOGE(INTERNAL_ERROR, "[Read][ProtoFromArray]Failed, task_partition size %u",
task_partition.size);
REPORT_CALL_ERROR("E19999", "Read proto from array failed, task_partition size %u",
task_partition.size);
return INTERNAL_ERROR;
}
GELOGD("TASK_INFO op_size:%d, stream_num:%u", task->op().size(), task->stream_num());
@@ -721,13 +834,20 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadTask(Om
ModelPartition task_partition;
if (om_load_helper.GetModelPartition(ModelPartitionType::TASK_INFO, task_partition, mode_index) != SUCCESS) {
GELOGE(FAILED, "Get task model partition failed.");
GELOGE(FAILED, "[Get][ModelTaskPartition]Failed, task_partition size %u, mode_index %zu",
task_partition.size, mode_index);
REPORT_CALL_ERROR("E19999", "Get model task partition failed, "
"task_partition size %u, mode_index %zu", task_partition.size, mode_index);
return FAILED;
}
std::shared_ptr<ModelTaskDef> task = ge::MakeShared<ModelTaskDef>();
GE_CHECK_NOTNULL(task);
if (task_partition.size != 0) {
if (!ReadProtoFromArray(task_partition.data, task_partition.size, task.get())) {
GELOGE(INTERNAL_ERROR, "ReadProtoFromArray failed.");
GELOGE(INTERNAL_ERROR, "[Read][ProtoFromArray]Failed, task_partition size %u",
task_partition.size);
REPORT_CALL_ERROR("E19999", "Read proto from array failed, task_partition size %u",
task_partition.size);
return INTERNAL_ERROR;
}
GELOGD("TASK_INFO op_size:%d, stream_num:%u", task->op().size(), task->stream_num());
@@ -835,7 +955,8 @@ Status ModelHelper::ReleaseLocalModelData() noexcept {
if (model_addr_tmp_ != nullptr) {
errno_t ret = memset_s(static_cast<void *>(model_addr_tmp_), model_len_tmp_, 0, model_len_tmp_);
if (ret != EOK) {
GELOGE(FAILED, "Failed to memset memory, error-code %d", ret);
GELOGE(FAILED, "[Memset][Memory]Failed, error-code %d", ret);
REPORT_CALL_ERROR("E19999", "Failed to memset memory, error-code %d", ret);
result = FAILED;
}
delete[] model_addr_tmp_;
@@ -884,7 +1005,9 @@ Status ModelTool::GetModelInfoFromOm(const char *model_file, ge::proto::ModelDef

Status ret = ModelParserBase::LoadFromFile(model_file, "", priority, model);
if (ret != SUCCESS) {
GELOGE(ret, "LoadFromFile failed.");
GELOGE(ret, "[Load][ModelInfo]Failed from file %s, error_code %u", model_file, ret);
REPORT_CALL_ERROR("E19999", "Load model info failed from file %s, error_code %u",
model_file, ret);
return ret;
}
std::function<void()> callback = [&]() {
@@ -902,31 +1025,32 @@ Status ModelTool::GetModelInfoFromOm(const char *model_file, ge::proto::ModelDef
ErrorManager::GetInstance().ATCReportErrMessage("E10003",
{"parameter", "value", "reason"}, {"om", model_file, "invalid om file"});
GELOGE(ACL_ERROR_GE_PARAM_INVALID,
"ParseModelContent failed because of invalid om file. Please check --om param.");
"[Parse][ModelContent]Failed because of invalid om file %s, please check om param",
model_file);
return ret;
}

OmFileLoadHelper om_load_helper;
ret = om_load_helper.Init(model_data, model_len);
if (ret != SUCCESS) {
ErrorManager::GetInstance().ATCReportErrMessage("E19021", {"reason"}, {"Om file init failed"});
GELOGE(ge::FAILED, "Om file init failed.");
REPORT_INNER_ERROR("E19999", "Init om file %s failed", model_file);
GELOGE(ge::FAILED, "[Init][OmFile]Failed, model_file %s", model_file);
return ret;
}

ModelPartition ir_part;
ret = om_load_helper.GetModelPartition(MODEL_DEF, ir_part);
if (ret != SUCCESS) {
ErrorManager::GetInstance().ATCReportErrMessage("E19021", {"reason"}, {"Get model part failed"});
GELOGE(ge::FAILED, "Get model part failed.");
REPORT_INNER_ERROR("E19999", "Get model partition failed, model_file %s", model_file);
GELOGE(ge::FAILED, "[Get][ModelPart]Failed, model_file %s", model_file);
return ret;
}

bool flag = ReadProtoFromArray(ir_part.data, ir_part.size, &model_def);
if (!flag) {
ret = INTERNAL_ERROR;
ErrorManager::GetInstance().ATCReportErrMessage("E19021", {"reason"}, {"ReadProtoFromArray failed"});
GELOGE(ret, "ReadProtoFromArray failed.");
REPORT_INNER_ERROR("E19999", "Read proto from array failed, model_file %s", model_file);
GELOGE(ret, "[Read][ProtoFromArray]Failed, model_file %s", model_file);
return ret;
}
modeldef_size = ir_part.size;
@@ -947,7 +1071,9 @@ Status ModelTool::GetModelInfoFromPbtxt(const char *model_file, ge::proto::Model
};
if (ret != SUCCESS) {
free_model_data(&model.model_data);
GELOGE(ret, "LoadFromFile failed.");
GELOGE(ret, "[Load][ModelInfo]Failed from file %s, error_code %u", model_file, ret);
REPORT_CALL_ERROR("E19999", "Load model info failed from file %s, error_code %u",
model_file, ret);
return ret;
}

@@ -955,17 +1081,18 @@ Status ModelTool::GetModelInfoFromPbtxt(const char *model_file, ge::proto::Model
bool flag = google::protobuf::TextFormat::ParseFromString(reinterpret_cast<char *>(model.model_data), &model_def);
if (!flag) {
free_model_data(&model.model_data);
ErrorManager::GetInstance().ATCReportErrMessage("E19021", {"reason"}, {"ParseFromString failed"});
GELOGE(FAILED, "ParseFromString failed.");
REPORT_INNER_ERROR("E19999", "Parse model info failed from string, model_file %s", model_file);
GELOGE(FAILED, "[Parse][ModelInfo]Failed from string, model_file %s", model_file);
return FAILED;
}
free_model_data(&model.model_data);
return SUCCESS;
} catch (google::protobuf::FatalException &e) {
free_model_data(&model.model_data);
ErrorManager::GetInstance().ATCReportErrMessage("E19021", {"reason"}, {"ParseFromString failed, exception message["
+ std::string(e.what()) + "]"});
GELOGE(FAILED, "ParseFromString failed. exception message : %s", e.what());
REPORT_INNER_ERROR("E19999", "Parse model info failed from string, exception message %s, model_file %s",
e.what(), model_file);
GELOGE(FAILED, "[Parse][ModelInfo]Failed from string, exception message %s, model_file %s",
e.what(), model_file);
return FAILED;
}
}


Loading…
Cancel
Save