Browse Source

ge log optimize

tags/v1.3.0
liyihan2@huawei.com 4 years ago
parent
commit
26ff4788de
11 changed files with 248 additions and 92 deletions
  1. +24
    -6
      ge/analyzer/analyzer.cc
  2. +19
    -2
      ge/client/ge_api.cc
  3. +32
    -17
      ge/common/auth/file_saver.cc
  4. +6
    -3
      ge/common/debug/memory_dumper.cc
  5. +5
    -2
      ge/common/dump/dump_manager.cc
  6. +32
    -16
      ge/common/dump/dump_op.cc
  7. +15
    -7
      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. +105
    -33
      ge/common/helper/model_helper.cc

+ 24
- 6
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");
return PARAM_INVALID;
}

@@ -222,9 +235,12 @@ ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_
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],"
"[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();
@@ -247,6 +263,8 @@ ge::Status Analyzer::DoAnalyze(DataInfo &data_info) {
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


+ 19
- 2
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;
}

@@ -112,6 +114,8 @@ Status GEInitializeImpl(const std::map<string, string> &options) {
GELOGE(GE_CLI_INIT_FAILED,
"[Init][OpsProtoPath]Loading OpsProto lib plugin failed, OpsProtoPath:%s invalid.",
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,14 @@ 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.");
}

// 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");
@@ -492,6 +499,8 @@ Status Session::RemoveGraph(uint32_t graph_id) {
GELOGE(ret,
"[Remove][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.",
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");
@@ -569,6 +578,8 @@ Status Session::RunGraph(uint32_t graph_id, const std::vector<Tensor> &inputs, s
GELOGE(ret,
"[Run][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.",
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;
}

@@ -615,6 +626,8 @@ Status Session::BuildGraph(uint32_t graph_id, const std::vector<InputTensorInfo>
GELOGE(ret,
"[Build][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.",
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;
@@ -641,6 +654,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 +707,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;


+ 32
- 17
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,7 +67,8 @@ 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));
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;
@@ -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;
}



+ 5
- 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,7 @@ 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");
return PARAM_INVALID;
}



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

@@ -102,7 +102,8 @@ 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_size %d", output_size);
REPORT_CALL_ERROR("E19999", "Get output_size %d failed", output_size);
return ACL_ERROR_GE_INTERNAL_ERROR;
}
GELOGD("Get output size in lanch dump op is %ld", output_size);
@@ -129,7 +130,8 @@ 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, iutput_size %d", iutput_size);
REPORT_CALL_ERROR("E19999", "Get input size %d failed", input_size);
return ACL_ERROR_GE_INTERNAL_ERROR;
}
GELOGD("Get input size in lanch dump op is %ld", input_size);
@@ -154,30 +156,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 +204,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");
@@ -230,12 +239,14 @@ 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, device_id %d.", rt_ret, device_id);
REPORT_CALL_ERROR("E19999", "[Call][rtGetDevice]Failed, ret 0x%X, device_id %d.",
rt_ret, device_id);
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;
@@ -265,7 +276,8 @@ 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, ret 0x%X", ret);
REPORT_CALL_ERROR("E19999", "Dump Output failed, ret 0x%X", ret);
return ret;
}
op_mapping_info.mutable_task()->Add(std::move(task));
@@ -273,7 +285,8 @@ 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, ret 0x%X", ret);
REPORT_CALL_ERROR("E19999", "Dump Input failed, ret 0x%X", ret);
return ret;
}
op_mapping_info.mutable_task()->Add(std::move(task));
@@ -281,19 +294,22 @@ 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, ret 0x%X", ret);
REPORT_CALL_ERROR("E19999", "Dump Output failed when in dumping all, ret 0x%X", 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, ret 0x%X", ret);
REPORT_CALL_ERROR("E19999", "Dump Input failed when in dumping all, ret 0x%X", 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;


+ 15
- 7
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 in model overflow, ret:0x%X", ret);
REPORT_CALL_ERROR("E19999", "Malloc memory for opdebug failed in model overflow, "
"ret 0x%X", ret);
return ret;
}
uint32_t debug_stream_id = 0;
@@ -74,15 +76,18 @@ 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);
return ret;
GELOGE(ret, "[Malloc][MemForOpdebug]Failed in stream overflow, ret:0x%X", ret);
REPORT_CALL_ERROR("E19999", "Malloc memory for opdebug failed in model overflow, "
"ret:0x%X", ret);
return ret
}

uint32_t debug_stream_id = 0;
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;
}



+ 105
- 33
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);
REPROT_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,8 @@ 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, error_code %u", ret);
REPORT_CALL_ERROR("E19999", "Save SizeToModelDef failed, error_code %u", ret);
return ret;
}

