@@ -11,8 +11,6 @@ elseif (ENABLE_D) | |||||
endif () | endif () | ||||
set(PROTO_LIST | set(PROTO_LIST | ||||
"${METADEF_DIR}/proto/dump_task.proto" | |||||
"${METADEF_DIR}/proto/op_mapping_info.proto" | |||||
"${METADEF_DIR}/proto/fusion_model.proto" | "${METADEF_DIR}/proto/fusion_model.proto" | ||||
"${GE_CODE_DIR}/ge/proto/optimizer_priority.proto" | "${GE_CODE_DIR}/ge/proto/optimizer_priority.proto" | ||||
) | ) | ||||
@@ -27,6 +25,7 @@ set(PROTO_HEADER_LIST | |||||
"${METADEF_DIR}/proto/insert_op.proto" | "${METADEF_DIR}/proto/insert_op.proto" | ||||
"${METADEF_DIR}/proto/ge_ir.proto" | "${METADEF_DIR}/proto/ge_ir.proto" | ||||
"${METADEF_DIR}/proto/fwk_adapter.proto" | "${METADEF_DIR}/proto/fwk_adapter.proto" | ||||
"${METADEF_DIR}/proto/op_mapping.proto" | |||||
) | ) | ||||
protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) | protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) | ||||
@@ -104,6 +104,7 @@ ge::Status Analyzer::Initialize() { | |||||
string real_path = RealPath(kFilePath.c_str()); | string real_path = RealPath(kFilePath.c_str()); | ||||
if (real_path.empty()) { | if (real_path.empty()) { | ||||
GELOGE(FAILED, "[Check][AnalyzeFilePath]File path is empty, Path invalid."); | GELOGE(FAILED, "[Check][AnalyzeFilePath]File path is empty, Path invalid."); | ||||
REPORT_CALL_ERROR("E19999", "Analyze file path check invalid, it is empty"); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
json_file_name_ = real_path + "/" + kAnalyzeFile; | 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_); | std::lock_guard<std::recursive_mutex> lg(mutex_); | ||||
auto iter = graph_infos_.find(session_id); | auto iter = graph_infos_.find(session_id); | ||||
if (iter == graph_infos_.end()) { | 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; | return nullptr; | ||||
} else { | } else { | ||||
auto iter1 = (iter->second).find(graph_id); | auto iter1 = (iter->second).find(graph_id); | ||||
if (iter1 == (iter->second).end()) { | 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; | return nullptr; | ||||
} | } | ||||
GELOGI("GetJsonObject Success!session_id:%lu graph_id:%lu", session_id, graph_id); | 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_); | std::lock_guard<std::mutex> lg(file_mutex_); | ||||
int fd = open(json_file_name_.c_str(), O_WRONLY | O_CREAT | O_TRUNC, kFileAuthority); | int fd = open(json_file_name_.c_str(), O_WRONLY | O_CREAT | O_TRUNC, kFileAuthority); | ||||
if (fd < 0) { | 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; | return INTERNAL_ERROR; | ||||
} | } | ||||
if (close(fd) != 0) { | 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; | return INTERNAL_ERROR; | ||||
} | } | ||||
is_json_file_create_ = true; | 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_); | std::lock_guard<std::mutex> lg(file_mutex_); | ||||
json_file_.open(json_file_name_, std::ios::app); | json_file_.open(json_file_name_, std::ios::app); | ||||
if (!json_file_.is_open()) { | 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; | return PARAM_INVALID; | ||||
} | } | ||||
@@ -221,10 +234,13 @@ ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_ | |||||
try { | try { | ||||
json_file_ << jsn.dump(kJsonDumpLevel) << std::endl; | json_file_ << jsn.dump(kJsonDumpLevel) << std::endl; | ||||
} catch (nlohmann::detail::type_error &e) { | } 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); | 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; | ret_failed = true; | ||||
} | } | ||||
json_file_.close(); | json_file_.close(); | ||||
@@ -244,9 +260,11 @@ ge::Status Analyzer::DoAnalyze(DataInfo &data_info) { | |||||
GE_CHECK_NOTNULL(graph_info); | GE_CHECK_NOTNULL(graph_info); | ||||
auto status = SaveOpInfo(desc, data_info, graph_info); | auto status = SaveOpInfo(desc, data_info, graph_info); | ||||
if (status != SUCCESS) { | if (status != SUCCESS) { | ||||
GELOGE(status, | |||||
GELOGE(status, | |||||
"[Check][SaveOpInfo]save op info: desc_name [%s] desc_type [%s] failed!", | "[Check][SaveOpInfo]save op info: desc_name [%s] desc_type [%s] failed!", | ||||
desc->GetName().c_str(), desc->GetType().c_str()); | 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; | return FAILED; | ||||
} | } | ||||
// create json file | // create json file | ||||
@@ -73,7 +73,8 @@ Status CheckOptionsValid(const std::map<string, string> &options) { | |||||
"the job_id [%s] string length: %zu > max string length: %d", | "the job_id [%s] string length: %zu > max string length: %d", | ||||
job_id_iter->second.c_str(), job_id_iter->second.length(), kMaxStrLen); | job_id_iter->second.c_str(), job_id_iter->second.length(), kMaxStrLen); | ||||
REPORT_INPUT_ERROR("E10051", std::vector<std::string>({"id","length"}), | 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; | return FAILED; | ||||
} | } | ||||
} | } | ||||
@@ -90,6 +91,7 @@ Status GEInitializeImpl(const std::map<string, string> &options) { | |||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
GELOGE(GE_CLI_INIT_FAILED, | GELOGE(GE_CLI_INIT_FAILED, | ||||
"[Init][PathBase]Init failed when pass param path_base:%s", path_base.c_str()); | "[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; | return ret; | ||||
} | } | ||||
@@ -111,7 +113,9 @@ Status GEInitializeImpl(const std::map<string, string> &options) { | |||||
if (!is_proto_init) { | if (!is_proto_init) { | ||||
GELOGE(GE_CLI_INIT_FAILED, | GELOGE(GE_CLI_INIT_FAILED, | ||||
"[Init][OpsProtoPath]Loading OpsProto lib plugin failed, OpsProtoPath:%s invalid.", | "[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; | return FAILED; | ||||
} | } | ||||
@@ -319,6 +323,7 @@ Session::Session(const std::map<AscendString, AscendString> &options) { | |||||
sessionId_ = session_id; | sessionId_ = session_id; | ||||
} else { | } else { | ||||
GELOGE(ret, "[Construct][Session]Failed, error code:%u.", ret); | GELOGE(ret, "[Construct][Session]Failed, error code:%u.", ret); | ||||
REPORT_CALL_ERROR("E19999", "Construct session failed, error code:%u.", ret); | |||||
return; | return; | ||||
} | } | ||||
GELOGT(TRACE_STOP, "Session Constructor finished"); | GELOGT(TRACE_STOP, "Session Constructor finished"); | ||||
@@ -350,12 +355,15 @@ Session::~Session() { | |||||
ret = instance_ptr->SessionManagerObj().DestroySession(session_id); | ret = instance_ptr->SessionManagerObj().DestroySession(session_id); | ||||
} catch (google::protobuf::FatalException &e) { | } 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 | // check return status, return, update session id if success | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
GELOGE(ret, "[Destruct][Session]Failed, error code:%u.", ret); | 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"); | 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(); | std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | ||||
if (!instance_ptr || !instance_ptr->InitFlag()) { | if (!instance_ptr || !instance_ptr->InitFlag()) { | ||||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, | 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", | 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; | return FAILED; | ||||
} | } | ||||
@@ -491,7 +501,9 @@ Status Session::RemoveGraph(uint32_t graph_id) { | |||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
GELOGE(ret, | GELOGE(ret, | ||||
"[Remove][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", | "[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; | return FAILED; | ||||
} | } | ||||
GELOGT(TRACE_STOP, "Session RemoveGraph finished"); | 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(); | std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | ||||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | ||||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, | 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", | 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; | return FAILED; | ||||
} | } | ||||
GELOGT(TRACE_RUNNING, "Running Graph"); | 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) { | if (ret != SUCCESS) { | ||||
GELOGE(ret, | GELOGE(ret, | ||||
"[Run][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", | "[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; | return FAILED; | ||||
} | } | ||||
@@ -603,10 +619,12 @@ Status Session::BuildGraph(uint32_t graph_id, const std::vector<InputTensorInfo> | |||||
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); | ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); | ||||
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | ||||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | 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", | 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; | return FAILED; | ||||
} | } | ||||
GELOGT(TRACE_RUNNING, "Building Graph"); | GELOGT(TRACE_RUNNING, "Building Graph"); | ||||
@@ -614,7 +632,9 @@ Status Session::BuildGraph(uint32_t graph_id, const std::vector<InputTensorInfo> | |||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
GELOGE(ret, | GELOGE(ret, | ||||
"[Build][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", | "[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 FAILED; | ||||
} | } | ||||
return SUCCESS; | 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(); | std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | ||||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | ||||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, | 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", | 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; | return FAILED; | ||||
} | } | ||||
GELOGT(TRACE_RUNNING, "Run Graph Asynchronously"); | GELOGT(TRACE_RUNNING, "Run Graph Asynchronously"); | ||||
@@ -641,6 +663,8 @@ Status Session::RunGraphAsync(uint32_t graph_id, const std::vector<InputTensorIn | |||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
GELOGE(ret, "[Run][Graph]RunGraphAsync Failed, error code:%u, session_id:%lu, graph_id:%u.", | GELOGE(ret, "[Run][Graph]RunGraphAsync Failed, error code:%u, session_id:%lu, graph_id:%u.", | ||||
ret, sessionId_, graph_id); | 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 FAILED; | ||||
} | } | ||||
return SUCCESS; | 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); | Status ret = ge::GELib::GetInstance()->SessionManagerObj().GetVariables(sessionId_, str_var_names, var_values); | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
GELOGE(ret, "[Get][Variables]Failed, error code:%u, session_id:%lu.", ret, sessionId_); | 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 FAILED; | ||||
} | } | ||||
return SUCCESS; | return SUCCESS; | ||||
@@ -33,8 +33,10 @@ const int kFileOpSuccess = 0; | |||||
namespace ge { | namespace ge { | ||||
Status FileSaver::OpenFile(int32_t &fd, const std::string &file_path) { | Status FileSaver::OpenFile(int32_t &fd, const std::string &file_path) { | ||||
if (CheckPath(file_path) != SUCCESS) { | 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; | 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) { | if (fd == EN_INVALID_PARAM || fd == EN_ERROR) { | ||||
// -1: Failed to open file; - 2: Illegal parameter | // -1: Failed to open file; - 2: Illegal parameter | ||||
GELOGE(FAILED, "[Open][File]Failed. mmpa_errno = %d, %s", fd, strerror(errno)); | 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 FAILED; | ||||
} | } | ||||
return SUCCESS; | return SUCCESS; | ||||
@@ -64,9 +67,10 @@ Status FileSaver::WriteData(const void *data, uint32_t size, int32_t fd) { | |||||
while (size > size_1g) { | while (size > size_1g) { | ||||
write_count = mmWrite(fd, reinterpret_cast<void *>(seek), size_1g); | write_count = mmWrite(fd, reinterpret_cast<void *>(seek), size_1g); | ||||
if (write_count == EN_INVALID_PARAM || write_count == EN_ERROR) { | 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; | return FAILED; | ||||
} | } | ||||
size -= size_1g; | 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 | // -1: Failed to write to file; - 2: Illegal parameter | ||||
if (write_count == EN_INVALID_PARAM || write_count == EN_ERROR) { | 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.", | REPORT_INNER_ERROR("E19999", "Write data failed, mmpa_errorno = %ld, error:%s.", | ||||
write_count, strerror(errno)); | write_count, strerror(errno)); | ||||
return FAILED; | 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, | Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFileHeader &file_header, const void *data, | ||||
int len) { | int len) { | ||||
if (data == nullptr || len <= 0) { | 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; | return FAILED; | ||||
} | } | ||||
@@ -112,7 +119,8 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi | |||||
// Close file | // Close file | ||||
if (mmClose(fd) != 0) { // mmClose 0: success | if (mmClose(fd) != 0) { // mmClose 0: success | ||||
GELOGE(FAILED, "[Close][File]Failed, error_code:%u errmsg:%s", ret, strerror(errno)); | 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; | ret = FAILED; | ||||
} | } | ||||
return ret; | return ret; | ||||
@@ -150,7 +158,8 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi | |||||
// Close file | // Close file | ||||
if (mmClose(fd) != EN_OK) { | if (mmClose(fd) != EN_OK) { | ||||
GELOGE(FAILED, "[Close][File]Failed, error_code:%u errmsg:%s", ret, strerror(errno)); | 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; | ret = FAILED; | ||||
} | } | ||||
return ret; | 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) { | if (file_path.size() >= MMPA_MAX_PATH) { | ||||
GELOGE(FAILED, "[Check][FilePath]Failed, file path's length:%zu > mmpa_max_path:%d", | GELOGE(FAILED, "[Check][FilePath]Failed, file path's length:%zu > mmpa_max_path:%d", | ||||
file_path.size(), MMPA_MAX_PATH); | 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; | 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 | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status | ||||
FileSaver::SaveToFile(const string &file_path, const ge::ModelData &model, const ModelFileHeader *model_file_header) { | 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) { | 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; | return FAILED; | ||||
} | } | ||||
@@ -360,7 +371,8 @@ Status FileSaver::SaveWithFileHeader(const std::string &file_path, const ModelFi | |||||
// Close file | // Close file | ||||
if (mmClose(fd) != 0) { // mmClose 0: success | if (mmClose(fd) != 0) { // mmClose 0: success | ||||
GELOGE(FAILED, "[Close][File]Failed, error_code:%u errmsg:%s", ret, strerror(errno)); | 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; | ret = FAILED; | ||||
} | } | ||||
return ret; | 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, | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::SaveToFile(const string &file_path, const void *data, | ||||
int len) { | int len) { | ||||
if (data == nullptr || len <= 0) { | 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; | return FAILED; | ||||
} | } | ||||
@@ -386,7 +400,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FileSaver::SaveToFile(co | |||||
// Close file | // Close file | ||||
if (mmClose(fd) != 0) { // mmClose 0: success | if (mmClose(fd) != 0) { // mmClose 0: success | ||||
GELOGE(FAILED, "[Close][File]Failed, error_code:%u errmsg:%s", ret, strerror(errno)); | 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; | ret = FAILED; | ||||
} | } | ||||
return ret; | return ret; | ||||
@@ -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 | // mmWrite return -1:Failed to write data to file;return -2:Invalid parameter | ||||
if (mmpa_ret == EN_ERROR || mmpa_ret == EN_INVALID_PARAM) { | if (mmpa_ret == EN_ERROR || mmpa_ret == EN_INVALID_PARAM) { | ||||
GELOGE(FAILED, "[Write][Data]Failed, errno = %d, error:%s", mmpa_ret, strerror(errno)); | 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; | ret = FAILED; | ||||
} | } | ||||
// Close the file | // Close the file | ||||
if (mmClose(fd) != EN_OK) { // mmClose return 0: success | if (mmClose(fd) != EN_OK) { // mmClose return 0: success | ||||
GELOGE(FAILED, "[Close][File]Failed, error_code:%u, filename:%s.", ret, filename); | 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; | 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 | // mmWrite return -1:failed to write data to file;return -2:invalid parameter | ||||
if (mmpa_ret == EN_ERROR || mmpa_ret == EN_INVALID_PARAM) { | if (mmpa_ret == EN_ERROR || mmpa_ret == EN_INVALID_PARAM) { | ||||
GELOGE(FAILED, "[Write][Data]Failed, errno = %d, error:%s", mmpa_ret, strerror(errno)); | 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; | return FAILED; | ||||
} | } | ||||
@@ -56,7 +56,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpManager::SetDumpConf | |||||
dump_properties.SetDumpOpSwitch(dump_op_switch); | dump_properties.SetDumpOpSwitch(dump_op_switch); | ||||
if (dump_op_switch == kDumpoff && dump_config.dump_list.empty()) { | if (dump_op_switch == kDumpoff && dump_config.dump_list.empty()) { | ||||
dump_properties_map_.emplace(kInferSessionId, dump_properties); | 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; | return PARAM_INVALID; | ||||
} | } | ||||
@@ -82,7 +85,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpManager::SetDumpConf | |||||
dump_path = dump_config.dump_path; | dump_path = dump_config.dump_path; | ||||
if (dump_path.empty()) { | 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; | return PARAM_INVALID; | ||||
} | } | ||||
@@ -26,7 +26,7 @@ | |||||
#include "graph/op_desc.h" | #include "graph/op_desc.h" | ||||
#include "graph/utils/tensor_utils.h" | #include "graph/utils/tensor_utils.h" | ||||
#include "proto/ge_ir.pb.h" | #include "proto/ge_ir.pb.h" | ||||
#include "proto/op_mapping_info.pb.h" | |||||
#include "proto/op_mapping.pb.h" | |||||
#include "runtime/mem.h" | #include "runtime/mem.h" | ||||
#include "aicpu/common/aicpu_task_struct.h" | #include "aicpu/common/aicpu_task_struct.h" | ||||
@@ -64,7 +64,7 @@ void DumpOp::SetDynamicModelInfo(const string &dynamic_model_name, const string | |||||
} | } | ||||
static void SetOpMappingLoopAddr(uintptr_t step_id, uintptr_t loop_per_iter, uintptr_t loop_cond, | static void SetOpMappingLoopAddr(uintptr_t step_id, uintptr_t loop_per_iter, uintptr_t loop_cond, | ||||
aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
toolkit::aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
if (step_id != 0) { | if (step_id != 0) { | ||||
GELOGI("step_id exists."); | GELOGI("step_id exists."); | ||||
op_mapping_info.set_step_id_addr(static_cast<uint64_t>(step_id)); | op_mapping_info.set_step_id_addr(static_cast<uint64_t>(step_id)); | ||||
@@ -87,11 +87,11 @@ static void SetOpMappingLoopAddr(uintptr_t step_id, uintptr_t loop_per_iter, uin | |||||
} | } | ||||
} | } | ||||
Status DumpOp::DumpOutput(aicpu::dump::Task &task) { | |||||
Status DumpOp::DumpOutput(toolkit::aicpu::dump::Task &task) { | |||||
GELOGI("Start dump output in Launch dump op"); | GELOGI("Start dump output in Launch dump op"); | ||||
const auto &output_descs = op_desc_->GetAllOutputsDesc(); | const auto &output_descs = op_desc_->GetAllOutputsDesc(); | ||||
for (size_t i = 0; i < output_descs.size(); ++i) { | for (size_t i = 0; i < output_descs.size(); ++i) { | ||||
aicpu::dump::Output output; | |||||
toolkit::aicpu::dump::Output output; | |||||
output.set_data_type(static_cast<int32_t>(DataTypeUtil::GetIrDataType(output_descs.at(i).GetDataType()))); | output.set_data_type(static_cast<int32_t>(DataTypeUtil::GetIrDataType(output_descs.at(i).GetDataType()))); | ||||
output.set_format(static_cast<int32_t>(output_descs.at(i).GetFormat())); | output.set_format(static_cast<int32_t>(output_descs.at(i).GetFormat())); | ||||
for (auto dim : output_descs.at(i).GetShape().GetDims()) { | for (auto dim : output_descs.at(i).GetShape().GetDims()) { | ||||
@@ -102,7 +102,10 @@ Status DumpOp::DumpOutput(aicpu::dump::Task &task) { | |||||
} | } | ||||
int64_t output_size = 0; | int64_t output_size = 0; | ||||
if (TensorUtils::GetTensorSizeInBytes(output_descs.at(i), output_size) != SUCCESS) { | 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; | return ACL_ERROR_GE_INTERNAL_ERROR; | ||||
} | } | ||||
GELOGD("Get output size in lanch dump op is %ld", output_size); | GELOGD("Get output size in lanch dump op is %ld", output_size); | ||||
@@ -113,11 +116,11 @@ Status DumpOp::DumpOutput(aicpu::dump::Task &task) { | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
Status DumpOp::DumpInput(aicpu::dump::Task &task) { | |||||
Status DumpOp::DumpInput(toolkit::aicpu::dump::Task &task) { | |||||
GELOGI("Start dump input in Launch dump op"); | GELOGI("Start dump input in Launch dump op"); | ||||
const auto &input_descs = op_desc_->GetAllInputsDesc(); | const auto &input_descs = op_desc_->GetAllInputsDesc(); | ||||
for (size_t i = 0; i < input_descs.size(); ++i) { | for (size_t i = 0; i < input_descs.size(); ++i) { | ||||
aicpu::dump::Input input; | |||||
toolkit::aicpu::dump::Input input; | |||||
input.set_data_type(static_cast<int32_t>(DataTypeUtil::GetIrDataType(input_descs.at(i).GetDataType()))); | input.set_data_type(static_cast<int32_t>(DataTypeUtil::GetIrDataType(input_descs.at(i).GetDataType()))); | ||||
input.set_format(static_cast<int32_t>(input_descs.at(i).GetFormat())); | input.set_format(static_cast<int32_t>(input_descs.at(i).GetFormat())); | ||||
@@ -129,7 +132,10 @@ Status DumpOp::DumpInput(aicpu::dump::Task &task) { | |||||
} | } | ||||
int64_t input_size = 0; | int64_t input_size = 0; | ||||
if (TensorUtils::GetTensorSizeInBytes(input_descs.at(i), input_size) != SUCCESS) { | 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; | return ACL_ERROR_GE_INTERNAL_ERROR; | ||||
} | } | ||||
GELOGD("Get input size in lanch dump op is %ld", input_size); | GELOGD("Get input size in lanch dump op is %ld", input_size); | ||||
@@ -149,35 +155,41 @@ void DumpOp::SetDumpInfo(const DumpProperties &dump_properties, const OpDescPtr | |||||
stream_ = stream; | stream_ = stream; | ||||
} | } | ||||
Status DumpOp::ExecutorDumpOp(aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
Status DumpOp::ExecutorDumpOp(toolkit::aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
std::string proto_msg; | std::string proto_msg; | ||||
size_t proto_size = op_mapping_info.ByteSizeLong(); | size_t proto_size = op_mapping_info.ByteSizeLong(); | ||||
bool ret = op_mapping_info.SerializeToString(&proto_msg); | bool ret = op_mapping_info.SerializeToString(&proto_msg); | ||||
if (!ret || proto_size == 0) { | 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; | return ACL_ERROR_GE_INTERNAL_ERROR; | ||||
} | } | ||||
rtError_t rt_ret = rtMalloc(&proto_dev_mem_, proto_size, RT_MEMORY_HBM); | rtError_t rt_ret = rtMalloc(&proto_dev_mem_, proto_size, RT_MEMORY_HBM); | ||||
if (rt_ret != RT_ERROR_NONE) { | 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); | 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); | 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) { | 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); | return RT_ERROR_TO_GE_STATUS(rt_ret); | ||||
} | } | ||||
rt_ret = rtMalloc(&proto_size_dev_mem_, sizeof(size_t), RT_MEMORY_HBM); | rt_ret = rtMalloc(&proto_size_dev_mem_, sizeof(size_t), RT_MEMORY_HBM); | ||||
if (rt_ret != RT_ERROR_NONE) { | 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); | 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); | 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) { | 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); | return RT_ERROR_TO_GE_STATUS(rt_ret); | ||||
} | } | ||||
@@ -196,14 +208,15 @@ Status DumpOp::ExecutorDumpOp(aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
nullptr, // no need smDesc | nullptr, // no need smDesc | ||||
stream_); | stream_); | ||||
if (rt_ret != RT_ERROR_NONE) { | 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); | return RT_ERROR_TO_GE_STATUS(rt_ret); | ||||
} | } | ||||
GELOGI("Kernel launch dump op success"); | GELOGI("Kernel launch dump op success"); | ||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
Status DumpOp::SetDumpModelName(aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
Status DumpOp::SetDumpModelName(toolkit::aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
if (dynamic_model_name_.empty() && dynamic_om_name_.empty()) { | if (dynamic_model_name_.empty() && dynamic_om_name_.empty()) { | ||||
GELOGI("Single op dump, no need set model name"); | GELOGI("Single op dump, no need set model name"); | ||||
return SUCCESS; | return SUCCESS; | ||||
@@ -234,15 +247,16 @@ Status DumpOp::LaunchDumpOp() { | |||||
int32_t device_id = 0; | int32_t device_id = 0; | ||||
rtError_t rt_ret = rtGetDevice(&device_id); | rtError_t rt_ret = rtGetDevice(&device_id); | ||||
if (rt_ret != RT_ERROR_NONE) { | 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); | return RT_ERROR_TO_GE_STATUS(rt_ret); | ||||
} | } | ||||
if (device_id < 0) { | 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; | return ACL_ERROR_GE_INTERNAL_ERROR; | ||||
} | } | ||||
aicpu::dump::OpMappingInfo op_mapping_info; | |||||
toolkit::aicpu::dump::OpMappingInfo op_mapping_info; | |||||
auto dump_path = dump_properties_.GetDumpPath() + std::to_string(device_id) + "/"; | auto dump_path = dump_properties_.GetDumpPath() + std::to_string(device_id) + "/"; | ||||
op_mapping_info.set_dump_path(dump_path); | op_mapping_info.set_dump_path(dump_path); | ||||
op_mapping_info.set_flag(kAicpuLoadFlag); | op_mapping_info.set_flag(kAicpuLoadFlag); | ||||
@@ -261,7 +275,7 @@ Status DumpOp::LaunchDumpOp() { | |||||
if (rt_ret != RT_ERROR_NONE) { | if (rt_ret != RT_ERROR_NONE) { | ||||
GELOGW("call rtGetTaskIdAndStreamID failed, ret = 0x%X", rt_ret); | GELOGW("call rtGetTaskIdAndStreamID failed, ret = 0x%X", rt_ret); | ||||
} | } | ||||
aicpu::dump::Task task; | |||||
toolkit::aicpu::dump::Task task; | |||||
task.set_task_id(task_id); | task.set_task_id(task_id); | ||||
task.set_stream_id(stream_id); | task.set_stream_id(stream_id); | ||||
task.mutable_op()->set_op_name(op_desc_->GetName()); | task.mutable_op()->set_op_name(op_desc_->GetName()); | ||||
@@ -269,7 +283,10 @@ Status DumpOp::LaunchDumpOp() { | |||||
if (dump_properties_.GetDumpMode() == kDumpOutput) { | if (dump_properties_.GetDumpMode() == kDumpOutput) { | ||||
auto ret = DumpOutput(task); | auto ret = DumpOutput(task); | ||||
if (ret != SUCCESS) { | 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; | return ret; | ||||
} | } | ||||
op_mapping_info.mutable_task()->Add(std::move(task)); | op_mapping_info.mutable_task()->Add(std::move(task)); | ||||
@@ -277,7 +294,10 @@ Status DumpOp::LaunchDumpOp() { | |||||
if (dump_properties_.GetDumpMode() == kDumpInput) { | if (dump_properties_.GetDumpMode() == kDumpInput) { | ||||
auto ret = DumpInput(task); | auto ret = DumpInput(task); | ||||
if (ret != SUCCESS) { | 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; | return ret; | ||||
} | } | ||||
op_mapping_info.mutable_task()->Add(std::move(task)); | op_mapping_info.mutable_task()->Add(std::move(task)); | ||||
@@ -285,19 +305,26 @@ Status DumpOp::LaunchDumpOp() { | |||||
if (dump_properties_.GetDumpMode() == kDumpAll || dump_properties_.IsOpDebugOpen()) { | if (dump_properties_.GetDumpMode() == kDumpAll || dump_properties_.IsOpDebugOpen()) { | ||||
auto ret = DumpOutput(task); | auto ret = DumpOutput(task); | ||||
if (ret != SUCCESS) { | 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; | return ret; | ||||
} | } | ||||
ret = DumpInput(task); | ret = DumpInput(task); | ||||
if (ret != SUCCESS) { | 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; | return ret; | ||||
} | } | ||||
op_mapping_info.mutable_task()->Add(std::move(task)); | op_mapping_info.mutable_task()->Add(std::move(task)); | ||||
} | } | ||||
auto ret = ExecutorDumpOp(op_mapping_info); | auto ret = ExecutorDumpOp(op_mapping_info); | ||||
if (ret != SUCCESS) { | 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 ret; | ||||
} | } | ||||
return SUCCESS; | return SUCCESS; | ||||
@@ -21,7 +21,7 @@ | |||||
#include "common/ge_inner_error_codes.h" | #include "common/ge_inner_error_codes.h" | ||||
#include "common/properties_manager.h" | #include "common/properties_manager.h" | ||||
#include "proto/op_mapping_info.pb.h" | |||||
#include "proto/op_mapping.pb.h" | |||||
#include "runtime/stream.h" | #include "runtime/stream.h" | ||||
namespace ge { | namespace ge { | ||||
@@ -37,10 +37,10 @@ class DumpOp { | |||||
void SetDynamicModelInfo(const string &dynamic_model_name, const string &dynamic_om_name, uint32_t dynamic_model_id); | void SetDynamicModelInfo(const string &dynamic_model_name, const string &dynamic_om_name, uint32_t dynamic_model_id); | ||||
private: | private: | ||||
Status ExecutorDumpOp(aicpu::dump::OpMappingInfo &op_mapping_info); | |||||
Status DumpOutput(aicpu::dump::Task &task); | |||||
Status DumpInput(aicpu::dump::Task &task); | |||||
Status SetDumpModelName(aicpu::dump::OpMappingInfo &op_mapping_info); | |||||
Status ExecutorDumpOp(toolkit::aicpu::dump::OpMappingInfo &op_mapping_info); | |||||
Status DumpOutput(toolkit::aicpu::dump::Task &task); | |||||
Status DumpInput(toolkit::aicpu::dump::Task &task); | |||||
Status SetDumpModelName(toolkit::aicpu::dump::OpMappingInfo &op_mapping_info); | |||||
DumpProperties dump_properties_; | DumpProperties dump_properties_; | ||||
OpDescPtr op_desc_; | OpDescPtr op_desc_; | ||||
@@ -43,15 +43,15 @@ static void ReplaceStringElem(std::string &str) { | |||||
}); | }); | ||||
} | } | ||||
static void SetDumpData(const ge::OpDescInfo &op_desc_info, toolkit::dumpdata::DumpData &dump_data) { | |||||
static void SetDumpData(const ge::OpDescInfo &op_desc_info, toolkit::dump::DumpData &dump_data) { | |||||
dump_data.set_version("2.0"); | dump_data.set_version("2.0"); | ||||
dump_data.set_dump_time(GetNowTime()); | dump_data.set_dump_time(GetNowTime()); | ||||
dump_data.set_op_name(op_desc_info.op_name); | dump_data.set_op_name(op_desc_info.op_name); | ||||
for (size_t i = 0; i < op_desc_info.input_format.size(); ++i) { | for (size_t i = 0; i < op_desc_info.input_format.size(); ++i) { | ||||
toolkit::dumpdata::OpInput input; | |||||
input.set_data_type(toolkit::dumpdata::OutputDataType( | |||||
toolkit::dump::OpInput input; | |||||
input.set_data_type(toolkit::dump::OutputDataType( | |||||
ge::DataTypeUtil::GetIrDataType(op_desc_info.input_data_type[i]))); | ge::DataTypeUtil::GetIrDataType(op_desc_info.input_data_type[i]))); | ||||
input.set_format(toolkit::dumpdata::OutputFormat(op_desc_info.input_format[i])); | |||||
input.set_format(toolkit::dump::OutputFormat(op_desc_info.input_format[i])); | |||||
for (auto dim : op_desc_info.input_shape[i]) { | for (auto dim : op_desc_info.input_shape[i]) { | ||||
input.mutable_shape()->add_dim(dim); | input.mutable_shape()->add_dim(dim); | ||||
} | } | ||||
@@ -61,10 +61,10 @@ static void SetDumpData(const ge::OpDescInfo &op_desc_info, toolkit::dumpdata::D | |||||
} | } | ||||
for (size_t j = 0; j < op_desc_info.output_format.size(); ++j) { | for (size_t j = 0; j < op_desc_info.output_format.size(); ++j) { | ||||
toolkit::dumpdata::OpOutput output; | |||||
output.set_data_type(toolkit::dumpdata::OutputDataType( | |||||
toolkit::dump::OpOutput output; | |||||
output.set_data_type(toolkit::dump::OutputDataType( | |||||
ge::DataTypeUtil::GetIrDataType(op_desc_info.output_data_type[j]))); | ge::DataTypeUtil::GetIrDataType(op_desc_info.output_data_type[j]))); | ||||
output.set_format(toolkit::dumpdata::OutputFormat(op_desc_info.output_format[j])); | |||||
output.set_format(toolkit::dump::OutputFormat(op_desc_info.output_format[j])); | |||||
for (auto dim : op_desc_info.output_shape[j]) { | for (auto dim : op_desc_info.output_shape[j]) { | ||||
output.mutable_shape()->add_dim(dim); | output.mutable_shape()->add_dim(dim); | ||||
} | } | ||||
@@ -148,7 +148,7 @@ Status ExceptionDumper::DumpExceptionInfo(const std::vector<rtExceptionInfo> &ex | |||||
for (const rtExceptionInfo &iter : exception_infos) { | for (const rtExceptionInfo &iter : exception_infos) { | ||||
OpDescInfo op_desc_info; | OpDescInfo op_desc_info; | ||||
if (GetOpDescInfo(iter.streamid, iter.taskid, op_desc_info)) { | if (GetOpDescInfo(iter.streamid, iter.taskid, op_desc_info)) { | ||||
toolkit::dumpdata::DumpData dump_data; | |||||
toolkit::dump::DumpData dump_data; | |||||
SetDumpData(op_desc_info, dump_data); | SetDumpData(op_desc_info, dump_data); | ||||
uint64_t now_time = GetNowTime(); | uint64_t now_time = GetNowTime(); | ||||
std::string op_name = op_desc_info.op_name; | std::string op_name = op_desc_info.op_name; | ||||
@@ -27,7 +27,9 @@ Status OpdebugRegister::RegisterDebugForModel(rtModel_t model_handle, uint32_t o | |||||
GELOGD("Start to register debug for model in overflow"); | GELOGD("Start to register debug for model in overflow"); | ||||
auto ret = MallocMemForOpdebug(); | auto ret = MallocMemForOpdebug(); | ||||
if (ret != SUCCESS) { | 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; | return ret; | ||||
} | } | ||||
uint32_t debug_stream_id = 0; | 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"); | GELOGD("Start to register debug for stream in stream overflow"); | ||||
auto ret = MallocMemForOpdebug(); | auto ret = MallocMemForOpdebug(); | ||||
if (ret != SUCCESS) { | 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; | return ret; | ||||
} | } | ||||
@@ -82,7 +86,8 @@ Status OpdebugRegister::RegisterDebugForStream(rtStream_t stream, uint32_t op_de | |||||
uint32_t debug_task_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); | auto rt_ret = rtDebugRegisterForStream(stream, op_debug_mode, op_debug_addr_, &debug_stream_id, &debug_task_id); | ||||
if (rt_ret != RT_ERROR_NONE) { | 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); | 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); | 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() { | Status OpdebugRegister::MallocMemForOpdebug() { | ||||
rtError_t rt_ret = rtMalloc(&op_debug_addr_, kOpDebugMemorySize, RT_MEMORY_DDR); | rtError_t rt_ret = rtMalloc(&op_debug_addr_, kOpDebugMemorySize, RT_MEMORY_DDR); | ||||
if (rt_ret != RT_ERROR_NONE) { | 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); | 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. | // 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); | rt_ret = rtMalloc(&p2p_debug_addr_, kDebugP2pSize, RT_MEMORY_HBM); | ||||
if (rt_ret != RT_ERROR_NONE) { | 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); | 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); | 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) { | 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); | return RT_ERROR_TO_GE_STATUS(rt_ret); | ||||
} | } | ||||
@@ -187,7 +187,7 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -33,7 +33,9 @@ void OpTilingManager::ClearHandles() noexcept { | |||||
if (mmDlclose(handle.second) != 0) { | if (mmDlclose(handle.second) != 0) { | ||||
const char *error = mmDlerror(); | const char *error = mmDlerror(); | ||||
GE_IF_BOOL_EXEC(error == nullptr, error = ""); | 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(); | handles_.clear(); | ||||
@@ -50,7 +52,8 @@ std::string OpTilingManager::GetPath() { | |||||
if (mmRealPath(opp_path_env, resolved_path, MMPA_MAX_PATH) != EN_OK) { | if (mmRealPath(opp_path_env, resolved_path, MMPA_MAX_PATH) != EN_OK) { | ||||
ErrorManager::GetInstance().ATCReportErrMessage( | ErrorManager::GetInstance().ATCReportErrMessage( | ||||
"E19024", {"env", "value", "situation"}, {"ASCEND_OPP_PATH", opp_path_env, "loading the tiling lib"}); | "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(); | return std::string(); | ||||
} | } | ||||
opp_path = resolved_path; | opp_path = resolved_path; | ||||
@@ -127,7 +127,7 @@ Status PluginManager::LoadSo(const string &path, const vector<string> &func_chec | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E19012", {"function", "reason"}, | ErrorManager::GetInstance().ATCReportErrMessage("E19012", {"function", "reason"}, | ||||
{"mmDlopen", "shared library path is " + FmtToStr(file_path_dlopen) + ". Errormessage" + FmtToStr(error)}); | {"mmDlopen", "shared library path is " + FmtToStr(file_path_dlopen) + ". Errormessage" + FmtToStr(error)}); | ||||
GELOGE(ACL_ERROR_GE_PLGMGR_PATH_INVALID, | 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); | file_path_dlopen.c_str(), error); | ||||
continue; | continue; | ||||
} | } | ||||
@@ -140,14 +140,15 @@ Status PluginManager::LoadSo(const string &path, const vector<string> &func_chec | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E19012", {"function", "reason"}, | ErrorManager::GetInstance().ATCReportErrMessage("E19012", {"function", "reason"}, | ||||
{"mmDlsym", FmtToStr(func_name) + " is skipped since function" + | {"mmDlsym", FmtToStr(func_name) + " is skipped since function" + | ||||
FmtToStr(func_name) + " is not existed!"}); | 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()); | func_name.c_str(), func_name.c_str()); | ||||
is_valid = false; | is_valid = false; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (!is_valid) { | if (!is_valid) { | ||||
GE_LOGE_IF(mmDlclose(handle), "Failed to dlclose."); | |||||
GE_LOGE_IF(mmDlclose(handle), "[DLClose][Handle]Failed."); | |||||
continue; | continue; | ||||
} | } | ||||
@@ -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, | Status ModelHelper::SaveModelPartition(std::shared_ptr<OmFileSaveHelper> &om_file_save_helper, ModelPartitionType type, | ||||
const uint8_t *data, size_t size, size_t model_index) { | const uint8_t *data, size_t size, size_t model_index) { | ||||
if (size < 1 || size > UINT32_MAX) { | 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) { | if (size > UINT32_MAX) { | ||||
string item = "item"; | string item = "item"; | ||||
if (type == MODEL_DEF) { | if (type == MODEL_DEF) { | ||||
@@ -57,7 +59,8 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr<OmFileSaveHelper> &om_fil | |||||
return PARAM_INVALID; | return PARAM_INVALID; | ||||
} | } | ||||
if (data == nullptr) { | 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; | return PARAM_INVALID; | ||||
} | } | ||||
ModelPartition partition_model; | 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.size = static_cast<uint32_t>(size); | ||||
partition_model.type = type; | partition_model.type = type; | ||||
if (om_file_save_helper->AddPartition(partition_model, model_index) != SUCCESS) { | 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 PARAM_INVALID; | ||||
} | } | ||||
return SUCCESS; | 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) { | 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()); | ModelPtr model_tmp = ge::MakeShared<ge::Model>(ge_model->GetName(), ge_model->GetPlatformVersion()); | ||||
if (model_tmp == nullptr) { | 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; | return FAILED; | ||||
} | } | ||||
model_tmp->SetGraph(ge_model->GetGraph()); | 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()); | model_tmp->SetAttr(ge_model->MutableAttrMap()); | ||||
Status ret = SaveSizeToModelDef(ge_model); | Status ret = SaveSizeToModelDef(ge_model); | ||||
if (ret != SUCCESS) { | 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; | return ret; | ||||
} | } | ||||
@@ -123,7 +131,10 @@ Status ModelHelper::SaveModelDef(std::shared_ptr<OmFileSaveHelper> &om_file_save | |||||
if (model_buffer.GetSize() > 0) { | if (model_buffer.GetSize() > 0) { | ||||
if (SaveModelPartition(om_file_save_helper, ModelPartitionType::MODEL_DEF, model_buffer.GetData(), | if (SaveModelPartition(om_file_save_helper, ModelPartitionType::MODEL_DEF, model_buffer.GetData(), | ||||
model_buffer.GetSize(), model_index) != SUCCESS) { | 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; | 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) { | const GeModelPtr &ge_model, ge::Buffer &task_buffer, size_t model_index) { | ||||
std::shared_ptr<ModelTaskDef> model_task_def = ge_model->GetModelTaskDefPtr(); | std::shared_ptr<ModelTaskDef> model_task_def = ge_model->GetModelTaskDefPtr(); | ||||
if (model_task_def == nullptr) { | 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; | return ACL_ERROR_GE_MEMORY_ALLOCATION; | ||||
} | } | ||||
size_t partition_task_size = model_task_def->ByteSizeLong(); | size_t partition_task_size = model_task_def->ByteSizeLong(); | ||||
GE_IF_BOOL_EXEC(partition_task_size == 0 || partition_task_size > INT_MAX, | 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); | return FAILED); | ||||
task_buffer = ge::Buffer(partition_task_size); | task_buffer = ge::Buffer(partition_task_size); | ||||
if (task_buffer.GetSize() == 0) { | 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; | return ACL_ERROR_GE_MEMORY_ALLOCATION; | ||||
} | } | ||||
(void)model_task_def->SerializePartialToArray(task_buffer.GetData(), static_cast<int>(partition_task_size)); | (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(), | if (SaveModelPartition(om_file_save_helper, ModelPartitionType::TASK_INFO, task_buffer.GetData(), | ||||
partition_task_size, model_index) != SUCCESS) { | 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 PARAM_INVALID; | ||||
} | } | ||||
return SUCCESS; | return SUCCESS; | ||||
@@ -218,7 +243,11 @@ Status ModelHelper::SaveModelHeader(std::shared_ptr<OmFileSaveHelper> &om_file_s | |||||
platform_version.size() + 1); | platform_version.size() + 1); | ||||
if (err != EOK) { | if (err != EOK) { | ||||
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, | 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; | return ACL_ERROR_GE_MEMORY_ALLOCATION; | ||||
} | } | ||||
string version = reinterpret_cast<char *>(model_header.platform_version); | 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; | 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); | err = memcpy_s(model_header.name, MODEL_NAME_LENGTH, ge_model->GetName().c_str(), name_size); | ||||
if (err != EOK) { | 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; | return ACL_ERROR_GE_MEMORY_ALLOCATION; | ||||
} | } | ||||
string model_name = reinterpret_cast<char *>(model_header.name); | 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, | const GeModelPtr &ge_model, ge::Buffer &model_buffer, | ||||
ge::Buffer &task_buffer, size_t model_index) { | ge::Buffer &task_buffer, size_t model_index) { | ||||
if (SaveModelDef(om_file_save_helper, ge_model, model_buffer, model_index) != SUCCESS) { | 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; | return FAILED; | ||||
} | } | ||||
if (SaveModelWeights(om_file_save_helper, ge_model, model_index) != SUCCESS) { | 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; | return FAILED; | ||||
} | } | ||||
if (SaveModelTbeKernel(om_file_save_helper, ge_model, model_index) != SUCCESS) { | 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; | return FAILED; | ||||
} | } | ||||
if (SaveModelCustAICPU(om_file_save_helper, ge_model, model_index) != SUCCESS) { | 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; | return FAILED; | ||||
} | } | ||||
if (SaveModelTaskDef(om_file_save_helper, ge_model, task_buffer, model_index) != SUCCESS) { | 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 FAILED; | ||||
} | } | ||||
return SUCCESS; | return SUCCESS; | ||||
@@ -272,7 +320,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod | |||||
const std::string &output_file, | const std::string &output_file, | ||||
ModelBufferData& model) { | ModelBufferData& model) { | ||||
if (output_file.empty()) { | 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; | 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); | auto ret = SaveAllModelPartiton(om_file_save_helper, ge_model, model_buffer, task_buffer); | ||||
if (ret != SUCCESS) { | 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; | return ret; | ||||
} | } | ||||
ret = SaveModelHeader(om_file_save_helper, ge_model); | ret = SaveModelHeader(om_file_save_helper, ge_model); | ||||
if (ret != SUCCESS) { | 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; | return ret; | ||||
} | } | ||||
ret = om_file_save_helper->SaveModel(save_param, output_file.c_str(), model, is_offline_); | ret = om_file_save_helper->SaveModel(save_param, output_file.c_str(), model, is_offline_); | ||||
if (ret != SUCCESS) { | 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 ret; | ||||
} | } | ||||
return SUCCESS; | return SUCCESS; | ||||
@@ -310,12 +370,21 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmRoo | |||||
bool is_unknown_shape) { | bool is_unknown_shape) { | ||||
GE_CHECK_NOTNULL(ge_root_model); | 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(); | 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(), | 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); | return FAILED); | ||||
if (!is_unknown_shape) { | if (!is_unknown_shape) { | ||||
@@ -344,7 +413,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmRoo | |||||
if (model_names.size() > 1) { | if (model_names.size() > 1) { | ||||
GELOGD("only save first model MODEL_DEF"); | GELOGD("only save first model MODEL_DEF"); | ||||
if (SaveModelDef(om_file_save_helper, first_ge_model, model_buffers[cur_index], cur_index) != SUCCESS) { | 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; | return FAILED; | ||||
} | } | ||||
++cur_index; | ++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], | auto ret = SaveAllModelPartiton(om_file_save_helper, ge_model, model_buffers[cur_index], | ||||
task_buffers[cur_index], cur_index); | task_buffers[cur_index], cur_index); | ||||
if (ret != SUCCESS) { | 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; | return INTERNAL_ERROR; | ||||
} | } | ||||
} | } | ||||
auto ret = SaveModelHeader(om_file_save_helper, first_ge_model, model_names.size()); | auto ret = SaveModelHeader(om_file_save_helper, first_ge_model, model_names.size()); | ||||
if (ret != SUCCESS) { | 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; | return INTERNAL_ERROR; | ||||
} | } | ||||
ret = om_file_save_helper->SaveRootModel(save_param, output_file.c_str(), model, is_offline_); | ret = om_file_save_helper->SaveRootModel(save_param, output_file.c_str(), model, is_offline_); | ||||
if (ret != SUCCESS) { | 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 FAILED; | ||||
} | } | ||||
return SUCCESS; | 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 | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status | ||||
ModelHelper::SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::string &output_file) { | ModelHelper::SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::string &output_file) { | ||||
if (output_file.empty()) { | 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; | return FAILED; | ||||
} | } | ||||
// Get computegraph from graph | // Get computegraph from graph | ||||
auto compute_graph = ge::GraphUtils::GetComputeGraph(graph); | auto compute_graph = ge::GraphUtils::GetComputeGraph(graph); | ||||
if (compute_graph == nullptr) { | 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; | return FAILED; | ||||
} | } | ||||
GE_DUMP(compute_graph, "OriginalGraph"); | GE_DUMP(compute_graph, "OriginalGraph"); | ||||
@@ -407,7 +489,10 @@ ModelHelper::SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::strin | |||||
ge::Buffer model_buffer; | ge::Buffer model_buffer; | ||||
ge::graphStatus status = model_ptr->Save(model_buffer); | ge::graphStatus status = model_ptr->Save(model_buffer); | ||||
if (status != ge::GRAPH_SUCCESS) { | 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; | return FAILED; | ||||
} | } | ||||
std::shared_ptr<OmFileSaveHelper> om_file_save_helper = ge::MakeShared<OmFileSaveHelper>(); | 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(), | errno_t err = memcpy_s(model_header.platform_version, PLATFORM_VERSION_LEN, platform_version.c_str(), | ||||
platform_version.size() + 1); | platform_version.size() + 1); | ||||
if (err != EOK) { | 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; | return FAILED; | ||||
} | } | ||||
size_t name_size = model_ptr->GetName().size(); | size_t name_size = model_ptr->GetName().size(); | ||||
name_size = name_size > (MODEL_NAME_LENGTH - 1) ? (MODEL_NAME_LENGTH - 1) : name_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); | err = memcpy_s(model_header.name, MODEL_NAME_LENGTH, model_ptr->GetName().c_str(), name_size); | ||||
if (err != EOK) { | 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; | return FAILED; | ||||
} | } | ||||
ModelBufferData model; | 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) { | 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) { | 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; | return ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID; | ||||
} | } | ||||
if (is_assign_model_) { | 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; | return ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED; | ||||
} | } | ||||
if (ReleaseLocalModelData() != SUCCESS) { | 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; | return ACL_ERROR_GE_EXEC_RELEASE_MODEL_DATA; | ||||
} | } | ||||
Status status = ModelParserBase::ParseModelContent(model_data, model_addr_tmp_, model_len_tmp_); | Status status = ModelParserBase::ParseModelContent(model_data, model_addr_tmp_, model_len_tmp_); | ||||
if (status != SUCCESS) { | 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; | 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; | OmFileLoadHelper om_load_helper; | ||||
status = om_load_helper.Init(model_addr_tmp_, model_len_tmp_); | status = om_load_helper.Init(model_addr_tmp_, model_len_tmp_); | ||||
if (status != SUCCESS) { | if (status != SUCCESS) { | ||||
GELOGE(status, "Om_load_helper init failed"); | |||||
GELOGE(status, "[Init][OmLoadHelper]Failed"); | |||||
model_addr_tmp_ = nullptr; | model_addr_tmp_ = nullptr; | ||||
return status; | return status; | ||||
} | } | ||||
auto partition_table = reinterpret_cast<ModelPartitionTable *>(model_addr_tmp_); | auto partition_table = reinterpret_cast<ModelPartitionTable *>(model_addr_tmp_); | ||||
if (partition_table->num == kOriginalOmPartitionNum) { | if (partition_table->num == kOriginalOmPartitionNum) { | ||||
model_addr_tmp_ = nullptr; | 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; | return ACL_ERROR_GE_PARAM_INVALID; | ||||
} | } | ||||
// Encrypt model need to del temp model/no encrypt model don't need to del model | // 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); | status = GenerateGeModel(om_load_helper); | ||||
if (status != SUCCESS) { | if (status != SUCCESS) { | ||||
GELOGE(status, "GenerateGeModel failed"); | |||||
GELOGE(status, "[Generate][GEModel]Failed"); | |||||
return status; | return status; | ||||
} | } | ||||
GELOGD("in ModelHelper::LoadModel, is_assign_model_ is setted to true!"); | 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) { | 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) { | 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; | return ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID; | ||||
} | } | ||||
if (is_assign_model_) { | 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; | return ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED; | ||||
} | } | ||||
if (ReleaseLocalModelData() != SUCCESS) { | if (ReleaseLocalModelData() != SUCCESS) { | ||||
GELOGE(INTERNAL_ERROR, "ReleaseLocalModelData failed."); | |||||
GELOGE(INTERNAL_ERROR, "[Release][ModelData]Failed."); | |||||
return INTERNAL_ERROR; | return INTERNAL_ERROR; | ||||
} | } | ||||
Status status = ModelParserBase::ParseModelContent(model_data, model_addr_tmp_, model_len_tmp_); | Status status = ModelParserBase::ParseModelContent(model_data, model_addr_tmp_, model_len_tmp_); | ||||
if (status != SUCCESS) { | 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; | 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_); | status = om_load_helper.Init(model_addr_tmp_, model_len_tmp_); | ||||
} | } | ||||
if (status != SUCCESS) { | if (status != SUCCESS) { | ||||
GELOGE(status, "Om_load_helper init failed"); | |||||
GELOGE(status, "[Init][OmLoadHelper]Failed"); | |||||
model_addr_tmp_ = nullptr; | model_addr_tmp_ = nullptr; | ||||
return status; | return status; | ||||
} | } | ||||
@@ -539,7 +636,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadRootMod | |||||
status = GenerateGeRootModel(om_load_helper); | status = GenerateGeRootModel(om_load_helper); | ||||
if (status != SUCCESS) { | if (status != SUCCESS) { | ||||
GELOGE(status, "GenerateGeRootModel failed"); | |||||
GELOGE(status, "[Generate][GERootModel]Failed"); | |||||
return status; | return status; | ||||
} | } | ||||
GELOGD("in ModelHelper::LoadRootModel, is_assign_model_ is setted to true!"); | 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_); | GE_CHECK_NOTNULL(root_model_); | ||||
if (!is_unknown_shape_model_) { | if (!is_unknown_shape_model_) { | ||||
if (GenerateGeModel(om_load_helper) != SUCCESS) { | 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; | return FAILED; | ||||
} | } | ||||
GE_CHECK_NOTNULL(model_); | GE_CHECK_NOTNULL(model_); | ||||
@@ -637,7 +735,10 @@ Status ModelHelper::LoadModelData(OmFileLoadHelper &om_load_helper) { | |||||
ge::Model model; | ge::Model model; | ||||
if (ge::Model::Load(partition_model_def.data, partition_model_def.size, model) != SUCCESS) { | 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; | return INTERNAL_ERROR; | ||||
} | } | ||||
@@ -661,7 +762,10 @@ Status ModelHelper::LoadModelData(OmFileLoadHelper &om_load_helper, GeModelPtr & | |||||
ge::Model model; | ge::Model model; | ||||
if (ge::Model::Load(partition_model_def.data, partition_model_def.size, model) != SUCCESS) { | 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; | return INTERNAL_ERROR; | ||||
} | } | ||||
@@ -673,7 +777,9 @@ Status ModelHelper::LoadModelData(OmFileLoadHelper &om_load_helper, GeModelPtr & | |||||
Status ModelHelper::LoadWeights(OmFileLoadHelper &om_load_helper) { | Status ModelHelper::LoadWeights(OmFileLoadHelper &om_load_helper) { | ||||
ModelPartition partition; | ModelPartition partition; | ||||
if (om_load_helper.GetModelPartition(ModelPartitionType::WEIGHTS_DATA, partition) != SUCCESS) { | 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; | return FAILED; | ||||
} | } | ||||
ge::Buffer weight = ge::Buffer::CopyFrom(partition.data, partition.size); | 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) { | Status ModelHelper::LoadWeights(OmFileLoadHelper &om_load_helper, GeModelPtr &cur_model, size_t mode_index) { | ||||
ModelPartition partition; | ModelPartition partition; | ||||
if (om_load_helper.GetModelPartition(ModelPartitionType::WEIGHTS_DATA, partition, mode_index) != SUCCESS) { | 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; | return FAILED; | ||||
} | } | ||||
ge::Buffer weight = ge::Buffer::CopyFrom(partition.data, partition.size); | 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) { | FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadTask(OmFileLoadHelper &om_load_helper) { | ||||
ModelPartition task_partition; | ModelPartition task_partition; | ||||
if (om_load_helper.GetModelPartition(ModelPartitionType::TASK_INFO, task_partition) != SUCCESS) { | 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; | return FAILED; | ||||
} | } | ||||
std::shared_ptr<ModelTaskDef> task = ge::MakeShared<ModelTaskDef>(); | std::shared_ptr<ModelTaskDef> task = ge::MakeShared<ModelTaskDef>(); | ||||
GE_CHECK_NOTNULL(task); | GE_CHECK_NOTNULL(task); | ||||
if (task_partition.size != 0) { | if (task_partition.size != 0) { | ||||
if (!ReadProtoFromArray(task_partition.data, task_partition.size, task.get())) { | 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; | return INTERNAL_ERROR; | ||||
} | } | ||||
GELOGD("TASK_INFO op_size:%d, stream_num:%u", task->op().size(), task->stream_num()); | 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; | ModelPartition task_partition; | ||||
if (om_load_helper.GetModelPartition(ModelPartitionType::TASK_INFO, task_partition, mode_index) != SUCCESS) { | if (om_load_helper.GetModelPartition(ModelPartitionType::TASK_INFO, task_partition, mode_index) != SUCCESS) { | ||||
GELOGE(FAILED, "Get task model partition failed."); | 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; | return FAILED; | ||||
} | } | ||||
std::shared_ptr<ModelTaskDef> task = ge::MakeShared<ModelTaskDef>(); | std::shared_ptr<ModelTaskDef> task = ge::MakeShared<ModelTaskDef>(); | ||||
GE_CHECK_NOTNULL(task); | GE_CHECK_NOTNULL(task); | ||||
if (task_partition.size != 0) { | if (task_partition.size != 0) { | ||||
if (!ReadProtoFromArray(task_partition.data, task_partition.size, task.get())) { | 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; | return INTERNAL_ERROR; | ||||
} | } | ||||
GELOGD("TASK_INFO op_size:%d, stream_num:%u", task->op().size(), task->stream_num()); | 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) { | if (model_addr_tmp_ != nullptr) { | ||||
errno_t ret = memset_s(static_cast<void *>(model_addr_tmp_), model_len_tmp_, 0, model_len_tmp_); | errno_t ret = memset_s(static_cast<void *>(model_addr_tmp_), model_len_tmp_, 0, model_len_tmp_); | ||||
if (ret != EOK) { | 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; | result = FAILED; | ||||
} | } | ||||
delete[] model_addr_tmp_; | 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); | Status ret = ModelParserBase::LoadFromFile(model_file, "", priority, model); | ||||
if (ret != SUCCESS) { | 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; | return ret; | ||||
} | } | ||||
std::function<void()> callback = [&]() { | std::function<void()> callback = [&]() { | ||||
@@ -902,31 +1025,32 @@ Status ModelTool::GetModelInfoFromOm(const char *model_file, ge::proto::ModelDef | |||||
ErrorManager::GetInstance().ATCReportErrMessage("E10003", | ErrorManager::GetInstance().ATCReportErrMessage("E10003", | ||||
{"parameter", "value", "reason"}, {"om", model_file, "invalid om file"}); | {"parameter", "value", "reason"}, {"om", model_file, "invalid om file"}); | ||||
GELOGE(ACL_ERROR_GE_PARAM_INVALID, | 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; | return ret; | ||||
} | } | ||||
OmFileLoadHelper om_load_helper; | OmFileLoadHelper om_load_helper; | ||||
ret = om_load_helper.Init(model_data, model_len); | ret = om_load_helper.Init(model_data, model_len); | ||||
if (ret != SUCCESS) { | 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; | return ret; | ||||
} | } | ||||
ModelPartition ir_part; | ModelPartition ir_part; | ||||
ret = om_load_helper.GetModelPartition(MODEL_DEF, ir_part); | ret = om_load_helper.GetModelPartition(MODEL_DEF, ir_part); | ||||
if (ret != SUCCESS) { | 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; | return ret; | ||||
} | } | ||||
bool flag = ReadProtoFromArray(ir_part.data, ir_part.size, &model_def); | bool flag = ReadProtoFromArray(ir_part.data, ir_part.size, &model_def); | ||||
if (!flag) { | if (!flag) { | ||||
ret = INTERNAL_ERROR; | 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; | return ret; | ||||
} | } | ||||
modeldef_size = ir_part.size; | modeldef_size = ir_part.size; | ||||
@@ -947,7 +1071,9 @@ Status ModelTool::GetModelInfoFromPbtxt(const char *model_file, ge::proto::Model | |||||
}; | }; | ||||
if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
free_model_data(&model.model_data); | 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; | 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); | bool flag = google::protobuf::TextFormat::ParseFromString(reinterpret_cast<char *>(model.model_data), &model_def); | ||||
if (!flag) { | if (!flag) { | ||||
free_model_data(&model.model_data); | 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; | return FAILED; | ||||
} | } | ||||
free_model_data(&model.model_data); | free_model_data(&model.model_data); | ||||
return SUCCESS; | return SUCCESS; | ||||
} catch (google::protobuf::FatalException &e) { | } catch (google::protobuf::FatalException &e) { | ||||
free_model_data(&model.model_data); | 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; | return FAILED; | ||||
} | } | ||||
} | } | ||||
@@ -1,5 +1,5 @@ | |||||
syntax = "proto3"; | syntax = "proto3"; | ||||
package aicpu.dump; | |||||
package toolkit.aicpu.dump; | |||||
message Shape { | message Shape { | ||||
repeated uint64 dim = 1; | repeated uint64 dim = 1; |
@@ -3,46 +3,12 @@ set(PROTO_LIST | |||||
"${METADEF_DIR}/proto/ge_ir.proto" | "${METADEF_DIR}/proto/ge_ir.proto" | ||||
"${METADEF_DIR}/proto/insert_op.proto" | "${METADEF_DIR}/proto/insert_op.proto" | ||||
"${METADEF_DIR}/proto/task.proto" | "${METADEF_DIR}/proto/task.proto" | ||||
) | |||||
set(DUMP_PROTO_LIST | |||||
"${METADEF_DIR}/proto/op_mapping.proto" | |||||
"${METADEF_DIR}/proto/dump_task.proto" | "${METADEF_DIR}/proto/dump_task.proto" | ||||
"${METADEF_DIR}/proto/op_mapping_info.proto" | |||||
) | ) | ||||
protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) | protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) | ||||
protobuf_generate(ge_static PROTO_STATIC_SRCS PROTO_STATIC_HDRS ${PROTO_LIST}) | protobuf_generate(ge_static PROTO_STATIC_SRCS PROTO_STATIC_HDRS ${PROTO_LIST}) | ||||
protobuf_generate(ge_dump DUMP_PROTO_SRCS DUMP_PROTO_HDRS ${DUMP_PROTO_LIST}) | |||||
############ libge_proto_dump.a ############ | |||||
add_library(ge_proto_dump STATIC | |||||
${DUMP_PROTO_SRCS} | |||||
) | |||||
target_compile_definitions(ge_proto_dump PRIVATE | |||||
PROTOBUF_INLINE_NOT_IN_HEADERS=0 | |||||
google=ascend_private | |||||
$<IF:$<STREQUAL:${TARGET_SYSTEM_NAME},Windows>,OS_TYPE=WIN,OS_TYPE=0> | |||||
$<$<STREQUAL:${TARGET_SYSTEM_NAME},Windows>:SECUREC_USING_STD_SECURE_LIB=0 NOMINMAX> | |||||
) | |||||
target_compile_options(ge_proto_dump PRIVATE | |||||
-O2 | |||||
-fno-common | |||||
-fvisibility=hidden | |||||
$<$<AND:$<STREQUAL:${TARGET_SYSTEM_NAME},Windows>,$<STREQUAL:${CMAKE_CONFIGURATION_TYPES},Debug>>:/MTd> | |||||
$<$<AND:$<STREQUAL:${TARGET_SYSTEM_NAME},Windows>,$<STREQUAL:${CMAKE_CONFIGURATION_TYPES},Release>>:/MT> | |||||
) | |||||
target_link_libraries(ge_proto_dump PRIVATE | |||||
$<BUILD_INTERFACE:intf_pub> | |||||
ascend_protobuf_static | |||||
) | |||||
target_link_options(ge_proto_dump PRIVATE | |||||
-Wl,-Bsymbolic | |||||
) | |||||
################################################################## | |||||
set(SRC_LIST | set(SRC_LIST | ||||
"ge_executor.cc" | "ge_executor.cc" | ||||
@@ -227,7 +193,6 @@ target_include_directories(ge_executor SYSTEM PRIVATE | |||||
${METADEF_DIR}/inc/external/graph | ${METADEF_DIR}/inc/external/graph | ||||
${METADEF_DIR}/inc/graph | ${METADEF_DIR}/inc/graph | ||||
${CMAKE_BINARY_DIR} | ${CMAKE_BINARY_DIR} | ||||
${CMAKE_BINARY_DIR}/proto/ge_dump | |||||
${CMAKE_BINARY_DIR}/proto/ge_static | ${CMAKE_BINARY_DIR}/proto/ge_static | ||||
#### yellow zone #### | #### yellow zone #### | ||||
${GE_CODE_DIR}/../inc | ${GE_CODE_DIR}/../inc | ||||
@@ -240,7 +205,6 @@ target_link_libraries(ge_executor PRIVATE | |||||
$<BUILD_INTERFACE:intf_pub> | $<BUILD_INTERFACE:intf_pub> | ||||
json | json | ||||
ascend_protobuf_static | ascend_protobuf_static | ||||
ge_proto_dump | |||||
c_sec | c_sec | ||||
$<$<NOT:$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>:-lrt> | $<$<NOT:$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>:-lrt> | ||||
-ldl | -ldl | ||||
@@ -275,7 +239,6 @@ target_include_directories(ge_executor_shared PRIVATE | |||||
${METADEF_DIR}/inc/external/graph | ${METADEF_DIR}/inc/external/graph | ||||
${METADEF_DIR}/inc/graph | ${METADEF_DIR}/inc/graph | ||||
${CMAKE_BINARY_DIR} | ${CMAKE_BINARY_DIR} | ||||
${CMAKE_BINARY_DIR}/proto/ge_dump | |||||
${CMAKE_BINARY_DIR}/proto/ge | ${CMAKE_BINARY_DIR}/proto/ge | ||||
#### yellow zone #### | #### yellow zone #### | ||||
${GE_CODE_DIR}/../inc | ${GE_CODE_DIR}/../inc | ||||
@@ -291,7 +254,6 @@ target_link_options(ge_executor_shared PRIVATE | |||||
target_link_libraries(ge_executor_shared PRIVATE | target_link_libraries(ge_executor_shared PRIVATE | ||||
$<BUILD_INTERFACE:intf_pub> | $<BUILD_INTERFACE:intf_pub> | ||||
ge_proto_dump | |||||
-Wl,--no-as-needed | -Wl,--no-as-needed | ||||
ge_common | ge_common | ||||
runtime | runtime | ||||
@@ -1,5 +1,5 @@ | |||||
syntax = "proto3"; | syntax = "proto3"; | ||||
package toolkit.dumpdata; | |||||
package toolkit.dump; | |||||
enum OutputDataType { | enum OutputDataType { | ||||
DT_UNDEFINED = 0; | DT_UNDEFINED = 0; | ||||
@@ -1,5 +1,5 @@ | |||||
syntax = "proto3"; | syntax = "proto3"; | ||||
package aicpu.dump; | |||||
package toolkit.aicpu.dump; | |||||
message Shape { | message Shape { | ||||
repeated uint64 dim = 1; | repeated uint64 dim = 1; |
@@ -35,7 +35,7 @@ | |||||
#include "graph/utils/tensor_utils.h" | #include "graph/utils/tensor_utils.h" | ||||
#include "proto/dump_task.pb.h" | #include "proto/dump_task.pb.h" | ||||
#include "proto/ge_ir.pb.h" | #include "proto/ge_ir.pb.h" | ||||
#include "proto/op_mapping_info.pb.h" | |||||
#include "proto/op_mapping.pb.h" | |||||
#include "runtime/base.h" | #include "runtime/base.h" | ||||
#include "runtime/mem.h" | #include "runtime/mem.h" | ||||
@@ -217,7 +217,7 @@ void DataDumper::SaveDumpTask(uint32_t task_id, uint32_t stream_id, const std::s | |||||
} | } | ||||
static void SetOpMappingLoopAddr(uintptr_t step_id, uintptr_t loop_per_iter, uintptr_t loop_cond, | static void SetOpMappingLoopAddr(uintptr_t step_id, uintptr_t loop_per_iter, uintptr_t loop_cond, | ||||
aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
toolkit::aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
if (step_id != 0) { | if (step_id != 0) { | ||||
GELOGI("step_id exists."); | GELOGI("step_id exists."); | ||||
op_mapping_info.set_step_id_addr(static_cast<uint64_t>(step_id)); | op_mapping_info.set_step_id_addr(static_cast<uint64_t>(step_id)); | ||||
@@ -234,7 +234,8 @@ static void SetOpMappingLoopAddr(uintptr_t step_id, uintptr_t loop_per_iter, uin | |||||
} | } | ||||
} | } | ||||
Status DataDumper::GenerateOutput(aicpu::dump::Output &output, const OpDesc::Vistor<GeTensorDesc> &tensor_descs, | |||||
Status DataDumper::GenerateOutput(toolkit::aicpu::dump::Output &output, | |||||
const OpDesc::Vistor<GeTensorDesc> &tensor_descs, | |||||
const uintptr_t &addr, size_t index) { | const uintptr_t &addr, size_t index) { | ||||
output.set_data_type(static_cast<int32_t>(GetIrDataType(tensor_descs.at(index).GetDataType()))); | output.set_data_type(static_cast<int32_t>(GetIrDataType(tensor_descs.at(index).GetDataType()))); | ||||
output.set_format(static_cast<int32_t>(tensor_descs.at(index).GetFormat())); | output.set_format(static_cast<int32_t>(tensor_descs.at(index).GetFormat())); | ||||
@@ -265,7 +266,8 @@ Status DataDumper::GenerateOutput(aicpu::dump::Output &output, const OpDesc::Vis | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
Status DataDumper::DumpRefOutput(const DataDumper::InnerDumpInfo &inner_dump_info, aicpu::dump::Output &output, | |||||
Status DataDumper::DumpRefOutput(const DataDumper::InnerDumpInfo &inner_dump_info, | |||||
toolkit::aicpu::dump::Output &output, | |||||
size_t i, const std::string &node_name_index) { | size_t i, const std::string &node_name_index) { | ||||
std::string dump_op_name; | std::string dump_op_name; | ||||
std::string input_or_output; | std::string input_or_output; | ||||
@@ -306,7 +308,7 @@ Status DataDumper::DumpRefOutput(const DataDumper::InnerDumpInfo &inner_dump_inf | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
Status DataDumper::DumpOutputWithTask(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task) { | |||||
Status DataDumper::DumpOutputWithTask(const InnerDumpInfo &inner_dump_info, toolkit::aicpu::dump::Task &task) { | |||||
const auto &output_descs = inner_dump_info.op->GetAllOutputsDesc(); | const auto &output_descs = inner_dump_info.op->GetAllOutputsDesc(); | ||||
const std::vector<void *> output_addrs = ModelUtils::GetOutputDataAddrs(*runtime_param_, inner_dump_info.op); | const std::vector<void *> output_addrs = ModelUtils::GetOutputDataAddrs(*runtime_param_, inner_dump_info.op); | ||||
std::vector<int64_t> v_memory_type; | std::vector<int64_t> v_memory_type; | ||||
@@ -318,7 +320,7 @@ Status DataDumper::DumpOutputWithTask(const InnerDumpInfo &inner_dump_info, aicp | |||||
size_t no_need_dump_output_num = 0; | size_t no_need_dump_output_num = 0; | ||||
for (size_t i = 0; i < output_descs.size(); ++i) { | for (size_t i = 0; i < output_descs.size(); ++i) { | ||||
aicpu::dump::Output output; | |||||
toolkit::aicpu::dump::Output output; | |||||
std::string node_name_index; | std::string node_name_index; | ||||
const auto &output_desc = output_descs.at(i); | const auto &output_desc = output_descs.at(i); | ||||
int32_t calc_type = 0; | int32_t calc_type = 0; | ||||
@@ -370,14 +372,14 @@ Status DataDumper::DumpOutputWithTask(const InnerDumpInfo &inner_dump_info, aicp | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
Status DataDumper::DumpOutput(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task) { | |||||
Status DataDumper::DumpOutput(const InnerDumpInfo &inner_dump_info, toolkit::aicpu::dump::Task &task) { | |||||
GELOGI("Start dump output"); | GELOGI("Start dump output"); | ||||
if (inner_dump_info.is_task) { | if (inner_dump_info.is_task) { | ||||
// tbe or aicpu op, these ops are with task | // tbe or aicpu op, these ops are with task | ||||
return DumpOutputWithTask(inner_dump_info, task); | return DumpOutputWithTask(inner_dump_info, task); | ||||
} | } | ||||
// else data, const or variable op | // else data, const or variable op | ||||
aicpu::dump::Output output; | |||||
toolkit::aicpu::dump::Output output; | |||||
auto output_tensor = inner_dump_info.op->GetOutputDescPtr(inner_dump_info.output_anchor_index); | auto output_tensor = inner_dump_info.op->GetOutputDescPtr(inner_dump_info.output_anchor_index); | ||||
const std::vector<void *> output_addrs = ModelUtils::GetOutputDataAddrs(*runtime_param_, inner_dump_info.op); | const std::vector<void *> output_addrs = ModelUtils::GetOutputDataAddrs(*runtime_param_, inner_dump_info.op); | ||||
if (output_tensor == nullptr) { | if (output_tensor == nullptr) { | ||||
@@ -422,7 +424,7 @@ Status DataDumper::DumpOutput(const InnerDumpInfo &inner_dump_info, aicpu::dump: | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
Status DataDumper::GenerateInput(aicpu::dump::Input &input, const OpDesc::Vistor<GeTensorDesc> &tensor_descs, | |||||
Status DataDumper::GenerateInput(toolkit::aicpu::dump::Input &input, const OpDesc::Vistor<GeTensorDesc> &tensor_descs, | |||||
const uintptr_t &addr, size_t index) { | const uintptr_t &addr, size_t index) { | ||||
input.set_data_type(static_cast<int32_t>(GetIrDataType(tensor_descs.at(index).GetDataType()))); | input.set_data_type(static_cast<int32_t>(GetIrDataType(tensor_descs.at(index).GetDataType()))); | ||||
input.set_format(static_cast<int32_t>(tensor_descs.at(index).GetFormat())); | input.set_format(static_cast<int32_t>(tensor_descs.at(index).GetFormat())); | ||||
@@ -447,8 +449,8 @@ Status DataDumper::GenerateInput(aicpu::dump::Input &input, const OpDesc::Vistor | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
Status DataDumper::DumpRefInput(const DataDumper::InnerDumpInfo &inner_dump_info, aicpu::dump::Input &input, size_t i, | |||||
const std::string &node_name_index) { | |||||
Status DataDumper::DumpRefInput(const DataDumper::InnerDumpInfo &inner_dump_info, toolkit::aicpu::dump::Input &input, | |||||
size_t i, const std::string &node_name_index) { | |||||
std::string dump_op_name; | std::string dump_op_name; | ||||
std::string input_or_output; | std::string input_or_output; | ||||
size_t index; | size_t index; | ||||
@@ -488,7 +490,7 @@ Status DataDumper::DumpRefInput(const DataDumper::InnerDumpInfo &inner_dump_info | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
Status DataDumper::DumpInput(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task) { | |||||
Status DataDumper::DumpInput(const InnerDumpInfo &inner_dump_info, toolkit::aicpu::dump::Task &task) { | |||||
GELOGI("Start dump input"); | GELOGI("Start dump input"); | ||||
const auto &input_descs = inner_dump_info.op->GetAllInputsDesc(); | const auto &input_descs = inner_dump_info.op->GetAllInputsDesc(); | ||||
const std::vector<void *> input_addrs = ModelUtils::GetInputDataAddrs(*runtime_param_, inner_dump_info.op); | const std::vector<void *> input_addrs = ModelUtils::GetInputDataAddrs(*runtime_param_, inner_dump_info.op); | ||||
@@ -507,7 +509,7 @@ Status DataDumper::DumpInput(const InnerDumpInfo &inner_dump_info, aicpu::dump:: | |||||
inner_dump_info.op->GetName().c_str(), input_descs.size(), v_memory_type.size()); | inner_dump_info.op->GetName().c_str(), input_descs.size(), v_memory_type.size()); | ||||
for (size_t i = 0; i < input_descs.size(); ++i) { | for (size_t i = 0; i < input_descs.size(); ++i) { | ||||
aicpu::dump::Input input; | |||||
toolkit::aicpu::dump::Input input; | |||||
std::string node_name_index; | std::string node_name_index; | ||||
// check dump input tensor desc is redirected by attr ATTR_DATA_DUMP_REF | // check dump input tensor desc is redirected by attr ATTR_DATA_DUMP_REF | ||||
if (AttrUtils::GetStr(&input_descs.at(i), ATTR_DATA_DUMP_REF, node_name_index)) { | if (AttrUtils::GetStr(&input_descs.at(i), ATTR_DATA_DUMP_REF, node_name_index)) { | ||||
@@ -538,15 +540,15 @@ Status DataDumper::DumpInput(const InnerDumpInfo &inner_dump_info, aicpu::dump:: | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
void DataDumper::GenerateOpBuffer(const int64_t &size, aicpu::dump::Task &task) { | |||||
aicpu::dump::OpBuffer op_buffer; | |||||
op_buffer.set_buffer_type(aicpu::dump::BufferType::L1); | |||||
void DataDumper::GenerateOpBuffer(const int64_t &size, toolkit::aicpu::dump::Task &task) { | |||||
toolkit::aicpu::dump::OpBuffer op_buffer; | |||||
op_buffer.set_buffer_type(toolkit::aicpu::dump::BufferType::L1); | |||||
op_buffer.set_address(reinterpret_cast<uintptr_t>(l1_fusion_addr_)); | op_buffer.set_address(reinterpret_cast<uintptr_t>(l1_fusion_addr_)); | ||||
op_buffer.set_size(size); | op_buffer.set_size(size); | ||||
task.mutable_buffer()->Add(std::move(op_buffer)); | task.mutable_buffer()->Add(std::move(op_buffer)); | ||||
} | } | ||||
Status DataDumper::ExecuteLoadDumpInfo(aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
Status DataDumper::ExecuteLoadDumpInfo(toolkit::aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
std::string proto_str; | std::string proto_str; | ||||
size_t proto_size = op_mapping_info.ByteSizeLong(); | size_t proto_size = op_mapping_info.ByteSizeLong(); | ||||
bool ret = op_mapping_info.SerializeToString(&proto_str); | bool ret = op_mapping_info.SerializeToString(&proto_str); | ||||
@@ -590,7 +592,7 @@ Status DataDumper::ExecuteLoadDumpInfo(aicpu::dump::OpMappingInfo &op_mapping_in | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
Status DataDumper::ExecuteUnLoadDumpInfo(aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
Status DataDumper::ExecuteUnLoadDumpInfo(toolkit::aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
std::string proto_str; | std::string proto_str; | ||||
size_t proto_size = op_mapping_info.ByteSizeLong(); | size_t proto_size = op_mapping_info.ByteSizeLong(); | ||||
bool ret = op_mapping_info.SerializeToString(&proto_str); | bool ret = op_mapping_info.SerializeToString(&proto_str); | ||||
@@ -641,7 +643,7 @@ Status DataDumper::LoadDumpInfo() { | |||||
GELOGD("op_list_ is empty"); | GELOGD("op_list_ is empty"); | ||||
} | } | ||||
aicpu::dump::OpMappingInfo op_mapping_info; | |||||
toolkit::aicpu::dump::OpMappingInfo op_mapping_info; | |||||
auto dump_path = dump_properties_.GetDumpPath() + std::to_string(device_id_) + "/"; | auto dump_path = dump_properties_.GetDumpPath() + std::to_string(device_id_) + "/"; | ||||
op_mapping_info.set_dump_path(dump_path); | op_mapping_info.set_dump_path(dump_path); | ||||
@@ -670,11 +672,11 @@ Status DataDumper::LoadDumpInfo() { | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
Status DataDumper::BuildTaskInfo(aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
Status DataDumper::BuildTaskInfo(toolkit::aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
for (const auto &op_iter : op_list_) { | for (const auto &op_iter : op_list_) { | ||||
auto op_desc = op_iter.op; | auto op_desc = op_iter.op; | ||||
GELOGD("Op %s in model begin to add task in op_mapping_info", op_desc->GetName().c_str()); | GELOGD("Op %s in model begin to add task in op_mapping_info", op_desc->GetName().c_str()); | ||||
aicpu::dump::Task task; | |||||
toolkit::aicpu::dump::Task task; | |||||
task.set_end_graph(false); | task.set_end_graph(false); | ||||
task.set_task_id(op_iter.task_id); | task.set_task_id(op_iter.task_id); | ||||
task.set_stream_id(op_iter.stream_id); | task.set_stream_id(op_iter.stream_id); | ||||
@@ -722,10 +724,10 @@ Status DataDumper::BuildTaskInfo(aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
} | } | ||||
void DataDumper::SetEndGraphIdToAicpu(uint32_t task_id, uint32_t stream_id, | void DataDumper::SetEndGraphIdToAicpu(uint32_t task_id, uint32_t stream_id, | ||||
aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
toolkit::aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
if (dump_properties_.GetDumpMode() == kDumpOutput || dump_properties_.GetDumpMode() == kDumpInput || | if (dump_properties_.GetDumpMode() == kDumpOutput || dump_properties_.GetDumpMode() == kDumpInput || | ||||
dump_properties_.GetDumpMode() == kDumpAll) { | dump_properties_.GetDumpMode() == kDumpAll) { | ||||
aicpu::dump::Task task; | |||||
toolkit::aicpu::dump::Task task; | |||||
task.set_end_graph(true); | task.set_end_graph(true); | ||||
task.set_task_id(end_graph_task_id_); | task.set_task_id(end_graph_task_id_); | ||||
task.set_stream_id(end_graph_stream_id_); | task.set_stream_id(end_graph_stream_id_); | ||||
@@ -734,7 +736,7 @@ void DataDumper::SetEndGraphIdToAicpu(uint32_t task_id, uint32_t stream_id, | |||||
op_mapping_info.mutable_task()->Add(std::move(task)); | op_mapping_info.mutable_task()->Add(std::move(task)); | ||||
is_end_graph_ = true; | is_end_graph_ = true; | ||||
if (op_mapping_info.model_name_param_case() == aicpu::dump::OpMappingInfo::kModelName) { | |||||
if (op_mapping_info.model_name_param_case() == toolkit::aicpu::dump::OpMappingInfo::kModelName) { | |||||
GELOGI("Add end_graph_info to aicpu, model_name is %s, task_id is %u, stream_id is %u", | GELOGI("Add end_graph_info to aicpu, model_name is %s, task_id is %u, stream_id is %u", | ||||
op_mapping_info.model_name().c_str(), end_graph_task_id_, end_graph_stream_id_); | op_mapping_info.model_name().c_str(), end_graph_task_id_, end_graph_stream_id_); | ||||
return; | return; | ||||
@@ -744,10 +746,10 @@ void DataDumper::SetEndGraphIdToAicpu(uint32_t task_id, uint32_t stream_id, | |||||
} | } | ||||
void DataDumper::SetOpDebugIdToAicpu(uint32_t task_id, uint32_t stream_id, void *op_debug_addr, | void DataDumper::SetOpDebugIdToAicpu(uint32_t task_id, uint32_t stream_id, void *op_debug_addr, | ||||
aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
toolkit::aicpu::dump::OpMappingInfo &op_mapping_info) { | |||||
if (is_op_debug_) { | if (is_op_debug_) { | ||||
GELOGI("add op_debug_info to aicpu, task_id is %u, stream_id is %u", task_id, stream_id); | GELOGI("add op_debug_info to aicpu, task_id is %u, stream_id is %u", task_id, stream_id); | ||||
aicpu::dump::Task task; | |||||
toolkit::aicpu::dump::Task task; | |||||
task.set_end_graph(false); | task.set_end_graph(false); | ||||
task.set_task_id(task_id); | task.set_task_id(task_id); | ||||
task.set_stream_id(stream_id); | task.set_stream_id(stream_id); | ||||
@@ -755,7 +757,7 @@ void DataDumper::SetOpDebugIdToAicpu(uint32_t task_id, uint32_t stream_id, void | |||||
task.mutable_op()->set_op_type(OP_TYPE_OP_DEBUG); | task.mutable_op()->set_op_type(OP_TYPE_OP_DEBUG); | ||||
// set output | // set output | ||||
aicpu::dump::Output output; | |||||
toolkit::aicpu::dump::Output output; | |||||
output.set_data_type(DT_UINT8); | output.set_data_type(DT_UINT8); | ||||
output.set_format(FORMAT_ND); | output.set_format(FORMAT_ND); | ||||
@@ -781,12 +783,12 @@ Status DataDumper::UnloadDumpInfo() { | |||||
} | } | ||||
GELOGI("UnloadDumpInfo start."); | GELOGI("UnloadDumpInfo start."); | ||||
aicpu::dump::OpMappingInfo op_mapping_info; | |||||
toolkit::aicpu::dump::OpMappingInfo op_mapping_info; | |||||
op_mapping_info.set_model_id(model_id_); | op_mapping_info.set_model_id(model_id_); | ||||
op_mapping_info.set_flag(kAicpuUnloadFlag); | op_mapping_info.set_flag(kAicpuUnloadFlag); | ||||
for (const auto &op_iter : op_list_) { | for (const auto &op_iter : op_list_) { | ||||
aicpu::dump::Task task; | |||||
toolkit::aicpu::dump::Task task; | |||||
task.set_task_id(op_iter.task_id); | task.set_task_id(op_iter.task_id); | ||||
task.set_stream_id(op_iter.stream_id); | task.set_stream_id(op_iter.stream_id); | ||||
op_mapping_info.mutable_task()->Add(std::move(task)); | op_mapping_info.mutable_task()->Add(std::move(task)); | ||||
@@ -27,7 +27,7 @@ | |||||
#include "graph/node.h" | #include "graph/node.h" | ||||
#include "graph/compute_graph.h" | #include "graph/compute_graph.h" | ||||
#include "proto/ge_ir.pb.h" | #include "proto/ge_ir.pb.h" | ||||
#include "proto/op_mapping_info.pb.h" | |||||
#include "proto/op_mapping.pb.h" | |||||
#include "runtime/mem.h" | #include "runtime/mem.h" | ||||
#include "task_info/task_info.h" | #include "task_info/task_info.h" | ||||
#include "framework/common/ge_types.h" | #include "framework/common/ge_types.h" | ||||
@@ -128,24 +128,25 @@ class DataDumper { | |||||
DumpProperties dump_properties_; | DumpProperties dump_properties_; | ||||
// Build task info of op mapping info | // Build task info of op mapping info | ||||
Status BuildTaskInfo(aicpu::dump::OpMappingInfo &op_mapping_info); | |||||
Status DumpOutput(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task); | |||||
Status DumpRefOutput(const DataDumper::InnerDumpInfo &inner_dump_info, aicpu::dump::Output &output, size_t i, | |||||
const std::string &node_name_index); | |||||
Status DumpOutputWithTask(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task); | |||||
Status DumpInput(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task); | |||||
Status DumpRefInput(const DataDumper::InnerDumpInfo &inner_dump_info, aicpu::dump::Input &input, size_t i, | |||||
const std::string &node_name_index); | |||||
Status ExecuteLoadDumpInfo(aicpu::dump::OpMappingInfo &op_mapping_info); | |||||
void SetEndGraphIdToAicpu(uint32_t task_id, uint32_t stream_id, aicpu::dump::OpMappingInfo &op_mapping_info); | |||||
Status BuildTaskInfo(toolkit::aicpu::dump::OpMappingInfo &op_mapping_info); | |||||
Status DumpOutput(const InnerDumpInfo &inner_dump_info, toolkit::aicpu::dump::Task &task); | |||||
Status DumpRefOutput(const DataDumper::InnerDumpInfo &inner_dump_info, toolkit::aicpu::dump::Output &output, | |||||
size_t i, const std::string &node_name_index); | |||||
Status DumpOutputWithTask(const InnerDumpInfo &inner_dump_info, toolkit::aicpu::dump::Task &task); | |||||
Status DumpInput(const InnerDumpInfo &inner_dump_info, toolkit::aicpu::dump::Task &task); | |||||
Status DumpRefInput(const DataDumper::InnerDumpInfo &inner_dump_info, toolkit::aicpu::dump::Input &input, | |||||
size_t i, const std::string &node_name_index); | |||||
Status ExecuteLoadDumpInfo(toolkit::aicpu::dump::OpMappingInfo &op_mapping_info); | |||||
void SetEndGraphIdToAicpu(uint32_t task_id, uint32_t stream_id, | |||||
toolkit::aicpu::dump::OpMappingInfo &op_mapping_info); | |||||
void SetOpDebugIdToAicpu(uint32_t task_id, uint32_t stream_id, void *op_debug_addr, | void SetOpDebugIdToAicpu(uint32_t task_id, uint32_t stream_id, void *op_debug_addr, | ||||
aicpu::dump::OpMappingInfo &op_mapping_info); | |||||
Status ExecuteUnLoadDumpInfo(aicpu::dump::OpMappingInfo &op_mapping_info); | |||||
Status GenerateInput(aicpu::dump::Input &input, const OpDesc::Vistor<GeTensorDesc> &tensor_descs, | |||||
toolkit::aicpu::dump::OpMappingInfo &op_mapping_info); | |||||
Status ExecuteUnLoadDumpInfo(toolkit::aicpu::dump::OpMappingInfo &op_mapping_info); | |||||
Status GenerateInput(toolkit::aicpu::dump::Input &input, const OpDesc::Vistor<GeTensorDesc> &tensor_descs, | |||||
const uintptr_t &addr, size_t index); | const uintptr_t &addr, size_t index); | ||||
Status GenerateOutput(aicpu::dump::Output &output, const OpDesc::Vistor<GeTensorDesc> &tensor_descs, | |||||
Status GenerateOutput(toolkit::aicpu::dump::Output &output, const OpDesc::Vistor<GeTensorDesc> &tensor_descs, | |||||
const uintptr_t &addr, size_t index); | const uintptr_t &addr, size_t index); | ||||
void GenerateOpBuffer(const int64_t &size, aicpu::dump::Task &task); | |||||
void GenerateOpBuffer(const int64_t &size, toolkit::aicpu::dump::Task &task); | |||||
}; | }; | ||||
struct DataDumper::InnerDumpInfo { | struct DataDumper::InnerDumpInfo { | ||||
uint32_t task_id; | uint32_t task_id; | ||||
@@ -21,6 +21,7 @@ | |||||
#include "graph/common/transop_util.h" | #include "graph/common/transop_util.h" | ||||
#include "graph/debug/ge_attr_define.h" | #include "graph/debug/ge_attr_define.h" | ||||
#include "graph/utils/type_utils.h" | #include "graph/utils/type_utils.h" | ||||
#include "init/gelib.h" | |||||
namespace ge { | namespace ge { | ||||
Status CastRemovePass::Run(NodePtr &node) { | Status CastRemovePass::Run(NodePtr &node) { | ||||
@@ -61,10 +62,14 @@ Status CastRemovePass::Run(NodePtr &node) { | |||||
if (!HasSameDataType(op_desc, end_op_desc, type)) { | if (!HasSameDataType(op_desc, end_op_desc, type)) { | ||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
if (RemoveCast(type, nodes_to_fuse) != SUCCESS) { | |||||
auto instance_ptr = ge::GELib::GetInstance(); | |||||
if ((instance_ptr == nullptr) || (!instance_ptr->InitFlag())) { | |||||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "gelib is not initilized!"); | |||||
return FAILED; | return FAILED; | ||||
} | } | ||||
return SUCCESS; | |||||
OpsKernelManager &ops_kernel_manager = instance_ptr->OpsKernelManagerObj(); | |||||
return DoFuse(ops_kernel_manager, type, nodes_to_fuse); | |||||
} | } | ||||
bool CastRemovePass::CheckPrecisionLoss(const std::vector<NodePtr> &nodes_to_fuse) { | bool CastRemovePass::CheckPrecisionLoss(const std::vector<NodePtr> &nodes_to_fuse) { | ||||
@@ -95,26 +100,14 @@ bool CastRemovePass::HasSameDataType(OpDescPtr &begin_op_desc, OpDescPtr &end_op | |||||
// op1->TransData->Cast->TransposeD->Cast->TransData->op2 | // op1->TransData->Cast->TransposeD->Cast->TransData->op2 | ||||
// change to be | // change to be | ||||
// op1->TransData->TransposeD->TransData->op2 | // op1->TransData->TransposeD->TransData->op2 | ||||
Status CastRemovePass::RemoveCast(DataType &type, std::vector<NodePtr> &nodes_to_fuse) { | |||||
string cast_name; | |||||
for (NodePtr &node : nodes_to_fuse) { | |||||
if (node->GetType() == CAST) { | |||||
GELOGI("CastRemovePass, remove Cast %s.", node->GetName().c_str()); | |||||
cast_name = node->GetName(); | |||||
if (IsolateAndDeleteNode(node, {0}) != SUCCESS) { | |||||
REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed", | |||||
node->GetName().c_str(), node->GetType().c_str()); | |||||
GELOGE(FAILED, "IsolateAndDeleteNode %s failed.", node->GetName().c_str()); | |||||
return FAILED; | |||||
} | |||||
} | |||||
} | |||||
if (cast_name.empty()) { | |||||
return SUCCESS; | |||||
} | |||||
for (auto &node : nodes_to_fuse) { | |||||
Status CastRemovePass::DoFuse(const OpsKernelManager &ops_kernel_manager, | |||||
const DataType &type, | |||||
std::vector<NodePtr> &nodes_to_fuse) { | |||||
std::vector<size_t> to_be_deleted_cast_index; | |||||
for (size_t i = 0; i < nodes_to_fuse.size(); i++) { | |||||
NodePtr node = nodes_to_fuse[i]; | |||||
if (node->GetType() == CAST) { | if (node->GetType() == CAST) { | ||||
to_be_deleted_cast_index.emplace_back(i); | |||||
continue; | continue; | ||||
} | } | ||||
OpDescPtr op_desc = node->GetOpDesc(); | OpDescPtr op_desc = node->GetOpDesc(); | ||||
@@ -123,25 +116,66 @@ Status CastRemovePass::RemoveCast(DataType &type, std::vector<NodePtr> &nodes_to | |||||
GELOGE(FAILED, "OpDesc must not be null."); | GELOGE(FAILED, "OpDesc must not be null."); | ||||
return FAILED; | return FAILED; | ||||
} | } | ||||
auto in_desc = op_desc->MutableInputDesc(0); | |||||
auto out_desc = op_desc->MutableOutputDesc(0); | |||||
auto in_desc_org_dtype = in_desc->GetDataType(); | |||||
auto out_desc_org_dtype = out_desc->GetDataType(); | |||||
in_desc->SetDataType(type); | |||||
out_desc->SetDataType(type); | |||||
bool is_supported = false; | |||||
string un_supported_reasons; | |||||
for (const auto &ops_kernel_store_info : ops_kernel_manager.GetAllOpsKernelInfoStores()) { | |||||
map<string, OpInfo> op_infos; | |||||
ops_kernel_store_info.second->GetAllOpsKernelInfo(op_infos); | |||||
if (op_infos.find(op_desc->GetType()) == op_infos.end()) { | |||||
continue; | |||||
} | |||||
string un_supported_reason; | |||||
is_supported = ops_kernel_store_info.second->CheckAccuracySupported(op_desc, un_supported_reason); | |||||
if (is_supported) { | |||||
break; | |||||
} | |||||
un_supported_reasons += "{op_store " + ops_kernel_store_info.first + ":" + un_supported_reason + "} "; | |||||
} | |||||
if (!is_supported) { | |||||
// if no operator_info_store supported, do nothing | |||||
in_desc->SetDataType(in_desc_org_dtype); | |||||
out_desc->SetDataType(out_desc_org_dtype); | |||||
to_be_deleted_cast_index.clear(); | |||||
GELOGI("Fused Op[%s] check supported fail! Reasons is as follows: %s", | |||||
op_desc->GetName().c_str(), | |||||
un_supported_reasons.c_str()); | |||||
return SUCCESS; | |||||
} | |||||
// change node name for recompile cache, will be abandoned in April | |||||
string new_node_name = cast_name + op_desc->GetName(); | |||||
op_desc->SetName(new_node_name); | |||||
// add attr to changed TransData, then will be rebuild | // add attr to changed TransData, then will be rebuild | ||||
if (!AttrUtils::SetBool(op_desc, ATTR_NEED_COMPILE, true)) { | if (!AttrUtils::SetBool(op_desc, ATTR_NEED_COMPILE, true)) { | ||||
REPORT_CALL_ERROR("E19999", "Set Attr:%s of op:%s(%s) failed", | REPORT_CALL_ERROR("E19999", "Set Attr:%s of op:%s(%s) failed", | ||||
ATTR_NEED_COMPILE.c_str(), | ATTR_NEED_COMPILE.c_str(), | ||||
op_desc->GetName().c_str(), op_desc->GetType().c_str()); | |||||
op_desc->GetName().c_str(), | |||||
op_desc->GetType().c_str()); | |||||
GELOGE(FAILED, "Set ATTR_NEED_COMPILE Attr fail."); | GELOGE(FAILED, "Set ATTR_NEED_COMPILE Attr fail."); | ||||
return FAILED; | return FAILED; | ||||
} | } | ||||
auto in_desc = op_desc->MutableInputDesc(0); | |||||
auto out_desc = op_desc->MutableOutputDesc(0); | |||||
in_desc->SetDataType(type); | |||||
out_desc->SetDataType(type); | |||||
GELOGI("CastRemovePass, change %s %s datatype to be %s.", node->GetType().c_str(), node->GetName().c_str(), | GELOGI("CastRemovePass, change %s %s datatype to be %s.", node->GetType().c_str(), node->GetName().c_str(), | ||||
TypeUtils::DataTypeToSerialString(type).c_str()); | TypeUtils::DataTypeToSerialString(type).c_str()); | ||||
} | } | ||||
return DoRemoveCast(to_be_deleted_cast_index, nodes_to_fuse); | |||||
} | |||||
Status CastRemovePass::DoRemoveCast(const std::vector<size_t> &to_be_deleted_cast_index, | |||||
std::vector<NodePtr> &nodes_to_fuse) { | |||||
for (auto &cast_idx : to_be_deleted_cast_index) { | |||||
GELOGI("CastRemovePass, remove Cast %s.", nodes_to_fuse[cast_idx]->GetName().c_str()); | |||||
if (IsolateAndDeleteNode(nodes_to_fuse[cast_idx], {0}) != SUCCESS) { | |||||
REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed when CastRemovePass %s", | |||||
nodes_to_fuse[cast_idx]->GetName().c_str(), | |||||
nodes_to_fuse[cast_idx]->GetType().c_str(), | |||||
__FUNCTION__); | |||||
GELOGE(FAILED, "IsolateAndDeleteNode %s failed.", nodes_to_fuse[cast_idx]->GetName().c_str()); | |||||
return FAILED; | |||||
} | |||||
} | |||||
return SUCCESS; | return SUCCESS; | ||||
} | } | ||||
@@ -19,6 +19,7 @@ | |||||
#include <vector> | #include <vector> | ||||
#include "graph/passes/base_pass.h" | #include "graph/passes/base_pass.h" | ||||
#include "opskernel_manager/ops_kernel_manager.h" | |||||
namespace ge { | namespace ge { | ||||
class CastRemovePass : public BaseNodePass { | class CastRemovePass : public BaseNodePass { | ||||
@@ -28,8 +29,9 @@ class CastRemovePass : public BaseNodePass { | |||||
private: | private: | ||||
bool CheckPrecisionLoss(const std::vector<NodePtr> &nodes_to_fuse); | bool CheckPrecisionLoss(const std::vector<NodePtr> &nodes_to_fuse); | ||||
bool HasSameDataType(OpDescPtr &begin_op_desc, OpDescPtr &end_op_desc, DataType &type) const; | bool HasSameDataType(OpDescPtr &begin_op_desc, OpDescPtr &end_op_desc, DataType &type) const; | ||||
Status RemoveCast(DataType &type, std::vector<NodePtr> &nodes_to_fuse); | |||||
NodePtr GetTheEndNode(NodePtr begin_node, std::vector<NodePtr> &nodes_to_fuse); | NodePtr GetTheEndNode(NodePtr begin_node, std::vector<NodePtr> &nodes_to_fuse); | ||||
Status DoRemoveCast(const std::vector<size_t> &to_be_deleted_cast_index, std::vector<NodePtr> &nodes_to_fuse); | |||||
Status DoFuse(const OpsKernelManager &ops_kernel_manager, const DataType &type, std::vector<NodePtr> &nodes_to_fuse); | |||||
}; | }; | ||||
} // namespace ge | } // namespace ge | ||||
#endif // GE_GRAPH_PASSES_CAST_REMOVE_PASS_H_ | #endif // GE_GRAPH_PASSES_CAST_REMOVE_PASS_H_ |
@@ -1,5 +1,5 @@ | |||||
syntax = "proto3"; | syntax = "proto3"; | ||||
package toolkit.dumpdata; | |||||
package toolkit.dump; | |||||
enum OutputDataType { | enum OutputDataType { | ||||
DT_UNDEFINED = 0; | DT_UNDEFINED = 0; | ||||
@@ -1,5 +1,5 @@ | |||||
syntax = "proto3"; | syntax = "proto3"; | ||||
package aicpu.dump; | |||||
package toolkit.aicpu.dump; | |||||
message Shape { | message Shape { | ||||
repeated uint64 dim = 1; | repeated uint64 dim = 1; |
@@ -1 +1 @@ | |||||
Subproject commit c1aea328cc04340188e796e639cd55a907488365 | |||||
Subproject commit 7ad77efb16b4a8a8d08345d600b345b7814f8ab6 |
@@ -1 +1 @@ | |||||
Subproject commit 06e784fad01d7e9089cc7e8e0d00fce5b1901886 | |||||
Subproject commit dda9def8bdb5177054a3abc132bf376172c3f01f |
@@ -18,7 +18,7 @@ | |||||
using namespace ErrorMessage; | using namespace ErrorMessage; | ||||
namespace ErrorMessage { | |||||
namespace error_message { | |||||
int FormatErrorMessage(char *str_dst, size_t dst_max, const char *format, ...) { | int FormatErrorMessage(char *str_dst, size_t dst_max, const char *format, ...) { | ||||
return 1; | return 1; | ||||
} | } | ||||
@@ -32,14 +32,6 @@ class UtestGeTestDefType : public testing::Test { | |||||
void TearDown() {} | void TearDown() {} | ||||
}; | }; | ||||
TEST_F(UtestGeTestDefType, base) { | |||||
CompressInfo com1; | |||||
com1.set_blockrow(1); | |||||
int32_t a = com1.blockrow; | |||||
EXPECT_EQ(a, 1); | |||||
} | |||||
TEST_F(UtestGeTestDefType, quant) { | TEST_F(UtestGeTestDefType, quant) { | ||||
OpDescPtr desc_ptr1 = std::make_shared<OpDesc>("name1", "type1"); | OpDescPtr desc_ptr1 = std::make_shared<OpDesc>("name1", "type1"); | ||||
EXPECT_EQ(desc_ptr1->AddInputDesc("x", GeTensorDesc(GeShape({1, 16, 16, 16}), FORMAT_NCHW)), GRAPH_SUCCESS); | EXPECT_EQ(desc_ptr1->AddInputDesc("x", GeTensorDesc(GeShape({1, 16, 16, 16}), FORMAT_NCHW)), GRAPH_SUCCESS); | ||||
@@ -48,28 +40,4 @@ TEST_F(UtestGeTestDefType, quant) { | |||||
EXPECT_EQ(OpDescUtils::HasQuantizeFactorParams(desc_ptr1), false); | EXPECT_EQ(OpDescUtils::HasQuantizeFactorParams(desc_ptr1), false); | ||||
EXPECT_EQ(OpDescUtils::HasQuantizeFactorParams(*desc_ptr1), false); | EXPECT_EQ(OpDescUtils::HasQuantizeFactorParams(*desc_ptr1), false); | ||||
QuantizeFactorParams q1; | |||||
EXPECT_EQ(q1.has_quantize_param(), false); | |||||
QuantizeFactor *qf1 = q1.mutable_quantize_param(); | |||||
EXPECT_EQ(q1.has_quantize_param(), true); | |||||
string s1 = "value1"; | |||||
q1.quantize_param.set_scale_value(s1.data(), s1.size()); | |||||
EXPECT_EQ(OpDescUtils::SetQuantizeFactorParams(desc_ptr1, q1), GRAPH_SUCCESS); | |||||
QuantizeFactorParams q2; | |||||
EXPECT_EQ(OpDescUtils::GetQuantizeFactorParams(desc_ptr1, q2), GRAPH_SUCCESS); | |||||
string s2((char *)q2.quantize_param.scale_value.GetData(), q2.quantize_param.scale_value.GetSize()); | |||||
EXPECT_EQ(s2, "value1"); | |||||
float f[2] = {1, 2}; | |||||
string s(static_cast<char *>(static_cast<void *>(f)), 2 * sizeof(float)); | |||||
q1.quantize_param.set_scale_value(f, 2 * sizeof(float)); | |||||
EXPECT_EQ(OpDescUtils::SetQuantizeFactorParams(*desc_ptr1, q1), GRAPH_SUCCESS); | |||||
QuantizeFactorParams q3; | |||||
EXPECT_EQ(OpDescUtils::GetQuantizeFactorParams(*desc_ptr1, q3), GRAPH_SUCCESS); | |||||
Buffer &b = q3.quantize_param.scale_value; | |||||
float f1[2]; | |||||
memcpy(f1, b.GetData(), b.GetSize()); | |||||
EXPECT_EQ(f1[0], 1); | |||||
EXPECT_EQ(f1[1], 2); | |||||
} | } |
@@ -209,18 +209,6 @@ TEST_F(UtestGeTensor, test_tensor_desc_invalid_null) { | |||||
tensor_desc2.SetDataType(DT_DUAL_SUB_INT8); | tensor_desc2.SetDataType(DT_DUAL_SUB_INT8); | ||||
EXPECT_EQ(tensor_desc2.GetDataType(), DT_DUAL_SUB_INT8); | EXPECT_EQ(tensor_desc2.GetDataType(), DT_DUAL_SUB_INT8); | ||||
CompressInfo info; | |||||
EXPECT_EQ(TensorUtils::GetCmpsInfo(tensor_desc2, info), GRAPH_FAILED); | |||||
TensorUtils::SetCmpsInfo(tensor_desc2, info); | |||||
EXPECT_EQ(TensorUtils::GetCmpsInfo(tensor_desc2, info), GRAPH_SUCCESS); | |||||
AllOffsetQuantizeInfo quantize_info; | |||||
EXPECT_FALSE(TensorUtils::HasAlloffsetQuantizeInfo(tensor_desc2)); | |||||
EXPECT_EQ(TensorUtils::GetAlloffsetQuantizeInfo(tensor_desc2, quantize_info), GRAPH_FAILED); | |||||
TensorUtils::SetAlloffsetQuantizeInfo(tensor_desc2, quantize_info); | |||||
EXPECT_EQ(TensorUtils::GetAlloffsetQuantizeInfo(tensor_desc2, quantize_info), GRAPH_SUCCESS); | |||||
EXPECT_TRUE(TensorUtils::HasAlloffsetQuantizeInfo(tensor_desc2)); | |||||
TensorUtils::SetWeightSize(tensor_desc, 100); | TensorUtils::SetWeightSize(tensor_desc, 100); | ||||
EXPECT_EQ(TensorUtils::GetWeightSize(tensor_desc), 0); | EXPECT_EQ(TensorUtils::GetWeightSize(tensor_desc), 0); | ||||
} | } | ||||
@@ -24,7 +24,7 @@ set(PROTO_LIST | |||||
"${GE_CODE_DIR}/metadef/proto/insert_op.proto" | "${GE_CODE_DIR}/metadef/proto/insert_op.proto" | ||||
"${GE_CODE_DIR}/metadef/proto/dump_task.proto" | "${GE_CODE_DIR}/metadef/proto/dump_task.proto" | ||||
"${GE_CODE_DIR}/metadef/proto/fwk_adapter.proto" | "${GE_CODE_DIR}/metadef/proto/fwk_adapter.proto" | ||||
"${GE_CODE_DIR}/metadef/proto/op_mapping_info.proto" | |||||
"${GE_CODE_DIR}/metadef/proto/op_mapping.proto" | |||||
"${GE_CODE_DIR}/metadef/proto/optimizer_priority.proto" | "${GE_CODE_DIR}/metadef/proto/optimizer_priority.proto" | ||||
"${GE_CODE_DIR}/metadef/proto/ge_api.proto" | "${GE_CODE_DIR}/metadef/proto/ge_api.proto" | ||||
"${GE_CODE_DIR}/metadef/proto/tensorflow/attr_value.proto" | "${GE_CODE_DIR}/metadef/proto/tensorflow/attr_value.proto" | ||||
@@ -590,6 +590,7 @@ set(PASS_TEST_FILES | |||||
"graph/passes/mark_node_unknown_shape_pass_unittest.cc" | "graph/passes/mark_node_unknown_shape_pass_unittest.cc" | ||||
"graph/passes/reshape_recovery_pass_unittest.cc" | "graph/passes/reshape_recovery_pass_unittest.cc" | ||||
"graph/passes/atomic_addr_clean_pass_unittest.cc" | "graph/passes/atomic_addr_clean_pass_unittest.cc" | ||||
"graph/passes/cast_remove_pass_unittest.cc" | |||||
) | ) | ||||
set(KERNEL_TEST_FILES | set(KERNEL_TEST_FILES | ||||
@@ -51,30 +51,19 @@ static ge::OpDescPtr CreateOpDesc(string name = "", string type = "") { | |||||
return op_desc; | return op_desc; | ||||
} | } | ||||
/* | |||||
TEST_F(UtestDataDumper, LoadDumpInfo_no_output_addrs_fail) { | |||||
TEST_F(UtestDataDumper, LoadDumpInfo_success) { | |||||
RuntimeParam rts_param; | RuntimeParam rts_param; | ||||
DataDumper data_dumper(rts_param); | |||||
DataDumper data_dumper(&rts_param); | |||||
data_dumper.SetModelName("test"); | data_dumper.SetModelName("test"); | ||||
data_dumper.SetModelId(2333); | data_dumper.SetModelId(2333); | ||||
std::shared_ptr<OpDesc> op_desc_1(new OpDesc()); | std::shared_ptr<OpDesc> op_desc_1(new OpDesc()); | ||||
op_desc_1->AddOutputDesc("test", GeTensorDesc()); | op_desc_1->AddOutputDesc("test", GeTensorDesc()); | ||||
data_dumper.SaveDumpTask(0, 0, op_desc_1, 0); | data_dumper.SaveDumpTask(0, 0, op_desc_1, 0); | ||||
string dump_mode = "output"; | string dump_mode = "output"; | ||||
data_dumper.is_op_debug_ = true; | |||||
data_dumper.dump_properties_.SetDumpMode(dump_mode); | data_dumper.dump_properties_.SetDumpMode(dump_mode); | ||||
Status ret = data_dumper.LoadDumpInfo(); | |||||
EXPECT_EQ(ret, SUCCESS); | |||||
} | |||||
*/ | |||||
TEST_F(UtestDataDumper, UnloadDumpInfo_success) { | |||||
RuntimeParam rts_param; | |||||
DataDumper data_dumper(&rts_param); | |||||
data_dumper.SetModelName("test"); | |||||
data_dumper.SetModelId(2333); | |||||
Status ret = data_dumper.UnloadDumpInfo(); | |||||
EXPECT_EQ(ret, SUCCESS); | |||||
EXPECT_EQ(data_dumper.LoadDumpInfo(), SUCCESS); | |||||
EXPECT_EQ(data_dumper.UnloadDumpInfo(), SUCCESS); | |||||
} | } | ||||
TEST_F(UtestDataDumper, DumpOutputWithTask_success) { | TEST_F(UtestDataDumper, DumpOutputWithTask_success) { | ||||
@@ -83,7 +72,7 @@ TEST_F(UtestDataDumper, DumpOutputWithTask_success) { | |||||
data_dumper.SetModelName("test"); | data_dumper.SetModelName("test"); | ||||
data_dumper.SetModelId(2333); | data_dumper.SetModelId(2333); | ||||
aicpu::dump::Task task; | |||||
toolkit::aicpu::dump::Task task; | |||||
OpDescPtr op_desc = CreateOpDesc("conv", CONVOLUTION); | OpDescPtr op_desc = CreateOpDesc("conv", CONVOLUTION); | ||||
GeTensorDesc tensor_0(GeShape(), FORMAT_NCHW, DT_FLOAT); | GeTensorDesc tensor_0(GeShape(), FORMAT_NCHW, DT_FLOAT); | ||||
GeTensorDesc tensor_1(GeShape(), FORMAT_NCHW, DT_FLOAT); | GeTensorDesc tensor_1(GeShape(), FORMAT_NCHW, DT_FLOAT); | ||||
@@ -95,5 +84,7 @@ TEST_F(UtestDataDumper, DumpOutputWithTask_success) { | |||||
inner_dump_info.op = op_desc; | inner_dump_info.op = op_desc; | ||||
Status ret = data_dumper.DumpOutputWithTask(inner_dump_info, task); | Status ret = data_dumper.DumpOutputWithTask(inner_dump_info, task); | ||||
EXPECT_EQ(ret, SUCCESS); | EXPECT_EQ(ret, SUCCESS); | ||||
int64_t task_size = 1; | |||||
data_dumper.GenerateOpBuffer(task_size, task); | |||||
} | } | ||||
} // namespace ge | } // namespace ge |
@@ -0,0 +1,88 @@ | |||||
/** | |||||
* Copyright 2019-2020 Huawei Technologies Co., Ltd | |||||
* | |||||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||||
* you may not use this file except in compliance with the License. | |||||
* You may obtain a copy of the License at | |||||
* | |||||
* http://www.apache.org/licenses/LICENSE-2.0 | |||||
* | |||||
* Unless required by applicable law or agreed to in writing, software | |||||
* distributed under the License is distributed on an "AS IS" BASIS, | |||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
* See the License for the specific language governing permissions and | |||||
* limitations under the License. | |||||
*/ | |||||
#include <gtest/gtest.h> | |||||
#include <vector> | |||||
#define protected public | |||||
#define private public | |||||
#include "graph/passes/cast_remove_pass.h" | |||||
#undef protected | |||||
#undef private | |||||
#include "anchor.h" | |||||
#include "common/debug/log.h" | |||||
#include "common/debug/memory_dumper.h" | |||||
#include "common/op/attr_value_util.h" | |||||
#include "common/types.h" | |||||
#include "framework/common/ge_inner_error_codes.h" | |||||
#include "graph/attr_value.h" | |||||
#include "graph/debug/ge_attr_define.h" | |||||
#include "inc/pass_manager.h" | |||||
#include "graph_builder_utils.h" | |||||
#include <string> | |||||
#include <iostream> | |||||
#include <vector> | |||||
#include "opskernel_manager/ops_kernel_manager.h" | |||||
#include "omg/omg_inner_types.h" | |||||
using namespace testing; | |||||
using namespace ge; | |||||
using namespace std; | |||||
class UtestGraphPassesCastRemovePass : public testing::Test { | |||||
protected: | |||||
void SetUp() {} | |||||
void TearDown() {} | |||||
}; | |||||
// case1:no net_out_put_node | |||||
TEST_F(UtestGraphPassesCastRemovePass, DoFuseProcess) { | |||||
std::vector<NodePtr> nodes_to_fuse; | |||||
auto builder = ut::GraphBuilder("g1"); | |||||
auto data = builder.AddNode("data", DATA, 1, 1); | |||||
auto cast1 = builder.AddNode("cast1", CAST, 1, 1); | |||||
cast1->GetOpDesc()->MutableOutputDesc(0)->SetDataType(DT_FLOAT16); | |||||
auto trans = builder.AddNode("trans", TRANSPOSE, 1, 1, FORMAT_NCHW, DT_FLOAT16); | |||||
auto cast2 = builder.AddNode("cast2", CAST, 1, 1); | |||||
cast2->GetOpDesc()->MutableInputDesc(0)->SetDataType(DT_FLOAT16); | |||||
auto net = builder.AddNode("netout", NETOUTPUT, 1, 1); | |||||
builder.AddDataEdge(data, 0, cast1, 0); | |||||
builder.AddDataEdge(cast1, 0, trans, 0); | |||||
builder.AddDataEdge(trans, 0, cast2, 0); | |||||
builder.AddDataEdge(cast2, 0, net, 0); | |||||
ComputeGraphPtr compute_graph = builder.GetGraph(); | |||||
map<string, string> options; | |||||
CastRemovePass cast_remove_pass; | |||||
DataType type = DT_FLOAT; | |||||
nodes_to_fuse.emplace_back(cast1); | |||||
nodes_to_fuse.emplace_back(trans); | |||||
nodes_to_fuse.emplace_back(cast2); | |||||
OpsKernelManager ops_kernel_manager; | |||||
cast_remove_pass.DoFuse(ops_kernel_manager, type, nodes_to_fuse); | |||||
EXPECT_EQ(compute_graph->GetAllNodesSize(),5); | |||||
std::vector<size_t> to_be_deleted_cast_index; | |||||
to_be_deleted_cast_index.emplace_back(0); | |||||
to_be_deleted_cast_index.emplace_back(2); | |||||
(void)cast_remove_pass.DoRemoveCast(to_be_deleted_cast_index, nodes_to_fuse); | |||||
EXPECT_EQ(compute_graph->GetAllNodesSize(),3); | |||||
} |