Browse Source

!1401 add error msg

Merge pull request !1401 from 王笑天/master
tags/v1.3.0
计晨 Gitee 4 years ago
parent
commit
6f74983fae
34 changed files with 1024 additions and 56 deletions
  1. +2
    -1
      ge/graph/build/model_builder.cc
  2. +1
    -1
      ge/graph/label/while_label_maker.cc
  3. +2
    -1
      ge/graph/load/model_manager/davinci_model.cc
  4. +6
    -3
      ge/graph/load/model_manager/model_manager.cc
  5. +2
    -2
      ge/graph/manager/graph_manager.cc
  6. +2
    -0
      ge/graph/manager/graph_manager_utils.cc
  7. +9
    -0
      ge/graph/manager/graph_mem_allocator.cc
  8. +51
    -0
      ge/graph/manager/graph_var_manager.cc
  9. +4
    -0
      ge/graph/manager/host_mem_allocator.cc
  10. +9
    -0
      ge/graph/manager/host_mem_manager.cc
  11. +6
    -0
      ge/graph/manager/memory_api.cc
  12. +11
    -0
      ge/graph/manager/rdma_pool_allocator.cc
  13. +50
    -3
      ge/graph/manager/trans_var_data_utils.cc
  14. +35
    -0
      ge/graph/optimize/graph_optimize.cc
  15. +2
    -0
      ge/graph/passes/addn_pass.cc
  16. +59
    -0
      ge/graph/passes/aicpu_constant_folding_pass.cc
  17. +4
    -0
      ge/graph/passes/assert_pass.cc
  18. +25
    -0
      ge/graph/passes/assign_remove_pass.cc
  19. +21
    -2
      ge/graph/passes/atomic_addr_clean_pass.cc
  20. +47
    -6
      ge/graph/passes/attach_stream_label_pass.cc
  21. +38
    -2
      ge/graph/passes/bitcast_pass.cc
  22. +11
    -0
      ge/graph/passes/cast_remove_pass.cc
  23. +5
    -0
      ge/graph/passes/cast_translate_pass.cc
  24. +6
    -0
      ge/graph/passes/common_subexpression_elimination_pass.cc
  25. +30
    -6
      ge/graph/passes/compile_nodes_pass.cc
  26. +1
    -1
      ge/graph/passes/compile_nodes_pass.h
  27. +36
    -0
      ge/graph/passes/cond_pass.cc
  28. +34
    -0
      ge/graph/passes/cond_remove_pass.cc
  29. +129
    -0
      ge/graph/preprocess/graph_preprocess.cc
  30. +46
    -0
      ge/graph/preprocess/insert_op/ge_aipp_op.cc
  31. +27
    -0
      ge/graph/preprocess/insert_op/util_insert_aipp_op.cc
  32. +263
    -28
      ge/graph/preprocess/multi_batch_copy_graph.cc
  33. +48
    -0
      ge/graph/preprocess/multi_batch_options.cc
  34. +2
    -0
      inc/framework/common/util.h

+ 2
- 1
ge/graph/build/model_builder.cc View File

@@ -674,7 +674,8 @@ Status ModelBuilder::SaveDataToModel(ge::Model &model, ge::GeModel &ge_model) {
GE_IF_BOOL_EXEC(cust_aicpu_kernel == nullptr, continue);
if (aicpu_name_set.count(cust_aicpu_kernel->GetName()) > 0) {
REPORT_INNER_ERROR("E19999", "aicpu_kernel name %s can't be the same, judge for op:%s(%s), when %s",
cust_aicpu_kernel->GetName().c_str(), n->GetName().c_str(), n->GetType().c_str(), __FUNCTION__);
cust_aicpu_kernel->GetName().c_str(), n->GetName().c_str(), n->GetType().c_str(),
__FUNCTION__);
GELOGE(FAILED, "aicpu_kernel name %s can't be the same", cust_aicpu_kernel->GetName().c_str());
return FAILED;
}


+ 1
- 1
ge/graph/label/while_label_maker.cc View File

@@ -143,7 +143,7 @@ Status WhileOpLabelMaker::Run(uint32_t &label_index) {
if (GraphUtils::AddEdge(in_anchor->GetPeerOutAnchor(), switch_node->GetInDataAnchor(kCondOutputIndex)) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add ctrl edge from %s to %s in graph:%s fail when %s",
in_anchor->GetPeerOutAnchor()->GetOwnerNode()->GetName().c_str(),
switch_node->GetName().c_str(), cond_graph ->GetName().c_str(), __FUNCTION__);
switch_node->GetName().c_str(), cond_graph->GetName().c_str(), __FUNCTION__);
GELOGE(FAILED, "Node: %s Add pred data input failed.", switch_node->GetName().c_str());
return FAILED;
}


+ 2
- 1
ge/graph/load/model_manager/davinci_model.cc View File