@@ -123,7 +129,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_def size %zu, model_index %zu",
model_buffer.GetSize(), model_index);
REPORT_CALL_ERROR("E19999", "Add model graph partititon failed, model_def %zu, "
"model_index %zu", model_buffer.GetSize(), model_index);
return PARAM_INVALID;
}
}
@@ -178,17 +187,24 @@ 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");
REPORT_CALL_ERROR("E19999", "Creat model task def failed, it is nullptr");
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!",
partition_task_size);
REPORT_CALL_ERROR("E19999", "Model def size %zu check invalid,"
partition_task_size);
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", partition_task_size);
REPORT_CALL_ERROR("E19999", "Allocate model task def buffer failed, model def size %zu",
partition_task_size);
return ACL_ERROR_GE_MEMORY_ALLOCATION;
}
(void)model_task_def->SerializePartialToArray(task_buffer.GetData(), static_cast<int>(partition_task_size));
@@ -198,7 +214,10 @@ 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", partition_task_size, model_index);
REPORT_CALL_ERROR("E19999", "Add model task def partition failed, model def size %zu "
"model_index %zu", partition_task_size, model_index);
return PARAM_INVALID;
}
return SUCCESS;
@@ -218,7 +237,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, errno %d",
platform_version.c_str(), err);
REPORT_CALL_ERROR("E19999", "ModelHelper save model failed while "
"allocating memory for platform_version %s, errno %d",
platform_version.c_str(), err);
return ACL_ERROR_GE_MEMORY_ALLOCATION;
}
string version = reinterpret_cast<char *>(model_header.platform_version);
@@ -228,7 +251,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 name %s, errno %d",
ge_model->GetName().c_str(), err);
REPORT_CALL_ERROR("E19999", "ModelHelper save model failed while allocating memory "
"for name %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 +267,38 @@ 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 index %zu", model_index);
REPORT_INNER_ERROR("E19999", "ModelHelper save model def failed, model index %zu",
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 index %zu", model_index);
REPORT_INNER_ERROR("E19999","ModelHelper save mode weights failed, mode index %zu",
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 index %zu", model_index);
REPORT_INNER_ERROR("E19999", "ModelHelper save model tbe kernel failed, model index %zu",
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 index %zu", model_index);
REPORT_INNER_ERROR("E19999", "ModelHelper save model cust aicpu failed, "
"model index %zu", 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 index %zu", model_index);
REPORT_INNER_ERROR("E19999", "ModelHelper save task def failed, model index %zu",
model_index);
return FAILED;
}
return SUCCESS;
@@ -272,7 +309,8 @@ 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");
REPORT_INNER_ERROR("E19999", "GraphBuilder SaveModel received invalid file name prefix");
return FAILED;
}

@@ -284,19 +322,25 @@ 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, error_code %u", ret);
REPORT_INNER_ERROR("E19999", "OmFileSaveHelper save all model partition failed, "
"error_code %u", 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, error_code %u", ret);
REPORT_INNER_ERROR("E19999", "OmFileSaveHelper save model header failed, "
"error_code %u", 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, output file %s", output_file.c_str());
REPORT_INNER_ERROR("E19999", "OmFileSaveHelper save model failed, output file %s",
output_file.c_str());
return ret;
}
return SUCCESS;
@@ -310,12 +354,19 @@ 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 +395,10 @@ 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, model name %s, cur_index %zu",
model_name.c_str(), cur_index);
REPORT_INNER_ERROR("E19999", "Save model %s def failed, cur_index %zu",
model_name.c_str(), cur_index);
return FAILED;
}
++cur_index;
@@ -357,20 +411,27 @@ 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_INNER_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_INNER_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 return fail, output_file %s",
output_file.c_str());
REPORT_INNER_ERROR("E19999", "OmFileSaveHelper save model return fail, output_file %s",
output_file.c_str());
return FAILED;
}
return SUCCESS;
@@ -379,13 +440,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_CALL_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_CALL_ERROR("E19999", "Save model failed for compute_graph null");
return FAILED;
}
GE_DUMP(compute_graph, "OriginalGraph");
@@ -407,7 +472,8 @@ 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");
REPORT_INNER_ERROR("E19999", "Save model failed for save buffer fail");
return FAILED;
}
std::shared_ptr<OmFileSaveHelper> om_file_save_helper = ge::MakeShared<OmFileSaveHelper>();
@@ -429,14 +495,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, errno %d",
platform_version.c_str(), err);
REPORT_CALL_ERROR("E19999", "Save model failed for platform_version %s, errno %d",
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;


Loading…
Cancel
Save