From 060a313702226804a348a1942c40b5d3d097b0b8 Mon Sep 17 00:00:00 2001 From: weiyang Date: Tue, 1 Dec 2020 18:00:11 +0800 Subject: [PATCH] fix errorcode --- ge/common/helper/model_helper.cc | 20 +++++++++---------- ge/common/helper/om_file_helper.cc | 4 ++-- ge/common/model_parser/base.cc | 6 +++--- .../load/new_model_manager/model_manager.cc | 8 ++++---- inc/external/ge/ge_api_error_codes.h | 3 --- inc/external/ge/ge_error_codes.h | 3 --- 6 files changed, 19 insertions(+), 25 deletions(-) diff --git a/ge/common/helper/model_helper.cc b/ge/common/helper/model_helper.cc index fbc6b782..6f201461 100644 --- a/ge/common/helper/model_helper.cc +++ b/ge/common/helper/model_helper.cc @@ -140,8 +140,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod std::shared_ptr model_task_def = ge_model->GetModelTaskDefPtr(); if (model_task_def == nullptr) { - GELOGE(MEMALLOC_FAILED, "Create model task def ptr failed"); - return FAILED; + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Create model task def ptr failed"); + return ACL_ERROR_GE_MEMORY_ALLOCATION; } size_t partition_task_size = model_task_def->ByteSizeLong(); GE_IF_BOOL_EXEC(partition_task_size == 0 || partition_task_size > INT_MAX, @@ -150,8 +150,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod ge::Buffer task_buffer(partition_task_size); if (task_buffer.GetSize() == 0) { - GELOGE(MEMALLOC_FAILED, "Alloc model task def buffer failed"); - return MEMALLOC_FAILED; + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Alloc model task def buffer failed"); + return ACL_ERROR_GE_MEMORY_ALLOCATION; } (void)model_task_def->SerializePartialToArray(task_buffer.GetData(), static_cast(partition_task_size)); @@ -173,8 +173,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod err = memcpy_s(model_header.platform_version, PLATFORM_VERSION_LEN, platform_version.c_str(), platform_version.size() + 1); if (err != EOK) { - GELOGE(MEMALLOC_FAILED, "ModelHelper SaveModel failed while allocating memory for platform_version."); - return MEMALLOC_FAILED; + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "ModelHelper SaveModel failed while allocating memory for platform_version."); + return ACL_ERROR_GE_MEMORY_ALLOCATION; } string version = reinterpret_cast(model_header.platform_version); GELOGD("Platform version save: %s", version.c_str()); @@ -183,8 +183,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmMod name_size = name_size > (MODEL_NAME_LENGTH - 1) ? (MODEL_NAME_LENGTH - 1) : name_size; err = memcpy_s(model_header.name, MODEL_NAME_LENGTH, ge_model->GetName().c_str(), name_size); if (err != EOK) { - GELOGE(MEMALLOC_FAILED, "ModelHelper SaveModel failed while allocating memory for name"); - return MEMALLOC_FAILED; + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "ModelHelper SaveModel failed while allocating memory for name"); + return ACL_ERROR_GE_MEMORY_ALLOCATION; } string model_name = reinterpret_cast(model_header.name); GELOGD("Model name save:%s", model_name.c_str()); @@ -299,8 +299,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadModel(c auto partition_table = reinterpret_cast(model_addr_tmp_); if (partition_table->num == kOriginalOmPartitionNum) { model_addr_tmp_ = nullptr; - GELOGE(ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID, "om model is error,please use executable om model"); - return ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID; + GELOGE(ACL_ERROR_GE_PARAM_INVALID, "om model is error,please use executable om model"); + return ACL_ERROR_GE_PARAM_INVALID; } // Encrypt model need to del temp model/no encrypt model don't need to del model model_addr_tmp_ = nullptr; diff --git a/ge/common/helper/om_file_helper.cc b/ge/common/helper/om_file_helper.cc index 0b076aaf..ce88cd08 100644 --- a/ge/common/helper/om_file_helper.cc +++ b/ge/common/helper/om_file_helper.cc @@ -119,8 +119,8 @@ Status OmFileLoadHelper::LoadModelPartitionTable(uint8_t *model_data, const uint // Original model partition include graph-info if ((partition_table->num != PARTITION_SIZE) && (partition_table->num != (PARTITION_SIZE - 1)) && (partition_table->num != (PARTITION_SIZE - kOptionalNum)) && (partition_table->num != 1)) { - GELOGE(ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID, "Invalid partition_table->num:%u", partition_table->num); - return ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID; + GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Invalid partition_table->num:%u", partition_table->num); + return ACL_ERROR_GE_PARAM_INVALID; } size_t mem_offset = SIZE_OF_MODEL_PARTITION_TABLE(*partition_table); GELOGD("ModelPartitionTable num :%u, ModelFileHeader length :%zu, ModelPartitionTable length :%zu", diff --git a/ge/common/model_parser/base.cc b/ge/common/model_parser/base.cc index 5d050a2b..64277199 100644 --- a/ge/common/model_parser/base.cc +++ b/ge/common/model_parser/base.cc @@ -101,15 +101,15 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::ParseMo // Get data address uint8_t *data = reinterpret_cast(model.model_data) + sizeof(ModelFileHeader); if (file_header->is_encrypt == ModelEncryptType::UNENCRYPTED) { // Unencrypted model - GE_CHK_BOOL_RET_STATUS(model.key.empty(), ACL_ERROR_GE_EXEC_MODEL_NOT_SUPPORT_ENCRYPTION, + GE_CHK_BOOL_RET_STATUS(model.key.empty(), ACL_ERROR_GE_PARAM_INVALID, "Invalid param. model is unencrypted, but key is not empty."); model_data = data; model_len = file_header->length; GELOGD("Model_len is %u, model_file_head_len is %zu.", model_len, sizeof(ModelFileHeader)); } else { - GELOGE(ACL_ERROR_GE_EXEC_MODEL_NOT_SUPPORT_ENCRYPTION, "Invalid model. ModelEncryptType not supported."); - res = ACL_ERROR_GE_EXEC_MODEL_NOT_SUPPORT_ENCRYPTION; + GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Invalid model. ModelEncryptType not supported."); + res = ACL_ERROR_GE_PARAM_INVALID; } return res; diff --git a/ge/graph/load/new_model_manager/model_manager.cc b/ge/graph/load/new_model_manager/model_manager.cc index 446c512c..bd996280 100755 --- a/ge/graph/load/new_model_manager/model_manager.cc +++ b/ge/graph/load/new_model_manager/model_manager.cc @@ -1044,7 +1044,7 @@ Status ModelManager::GenSessionId(uint64_t &session_id) { Status ModelManager::LoadModelOffline(uint32_t &model_id, const ModelData &model, shared_ptr listener, void *dev_ptr, size_t mem_size, void *weight_ptr, size_t weight_size) { GE_CHK_BOOL_RET_STATUS(model.key.empty() || mmAccess2(model.key.c_str(), M_F_OK) == EN_OK, - ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID, + ACL_ERROR_GE_PARAM_INVALID, "input key file path %s is invalid, %s", model.key.c_str(), strerror(errno)); GenModelId(&model_id); @@ -1130,7 +1130,7 @@ Status ModelManager::LoadModelWithQ(uint32_t &model_id, const ModelData &model_d const std::vector &input_queue_ids, const std::vector &output_queue_ids) { GE_CHK_BOOL_RET_STATUS(model_data.key.empty() || mmAccess2(model_data.key.c_str(), M_F_OK) == EN_OK, - ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID, "input key file path %s is not valid, %s", + ACL_ERROR_GE_PARAM_INVALID, "input key file path %s is not valid, %s", model_data.key.c_str(), strerror(errno)); ModelHelper model_helper; @@ -1397,8 +1397,8 @@ Status ModelManager::GetModelMemAndWeightSize(const ModelData &model, size_t &me auto partition_table = reinterpret_cast(model_data); if (partition_table->num == 1) { - GELOGE(ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID, "om model is error,please use executable om model"); - return ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID; + GELOGE(ACL_ERROR_GE_PARAM_INVALID, "om model is error,please use executable om model"); + return ACL_ERROR_GE_PARAM_INVALID; } ModelPartition task_partition; if (om_file_helper.GetModelPartition(ModelPartitionType::TASK_INFO, task_partition) != SUCCESS) { diff --git a/inc/external/ge/ge_api_error_codes.h b/inc/external/ge/ge_api_error_codes.h index 0ea2d064..3d63aced 100644 --- a/inc/external/ge/ge_api_error_codes.h +++ b/inc/external/ge/ge_api_error_codes.h @@ -97,13 +97,10 @@ GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_PARAM_INVALID, "Parameter invalid."); GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_NOT_INIT, "GE executor not initialized yet."); GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "Model file path invalid."); GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_ID_INVALID, "Model id invalid."); -GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID, "Model key path invalid."); -GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_NOT_SUPPORT_ENCRYPTION, "Model does not support encryption."); GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID, "Data size of model invalid."); GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_ADDR_INVALID, "Model addr invalid."); GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_QUEUE_ID_INVALID, "Queue id of model invalid."); GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED, "The model loaded repeatedly."); -GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID, "Model partition num invalid."); GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID, "Dynamic input addr invalid."); GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID, "Dynamic input size invalid."); GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_DYNAMIC_BATCH_SIZE_INVALID, "Dynamic batch size invalid."); diff --git a/inc/external/ge/ge_error_codes.h b/inc/external/ge/ge_error_codes.h index 30631d8b..20a7e0f9 100644 --- a/inc/external/ge/ge_error_codes.h +++ b/inc/external/ge/ge_error_codes.h @@ -26,13 +26,10 @@ static const uint32_t ACL_ERROR_GE_PARAM_INVALID = 145000; static const uint32_t ACL_ERROR_GE_EXEC_NOT_INIT = 145001; static const uint32_t ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID = 145002; static const uint32_t ACL_ERROR_GE_EXEC_MODEL_ID_INVALID = 145003; -static const uint32_t ACL_ERROR_GE_EXEC_MODEL_KEY_PATH_INVALID = 145004; -static const uint32_t ACL_ERROR_GE_EXEC_MODEL_NOT_SUPPORT_ENCRYPTION = 145005; static const uint32_t ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID = 145006; static const uint32_t ACL_ERROR_GE_EXEC_MODEL_ADDR_INVALID = 145007; static const uint32_t ACL_ERROR_GE_EXEC_MODEL_QUEUE_ID_INVALID = 145008; static const uint32_t ACL_ERROR_GE_EXEC_LOAD_MODEL_REPEATED = 145009; -static const uint32_t ACL_ERROR_GE_EXEC_MODEL_PARTITION_NUM_INVALID = 145010; static const uint32_t ACL_ERROR_GE_DYNAMIC_INPUT_ADDR_INVALID = 145011; static const uint32_t ACL_ERROR_GE_DYNAMIC_INPUT_LENGTH_INVALID = 145012; static const uint32_t ACL_ERROR_GE_DYNAMIC_BATCH_SIZE_INVALID = 145013;