@@ -1486,7 +1486,8 @@ Status DavinciModel::InitLabelSet(const OpDescPtr &op_desc) {
rtLabel_t rt_label = nullptr;
rtError_t rt_error = rtLabelCreateExV2(&rt_label, rt_model_handle_, stream);
if (rt_error != RT_ERROR_NONE || rt_label == nullptr) {
REPORT_CALL_ERROR("E19999", "Call rtLabelCreateExV2 failed, ret: 0x%X when DavinciModel %s", rt_error, __FUNCTION__);
REPORT_CALL_ERROR("E19999", "Call rtLabelCreateExV2 failed, ret: 0x%X when DavinciModel %s",
rt_error, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "InitLabelSet: %s create label failed, error=0x%x.", op_desc->GetName().c_str(), rt_error);
return INTERNAL_ERROR;
}


+ 6
- 3
ge/graph/load/model_manager/model_manager.cc View File

@@ -159,7 +159,8 @@ Status ModelManager::KernelLaunchEx(aicpu::FWKAdapter::FWKOperateType op_type, u
}
rt_ret = rtStreamSynchronize(stream);
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtStreamSynchronize failed, ret: 0x%X when ModelManager %s", rt_ret, __FUNCTION__);
REPORT_CALL_ERROR("E19999", "Call rtStreamSynchronize failed, ret: 0x%X when ModelManager %s",
rt_ret, __FUNCTION__);
GELOGE(RT_FAILED, "rtStreamSynchronize failed. ret: 0x%X", rt_ret);
GE_IF_BOOL_EXEC(aicpu_kernel_addr != nullptr, GE_CHK_RT(rtFree(aicpu_kernel_addr)));
GE_CHK_RT(rtFree(devicebase));
@@ -1325,7 +1326,8 @@ Status ModelManager::LoadCustAicpuSo(const OpDescPtr &op_desc, const string &so_
rtContext_t rt_cur_ctx = nullptr;
auto rt_error = rtCtxGetCurrent(&rt_cur_ctx);
if (rt_error != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtCtxGetCurrent failed, ret = 0x%X, when ModelManager %s", rt_error, __FUNCTION__);
REPORT_CALL_ERROR("E19999", "Call rtCtxGetCurrent failed, ret = 0x%X, when ModelManager %s",
rt_error, __FUNCTION__);
GELOGE(RT_FAILED, "get current context failed, runtime result is %d", static_cast<int>(rt_error));
return RT_FAILED;
}
@@ -1361,7 +1363,8 @@ Status ModelManager::LaunchKernelCustAicpuSo(const string &kernel_name) {
rtContext_t rt_cur_ctx = nullptr;
auto rt_error = rtCtxGetCurrent(&rt_cur_ctx);
if (rt_error != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtCtxGetCurrent failed, ret = 0x%X, when ModelManager %s", rt_error, __FUNCTION__);
REPORT_CALL_ERROR("E19999", "Call rtCtxGetCurrent failed, ret = 0x%X, when ModelManager %s",
rt_error, __FUNCTION__);
GELOGE(RT_FAILED, "get current context failed, runtime result is %d", static_cast<int>(rt_error));
return RT_FAILED;
}


+ 2
- 2
ge/graph/manager/graph_manager.cc View File

@@ -803,8 +803,8 @@ Status GraphManager::SetRtContext(rtContext_t rt_context, rtCtxMode_t mode, uint
}
rt_ret = rtCtxSetCurrent(rt_context);
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtCtxSetCurrent failed, session_id:%lu, graph_id:%u, mode:%d, when GraphManager %s",
session_id, graph_id, mode, __FUNCTION__);
REPORT_CALL_ERROR("E19999", "Call rtCtxSetCurrent failed, session_id:%lu, graph_id:%u, mode:%d, "
"when GraphManager %s", session_id, graph_id, mode, __FUNCTION__);
GELOGE(FAILED, "Call rt api failed, ret: 0x%X", rt_ret);
return FAILED;
}


+ 2
- 0
ge/graph/manager/graph_manager_utils.cc View File

@@ -84,6 +84,7 @@ Status SubGraphInfo::FreeInOutBuffer() {
rtError_t rt_ret;
rt_ret = rtFreeHost(*iter);
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtFreeHost fail when SubGraphInfo %s", __FUNCTION__);
GELOGE(rt_ret, "[GraphManager] subgraph free buffer failed, modelId = %u", model_id_info_.model_id);
buffer_addr_.erase(buffer_addr_.begin(), iter);
return GE_GRAPH_FREE_FAILED;
@@ -119,6 +120,7 @@ Status GraphModelListener::OnComputeDone(uint32_t model_id, uint32_t task_id, ui

uint32_t GraphModelListener::GetResultCode() const {
if (!is_finished_) {
REPORT_CALL_ERROR("E19999", "Model not run finish, fail for %s", __FUNCTION__);
GELOGE(INTERNAL_ERROR, "[GraphManager] model not run finish.");
return INTERNAL_ERROR;
}


+ 9
- 0
ge/graph/manager/graph_mem_allocator.cc View File

@@ -49,6 +49,8 @@ uint8_t *MemoryAllocator::MallocMemory(const string &purpose, size_t memory_size
uint8_t *memory_addr = nullptr;

if (rtMalloc(reinterpret_cast<void **>(&memory_addr), memory_size, memory_type_) != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMalloc fail, purpose:%s, size:%zu, device_id:%u, when MemoryAllocator %s",
purpose.c_str(), memory_size, device_id, __FUNCTION__);
GELOGE(ge::INTERNAL_ERROR,
"MemoryAllocator::MallocMemory device_id = %u,"
" size= %lu",
@@ -66,6 +68,7 @@ Status MemoryAllocator::FreeMemory(uint8_t *memory_addr, uint32_t device_id) con
GELOGI("MemoryAllocator::FreeMemory device_id = %u", device_id);
auto rtRet = rtFree(memory_addr);
if (rtRet != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtFree fail, device_id:%u, when MemoryAllocator %s", device_id, __FUNCTION__);
GELOGE(rtRet, "MemoryAllocator::MallocMemory device_id = %u", device_id);
return RT_ERROR_TO_GE_STATUS(rtRet);
}
@@ -84,6 +87,9 @@ uint8_t *MemoryAllocator::MallocMemory(const string &purpose, const string &memo
uint8_t *memory_addr = MallocMemory(purpose, memory_size, device_id);

if (memory_addr == nullptr) {
REPORT_CALL_ERROR("E19999", "Malloc Memory fail, purpose:%s, memory_key:%s, memory_size:%zu, device_id:%u, "
"when MemoryAllocator %s", purpose.c_str(), memory_key.c_str(),
memory_size, device_id, __FUNCTION__);
GELOGE(ge::INTERNAL_ERROR,
"MemoryAllocator::MallocMemory failed,"
" memory_key[%s], size = %lu.",
@@ -120,6 +126,8 @@ Status MemoryAllocator::FreeMemory(const string &memory_key, uint32_t device_id)
}

if (FreeMemory(it->second.memory_addr_, device_id) != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Free Memory fail, memory_key:%s, device_id:%u, when MemoryAllocator %s",
memory_key.c_str(), device_id, __FUNCTION__);
GELOGE(ge::INTERNAL_ERROR,
"MemoryAllocator::FreeMemory rtFree failed,"
" memory_key[%s]",
@@ -169,6 +177,7 @@ Status MemManager::Initialize(const std::vector<rtMemType_t> &memory_type) {
memory_allocator_map_[index] = memory_allocator;
GELOGI("Create MemoryAllocator memory type[%u] success.", index);
} else {
REPORT_CALL_ERROR("E19999", "New MemoryAllocator fail, index:%u, when MemoryAllocator %s", index, __FUNCTION__);
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Alloc MemoryAllocator failed.");
}
} else {


+ 51
- 0
ge/graph/manager/graph_var_manager.cc View File

@@ -39,6 +39,8 @@ VarResource::~VarResource() {
ge::Status VarResource::GetVarAddr(const std::string &var_name, const ge::GeTensorDesc &tensor_desc, uint8_t **dev_ptr,
rtMemType_t &memory_type) {
if (dev_ptr == nullptr) {
REPORT_INNER_ERROR("E19999", "Param dev_ptr is nullptr, var_name:%s, session_id:%lu, "
"check invalid when VarResource %s", var_name.c_str(), session_id_, __FUNCTION__);
GELOGE(FAILED, "[GetVarAddr] dev_ptr is null!");
return FAILED;
}
@@ -47,6 +49,9 @@ ge::Status VarResource::GetVarAddr(const std::string &var_name, const ge::GeTens

auto iter = var_addr_mgr_map_.find(var_key);
if (iter == var_addr_mgr_map_.end()) {
REPORT_INNER_ERROR("E19999", "var_key:%s can't find in var_addr_mgr_map_, var_name:%s, session_id:%lu, "
"check invalid when VarResource %s", var_key.c_str(), var_name.c_str(),
session_id_, __FUNCTION__);
GELOGE(FAILED, "VarResource::GetVarAddr failed, var_key %s", var_key.c_str());
return FAILED;
}
@@ -102,6 +107,9 @@ ge::Status VarResource::SaveVarAddr(const std::string &var_name, const ge::GeTen
return SUCCESS;
}

REPORT_INNER_ERROR("E19999", "var_key:%s conflict in var_addr_mgr_map_, var_name:%s, session_id:%lu, "
"check invalid when VarResource %s", var_key.c_str(), var_name.c_str(),
session_id_, __FUNCTION__);
GELOGE(FAILED, "VarResource::SaveVarAddr, var_key %s save addr conflict", var_key.c_str());
return FAILED;
}
@@ -136,6 +144,8 @@ ge::Status VarResource::RenewCurVarDesc(const std::string &var_name, const ge::O
}

if (op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "Param op_desc is nullptr, var_name:%s, session_id:%lu, check invalid "
"when VarResource %s", var_name.c_str(), session_id_, __FUNCTION__);
GELOGE(FAILED, "[RenewCurVarDesc] renew var desc fail! input opdesc is null!");
return FAILED;
}
@@ -152,6 +162,9 @@ ge::Status VarResource::RenewCurVarDesc(const std::string &var_name, const ge::O
cur_var_tensor_desc_map_[var_name] = curr_desc;
auto iter = var_addr_mgr_map_.find(key);
if (iter == var_addr_mgr_map_.end()) {
REPORT_INNER_ERROR("E19999", "var_key:%s can't find in var_addr_mgr_map_, var_name:%s, session_id:%lu, op:%s(%s), "
"check invalid when VarResource %s", key.c_str(), var_name.c_str(),
session_id_, op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(FAILED, "[RenewCurVarDesc] can't find ele with key [%s]", key.c_str());
return FAILED;
}
@@ -271,11 +284,15 @@ Status HbmMemResource::AssignVarMem(const std::string &var_name, uint64_t size,
uint64_t real_size = size;
total_size_ = VarManager::Instance(session_id)->GetVarMemMaxSize();
if (total_size_ < var_mem_size_) {
REPORT_INNER_ERROR("E19999", "VarMemMaxSize:%lu < var_mem_size_:%lu, var_size:%lu, var_name:%s, check invalid"
" when HbmMemResource %s", total_size_, var_mem_size_, size, var_name.c_str(), __FUNCTION__);
GELOGE(PARAM_INVALID, "total_size_: %lu is smaller than var_mem_size_: %lu", total_size_, var_mem_size_);
return PARAM_INVALID;
}
uint64_t free_size = total_size_ - var_mem_size_;
if (free_size < (size + kSessionMemAlignSize * kSessionMemAlignUnit)) {
REPORT_INNER_ERROR("E19999", "free_size:%lu not enough, var_align_size:%lu, var_name:%s, check invalid "
"when HbmMemResource %s", free_size, size, var_name.c_str(), __FUNCTION__);
GELOGE(PARAM_INVALID, "Out of memory : current var size[%lu] exceeds total var size[%lu]",
size + kSessionMemAlignSize * kSessionMemAlignUnit + var_mem_size_, total_size_);
return PARAM_INVALID;
@@ -299,6 +316,8 @@ Status HbmMemResource::AssignVarMem(const std::string &var_name, uint64_t size,
Status RdmaMemResource::AssignVarMem(const std::string &var_name, uint64_t size, uint64_t session_id, size_t &address) {
uint8_t *buffer = MemManager::Instance().RdmaPoolInstance(RT_MEMORY_HBM).Malloc(size);
if (buffer == nullptr) {
REPORT_CALL_ERROR("E19999", "malloc rdma memory fail, var_size:%lu, var_name:%s when RdmaMemResource %s",
size, var_name.c_str(), __FUNCTION__);
GELOGE(MEMALLOC_FAILED, "Failed to malloc rdma memory for node %s, size = %lu", var_name.c_str(), size);
return MEMALLOC_FAILED;
}
@@ -448,6 +467,8 @@ int64_t VarManager::GetVarMemSize(rtMemType_t memory_type) {
}

if (mem_resource == nullptr) {
REPORT_INNER_ERROR("E19999", "Find no mem_resource in map, memory_type:%d, session_id:%lu when VarManager %s",
memory_type, session_id_, __FUNCTION__);
GELOGE(ge::INTERNAL_ERROR, "MemResource is invalid.");
return 0;
}
@@ -461,6 +482,8 @@ 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_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 {
@@ -471,6 +494,8 @@ Status VarManager::UpdateVarMemSize(rtMemType_t memory_type, int64_t mem_size) {
}

if (mem_resource == nullptr) {
REPORT_INNER_ERROR("E19999", "MemResource is invalid, memory_type:%d, session_id:%lu when VarManager %s",
memory_type, session_id_, __FUNCTION__);
GELOGE(ge::INTERNAL_ERROR, "MemResource is invalid.");
return FAILED;
}
@@ -489,6 +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_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;
}
@@ -498,6 +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_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 {
@@ -508,6 +537,8 @@ ge::Status VarManager::AssignVarMem(const std::string &var_name, const ge::GeTen
}

if (mem_resource == nullptr) {
REPORT_INNER_ERROR("E19999", "MemResource is invalid, memory_type:%d, session_id:%lu when VarManager %s",
memory_type, session_id_, __FUNCTION__);
GELOGE(ge::INTERNAL_ERROR, "MemResource is invalid, memory_type = %u.", memory_type);
return ge::INTERNAL_ERROR;
}
@@ -517,6 +548,8 @@ ge::Status VarManager::AssignVarMem(const std::string &var_name, const ge::GeTen
return ge::INTERNAL_ERROR;
}
if (var_resource_ == nullptr) {
REPORT_INNER_ERROR("E19999", "VarManager has not been init, memory_type:%d, session_id:%lu, "
"check invalid when VarManager %s", memory_type, session_id_, __FUNCTION__);
GELOGW("VarManager has not been init.");
return ge::INTERNAL_ERROR;
}
@@ -635,6 +668,9 @@ ge::Status VarManager::RenewCurVarDesc(const std::string &var_name, ge::OpDescPt
GELOGD("VarManager::RenewCurVarDesc var_name = %s.", var_name.c_str());

if (var_resource_ == nullptr) {
REPORT_INNER_ERROR("E19999", "VarManager has not been init, op:%s(%s), session_id:%lu, check invalid "
"when VarManager %s", op_desc->GetName().c_str(), op_desc->GetType().c_str(),
session_id_, __FUNCTION__);
GELOGE(ge::INTERNAL_ERROR, "VarManager has not been init.");
return ge::INTERNAL_ERROR;
}
@@ -786,6 +822,8 @@ Status VarManager::SetMemoryMallocSize(const map<string, string> &options) {

var_mem_logic_base_ = graph_mem_max_size_ + kGraphMemoryBuffer;
if (var_mem_logic_base_ > kMaxMemorySize) {
REPORT_INNER_ERROR("E19999", "var_login_base:%zu can not exeed limit:%zu, session_id:%lu, check invalid "
"when VarManager %s", var_mem_logic_base_, kMaxMemorySize, session_id_, __FUNCTION__);
GELOGE(ge::GE_GRAPH_OPTIONS_INVALID, "kMemoryVarLogicBase : %zu can not exceed max memory size : %zu.",
var_mem_logic_base_, kMaxMemorySize);
return ge::GE_GRAPH_OPTIONS_INVALID;
@@ -793,6 +831,8 @@ Status VarManager::SetMemoryMallocSize(const map<string, string> &options) {

use_max_mem_size_ = graph_mem_max_size_ + var_mem_max_size_;
if (use_max_mem_size_ > kMaxMemorySize) {
REPORT_INNER_ERROR("E19999", "all mem_use size:%zu can not exeed limit:%zu, session_id:%lu, check invalid "
"when VarManager %s", use_max_mem_size_, kMaxMemorySize, session_id_, __FUNCTION__);
GELOGE(ge::GE_GRAPH_OPTIONS_INVALID, "kUseMaxMemorySize : %zu can not exceed max memory size : %zu.",
use_max_mem_size_, kMaxMemorySize);
return ge::GE_GRAPH_OPTIONS_INVALID;
@@ -803,6 +843,8 @@ Status VarManager::SetMemoryMallocSize(const map<string, string> &options) {

Status VarManager::ParseMemoryMallocSize(string &memory_size, size_t &result) {
if (memory_size.empty()) {
REPORT_INNER_ERROR("E19999", "Param memory_size is empty, session_id:%lu, check invalid when VarManager %s",
session_id_, __FUNCTION__);
GELOGE(GE_GRAPH_OPTIONS_INVALID, "Memory malloc size input is empty.");
return GE_GRAPH_OPTIONS_INVALID;
}
@@ -828,15 +870,23 @@ Status VarManager::ParseMemoryMallocSize(string &memory_size, size_t &result) {

for (char c : split) {
if (!isdigit(c)) {
REPORT_INNER_ERROR("E19999", "Param memory_size:%s contains non digit, session_id:%lu, check invalid "
"when VarManager %s", memory_size.c_str(), session_id_, __FUNCTION__);
GELOGE(GE_GRAPH_OPTIONS_INVALID, "Memory malloc size input contains non digit.");
return GE_GRAPH_OPTIONS_INVALID;
}
}
uint64_t num = std::strtoul(split.c_str(), nullptr, 0);
GE_IF_BOOL_EXEC(TypeUtils::CheckUint64MulOverflow(result, static_cast<uint32_t>(num)),
REPORT_INNER_ERROR("E19999", "Param memory_size:%s will overflow after multi all, session_id:%lu, "
"check invalid when VarManager %s", memory_size.c_str(),
session_id_, __FUNCTION__);
GELOGE(FAILED, "Input memory size is out of range.");
return FAILED);
if ((num > kMaxMemorySize) || (result * static_cast<size_t>(num) > kMaxMemorySize)) {
REPORT_INNER_ERROR("E19999", "Param memory_size:%s after multi will exceed limit:%lu, session_id:%lu, "
"check invalid when VarManager %s", memory_size.c_str(), kMaxMemorySize,
session_id_, __FUNCTION__);
GELOGE(FAILED, "Input memory size can not exceed max memory size : %zu.", kMaxMemorySize);
return FAILED;
}
@@ -940,6 +990,7 @@ VarManager *VarManagerPool::GetVarManager(uint64_t session_id) {

VarManager *var_manager = new (std::nothrow) VarManager(session_id);
if (var_manager == nullptr) {
REPORT_INNER_ERROR("E19999", "New VarManager fail, session_id:%lu, when VarManager %s", session_id, __FUNCTION__);
GELOGE(INTERNAL_ERROR,
"VarManager::Instance find session by "
"session_id[%lu] failed.",


+ 4
- 0
ge/graph/manager/host_mem_allocator.cc View File

@@ -34,6 +34,7 @@ uint8_t *HostMemAllocator::Malloc(size_t size) {
std::lock_guard<std::mutex> lock(mutex_);
std::shared_ptr<AlignedPtr> aligned_ptr = MakeShared<AlignedPtr>(size);
if (aligned_ptr == nullptr) {
REPORT_INNER_ERROR("E19999", "New AlignedPtr fail, when HostMemAllocator %s", __FUNCTION__);
GELOGE(INTERNAL_ERROR, "make shared_ptr for AlignedPtr failed");
return nullptr;
}
@@ -44,6 +45,7 @@ uint8_t *HostMemAllocator::Malloc(size_t size) {

Status HostMemAllocator::Free(const void *memory_addr) {
if (memory_addr == nullptr) {
REPORT_INNER_ERROR("E19999", "Param memory_addr is nullptr, check invalid when HostMemAllocator %s", __FUNCTION__);
GELOGE(GE_GRAPH_FREE_FAILED, "Invalid memory pointer");
return GE_GRAPH_FREE_FAILED;
}
@@ -51,6 +53,8 @@ Status HostMemAllocator::Free(const void *memory_addr) {
std::lock_guard<std::mutex> lock(mutex_);
auto it = allocated_blocks_.find(memory_addr);
if (it == allocated_blocks_.end()) {
REPORT_INNER_ERROR("E19999", "Memory_addr is not alloc before, check invalid when HostMemAllocator %s",
__FUNCTION__);
GELOGE(PARAM_INVALID, "Invalid memory pointer");
return PARAM_INVALID;
}


+ 9
- 0
ge/graph/manager/host_mem_manager.cc View File

@@ -39,6 +39,8 @@ Status SharedMemAllocator::Allocate(SharedMemInfo &mem_info) {
rtMallocHostSharedMemoryOut output_para;
rtError_t rt_ret = rtMallocHostSharedMemory(&input_para, &output_para);
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMallocHostSharedMemory fail, ret:0x%X, when SharedMemAllocator %s",
rt_ret, __FUNCTION__);
GELOGE(RT_FAILED, "Call rt api(rtMallocHostSharedMemory) failed, devid:[%u].", device_id);
return GE_GRAPH_MEMORY_ALLOC_FAILED;
}
@@ -59,6 +61,8 @@ Status SharedMemAllocator::DeAllocate(SharedMemInfo &mem_info) {
mem_info.host_aligned_ptr->MutableGet(), mem_info.device_address};
rtError_t rt_ret = rtFreeHostSharedMemory(&free_para);
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtFreeHostSharedMemory fail, ret:0x%X, when SharedMemAllocator %s",
rt_ret, __FUNCTION__);
GELOGE(RT_FAILED, "Call rt api(rtFreeHostSharedMemory) failed, ret: 0x%X.", rt_ret);
return RT_FAILED;
}
@@ -74,6 +78,7 @@ Status HostMemManager::Initialize() {
std::lock_guard<std::recursive_mutex> lock(mutex_);
allocator_ = std::unique_ptr<SharedMemAllocator>(new (std::nothrow) SharedMemAllocator());
if (allocator_ == nullptr) {
REPORT_CALL_ERROR("E19999", "New SharedMemAllocator fail when SharedMemAllocator %s", __FUNCTION__);
GELOGE(GE_GRAPH_MALLOC_FAILED, "Shared memory allocator init failed!");
return GE_GRAPH_MALLOC_FAILED;
}
@@ -94,6 +99,8 @@ Status HostMemManager::MallocSharedMemory(SharedMemInfo &mem_info) {
std::lock_guard<std::recursive_mutex> lock(mutex_);
auto iter = var_memory_base_map_.find(mem_info.op_name);
if (iter != var_memory_base_map_.end()) {
REPORT_INNER_ERROR("E19999", "MemInfo.op_name:%s can't find in var_memory_base_map_ when HostMemManager %s",
mem_info.op_name.c_str(), __FUNCTION__);
GELOGE(FAILED, "Host shared memory for op %s has been malloced", mem_info.op_name.c_str());
return FAILED;
}
@@ -107,6 +114,8 @@ Status HostMemManager::MallocSharedMemory(SharedMemInfo &mem_info) {
Status HostMemManager::QueryVarMemInfo(const string &op_name, uint64_t &base_addr, uint64_t &data_size) {
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (var_memory_base_map_.find(op_name) == var_memory_base_map_.end()) {
REPORT_INNER_ERROR("E19999", "MemInfo.op_name:%s can't find in var_memory_base_map_ when HostMemManager %s",
op_name.c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Find host base base_addr failed,node name:%s!", op_name.c_str());
return INTERNAL_ERROR;
}


+ 6
- 0
ge/graph/manager/memory_api.cc View File

@@ -50,6 +50,8 @@ Status RdmaRemoteRegister(const std::vector<HostVarInfo> &var_info, rtMemType_t
path.append(file_name);
string canonical_path = RealPath(path.c_str());
if (canonical_path.empty()) {
REPORT_INNER_ERROR("E19999", "canonical_path:%s is empty, check invalid when %s",
canonical_path.c_str(), __FUNCTION__);
GELOGE(FAILED, "Failed to get realpath of %s", path.c_str());
return FAILED;
}
@@ -65,12 +67,16 @@ Status RdmaRemoteRegister(const std::vector<HostVarInfo> &var_info, rtMemType_t
auto hcom_remote_mem_register =
(HcclResult(*)(const MemRegisterAddr *, uint32_t))dlsym(handle, "HcomRegRemoteAccessMem");
if (hcom_remote_mem_register == nullptr) {
REPORT_CALL_ERROR("E19999", "Symbol HcomRegRemoteAccessMem can't find in %s, check invalid when %s",
canonical_path.c_str(), __FUNCTION__);
GELOGE(FAILED, "Failed to invoke hcom_remote_mem_register function.");
return FAILED;
}

HcclResult hccl_ret = hcom_remote_mem_register(reg_addrs.get(), table_len);
if (hccl_ret != HCCL_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Call hcom_remote_mem_register failed, ret:%d, when %s",
hccl_ret, __FUNCTION__);
GELOGE(HCCL_E_INTERNAL, "Rdma mem register failed, ret: 0x%X", hccl_ret);
return HCCL_E_INTERNAL;
}


+ 11
- 0
ge/graph/manager/rdma_pool_allocator.cc View File

@@ -81,6 +81,8 @@ Status RdmaPoolAllocator::InitMemory(size_t mem_size) {
auto device_id = GetContext().DeviceId();
GELOGD("Init Rdma Memory with size [%zu] for devid:[%u]", mem_size, device_id);
if (rdma_base_addr_ != nullptr) {
REPORT_INNER_ERROR("E19999", "Param rdma_base_addr_ is nullptr, check invalid when RdmaPoolAllocator %s",
__FUNCTION__);
GELOGE(GE_MULTI_INIT, "Rdma pool has been malloced");
return GE_MULTI_INIT;
}
@@ -100,6 +102,7 @@ Status RdmaPoolAllocator::InitMemory(size_t mem_size) {
// Init with a base block.
auto *base_block = new (std::nothrow) Block(device_id, mem_size, rdma_base_addr_);
if (base_block == nullptr) {
REPORT_CALL_ERROR("E19999", "New Block failed, device_id:%u, when RdmaPoolAllocator %s", device_id, __FUNCTION__);
GELOGE(GE_GRAPH_MALLOC_FAILED, "Block malloc failed");
return GE_GRAPH_MALLOC_FAILED;
}
@@ -118,6 +121,8 @@ uint8_t *RdmaPoolAllocator::Malloc(size_t size, uint32_t device_id) {
block_bin_.erase(it);
block->allocated = true;
if (block->ptr == nullptr) {
REPORT_INNER_ERROR("E19999", "Rdmapool memory address is nullptr, device_id:%u, check invalid when RdmaPoolAllocator %s",
device_id, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Rdmapool memory address is nullptr.");
return nullptr;
}
@@ -150,6 +155,8 @@ uint8_t *RdmaPoolAllocator::Malloc(size_t size, uint32_t device_id) {
Status RdmaPoolAllocator::Free(uint8_t *memory_addr, uint32_t device_id) {
GELOGI("Free rdma memory, device id = %u", device_id);
if (memory_addr == nullptr) {
REPORT_INNER_ERROR("E19999", "Param memory_addr is nullptr, device_id:%u, check invalid when RdmaPoolAllocator %s",
device_id, __FUNCTION__);
GELOGE(GE_GRAPH_FREE_FAILED, "Invalid memory pointer");
return GE_GRAPH_FREE_FAILED;
}
@@ -157,6 +164,8 @@ Status RdmaPoolAllocator::Free(uint8_t *memory_addr, uint32_t device_id) {
std::lock_guard<std::recursive_mutex> lock(mutex_);
auto it = allocated_blocks_.find(memory_addr);
if (it == allocated_blocks_.end()) {
REPORT_INNER_ERROR("E19999", "Param memory_addr is not allocated before, device_id:%u, "
"check invalid when RdmaPoolAllocator %s", device_id, __FUNCTION__);
GELOGE(PARAM_INVALID, "Invalid memory pointer");
return PARAM_INVALID;
}
@@ -199,6 +208,8 @@ void RdmaPoolAllocator::MergeBlocks(Block *dst, Block *src) {

Status RdmaPoolAllocator::GetBaseAddr(uint64_t &base_addr, uint64_t &mem_size) {
if (rdma_base_addr_ == nullptr) {
REPORT_INNER_ERROR("E19999", "Param rdma_base_addr_ is nullptr, check invalid when RdmaPoolAllocator %s",
__FUNCTION__);
GELOGE(INTERNAL_ERROR, "Rdma base addr is nullptr.");
return INTERNAL_ERROR;
}


+ 50
- 3
ge/graph/manager/trans_var_data_utils.cc View File

@@ -35,18 +35,24 @@ class RtContextSwitchGuard {
RtContextSwitchGuard(rtCtxMode_t mode, uint32_t device_id) : last_(nullptr), current_(nullptr) {
auto ret = rtCtxGetCurrent(&last_);
if (ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtCtxGetCurrent failed, device_id:%u, ret:0x%X, when %s",
device_id, ret, __FUNCTION__);
GELOGE(RT_FAILED, "Failed to get current context from rt, error-code %d", ret);
return;
}

ret = rtCtxCreate(&current_, mode, static_cast<int32_t>(device_id));
if (ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtCtxCreate failed, device_id:%u, ret:0x%X, when %s",
device_id, ret, __FUNCTION__);
GELOGE(RT_FAILED, "Failed to create new context for device %u, error-code %d", device_id, ret);
return;
}

ret = rtCtxSetCurrent(current_);
if (ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtCtxSetCurrent failed, device_id:%u, ret:0x%X, when %s",
device_id, ret, __FUNCTION__);
GELOGE(RT_FAILED, "Failed to switch context to normal, context %p, device %u", current_, device_id);
return;
}
@@ -72,6 +78,8 @@ class RtContextSwitchGuard {
int64_t CalcVarSizeInBytes(const GeTensorDesc &desc) {
int64_t var_size = GetSizeByDataType(desc.GetDataType());
if (var_size <= 0) {
REPORT_INNER_ERROR("E19999", "Data type:%s in desc, it's size:%ld < 0, check invalid when %s",
TypeUtils::DataTypeToSerialString(desc.GetDataType()).c_str(), var_size, __FUNCTION__);
GELOGE(PARAM_INVALID, "Failed to calc var data size from data type %s",
TypeUtils::DataTypeToSerialString(desc.GetDataType()).c_str());
return -1;
@@ -89,6 +97,8 @@ Status CopyVarToDevice(const NodePtr &var, const formats::TransResult &trans_res
auto ret = rtMemcpy(var_addr, trans_result.length, reinterpret_cast<void *>(trans_result.data.get()),
trans_result.length, RT_MEMCPY_HOST_TO_DEVICE);
if (ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, op:%s(%s), size:%lu, ret:0x%X, when %s", var->GetName().c_str(),
var->GetType().c_str(), trans_result.length, ret, __FUNCTION__);
GELOGE(RT_FAILED, "Failed to copy memory to device, size %zu", trans_result.length);
return RT_FAILED;
}
@@ -110,6 +120,8 @@ Status CopyVarFromDevice(uint64_t session_id, const NodePtr &var, std::unique_pt

uint8_t *var_addr = VarManager::Instance(session_id)->GetVarMemoryAddr(var_logic, RT_MEMORY_HBM);
if (var_addr == nullptr) {
REPORT_CALL_ERROR("E19999", "Get variable memory addr failed, mem_type:%d, op:%s(%s), session_id:%lu, when %s",
RT_MEMORY_HBM, var->GetName().c_str(), var->GetType().c_str(), session_id, __FUNCTION__);
GELOGE(INTERNAL_ERROR,
"Failed to copy var %s from device, cant not get "
"var addr from logic addr %p",
@@ -124,6 +136,8 @@ Status CopyVarFromDevice(uint64_t session_id, const NodePtr &var, std::unique_pt

std::unique_ptr<uint8_t[]> var_host(new(std::nothrow) uint8_t[var_size_bytes]);
if (var_host == nullptr) {
REPORT_CALL_ERROR("E19999", "New host memory failed, size:%ld, op:%s(%s), session_id:%lu, when %s",
var_size_bytes, var->GetName().c_str(), var->GetType().c_str(), session_id, __FUNCTION__);
GELOGE(OUT_OF_MEMORY, "Failed to malloc rt-host memory, size %ld", var_size_bytes);
return OUT_OF_MEMORY;
}
@@ -131,6 +145,8 @@ Status CopyVarFromDevice(uint64_t session_id, const NodePtr &var, std::unique_pt
ret = rtMemcpy(reinterpret_cast<void *>(var_host.get()), var_size_bytes, reinterpret_cast<void *>(var_addr),
var_size_bytes, RT_MEMCPY_DEVICE_TO_HOST);
if (ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, size:%ld, op:%s(%s), session_id:%lu, ret:0x%X when %s",
var_size_bytes, var->GetName().c_str(), var->GetType().c_str(), session_id, ret, __FUNCTION__);
GELOGE(RT_FAILED,
"Failed to copy var memory from device, var %s, size %ld,"
" rt-error-code %u",
@@ -175,6 +191,12 @@ Status TransVarOnHost(uint8_t *var_data, const VarTransRoad &trans_road, formats
TypeUtils::DataTypeToSerialString(data_type).c_str());
auto ret = formats::TransFormat({src_data, src_format, dst_format, src_shape, dst_shape, data_type}, tmp_result);
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Trans format from %s to %s, shape %s to %s failed, data type:%s, ret:%u, when %s",
TypeUtils::FormatToSerialString(src_format).c_str(),
TypeUtils::FormatToSerialString(dst_format).c_str(),
formats::ShapeToString(src_shape).c_str(),
formats::ShapeToString(dst_shape).c_str(),
TypeUtils::DataTypeToSerialString(data_type).c_str(), ret, __FUNCTION__);
GELOGE(INTERNAL_ERROR,
"Failed to trans format from %s to %s, shape %s to %s, "
"data type %s error code %u",
@@ -195,6 +217,10 @@ Status TransVarOnHost(uint8_t *var_data, const VarTransRoad &trans_road, formats
auto ret = formats::TransDataType({src_data, static_cast<size_t>(src_data_size), src_data_type, dst_data_type},
tmp_result);
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Trans data type from %s to %s failed, input shape %s, data size %ld, ret:%u, "
"when %s", TypeUtils::DataTypeToSerialString(src_data_type).c_str(),
TypeUtils::DataTypeToSerialString(dst_data_type).c_str(),
formats::ShapeToString(input_shape).c_str(), src_data_size, ret, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to trans data type from %s to %s, input shape %s, data size %ld, error code %u",
TypeUtils::DataTypeToSerialString(src_data_type).c_str(),
TypeUtils::DataTypeToSerialString(dst_data_type).c_str(), formats::ShapeToString(input_shape).c_str(),
@@ -202,6 +228,8 @@ Status TransVarOnHost(uint8_t *var_data, const VarTransRoad &trans_road, formats
return ret;
}
} else {
REPORT_INNER_ERROR("E19999", "Trans var data failed, the trans type %s does not supported, check invalid when %s",
trans_info.node_type.c_str(), __FUNCTION__);
GELOGE(UNSUPPORTED, "Failed to trans var data, the trans type %s does not supported",
trans_info.node_type.c_str());
return UNSUPPORTED;
@@ -236,6 +264,8 @@ Status ReAssignVarAddr(uint64_t session_id,

uint8_t *var_addr = VarManager::Instance(session_id)->GetVarMemoryAddr(var_logic, RT_MEMORY_HBM);
if (var_addr == nullptr) {
REPORT_CALL_ERROR("E19999", "Get variable memory addr failed, mem_type:%d, var_name:%s, session_id:%lu, when %s",
RT_MEMORY_HBM, var_name.c_str(), session_id, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to convert var %s logic addr to real addr", var_name.c_str());
return INTERNAL_ERROR;
}
@@ -263,6 +293,8 @@ Status TransVarData(const NodePtr &var, const VarTransRoad &trans_road, uint64_t
// Sync var data from device
std::unique_ptr<uint8_t[]> var_data;
if (trans_road.empty()) {
REPORT_INNER_ERROR("E19999", "Param trans_road is empty, session_id:%lu, check invalid when %s",
session_id, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to get trans_road, trans_road is empty.");
return INTERNAL_ERROR;
}
@@ -314,6 +346,10 @@ Status TransTensor(uint8_t *var_data, const NodePtr &var_src, const NodePtr &var
auto ret = formats::TransDataType(
{var_data, static_cast<size_t>(src_data_shape_size), src_data_datatype, dst_data_datatype}, result);
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Trans data type from %s to %s failed, data size %ld, ret:%u, "
"when %s", TypeUtils::DataTypeToSerialString(src_data_datatype).c_str(),
TypeUtils::DataTypeToSerialString(dst_data_datatype).c_str(),
src_data_shape_size, ret, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "trans var data on host failed");
return ret;
});
@@ -329,7 +365,10 @@ Status CopyTensorFromSrcVarNode(const NodePtr &var_src,
/// unlink edges between var_fp32 and "dst_node" (need fp16) of var_fp32, add edge between var_fp16 and dst_node.
/// need copy value from var_fp32 to var_fp16.
/// [opdesc of var_src and var_dst are checked before passed in, no need to check if they are nullptr]
GE_IF_BOOL_EXEC(var_src == nullptr || var_dst == nullptr, GELOGE(FAILED, "node var is nullptr"); return FAILED);
GE_IF_BOOL_EXEC(var_src == nullptr || var_dst == nullptr,
REPORT_INNER_ERROR("E19999", "Param var_src or var_dst is empty, session_id:%lu, device_id:%u, "
"check invalid when %s", session_id, device_id, __FUNCTION__);
GELOGE(FAILED, "node var is nullptr"); return FAILED);
// src_node output_desc (fp32)
GeTensorDesc output_desc = var_src->GetOpDesc()->GetOutputDesc(0);
auto src_data_type = output_desc.GetDataType();
@@ -447,15 +486,21 @@ Status TransVarDataUtils::TransAllVarData(const vector<NodePtr> &variable_nodes,
}

std::future<Status> f = executor.commit(
[](const ge::NodePtr &node, uint64_t session_id, rtContext_t ctx, uint32_t graph_id) -> Status {
[](const ge::NodePtr &node, uint64_t session_id, rtContext_t ctx, uint32_t graph_id,
const struct ErrorMessage::Context &error_context) -> Status {
ErrorManager::GetInstance().SetErrorContext(error_context);
rtError_t rt_ret = rtCtxSetCurrent(ctx);
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtCtxSetCurrent failed, session_id:%lu, graph_id:%u, ret:0x%X, when %s",
session_id, graph_id, rt_ret, __FUNCTION__);
GELOGE(RT_FAILED, "Failed to set context, error_code is: 0x%X.", rt_ret);
return RT_ERROR_TO_GE_STATUS(rt_ret);
}
uint32_t allocated_graph_id = 0;
Status ret = VarManager::Instance(session_id)->GetAllocatedGraphId(node->GetName(), allocated_graph_id);
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Get allocated GraphId failed, session_id:%lu, graph_id:%u, ret:0x%X, when %s",
session_id, graph_id, ret, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "var has not been allocated, node:%s, graph_id:%u.", node->GetName().c_str(),
graph_id);
return INTERNAL_ERROR;
@@ -480,7 +525,7 @@ Status TransVarDataUtils::TransAllVarData(const vector<NodePtr> &variable_nodes,
}
return SUCCESS;
},
node, session_id, context, graph_id);
node, session_id, context, graph_id, ErrorManager::GetInstance().GetErrorContext());
if (!f.valid()) {
GELOGE(FAILED, "Future is invalid");
return FAILED;
@@ -503,6 +548,8 @@ Status TransVarDataUtils::TransAllVarData(const vector<NodePtr> &variable_nodes,
Status TransVarDataUtils::CopyVarData(const ComputeGraphPtr &compute_graph, uint64_t session_id, uint32_t device_id) {
GELOGD("CopyVarData start: session_id:%lu.", session_id);
if (compute_graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, session_id:%lu, device_id:%u, check invalid when %s",
session_id, device_id, __FUNCTION__);
GELOGE(FAILED, "compute_graph is nullptr");
return FAILED;
}


+ 35
- 0
ge/graph/optimize/graph_optimize.cc View File

@@ -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;
}


+ 2
- 0
ge/graph/passes/addn_pass.cc View File

@@ -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;
}


+ 59
- 0
ge/graph/passes/aicpu_constant_folding_pass.cc View File

@@ -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;
}


+ 4
- 0
ge/graph/passes/assert_pass.cc View File

@@ -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;
}
}


+ 25
- 0
ge/graph/passes/assign_remove_pass.cc View File

@@ -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;
}


+ 21
- 2
ge/graph/passes/atomic_addr_clean_pass.cc View File

@@ -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;
}


+ 47
- 6
ge/graph/passes/attach_stream_label_pass.cc View File

@@ -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);
}
}


+ 38
- 2
ge/graph/passes/bitcast_pass.cc View File

@@ -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;
}


+ 11
- 0
ge/graph/passes/cast_remove_pass.cc View File

@@ -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;
}


+ 5
- 0
ge/graph/passes/cast_translate_pass.cc View File

@@ -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;
}


+ 6
- 0
ge/graph/passes/common_subexpression_elimination_pass.cc View File

@@ -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;
}


+ 30
- 6
ge/graph/passes/compile_nodes_pass.cc View File

@@ -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;
}


+ 1
- 1
ge/graph/passes/compile_nodes_pass.h View File

@@ -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);
};


+ 36
- 0
ge/graph/passes/cond_pass.cc View File

@@ -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;
}


+ 34
- 0
ge/graph/passes/cond_remove_pass.cc View File

@@ -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,


+ 129
- 0
ge/graph/preprocess/graph_preprocess.cc View File

@@ -99,6 +99,7 @@ const int64_t kInvalidDynaimcDimsType = -1;
OpDescPtr CreateTensorShape(const GeTensorDesc &data_tensor) {
GeTensorPtr tensor = MakeShared<GeTensor>();
if (tensor == nullptr) {
REPORT_CALL_ERROR("E19999", "New GeTensor failed when %s", __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Create shared ptr for GeTensor failed");
return nullptr;
}
@@ -110,6 +111,7 @@ OpDescPtr CreateTensorShape(const GeTensorDesc &data_tensor) {
tensor->MutableTensorDesc().SetShape(GeShape());
int32_t dst_shape = 1;
if (tensor->SetData(reinterpret_cast<const uint8_t *>(&dst_shape), sizeof(int32_t)) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set data to tensor failed when %s", __FUNCTION__);
GELOGE(INTERNAL_ERROR, "tensor set data failed");
return nullptr;
}
@@ -117,6 +119,7 @@ OpDescPtr CreateTensorShape(const GeTensorDesc &data_tensor) {
tensor->MutableTensorDesc().SetShape(GeShape(std::vector<int64_t>({dim_cnt})));
unique_ptr<int32_t[]> dst_shape(new (std::nothrow) int32_t[dim_cnt]());
if (dst_shape == nullptr) {
REPORT_CALL_ERROR("E19999", "Malloc buffer failed, size:%zu, when %s", dim_cnt, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Create unique ptr failed");
return nullptr;
}
@@ -126,6 +129,7 @@ OpDescPtr CreateTensorShape(const GeTensorDesc &data_tensor) {

GE_IF_BOOL_EXEC(
tensor->SetData(reinterpret_cast<const uint8_t *>(dst_shape.get()), dim_cnt * sizeof(int32_t)) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Set data to tensor failed when %s", __FUNCTION__);
GELOGE(INTERNAL_ERROR, "tensor set data failed");
return nullptr;)
}
@@ -172,11 +176,15 @@ void AddTransNodeAttr(const std::string &node_type, const GeTensorDesc &input, c
NodePtr CreateTransNode(const std::string &name, const std::string &node_type, const GeTensorDesc &input,
const GeTensorDesc &output, NodePtr &node) {
if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, trans_name:%s, trans_type:%s, check invalid when %s",
name.c_str(), node_type.c_str(), __FUNCTION__);
GELOGE(PARAM_INVALID, "node is null.");
return nullptr;
}
auto graph = node->GetOwnerComputeGraph();
if (graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Owner graph in node is nullptr, trans_name:%s, trans_type:%s, check invalid when %s",
name.c_str(), node_type.c_str(), __FUNCTION__);
GELOGE(PARAM_INVALID, "Owner graph is null, node name:%s.", node->GetName().c_str());
return nullptr;
}
@@ -191,6 +199,8 @@ NodePtr CreateTransNode(const std::string &name, const std::string &node_type, c
}
OpDescPtr op_desc = MakeShared<OpDesc>(name, node_type);
if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed, trans_name:%s, trans_type:%s, when %s",
name.c_str(), node_type.c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Create shared ptr for OpDesc failed");
return nullptr;
}
@@ -203,11 +213,15 @@ NodePtr CreateTransNode(const std::string &name, const std::string &node_type, c
// Default single input and single output
auto ret = op_desc->AddInputDesc(input);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc into op:%s(%s) failed when %s",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add input desc when create node %s type %s", name.c_str(), node_type.c_str());
return nullptr;
}
ret = op_desc->AddOutputDesc(output);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add output desc into op:%s(%s) failed when %s",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add output desc when create node %s type %s", name.c_str(), node_type.c_str());
return nullptr;
}
@@ -224,12 +238,17 @@ NodePtr CreateTransNode(const std::string &name, const std::string &node_type, c
}
ret = op_desc->AddInputDesc(shape_desc->GetOutputDesc(0));
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc into op:%s(%s) failed when %s",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add the first input for reshape %s", name.c_str());
return nullptr;
}

shape_node = graph->AddNode(shape_desc);
if (shape_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed when %s",
shape_desc->GetName().c_str(), shape_desc->GetType().c_str(),
graph->GetName().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add shape node for reshape %s, can not add the shape to graph", name.c_str());
return nullptr;
}
@@ -237,12 +256,18 @@ NodePtr CreateTransNode(const std::string &name, const std::string &node_type, c

auto trans_node = graph->AddNode(op_desc);
if (trans_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed when %s",
op_desc->GetName().c_str(), op_desc->GetType().c_str(),
graph->GetName().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add trans node %s to graph", name.c_str());
return nullptr;
}

if (node_type == RESHAPE) {
if (GraphUtils::AddEdge(shape_node->GetOutDataAnchor(0), trans_node->GetInDataAnchor(1)) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(out_index:0) and op:%s(%s)(in_index:0) failed "
"when %s", shape_node->GetName().c_str(), shape_node->GetType().c_str(),
trans_node->GetName().c_str(), trans_node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add shape node for reshape %s, can not add the edge", name.c_str());
return nullptr;
}
@@ -261,6 +286,9 @@ Status RecoverOneTransNodeForVar(const std::string &name, const TransNodeInfo &t

auto ret = GraphUtils::ReplaceNodeDataAnchors(trans_node, node, {}, {0});
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Replace out anchors of node:%s(%s) by node:%s(%s) failed when %s",
node->GetName().c_str(), node->GetType().c_str(),
trans_node->GetName().c_str(), trans_node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to replace out anchors when recover trans node for %s type %s",
node->GetName().c_str(), node->GetType().c_str());
return INTERNAL_ERROR;
@@ -268,6 +296,9 @@ Status RecoverOneTransNodeForVar(const std::string &name, const TransNodeInfo &t

ret = GraphUtils::AddEdge(node->GetOutDataAnchor(0), trans_node->GetInDataAnchor(0));
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(out_index:0) and op:%s(%s)(in_index:0) failed when %s",
node->GetName().c_str(), node->GetType().c_str(),
trans_node->GetName().c_str(), trans_node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to connect node %s to trans node %s", node->GetName().c_str(),
trans_node->GetName().c_str());
return INTERNAL_ERROR;
@@ -275,6 +306,9 @@ Status RecoverOneTransNodeForVar(const std::string &name, const TransNodeInfo &t

ret = GraphUtils::MoveOutCtrlEdges(node, trans_node);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Move out control edges from node:%s(%s) to node:%s(%s) failed when %s",
node->GetName().c_str(), node->GetType().c_str(),
trans_node->GetName().c_str(), trans_node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to move out control edges from %s to %s when recover trans node.",
node->GetName().c_str(), trans_node->GetName().c_str());
return INTERNAL_ERROR;
@@ -293,6 +327,9 @@ Status RecoverOneTransNodeForVarRef(const std::string &name, const TransNodeInfo

auto ret = GraphUtils::ReplaceNodeDataAnchors(trans_node, node, {0}, {});
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Replace out anchors of node:%s(%s) by node:%s(%s) failed when %s",
node->GetName().c_str(), node->GetType().c_str(),
trans_node->GetName().c_str(), trans_node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to replace int anchors when recover trans node for %s type %s",
node->GetName().c_str(), node->GetType().c_str());
return INTERNAL_ERROR;
@@ -300,6 +337,9 @@ Status RecoverOneTransNodeForVarRef(const std::string &name, const TransNodeInfo

ret = GraphUtils::AddEdge(trans_node->GetOutDataAnchor(0), node->GetInDataAnchor(0));
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(out_index:0) and op:%s(%s)(in_index:0) failed when %s",
trans_node->GetName().c_str(), trans_node->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to connect trans node %s to node %s", trans_node->GetName().c_str(),
node->GetName().c_str());
return INTERNAL_ERROR;
@@ -307,6 +347,9 @@ Status RecoverOneTransNodeForVarRef(const std::string &name, const TransNodeInfo

ret = GraphUtils::MoveInCtrlEdges(node, trans_node);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Move out control edges from node:%s(%s) to node:%s(%s) failed when %s",
node->GetName().c_str(), node->GetType().c_str(),
trans_node->GetName().c_str(), trans_node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to move int control edges from %s to %s when recover trans node.",
node->GetName().c_str(), trans_node->GetName().c_str());
return INTERNAL_ERROR;
@@ -327,6 +370,8 @@ Status UpdateVarFormats(const NodePtr &var, const GeTensorDesc &tensor_desc) {
output_desc.SetOriginDataType(tensor_desc.GetOriginDataType());
output_desc.SetOriginShape(tensor_desc.GetOriginShape());
GE_IF_BOOL_EXEC(var->GetOpDesc()->UpdateOutputDesc(0, output_desc) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Update output desc of node:%s(%s) failed, index:0, when %s",
var->GetName().c_str(), var->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "UpdateOutputDesc failed");
return INTERNAL_ERROR;);
}
@@ -340,6 +385,8 @@ Status UpdateVarFormats(const NodePtr &var, const GeTensorDesc &tensor_desc) {
desc.SetOriginDataType(tensor_desc.GetOriginDataType());
desc.SetOriginShape(tensor_desc.GetOriginShape());
GE_IF_BOOL_EXEC(var->GetOpDesc()->UpdateInputDesc(0, desc) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Update input desc of node:%s(%s) failed, index:0, when %s",
var->GetName().c_str(), var->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "UpdateInputDesc failed");
return INTERNAL_ERROR;)
}
@@ -369,6 +416,9 @@ 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 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.");
GELOGD("Recover trans node %s type %s success", trans_name.c_str(), iter->node_type.c_str());
}
@@ -404,6 +454,9 @@ Status RecoverTransRoadForVarRef(const std::set<NodePtr> &nodes, const VarTransR
}

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",
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.");
}
if (!(road.empty()) && (UpdateVarFormats(var, road.rbegin()->output) != SUCCESS)) {
@@ -419,6 +472,7 @@ VarNamesToRefs CollectVarNamesToRefs(const ComputeGraphPtr &graph) {
VarNamesToRefs names_to_refs;
std::string var_name;
if (graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param graph is nullptr, check invalid when %s", __FUNCTION__);
GELOGE(PARAM_INVALID, "graph is null.");
return names_to_refs;
}
@@ -462,6 +516,8 @@ Status ModifyInputFormatAndShape(NodePtr &node_ptr) {
ge::DataType dt = input->GetDataType();
std::vector<int64_t> dst_shape_dims;
if (TransferShape2NC1HWC0(old_format, old_shape, dt, FORMAT_NC1HWC0, dst_shape_dims) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Transfer shape to NC1HWC0 failed, op:%s(%s), when %s",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Trans shape failed");
return FAILED;
}
@@ -477,6 +533,8 @@ Status ModifyInputFormatAndShape(NodePtr &node_ptr) {
int64_t size = 0;
graphStatus graph_status = TensorUtils::GetTensorMemorySizeInBytes(*output, size);
if (graph_status != ge::GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Get output tensor size failed, op:%s(%s), index:0 when %s",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(graph_status, "GetTensorSizeInBytes failed!");
return FAILED;
}
@@ -521,6 +579,8 @@ Status ModifyDataNetOutputFormatAndShape(OpDescPtr &op_desc, uint32_t index, For
int64_t size = 0;
graphStatus graph_status = TensorUtils::GetTensorMemorySizeInBytes(*output, size);
if (graph_status != ge::GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Get output tensor size failed, op:%s(%s), index:%u when %s",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), index, __FUNCTION__);
GELOGE(graph_status, "GetTensorSizeInBytes failed!");
return FAILED;
}
@@ -630,6 +690,8 @@ Status ProcessInputDtDynShape(NodePtr &node_ptr, bool &is_dynamic_batch, NodePtr
ge::graphStatus input_graph_status = ge::TensorUtils::GetTensorSizeInBytes(*input, input_shape_size);
ge::graphStatus output_graph_status = ge::TensorUtils::GetTensorMemorySizeInBytes(*input, output_shape_size);
if (input_graph_status != ge::GRAPH_SUCCESS && output_graph_status != ge::GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Get input tensor size failed, op:%s(%s), index:0 when %s",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(GRAPH_FAILED, "[Process][InputOp] Get tensor size of op [%s] failed!", node_ptr->GetName().c_str());
return FAILED;
}
@@ -680,6 +742,8 @@ Status ProcessInputNC1HWC0DynShape(NodePtr &node_ptr, bool &is_dynamic_batch, No
GE_CHECK_NOTNULL(switchn_op_desc);
const GeTensorDescPtr &switchn_input = switchn_op_desc->MutableInputDesc(0);
if (ModifyFormatAndShapeForSingleTensor(switchn_input) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Modify format and shape of input:0 in op:%s(%s) failed when %s",
switchn_op_desc->GetName().c_str(), switchn_op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "modify format and shape failed");
return FAILED;
}
@@ -689,6 +753,8 @@ Status ProcessInputNC1HWC0DynShape(NodePtr &node_ptr, bool &is_dynamic_batch, No
old_format = switchn_output->GetFormat();
old_shape = switchn_output->GetShape();
if (ModifyFormatAndShapeForSingleTensor(switchn_output) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Modify format and shape of output:%u in op:%s(%s) failed when %s", i,
switchn_op_desc->GetName().c_str(), switchn_op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "modify format and shape failed");
return FAILED;
}
@@ -789,6 +855,9 @@ Status ProcessNetoutputNodeFp16Nc1hwc0DynShape(GeTensorDesc &src_desc, GeTensorD
std::vector<int64_t> dst_shape_dims;
std::vector<int64_t> src_shape_dims = src_shape.GetDims();
if (TransferShape2NC1HWC0(src_format, src_shape_dims, DT_FLOAT16, FORMAT_NC1HWC0, dst_shape_dims) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Transfer output:0 shape of op:%s(%s) to NC1HWC0 format failed, shape:%s, format:%s, "
"when %s", src_op_desc->GetName().c_str(), src_op_desc->GetType().c_str(),
src_shape.ToString().c_str(), TypeUtils::FormatToSerialString(src_format).c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Trans shape failed");
return FAILED;
}
@@ -799,6 +868,8 @@ Status ProcessNetoutputNodeFp16Nc1hwc0DynShape(GeTensorDesc &src_desc, GeTensorD
auto merge_out = src_op_desc->MutableOutputDesc(0);
GE_CHECK_NOTNULL(merge_out);
if (ModifyFormatAndShapeForSingleTensor(merge_out) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Modify format and shape of output:0 in op:%s(%s) failed when %s",
src_op_desc->GetName().c_str(), src_op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "modify format and shape failed");
return FAILED;
}
@@ -806,6 +877,8 @@ Status ProcessNetoutputNodeFp16Nc1hwc0DynShape(GeTensorDesc &src_desc, GeTensorD
auto merge_in = src_op_desc->MutableInputDesc(i);
GE_CHECK_NOTNULL(merge_in);
if (ModifyFormatAndShapeForSingleTensor(merge_in) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Modify format and shape of input:%u in op:%s(%s) failed when %s", i,
src_op_desc->GetName().c_str(), src_op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "modify format and shape failed");
return FAILED;
}
@@ -931,12 +1004,15 @@ long StringToLongNoThrow(const string &str) {
Status ParseDynamicInputShapeRange(const std::string &shape_range,
std::vector<std::vector<std::pair<int64_t, int64_t>>> &range) {
if (shape_range.size() < 2) {
REPORT_INNER_ERROR("E19999", "shape_range.size:%zu < 2, check invalid when %s", shape_range.size(), __FUNCTION__);
GELOGE(PARAM_INVALID, "Shape range %s is invalid.", shape_range.c_str());
return PARAM_INVALID;
}
// different shape_range of single input are split by ']'
vector<string> shape_range_set = ge::StringUtils::Split(shape_range, ']');
if (shape_range_set.empty()) {
REPORT_INNER_ERROR("E19999", "Shape range %s is not valid. Correct example: \"[1~20,3,3~6,-1],[1~20,3,3~6,-1]\"",
shape_range.c_str());
GELOGE(PARAM_INVALID, "Shape range %s is not valid. Correct example: \"[1~20,3,3~6,-1],[1~20,3,3~6,-1]\"",
shape_range.c_str());
return PARAM_INVALID;
@@ -975,6 +1051,8 @@ Status ParseDynamicInputShapeRange(const std::string &shape_range,
auto range_left = StringToLongNoThrow(range_pair_set.at(0).c_str());
auto range_right = StringToLongNoThrow(range_pair_set.at(1).c_str());
if (range_left < 0 || range_right < 0) {
REPORT_INNER_ERROR("E19999", "Shape range of input is invalid. Given range pair [%ld,%ld], "
"while correct example: \"[1~20,3,3~6,-1],[1~20,3,3~6,-1]\"", range_left, range_right);
GELOGE(PARAM_INVALID,
"Shape range of input is invalid. Given range pair [%ld,%ld], while correct example: "
"\"[1~20,3,3~6,-1],[1~20,3,3~6,-1]\"",
@@ -983,6 +1061,8 @@ Status ParseDynamicInputShapeRange(const std::string &shape_range,
}
range_pair = std::make_pair(range_left, range_right);
} else {
REPORT_INNER_ERROR("E19999", "Shape range of input is invalid. Given %s, "
"while correct example: \"[1~20,3,3~6,-1],[1~20,3,3~6,-1]\"", shape_range.c_str());
GELOGE(PARAM_INVALID,
"Shape range of input is invalid. Given %s, while correct example: \"[1~20,3,3~6,-1],[1~20,3,3~6,-1]\"",
shape_range.c_str());
@@ -1016,6 +1096,8 @@ Status GetDynamicInputShapeRange(const std::vector<GeTensor> &user_input, const
} else if (!enable_dynamic_execute_mode && !enable_input_shape_range) {
return SUCCESS;
} else {
REPORT_INNER_ERROR("E19999", "Graph option: %s and %s should be enabled at the same time, check invalid when %s",
OPTION_EXEC_DYNAMIC_EXECUTE_MODE, OPTION_EXEC_DATA_INPUTS_SHAPE_RANGE, __FUNCTION__);
GELOGE(PARAM_INVALID, "Graph option: %s and %s should be enabled at the same time.",
OPTION_EXEC_DYNAMIC_EXECUTE_MODE, OPTION_EXEC_DATA_INPUTS_SHAPE_RANGE);
return PARAM_INVALID;
@@ -1037,6 +1119,9 @@ Status UpdateDynamicInputShapeRange(const ge::GeAttrValue::INT index,
auto origin_shape = desc.GetShape();
auto current_shape_range_vec = range_vec.at(index);
if (current_shape_range_vec.size() != origin_shape.GetDimNum()) {
REPORT_INNER_ERROR("E19999", "Given shape_range dim num is %zu, current dim:%s num is %zu, not match, "
"check invalid when %s", current_shape_range_vec.size(), origin_shape.ToString().c_str(),
origin_shape.GetDimNum(), __FUNCTION__);
GELOGE(PARAM_INVALID, "Given shape_range dim num is %zu, current dim num is %zu, not match.Pleace Check.",
current_shape_range_vec.size(), origin_shape.GetDimNum());
return PARAM_INVALID;
@@ -1048,6 +1133,8 @@ Status UpdateDynamicInputShapeRange(const ge::GeAttrValue::INT index,
if (left_range == right_range) {
// given shape_range is known dim, check is same as origin or not
if (curr_dim != left_range) {
REPORT_INNER_ERROR("E19999", "Given shape range is %ld, current dim shape is %ld, not match, dim_index:%zu, "
"check invalid when %s", left_range, curr_dim, i, __FUNCTION__);
GELOGE(PARAM_INVALID, "Given shape range is %ld, current dim shape is %ld, not match.Pleace Check.",
left_range, curr_dim);
return PARAM_INVALID;
@@ -1057,6 +1144,9 @@ Status UpdateDynamicInputShapeRange(const ge::GeAttrValue::INT index,
// given shape_range is fix range, check input_shape is in this range or not
if (right_range != UNKNOWN_DIM) {
if ((curr_dim < left_range) || (curr_dim > right_range)) {
REPORT_INNER_ERROR("E19999", "Given shape range is [%ld~%ld], current dim shape is %ld, out of range, "
"dim_index:%zu, check invalid when %s",
left_range, right_range, curr_dim, i, __FUNCTION__);
GELOGE(PARAM_INVALID, "Given shape range is [%ld~%ld], current dim shape is %ld, out of range.Pleace Check.",
left_range, right_range, curr_dim);
return PARAM_INVALID;
@@ -1145,17 +1235,21 @@ Status GraphPrepare::Init(const ge::Graph &graph, uint64_t session_id) {

Status GraphPrepare::CheckGraph() {
if (compute_graph_ == nullptr) {
REPORT_INNER_ERROR("E19999", "compute_graph_ is nullptr, check invalid when GraphPrepare %s", __FUNCTION__);
GELOGE(GE_GRAPH_INIT_FAILED, "Graph prepare init compute graph is NULLPTR");
return GE_GRAPH_INIT_FAILED;
}
auto nodes = compute_graph_->GetAllNodes();
if (nodes.empty()) {
REPORT_INNER_ERROR("E19999", "nodes in graph is empty, check invalid when GraphPrepare %s", __FUNCTION__);
GELOGE(GE_GRAPH_INIT_FAILED, "Invalid graph, no nodes in this graph.");
return GE_GRAPH_INIT_FAILED;
}
for (const NodePtr &node : compute_graph_->GetAllNodes()) {
GE_CHECK_NOTNULL(node);
if (node->GetOpDesc() == nullptr) {
REPORT_INNER_ERROR("E19999", "node without opdesc exist in graph, check invalid when GraphPrepare %s",
__FUNCTION__);
GELOGE(GE_GRAPH_INIT_FAILED, "Check Graph node opdesc is NULL");
return GE_GRAPH_INIT_FAILED;
}
@@ -1191,6 +1285,9 @@ Status GraphPrepare::CheckRefInputNode(const NodePtr &node, const std::string &i
auto input_type = input_op_desc->GetType();
if (input_type == ge::FRAMEWORKOP) {
if (!ge::AttrUtils::GetStr(input_op_desc, ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, input_type)) {
REPORT_INNER_ERROR("E19999", "Get Attr:%s of op:%s(%s) failed when GraphPrepare %s",
ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE.c_str(),
input_op_desc->GetName().c_str(), input_op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(PARAM_INVALID, "Get original type failed.");
return PARAM_INVALID;
}
@@ -1214,11 +1311,15 @@ Status GraphPrepare::CheckRefOp() {
std::set<NodePtr> ref_nodes;
for (const NodePtr &node : compute_graph_->GetDirectNode()) {
if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "nullptr node exist in graph, check invalid when GraphPrepare %s",
__FUNCTION__);
GELOGE(PARAM_INVALID, "param [node] must not be null.");
return PARAM_INVALID;
}
auto op_desc = node->GetOpDesc();
if (op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "node without opdesc exist in graph, check invalid when GraphPrepare %s",
__FUNCTION__);
GELOGE(PARAM_INVALID, "OpDesc of param [node] must not be null.");
return PARAM_INVALID;
}
@@ -1252,11 +1353,15 @@ Status GraphPrepare::SetRtContext(rtContext_t rt_context, rtCtxMode_t mode) {

Status GraphPrepare::AdjustDataOpOutput(const NodePtr &node) {
if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid when GraphPrepare %s",
__FUNCTION__);
GELOGE(GE_GRAPH_GRAPH_NODE_NULL, "Input node is NULL");
return GE_GRAPH_GRAPH_NODE_NULL;
}
OpDescPtr op_desc_ptr = node->GetOpDesc();
if (op_desc_ptr == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node's op_desc is nullptr, check invalid when GraphPrepare %s",
__FUNCTION__);
GELOGE(GE_GRAPH_GRAPH_NODE_NULL, "Input node opdesc is NULL");
return GE_GRAPH_GRAPH_NODE_NULL;
}
@@ -1278,6 +1383,8 @@ Status GraphPrepare::AdjustDataOpOutput(const NodePtr &node) {
TensorUtils::SetSize(output, tensor_size);
graphStatus graph_ret = op_desc_ptr->UpdateOutputDesc(0, output);
if (graph_ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update output desc of op:%s(%s) failed, index:0, when GraphPrepare %s",
op_desc_ptr->GetName().c_str(), op_desc_ptr->GetType().c_str(), __FUNCTION__);
GELOGE(graph_ret, "UpdateOutputDesc fail, graph_ret:%u", graph_ret);
return graph_ret;
}
@@ -1348,6 +1455,8 @@ Status GraphPrepare::UpdateInput(const std::vector<GeTensor> &user_input,
GE_IF_BOOL_EXEC(shape_size == 0 && desc.GetShape().GetDimNum() == 0, shape_size = static_cast<int64_t>(length));
int64_t size = 0;
GE_IF_BOOL_EXEC(ge::TensorUtils::GetSize(desc, size) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Get size of user input tensor failed, index:%ld, "
"when GraphPrepare %s", index, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "TensorUtils GetSize failed");
return FAILED);
bool size_check = (size != 0 && shape_size != size);
@@ -1363,6 +1472,8 @@ Status GraphPrepare::UpdateInput(const std::vector<GeTensor> &user_input,
if (!tune_flag) {
graphStatus graph_ret = op->UpdateInputDesc(0, desc);
if (graph_ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update input desc of op:%s(%s) failed, index:0, when GraphPrepare %s",
op->GetName().c_str(), op->GetType().c_str(), __FUNCTION__);
GELOGE(graph_ret, "UpdateInputDesc fail, graph_ret:%u", graph_ret);
return graph_ret;
}
@@ -1370,6 +1481,8 @@ Status GraphPrepare::UpdateInput(const std::vector<GeTensor> &user_input,
ge::TensorUtils::SetSize(desc, 0);
graph_ret = op->UpdateOutputDesc(0, desc);
if (graph_ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update output desc of op:%s(%s) failed, index:0, when GraphPrepare %s",
op->GetName().c_str(), op->GetType().c_str(), __FUNCTION__);
GELOGE(graph_ret, "UpdateOutputDesc fail, graph_ret:%u", graph_ret);
return graph_ret;
}
@@ -1468,6 +1581,8 @@ Status GraphPrepare::ResourcePairProcess(const std::string &action) {
new ResourcePairRemoveControlPass);
}
} catch (std::bad_alloc &e) {
REPORT_INNER_ERROR("E19999", "bad memory allocation occur when add ResourcePair Pass, when GraphPrepare %s",
__FUNCTION__);
GELOGE(INTERNAL_ERROR, "Add pass failed, bad memory allocation occur, action:%s.", action.c_str());
return INTERNAL_ERROR;
}
@@ -1604,6 +1719,7 @@ Status GraphPrepare::PrepareRunningFormatRefiner() {

Status GraphPrepare::SwitchOpOptimize(ComputeGraphPtr &compute_graph) {
if (compute_graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid when GraphPrepare %s", __FUNCTION__);
GELOGE(GE_GRAPH_NULL_INPUT, "Input Graph is NULL");
return GE_GRAPH_NULL_INPUT;
}
@@ -1619,6 +1735,7 @@ Status GraphPrepare::SwitchOpOptimize(ComputeGraphPtr &compute_graph) {
}
ret = compute_graph->TopologicalSorting();
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Topological sorting failed when GraphPrepare %s", __FUNCTION__);
GELOGE(ret, "Graph topological sort failed, ret:%u.", ret);
return ret;
}
@@ -1629,6 +1746,7 @@ Status GraphPrepare::SwitchOpOptimize(ComputeGraphPtr &compute_graph) {

Status GraphPrepare::GenerateInfershapeGraph(ConstGraphPtr graph) {
if (graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param graph is nullptr, check invalid when GraphPrepare %s", __FUNCTION__);
GELOGE(GE_GRAPH_NULL_INPUT, "Input Graph is NULL");
return GE_GRAPH_NULL_INPUT;
}
@@ -1643,6 +1761,7 @@ Status GraphPrepare::GenerateInfershapeGraph(ConstGraphPtr graph) {
ret = compute_graph_->InferOriginFormat();
GE_DUMP(compute_graph_, "after_inferformat");
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Infer OriginFormat failed when GraphPrepare %s", __FUNCTION__);
GELOGE(ret, "Prepare Graph inferformat failed");
return ret;
}
@@ -1669,6 +1788,7 @@ Status GraphPrepare::CheckConstOp() {
} else if (node_ptr->GetType() == FRAMEWORKOP) {
auto op_desc = node_ptr->GetOpDesc();
if (op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "op_desc is nullptr, check invalid when GraphPrepare %s", __FUNCTION__);
GELOGE(PARAM_INVALID, "Get op desc failed");
return PARAM_INVALID;
}
@@ -1690,6 +1810,8 @@ Status GraphPrepare::VerifyConstOp(const NodePtr &node) {
GE_CHECK_NOTNULL(op_desc);
ConstGeTensorPtr ge_tensor_ptr;
if (!(AttrUtils::GetTensor(op_desc, ATTR_NAME_WEIGHTS, ge_tensor_ptr))) {
REPORT_INNER_ERROR("E19999", "Get Attr:%s of op:%s(%s) failed when GraphPrepare %s", ATTR_NAME_WEIGHTS.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(PARAM_INVALID, "Get value from const attr failed");
return PARAM_INVALID;
}
@@ -1764,6 +1886,8 @@ Status GraphPrepare::CheckUserInput(const std::vector<GeTensor> &user_input) {
data_num++;
GeAttrValue::INT index = 0;
if (!(AttrUtils::GetInt(op, ATTR_NAME_INDEX, index))) {
REPORT_INNER_ERROR("E19999", "Get Attr:%s of op:%s(%s) failed when GraphPrepare %s", ATTR_NAME_WEIGHTS.c_str(),
op->GetName().c_str(), op->GetType().c_str(), __FUNCTION__);
GELOGE(GE_GRAPH_INIT_FAILED, "Get index from attr failed");
return GE_GRAPH_INIT_FAILED;
}
@@ -1868,6 +1992,7 @@ Status GraphPrepare::PrepareOptimize() {
(void)original_graph_passes.AddPass("PrepareOptimize::ReplaceTransShapePass", new ReplaceTransShapePass);
(void)original_graph_passes.AddPass("PrepareOptimize::MarkAgnosticPass", new MarkAgnosticPass);
} catch (std::bad_alloc &e) {
REPORT_INNER_ERROR("E19999", "bad memory allocation occur when add Pass, when GraphPrepare %s", __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Add pass failed, bad memory allocation occurs.");
return INTERNAL_ERROR;
}
@@ -1931,6 +2056,7 @@ Status GraphPrepare::PrepareOptimize() {
// can't move to optimize1/2 directly, may cause more identity insert, cause CI fail
(void)graph_pass.AddPass("PrepareOptimize::HcclMemcpyPass", new HcclMemcpyPass);
} catch (std::bad_alloc &e) {
REPORT_INNER_ERROR("E19999", "bad memory allocation occur when add Pass, when GraphPrepare %s", __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Add pass failed, bad memory allocation occurs.");
return INTERNAL_ERROR;
}
@@ -1947,6 +2073,7 @@ Status GraphPrepare::PrepareOptimize() {

ret = compute_graph_->TopologicalSorting();
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Topological sorting failed when GraphPrepare %s", __FUNCTION__);
GELOGE(ret, "Graph topological sort failed, ret:%u.", ret);
return ret;
}
@@ -2017,6 +2144,7 @@ Status GraphPrepare::ProcessNetOutput() {
graph_passes_before_infershape.AddPass("ProcessNetOutput::DataPass",
new (std::nothrow) DataPass); // Add NetOutput first.
} catch (std::bad_alloc) {
REPORT_INNER_ERROR("E19999", "bad memory allocation occur when add Pass, when GraphPrepare %s", __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Add pass failed, bad memory allocation occurs.");
return INTERNAL_ERROR;
}
@@ -2056,6 +2184,7 @@ Status GraphPrepare::CheckAndUpdateInput(const std::vector<GeTensor> &user_input
} else {
ret = compute_graph_->TopologicalSorting();
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Topological sorting failed when GraphPrepare %s", __FUNCTION__);
GELOGE(ret, "graph prepare error: compute_graph_->Topological Sorting");
return FAILED;
}


+ 46
- 0
ge/graph/preprocess/insert_op/ge_aipp_op.cc View File

@@ -110,6 +110,12 @@ Status GetDataDimN(const ge::NodePtr &data_node, ge::Format format, int64_t &bat
batch = shape[NHWC_DIM_N];
return SUCCESS;
default:
REPORT_INPUT_ERROR("E10001", std::vector<std::string>({"parameter", "value", "reason"}),
std::vector<std::string>({
data_node->GetName() + " format",
TypeUtils::FormatToSerialString(format),
"only format " + TypeUtils::FormatToSerialString(FORMAT_NCHW) + " and "
+ TypeUtils::FormatToSerialString(FORMAT_NHWC) + " supported"}));
GELOGE(PARAM_INVALID, "Not support data format: %s", TypeUtils::FormatToSerialString(format).c_str());
return PARAM_INVALID;
}
@@ -156,6 +162,7 @@ Format GetAndCheckFormat() {
Status AippOp::Init(domi::AippOpParams *aipp_params) {
aipp_params_ = new (std::nothrow) domi::AippOpParams();
if (aipp_params_ == nullptr) {
REPORT_CALL_ERROR("E19999", "New AippOpParams failed when AippOp %s", __FUNCTION__);
return FAILED;
}
aipp_params_->CopyFrom(*aipp_params);
@@ -190,6 +197,13 @@ Status AippOp::InsertAippToGraph(ComputeGraphPtr &graph, std::string &aippConfig

auto ret = GraphUtils::InsertNodeBetweenDataAnchors(out_in_anchors.first, out_in_anchors.second, aipp);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Insert aipp:%s(%s) node between op:%s(%s) and op:%s:%s failed when AippOp %s",
aipp->GetName().c_str(), aipp->GetType().c_str(),
out_in_anchors.first->GetOwnerNode()->GetName().c_str(),
out_in_anchors.first->GetOwnerNode()->GetType().c_str(),
out_in_anchors.second->GetOwnerNode()->GetName().c_str(),
out_in_anchors.second->GetOwnerNode()->GetType().c_str(),
__FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to link edges for aipp node %s", aipp->GetName().c_str());
return INTERNAL_ERROR;
}
@@ -209,6 +223,11 @@ Status AippOp::InsertAippToGraph(ComputeGraphPtr &graph, std::string &aippConfig
auto &aipp = iter->second;
auto ret = out_in_anchors.second->LinkFrom(aipp->GetOutDataAnchor(0));
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "link aipp:%s(%s) to peer op:%s(%s) failed when AippOp %s",
aipp->GetName().c_str(), aipp->GetType().c_str(),
out_in_anchors.second->GetOwnerNode()->GetName().c_str(),
out_in_anchors.second->GetOwnerNode()->GetType().c_str(),
__FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to link aipp %s to the peer node %s", aipp->GetName().c_str(),
out_in_anchors.second->GetOwnerNode()->GetName().c_str());
return INTERNAL_ERROR;
@@ -224,6 +243,7 @@ NodePtr AippOp::CreateAipp(const OutDataAnchorPtr &out_anchor,
std::string current_name = node->GetName() + "_" + std::to_string(out_anchor->GetIdx()) + "_huawei_aipp";
auto aipp_opdesc_ptr = MakeShared<OpDesc>(current_name, AIPP);
if (aipp_opdesc_ptr == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed when AippOp %s", __FUNCTION__);
GELOGE(OUT_OF_MEMORY, "Failed to alloc aipp desc, name %s", current_name.c_str());
return nullptr;
}
@@ -250,6 +270,9 @@ NodePtr AippOp::CreateAipp(const OutDataAnchorPtr &out_anchor,
// but the InferFormat process before InferShape can not infer the format
// if the tensor on the Aipp has an unknown shape
if (aipp_opdesc_ptr->UpdateInputDesc(kAippImageInputIndex, opdesc_src_data) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update the output desc from node:%s(%s) to aipp:%s(%s) failed when AippOp %s",
node_desc->GetName().c_str(), node_desc->GetType().c_str(),
aipp_opdesc_ptr->GetName().c_str(), aipp_opdesc_ptr->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to update the output desc from node %s to aipp %s", node_desc->GetName().c_str(),
aipp_opdesc_ptr->GetName().c_str());
return nullptr;
@@ -341,6 +364,8 @@ Status AippOp::GetAndCheckTarget(const ComputeGraphPtr &graph, int rank, NodePtr
GeAttrValue::NAMED_ATTRS aipp_attr;
ConvertParamToAttr(aipp_attr);
if (!AttrUtils::SetNamedAttrs(data_opdesc, ATTR_NAME_AIPP, aipp_attr)) {
REPORT_INNER_ERROR("E19999", "Set Attr:%s for op:%s(%s) failed when AippOp %s", ATTR_NAME_AIPP.c_str(),
data_opdesc->GetName().c_str(), data_opdesc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Set name attrs for Data node failed. id: %d", rank);
return INTERNAL_ERROR;
}
@@ -371,12 +396,18 @@ Status AippOp::GetStaticTargetNode(const ComputeGraphPtr &graph, NodePtr &data_n
std::string related_node_name;
if (AttrUtils::GetStr(data_node->GetOpDesc(), kMbatchSwitchnName, related_node_name)) {
if (related_node_name.empty()) {
REPORT_INNER_ERROR("E19999", "The data node %s has switchn node flag, but the value of attr:%s is empty, "
"check invalid when AippOp %s", data_node->GetName().c_str(),
kMbatchSwitchnName, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "The data node %s has switchn node flag, but the value is empty",
data_node->GetName().c_str());
return INTERNAL_ERROR;
}
auto switchn = graph->FindNode(related_node_name);
if (switchn == nullptr) {
REPORT_INNER_ERROR("E19999", "The data node %s has switchn node %s, but can not find it on the graph, "
"check invalid when AippOp %s", data_node->GetName().c_str(), related_node_name.c_str(),
__FUNCTION__);
GELOGE(INTERNAL_ERROR, "The data node %s has switchn node %s, but can not find it on the graph",
data_node->GetName().c_str(), related_node_name.c_str());
return INTERNAL_ERROR;
@@ -466,6 +497,9 @@ Status AippOp::GetTargetPosition(ComputeGraphPtr graph, NodePtr &target_input,
for (const auto &name : func_desc->GetSubgraphInstanceNames()) {
const auto &subgraph = graph->GetSubgraph(name);
if (subgraph == nullptr) {
REPORT_INNER_ERROR("E19999", "Subgraph:%s of op:%s(%s) not find in graph:%s, check invalid when AippOp %s",
name.c_str(), func_desc->GetName().c_str(), func_desc->GetType().c_str(),
graph->GetName().c_str(), __FUNCTION__);
GELOGE(GE_GRAPH_EMPTY_SUBGRAPH, "Subgraph not found, name: %s", name.c_str());
return GE_GRAPH_EMPTY_SUBGRAPH;
}
@@ -666,11 +700,15 @@ Status AippOp::GenerateOpDesc(OpDescPtr op_desc) {
// Add two InputDesc, add the second after the first one is added successfully.
if ((op_desc->AddInputDesc(GeTensorDesc()) != GRAPH_SUCCESS) ||
(op_desc->AddInputDesc(GeTensorDesc()) != GRAPH_SUCCESS)) {
REPORT_CALL_ERROR("E19999", "Add input desc into op:%s(%s) failed when AippOp %s",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(FAILED, "failed to add input desc");
return FAILED;
}

if (op_desc->AddOutputDesc(GeTensorDesc()) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add output desc into op:%s(%s) failed when AippOp %s",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(FAILED, "add output desc failed.");
return FAILED;
}
@@ -678,6 +716,8 @@ Status AippOp::GenerateOpDesc(OpDescPtr op_desc) {
ConvertParamToAttr(aipp_attrs);

GE_IF_BOOL_EXEC(!AttrUtils::SetNamedAttrs(op_desc, ATTR_NAME_AIPP, aipp_attrs),
REPORT_INNER_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed when AippOp %s", ATTR_NAME_AIPP.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(FAILED, "failed to set ATTR_NAME_AIPP");
return FAILED);

@@ -858,12 +898,18 @@ Status AippOp::AddNodeToGraph(const NodePtr &aipp_node, int64_t max_dynamic_aipp
// add node desc for aipp node
auto stat3 = aipp_node->GetOpDesc()->UpdateInputDesc(kAippParamsInputIndex, output_tensor);
if (stat1 != GRAPH_SUCCESS || stat2 != GRAPH_SUCCESS || stat3 != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add and Update InputDesc to op:%s(%s) failed, index:%d, when AippOp %s",
aipp_node->GetName().c_str(), aipp_node->GetType().c_str(), kAippParamsInputIndex, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "node process desc failed!");
return INTERNAL_ERROR;
}
// aipp_node should have two input data but now tbe only one input
if (GraphUtils::AddEdge(aipp_data_node_ptr->GetOutDataAnchor(kAippDataOutputIndex),
aipp_node->GetInDataAnchor(kAippParamsInputIndex)) != GRAPH_SUCCESS) {
REPORT_INNER_ERROR("E19999", "Add edge between op:%s(%s)(out_index:%u) and op:%s(%s)(in_index:%u) failed "
"when AippOp %s", aipp_data_node_ptr->GetName().c_str(), aipp_data_node_ptr->GetType().c_str(),
kAippDataOutputIndex, aipp_node->GetName().c_str(), aipp_node->GetType().c_str(),
kAippParamsInputIndex, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Add Anchor anchor between aipp data node and aipp failed!");
return INTERNAL_ERROR;
}


+ 27
- 0
ge/graph/preprocess/insert_op/util_insert_aipp_op.cc View File

@@ -306,6 +306,9 @@ Status InsertNewOpUtil::FindMaxSizeNode(const ComputeGraphPtr &graph, const Node
for (const auto &name : func_desc->GetSubgraphInstanceNames()) {
const auto &subgraph = graph->GetSubgraph(name);
if (subgraph == nullptr) {
REPORT_INNER_ERROR("E19999", "Subgraph:%s of op:%s(%s) not find in graph:%s, check invalid "
"when InsertNewOpUtil %s", name.c_str(), func_desc->GetName().c_str(),
func_desc->GetType().c_str(), graph->GetName().c_str(), __FUNCTION__);
GELOGE(GE_GRAPH_EMPTY_SUBGRAPH, "Subgraph not found, name: %s", name.c_str());
return GE_GRAPH_EMPTY_SUBGRAPH;
}
@@ -325,6 +328,9 @@ Status InsertNewOpUtil::FindMaxSizeNode(const ComputeGraphPtr &graph, const Node

uint32_t parent_index = 0;
if (!AttrUtils::GetInt(src_op, ATTR_NAME_PARENT_NODE_INDEX, parent_index)) {
REPORT_INNER_ERROR("E19999", "Get Attr:%s of op:%s(%s) failed when InsertNewOpUtil %s",
ATTR_NAME_PARENT_NODE_INDEX.c_str(),
src_op->GetName().c_str(), src_op->GetType().c_str(), __FUNCTION__);
GELOGE(FAILED, "Parent index not found, name: %s", src_op->GetName().c_str());
return FAILED;
}
@@ -376,12 +382,16 @@ Status InsertNewOpUtil::UpdateCaseNode(const ComputeGraphPtr &graph, const NodeP

auto ret = data_opdesc->UpdateOutputDesc(0, *input_desc);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update OutputDesc to op:%s(%s) failed, index:0, when InsertNewOpUtil %s",
data_opdesc->GetName().c_str(), data_opdesc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to update data %s output using case %s", data->GetName().c_str(),
case_node->GetName().c_str());
return INTERNAL_ERROR;
}
ret = data_opdesc->UpdateInputDesc(0, *input_desc);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update InputDesc to op:%s(%s) failed, index:0, when InsertNewOpUtil %s",
data_opdesc->GetName().c_str(), data_opdesc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to update data %s input using case %s", data->GetName().c_str(),
case_node->GetName().c_str());
return INTERNAL_ERROR;
@@ -404,11 +414,15 @@ Status InsertNewOpUtil::UpdatePrevNodeByAipp(NodePtr &node, std::set<NodePtr> &s
int64_t size = 0;
graphStatus graph_ret = ge::TensorUtils::GetSize(*aipp_input, size);
if (graph_ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Get input size of op:%s(%s), index:0, failed, when InsertNewOpUtil %s",
aipp_op_desc->GetName().c_str(), aipp_op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(FAILED, "UpdateOutputDesc fail, graph_ret:%d", graph_ret);
return FAILED;
}
GELOGI("Get input size [%ld] from aipp [%s].", size, aipp_op_desc->GetName().c_str());
if (size == 0) {
REPORT_CALL_ERROR("E19999", "Tensor size of op:%s(%s) is 0, input_index:0, check invalid when InsertNewOpUtil %s",
aipp_op_desc->GetName().c_str(), aipp_op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(FAILED, "Can not get size from aipp [%s]", aipp_op_desc->GetName().c_str());
return FAILED;
}
@@ -495,12 +509,16 @@ Status InsertNewOpUtil::UpdateDataBySwitchN(const NodePtr &switchn, const NodePt

auto ret = data_opdesc->UpdateOutputDesc(0, *input_desc);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update OutputDesc to op:%s(%s) failed, index:0, when InsertNewOpUtil %s",
data_opdesc->GetName().c_str(), data_opdesc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to update data %s output using switchn %s", data->GetName().c_str(),
switchn->GetName().c_str());
return INTERNAL_ERROR;
}
ret = data_opdesc->UpdateInputDesc(0, *input_desc);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update InputDesc to op:%s(%s) failed, index:0, when InsertNewOpUtil %s",
data_opdesc->GetName().c_str(), data_opdesc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to update data %s input using switchn %s", data->GetName().c_str(),
switchn->GetName().c_str());
return INTERNAL_ERROR;
@@ -600,6 +618,9 @@ Status InsertNewOpUtil::GetAllAipps(const NodePtr &data_node, const NodePtr &nod
for (const auto &name : op->GetSubgraphInstanceNames()) {
const auto &subgraph = graph->GetSubgraph(name);
if (subgraph == nullptr) {
REPORT_INNER_ERROR("E19999", "Subgraph:%s of op:%s(%s) not find in graph:%s, check invalid "
"when InsertNewOpUtil %s", name.c_str(), op->GetName().c_str(),
op->GetType().c_str(), graph->GetName().c_str(), __FUNCTION__);
GELOGE(GE_GRAPH_EMPTY_SUBGRAPH, "Subgraph not found, name: %s", name.c_str());
return GE_GRAPH_EMPTY_SUBGRAPH;
}
@@ -611,6 +632,9 @@ Status InsertNewOpUtil::GetAllAipps(const NodePtr &data_node, const NodePtr &nod
GE_CHECK_NOTNULL(src_op);
uint32_t parent_index = 0;
if (!AttrUtils::GetInt(src_op, ATTR_NAME_PARENT_NODE_INDEX, parent_index)) {
REPORT_INNER_ERROR("E19999", "Get Attr:%s of op:%s(%s) failed when InsertNewOpUtil %s",
ATTR_NAME_PARENT_NODE_INDEX.c_str(),
src_op->GetName().c_str(), src_op->GetType().c_str(), __FUNCTION__);
GELOGE(FAILED, "Parent index not found, name: %s", src_op->GetName().c_str());
return FAILED;
}
@@ -750,6 +774,9 @@ Status InsertNewOpUtil::SetModelInputDims(NodePtr &data_node, NodePtr &aipp_node
}
GELOGD("After set N or H/W to -1, the model input dims: %s.", formats::JoinToString(model_input_dims).c_str());
if (!AttrUtils::SetListInt(data_opdesc, ATTR_NAME_INPUT_DIMS, model_input_dims)) {
REPORT_INNER_ERROR("E19999", "Set Attr:%s of op:%s(%s) failed when InsertNewOpUtil %s",
ATTR_NAME_INPUT_DIMS.c_str(),
data_opdesc->GetName().c_str(), data_opdesc->GetType().c_str(), __FUNCTION__);
GELOGE(FAILED, "SetListInt of %s failed.", ATTR_NAME_INPUT_DIMS.c_str());
return FAILED;
}


+ 263
- 28
ge/graph/preprocess/multi_batch_copy_graph.cc View File

@@ -78,6 +78,7 @@ inline bool IsGetNextType(const NodePtr &node) {
NodePtr InsertMergeNodeToGraph(const std::string &name, size_t input_num, const ComputeGraphPtr &graph) {
OpDescPtr desc = MakeShared<OpDesc>();
if (desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed when %s", __FUNCTION__);
GELOGE(OUT_OF_MEMORY, "Failed to insert merge node, name %s", name.c_str());
return nullptr;
}
@@ -87,24 +88,33 @@ NodePtr InsertMergeNodeToGraph(const std::string &name, size_t input_num, const
for (size_t i = 0; i < input_num; ++i) {
auto ret = desc->AddInputDesc("x" + std::to_string(i), tensor_desc);
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, input desc name:%s, when %s",
desc->GetName().c_str(), desc->GetType().c_str(),
("x" + std::to_string(i)).c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to create merge node %s, failed to add input %zu, error-code %u",
name.c_str(), i, ret);
return nullptr);
}
auto ret = desc->AddOutputDesc("y", tensor_desc);
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed, output desc name:%s, when %s",
desc->GetName().c_str(), desc->GetType().c_str(), "y", __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to create merge node %s, failed to add output 'y', error-code %u",
name.c_str(), ret);
return nullptr);
tensor_desc.SetDataType(DT_INT32);
ret = desc->AddOutputDesc("value_index", tensor_desc);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed, output desc name:%s, when %s",
desc->GetName().c_str(), desc->GetType().c_str(), "value_index", __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to create merge node %s, failed to add output 'value_index', error-code %u",
name.c_str(), ret);
return nullptr;
}

if (!AttrUtils::SetBool(desc, ATTR_INSERT_BY_MBATCH, true)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed when %s", ATTR_INSERT_BY_MBATCH.c_str(),
desc->GetName().c_str(), desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to create merge node %s, failed to add attr", name.c_str());
return nullptr;
}
@@ -114,13 +124,18 @@ NodePtr InsertMergeNodeToGraph(const std::string &name, size_t input_num, const
NodePtr InsertCopyNode(const NodePtr &node, size_t n) {
const std::string &name = node->GetName() + "_ascend_mbatch_batch_" + std::to_string(n);
auto src_op_desc = node->GetOpDesc();
GE_IF_BOOL_EXEC(src_op_desc == nullptr, GELOGE(INTERNAL_ERROR, "Failed to copy node %s to %s, the OpDesc is null",
node->GetName().c_str(), name.c_str());
GE_IF_BOOL_EXEC(src_op_desc == nullptr,
REPORT_INNER_ERROR("E19999", "Param opdesc in node is nullptr, check invalid when %s", __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to copy node %s to %s, the OpDesc is null",
node->GetName().c_str(), name.c_str());
return nullptr);

auto desc = AttrUtils::CopyOpDesc(src_op_desc);
GE_IF_BOOL_EXEC(desc == nullptr, GELOGE(OUT_OF_MEMORY, "Failed to create op desc for copy node for node %s name %s",
node->GetName().c_str(), name.c_str());
GE_IF_BOOL_EXEC(desc == nullptr,
REPORT_CALL_ERROR("E19999", "Copy OpDesc from op:%s(%s) failed when %s",
src_op_desc->GetName().c_str(), src_op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(OUT_OF_MEMORY, "Failed to create op desc for copy node for node %s name %s",
node->GetName().c_str(), name.c_str());
return nullptr);

desc->SetName(name);
@@ -128,6 +143,8 @@ NodePtr InsertCopyNode(const NodePtr &node, size_t n) {
for (uint32_t i = 0; i < node->GetAllInDataAnchorsSize(); ++i) {
auto input_desc = desc->MutableInputDesc(i);
GE_IF_BOOL_EXEC(input_desc == nullptr,
REPORT_INNER_ERROR("E19999", "Input desc of op:%s(%s) not exist, index:%u, check invalid when %s",
desc->GetName().c_str(), desc->GetType().c_str(), i, __FUNCTION__);
GELOGW("Get null input desc by index %u from node %s when copy from %s", i,
desc->GetName().c_str(), node->GetName().c_str());
continue);
@@ -137,6 +154,8 @@ NodePtr InsertCopyNode(const NodePtr &node, size_t n) {
for (uint32_t i = 0; i < node->GetAllOutDataAnchorsSize(); ++i) {
auto output_desc = desc->MutableOutputDesc(i);
GE_IF_BOOL_EXEC(output_desc == nullptr,
REPORT_INNER_ERROR("E19999", "Ouput desc of op:%s(%s) not exist, index:%u, check invalid when %s",
desc->GetName().c_str(), desc->GetType().c_str(), i, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to get output desc by index %u from node %s when copy from %s", i,
desc->GetName().c_str(), node->GetName().c_str());
return nullptr);
@@ -145,6 +164,8 @@ NodePtr InsertCopyNode(const NodePtr &node, size_t n) {
}
const std::string &batch_label = "Batch_" + std::to_string(n);
if (!AttrUtils::SetStr(desc, ATTR_NAME_BATCH_LABEL, batch_label)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed when %s", ATTR_NAME_BATCH_LABEL.c_str(),
desc->GetName().c_str(), desc->GetType().c_str(), __FUNCTION__);
GELOGE(FAILED, "set attr ATTR_NAME_BATCH_LABEL failed, node:%s.", name.c_str());
return nullptr;
}
@@ -167,6 +188,7 @@ bool IsAllDimsPositive(const std::vector<int64_t> &dims) {
NodePtr InsertConst(const std::string &name, const ComputeGraphPtr &graph) {
auto desc = MakeShared<OpDesc>();
if (desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed when %s", __FUNCTION__);
GELOGE(OUT_OF_MEMORY, "Failed to create const op %s, out of memory", name.c_str());
return nullptr;
}
@@ -175,14 +197,20 @@ NodePtr InsertConst(const std::string &name, const ComputeGraphPtr &graph) {
GeTensor tensor;
tensor.SetData(std::vector<uint8_t>({0}));
if (!AttrUtils::SetTensor(desc, ATTR_NAME_WEIGHTS, tensor)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed when %s", ATTR_NAME_WEIGHTS.c_str(),
desc->GetName().c_str(), desc->GetType().c_str(), __FUNCTION__);
GELOGE(OUT_OF_MEMORY, "Failed to init tensor value for const %s", name.c_str());
return nullptr;
}
if (!AttrUtils::SetBool(desc, ATTR_INSERT_BY_MBATCH, true)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed when %s", ATTR_INSERT_BY_MBATCH.c_str(),
desc->GetName().c_str(), desc->GetType().c_str(), __FUNCTION__);
GELOGE(OUT_OF_MEMORY, "Failed to set insert flag for const node %s", name.c_str());
return nullptr;
}
if (desc->AddOutputDesc(GeTensorDesc()) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed when %s",
desc->GetName().c_str(), desc->GetType().c_str(), __FUNCTION__);
GELOGE(OUT_OF_MEMORY, "Failed to add output desc for const node %s", name.c_str());
return nullptr;
}
@@ -371,6 +399,9 @@ Status MultiBatchGraphCopyer::GetEnterNodesGroupByFrame(map<string, vector<NodeP
GE_CHECK_NOTNULL(op_desc);
string frame_name;
if (!AttrUtils::GetStr(op_desc, ENTER_ATTR_FRAME_NAME, frame_name)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed when MultiBatchGraphCopyer %s",
ENTER_ATTR_FRAME_NAME.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(FAILED, "Get attr frame_name of enter[%s] failed.", node->GetName().c_str());
return FAILED;
}
@@ -578,7 +609,9 @@ Status MultiBatchGraphCopyer::LabelInBatchBranchStatus() {
GELOGD("Start label in batch branch status.");
for (const auto &data : origin_data_nodes_) {
auto op_desc = data->GetOpDesc();
GE_IF_BOOL_EXEC(op_desc == nullptr, GELOGE(PARAM_INVALID, "Op desc is nullptr.");
GE_IF_BOOL_EXEC(op_desc == nullptr,
REPORT_INNER_ERROR("E19999", "op_desc in origin_data_nodes_ is nullptr, check invalid when %s", __FUNCTION__);
GELOGE(PARAM_INVALID, "Op desc is nullptr.");
return PARAM_INVALID);
LabelStatusForData(data);
if (!GetLocalOmgContext().dynamic_node_type.empty()) {
@@ -853,6 +886,9 @@ NodePtr MultiBatchGraphCopyer::FindSwitchnNodeForDataEdge(const OutDataAnchorPtr
GELOGI("The output idx %d has %zu referenced nums.", output_idx, data_out_anchor->GetPeerInDataAnchors().size());
for (const auto &peer_in_anchor : data_out_anchor->GetPeerInDataAnchors()) {
if (peer_in_anchor->GetOwnerNode()->GetOpDesc() == nullptr) {
REPORT_INNER_ERROR("E19999", "peer op_desc of op:%s(%s)'s out_index:%d anchor exist nullptr, "
"check invalid when MultiBatchGraphCopyer %s",
data_node->GetName().c_str(), data_node->GetType().c_str(), output_idx, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Op desc should not be nullptr.");
return nullptr;
}
@@ -862,6 +898,11 @@ NodePtr MultiBatchGraphCopyer::FindSwitchnNodeForDataEdge(const OutDataAnchorPtr
}
if (output_idx >= static_cast<int>(getnext_nodes_to_switchn_.size()) ||
referenced_index >= getnext_nodes_to_switchn_.at(output_idx).size()) {
REPORT_INNER_ERROR("E19999", "output_index:%d of op:%s(%s) > getnext_nodes_to_switchn_.size():%zu or "
"referenced_index:%zu >= getnext_nodes_to_switchn_.at(output_idx).size():%zu, "
"check invalid when %s", output_idx,
data_node->GetName().c_str(), data_node->GetType().c_str(), getnext_nodes_to_switchn_.size(),
referenced_index, getnext_nodes_to_switchn_.at(output_idx).size(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Output idx is %d, referenced index is %zu", output_idx, referenced_index);
return nullptr;
}
@@ -891,6 +932,10 @@ Status MultiBatchGraphCopyer::CopyInDataEdges(const NodePtr &origin_node, int ba
if (switchn != nullptr) {
auto ret = GraphUtils::AddEdge(switchn->GetOutDataAnchor(batch_num), dst_anchor);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(out_index:%d) and op:%s(%s)(in_index:%d) failed "
"when MultiBatchGraphCopyer %s", switchn->GetName().c_str(), switchn->GetType().c_str(),
batch_num, copyed_node->GetName().c_str(), copyed_node->GetType().c_str(),
in_anchor->GetIdx(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add data edge between %s(%d) to %s(%d), error-code %u",
switchn->GetName().c_str(), batch_num, copyed_node->GetName().c_str(), in_anchor->GetIdx(),
ret);
@@ -906,6 +951,11 @@ Status MultiBatchGraphCopyer::CopyInDataEdges(const NodePtr &origin_node, int ba
auto src_batch_node = batch_branch_iter->second.at(batch_num);
auto ret = GraphUtils::AddEdge(src_batch_node->GetOutDataAnchor(origin_src_anchor->GetIdx()), dst_anchor);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(out_index:%d) and op:%s(%s)(in_index:%d) failed "
"when MultiBatchGraphCopyer %s", src_batch_node->GetName().c_str(),
src_batch_node->GetType().c_str(), origin_src_anchor->GetIdx(),
copyed_node->GetName().c_str(), copyed_node->GetType().c_str(),
in_anchor->GetIdx(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add data edge between %s(%d) to %s(%d), error-code %u",
src_batch_node->GetName().c_str(), batch_num, copyed_node->GetName().c_str(), in_anchor->GetIdx(), ret);
return INTERNAL_ERROR;
@@ -917,6 +967,11 @@ Status MultiBatchGraphCopyer::CopyInDataEdges(const NodePtr &origin_node, int ba

auto ret = GraphUtils::AddEdge(origin_src_anchor, dst_anchor);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(out_index:%d) and op:%s(%s)(in_index:%d) failed "
"when MultiBatchGraphCopyer %s", origin_src_node->GetName().c_str(),
origin_src_node->GetType().c_str(), origin_src_anchor->GetIdx(),
copyed_node->GetName().c_str(), copyed_node->GetType().c_str(),
in_anchor->GetIdx(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add data edge between origin node %s(%d) to copyed %s(%d)",
origin_src_node->GetName().c_str(), origin_src_anchor->GetIdx(), copyed_node->GetName().c_str(),
dst_anchor->GetIdx());
@@ -936,6 +991,10 @@ Status MultiBatchGraphCopyer::CopyInControlEdges(const NodePtr &node, int batch_
// reconnect data node
auto ret = GraphUtils::AddEdge(switchn_iter->second->GetOutControlAnchor(), copyed_node->GetInControlAnchor());
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add ctrl edge between op:%s(%s) and op:%s(%s) failed "
"when MultiBatchGraphCopyer %s",
switchn_iter->second->GetName().c_str(), switchn_iter->second->GetType().c_str(),
copyed_node->GetName().c_str(), copyed_node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add control edge between %s to %s, error-code %u",
switchn_iter->second->GetName().c_str(), copyed_node->GetName().c_str(), ret);
return INTERNAL_ERROR;
@@ -950,6 +1009,10 @@ Status MultiBatchGraphCopyer::CopyInControlEdges(const NodePtr &node, int batch_
auto src_batch_node = batch_branch_iter->second.at(batch_num);
auto ret = GraphUtils::AddEdge(src_batch_node->GetOutControlAnchor(), copyed_node->GetInControlAnchor());
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add ctrl edge between op:%s(%s) and op:%s(%s) failed "
"when MultiBatchGraphCopyer %s",
src_batch_node->GetName().c_str(), src_batch_node->GetType().c_str(),
copyed_node->GetName().c_str(), copyed_node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add data edge between %s to %s, error-code %u",
src_batch_node->GetName().c_str(), copyed_node->GetName().c_str(), ret);
return INTERNAL_ERROR;
@@ -960,6 +1023,10 @@ Status MultiBatchGraphCopyer::CopyInControlEdges(const NodePtr &node, int batch_

auto ret = GraphUtils::AddEdge(origin_src_node->GetOutControlAnchor(), copyed_node->GetInControlAnchor());
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add ctrl edge between op:%s(%s) and op:%s(%s) failed "
"when MultiBatchGraphCopyer %s",
origin_src_node->GetName().c_str(), origin_src_node->GetType().c_str(),
copyed_node->GetName().c_str(), copyed_node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add control edge from origin %s to copyed %s",
origin_src_node->GetName().c_str(), copyed_node->GetName().c_str());
return INTERNAL_ERROR;
@@ -973,6 +1040,7 @@ Status MultiBatchGraphCopyer::CopyInControlEdges(const NodePtr &node, int batch_
NodePtr MultiBatchGraphCopyer::InsertShapeDataNode() {
auto desc = MakeShared<OpDesc>();
if (desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed when MultiBatchGraphCopyer %s", __FUNCTION__);
GELOGE(OUT_OF_MEMORY, "Failed to create shape data node, out of memory");
return nullptr;
}
@@ -987,27 +1055,38 @@ NodePtr MultiBatchGraphCopyer::InsertShapeDataNode() {
GeTensorDesc tensor_desc(GeShape({static_cast<int64_t>(shapes_.at(0).size())}), FORMAT_ND, DT_INT64);
auto ret = desc->AddInputDesc(tensor_desc);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed when MultiBatchGraphCopyer %s",
desc->GetName().c_str(), desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add input desc for created data");
return nullptr;
}
ret = desc->AddOutputDesc(tensor_desc);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add output desc into op:%s(%s) failed when MultiBatchGraphCopyer %s",
desc->GetName().c_str(), desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add output desc for created data");
return nullptr;
}

if (!AttrUtils::SetBool(desc, ATTR_INSERT_BY_MBATCH, true)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to node:%s(%s) failed when MultiBatchGraphCopyer %s",
ATTR_INSERT_BY_MBATCH.c_str(), desc->GetName().c_str(), desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add attr for created data");
return nullptr;
}

auto data_node = graph_->AddNode(desc);
if (data_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed when MultiBatchGraphCopyer %s",
desc->GetName().c_str(), desc->GetType().c_str(), graph_->GetName().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add shape data node to graph");
return nullptr;
}
ret = GraphUtils::AppendInputNode(graph_, data_node);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Append input node:%s(%s) to graph:%s failed when MultiBatchGraphCopyer %s",
data_node->GetName().c_str(), data_node->GetType().c_str(),
graph_->GetName().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to append data node %s as input to graph", data_node->GetName().c_str());
return nullptr;
}
@@ -1019,6 +1098,7 @@ NodePtr MultiBatchGraphCopyer::InsertGetDynamicDimsNode() {
GELOGD("Start insert getdynamicdims node to get shape info.");
auto desc = MakeShared<OpDesc>();
if (desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed when MultiBatchGraphCopyer %s", __FUNCTION__);
GELOGE(OUT_OF_MEMORY, "Failed to create shape data node, out of memory");
return nullptr;
}
@@ -1040,33 +1120,49 @@ NodePtr MultiBatchGraphCopyer::InsertGetDynamicDimsNode() {
tensor_desc.SetFormat(FORMAT_ND);
tensor_desc.SetDataType(DT_INT64);
auto ret = desc->AddInputDesc(tensor_desc);
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, GELOGE(INTERNAL_ERROR, "Failed to add input desc for created data");
return nullptr);
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed when MultiBatchGraphCopyer %s",
desc->GetName().c_str(), desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add input desc for created data");
return nullptr);
continue;
}
GeTensorDesc tensor_desc(GeShape({static_cast<int64_t>(input_shape_dims)}), FORMAT_ND, DT_INT64);
auto ret = desc->AddInputDesc(tensor_desc);
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, GELOGE(INTERNAL_ERROR, "Failed to add input desc for created data");
return nullptr);
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed when MultiBatchGraphCopyer %s",
desc->GetName().c_str(), desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add input desc for created data");
return nullptr);
}

GeTensorDesc tensor_desc(GeShape({static_cast<int64_t>(shapes_.at(0).size())}), FORMAT_ND, DT_INT64);
auto ret = desc->AddOutputDesc(tensor_desc);
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, GELOGE(INTERNAL_ERROR, "Failed to add output desc for created data");
return nullptr);
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed when MultiBatchGraphCopyer %s",
desc->GetName().c_str(), desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add output desc for created data");
return nullptr);

if (!AttrUtils::SetBool(desc, ATTR_INSERT_BY_MBATCH, true)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to node:%s(%s) failed when MultiBatchGraphCopyer %s",
ATTR_INSERT_BY_MBATCH.c_str(), desc->GetName().c_str(), desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add attr for created data");
return nullptr;
}

auto data_node = graph_->AddNode(desc);
if (data_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed when MultiBatchGraphCopyer %s",
desc->GetName().c_str(), desc->GetType().c_str(), graph_->GetName().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add shape data node to graph");
return nullptr;
}
ret = GraphUtils::AppendInputNode(graph_, data_node);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Append input node:%s(%s) to graph:%s failed when MultiBatchGraphCopyer %s",
data_node->GetName().c_str(), data_node->GetType().c_str(),
graph_->GetName().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to append data node %s as input to graph", data_node->GetName().c_str());
return nullptr;
}
@@ -1076,6 +1172,7 @@ NodePtr MultiBatchGraphCopyer::InsertGetDynamicDimsNode() {

Status MultiBatchGraphCopyer::CheckArguments() {
if (graph_ == nullptr) {
REPORT_INNER_ERROR("E19999", "graph_ is nullptr, check invalid when MultiBatchGraphCopyer %s", __FUNCTION__);
GELOGE(PARAM_INVALID, "Failed to copy graph, the graph is null");
return PARAM_INVALID;
}
@@ -1122,6 +1219,10 @@ Status MultiBatchGraphCopyer::LinkDataToMerge(const NodePtr &data, const NodePtr
for (size_t i = 0; i < shapes_.size(); ++i) {
auto ret = GraphUtils::AddEdge(switchn->GetOutDataAnchor(i), merge->GetInDataAnchor(i));
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%zu) and op:%s(%s)(index:%zu) failed "
"when MultiBatchGraphCopyer %s",
switchn->GetName().c_str(), switchn->GetType().c_str(), i,
merge->GetName().c_str(), merge->GetType().c_str(), i, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add edge between switchn %s(%zu) to merge %s(%zu), error-code %u",
switchn->GetName().c_str(), i, merge->GetName().c_str(), i, ret);
return INTERNAL_ERROR);
@@ -1132,6 +1233,10 @@ Status MultiBatchGraphCopyer::LinkDataToMerge(const NodePtr &data, const NodePtr
Status MultiBatchGraphCopyer::LinkNodeToMerge(const NodePtr &node, int out_index, const NodePtr &merge) {
auto &copyed_nodes = nodes_to_batch_nodes_[node.get()];
if (copyed_nodes.size() != shapes_.size()) {
REPORT_INNER_ERROR("E19999", "Create merge node for node %s failed, "
"the copyed nodes for it count %zu different with shape %zu, "
"check invalid when MultiBatchGraphCopyer %s",
node->GetName().c_str(), copyed_nodes.size(), shapes_.size(), __FUNCTION__);
GELOGE(INTERNAL_ERROR,
"Failed to create merge node for node %s, the copyed nodes for it count %zu different with shape %zu",
node->GetName().c_str(), copyed_nodes.size(), shapes_.size());
@@ -1153,14 +1258,23 @@ Status MultiBatchGraphCopyer::LinkNodeToMerge(const NodePtr &node, int out_index
return OUT_OF_MEMORY);

auto ret = GraphUtils::AddEdge(src_node->GetOutControlAnchor(), const_node->GetInControlAnchor());
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, GELOGE(INTERNAL_ERROR, "Failed to add control edge from %s to %s",
src_node->GetName().c_str(), const_node->GetName().c_str());
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add ctrl edge between op:%s(%s) and op:%s(%s) failed "
"when MultiBatchGraphCopyer %s",
src_node->GetName().c_str(), src_node->GetType().c_str(),
const_node->GetName().c_str(), const_node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add control edge from %s to %s",
src_node->GetName().c_str(), const_node->GetName().c_str());
return INTERNAL_ERROR);

src_node = const_node;
}
auto ret = GraphUtils::AddEdge(src_node->GetOutDataAnchor(out_index), merge->GetInDataAnchor(i));
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%zu) failed "
"when MultiBatchGraphCopyer %s",
src_node->GetName().c_str(), src_node->GetType().c_str(), out_index,
merge->GetName().c_str(), merge->GetType().c_str(), i, __FUNCTION__);
GELOGE(INTERNAL_ERROR,
"Failed to add edge between copyed node %s(%d) to inserted merge node %s(%zu), error-code %u",
copyed_nodes[i]->GetName().c_str(), out_index, merge->GetName().c_str(), i, ret);
@@ -1219,6 +1333,8 @@ Status MultiBatchGraphCopyer::UpdateShapeOfShapeNode(const NodePtr &node, size_t
GeShape output_shape(output_dims);
output_desc.SetShape(output_shape);
if (node->GetOpDesc()->UpdateOutputDesc(shape_index, output_desc) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update output desc to op:%s(%s) failed, index:%zu, when MultiBatchGraphCopyer %s",
node->GetName().c_str(), node->GetType().c_str(), shape_index, __FUNCTION__);
GELOGE(FAILED, "Update output desc fail.");
return FAILED;
}
@@ -1253,6 +1369,10 @@ Status MultiBatchGraphCopyer::UpdateMaxShapeToData(const NodePtr &node, size_t o
int64_t size = 1;
for (auto dim : data_to_dynamic_info_.at(data_name).at(i)) {
if (INT64_MAX / dim < size) {
REPORT_CALL_ERROR("E19999", "Op:%s(%s)'s shape:%s size will overflow after multi, "
"check invalid when MultiBatchGraphCopyer %s",
node->GetName().c_str(), node->GetType().c_str(),
formats::ShapeToString(data_to_dynamic_info_[data_name].at(i)).c_str(), __FUNCTION__);
GELOGE(PARAM_INVALID, "The shape %s size overflow",
formats::ShapeToString(data_to_dynamic_info_[data_name].at(i)).c_str());
return PARAM_INVALID;
@@ -1300,6 +1420,7 @@ Status MultiBatchGraphCopyer::InsertSwitchNForData(const NodePtr &node, const si

auto switchn_desc = MakeShared<OpDesc>();
GE_IF_BOOL_EXEC(switchn_desc == nullptr,
REPORT_CALL_ERROR("E19999", "New OpDesc failed when MultiBatchGraphCopyer %s", __FUNCTION__);
GELOGE(OUT_OF_MEMORY, "Failed to create switchn for data %s", node->GetName().c_str());
return OUT_OF_MEMORY);
string switchn_name = node->GetName() + "_ascend_mbatch_switchn";
@@ -1313,10 +1434,18 @@ Status MultiBatchGraphCopyer::InsertSwitchNForData(const NodePtr &node, const si

GeTensorDesc tensor(NodeUtils::GetOutputDesc(*node, out_anchor_index));
GE_IF_BOOL_EXEC(switchn_desc->AddInputDesc("data", tensor) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, input desc name:%s, "
"when MultiBatchGraphCopyer %s",
switchn_desc->GetName().c_str(), switchn_desc->GetType().c_str(),
"data", __FUNCTION__);
GELOGE(OUT_OF_MEMORY, "Failed to add input tensor desc for %s", switchn_desc->GetName().c_str());
return OUT_OF_MEMORY);
GeTensorDesc pred_tensor;
GE_IF_BOOL_EXEC(switchn_desc->AddInputDesc("pred_value", pred_tensor) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, input desc name:%s, "
"when MultiBatchGraphCopyer %s",
switchn_desc->GetName().c_str(), switchn_desc->GetType().c_str(),
"pred_value", __FUNCTION__);
GELOGE(OUT_OF_MEMORY, "Failed to add input pred tensor desc for %s", switchn_desc->GetName().c_str());
return OUT_OF_MEMORY);
std::vector<std::string> input_dims_str;
@@ -1340,11 +1469,18 @@ Status MultiBatchGraphCopyer::InsertSwitchNForData(const NodePtr &node, const si
formats::JoinToString(tensor.GetShape().GetDims());
input_dims_str.emplace_back(input_str);
if (!AttrUtils::SetListInt(tensor, ATTR_NAME_SWITCHN_PRED_VALUE, shapes_.at(i))) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to output tensor of node:%s(%s) failed, index:%zu, "
"when MultiBatchGraphCopyer %s", ATTR_NAME_SWITCHN_PRED_VALUE.c_str(),
node->GetName().c_str(), node->GetType().c_str(), out_anchor_index, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add attr value on output %zu tensor", i);
return INTERNAL_ERROR;
}
(void) AttrUtils::SetListInt(tensor, ATTR_NAME_COMBINED_DYNAMIC_DIMS, shape.GetDims());
if (switchn_desc->AddOutputDesc("output" + std::to_string(i), tensor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed, output desc name:%s, "
"when MultiBatchGraphCopyer %s",
switchn_desc->GetName().c_str(), switchn_desc->GetType().c_str(),
("output" + std::to_string(i)).c_str(), __FUNCTION__);
GELOGE(GRAPH_FAILED, "Opdesc AddOutputDesc failed");
return GRAPH_FAILED;
}
@@ -1352,15 +1488,23 @@ Status MultiBatchGraphCopyer::InsertSwitchNForData(const NodePtr &node, const si
}
(void)AttrUtils::SetListStr(node->GetOpDesc(), "_all_origin_gears_inputs", input_dims_str);
if (!AttrUtils::SetListStr(switchn_desc, ATTR_USER_DESIGNEATE_SHAPE_ORDER, data_name_order_)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to node:%s(%s) failed when MultiBatchGraphCopyer %s",
ATTR_USER_DESIGNEATE_SHAPE_ORDER.c_str(),
switchn_desc->GetName().c_str(), switchn_desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add user designate shape order attr on switchn node %s",
switchn_desc->GetName().c_str());
return INTERNAL_ERROR;
}
if (!AttrUtils::SetBool(switchn_desc, ATTR_INSERT_BY_MBATCH, true)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to node:%s(%s) failed when MultiBatchGraphCopyer %s",
ATTR_INSERT_BY_MBATCH.c_str(), switchn_desc->GetName().c_str(), switchn_desc->GetType().c_str(),
__FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add insert attr on switchn node %s", switchn_desc->GetName().c_str());
return INTERNAL_ERROR;
}
if (!AttrUtils::SetStr(node->GetOpDesc(), kMbatchSwitchnName, switchn_desc->GetName())) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to node:%s(%s) failed when MultiBatchGraphCopyer %s",
kMbatchSwitchnName, node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add switchn attr on data node %s", node->GetName().c_str());
return INTERNAL_ERROR;
}
@@ -1371,6 +1515,9 @@ Status MultiBatchGraphCopyer::InsertSwitchNForData(const NodePtr &node, const si

auto switchn = graph_->AddNode(switchn_desc);
GE_IF_BOOL_EXEC(switchn == nullptr,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed when MultiBatchGraphCopyer %s",
switchn_desc->GetName().c_str(), switchn_desc->GetType().c_str(),
graph_->GetName().c_str(), __FUNCTION__);
GELOGE(OUT_OF_MEMORY, "Failed to create switchn %s from desc", switchn_desc->GetName().c_str());
return OUT_OF_MEMORY);
if (!getnext_sink_dynamic_dims_) {
@@ -1416,6 +1563,8 @@ Status MultiBatchGraphCopyer::LinkGetDynamicDimsToNetOutput(const NodePtr &node)
if (node->GetType() == NETOUTPUT) {
if (!GetLocalOmgContext().dynamic_node_type.empty()) {
if (!AttrUtils::SetStr(node->GetOpDesc(), ATTR_ALL_GEARS_INFO, GetLocalOmgContext().dynamic_dims)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to node:%s(%s) failed when MultiBatchGraphCopyer %s",
ATTR_ALL_GEARS_INFO.c_str(), node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to set all gears info attr on netoutput %s.", node->GetName().c_str());
return INTERNAL_ERROR;
}
@@ -1423,15 +1572,26 @@ Status MultiBatchGraphCopyer::LinkGetDynamicDimsToNetOutput(const NodePtr &node)
if (getnext_sink_dynamic_dims_) {
size_t input_index = node->GetAllInDataAnchors().size();
if (NodeUtils::AppendInputAnchor(node, input_index + 1) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Append %zu input anchors to node:%s(%s) failed when MultiBatchGraphCopyer %s",
input_index + 1, node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Append input anchor of %s of %zu failed.", node->GetName().c_str(), input_index);
return INTERNAL_ERROR;
}
auto ret =
ge::GraphUtils::AddEdge(shape_data_->GetOutDataAnchor(kDataOutIndex), node->GetInDataAnchor(input_index));
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, GELOGE(INTERNAL_ERROR, "Failed to link netoutput %s to getdynamicdims %s",
node->GetName().c_str(), shape_data_->GetName().c_str());
GE_IF_BOOL_EXEC(
ret != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%zu) failed "
"when MultiBatchGraphCopyer %s",
shape_data_->GetName().c_str(), shape_data_->GetType().c_str(), kDataOutIndex,
node->GetName().c_str(), node->GetType().c_str(), input_index, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to link netoutput %s to getdynamicdims %s",
node->GetName().c_str(), shape_data_->GetName().c_str());
return INTERNAL_ERROR);
if (!AttrUtils::SetBool(node->GetOpDesc(), ATTR_GETNEXT_SINK_DYNMAIC, true)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to node:%s(%s) failed when MultiBatchGraphCopyer %s",
ATTR_GETNEXT_SINK_DYNMAIC.c_str(), node->GetName().c_str(), node->GetType().c_str(),
__FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to set getnext sink dynamic attr on netoutput %s.", node->GetName().c_str());
return INTERNAL_ERROR;
}
@@ -1459,6 +1619,9 @@ Status MultiBatchGraphCopyer::AddAttrForGetDynamicDims(const NodePtr &node) {
GELOGD("Add attr for :%s, type is %s:", shape_data_->GetName().c_str(), shape_data_->GetType().c_str());
size_t data_count = node->GetAllOutDataAnchors().size() / kDivisionConst;
if (!AttrUtils::SetInt(shape_data_->GetOpDesc(), ATTR_GETNEXT_SINK_DATA_COUNT, data_count)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to node:%s(%s) failed when MultiBatchGraphCopyer %s",
ATTR_GETNEXT_SINK_DATA_COUNT.c_str(),
shape_data_->GetName().c_str(), shape_data_->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "set ATTR_GETNEXT_SINK_DATA_COUNT failed");
return INTERNAL_ERROR;
}
@@ -1475,6 +1638,9 @@ Status MultiBatchGraphCopyer::AddAttrForGetDynamicDims(const NodePtr &node) {
}
}
if (!AttrUtils::SetListInt(shape_data_->GetOpDesc(), ATTR_GETNEXT_SINK_SHAPE_INFO, shape_info)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to node:%s(%s) failed when MultiBatchGraphCopyer %s",
ATTR_GETNEXT_SINK_SHAPE_INFO.c_str(),
shape_data_->GetName().c_str(), shape_data_->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "set ATTR_GETNEXT_SINK_SHAPE_INFO failed");
return INTERNAL_ERROR;
}
@@ -1491,8 +1657,13 @@ Status MultiBatchGraphCopyer::AddLinkForGetDynamicDims(const NodePtr &node) {
shape_data_->GetName().c_str(), input_index);
auto out_data_anchor = node->GetOutDataAnchor(out_index);
auto ret = GraphUtils::AddEdge(out_data_anchor, shape_data_->GetInDataAnchor(input_index));
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, GELOGE(INTERNAL_ERROR, "Failed to link getnext %s to getdynamicdims %s",
node->GetName().c_str(), shape_data_->GetName().c_str());
GE_IF_BOOL_EXEC(
ret != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%zu) and op:%s(%s)(index:%zu) failed "
"when MultiBatchGraphCopyer %s", node->GetName().c_str(), node->GetType().c_str(), out_index,
shape_data_->GetName().c_str(), shape_data_->GetType().c_str(), input_index, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to link getnext %s to getdynamicdims %s",
node->GetName().c_str(), shape_data_->GetName().c_str());
return INTERNAL_ERROR);
}
return SUCCESS;
@@ -1506,6 +1677,9 @@ Status MultiBatchGraphCopyer::LinkEdges() {
if (data_nodes_to_switchn_.count(node.get()) > 0) {
auto switchn = data_nodes_to_switchn_[node.get()];
GE_IF_BOOL_EXEC(switchn == nullptr,
REPORT_INNER_ERROR("E19999", "swithn in data_nodes_to_switchn_ for op:%s(%s) is nullptr, "
"check invalid when MultiBatchGraphCopyer %s",
node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__);
GELOGE(PARAM_INVALID, "Switchn should not be nullptr for %s.", node->GetName().c_str());
return OUT_OF_MEMORY);
ret = LinkDataToSwitchN(node, switchn, kDataOutIndex);
@@ -1545,14 +1719,26 @@ Status MultiBatchGraphCopyer::LinkEdges() {
Status MultiBatchGraphCopyer::LinkDataToSwitchN(const NodePtr &data, const NodePtr &switchn, const int &out_index) {
auto ret =
GraphUtils::AddEdge(shape_data_->GetOutDataAnchor(kDataOutIndex), switchn->GetInDataAnchor(kSwitchNPredIndex));
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, GELOGE(INTERNAL_ERROR, "Failed to link shape data %s to switchn %s",
shape_data_->GetName().c_str(), switchn->GetName().c_str());
return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(
ret != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed "
"when MultiBatchGraphCopyer %s",
shape_data_->GetName().c_str(), shape_data_->GetType().c_str(), kDataOutIndex,
switchn->GetName().c_str(), switchn->GetType().c_str(), kSwitchNPredIndex, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to link shape data %s to switchn %s",
shape_data_->GetName().c_str(), switchn->GetName().c_str());
return INTERNAL_ERROR);

ret = GraphUtils::AddEdge(data->GetOutDataAnchor(out_index), switchn->GetInDataAnchor(kSwitchNDataIndex));
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, GELOGE(INTERNAL_ERROR, "Failed to link data %s to switchn %s",
data->GetName().c_str(), switchn->GetName().c_str());
return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(
ret != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed "
"when MultiBatchGraphCopyer %s",
data->GetName().c_str(), data->GetType().c_str(), out_index,
switchn->GetName().c_str(), switchn->GetType().c_str(), kSwitchNDataIndex, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to link data %s to switchn %s",
data->GetName().c_str(), switchn->GetName().c_str());
return INTERNAL_ERROR);
return SUCCESS;
}

@@ -1594,6 +1780,8 @@ Status MultiBatchGraphCopyer::LinkToMerge(const NodePtr &node) {
}
continue;
}
REPORT_INNER_ERROR("E19999", "The merge node %s is created, index %zu, but can not find the src node, "
"check invalid when MultiBatchGraphCopyer %s", merge_node->GetName().c_str(), i, __FUNCTION__);
GELOGE(INTERNAL_ERROR, "The merge node %s is created, index %zu, but can not find the src node",
merge_node->GetName().c_str(), i);
return INTERNAL_ERROR;
@@ -1630,24 +1818,40 @@ Status MultiBatchGraphCopyer::LinkToNodeOutBranch(const NodePtr &node) {
}
auto iter = nodes_to_merge_nodes_.find(in_node.get());
if (iter == nodes_to_merge_nodes_.end()) {
REPORT_INNER_ERROR("E19999", "Failed to link data edge from %s(%s)(index:%d) to %s(%s)(index:%d), "
"cause no merge node found, check invalid when MultiBatchGraphCopyer %s",
in_node->GetName().c_str(), in_node->GetType().c_str(), src_out_anchor->GetIdx(),
node->GetName().c_str(), node->GetType().c_str(), in_data_anchor->GetIdx(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to link IO data edge from %s(%d) to %s(%d), no merge node found",
in_node->GetName().c_str(), src_out_anchor->GetIdx(), node->GetName().c_str(), in_data_anchor->GetIdx());
return INTERNAL_ERROR;
}
auto merge_node = iter->second[src_out_anchor->GetIdx()];
if (merge_node == nullptr) {
REPORT_INNER_ERROR("E19999", "Failed to link data edge from %s(%s)(index:%d) to %s(%s)(index:%d), "
"cause no merge node found, check invalid when MultiBatchGraphCopyer %s",
in_node->GetName().c_str(), in_node->GetType().c_str(), src_out_anchor->GetIdx(),
node->GetName().c_str(), node->GetType().c_str(), in_data_anchor->GetIdx(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to link IO data edge from %s(%d) to %s(%d), no merge node found",
in_node->GetName().c_str(), src_out_anchor->GetIdx(), node->GetName().c_str(), in_data_anchor->GetIdx());
return INTERNAL_ERROR;
}
auto ret = src_out_anchor->Unlink(in_data_anchor);
if (ret != GRAPH_SUCCESS) {
REPORT_INNER_ERROR("E19999", "Unlink edge from %s(%s)(index:%d) to %s(%s)(index:%d) failed, "
"when MultiBatchGraphCopyer %s",
in_node->GetName().c_str(), in_node->GetType().c_str(), src_out_anchor->GetIdx(),
node->GetName().c_str(), node->GetType().c_str(), in_data_anchor->GetIdx(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to unlink the control edge from %s(%d) to %s(%d)", in_node->GetName().c_str(),
src_out_anchor->GetIdx(), node->GetName().c_str(), in_data_anchor->GetIdx());
return INTERNAL_ERROR;
}
ret = GraphUtils::AddEdge(merge_node->GetOutDataAnchor(kMergeDataOutIndex), in_data_anchor);
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed "
"when MultiBatchGraphCopyer %s",
merge_node->GetName().c_str(), merge_node->GetType().c_str(), kMergeDataOutIndex,
node->GetName().c_str(), node->GetType().c_str(), in_data_anchor->GetIdx(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add data edge from %s(%d) to %s(%d)", merge_node->GetName().c_str(),
src_out_anchor->GetIdx(), node->GetName().c_str(), in_data_anchor->GetIdx());
return INTERNAL_ERROR;
@@ -1662,28 +1866,49 @@ Status MultiBatchGraphCopyer::LinkToNodeOutBranch(const NodePtr &node) {
}
auto iter = nodes_to_merge_nodes_.find(in_node.get());
if (iter == nodes_to_merge_nodes_.end()) {
REPORT_INNER_ERROR("E19999", "Failed to link IO control edge from %s(%s) to %s(%s), no merge node found,"
"check invalid when MultiBatchGraphCopyer %s",
in_node->GetName().c_str(), in_node->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to link IO control edge from %s to %s, no merge node found",
in_node->GetName().c_str(), node->GetName().c_str());
return INTERNAL_ERROR;
}
auto merge_node = iter->second[0];
if (merge_node == nullptr) {
REPORT_INNER_ERROR("E19999", "Failed to link IO control edge from %s(%s) to %s(%s), no merge node found,"
"check invalid when MultiBatchGraphCopyer %s",
in_node->GetName().c_str(), in_node->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to link IO control edge from %s to %s, no merge node found",
in_node->GetName().c_str(), node->GetName().c_str());
return INTERNAL_ERROR;
}

GE_IF_BOOL_EXEC(in_node->GetOutControlAnchor() == nullptr,
REPORT_INNER_ERROR("E19999", "Out control anchor of op:%s(%s) is nullptr, "
"check invalid when MultiBatchGraphCopyer %s",
in_node->GetName().c_str(), in_node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Innode outputControlAnchor is null");
return INTERNAL_ERROR);
auto ret = in_node->GetOutControlAnchor()->Unlink(node->GetInControlAnchor());
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, GELOGE(INTERNAL_ERROR, "Failed to unlink the control edge from %s to %s",
in_node->GetName().c_str(), node->GetName().c_str());
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS,
REPORT_INNER_ERROR("E19999", "Unlink ctrl edge from %s(%s) to %s(%s) failed, "
"when MultiBatchGraphCopyer %s",
in_node->GetName().c_str(), in_node->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to unlink the control edge from %s to %s",
in_node->GetName().c_str(), node->GetName().c_str());
return INTERNAL_ERROR);
ret = GraphUtils::AddEdge(merge_node->GetOutControlAnchor(), node->GetInControlAnchor());
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, GELOGE(INTERNAL_ERROR, "Failed to add control edge from %s to %s",
merge_node->GetName().c_str(), node->GetName().c_str());
return INTERNAL_ERROR);
GE_IF_BOOL_EXEC(
ret != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add ctrl edge between op:%s(%s) and op:%s(%s) failed "
"when MultiBatchGraphCopyer %s", merge_node->GetName().c_str(), merge_node->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add control edge from %s to %s",
merge_node->GetName().c_str(), node->GetName().c_str());
return INTERNAL_ERROR);
GELOGI("Link control edge from merge %s(from %s) to %s", merge_node->GetName().c_str(), in_node->GetName().c_str(),
node->GetName().c_str());
}
@@ -1779,6 +2004,8 @@ void GetDynamicShapeByGraph(const ComputeGraphPtr &graph, const NodePtr &node,
for (size_t j = 0; j < dynamic_branch_names.size(); ++j) {
const auto &subgraph = graph->GetSubgraph(dynamic_branch_names[j]);
if (subgraph == nullptr) {
REPORT_INNER_ERROR("E19999", "Get subgraph:%s from graph:%s failed when MultiBatchGraphCopyer %s",
dynamic_branch_names[j].c_str(), graph->GetName().c_str(), __FUNCTION__);
GELOGE(GE_GRAPH_EMPTY_SUBGRAPH, "Subgraph not found, name: %s", dynamic_branch_names[j].c_str());
dynamic_output_dims.clear();
return;
@@ -1786,6 +2013,8 @@ void GetDynamicShapeByGraph(const ComputeGraphPtr &graph, const NodePtr &node,

const auto &out_node = subgraph->FindFirstNodeMatchType(NETOUTPUT);
if (out_node == nullptr) {
REPORT_INNER_ERROR("E19999", "No netoutput node exist in subgraph:%s, check invalid "
"when MultiBatchGraphCopyer %s", subgraph->GetName().c_str(), __FUNCTION__);
GELOGE(GE_GRAPH_GRAPH_NODE_NULL, "NetOutput not found, name: %s", dynamic_branch_names[j].c_str());
dynamic_output_dims.clear();
return;
@@ -1794,6 +2023,9 @@ void GetDynamicShapeByGraph(const ComputeGraphPtr &graph, const NodePtr &node,
GELOGI("Find the subgraph Output node %s and the index is %zu", out_node->GetName().c_str(), i);
const auto &out_desc = out_node->GetOpDesc();
if (out_desc == nullptr || out_desc->GetInputsSize() <= i) {
REPORT_INNER_ERROR("E19999", "op_desc of node in subgraph:%s is nullptr or input desc size:%zu <= %zu, "
"check invalid when MultiBatchGraphCopyer %s", subgraph->GetName().c_str(),
out_desc->GetInputsSize(), i, __FUNCTION__);
GELOGE(GE_GRAPH_GRAPH_NODE_NULL, "Get Input desc failed, name: %s, index: %zu", out_node->GetName().c_str(), i);
dynamic_output_dims.clear();
return;
@@ -1895,6 +2127,9 @@ Status GetDynamicOutputShape(ComputeGraphPtr &graph) {
if ((net_output != nullptr) && !dynamic_output_dims.empty()) {
GetDirectOutputShape(graph, net_output, dynamic_output_index, dynamic_output_dims);
if (!AttrUtils::SetListStr(net_output->GetOpDesc(), ATTR_NAME_DYNAMIC_OUTPUT_DIMS, dynamic_output_dims)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to node:%s(%s) failed when MultiBatchGraphCopyer %s",
ATTR_NAME_DYNAMIC_OUTPUT_DIMS.c_str(),
net_output->GetName().c_str(), net_output->GetType().c_str(), __FUNCTION__);
GELOGE(FAILED, "Set dynamic output dims attr failed");
return FAILED;
}


+ 48
- 0
ge/graph/preprocess/multi_batch_options.cc View File

@@ -102,6 +102,10 @@ Status DistinguishGetNextAndData(ComputeGraphPtr &graph, vector<NodePtr> &data_n
Status CheckSequenceOfData(ComputeGraphPtr &graph, const vector<NodePtr> &data_nodes) {
GELOGD("Start check input sequence from data nodes and input shape.");
if (data_nodes.size() != GetLocalOmgContext().user_input_dims.size()) {
REPORT_INNER_ERROR("E19999", "Count:%zu of data_nodes in graph:%s should be equal to "
"input_shape count:%zu from option, check invalid when %s",
data_nodes.size(), graph->GetName().c_str(), GetLocalOmgContext().user_input_dims.size(),
__FUNCTION__);
GELOGE(PARAM_INVALID, "The count of input shape:%zu should be equal to the count of data num:%zu.",
GetLocalOmgContext().user_input_dims.size(), data_nodes.size());
return PARAM_INVALID;
@@ -119,6 +123,11 @@ Status CheckSequenceOfData(ComputeGraphPtr &graph, const vector<NodePtr> &data_n
continue;
}
if (dynamic_dims.size() != output_shape.size()) {
REPORT_INNER_ERROR("E19999", "The output shape of %s is %s, the input shape from options of %s is %s, graph:%s,"
"check invalid when %s", data_node->GetName().c_str(),
formats::JoinToString(output_shape).c_str(),
GetLocalOmgContext().user_input_dims.at(i).first.c_str(),
formats::JoinToString(dynamic_dims).c_str(), graph->GetName().c_str(), __FUNCTION__);
GELOGE(PARAM_INVALID, "The output shape of %s is %s, the input shape from options of %s is %s.",
data_node->GetName().c_str(), formats::JoinToString(output_shape).c_str(),
GetLocalOmgContext().user_input_dims.at(i).first.c_str(), formats::JoinToString(dynamic_dims).c_str());
@@ -126,6 +135,11 @@ Status CheckSequenceOfData(ComputeGraphPtr &graph, const vector<NodePtr> &data_n
}
for (size_t j = 0; j < dynamic_dims.size(); ++j) {
if (dynamic_dims.at(j) != kDynmaicDims && dynamic_dims.at(j) != output_shape.at(j)) {
REPORT_INNER_ERROR("E19999", "Value of input shape %s from option and output shape %s of data op:%s "
"should be equal to %d, index:%zu, graph:%s, check invalid when %s",
formats::JoinToString(dynamic_dims).c_str(),
formats::JoinToString(output_shape).c_str(), data_node->GetName().c_str(), kDynmaicDims,
j, graph->GetName().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Value of input shape %s should be equal to %s.",
formats::JoinToString(dynamic_dims).c_str(), formats::JoinToString(output_shape).c_str());
return INTERNAL_ERROR;
@@ -138,6 +152,9 @@ Status CheckSequenceOfData(ComputeGraphPtr &graph, const vector<NodePtr> &data_n
Status CheckSequenceOfGetnext(ComputeGraphPtr &graph, const vector<NodePtr> &getnext_sink_node) {
GELOGD("Start check input sequence from getnext sink nodes and input shape.");
if (getnext_sink_node.size() != kNumOfGetnextNode) {
REPORT_INNER_ERROR("E19999", "Not support dynamic dims when a graph with multi getnext nodes, graph:%s, "
"num of getnext node:%zu, check invalid when %s",
graph->GetName().c_str(), getnext_sink_node.size(), __FUNCTION__);
GELOGE(PARAM_INVALID, "Not support dynamic dims when a graph with multi getnext nodes.");
return PARAM_INVALID;
}
@@ -147,6 +164,9 @@ Status CheckSequenceOfGetnext(ComputeGraphPtr &graph, const vector<NodePtr> &get
GE_CHECK_NOTNULL(op_desc);
size_t data_count = data_node->GetAllOutDataAnchors().size() / kDivisionConst;
if (data_count != GetLocalOmgContext().user_input_dims.size()) {
REPORT_INNER_ERROR("E19999", "Output desc count of %s is %zu, should be equal to count of input shape: %zu, "
"graph:%s, check invalid when %s", op_desc->GetName().c_str(), data_count,
GetLocalOmgContext().user_input_dims.size(), graph->GetName().c_str(), __FUNCTION__);
GELOGE(PARAM_INVALID, "Output count of %s is %zu, should be equal to count of input shape: %zu",
op_desc->GetName().c_str(), data_count, GetLocalOmgContext().user_input_dims.size());
return PARAM_INVALID;
@@ -161,6 +181,12 @@ Status CheckSequenceOfGetnext(ComputeGraphPtr &graph, const vector<NodePtr> &get
continue;
}
if (dynamic_dims.size() != output_shape.size()) {
REPORT_INNER_ERROR("E19999", "The %zu output_shape of %s is %s not equal to the input_shape:%s "
"from options of %s, graph:%s, check invalid when %s", i,
data_node->GetName().c_str(), formats::JoinToString(output_shape).c_str(),
formats::JoinToString(dynamic_dims).c_str(),
GetLocalOmgContext().user_input_dims.at(i).first.c_str(),
graph->GetName().c_str(), __FUNCTION__);
GELOGE(PARAM_INVALID, "the output_shape of %s is %s, the input_shape from options of %s is %s.",
data_node->GetName().c_str(), formats::JoinToString(output_shape).c_str(),
GetLocalOmgContext().user_input_dims.at(i).first.c_str(), formats::JoinToString(dynamic_dims).c_str());
@@ -168,6 +194,11 @@ Status CheckSequenceOfGetnext(ComputeGraphPtr &graph, const vector<NodePtr> &get
}
for (size_t j = 0; j < dynamic_dims.size(); ++j) {
if (dynamic_dims.at(j) != kDynmaicDims && dynamic_dims.at(j) != output_shape.at(j)) {
REPORT_INNER_ERROR("E19999", "Value of input shape %s from option and output shape %s of data op:%s "
"should be equal to %d, index:%zu, graph:%s, check invalid when %s",
formats::JoinToString(dynamic_dims).c_str(),
formats::JoinToString(output_shape).c_str(), data_node->GetName().c_str(), kDynmaicDims,
j, graph->GetName().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "value of input_shape %s should be equal to %s.",
formats::JoinToString(dynamic_dims).c_str(), formats::JoinToString(output_shape).c_str());
return INTERNAL_ERROR;
@@ -215,6 +246,10 @@ Status CheckSequenceOfOptions(ComputeGraphPtr &graph, vector<NodePtr> &data_node
Status UpdateNameOfData(ComputeGraphPtr &graph, const vector<NodePtr> &data_nodes) {
GELOGD("Update first value of input shape by data nodes.");
if (data_nodes.size() != GetLocalOmgContext().user_input_dims.size()) {
REPORT_INNER_ERROR("E19999", "Count:%zu of data_nodes in graph:%s should be equal to "
"input_shape count:%zu from option, check invalid when %s",
data_nodes.size(), graph->GetName().c_str(), GetLocalOmgContext().user_input_dims.size(),
__FUNCTION__);
GELOGE(PARAM_INVALID, "count of data_nodes: %zu should be equal to input_shape count: %zu.",
data_nodes.size(), GetLocalOmgContext().user_input_dims.size());
return PARAM_INVALID;
@@ -229,6 +264,9 @@ Status UpdateNameOfData(ComputeGraphPtr &graph, const vector<NodePtr> &data_node
Status UpdateNameOfGetnext(ComputeGraphPtr &graph, const vector<NodePtr> &getnext_sink_nodes) {
GELOGD("Update first value of input shape by getnext sink nodes.");
if (getnext_sink_nodes.size() != kNumOfGetnextNode) {
REPORT_INNER_ERROR("E19999", "Not support dynamic dims when a graph with multi getnext nodes, graph:%s, "
"num of getnext node:%zu, check invalid when %s",
graph->GetName().c_str(), getnext_sink_nodes.size(), __FUNCTION__);
GELOGE(PARAM_INVALID, "Not support dynamic dims when a graph with multi getnext nodes.");
return PARAM_INVALID;
}
@@ -239,6 +277,9 @@ Status UpdateNameOfGetnext(ComputeGraphPtr &graph, const vector<NodePtr> &getnex
// user want getnext dynamic, just getnext or data+getnext_sink
size_t data_count = input_node->GetAllOutDataAnchors().size() / kDivisionConst;
if (data_count != GetLocalOmgContext().user_input_dims.size()) {
REPORT_INNER_ERROR("E19999", "Output desc count of %s is %zu, should be equal to count of input shape: %zu, "
"graph:%s, check invalid when %s", op_desc->GetName().c_str(), data_count,
GetLocalOmgContext().user_input_dims.size(), graph->GetName().c_str(), __FUNCTION__);
GELOGE(PARAM_INVALID, "Output count of %s is %zu, should be equal to count of input shape: %zu",
op_desc->GetName().c_str(), data_count, GetLocalOmgContext().user_input_dims.size());
return PARAM_INVALID;
@@ -299,6 +340,9 @@ Status DeleteIdentityInsertByAdapter(ComputeGraphPtr &graph) {
if (dst_node->GetType() == IDENTITY) {
GELOGI("Need to remove %s.", dst_node->GetName().c_str());
if (ge::GraphUtils::RemoveNodeWithoutRelink(graph, dst_node) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) from graph:%s failed when %s",
dst_node->GetName().c_str(), dst_node->GetType().c_str(), graph->GetName().c_str(),
__FUNCTION__);
GELOGE(FAILED, "Remove Identity node %s failed.", dst_node->GetName().c_str());
return FAILED;
}
@@ -322,6 +366,8 @@ Status CheckNegativeCountOfOptions(const std::vector<std::vector<int64_t>> &shap
}
for (size_t i = 0; i < shapes.size(); ++i) {
if (shapes.at(i).size() != negative_count) {
REPORT_INNER_ERROR("E19999", "gear num of dynamic_dims is %zu should be equal to num:%zu from option, "
"check invalid when %s", shapes.at(i).size(), negative_count, __FUNCTION__);
GELOGE(PARAM_INVALID, "Each gear num of dynamic_dims is %zu should be equal to %zu.", shapes.at(i).size(),
negative_count);
return PARAM_INVALID;
@@ -533,6 +579,8 @@ Status StampDynamicType(const OpDescPtr &op_desc) {
dynamic_type = static_cast<int32_t>(DYNAMIC_DIMS);
}
if (!AttrUtils::SetInt(op_desc, ATTR_DYNAMIC_TYPE, dynamic_type)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to node:%s(%s) failed when %s",
ATTR_DYNAMIC_TYPE.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str(), __FUNCTION__);
GELOGE(INTERNAL_ERROR, "Failed to add dynamic type attr for node %s", op_desc->GetName().c_str());
return INTERNAL_ERROR;
}


+ 2
- 0
inc/framework/common/util.h View File

@@ -116,6 +116,8 @@
#define GE_CHECK_NOTNULL(val) \
do { \
if (val == nullptr) { \
REPORT_INNER_ERROR("E19999", "Param:%s is nullptr, check invalid when %s", \
#val, __FUNCTION__); \
DOMI_LOGE("[Check][Param:%s]null is invalid when %s.", #val, __FUNCTION__); \
return ge::PARAM_INVALID; \
} \


Loading…
Cancel
Save