@@ -482,7 +482,7 @@ Status VarManager::UpdateVarMemSize(rtMemType_t memory_type, int64_t mem_size) { | |||
if (iter == mem_resource_map_.end()) { | |||
mem_resource = MemResource::BuildMemResourceFromType(memory_type); | |||
if (mem_resource == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "memory_type:%d invalid or New MemResource fail, session_id:%lu when VarManager %s", | |||
REPORT_CALL_ERROR("E19999", "memory_type:%d invalid or New MemResource fail, session_id:%lu when VarManager %s", | |||
memory_type, session_id_, __FUNCTION__); | |||
GELOGE(ge::INTERNAL_ERROR, "Alloc MemResource failed, memory_type = %u.", memory_type); | |||
return ge::INTERNAL_ERROR; | |||
@@ -514,8 +514,8 @@ ge::Status VarManager::AssignVarMem(const std::string &var_name, const ge::GeTen | |||
size_t mem_offset = 0; | |||
ge::Status result = TensorUtils::GetSize(tensor_desc, tensor_desc_size); | |||
if (result != ge::SUCCESS) { | |||
REPORT_INNER_ERROR("E19999", "Get size from tensor fail, var_name:%s, memory_type:%d, session_id:%lu, " | |||
"when VarManager %s", var_name.c_str(), memory_type, session_id_, __FUNCTION__); | |||
REPORT_CALL_ERROR("E19999", "Get size from tensor fail, var_name:%s, memory_type:%d, session_id:%lu, " | |||
"when VarManager %s", var_name.c_str(), memory_type, session_id_, __FUNCTION__); | |||
GELOGE(result, "get size from TensorDesc failed"); | |||
return result; | |||
} | |||
@@ -525,8 +525,8 @@ ge::Status VarManager::AssignVarMem(const std::string &var_name, const ge::GeTen | |||
if (it == mem_resource_map_.end()) { | |||
mem_resource = MemResource::BuildMemResourceFromType(memory_type); | |||
if (mem_resource == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "memory_type:%d invalid or New MemResource fail, session_id:%lu when VarManager %s", | |||
memory_type, session_id_, __FUNCTION__); | |||
REPORT_CALL_ERROR("E19999", "memory_type:%d invalid or New MemResource fail, session_id:%lu when VarManager %s", | |||
memory_type, session_id_, __FUNCTION__); | |||
GELOGE(ge::INTERNAL_ERROR, "Alloc MemResource failed, memory_type = %u.", memory_type); | |||
return ge::INTERNAL_ERROR; | |||
} else { | |||
@@ -37,6 +37,7 @@ GraphOptimize::GraphOptimize() | |||
void AddNodeInputProperty(ComputeGraphPtr &compute_graph) { | |||
if (compute_graph == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid when %s", __FUNCTION__); | |||
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[AddNodeInputProperty]: compute_graph is nullptr."); | |||
return; | |||
} | |||
@@ -78,6 +79,7 @@ void AddNodeInputProperty(ComputeGraphPtr &compute_graph) { | |||
Status GraphOptimize::OptimizeSubGraph(ComputeGraphPtr &compute_graph, const std::string &engine_name) { | |||
if (compute_graph == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid when GraphOptimize %s", __FUNCTION__); | |||
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[OptimizeSubGraph]: compute_graph is nullptr."); | |||
return GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL; | |||
} | |||
@@ -87,6 +89,7 @@ Status GraphOptimize::OptimizeSubGraph(ComputeGraphPtr &compute_graph, const std | |||
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | |||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | |||
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid when GraphOptimize %s", __FUNCTION__); | |||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GraphOptimzer: GE is not initialized"); | |||
return GE_CLI_GE_NOT_INITIALIZED; | |||
} | |||
@@ -105,6 +108,9 @@ Status GraphOptimize::OptimizeSubGraph(ComputeGraphPtr &compute_graph, const std | |||
for (auto iter = graph_optimizer.begin(); iter != graph_optimizer.end(); ++iter) { | |||
Status ret = (*iter)->OptimizeFusedGraphAfterGraphSlice(*(compute_graph)); | |||
if (ret != SUCCESS) { | |||
REPORT_INNER_ERROR("E19999", "Call OptimizeFusedGraphAfterGraphSlice failed, ret:%d, engine_name:%s, " | |||
"graph_name:%s when GraphOptimize %s", ret, engine_name.c_str(), | |||
compute_graph->GetName().c_str(), __FUNCTION__); | |||
GELOGE(ret, "[OptimizeSubGraph][OptimizeFusedGraphAfterGraphSlice]: graph optimize failed, ret:%d", ret); | |||
return ret; | |||
} | |||
@@ -115,6 +121,9 @@ Status GraphOptimize::OptimizeSubGraph(ComputeGraphPtr &compute_graph, const std | |||
for (auto iter = graph_optimizer.begin(); iter != graph_optimizer.end(); ++iter) { | |||
ret = (*iter)->OptimizeFusedGraph(*(compute_graph)); | |||
if (ret != SUCCESS) { | |||
REPORT_INNER_ERROR("E19999", "Call OptimizeFusedGraph failed, ret:%d, engine_name:%s, " | |||
"graph_name:%s when GraphOptimize %s", ret, engine_name.c_str(), | |||
compute_graph->GetName().c_str(), __FUNCTION__); | |||
GELOGE(ret, "[OptimizeSubGraph][OptimizeFusedGraph]: graph optimize failed, ret:%d", ret); | |||
return ret; | |||
} | |||
@@ -132,6 +141,7 @@ Status GraphOptimize::OptimizeOriginalGraph(ComputeGraphPtr &compute_graph) { | |||
return SUCCESS; | |||
} | |||
if (compute_graph == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid when GraphOptimize %s", __FUNCTION__); | |||
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[OptimizeOriginalGraph]: compute_graph is nullptr."); | |||
return GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL; | |||
} | |||
@@ -139,6 +149,7 @@ Status GraphOptimize::OptimizeOriginalGraph(ComputeGraphPtr &compute_graph) { | |||
Status ret = SUCCESS; | |||
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | |||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | |||
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid when GraphOptimize %s", __FUNCTION__); | |||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "OptimizeOriginalGraph failed."); | |||
return GE_CLI_GE_NOT_INITIALIZED; | |||
} | |||
@@ -155,6 +166,9 @@ Status GraphOptimize::OptimizeOriginalGraph(ComputeGraphPtr &compute_graph) { | |||
} | |||
ret = (iter->second)->OptimizeOriginalGraph(*compute_graph); | |||
if (ret != SUCCESS) { | |||
REPORT_INNER_ERROR("E19999", "Call OptimizeOriginalGraph failed, ret:%d, engine_name:%s, " | |||
"graph_name:%s when GraphOptimize %s", ret, iter->first.c_str(), | |||
compute_graph->GetName().c_str(), __FUNCTION__); | |||
GELOGE(ret, "[OptimizeOriginalGraph]: graph optimize failed, ret:%d", ret); | |||
return ret; | |||
} | |||
@@ -174,6 +188,7 @@ Status GraphOptimize::OptimizeOriginalGraphJudgeInsert(ComputeGraphPtr &compute_ | |||
Status ret = SUCCESS; | |||
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | |||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | |||
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid when GraphOptimize %s", __FUNCTION__); | |||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "OptimizeOriginalGraph failed."); | |||
return GE_CLI_GE_NOT_INITIALIZED; | |||
} | |||
@@ -191,6 +206,9 @@ Status GraphOptimize::OptimizeOriginalGraphJudgeInsert(ComputeGraphPtr &compute_ | |||
GELOGI("Begin to refine running format by engine %s", iter->first.c_str()); | |||
ret = (iter->second)->OptimizeOriginalGraphJudgeInsert(*compute_graph); | |||
if (ret != SUCCESS) { | |||
REPORT_INNER_ERROR("E19999", "Call OptimizeOriginalGraphJudgeInsert failed, ret:%d, engine_name:%s, " | |||
"graph_name:%s when GraphOptimize %s", ret, iter->first.c_str(), | |||
compute_graph->GetName().c_str(), __FUNCTION__); | |||
GELOGE(ret, "[OptimizeOriginalGraphJudgeInsert]: graph optimize failed, ret:%d", ret); | |||
return ret; | |||
} | |||
@@ -201,12 +219,14 @@ Status GraphOptimize::OptimizeOriginalGraphJudgeInsert(ComputeGraphPtr &compute_ | |||
Status GraphOptimize::OptimizeOriginalGraphForQuantize(ComputeGraphPtr &compute_graph) { | |||
if (compute_graph == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid when GraphOptimize %s", __FUNCTION__); | |||
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[OptimizeOriginalGraph]: compute_graph is nullptr."); | |||
return GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL; | |||
} | |||
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | |||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | |||
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid when GraphOptimize %s", __FUNCTION__); | |||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "OptimizeOriginalGraph failed."); | |||
return GE_CLI_GE_NOT_INITIALIZED; | |||
} | |||
@@ -224,6 +244,9 @@ Status GraphOptimize::OptimizeOriginalGraphForQuantize(ComputeGraphPtr &compute_ | |||
} | |||
ret = iter->second->OptimizeGraphPrepare(*compute_graph); | |||
if (ret != SUCCESS) { | |||
REPORT_INNER_ERROR("E19999", "Call OptimizeGraphPrepare failed, ret:%d, engine_name:%s, " | |||
"graph_name:%s when GraphOptimize %s", ret, iter->first.c_str(), | |||
compute_graph->GetName().c_str(), __FUNCTION__); | |||
GELOGE(ret, "[OptimizeOriginalGraphForQuantize]: graph optimize failed, ret:%u", ret); | |||
return ret; | |||
} | |||
@@ -234,12 +257,14 @@ Status GraphOptimize::OptimizeOriginalGraphForQuantize(ComputeGraphPtr &compute_ | |||
Status GraphOptimize::OptimizeGraphBeforeBuildForRts(ComputeGraphPtr &compute_graph) { | |||
if (compute_graph == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid when GraphOptimize %s", __FUNCTION__); | |||
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[OptimizeGraphBeforeBuildForRts]: compute_graph is nullptr."); | |||
return GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL; | |||
} | |||
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | |||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | |||
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid when GraphOptimize %s", __FUNCTION__); | |||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "OptimizeGraphBeforeBuildForRts failed."); | |||
return GE_CLI_GE_NOT_INITIALIZED; | |||
} | |||
@@ -258,6 +283,9 @@ Status GraphOptimize::OptimizeGraphBeforeBuildForRts(ComputeGraphPtr &compute_gr | |||
} | |||
ret = iter->second->OptimizeGraphBeforeBuild(*compute_graph); | |||
if (ret != SUCCESS) { | |||
REPORT_INNER_ERROR("E19999", "Call OptimizeGraphBeforeBuild failed, ret:%d, engine_name:%s, " | |||
"graph_name:%s when GraphOptimize %s", ret, iter->first.c_str(), | |||
compute_graph->GetName().c_str(), __FUNCTION__); | |||
GELOGE(ret, "[OptimizeGraphBeforeBuildForRts]: graph optimize failed, ret:%u", ret); | |||
return ret; | |||
} | |||
@@ -268,6 +296,8 @@ Status GraphOptimize::OptimizeGraphBeforeBuildForRts(ComputeGraphPtr &compute_gr | |||
Status GraphOptimize::SetOptions(const ge::GraphManagerOptions &options) { | |||
if (options.framework_type >= static_cast<int32_t>(domi::FrameworkType::FRAMEWORK_RESERVED)) { | |||
REPORT_INNER_ERROR("E19999", "Param framework_type:%d in option check invalid when GraphOptimize %s", | |||
options.framework_type, __FUNCTION__); | |||
GELOGE(GE_GRAPH_OPTIONS_INVALID, "Optimize Type %d invalid.", options.framework_type); | |||
return GE_GRAPH_OPTIONS_INVALID; | |||
} | |||
@@ -342,12 +372,14 @@ Status GraphOptimize::IdentifyReference(ComputeGraphPtr &compute_graph) { | |||
} | |||
Status GraphOptimize::OptimizeWholeGraph(ComputeGraphPtr &compute_graph) { | |||
if (compute_graph == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid when GraphOptimize %s", __FUNCTION__); | |||
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[OptimizeWholeGraph]: compute_graph is nullptr."); | |||
return GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL; | |||
} | |||
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | |||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | |||
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid when GraphOptimize %s", __FUNCTION__); | |||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "OptimizeWholeGraph failed."); | |||
return GE_CLI_GE_NOT_INITIALIZED; | |||
} | |||
@@ -366,6 +398,9 @@ Status GraphOptimize::OptimizeWholeGraph(ComputeGraphPtr &compute_graph) { | |||
ret = iter.second->OptimizeWholeGraph(*compute_graph); | |||
GE_DUMP(compute_graph, "OptimizeWholeGraph" + iter.first); | |||
if (ret != SUCCESS) { | |||
REPORT_INNER_ERROR("E19999", "Call OptimizeWholeGraph failed, ret:%d, engine_name:%s, " | |||
"graph_name:%s when GraphOptimize %s", ret, iter.first.c_str(), | |||
compute_graph->GetName().c_str(), __FUNCTION__); | |||
GELOGE(ret, "[OptimizeWholeGraph]: graph optimize failed, ret:%u", ret); | |||
return ret; | |||
} | |||
@@ -26,12 +26,14 @@ const size_t kInputSizeSingle = 1; | |||
Status AddNPass::Run(NodePtr &node) { | |||
GELOGD("AddNPass running"); | |||
if (node == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid when AddNPass %s", __FUNCTION__); | |||
GELOGE(PARAM_INVALID, "param [node] must not be null."); | |||
return PARAM_INVALID; | |||
} | |||
if (node->GetType() == ADDN) { | |||
if (node->GetOpDesc() == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Param op_desc of node is nullptr, check invalid when AddNPass %s", __FUNCTION__); | |||
GELOGE(PARAM_INVALID, "Param [node] op desc is null."); | |||
return PARAM_INVALID; | |||
} | |||
@@ -122,6 +122,8 @@ bool AicpuConstantFoldingPass::CheckInput(const NodePtr &node, vector<ConstGeTen | |||
Status AicpuConstantFoldingPass::GetInputAddrs(const vector<ConstGeTensorPtr> &weight_vec, | |||
vector<AddrAndType> &input_addrs) { | |||
if (weight_vec.empty()) { | |||
REPORT_INNER_ERROR("E19999", "Param weight_vec is empty, check invalid when AicpuConstantFoldingPass :%s", | |||
__FUNCTION__); | |||
GELOGE(FAILED, "Weight is null"); | |||
return FAILED; | |||
} | |||
@@ -132,6 +134,8 @@ Status AicpuConstantFoldingPass::GetInputAddrs(const vector<ConstGeTensorPtr> &w | |||
rtError_t rt_ret = rtMemcpy(input_addr, weight->GetData().size(), weight->GetData().data(), | |||
weight->GetData().size(), RT_MEMCPY_HOST_TO_DEVICE); | |||
if (rt_ret != RT_ERROR_NONE) { | |||
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, size:%zu, ret = 0x%X, when AicpuConstantFoldingPass %s", | |||
weight->GetData().size(), rt_ret, __FUNCTION__); | |||
GELOGE(rt_ret, "rtMemcpy error"); | |||
GE_CHK_RT(rtFree(input_addr)); | |||
return FAILED; | |||
@@ -145,6 +149,8 @@ Status AicpuConstantFoldingPass::GetInputAddrs(const vector<ConstGeTensorPtr> &w | |||
Status AicpuConstantFoldingPass::GetOutputAddrs(const OpDescPtr &node_desc, vector<uint64_t> &output_addrs) { | |||
if (node_desc->GetOutputsSize() == 0) { | |||
REPORT_INNER_ERROR("E19999", "Ouput desc size of op:%s(%s) is 0, check invalid when AicpuConstantFoldingPass :%s", | |||
node_desc->GetName().c_str(), node_desc->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Output size is 0 "); | |||
return FAILED; | |||
} | |||
@@ -171,6 +177,8 @@ Status AicpuConstantFoldingPass::GenerateDataPtrInfo(const vector<uint64_t> &out | |||
if (result_summary.shape_data_size != 0) { | |||
rtError_t rt_ret = rtMalloc(&shape_data_addr, result_summary.shape_data_size, RT_MEMORY_HBM); | |||
if (rt_ret != RT_ERROR_NONE) { | |||
REPORT_CALL_ERROR("E19999", "Call rtMalloc failed, size:%lu, ret = 0x%X, when AicpuConstantFoldingPass %s", | |||
result_summary.shape_data_size, rt_ret, __FUNCTION__); | |||
GELOGE(rt_ret, "rtMalloc error"); | |||
GE_CHK_RT(rtFree(raw_data_addr)); | |||
return FAILED; | |||
@@ -200,6 +208,8 @@ Status AicpuConstantFoldingPass::GenerateDataPtrInfo(const vector<uint64_t> &out | |||
Status AicpuConstantFoldingPass::UpdateWorkSpaceAddr(string &task_info, STR_FWK_OP_KERNEL &task) { | |||
// Update the workspace_addr | |||
if (task_info.empty()) { | |||
REPORT_INNER_ERROR("E19999", "Param task_info is empty, check invalid when AicpuConstantFoldingPass :%s", | |||
__FUNCTION__); | |||
GELOGE(FAILED, "task_info is empty "); | |||
return FAILED; | |||
} | |||
@@ -208,6 +218,8 @@ Status AicpuConstantFoldingPass::UpdateWorkSpaceAddr(string &task_info, STR_FWK_ | |||
rtError_t rt_ret = | |||
rtMemcpy(workspace_addr, task_info.size(), task_info.data(), task_info.size(), RT_MEMCPY_HOST_TO_DEVICE); | |||
if (rt_ret != RT_ERROR_NONE) { | |||
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, size:%zu, ret = 0x%X, when AicpuConstantFoldingPass %s", | |||
task_info.size(), rt_ret, __FUNCTION__); | |||
GELOGE(rt_ret, "rtMemcpy error"); | |||
GE_CHK_RT(rtFree(workspace_addr)); | |||
return FAILED; | |||
@@ -221,6 +233,8 @@ Status AicpuConstantFoldingPass::UpdateWorkSpaceAddr(string &task_info, STR_FWK_ | |||
Status AicpuConstantFoldingPass::UpdateInputAndOutputAddr(const vector<uint64_t> &io_addrs, STR_FWK_OP_KERNEL &task) { | |||
auto addrs_size = sizeof(uint64_t) * (io_addrs.size()); | |||
if (addrs_size <= 0) { | |||
REPORT_INNER_ERROR("E19999", "Param io_addrs size is 0, check invalid when AicpuConstantFoldingPass :%s", | |||
__FUNCTION__); | |||
GELOGE(FAILED, "addrs_size is less than 1 "); | |||
return FAILED; | |||
} | |||
@@ -228,6 +242,8 @@ Status AicpuConstantFoldingPass::UpdateInputAndOutputAddr(const vector<uint64_t> | |||
GE_CHK_RT_RET(rtMalloc(&input_output_addr, addrs_size, RT_MEMORY_HBM)); | |||
rtError_t rt_ret = rtMemcpy(input_output_addr, addrs_size, io_addrs.data(), addrs_size, RT_MEMCPY_HOST_TO_DEVICE); | |||
if (rt_ret != RT_ERROR_NONE) { | |||
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, size:%zu, ret = 0x%X, when AicpuConstantFoldingPass %s", | |||
addrs_size, rt_ret, __FUNCTION__); | |||
GELOGE(rt_ret, "rtMemcpy error"); | |||
GE_CHK_RT(rtFree(input_output_addr)); | |||
return FAILED; | |||
@@ -284,6 +300,8 @@ Status AicpuConstantFoldingPass::UpdateMemCopyAddr(string &task_info, const vect | |||
GE_CHK_RT_RET(rtMalloc(&input_addr_ptr, data_size, RT_MEMORY_HBM)); | |||
rtError_t rt_ret = rtMemcpy(input_addr_ptr, data_size, item.data(), data_size, RT_MEMCPY_HOST_TO_DEVICE); | |||
if (rt_ret != RT_ERROR_NONE) { | |||
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, size:%zu, ret = 0x%X, when AicpuConstantFoldingPass %s", | |||
data_size, rt_ret, __FUNCTION__); | |||
GELOGE(rt_ret, "rtMemcpy error"); | |||
GE_CHK_RT(rtFree(input_addr_ptr)); | |||
return FAILED; | |||
@@ -312,11 +330,15 @@ Status AicpuConstantFoldingPass::LaunchSingleOpRunTask(const NodePtr &node, cons | |||
void *task_buf = nullptr; | |||
auto instance_ptr = ge::GELib::GetInstance(); | |||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | |||
REPORT_INNER_ERROR("E19999", "GeLib is not init before, check invalid when AicpuConstantFoldingPass %s", | |||
__FUNCTION__); | |||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized"); | |||
return GE_CLI_GE_NOT_INITIALIZED; | |||
} | |||
auto kernel_builder = OpsKernelBuilderManager::Instance().GetOpsKernelBuilder(kKernelLibName); | |||
if (kernel_builder == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Find ops kernel by name:%s failed, when AicpuConstantFoldingPass %s", | |||
kKernelLibName, __FUNCTION__); | |||
GELOGE(FAILED, "Get op kernel info store failed"); | |||
return FAILED; | |||
} | |||
@@ -367,11 +389,15 @@ Status AicpuConstantFoldingPass::LaunchMemCopyTask(const vector<uint64_t> &data_ | |||
void *task_buf = nullptr; | |||
auto instance_ptr = ge::GELib::GetInstance(); | |||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | |||
REPORT_INNER_ERROR("E19999", "GeLib is not init before, check invalid when AicpuConstantFoldingPass %s", | |||
__FUNCTION__); | |||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized"); | |||
return GE_CLI_GE_NOT_INITIALIZED; | |||
} | |||
auto kernel_builder = OpsKernelBuilderManager::Instance().GetOpsKernelBuilder(kKernelLibName); | |||
if (kernel_builder == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Find ops kernel by name:%s failed, when AicpuConstantFoldingPass %s", | |||
kKernelLibName, __FUNCTION__); | |||
GELOGE(FAILED, "Get op kernel info store failed"); | |||
return FAILED; | |||
} | |||
@@ -428,6 +454,8 @@ Status AicpuConstantFoldingPass::GenerateTaskForLaunch(STR_FWK_OP_KERNEL &aicpu_ | |||
rtError_t rt_ret = rtMemcpy(task_buf, sizeof(STR_FWK_OP_KERNEL), reinterpret_cast<void *>(&aicpu_task), | |||
sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE); | |||
if (rt_ret != RT_ERROR_NONE) { | |||
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, size:%zu, ret = 0x%X, when AicpuConstantFoldingPass %s", | |||
sizeof(STR_FWK_OP_KERNEL), rt_ret, __FUNCTION__); | |||
GELOGE(rt_ret, "rtMemcpy error"); | |||
GE_CHK_RT(rtFree(task_buf)); | |||
return FAILED; | |||
@@ -457,41 +485,57 @@ Status AicpuConstantFoldingPass::KernelLaunch(void *task_buf) { | |||
rtError_t rt_ret = rtModelCreate(&model, 0); | |||
if (rt_ret != RT_ERROR_NONE) { | |||
REPORT_CALL_ERROR("E19999", "Call rtModelCreate failed, ret = 0x%X, when AicpuConstantFoldingPass %s", | |||
rt_ret, __FUNCTION__); | |||
GELOGE(rt_ret, "create model failed."); | |||
return FAILED; | |||
} | |||
rt_ret = rtStreamCreate(&stream, 0); | |||
if (rt_ret != RT_ERROR_NONE) { | |||
REPORT_CALL_ERROR("E19999", "Call rtStreamCreate failed, ret = 0x%X, when AicpuConstantFoldingPass %s", | |||
rt_ret, __FUNCTION__); | |||
GELOGE(rt_ret, "create stream failed."); | |||
return FAILED; | |||
} | |||
rt_ret = rtModelBindStream(model, stream, 0); | |||
if (rt_ret != RT_ERROR_NONE) { | |||
REPORT_CALL_ERROR("E19999", "Call rtModelBindStream failed, ret = 0x%X, when AicpuConstantFoldingPass %s", | |||
rt_ret, __FUNCTION__); | |||
GELOGE(rt_ret, "rtModelBindStream failed."); | |||
return FAILED; | |||
} | |||
rt_ret = rtKernelLaunchEx(task_buf, sizeof(STR_FWK_OP_KERNEL), 0, stream); | |||
if (rt_ret != RT_ERROR_NONE) { | |||
REPORT_CALL_ERROR("E19999", "Call rtModelBindStream failed, ret = 0x%X, when AicpuConstantFoldingPass %s", | |||
rt_ret, __FUNCTION__); | |||
GELOGE(rt_ret, "rtKernelLaunchEx failed."); | |||
return FAILED; | |||
} | |||
rt_ret = rtModelLoadComplete(model); | |||
if (rt_ret != RT_ERROR_NONE) { | |||
REPORT_CALL_ERROR("E19999", "Call rtModelLoadComplete failed, ret = 0x%X, when AicpuConstantFoldingPass %s", | |||
rt_ret, __FUNCTION__); | |||
GELOGE(rt_ret, "rtModelLoadComplete failed."); | |||
return FAILED; | |||
} | |||
rt_ret = rtStreamCreate(&stream_run, 0); | |||
if (rt_ret != RT_ERROR_NONE) { | |||
REPORT_CALL_ERROR("E19999", "Call rtStreamCreate failed, ret = 0x%X, when AicpuConstantFoldingPass %s", | |||
rt_ret, __FUNCTION__); | |||
GELOGE(rt_ret, "create run stream failed."); | |||
return FAILED; | |||
} | |||
rt_ret = rtModelExecute(model, stream_run, 0); | |||
if (rt_ret != RT_ERROR_NONE) { | |||
REPORT_CALL_ERROR("E19999", "Call rtModelExecute failed, ret = 0x%X, when AicpuConstantFoldingPass %s", | |||
rt_ret, __FUNCTION__); | |||
GELOGE(rt_ret, "rtModelExecute failed."); | |||
return FAILED; | |||
} | |||
rt_ret = rtStreamSynchronize(stream_run); | |||
if (rt_ret != RT_ERROR_NONE) { | |||
REPORT_CALL_ERROR("E19999", "Call rtStreamSynchronize failed, ret = 0x%X, when AicpuConstantFoldingPass %s", | |||
rt_ret, __FUNCTION__); | |||
GELOGE(rt_ret, "rtStreamSynchronize failed."); | |||
return FAILED; | |||
} | |||
@@ -501,6 +545,9 @@ Status AicpuConstantFoldingPass::KernelLaunch(void *task_buf) { | |||
Status AicpuConstantFoldingPass::GenerateGeTensor(const OpDescPtr &node_desc, const vector<DataPtrInfo> &data_vec, | |||
vector<GeTensorPtr> &outputs) { | |||
if ((node_desc->GetOutputsSize() * kDouble) != data_vec.size()) { | |||
REPORT_INNER_ERROR("E19999", "Output desc size:%zu of op:%s(%s), after multi 2, not equal to data_vec.size:%zu, " | |||
"check invalid when AicpuConstantFoldingPass %s", node_desc->GetOutputsSize(), | |||
node_desc->GetName().c_str(), node_desc->GetType().c_str(), data_vec.size(), __FUNCTION__); | |||
GELOGE(FAILED, "node[%s] something wrong with output size", node_desc->GetName().c_str()); | |||
return FAILED; | |||
} | |||
@@ -509,6 +556,7 @@ Status AicpuConstantFoldingPass::GenerateGeTensor(const OpDescPtr &node_desc, co | |||
auto output_tensor_desc = node_desc->GetOutputDesc(static_cast<uint32_t>(i)); | |||
GeTensorPtr output_ptr = MakeShared<GeTensor>(output_tensor_desc); | |||
if (output_ptr == nullptr) { | |||
REPORT_CALL_ERROR("E19999", "New GeTensor failed when AicpuConstantFoldingPass %s", __FUNCTION__); | |||
GELOGE(FAILED, "node[%s] something wrong with construct GeTensor", node_desc->GetName().c_str()); | |||
return FAILED; | |||
} | |||
@@ -516,6 +564,8 @@ Status AicpuConstantFoldingPass::GenerateGeTensor(const OpDescPtr &node_desc, co | |||
uint64_t raw_data_size = raw_data_info.data_size; | |||
std::unique_ptr<uint8_t[]> data_addr(new (std::nothrow) uint8_t[raw_data_size]()); | |||
if (data_addr == nullptr) { | |||
REPORT_CALL_ERROR("E19999", "New Buffer failed, size:%lu, when AicpuConstantFoldingPass %s", | |||
raw_data_size, __FUNCTION__); | |||
GELOGE(MEMALLOC_FAILED, "new data_addr failed"); | |||
return INTERNAL_ERROR; | |||
} | |||
@@ -539,6 +589,8 @@ Status AicpuConstantFoldingPass::GenerateGeTensor(const OpDescPtr &node_desc, co | |||
uint64_t dim_num = shape_data_size / sizeof(uint64_t); | |||
std::unique_ptr<int64_t[]> shape_addr(new (std::nothrow) int64_t[dim_num]()); | |||
if (shape_addr == nullptr) { | |||
REPORT_CALL_ERROR("E19999", "New Buffer failed, size:%lu, when AicpuConstantFoldingPass %s", | |||
dim_num, __FUNCTION__); | |||
GELOGE(MEMALLOC_FAILED, "new shape_addr failed"); | |||
return INTERNAL_ERROR; | |||
} | |||
@@ -584,17 +636,24 @@ bool AicpuConstantFoldingPass::IsSkipFold(const ge::NodePtr &node) { | |||
} | |||
auto instance_ptr = ge::GELib::GetInstance(); | |||
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | |||
REPORT_INNER_ERROR("E19999", "GeLib is not init before, check invalid when AicpuConstantFoldingPass %s", | |||
__FUNCTION__); | |||
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized"); | |||
return true; | |||
} | |||
OpsKernelInfoStorePtr kernel_info = instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(kKernelLibName); | |||
if (kernel_info == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Find ops kernel by name:%s failed, when AicpuConstantFoldingPass %s", | |||
kKernelLibName, __FUNCTION__); | |||
GELOGE(FAILED, "Get op kernel info store failed"); | |||
return true; | |||
} | |||
std::string check_result; | |||
kernel_info->opsFlagCheck(*node, check_result); | |||
if (check_result.empty()) { | |||
REPORT_CALL_ERROR("E19999", "Call opsFlagCheck faled, ops kernel name:%s, op:%s(%s), " | |||
"when AicpuConstantFoldingPass %s", kKernelLibName, | |||
node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Get op check_result failed"); | |||
return true; | |||
} | |||
@@ -30,10 +30,12 @@ namespace ge { | |||
Status AssertPass::Run(NodePtr &node) { | |||
GELOGD("AssertPass running"); | |||
if (node == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid when AssertPass %s", __FUNCTION__); | |||
GELOGE(PARAM_INVALID, "param [node] must not be null."); | |||
return PARAM_INVALID; | |||
} | |||
if (node->GetOpDesc() == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Param op_desc of node is nullptr, check invalid when AssertPass %s", __FUNCTION__); | |||
GELOGE(PARAM_INVALID, "param [node] [opDesc] must not be null."); | |||
return PARAM_INVALID; | |||
} | |||
@@ -93,6 +95,8 @@ Status AssertPass::RemoveUnusedNode(std::vector<NodePtr> &nodes_unused) { | |||
} | |||
if (IsolateAndDeleteNode(node, assert_io_map) != SUCCESS) { | |||
REPORT_INNER_ERROR("E19999", "Isolate and delete node:%s(%s) faild when AssertPass %s", | |||
node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__); | |||
return FAILED; | |||
} | |||
} | |||
@@ -57,12 +57,18 @@ Status AssignRemovePass::OptimizedAssignNode(NodePtr &assign_node) { | |||
const auto &ref_in_anchor = assign_node->GetInDataAnchor(kAssignRefInputIndex); | |||
const auto &value_in_anchor = assign_node->GetInDataAnchor(kAssignValueInputIndex); | |||
if ((ref_in_anchor == nullptr) || (value_in_anchor == nullptr)) { | |||
REPORT_INNER_ERROR("E19999", "Index %d or %d input anchor of node:%s(%s) is nullptr, check invalid " | |||
"when AssignRemovePass %s", kAssignRefInputIndex, kAssignValueInputIndex, | |||
assign_node->GetName().c_str(), assign_node->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "In data anchor is null, node:%s", assign_node->GetName().c_str()); | |||
return FAILED; | |||
} | |||
const auto &ref_peer_anchor = ref_in_anchor->GetPeerOutAnchor(); | |||
const auto &value_peer_anchor = value_in_anchor->GetPeerOutAnchor(); | |||
if ((ref_peer_anchor == nullptr) || (value_peer_anchor == nullptr)) { | |||
REPORT_INNER_ERROR("E19999", "Index %d or %d input anchor of node:%s(%s), peer anchor is nullptr, check invalid " | |||
"when AssignRemovePass %s", kAssignRefInputIndex, kAssignValueInputIndex, | |||
assign_node->GetName().c_str(), assign_node->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Peer data anchor is null, node:%s", assign_node->GetName().c_str()); | |||
return FAILED; | |||
} | |||
@@ -79,6 +85,8 @@ Status AssignRemovePass::OptimizedAssignNode(NodePtr &assign_node) { | |||
/// | |||
GELOGD("Optimization for assign_node %s start", assign_node->GetName().c_str()); | |||
if (IsolateAndDeleteNode(assign_node, {kAssignRefInputIndex}) != SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed when AssignRemovePass %s", | |||
assign_node->GetName().c_str(), assign_node->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Isolate and delete assign_node %s failed.", assign_node->GetName().c_str()); | |||
return FAILED; | |||
} | |||
@@ -86,16 +94,27 @@ Status AssignRemovePass::OptimizedAssignNode(NodePtr &assign_node) { | |||
const auto &ref_input = ref_peer_anchor->GetOwnerNode()->GetOpDesc(); | |||
const auto &value_input = value_peer_anchor->GetOwnerNode()->GetOpDesc(); | |||
if ((ref_input == nullptr) || (value_input == nullptr)) { | |||
REPORT_INNER_ERROR("E19999", "Input index %d or %d of node:%s(%s), peer op is nullptr, check invalid " | |||
"when AssignRemovePass %s", kAssignRefInputIndex, kAssignValueInputIndex, | |||
assign_node->GetName().c_str(), assign_node->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "value input is null"); | |||
return FAILED; | |||
} | |||
// variable has and only has one input | |||
if (ref_input->UpdateInputDesc(0, value_input->GetOutputDesc(value_peer_anchor->GetIdx())) != GRAPH_SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Input index %d of node:%s(%s), update it's peer op input:0 desc failed " | |||
"when AssignRemovePass %s", kAssignRefInputIndex, | |||
assign_node->GetName().c_str(), assign_node->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Update input_desc for variable %s failed.", ref_input->GetName().c_str()); | |||
return FAILED; | |||
} | |||
if (GraphUtils::AddEdge(value_peer_anchor, ref_peer_anchor->GetOwnerNode()->GetInDataAnchor(0)) != GRAPH_SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(out_index:%d) and op:%s(%s)(in_index:0) failed " | |||
"when AssignRemovePass %s", value_peer_anchor->GetOwnerNode()->GetName().c_str(), | |||
value_peer_anchor->GetOwnerNode()->GetType().c_str(), value_peer_anchor->GetIdx(), | |||
ref_peer_anchor->GetOwnerNode()->GetName().c_str(), | |||
ref_peer_anchor->GetOwnerNode()->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Add data edge %s->%s failed", value_input->GetName().c_str(), ref_input->GetName().c_str()); | |||
return FAILED; | |||
} | |||
@@ -104,6 +123,9 @@ Status AssignRemovePass::OptimizedAssignNode(NodePtr &assign_node) { | |||
value_input->GetName().c_str(), ref_input->GetName().c_str()); | |||
if (!AttrUtils::SetStr(value_input->MutableOutputDesc(value_peer_anchor->GetIdx()), ASSIGN_VAR_NAME, | |||
ref_input->GetName())) { | |||
REPORT_CALL_ERROR("E19999", "Set Attr:%s to output:%d desc of node:%s(%s) failed when %s", | |||
ASSIGN_VAR_NAME.c_str(), value_peer_anchor->GetIdx(), | |||
value_input->GetName().c_str(), value_input->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Set attr ASSIGN_VAR_NAME failed."); | |||
return FAILED; | |||
} | |||
@@ -136,6 +158,9 @@ Status AssignRemovePass::TransformAttr(NodePtr &node) { | |||
GELOGD("add attr ASSIGN_VAR_NAME on node %s, var_name=%s", in_node->GetName().c_str(), assign_var_name.c_str()); | |||
if (!AttrUtils::SetStr(in_node->GetOpDesc()->MutableOutputDesc(peer_data_anchor->GetIdx()), | |||
ASSIGN_VAR_NAME, assign_var_name)) { | |||
REPORT_CALL_ERROR("E19999", "Set Attr:%s to output:%d desc of node:%s(%s) failed when %s", | |||
ASSIGN_VAR_NAME.c_str(), peer_data_anchor->GetIdx(), | |||
in_node->GetName().c_str(), in_node->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Set attr ASSIGN_VAR_NAME failed."); | |||
return FAILED; | |||
} | |||
@@ -93,7 +93,7 @@ bool AtomicAddrCleanPass::CheckAtomicFromOpsKernel(const NodePtr &node) { | |||
in_data_anchor->GetPeerOutAnchor()->GetOwnerNode() != nullptr) { | |||
auto peer_in_node = in_data_anchor->GetPeerOutAnchor()->GetOwnerNode(); | |||
if (peer_in_node->GetType() == DATA) { | |||
GELOGI("Recognized atomic op %s from %s engine and input is DATA.", node->GetName().c_str(), | |||
GELOGI("Recognized atomic op %s from %s engine and input is DATA.", node->GetName().c_str(), | |||
op_info.engine.c_str()); | |||
return false; | |||
} | |||
@@ -266,6 +266,7 @@ Status AtomicAddrCleanPass::HandleDispersedAtomicNodes(ComputeGraphPtr &graph, | |||
NodePtr AtomicAddrCleanPass::InsertAtomicAddrCleanNode(ComputeGraphPtr &graph) { | |||
OpDescPtr op_desc = MakeShared<OpDesc>(NODE_NAME_ATOMIC_ADDR_CLEAN, ATOMICADDRCLEAN); | |||
if (op_desc == nullptr) { | |||
REPORT_CALL_ERROR("E19999", "New OpDesc failed when AtomicAddrCleanPass %s", __FUNCTION__); | |||
GELOGE(INTERNAL_ERROR, "Make shared atomic addr clean op failed."); | |||
return nullptr; | |||
} | |||
@@ -292,10 +293,17 @@ NodePtr AtomicAddrCleanPass::InsertAtomicAddrCleanNode(ComputeGraphPtr &graph) { | |||
Status AtomicAddrCleanPass::LinkToAtomicNode(const NodePtr &atomic_node, NodePtr &atomic_clean_node) { | |||
GE_IF_BOOL_EXEC(atomic_node == nullptr || atomic_clean_node == nullptr, | |||
DOMI_LOGE("param [atomic_node][atomic_clean_node] must not be null."); return PARAM_INVALID); | |||
REPORT_INNER_ERROR("E19999", "Param atomic_node or atomic_clean_node is nullptr, " | |||
"check invalid when AtomicAddrCleanPass %s", __FUNCTION__); | |||
DOMI_LOGE("param [atomic_node][atomic_clean_node] must not be null."); | |||
return PARAM_INVALID); | |||
InControlAnchorPtr in_ctrl_anchor = atomic_node->GetInControlAnchor(); | |||
OutControlAnchorPtr out_ctrl_anchor = atomic_clean_node->GetOutControlAnchor(); | |||
if (in_ctrl_anchor == nullptr || out_ctrl_anchor == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "in_ctrl_anchor of op:%s(%s) or out_ctrl_anchor of op:%s(%s) is nullptr, " | |||
"check invalid when AtomicAddrCleanPass %s", | |||
atomic_node->GetName().c_str(), atomic_node->GetType().c_str(), | |||
atomic_clean_node->GetName().c_str(), atomic_clean_node->GetType().c_str(), __FUNCTION__); | |||
GELOGE(INTERNAL_ERROR, | |||
"Get control anchor faild, dst node: %s.", | |||
atomic_node->GetName().c_str()); | |||
@@ -304,6 +312,11 @@ Status AtomicAddrCleanPass::LinkToAtomicNode(const NodePtr &atomic_node, NodePtr | |||
graphStatus status = GraphUtils::AddEdge(out_ctrl_anchor, in_ctrl_anchor); | |||
if (status != GRAPH_SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(out_index:%d) and op:%s(%s)(in_index:%d) failed " | |||
"when AssignRemovePass %s", out_ctrl_anchor->GetOwnerNode()->GetName().c_str(), | |||
out_ctrl_anchor->GetOwnerNode()->GetType().c_str(), out_ctrl_anchor->GetIdx(), | |||
in_ctrl_anchor->GetOwnerNode()->GetName().c_str(), | |||
in_ctrl_anchor->GetOwnerNode()->GetType().c_str(), in_ctrl_anchor->GetIdx(), __FUNCTION__); | |||
GELOGE(INTERNAL_ERROR, | |||
"Graph add cleanAddrNode op out ctrl edge fail, dst node: %s.", | |||
atomic_node->GetName().c_str()); | |||
@@ -361,6 +374,8 @@ Status AtomicAddrCleanPass::CompileUnknownGraphOp(const vector<NodePtr> &atomic_ | |||
std::unordered_map<string, vector<ge::NodePtr>> node_vector_map; | |||
std::shared_ptr<GELib> instance = ge::GELib::GetInstance(); | |||
if ((instance == nullptr) || !instance->InitFlag()) { | |||
REPORT_INNER_ERROR("E19999", "GeLib is not init before, check invalid when AtomicAddrCleanPass %s", | |||
__FUNCTION__); | |||
GELOGE(ge::GE_CLI_GE_NOT_INITIALIZED, "CompileSingleOp failed."); | |||
return ge::GE_CLI_GE_NOT_INITIALIZED; | |||
} | |||
@@ -373,6 +388,8 @@ Status AtomicAddrCleanPass::CompileUnknownGraphOp(const vector<NodePtr> &atomic_ | |||
} | |||
string kernel_lib_name = op_desc->GetOpKernelLibName(); | |||
if (kernel_lib_name.empty()) { | |||
REPORT_INNER_ERROR("E19999", "Find ops kernel by name:%s failed, when AtomicAddrCleanPass %s", | |||
kernel_lib_name.c_str(), __FUNCTION__); | |||
GELOGE(ge::INTERNAL_ERROR, "Get atomic node:%s(%s) kernel lib failed.", atomic_node->GetName().c_str(), | |||
atomic_node->GetType().c_str()); | |||
return ge::INTERNAL_ERROR; | |||
@@ -393,6 +410,8 @@ Status AtomicAddrCleanPass::CompileUnknownGraphOp(const vector<NodePtr> &atomic_ | |||
GELOGI("The atomic node size of compile op of %s is %zu", kernel_lib_name.c_str(), node_vector.size()); | |||
GE_TIMESTAMP_ADD(UnknownGraphCompileOp); | |||
if (ret != ge::SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Call CompileOp failed, kernel_lib_name:%s, ret:%d, when AtomicAddrCleanPass %s", | |||
kernel_lib_name.c_str(), ret, __FUNCTION__); | |||
GELOGE(ret, "Compile atomic op failed, kernel lib name is %s", kernel_lib_name.c_str()); | |||
return ret; | |||
} | |||
@@ -117,7 +117,13 @@ Status AttachStreamLabelPass::UpdateCondBranch(const NodePtr &node) { | |||
for (const NodePtr &tmp_node : branch_nodes) { | |||
GELOGD("Attach label %s to node: %s.", stream_label.c_str(), tmp_node->GetName().c_str()); | |||
GE_CHK_STATUS_RET(SetStreamLabel(tmp_node, stream_label), "Set stream label failed."); | |||
auto status = SetStreamLabel(tmp_node, stream_label); | |||
if (status != ge::SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed when AttachStreamLabelPass %s", | |||
stream_label.c_str(), tmp_node->GetName().c_str(), tmp_node->GetType().c_str(), __FUNCTION__); | |||
GELOGE(status, "Set stream label failed."); | |||
return status; | |||
} | |||
} | |||
return SUCCESS; | |||
@@ -133,6 +139,8 @@ Status AttachStreamLabelPass::AttachFlag(const NodePtr &node, std::string &strea | |||
const std::string &type = node->GetType(); | |||
if (type == STREAMSWITCH) { | |||
if (node->GetInDataNodes().empty()) { | |||
REPORT_INNER_ERROR("E19999", "In data nodes is empty of op:%s(%s), check invalid when AttachStreamLabelPass %s", | |||
node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__); | |||
GELOGE(INTERNAL_ERROR, "node %s has no input_data_node.", node->GetName().c_str()); | |||
return INTERNAL_ERROR; | |||
} | |||
@@ -140,13 +148,29 @@ Status AttachStreamLabelPass::AttachFlag(const NodePtr &node, std::string &strea | |||
bool value = false; | |||
OpDescPtr op_desc = node->GetOpDesc(); | |||
GE_CHECK_NOTNULL(op_desc); | |||
GE_CHK_BOOL_EXEC(AttrUtils::GetBool(op_desc, ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG, value), return FAILED, | |||
GE_CHK_BOOL_EXEC(AttrUtils::GetBool(op_desc, ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG, value), | |||
REPORT_CALL_ERROR("E19999", "Get Attr:%s of op:%s(%s) failed when AttachStreamLabelPass %s", | |||
ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG.c_str(), | |||
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__); | |||
return FAILED, | |||
"StreamSwitch get attr TRUE_BRANCH_STREAM failed."); | |||
stream_label += (value ? "_t" : "_f"); | |||
GE_CHK_STATUS_RET(SetActiveLabelList(node, {stream_label}), "set active_label_list failed."); | |||
auto status = SetActiveLabelList(node, {stream_label}); | |||
if (status != ge::SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Set active label list:%s to op:%s(%s) failed when AttachStreamLabelPass %s", | |||
stream_label.c_str(), node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__); | |||
GELOGE(status, "set active_label_list failed."); | |||
return status; | |||
} | |||
} else if (type == STREAMMERGE) { | |||
stream_label = node->GetName(); | |||
GE_CHK_STATUS_RET(SetStreamLabel(node, stream_label), "Set stream label failed."); | |||
auto status = SetStreamLabel(node, stream_label); | |||
if (status != ge::SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed when AttachStreamLabelPass %s", | |||
stream_label.c_str(), node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__); | |||
GELOGE(status, "Set stream label failed."); | |||
return status; | |||
} | |||
} | |||
return SUCCESS; | |||
@@ -183,6 +207,9 @@ Status AttachStreamLabelPass::UpdateEnterNode() { | |||
bool get_attr = AttrUtils::GetListStr(active_node->GetOpDesc(), ATTR_NAME_ACTIVE_LABEL_LIST, active_label_list) && | |||
(active_label_list.size() == 1) && !active_label_list[0].empty(); | |||
if (!get_attr) { | |||
REPORT_CALL_ERROR("E19999", "Get Attr:%s of op:%s(%s) failed when AttachStreamLabelPass %s", | |||
ATTR_NAME_ACTIVE_LABEL_LIST.c_str(), | |||
active_node->GetName().c_str(), active_node->GetType().c_str(), __FUNCTION__); | |||
GELOGE(INTERNAL_ERROR, "Get attr ATTR_NAME_ACTIVE_LABEL_LIST failed, node: %s.", active_node->GetName().c_str()); | |||
return INTERNAL_ERROR; | |||
} | |||
@@ -216,7 +243,14 @@ Status AttachStreamLabelPass::SetEnterLabel(const std::vector<NodePtr> &enter_no | |||
} | |||
for (const auto &enter_node : enter_nodes) { | |||
GE_CHK_STATUS_RET(SetStreamLabel(enter_node, stream_label), "Set stream label failed."); | |||
auto status = SetStreamLabel(enter_node, stream_label); | |||
if (status != ge::SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed when AttachStreamLabelPass %s", | |||
stream_label.c_str(), enter_node->GetName().c_str(), enter_node->GetType().c_str(), | |||
__FUNCTION__); | |||
GELOGE(status, "Set stream label failed."); | |||
return status; | |||
} | |||
} | |||
return SUCCESS; | |||
} | |||
@@ -245,7 +279,14 @@ Status AttachStreamLabelPass::UpdateLoopBranch(const std::stack<NodePtr> &enter_ | |||
continue; | |||
} | |||
GELOGD("Attach label %s to node: %s.", stream_label.c_str(), out_node->GetName().c_str()); | |||
GE_CHK_STATUS_RET(SetStreamLabel(out_node, stream_label), "Set stream label failed."); | |||
auto status = SetStreamLabel(out_node, stream_label); | |||
if (status != ge::SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed when AttachStreamLabelPass %s", | |||
stream_label.c_str(), out_node->GetName().c_str(), out_node->GetType().c_str(), | |||
__FUNCTION__); | |||
GELOGE(status, "Set stream label failed."); | |||
return status; | |||
} | |||
nodes.push(out_node); | |||
} | |||
} | |||
@@ -22,6 +22,7 @@ | |||
#include "graph/utils/type_utils.h" | |||
#include "framework/common/debug/log.h" | |||
#include "framework/common/ge_inner_error_codes.h" | |||
#include "common/formats/utils/formats_trans_utils.h" | |||
namespace ge { | |||
namespace { | |||
@@ -31,6 +32,7 @@ const char *const kAttrNameType = "type"; | |||
Status BitcastPass::Run(NodePtr &node) { | |||
GELOGD("Bitcast running"); | |||
if (node == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid when BitcastPass %s", __FUNCTION__); | |||
GELOGE(PARAM_INVALID, "Param [node] must not be null."); | |||
return PARAM_INVALID; | |||
} | |||
@@ -41,6 +43,7 @@ Status BitcastPass::Run(NodePtr &node) { | |||
OpDescPtr op_desc = node->GetOpDesc(); | |||
if (op_desc == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Param op_desc of node is nullptr, check invalid when BitcastPass %s", __FUNCTION__); | |||
return PARAM_INVALID; | |||
} | |||
ge::DataType dst_data_type; | |||
@@ -58,20 +61,31 @@ Status BitcastPass::Run(NodePtr &node) { | |||
Status BitcastPass::CheckDstDataType(const OpDescPtr op_desc, ge::DataType &dst_data_type) { | |||
if (!ge::AttrUtils::GetDataType(op_desc, kAttrNameType, dst_data_type)) { | |||
REPORT_CALL_ERROR("E19999", "Get Attr:%s of op:%s(%s) failed when BitcastPass %s", | |||
kAttrNameType, op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__); | |||
GELOGE(PARAM_INVALID, "Node failed to get attribute type."); | |||
return PARAM_INVALID; | |||
} | |||
if (dst_data_type >= ge::DT_UNDEFINED) { | |||
GELOGE(PARAM_INVALID, "dst_data_type[%s] is not valid.", | |||
REPORT_INNER_ERROR("E19999", "Param dst_data_type:%d check invalid, op:%s(%s), when BitcastPass %s", | |||
dst_data_type, op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__); | |||
GELOGE(PARAM_INVALID, "dst_data_type[%s] is not valid.", | |||
TypeUtils::DataTypeToSerialString(dst_data_type).c_str()); | |||
return PARAM_INVALID; | |||
} | |||
if (op_desc->GetOutputDescPtr(0) == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Index 0 ouput desc of op:%s(%s) not exist, check invalid when BitcastPass %s", | |||
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__); | |||
GELOGE(PARAM_INVALID, "Bitcast node outputDesc is null."); | |||
return PARAM_INVALID; | |||
} | |||
if (op_desc->GetOutputDescPtr(0)->GetDataType() != dst_data_type) { | |||
REPORT_INNER_ERROR("E19999", "Index 0 ouput desc of op:%s(%s), it't data type:%s not equal to dst_data_type:%s, " | |||
"check invalid when BitcastPass %s", op_desc->GetName().c_str(), op_desc->GetType().c_str(), | |||
TypeUtils::DataTypeToSerialString(dst_data_type).c_str(), | |||
TypeUtils::DataTypeToSerialString(op_desc->GetOutputDescPtr(0)->GetDataType()).c_str(), | |||
__FUNCTION__); | |||
GELOGE(PARAM_INVALID, "dst_data_type[%s] is not equal to output_data_type[%s].", | |||
TypeUtils::DataTypeToSerialString(dst_data_type).c_str(), | |||
TypeUtils::DataTypeToSerialString(op_desc->GetOutputDescPtr(0)->GetDataType()).c_str()); | |||
@@ -84,6 +98,8 @@ Status BitcastPass::CheckOutputShape(const OpDescPtr op_desc, const ge::DataType | |||
const GeTensorDescPtr &input_tensor_desc = op_desc->MutableInputDesc(0); | |||
const GeTensorDescPtr &output_tensor_desc = op_desc->MutableOutputDesc(0); | |||
if (input_tensor_desc == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Index 0 input desc of op:%s(%s) not exist, check invalid when BitcastPass %s", | |||
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__); | |||
GELOGE(PARAM_INVALID, "input_tensor_desc must not be null."); | |||
return PARAM_INVALID; | |||
} | |||
@@ -91,7 +107,10 @@ Status BitcastPass::CheckOutputShape(const OpDescPtr op_desc, const ge::DataType | |||
// get origin data_type and shape | |||
ge::DataType ori_data_type = input_tensor_desc->GetDataType(); | |||
if (ori_data_type >= ge::DT_UNDEFINED) { | |||
GELOGE(PARAM_INVALID, "ori_data_type[%s] is not valid.", | |||
REPORT_INNER_ERROR("E19999", "ori_data_type:%d of index 0 input desc in op:%s(%s), " | |||
"check invalid when BitcastPass %s", | |||
ori_data_type, op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__); | |||
GELOGE(PARAM_INVALID, "ori_data_type[%s] is not valid.", | |||
TypeUtils::DataTypeToSerialString(ori_data_type).c_str()); | |||
return PARAM_INVALID; | |||
} | |||
@@ -108,6 +127,11 @@ Status BitcastPass::CheckOutputShape(const OpDescPtr op_desc, const ge::DataType | |||
} | |||
if (dim_vec != output_tensor_desc->GetShape().GetDims()) { | |||
REPORT_INNER_ERROR("E19999", "Shape:%s of index 0 output desc in op:%s(%s), different from expect shape:%s ," | |||
"check invalid when BitcastPass %s", | |||
formats::JoinToString(output_tensor_desc->GetShape().GetDims()).c_str(), | |||
op_desc->GetName().c_str(), op_desc->GetType().c_str(), formats::JoinToString(dim_vec).c_str(), | |||
__FUNCTION__); | |||
GELOGE(PARAM_INVALID, "out_put_shape is different from expectations."); | |||
return PARAM_INVALID; | |||
} | |||
@@ -118,6 +142,7 @@ Status BitcastPass::CheckOutputShape(const OpDescPtr op_desc, const ge::DataType | |||
Status BitcastPass::CalcAndUpdateShape(BitcastPass::kVecInt64 &dim_vec, ge::DataType ori_data_type, | |||
ge::DataType dst_data_type) { | |||
if (dim_vec.size() == 0) { | |||
REPORT_INNER_ERROR("E19999", "Param dim_vec is empty, check invalid when BitcastPass %s", __FUNCTION__); | |||
GELOGE(PARAM_INVALID, "Pre node shape size is zero."); | |||
return PARAM_INVALID; | |||
} | |||
@@ -128,6 +153,10 @@ Status BitcastPass::CalcAndUpdateShape(BitcastPass::kVecInt64 &dim_vec, ge::Data | |||
return SUCCESS; | |||
} else if (ori_data_size > dst_data_size) { | |||
if (ori_data_size % dst_data_size != 0) { | |||
REPORT_INNER_ERROR("E19999", "size:%ld of ori_data_type:%s is not divisible by size:%ld of dst_data_type:%s ," | |||
"check invalid when BitcastPass %s", | |||
ori_data_size, TypeUtils::DataTypeToSerialString(ori_data_type).c_str(), | |||
dst_data_size, TypeUtils::DataTypeToSerialString(dst_data_type).c_str(), __FUNCTION__); | |||
GELOGE(PARAM_INVALID, "ori_data_size is not divisible by dst_data_size."); | |||
return PARAM_INVALID; | |||
} | |||
@@ -135,11 +164,18 @@ Status BitcastPass::CalcAndUpdateShape(BitcastPass::kVecInt64 &dim_vec, ge::Data | |||
return SUCCESS; | |||
} else { | |||
if (dst_data_size % ori_data_size != 0) { | |||
REPORT_INNER_ERROR("E19999", "size:%ld of dst_data_type:%s is not divisible by size:%ld of ori_data_type:%s ," | |||
"check invalid when BitcastPass %s", | |||
dst_data_size, TypeUtils::DataTypeToSerialString(dst_data_type).c_str(), | |||
ori_data_size, TypeUtils::DataTypeToSerialString(ori_data_type).c_str(), __FUNCTION__); | |||
GELOGE(PARAM_INVALID, "dst_data_size is not divisible by ori_data_size."); | |||
return PARAM_INVALID; | |||
} | |||
if (dim_vec[dim_vec.size() - 1] != (dst_data_size / ori_data_size)) { | |||
REPORT_INNER_ERROR("E19999", "The last dim:%ld in param dim_vec is not equal to " | |||
"dst_data_size:%ld / ori_data_size:%ld, check invalid when BitcastPass %s", | |||
dim_vec[dim_vec.size() - 1], dst_data_size, ori_data_size, __FUNCTION__); | |||
GELOGE(PARAM_INVALID, "The last dim is not equal to dst_data_size / ori_data_size."); | |||
return PARAM_INVALID; | |||
} | |||
@@ -25,11 +25,14 @@ | |||
namespace ge { | |||
Status CastRemovePass::Run(NodePtr &node) { | |||
if (node == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid when CastRemovePass %s", __FUNCTION__); | |||
GELOGE(PARAM_INVALID, "Param [node] must not be null."); | |||
return PARAM_INVALID; | |||
} | |||
OpDescPtr op_desc = node->GetOpDesc(); | |||
if (op_desc == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Param op_desc of node is nullptr, check invalid when CastRemovePass %s", | |||
__FUNCTION__); | |||
GELOGE(PARAM_INVALID, "OpDesc of param [node] must not be null."); | |||
return PARAM_INVALID; | |||
} | |||
@@ -46,6 +49,7 @@ Status CastRemovePass::Run(NodePtr &node) { | |||
} | |||
OpDescPtr end_op_desc = end_node->GetOpDesc(); | |||
if (end_op_desc == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "op_desc of end_node is nullptr, check invalid when CastRemovePass %s", __FUNCTION__); | |||
GELOGE(PARAM_INVALID, "OpDesc of end node must not be null."); | |||
return PARAM_INVALID; | |||
} | |||
@@ -99,6 +103,8 @@ Status CastRemovePass::RemoveCast(DataType &type, std::vector<NodePtr> &nodes_to | |||
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 when CastRemovePass %s", | |||
node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "IsolateAndDeleteNode %s failed.", node->GetName().c_str()); | |||
return FAILED; | |||
} | |||
@@ -114,6 +120,8 @@ Status CastRemovePass::RemoveCast(DataType &type, std::vector<NodePtr> &nodes_to | |||
} | |||
OpDescPtr op_desc = node->GetOpDesc(); | |||
if (op_desc == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Find nullptr op_desc in node, check invalid when CastRemovePass %s", | |||
__FUNCTION__); | |||
GELOGE(FAILED, "OpDesc must not be null."); | |||
return FAILED; | |||
} | |||
@@ -123,6 +131,9 @@ Status CastRemovePass::RemoveCast(DataType &type, std::vector<NodePtr> &nodes_to | |||
op_desc->SetName(new_node_name); | |||
// add attr to changed TransData, then will be rebuild | |||
if (!AttrUtils::SetBool(op_desc, ATTR_NEED_COMPILE, true)) { | |||
REPORT_CALL_ERROR("E19999", "Set Attr:%s of op:%s(%s) failed when CastRemovePass %s", | |||
ATTR_NEED_COMPILE.c_str(), | |||
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Set ATTR_NEED_COMPILE Attr fail."); | |||
return FAILED; | |||
} | |||
@@ -223,6 +223,8 @@ Status CastTranslatePass::Run(NodePtr &node) { | |||
continue; | |||
} | |||
if (IsolateAndDeleteNode(out_data_node, {0}) != SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed when CastTranslatePass %s", | |||
out_data_node->GetName().c_str(), out_data_node->GetType().c_str(), __FUNCTION__); | |||
return FAILED; | |||
} | |||
} | |||
@@ -262,6 +264,9 @@ Status CastTranslatePass::FuseDstNTranslates(NodePtr &node) { | |||
ComputeGraphPtr graph = out_data_node->GetOwnerComputeGraph(); | |||
GE_CHECK_NOTNULL(graph); | |||
if (GraphUtils::RemoveNodeWithoutRelink(graph, out_data_node) != SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed when CastTranslatePass %s", | |||
out_data_node->GetName().c_str(), out_data_node->GetType().c_str(), graph->GetName().c_str(), | |||
__FUNCTION__); | |||
GELOGE(FAILED, "[%s] RemoveNodeWithoutRelink failed.", out_data_node->GetName().c_str()); | |||
return FAILED; | |||
} | |||
@@ -106,6 +106,9 @@ Status CommonSubexpressionEliminationPass::Run(ComputeGraphPtr graph) { | |||
ret = GraphUtils::ReplaceNodeAnchors(iter->second, node, {}, output_map); | |||
if (ret != GRAPH_SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Replace node:%s(%s) by node:%s(%s) failed " | |||
"when CommonSubexpressionEliminationPass %s", node->GetName().c_str(), node->GetType().c_str(), | |||
iter->second->GetName().c_str(), iter->second->GetType().c_str(), __FUNCTION__); | |||
GELOGE(INTERNAL_ERROR, "Failed to replace node %s by node %s error node %u", | |||
node->GetName().c_str(), iter->second->GetName().c_str(), ret); | |||
return INTERNAL_ERROR; | |||
@@ -115,6 +118,9 @@ Status CommonSubexpressionEliminationPass::Run(ComputeGraphPtr graph) { | |||
ret = GraphUtils::RemoveNodeWithoutRelink(graph, node); | |||
if (ret != GRAPH_SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed " | |||
"when CommonSubexpressionEliminationPass %s", | |||
node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str(), __FUNCTION__); | |||
GELOGE(INTERNAL_ERROR, "Failed to remove node %s from graph", node->GetName().c_str()); | |||
return INTERNAL_ERROR; | |||
} | |||
@@ -41,6 +41,7 @@ graphStatus CompileNodesPass::Run(ComputeGraphPtr graph) { | |||
} | |||
std::shared_ptr<GELib> instance = ge::GELib::GetInstance(); | |||
if (instance == nullptr || !instance->InitFlag()) { | |||
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid when CompileNodesPass %s", __FUNCTION__); | |||
GELOGE(ge::GE_CLI_GE_NOT_INITIALIZED, "Run CompileNodesPass failed."); | |||
return ge::GE_CLI_GE_NOT_INITIALIZED; | |||
} | |||
@@ -99,6 +100,8 @@ graphStatus CompileNodesPass::GetSupportedKernel(const NodePtr &node, const std: | |||
(void)instance->DNNEngineManagerObj().GetDNNEngineName(node); | |||
kernel_lib_name = op_desc->GetOpKernelLibName(); | |||
if (kernel_lib_name.empty()) { | |||
REPORT_INNER_ERROR("E19999", "kernel_lib_name in op:%s(%s) is empty, check invalid when CompileNodesPass %s", | |||
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__); | |||
GELOGE(GRAPH_FAILED, "Get node:%s, type:%s kernel lib failed.", node->GetName().c_str(), | |||
op_desc->GetType().c_str()); | |||
return GRAPH_FAILED; | |||
@@ -106,11 +109,16 @@ graphStatus CompileNodesPass::GetSupportedKernel(const NodePtr &node, const std: | |||
} | |||
OpsKernelInfoStorePtr kernel_info = instance->OpsKernelManagerObj().GetOpsKernelInfoStore(kernel_lib_name); | |||
if (kernel_info == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Find ops kernel by name:%s failed for op:%s(%s), when CompileNodesPass %s", | |||
kernel_lib_name.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__); | |||
GELOGE(ge::GE_GRAPH_PARAM_NULLPTR, "Get op %s ops kernel info store failed", node->GetName().c_str()); | |||
return ge::GE_GRAPH_PARAM_NULLPTR; | |||
} | |||
std::map<std::string, std::string> unsupported_reasons; | |||
std::string unsupported_reason; | |||
// begin accuracy supported check | |||
if (!CheckAccuracySupport(kernel_info, instance, node)) { | |||
if (!CheckAccuracySupport(kernel_info, instance, node, unsupported_reason)) { | |||
// if check accuracy support failed , try to go to other engine. | |||
GELOGD("Check Accuracy Supported return not support, node name is %s. Try to go to other engine.", | |||
op_desc->GetName().c_str()); | |||
@@ -123,13 +131,25 @@ graphStatus CompileNodesPass::GetSupportedKernel(const NodePtr &node, const std: | |||
continue; | |||
} | |||
OpsKernelInfoStorePtr tmp_kernel_info = it->second; | |||
if (CheckAccuracySupport(tmp_kernel_info, instance, node)) { | |||
if (CheckAccuracySupport(tmp_kernel_info, instance, node, unsupported_reason)) { | |||
kernel_lib_name = tmp_kernel_name; | |||
GELOGD("Find kernel lib %s support node:%s, type:%s , get kernel lib success.", tmp_kernel_name.c_str(), | |||
node->GetName().c_str(), op_desc->GetType().c_str()); | |||
return GRAPH_SUCCESS; | |||
} else { | |||
unsupported_reasons.emplace(tmp_kernel_name, unsupported_reason); | |||
} | |||
} | |||
for (const auto &it : unsupported_reasons) { | |||
REPORT_INPUT_ERROR("E13002", std::vector<std::string>({"optype", "opskernel", "reason"}), | |||
std::vector<std::string>({op_desc->GetType(), it.first, it.second})); | |||
GELOGE(GE_GRAPH_ASSIGN_ENGINE_FAILED, | |||
"CheckAccuracySupport:Op type %s of ops kernel %s is unsupported, reason:%s", | |||
op_desc->GetType().c_str(), it.first.c_str(), it.second.c_str()); | |||
} | |||
REPORT_INPUT_ERROR("E13003", std::vector<std::string>({"opname", "optype"}), | |||
std::vector<std::string>({op_desc->GetName(), op_desc->GetType()})); | |||
GELOGE(GRAPH_FAILED, "Cannot find kernel lib support node:%s, type:%s , get kernel lib failed.", | |||
node->GetName().c_str(), op_desc->GetType().c_str()); | |||
return GRAPH_FAILED; | |||
@@ -137,10 +157,10 @@ graphStatus CompileNodesPass::GetSupportedKernel(const NodePtr &node, const std: | |||
return GRAPH_SUCCESS; | |||
} | |||
bool CompileNodesPass::CheckAccuracySupport(const OpsKernelInfoStorePtr &kernel_info, | |||
const std::shared_ptr<GELib> instance, const NodePtr &node) { | |||
string reason; | |||
if (!(kernel_info->CheckAccuracySupported(node, reason, true))) { | |||
bool CompileNodesPass::CheckAccuracySupport( | |||
const OpsKernelInfoStorePtr &kernel_info, const std::shared_ptr<GELib> instance, | |||
const NodePtr &node, string& unsupported_reason) { | |||
if (!(kernel_info->CheckAccuracySupported(node, unsupported_reason, true))) { | |||
return false; | |||
} | |||
return true; | |||
@@ -153,6 +173,8 @@ graphStatus CompileNodesPass::CompileNodes(const std::shared_ptr<GELib> instance | |||
for (auto &kernel_nodes : kernel_to_compile_nodes) { | |||
kernel_info = instance->OpsKernelManagerObj().GetOpsKernelInfoStore(kernel_nodes.first); | |||
if (kernel_info == nullptr) { | |||
REPORT_INNER_ERROR("E19999", "Find ops kernel by name:%s failed, when CompileNodesPass %s", | |||
kernel_nodes.first.c_str(), __FUNCTION__); | |||
GELOGE(ge::GE_GRAPH_PARAM_NULLPTR, "Get op %s ops kernel info store failed", kernel_nodes.first.c_str()); | |||
return ge::GE_GRAPH_PARAM_NULLPTR; | |||
} | |||
@@ -168,6 +190,8 @@ graphStatus CompileNodesPass::CompileNodes(const std::shared_ptr<GELib> instance | |||
} | |||
auto ret = kernel_info->CompileOp(kernel_nodes.second); | |||
if (ret != GRAPH_SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Call CompileOp failed, kernel_lib_name:%s, ret:%d, when CompileNodesPass %s", | |||
kernel_nodes.first.c_str(), ret, __FUNCTION__); | |||
GELOGE(ret, "Compile op failed, kernel name is %s", kernel_nodes.first.c_str()); | |||
return GRAPH_FAILED; | |||
} | |||
@@ -39,7 +39,7 @@ class CompileNodesPass : public GraphPass { | |||
private: | |||
graphStatus GetSupportedKernel(const NodePtr &node, const std::shared_ptr<GELib> instance, string &kernel_lib_name); | |||
bool CheckAccuracySupport(const OpsKernelInfoStorePtr &kernel_info, const std::shared_ptr<GELib> instance, | |||
const NodePtr &node); | |||
const NodePtr &node, string& unsupported_reason); | |||
graphStatus CompileNodes(const std::shared_ptr<GELib> instance, | |||
std::unordered_map<string, vector<NodePtr>> &kernel_to_compile_nodes); | |||
}; | |||
@@ -75,6 +75,10 @@ Status CondPass::Run(NodePtr &node) { | |||
case DT_INT32: | |||
break; | |||
default: | |||
REPORT_INNER_ERROR("E19999", | |||
"data_type:%d of index:%d input tensor in op:%s(%s) check invalid when CondPass %s", | |||
cond_tensor.GetDataType(), cond_in_anchor->GetIdx(), | |||
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "UpdateInputDesc for node %s failed.", op_desc->GetName().c_str()); | |||
return FAILED; | |||
} | |||
@@ -85,6 +89,8 @@ Status CondPass::Run(NodePtr &node) { | |||
cond_tensor.SetShape(GeShape()); | |||
cond_tensor.SetOriginShape(GeShape()); | |||
if (op_desc->UpdateInputDesc(cond_in_anchor->GetIdx(), cond_tensor) != GRAPH_SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Update input desc of op:%s(%s) failed, index:%d, when CondPass %s", | |||
op_desc->GetName().c_str(), op_desc->GetType().c_str(), cond_in_anchor->GetIdx(), __FUNCTION__); | |||
GELOGE(FAILED, "UpdateInputDesc for node %s failed.", op_desc->GetName().c_str()); | |||
return FAILED; | |||
} | |||
@@ -158,6 +164,9 @@ Status CondPass::GetCondInfoForWhile(const NodePtr &node, ComputeGraphPtr &graph | |||
std::map<std::string, uint32_t> subgraph_names_to_index = op_desc->GetSubgraphNameIndexes(); | |||
auto iter = subgraph_names_to_index.find(ATTR_NAME_WHILE_COND); | |||
if (iter == subgraph_names_to_index.end()) { | |||
REPORT_INNER_ERROR("E19999", "subgraph name:%s not exist in SubgraphNameIndexes map of op:%s(%s), " | |||
"check invalid when CondPass %s", ATTR_NAME_WHILE_COND.c_str(), | |||
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Get cond_graph index failed, while_node:%s.", node->GetName().c_str()); | |||
return FAILED; | |||
} | |||
@@ -170,6 +179,8 @@ Status CondPass::GetCondInfoForWhile(const NodePtr &node, ComputeGraphPtr &graph | |||
// cond_graph has and only has one output | |||
uint32_t output_num = net_output_node->GetAllInDataAnchorsSize(); | |||
if (output_num != 1) { | |||
REPORT_INNER_ERROR("E19999", "Input data anchor num:%u of op:%s(%s) not equal to 1, check invalid when CondPass %s", | |||
output_num, op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "output size of cond_graph is invalid, expect 1 but %u exactly, while_node:%s.", | |||
output_num, node->GetName().c_str()); | |||
return FAILED; | |||
@@ -233,6 +244,12 @@ Status CondPass::HandleScalarCond(const ComputeGraphPtr &graph, const OutDataAnc | |||
} | |||
if (GraphUtils::InsertNodeAfter(peer_out_anchor, { cond_in_anchor }, cast_node) != GRAPH_SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Insert Cast node %s(%s) between %s(%s)->%s(%s) failed, when CondPass %s", | |||
cast_node->GetName().c_str(), cast_node->GetType().c_str(), | |||
peer_out_anchor->GetOwnerNode()->GetName().c_str(), | |||
peer_out_anchor->GetOwnerNode()->GetType().c_str(), | |||
cond_in_anchor->GetOwnerNode()->GetName().c_str(), | |||
cond_in_anchor->GetOwnerNode()->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Insert Cast node %s between %s->%s failed.", | |||
cast_node->GetName().c_str(), peer_out_anchor->GetOwnerNode()->GetName().c_str(), | |||
cond_in_anchor->GetOwnerNode()->GetName().c_str()); | |||
@@ -268,17 +285,27 @@ Status CondPass::InsertNode(const ComputeGraphPtr &graph, const OutDataAnchorPtr | |||
OpDescBuilder op_desc_builder(in_data_anchor->GetOwnerNode()->GetName() + "_" + type, type); | |||
OpDescPtr op_desc = op_desc_builder.AddInput("x", in_tensor).AddOutput("y", out_tensor).Build(); | |||
if (op_desc == nullptr) { | |||
REPORT_CALL_ERROR("E19999", "Create op_desc:%s(%s) failed, when CondPass %s", | |||
(in_data_anchor->GetOwnerNode()->GetName() + "_" + type).c_str(), type.c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Create op_desc failed."); | |||
return FAILED; | |||
} | |||
NodePtr new_node = graph->AddNode(op_desc); | |||
if (new_node == nullptr) { | |||
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed when CondPass %s", | |||
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Create %s node failed.", type.c_str()); | |||
return FAILED; | |||
} | |||
AddRePassNode(new_node); | |||
if (GraphUtils::InsertNodeAfter(peer_out_anchor, { in_data_anchor }, new_node) != GRAPH_SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Insert node %s(%s) between %s(%s)->%s(%s) failed, when CondPass %s", | |||
new_node->GetName().c_str(), new_node->GetType().c_str(), | |||
peer_out_anchor->GetOwnerNode()->GetName().c_str(), | |||
peer_out_anchor->GetOwnerNode()->GetType().c_str(), | |||
in_data_anchor->GetOwnerNode()->GetName().c_str(), | |||
in_data_anchor->GetOwnerNode()->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Insert %s node %s between %s->%s failed.", type.c_str(), | |||
new_node->GetName().c_str(), peer_out_anchor->GetOwnerNode()->GetName().c_str(), | |||
in_data_anchor->GetOwnerNode()->GetName().c_str()); | |||
@@ -310,6 +337,8 @@ NodePtr CondPass::AddCastNode(const ComputeGraphPtr &graph, const std::string &n | |||
OpDescBuilder op_desc_builder(name, CAST); | |||
OpDescPtr cast_desc = op_desc_builder.AddInput("x", in_tensor).AddOutput("y", out_tensor).Build(); | |||
if (cast_desc == nullptr) { | |||
REPORT_CALL_ERROR("E19999", "Create op_desc:%s(%s) failed, when CondPass %s", | |||
name.c_str(), CAST, __FUNCTION__); | |||
GELOGE(FAILED, "Create cast op_desc failed, name: %s.", name.c_str()); | |||
return nullptr; | |||
} | |||
@@ -317,12 +346,19 @@ NodePtr CondPass::AddCastNode(const ComputeGraphPtr &graph, const std::string &n | |||
AttrUtils::SetInt(cast_desc, CAST_ATTR_DSTT, dst) && | |||
AttrUtils::SetInt(cast_desc, CAST_ATTR_DST_TYPE, dst) && | |||
AttrUtils::SetBool(cast_desc, CAST_ATTR_TRUNCATE, false))) { | |||
REPORT_CALL_ERROR("E19999", "Set Attr:%s,%s,%s,%s to node:%s(%s) not all success, when CondPass %s", | |||
CAST_ATTR_SRCT.c_str(), CAST_ATTR_DSTT.c_str(), | |||
CAST_ATTR_DST_TYPE.c_str(), CAST_ATTR_TRUNCATE.c_str(), | |||
cast_desc->GetName().c_str(), cast_desc->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Set CAST_ATTR failed, node: %s.", name.c_str()); | |||
return nullptr; | |||
} | |||
NodePtr cast_node = graph->AddNode(cast_desc); | |||
if (cast_node == nullptr) { | |||
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed when CondPass %s", | |||
cast_desc->GetName().c_str(), cast_desc->GetType().c_str(), graph->GetName().c_str(), | |||
__FUNCTION__); | |||
GELOGE(FAILED, "Add cast node failed, name: %s.", name.c_str()); | |||
return nullptr; | |||
} | |||
@@ -85,6 +85,12 @@ Status CondRemovePass::RemoveDeadCondLink(const int32_t index, const NodePtr &no | |||
const auto &in_anchor = node->GetInDataAnchor(index); | |||
const auto &peerout_anchor = in_anchor->GetPeerOutAnchor(); | |||
if (GraphUtils::RemoveEdge(peerout_anchor, in_anchor) != SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(out_index:%d) and op:%s(%s)(in_index:%d) failed " | |||
"when CondRemovePass %s", | |||
peerout_anchor->GetOwnerNode()->GetName().c_str(), | |||
peerout_anchor->GetOwnerNode()->GetType().c_str(), peerout_anchor->GetIdx(), | |||
in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetType().c_str(), | |||
in_anchor->GetIdx(), __FUNCTION__); | |||
GELOGE(FAILED, "Remove edge from node %s index %d to node %s index %d.", | |||
peerout_anchor->GetOwnerNode()->GetName().c_str(), peerout_anchor->GetIdx(), | |||
in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetIdx()); | |||
@@ -98,6 +104,8 @@ Status CondRemovePass::GetCaseChosenBranch(const NodePtr &node, const uint32_t c | |||
uint32_t subgraph_names_size = static_cast<uint32_t>(node->GetOpDesc()->GetSubgraphInstanceNames().size()); | |||
uint32_t cond_index_new = cond_index; | |||
if (subgraph_names_size == 0) { | |||
REPORT_INNER_ERROR("E19999", "subgraph size of op:%s(%s) is 0, check invavlid when CondRemovePass %s", | |||
node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Node %s has none subgraph.", node->GetName().c_str()); | |||
return ge::FAILED; | |||
} | |||
@@ -107,6 +115,8 @@ Status CondRemovePass::GetCaseChosenBranch(const NodePtr &node, const uint32_t c | |||
} | |||
const auto &chosen_branch_name = node->GetOpDesc()->GetSubgraphInstanceName(cond_index_new); | |||
if (chosen_branch_name.empty()) { | |||
REPORT_INNER_ERROR("E19999", "Get subgraph name from op:%s(%s) by index:%u failed, when CondRemovePass %s", | |||
node->GetName().c_str(), node->GetType().c_str(), cond_index_new, __FUNCTION__); | |||
GELOGE(FAILED, "Node %s has no subgraph, index is %u.", node->GetName().c_str(), cond_index_new); | |||
return ge::FAILED; | |||
} | |||
@@ -121,6 +131,8 @@ Status CondRemovePass::GetIfChosenBranch(const NodePtr &node, const uint32_t con | |||
uint32_t subgraph_names_size = static_cast<uint32_t>(node->GetOpDesc()->GetSubgraphInstanceNames().size()); | |||
uint32_t cond_index_new = 0; | |||
if (subgraph_names_size == 0) { | |||
REPORT_INNER_ERROR("E19999", "subgraph size of op:%s(%s) is 0, check invavlid when CondRemovePass %s", | |||
node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Node %s has none subgraph.", node->GetName().c_str()); | |||
return ge::FAILED; | |||
} | |||
@@ -130,11 +142,16 @@ Status CondRemovePass::GetIfChosenBranch(const NodePtr &node, const uint32_t con | |||
} | |||
const auto &chosen_branch_name = node->GetOpDesc()->GetSubgraphInstanceName(cond_index_new); | |||
if (chosen_branch_name.empty()) { | |||
REPORT_INNER_ERROR("E19999", "Get subgraph name from op:%s(%s) by index:%u failed, when CondRemovePass %s", | |||
node->GetName().c_str(), node->GetType().c_str(), cond_index_new, __FUNCTION__); | |||
GELOGE(FAILED, "Node %s has no subgraph, index is %u.", node->GetName().c_str(), cond_index_new); | |||
return ge::FAILED; | |||
} | |||
auto chosen_graph = GraphUtils::FindRootGraph(node->GetOwnerComputeGraph())->GetSubgraph(chosen_branch_name); | |||
if (chosen_graph == nullptr) { | |||
REPORT_INNER_ERROR("E19999", | |||
"Find subgraph by name:%s from node:%s(%s)'s root_graph failed, when CondRemovePass %s", | |||
chosen_branch_name.c_str(), node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__); | |||
GELOGE(FAILED, "Can not find branch %s in node %s's parent graph %s.", chosen_branch_name.c_str(), | |||
node->GetName().c_str(), node->GetOwnerComputeGraph()->GetName().c_str()); | |||
return ge::FAILED; | |||
@@ -242,6 +259,12 @@ Status CondRemovePass::ReplaceIfCaseNodeWithPartitioncall(const NodePtr &node, c | |||
for (const auto &peerout_anchor : input_anchor->GetPeerAnchors()) { | |||
if (GraphUtils::AddEdge(peerout_anchor, partitioncall_node->GetInAnchor( | |||
input_anchor->GetIdx() - kConditionIndexNum)) != ge::GRAPH_SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(out_index:%d) and op:%s(%s)(in_index:%d) failed " | |||
"when CondRemovePass %s", | |||
peerout_anchor->GetOwnerNode()->GetName().c_str(), | |||
peerout_anchor->GetOwnerNode()->GetType().c_str(), peerout_anchor->GetIdx(), | |||
partitioncall_node->GetName().c_str(), | |||
partitioncall_node->GetType().c_str(), input_anchor->GetIdx(), __FUNCTION__); | |||
GELOGE(FAILED, "Add edge failed, from node:%s idx:%d to node:%s idx:%d, input num:%zu, output num:%zu", | |||
peerout_anchor->GetOwnerNode()->GetName().c_str(), peerout_anchor->GetIdx(), | |||
partitioncall_node->GetName().c_str(), input_anchor->GetIdx(), input_desc_size, | |||
@@ -255,6 +278,11 @@ Status CondRemovePass::ReplaceIfCaseNodeWithPartitioncall(const NodePtr &node, c | |||
for (const auto &output_anchor : node->GetAllOutAnchors()) { | |||
for (const auto &peerin_anchor : output_anchor->GetPeerAnchors()) { | |||
if (GraphUtils::RemoveEdge(node->GetOutAnchor(output_anchor->GetIdx()), peerin_anchor) != ge::GRAPH_SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(out_index:%d) and op:%s(%s)(in_index:%d) failed " | |||
"when CondRemovePass %s", | |||
node->GetName().c_str(), node->GetType().c_str(), output_anchor->GetIdx(), | |||
peerin_anchor->GetOwnerNode()->GetName().c_str(), | |||
peerin_anchor->GetOwnerNode()->GetType().c_str(), peerin_anchor->GetIdx(), __FUNCTION__); | |||
GELOGE(FAILED, "Remove edge failed, from node:%s idx:%d to node:%s idx:%d, input num:%zu, output num:%zu", | |||
node->GetName().c_str(), output_anchor->GetIdx(), peerin_anchor->GetOwnerNode()->GetName().c_str(), | |||
peerin_anchor->GetIdx(), input_desc_size, output_desc_size); | |||
@@ -262,6 +290,12 @@ Status CondRemovePass::ReplaceIfCaseNodeWithPartitioncall(const NodePtr &node, c | |||
} | |||
if (GraphUtils::AddEdge(partitioncall_node->GetOutAnchor(output_anchor->GetIdx()), peerin_anchor) != | |||
ge::GRAPH_SUCCESS) { | |||
REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(out_index:%d) and op:%s(%s)(in_index:%d) failed " | |||
"when CondRemovePass %s", | |||
partitioncall_node->GetName().c_str(), | |||
partitioncall_node->GetType().c_str(), output_anchor->GetIdx(), | |||
peerin_anchor->GetOwnerNode()->GetName().c_str(), | |||
peerin_anchor->GetOwnerNode()->GetType().c_str(), peerin_anchor->GetIdx(), __FUNCTION__); | |||
GELOGE(FAILED, "Add edge failed, from node:%s idx:%d to node:%s idx:%d, input num:%zu, output num:%zu", | |||
partitioncall_node->GetName().c_str(), output_anchor->GetIdx(), | |||
peerin_anchor->GetOwnerNode()->GetName().c_str(), peerin_anchor->GetIdx(), input_desc_size, | |||
@@ -416,7 +416,7 @@ Status RecoverTransRoadForVar(const NodePtr &var, const VarTransRoad &road) { | |||
GE_CHK_STATUS_RET(SetStreamLabel(last_node, stream_label), "set stream label failed"); | |||
} | |||
GE_CHK_BOOL_EXEC((ge::AttrUtils::SetBool(last_node->GetOpDesc(), ge::ATTR_INSERTED_BY_GE, true)), | |||
REPORT_CALL_ERROR("E19999", "Set Attr:%s of node:%s(%s) failed when %s", | |||
REPORT_CALL_ERROR("E19999", "Set Attr:%s to node:%s(%s) failed when %s", | |||
ge::ATTR_INSERTED_BY_GE.c_str(), | |||
last_node->GetName().c_str(), last_node->GetType().c_str(), __FUNCTION__); | |||
return INTERNAL_ERROR, "Set attr ATTR_INSERTED_BY_GE failed."); | |||