diff --git a/ge/host_cpu_engine/engine/host_cpu_engine.cc b/ge/host_cpu_engine/engine/host_cpu_engine.cc index cdbad1ed..62dd9ec2 100644 --- a/ge/host_cpu_engine/engine/host_cpu_engine.cc +++ b/ge/host_cpu_engine/engine/host_cpu_engine.cc @@ -34,7 +34,8 @@ Status HostCpuEngine::Initialize(const std::map &options) { if (ops_kernel_store_ == nullptr) { ops_kernel_store_ = MakeShared(); if (ops_kernel_store_ == nullptr) { - GELOGE(FAILED, "Make HostCpuOpsKernelInfoStore failed."); + GELOGE(FAILED, "[Init][HostCpuEngine] fail for new HostCpuOpsKernelInfoStore."); + REPORT_INNER_ERROR("E19999", "HostCpuEngine Initialize failed. fail for new HostCpuOpsKernelInfoStore."); return FAILED; } } diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc index adb252bc..db08ca0e 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc +++ b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#include #include "host_cpu_ops_kernel_builder.h" #include #include "common/ge_inner_error_codes.h" @@ -39,7 +39,9 @@ Status HostCpuOpsKernelBuilder::Initialize(const map & Status HostCpuOpsKernelBuilder::CalcOpRunningParam(Node &ge_node) { OpDescPtr op_desc = ge_node.GetOpDesc(); if (op_desc == nullptr) { - GELOGE(FAILED, "CalcOpRunningParam failed, as op desc is null"); + GELOGE(FAILED, "[Check][Param:OpDesc]nullptr is invalid, node:%s.", ge_node.GetName().c_str()); + REPORT_INNER_ERROR("E19999", "OpDesc is nullptr in node:%s, check invalid when CalcOpRunningParam", + ge_node.GetName().c_str()); return FAILED; } @@ -73,9 +75,12 @@ Status HostCpuOpsKernelBuilder::CalcOpRunningParam(Node &ge_node) { GeShape output_shape = output_tensor.GetShape(); if ((TensorUtils::CalcTensorMemSize(output_shape, format, data_type, output_mem_size) != GRAPH_SUCCESS) || (output_mem_size < 0)) { - GELOGE(FAILED, "Calc op[%s:%s] out[%zu] mem size failed, mem_size=%ld, format=%s, data_type=%s.", - name.c_str(), type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str()); + GELOGE(FAILED, "[Calc][TensorMemSize]fail for op[%s:%s] out[%zu], mem_size=%ld, format=%s, data_type=%s.", + name.c_str(), type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); + REPORT_CALL_ERROR("E19999", "CalcTensorMemSize failed, op[%s:%s] out[%zu], size=%ld, format=%s, type=%s.", + name.c_str(), type.c_str(), i, output_mem_size, + TypeUtils::FormatToSerialString(format).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str()); return FAILED; } GELOGI("Calc op[%s:%s] out[%zu] mem size is %ld, format=%s, data_type=%s.", @@ -84,8 +89,12 @@ Status HostCpuOpsKernelBuilder::CalcOpRunningParam(Node &ge_node) { TensorUtils::SetSize(output_tensor, output_mem_size); if (op_desc->UpdateOutputDesc(static_cast(i), output_tensor) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Update op[%s:%s] out[%zu] desc failed, format=%s, data_type=%s.", name.c_str(), type.c_str(), i, - TypeUtils::FormatToSerialString(format).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str()); + GELOGE(FAILED, "[Update][OutputDesc] fail for op[%s:%s] out[%zu], format=%s, data_type=%s.", + name.c_str(), type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); + REPORT_CALL_ERROR("E19999", "UpdateOutputDesc failed, fail for op[%s:%s] out[%zu], format=%s, data_type=%s.", + name.c_str(), type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); return FAILED; } } diff --git a/ge/init/gelib.cc b/ge/init/gelib.cc index 17e257c0..add130c4 100644 --- a/ge/init/gelib.cc +++ b/ge/init/gelib.cc @@ -1,563 +1,212 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "init/gelib.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "common/ge/ge_util.h" -#include "common/ge/plugin_manager.h" -#include "common/profiling/profiling_manager.h" -#include "common/properties_manager.h" -#include "framework/common/debug/ge_log.h" -#include "framework/common/debug/log.h" -#include "framework/common/util.h" -#include "framework/omg/ge_init.h" -#include "analyzer/analyzer.h" -#include "ge/ge_api_types.h" -#include "ge_local_engine/engine/host_cpu_engine.h" -#include "graph/common/ge_call_wrapper.h" -#include "graph/ge_context.h" -#include "graph/ge_global_options.h" -#include "graph/load/model_manager/model_manager.h" -#include "graph/manager/graph_mem_allocator.h" -#include "graph/manager/host_mem_manager.h" -#include "graph/manager/graph_var_manager.h" -#include "omm/csa_interact.h" -#include "runtime/kernel.h" -#include "opskernel_manager/ops_kernel_builder_manager.h" -#include "external/runtime/rt_error_codes.h" - -using Json = nlohmann::json; - -namespace ge { -namespace { -const int kDecimal = 10; -const int kSocVersionLen = 50; -const int kDefaultDeviceIdForTrain = 0; -const int kDefaultDeviceIdForInfer = -1; -const char *const kGlobalOptionFpCeilingModeDefault = "2"; -} // namespace -static std::shared_ptr instancePtr_ = nullptr; - -// Initial each module of GE, if one failed, release all -Status GELib::Initialize(const map &options) { - - - GELOGI("initial start"); - GEEVENT("[GEPERFTRACE] GE Init Start"); - // Multiple initializations are not allowed - instancePtr_ = MakeShared(); - if (instancePtr_ == nullptr) { - GELOGE(GE_CLI_INIT_FAILED, "GeLib initialize failed, malloc shared_ptr failed."); - return GE_CLI_INIT_FAILED; - } - - ErrorManager::GetInstance().SetStage(ErrorMessage::kInitialize, ErrorMessage::kSystemInit); - map new_options; - Status ret = instancePtr_->SetRTSocVersion(options, new_options); - if (ret != SUCCESS) { - GELOGE(ret, "GeLib initial failed."); - return ret; - } - - ret = instancePtr_->SetAiCoreNum(new_options); - if (ret != SUCCESS) { - GELOGE(ret, "GeLib initial: SetAiCoreNum failed."); - return ret; - } - - instancePtr_->SetDefaultPrecisionMode(new_options); - - if (new_options.find("ge.fpCeilingMode") == new_options.end()) { - new_options["ge.fpCeilingMode"] = kGlobalOptionFpCeilingModeDefault; - } - - GetMutableGlobalOptions().insert(new_options.begin(), new_options.end()); - GetThreadLocalContext().SetGlobalOption(GetMutableGlobalOptions()); - GE_TIMESTAMP_START(Init); - ret = instancePtr_->InnerInitialize(new_options); - if (ret != SUCCESS) { - GELOGE(ret, "GeLib initial failed."); - instancePtr_ = nullptr; - return ret; - } - GE_TIMESTAMP_EVENT_END(Init, "GELib::Initialize"); - return SUCCESS; -} - -Status GELib::InnerInitialize(const map &options) { - // Multiple initializations are not allowed - if (init_flag_) { - GELOGW("multi initializations"); - return SUCCESS; - } - - ErrorManager::GetInstance().SetStage(ErrorMessage::kInitialize, ErrorMessage::kSystemInit); - GELOGI("GE System initial."); - GE_TIMESTAMP_START(SystemInitialize); - Status initSystemStatus = SystemInitialize(options); - GE_TIMESTAMP_END(SystemInitialize, "InnerInitialize::SystemInitialize"); - if (initSystemStatus != SUCCESS) { - GELOGE(initSystemStatus, "GE system initial failed."); - RollbackInit(); - return initSystemStatus; - } - - ErrorManager::GetInstance().SetStage(ErrorMessage::kInitialize, ErrorMessage::kEngineInit); - GELOGI("engineManager initial."); - GE_TIMESTAMP_START(EngineInitialize); - Status initEmStatus = engineManager_.Initialize(options); - GE_TIMESTAMP_END(EngineInitialize, "InnerInitialize::EngineInitialize"); - if (initEmStatus != SUCCESS) { - GELOGE(initEmStatus, "GE engine manager initial failed."); - RollbackInit(); - return initEmStatus; - } - - ErrorManager::GetInstance().SetStage(ErrorMessage::kInitialize, ErrorMessage::kOpsKernelInit); - GELOGI("opsManager initial."); - GE_TIMESTAMP_START(OpsManagerInitialize); - Status initOpsStatus = opsManager_.Initialize(options); - GE_TIMESTAMP_END(OpsManagerInitialize, "InnerInitialize::OpsManagerInitialize"); - if (initOpsStatus != SUCCESS) { - GELOGE(initOpsStatus, "GE ops manager initial failed."); - RollbackInit(); - return initOpsStatus; - } - - ErrorManager::GetInstance().SetStage(ErrorMessage::kInitialize, ErrorMessage::kOpsKernelBuilderInit); - GELOGI("opsBuilderManager initial."); - GE_TIMESTAMP_START(OpsKernelBuilderManagerInitialize); - Status initOpsBuilderStatus = OpsKernelBuilderManager::Instance().Initialize(options); - GE_TIMESTAMP_END(OpsKernelBuilderManagerInitialize, "InnerInitialize::OpsKernelBuilderManager"); - if (initOpsBuilderStatus != SUCCESS) { - GELOGE(initOpsBuilderStatus, "GE ops builder manager initial failed."); - RollbackInit(); - return initOpsBuilderStatus; - } - - ErrorManager::GetInstance().SetStage(ErrorMessage::kInitialize, ErrorMessage::kOther); - GELOGI("sessionManager initial."); - GE_TIMESTAMP_START(SessionManagerInitialize); - Status initSmStatus = sessionManager_.Initialize(options); - GE_TIMESTAMP_END(SessionManagerInitialize, "InnerInitialize::SessionManagerInitialize"); - if (initSmStatus != SUCCESS) { - GELOGE(initSmStatus, "GE session manager initial failed."); - RollbackInit(); - return initSmStatus; - } - - GELOGI("Start to initialize HostCpuEngine"); - GE_TIMESTAMP_START(HostCpuEngineInitialize); - Status initHostCpuEngineStatus = HostCpuEngine::GetInstance().Initialize(); - GE_TIMESTAMP_END(HostCpuEngineInitialize, "InnerInitialize::HostCpuEngineInitialize"); - if (initHostCpuEngineStatus != SUCCESS) { - GELOGE(initHostCpuEngineStatus, "Failed to initialize HostCpuEngine"); - RollbackInit(); - return initHostCpuEngineStatus; - } - - GELOGI("Start to init Analyzer!"); - Status init_analyzer_status = ge::Analyzer::GetInstance()->Initialize(); - if (init_analyzer_status != SUCCESS) { - GELOGE(init_analyzer_status, "Failed to initialize HostCpuEngine"); - RollbackInit(); - return init_analyzer_status; - } - - init_flag_ = true; - return SUCCESS; -} - -Status GELib::SystemInitialize(const map &options) { - Status status = FAILED; - auto iter = options.find(OPTION_GRAPH_RUN_MODE); - if (iter != options.end()) { - if (GraphRunMode(std::strtol(iter->second.c_str(), nullptr, kDecimal)) >= TRAIN) { - is_train_mode_ = true; - } - } - - InitOptions(options); - - // In train and infer, profiling is always needed. - InitProfiling(this->options_); - auto model_manager = ModelManager::GetInstance(); - GE_CHECK_NOTNULL(model_manager); - GE_IF_BOOL_EXEC(model_manager->EnableExceptionDump(options) != SUCCESS, - GELOGE(FAILED, "Enable exception dump failed"); - return FAILED); - // 1.`is_train_mode_` means case: train - // 2.`(!is_train_mode_) && (options_.device_id != kDefaultDeviceIdForInfer)` means case: online infer - // these two case with logical device id - if (is_train_mode_ || (options_.device_id != kDefaultDeviceIdForInfer)) { - status = InitSystemWithOptions(this->options_); - } else { - status = InitSystemWithoutOptions(); - } - return status; -} - -void GELib::InitProfiling(Options &options) { - GELOGI("Init Profiling. session Id: %ld, device id:%d ", options.session_id, options.device_id); - std::lock_guard lock(status_mutex_); - GetContext().Init(); - // Profiling init - if (ProfilingManager::Instance().Init(options) != SUCCESS) { - GELOGW("Profiling init failed."); - } -} - -void GELib::SetDefaultPrecisionMode(map &new_options) { - auto iter = new_options.find(PRECISION_MODE); - if (iter != new_options.end()) { - GELOGI("Find precision_mode in options, value is %s", iter->second.c_str()); - return; - } - iter = new_options.find(OPTION_GRAPH_RUN_MODE); - if (iter != new_options.end()) { - if (GraphRunMode(std::strtol(iter->second.c_str(), nullptr, kDecimal)) >= TRAIN) { - // only train mode need to be set allow_fp32_to_fp16. - GELOGI("This is train mode, precision_mode need to be set allow_fp32_to_fp16"); - new_options.insert(std::make_pair(PRECISION_MODE, "allow_fp32_to_fp16")); - return; - } - } - GELOGI("This is not train mode, precision_mode need to be set force_fp16"); - new_options.insert(std::make_pair(PRECISION_MODE, "force_fp16")); - return; -} - -Status GELib::SetRTSocVersion(const map &options, map &new_options) { - GELOGI("Start to set SOC_VERSION"); - new_options.insert(options.begin(), options.end()); - auto it = new_options.find(ge::SOC_VERSION); - if (it != new_options.end()) { - GE_CHK_RT_RET(rtSetSocVersion(it->second.c_str())); - GELOGI("Succeeded in setting SOC_VERSION[%s] to runtime.", it->second.c_str()); - } else { - GELOGI("SOC_VERSION is not exist in options"); - char version[kSocVersionLen] = {0}; - rtError_t rt_ret = rtGetSocVersion(version, kSocVersionLen); - GE_IF_BOOL_EXEC(rt_ret != RT_ERROR_NONE, GELOGE(rt_ret, "rtGetSocVersion failed"); return FAILED;) - GELOGI("Succeeded in getting SOC_VERSION[%s] from runtime.", version); - new_options.insert(std::make_pair(ge::SOC_VERSION, version)); - } - return SUCCESS; -} - -Status GELib::SetAiCoreNum(map &options) { - // Already set or get AICORE_NUM from options in offline mode - if (options.find(AICORE_NUM) != options.end()) { - return SUCCESS; - } - - uint32_t aicore_num = 0; - rtError_t ret = rtGetAiCoreCount(&aicore_num); - if (ret == ACL_ERROR_RT_FEATURE_NOT_SUPPORT) { // offline without ATC Input of AiCoreNum - return SUCCESS; - } else if (ret == RT_ERROR_NONE) { // online-mode - options.emplace(std::make_pair(AICORE_NUM, std::to_string(aicore_num))); - return SUCCESS; - } - GELOGE(FAILED, "rtGetAiCoreCount failed."); - return FAILED; -} - -void GELib::InitOptions(const map &options) { - this->options_.session_id = 0; - auto iter = options.find(OPTION_EXEC_SESSION_ID); - if (iter != options.end()) { - this->options_.session_id = std::strtoll(iter->second.c_str(), nullptr, kDecimal); - } - this->options_.device_id = is_train_mode_ ? kDefaultDeviceIdForTrain : kDefaultDeviceIdForInfer; - iter = options.find(OPTION_EXEC_DEVICE_ID); - if (iter != options.end()) { - this->options_.device_id = static_cast(std::strtol(iter->second.c_str(), nullptr, kDecimal)); - } - iter = options.find(OPTION_EXEC_JOB_ID); - if (iter != options.end()) { - this->options_.job_id = iter->second.c_str(); - } - this->options_.isUseHcom = false; - iter = options.find(OPTION_EXEC_IS_USEHCOM); - if (iter != options.end()) { - std::istringstream(iter->second) >> this->options_.isUseHcom; - } - this->options_.isUseHvd = false; - iter = options.find(OPTION_EXEC_IS_USEHVD); - if (iter != options.end()) { - std::istringstream(iter->second) >> this->options_.isUseHvd; - } - this->options_.deployMode = false; - iter = options.find(OPTION_EXEC_DEPLOY_MODE); - if (iter != options.end()) { - std::istringstream(iter->second) >> this->options_.deployMode; - } - iter = options.find(OPTION_EXEC_POD_NAME); - if (iter != options.end()) { - this->options_.podName = iter->second.c_str(); - } - iter = options.find(OPTION_EXEC_PROFILING_MODE); - if (iter != options.end()) { - this->options_.profiling_mode = iter->second.c_str(); - } - iter = options.find(OPTION_EXEC_PROFILING_OPTIONS); - if (iter != options.end()) { - this->options_.profiling_options = iter->second.c_str(); - } - iter = options.find(OPTION_EXEC_RANK_ID); - if (iter != options.end()) { - this->options_.rankId = std::strtoll(iter->second.c_str(), nullptr, kDecimal); - } - iter = options.find(OPTION_EXEC_RANK_TABLE_FILE); - if (iter != options.end()) { - this->options_.rankTableFile = iter->second.c_str(); - } - this->options_.enable_atomic = true; - iter = options.find(OPTION_EXEC_ATOMIC_FLAG); - GE_IF_BOOL_EXEC(iter != options.end(), - this->options_.enable_atomic = std::strtol(iter->second.c_str(), nullptr, kDecimal)); - GELOGI("ge InnerInitialize, the enable_atomic_flag in options_ is %d", this->options_.enable_atomic); -} - -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status GELib::InitSystemWithOptions(Options &options) { - std::string mode = is_train_mode_ ? "Training" : "Online infer"; - GELOGI("%s init GELib. session Id:%ld, device id :%d ", mode.c_str(), options.session_id, options.device_id); - GEEVENT("System init with options begin, job id %s", options.job_id.c_str()); - std::lock_guard lock(status_mutex_); - GE_IF_BOOL_EXEC(is_system_inited && !is_shutdown, - GELOGW("System init with options is already inited and not shutdown."); - return SUCCESS); - - std::vector mem_type; - mem_type.push_back(RT_MEMORY_HBM); - mem_type.push_back(RT_MEMORY_P2P_DDR); - Status initMmStatus = MemManager::Instance().Initialize(mem_type); - if (initMmStatus != SUCCESS) { - GELOGE(initMmStatus, "[Initialize] MemoryAllocatorManager initialize failed."); - return initMmStatus; - } - - GE_CHK_STATUS_RET(HostMemManager::Instance().Initialize()); - // Update CSA file - CsaInteract::GetInstance().Init(options.device_id, GetContext().TraceId()); - Status ret = CsaInteract::GetInstance().WriteJobState(JOBSTATE_RUNNING, JOBSUBSTATE_ENV_INIT); - GE_LOGE_IF(ret != SUCCESS, "write job state failed, ret:%u", ret); - - // set device id - GELOGI("set logical device id:%u", options.device_id); - GetContext().SetCtxDeviceId(static_cast(options.device_id)); - GE_CHK_RT_RET(rtSetDevice(options.device_id)); - - // In the scenario that the automatic add fusion is set, but there is no cleanaddr operator, - // maybe need to check it - is_system_inited = true; - is_shutdown = false; - - GELOGI("%s init GELib success.", mode.c_str()); - - return SUCCESS; -} - -Status GELib::SystemShutdownWithOptions(const Options &options) { - std::string mode = is_train_mode_ ? "Training" : "Online infer"; - GELOGI("%s finalize GELib begin.", mode.c_str()); - std::lock_guard lock(status_mutex_); - GE_IF_BOOL_EXEC(is_shutdown || !is_system_inited, - GELOGW("System Shutdown with options is already is_shutdown or system does not inited. " - "is_shutdown:%d is_omm_inited:%d", - is_shutdown, is_system_inited); - return SUCCESS); - - GE_CHK_RT(rtDeviceReset(options.device_id)); - - // Update CSA file - Status ret = CsaInteract::GetInstance().WriteJobState(JOBSTATE_SUCCEED); - GE_LOGE_IF(ret != SUCCESS, "write job state failed, ret:%u", ret); - - is_system_inited = false; - is_shutdown = true; - GELOGI("%s finalize GELib success.", mode.c_str()); - return SUCCESS; -} - -FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status GELib::InitSystemWithoutOptions() { - GELOGI("Inference Init GELib begin."); - - std::vector mem_type; - mem_type.push_back(RT_MEMORY_HBM); - mem_type.push_back(RT_MEMORY_P2P_DDR); - Status initMmStatus = MemManager::Instance().Initialize(mem_type); - if (initMmStatus != SUCCESS) { - GELOGE(initMmStatus, "[Initialize] MemoryAllocatorManager initialize failed."); - return initMmStatus; - } - GE_CHK_STATUS_RET(HostMemManager::Instance().Initialize()); - - static bool is_inited = false; - if (is_inited) { - GELOGW("System init without options is already inited, don't need to init again."); - return SUCCESS; - } - is_inited = true; - GELOGI("Inference init GELib success."); - - return SUCCESS; -} - -string GELib::GetPath() { return PluginManager::GetPath(); } - -// Finalize all modules -Status GELib::Finalize() { - ErrorManager::GetInstance().SetStage(ErrorMessage::kFinalize, ErrorMessage::kFinalize); - GELOGI("finalization start"); - // Finalization is not allowed before initialization - if (!init_flag_) { - GELOGW("not initialize"); - return SUCCESS; - } - if (is_train_mode_ || (options_.device_id != kDefaultDeviceIdForInfer)) { - GE_CHK_RT_RET(rtSetDevice(options_.device_id)); - } - Status final_state = SUCCESS; - Status mid_state; - GELOGI("engineManager finalization."); - mid_state = engineManager_.Finalize(); - if (mid_state != SUCCESS) { - GELOGW("engineManager finalize failed"); - final_state = mid_state; - } - GELOGI("sessionManager finalization."); - mid_state = sessionManager_.Finalize(); - if (mid_state != SUCCESS) { - GELOGW("sessionManager finalize failed"); - final_state = mid_state; - } - - GELOGI("opsBuilderManager finalization."); - mid_state = OpsKernelBuilderManager::Instance().Finalize(); - if (mid_state != SUCCESS) { - GELOGW("opsBuilderManager finalize failed"); - final_state = mid_state; - } - GELOGI("opsManager finalization."); - mid_state = opsManager_.Finalize(); - if (mid_state != SUCCESS) { - GELOGW("opsManager finalize failed"); - final_state = mid_state; - } - - GELOGI("VarManagerPool finalization."); - VarManagerPool::Instance().Destory(); - - GELOGI("MemManager finalization."); - MemManager::Instance().Finalize(); - - GELOGI("HostMemManager finalization."); - HostMemManager::Instance().Finalize(); - - GELOGI("HostCpuEngine finalization."); - HostCpuEngine::GetInstance().Finalize(); - - GELOGI("Analyzer finalization"); - Analyzer::GetInstance()->Finalize(); - - // Shut down profiling - ShutDownProfiling(); - - if (is_train_mode_ || (options_.device_id != kDefaultDeviceIdForInfer)) { - GELOGI("System ShutDown."); - mid_state = SystemShutdownWithOptions(this->options_); - if (mid_state != SUCCESS) { - GELOGW("System shutdown with options failed"); - final_state = mid_state; - } - } - - is_train_mode_ = false; - - GetMutableGlobalOptions().erase(ENABLE_SINGLE_STREAM); - - if (is_train_mode_ || (options_.device_id != kDefaultDeviceIdForInfer)) { - GE_CHK_RT_RET(rtDeviceReset(options_.device_id)); - } - - instancePtr_ = nullptr; - init_flag_ = false; - if (final_state != SUCCESS) { - GELOGE(FAILED, "finalization failed."); - return final_state; - } - GELOGI("finalization success."); - return SUCCESS; -} - -void GELib::ShutDownProfiling() { - std::lock_guard lock(status_mutex_); - - if (ProfilingManager::Instance().ProfilingOn()) { - ProfilingManager::Instance().StopProfiling(); - ProfilingManager::Instance().PluginUnInit(); - } -} - -// Get Singleton Instance -std::shared_ptr GELib::GetInstance() { return instancePtr_; } - -void GELib::RollbackInit() { - if (engineManager_.init_flag_) { - (void)engineManager_.Finalize(); - } - if (opsManager_.init_flag_) { - (void)opsManager_.Finalize(); - } - if (sessionManager_.init_flag_) { - (void)sessionManager_.Finalize(); - } - MemManager::Instance().Finalize(); - HostMemManager::Instance().Finalize(); - VarManagerPool::Instance().Destory(); -} - -Status GEInit::Initialize(const map &options) { - Status ret = SUCCESS; - std::shared_ptr instance_ptr = ge::GELib::GetInstance(); - if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { - ret = GELib::Initialize(options); - } - return ret; -} - -Status GEInit::Finalize() { - std::shared_ptr instance_ptr = ge::GELib::GetInstance(); - if (instance_ptr != nullptr) { - return instance_ptr->Finalize(); - } - return SUCCESS; -} - -string GEInit::GetPath() { - return GELib::GetPath(); -} -} // namespace ge +/** + * Copyright 2019-2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "plugin/engine/engine_manage.h" + +#include +#include +#include + +#include "common/ge/ge_util.h" +#include "framework/common/debug/ge_log.h" +#include "plugin/engine/dnnengines.h" + +namespace ge { +std::unique_ptr> EngineManager::engine_map_; + +Status EngineManager::RegisterEngine(const std::string &engine_name, DNNEnginePtr engine_ptr) { + if (engine_ptr == nullptr) { + GELOGE(FAILED, "[Register][Engine] failed, as input engine_ptr is nullptr"); + REPORT_INNER_ERROR("E19999", "RegisterEngine failed, as input engine_ptr is nullptr"); + return FAILED; + } + + if (engine_map_ == nullptr) { + engine_map_.reset(new (std::nothrow) std::map()); + } + + auto it = engine_map_->find(engine_name); + if (it != engine_map_->end()) { + GELOGW("engine %s already exist.", engine_name.c_str()); + return FAILED; + } + engine_map_->emplace(engine_name, engine_ptr); + return SUCCESS; +} + +DNNEnginePtr EngineManager::GetEngine(const std::string &engine_name) { + auto it = engine_map_->find(engine_name); + if (it == engine_map_->end()) { + GELOGW("engine %s not exist.", engine_name.c_str()); + return nullptr; + } + + auto engine = it->second; + return engine; +} + +void RegisterAiCoreEngine() { + const std::string ai_core = "AIcoreEngine"; + std::vector mem_type_aicore; + mem_type_aicore.emplace_back(GE_ENGINE_ATTR_MEM_TYPE_HBM); + DNNEngineAttribute attr_aicore = {ai_core, mem_type_aicore, COST_0, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; + DNNEnginePtr aicore_engine_ptr = MakeShared(attr_aicore); + if (aicore_engine_ptr == nullptr) { + GELOGE(ge::FAILED, "[Register][AiCoreEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterAiCoreEngine failed, as malloc shared_ptr failed."); + return; + } + if (EngineManager::RegisterEngine(ai_core, aicore_engine_ptr) != SUCCESS) { + GELOGW("register ai_core failed"); + } +} + +void RegisterVectorEngine() { + const std::string vector_core = "VectorEngine"; + std::vector mem_type_aivcore; + mem_type_aivcore.emplace_back(GE_ENGINE_ATTR_MEM_TYPE_HBM); + DNNEngineAttribute attr_vector_core = {vector_core, mem_type_aivcore, COST_1, + DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; + DNNEnginePtr vectorcore_engine_ptr = MakeShared(attr_vector_core); + if (vectorcore_engine_ptr == nullptr) { + GELOGE(ge::FAILED, "[Register][VectorEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterVectorEngine failed, as malloc shared_ptr failed."); + return; + } + if (EngineManager::RegisterEngine(vector_core, vectorcore_engine_ptr) != SUCCESS) { + GELOGW("register vector_core failed"); + } +} + +void RegisterAiCpuEngine() { + const std::string vm_aicpu = "DNN_VM_AICPU_ASCEND"; + std::vector mem_type_aicpu; + mem_type_aicpu.emplace_back(GE_ENGINE_ATTR_MEM_TYPE_HBM); + DNNEngineAttribute attr_aicpu = {vm_aicpu, mem_type_aicpu, COST_3, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; + DNNEnginePtr vm_engine_ptr = MakeShared(attr_aicpu); + if (vm_engine_ptr == nullptr) { + GELOGE(ge::FAILED, "[Register][AiCpuEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterAiCpuEngine failed, as malloc shared_ptr failed."); + return; + } + if (EngineManager::RegisterEngine(vm_aicpu, vm_engine_ptr) != SUCCESS) { + GELOGW("register vmAicpuEngine failed"); + } +} + +void RegisterAiCpuTFEngine() { + const std::string vm_aicpu_tf = "DNN_VM_AICPU"; + std::vector mem_type_aicpu_tf; + mem_type_aicpu_tf.emplace_back(GE_ENGINE_ATTR_MEM_TYPE_HBM); + DNNEngineAttribute attr_aicpu_tf = {vm_aicpu_tf, mem_type_aicpu_tf, COST_2, DEVICE, + FORMAT_RESERVED, FORMAT_RESERVED}; + DNNEnginePtr vm_engine_ptr = MakeShared(attr_aicpu_tf); + if (vm_engine_ptr == nullptr) { + GELOGE(ge::FAILED, "[Register][AiCpuTFEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterAiCpuTFEngine failed, as malloc shared_ptr failed."); + return; + } + if (EngineManager::RegisterEngine(vm_aicpu_tf, vm_engine_ptr) != SUCCESS) { + GELOGW("register vmAicpuTFEngine failed"); + } +} + +void RegisterGeLocalEngine() { + const std::string vm_ge_local = "DNN_VM_GE_LOCAL"; + std::vector mem_type_ge_local; + mem_type_ge_local.emplace_back(GE_ENGINE_ATTR_MEM_TYPE_HBM); + // GeLocal use minimum priority, set it as 9 + DNNEngineAttribute attr_ge_local = {vm_ge_local, mem_type_ge_local, COST_9, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; + DNNEnginePtr ge_local_engine = MakeShared(attr_ge_local); + if (ge_local_engine == nullptr) { + GELOGE(ge::FAILED, "[Register][GeLocalEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterGeLocalEngine failed, as malloc shared_ptr failed."); + return; + } + if (EngineManager::RegisterEngine(vm_ge_local, ge_local_engine) != SUCCESS) { + GELOGW("register ge_local_engine failed"); + } +} + +void RegisterHostCpuEngine() { + const std::string vm_host_cpu = "DNN_VM_HOST_CPU"; + std::vector mem_type_host_cpu; + mem_type_host_cpu.emplace_back(GE_ENGINE_ATTR_MEM_TYPE_HBM); + // HostCpu use minimum priority, set it as 10 + DNNEngineAttribute attr_host_cpu = {vm_host_cpu, mem_type_host_cpu, COST_10, + HOST, FORMAT_RESERVED, FORMAT_RESERVED}; + DNNEnginePtr host_cpu_engine = MakeShared(attr_host_cpu); + if (host_cpu_engine == nullptr) { + GELOGE(ge::FAILED, "[Register][HostCpuEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterHostCpuEngine failed, as malloc shared_ptr failed."); + return; + } + if (EngineManager::RegisterEngine(vm_host_cpu, host_cpu_engine) != SUCCESS) { + GELOGW("register host_cpu_engine failed"); + } +} + +void RegisterRtsEngine() { + const std::string vm_rts = "DNN_VM_RTS"; + std::vector mem_type_rts; + mem_type_rts.emplace_back(GE_ENGINE_ATTR_MEM_TYPE_HBM); + DNNEngineAttribute attr_rts = {vm_rts, mem_type_rts, COST_1, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; + DNNEnginePtr rts_engine = MakeShared(attr_rts); + if (rts_engine == nullptr) { + GELOGE(ge::FAILED, "[Register][RtsEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterRtsEngine failed, as malloc shared_ptr failed."); + return; + } + if (EngineManager::RegisterEngine(vm_rts, rts_engine) != SUCCESS) { + GELOGW("register rts_engine failed"); + } +} + +void RegisterHcclEngine() { + const std::string dnn_hccl = "DNN_HCCL"; + std::vector mem_type_hccl; + mem_type_hccl.emplace_back(GE_ENGINE_ATTR_MEM_TYPE_HBM); + DNNEngineAttribute attr_hccl = {dnn_hccl, mem_type_hccl, COST_1, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; + DNNEnginePtr hccl_engine = MakeShared(attr_hccl); + if (hccl_engine == nullptr) { + GELOGE(ge::FAILED, "[Register][HcclEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterHcclEngine failed, as malloc shared_ptr failed."); + return; + } + if (EngineManager::RegisterEngine(dnn_hccl, hccl_engine) != SUCCESS) { + GELOGW("register hccl_engine failed"); + } +} + +void GetDNNEngineObjs(std::map &engines) { + RegisterAiCoreEngine(); + RegisterVectorEngine(); + RegisterAiCpuTFEngine(); + RegisterAiCpuEngine(); + RegisterGeLocalEngine(); + RegisterHostCpuEngine(); + RegisterRtsEngine(); + RegisterHcclEngine(); + + for (auto it = EngineManager::engine_map_->begin(); it != EngineManager::engine_map_->end(); ++it) { + GELOGI("get engine %s from engine plugin.", it->first.c_str()); + engines.emplace(std::pair(it->first, it->second)); + } + + GELOGI("after get engine, engine size: %zu", engines.size()); + return; +} +} // namespace ge diff --git a/ge/ir_build/atc_ir_common.cc b/ge/ir_build/atc_ir_common.cc index 667f06e6..db2624d0 100755 --- a/ge/ir_build/atc_ir_common.cc +++ b/ge/ir_build/atc_ir_common.cc @@ -80,7 +80,7 @@ Status CheckInputFormat(const string &input_format) { if (!ge::TypeUtils::IsFormatValid(input_format.c_str())) { ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, {"--input_format", input_format, "input format is invalid!"}); - GELOGE(ge::PARAM_INVALID, "input format [%s] is invalid!", input_format.c_str()); + GELOGE(ge::PARAM_INVALID, "[Check][InputFormat] --input_format[%s] is invalid!", input_format.c_str()); return ge::PARAM_INVALID; } return ge::SUCCESS; @@ -93,7 +93,7 @@ bool CheckDynamicBatchSizeInputShapeValid(map> shape_map vector shape = iter->second; if (shape.empty()) { ErrorManager::GetInstance().ATCReportErrMessage("E10012"); - GELOGE(ge::PARAM_INVALID, "--input_shape's shape size can not be less than 1 when set --dynamic_batch_size."); + GELOGE(ge::PARAM_INVALID, "[Check][Param] shape size can not be less than 1 when set --dynamic_batch_size."); return false; } @@ -109,7 +109,7 @@ bool CheckDynamicBatchSizeInputShapeValid(map> shape_map if (size == 0) { ErrorManager::GetInstance().ATCReportErrMessage("E10031"); - GELOGE(ge::PARAM_INVALID, "At least one batch n must be equal to -1 when set --dynamic_batch_size."); + GELOGE(ge::PARAM_INVALID, "[Check][Param]At least one batch n must be equal to -1 when set dynamic_batch_size."); return false; } @@ -117,8 +117,8 @@ bool CheckDynamicBatchSizeInputShapeValid(map> shape_map if (!isdigit(c) && (c != ',') && (c != ' ')) { ErrorManager::GetInstance().ATCReportErrMessage( "E10033", {"value", "reason"}, {dynamic_batch_size, kDynamicBatchSizeError}); - GELOGE(ge::PARAM_INVALID, "Input parameter[--dynamic_batch_size]'s value[%s] is invalid. reason: %s", - dynamic_batch_size.c_str(), kDynamicBatchSizeError); + GELOGE(ge::PARAM_INVALID, "[Check][Param] dynamic_batch_size:%s is invalid. reason: %s", + dynamic_batch_size.c_str(), kDynamicBatchSizeError); return false; } } @@ -131,7 +131,7 @@ bool CheckDynamicBatchSizeInputShapeValid(map> shape_map bool CheckDynamicImagesizeInputShapeValid(map> shape_map, const std::string input_format, std::string &dynamic_image_size) { if (!input_format.empty() && !ge::TypeUtils::IsFormatValid(input_format.c_str())) { - GELOGE(ge::PARAM_INVALID, "user input format [%s] is not found!", input_format.c_str()); + GELOGE(ge::PARAM_INVALID, "[Check][Param] input_format [%s] invalid.", input_format.c_str()); return false; } int32_t size = 0; @@ -141,8 +141,8 @@ bool CheckDynamicImagesizeInputShapeValid(map> shape_map if (shape.size() != DIM_DEFAULT_SIZE) { if (std::count(shape.begin(), shape.end(), kDynamicInputDim) > 0) { ErrorManager::GetInstance().ATCReportErrMessage("E10019"); - GELOGE(ge::PARAM_INVALID, - "--input_shape's shape is invalid, only height and width can be -1 when set --dynamic_image_size."); + GELOGE(ge::PARAM_INVALID, + "[Check][Param] shape invalid, only height and width can be -1 when set --dynamic_image_size."); return false; } continue; @@ -161,7 +161,7 @@ bool CheckDynamicImagesizeInputShapeValid(map> shape_map if (size == 0) { ErrorManager::GetInstance().ATCReportErrMessage("E10019"); GELOGE(ge::PARAM_INVALID, - "--input_shape's shape is invalid, only height and width can be -1 when set --dynamic_image_size."); + "[Check][Param]shape invalid, only height and width can be -1 when set --dynamic_image_size."); return false; } @@ -176,9 +176,8 @@ bool CheckDynamicImagesizeInputShapeValid(map> shape_map ErrorManager::GetInstance().ATCReportErrMessage("E10020", {"DynamicImageSizeNum"}, {std::to_string(kDynamicImageSizeNum)}); GELOGE(ge::PARAM_INVALID, - "--dynamic_image_size's number of dimensions of each " - "group must be %ld.", - kDynamicImageSizeNum); + "[Check][Param] invalid value:%s number of dimensions of each group must be %ld.", + dynamic_image_size.c_str(), kDynamicImageSizeNum); return false; } } @@ -192,7 +191,7 @@ bool CheckDynamicDimsInputShapeValid(const map> &shape_m ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, {"--input_format", input_format.c_str(), "input_format must be ND when set dynamic_dims"}); - GELOGE(ge::PARAM_INVALID, "input_format must be ND when set dynamic_dims."); + GELOGE(ge::PARAM_INVALID, "[Check][Param]--input_format must be ND when set dynamic_dims."); return false; } @@ -202,8 +201,9 @@ bool CheckDynamicDimsInputShapeValid(const map> &shape_m if (shapes.size() > kMaxNDDimNum || shapes.size() < kMinNDDimNum) { ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, - {"--input_shape's dim", std::to_string(shapes.size()), "Dim num must within [1, 4] when set dynamic_dims"}); - GELOGE(ge::PARAM_INVALID, "Dim num must within [%zu, %zu] when set dynamic_dims.", kMinNDDimNum, kMaxNDDimNum); + {"input_shape's dim", std::to_string(shapes.size()), "Dim num must within [1, 4] when set dynamic_dims"}); + GELOGE(ge::PARAM_INVALID, "[Check][Param]Dim num must within [%zu, %zu] when set dynamic_dims.", + kMinNDDimNum, kMaxNDDimNum); return false; } dynamic_dim += std::count(shapes.begin(), shapes.end(), kDynamicInputDim); @@ -212,12 +212,13 @@ bool CheckDynamicDimsInputShapeValid(const map> &shape_m ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, {"--input_shape's dynamic dim num", "0", "at least one dim should be -1 when set dynamic_dims"}); - GELOGE(ge::PARAM_INVALID, "input_shape's shape is invalid, at least one dim should be -1 when set dynamic_dims."); + GELOGE(ge::PARAM_INVALID, + "[Check][Param]--input_shape invalid, at least one dim should be -1 when set dynamic_dims."); return false; } if (!CheckAndParseDynamicDims(dynamic_dim, dynamic_dims)) { - GELOGE(ge::PARAM_INVALID, "Check and parse dynamic dims: %s failed.", dynamic_dims.c_str()); + GELOGE(ge::PARAM_INVALID, "[CheckAndParse][DynamicDims]: %s failed.", dynamic_dims.c_str()); return false; } @@ -230,7 +231,7 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, {"--dynamic_dims", dynamic_dims.c_str(), "dynamic_dims can not be empty"}); - GELOGE(ge::PARAM_INVALID, "dynamic_dims can not be empty."); + GELOGE(ge::PARAM_INVALID, "[Check][Param]--dynamic_dims can not be empty."); return false; } // Different parameter sets are split by ';' @@ -238,7 +239,8 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims if (split_set.size() > kMaxDynamicDimNum) { ErrorManager::GetInstance().ATCReportErrMessage( "E10042", {"parameter", "reason"}, {"dynamic_dims", "dynamic_dims's num of parameter set can not exceed 100"}); - GELOGE(ge::PARAM_INVALID, "dynamic_dims's num of parameter set can not exceed %zu.", kMaxDynamicDimNum); + GELOGE(ge::PARAM_INVALID, + "[Check][Param]dynamic_dims's num of parameter set can not exceed %zu.", kMaxDynamicDimNum); return false; } for (auto split_dim : split_set) { @@ -247,8 +249,9 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims ErrorManager::GetInstance().ATCReportErrMessage( "E10042", {"parameter", "reason"}, {"dynamic_dims", "Each gear setting needs to be consistent with the number of -1 in the inputshape"}); - GELOGE(ge::PARAM_INVALID, "Input parameter --dynamic_dims parse failed, " - "reason: Each gear setting needs to be consistent with the number of -1 in the inputshape."); + GELOGE(ge::PARAM_INVALID, "[Check][Param]dynamic_dims:%s invalid. " + "reason: Each gear setting needs to be consistent with the number of -1 in the inputshape.", + dynamic_dims.c_str()); return false; } for (auto dim : one_set) { @@ -257,7 +260,8 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, {"--dynamic_dims's parameter", dim.c_str(), "must be positive integer"}); - GELOGE(ge::PARAM_INVALID, "dynamic_dims's parameter must be positive integer."); + GELOGE(ge::PARAM_INVALID, + "[Check][Param]--dynamic_dims:%s parameter must be positive integer.", dynamic_dims.c_str()); return false; } } @@ -273,15 +277,13 @@ bool StringToLongNoThrow(const string &str, long &val) { } catch (const std::invalid_argument) { ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape_range", "reason", "sample"}, {str, kShapeRangeValueConvertError, kInputShapeRangeSample3}); - GELOGE(PARAM_INVALID, - "Parse input parameter [--input_shape_range]'s shape range[%s] failed, reason: %s, correct sample is %s.", - str.c_str(), kShapeRangeValueConvertError, kInputShapeRangeSample3); + GELOGE(PARAM_INVALID, "[Parse][Parameter] str:%s invalid, reason: %s, correct sample is %s.", + str.c_str(), kShapeRangeValueConvertError, kInputShapeRangeSample3); } catch (const std::out_of_range) { ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape_range", "reason", "sample"}, {str, kShapeRangeValueConvertError, kInputShapeRangeSample3}); - GELOGE(PARAM_INVALID, - "Parse input parameter [--input_shape_range]'s shape range[%s] failed, reason: %s, correct sample is %s.", - str.c_str(), kShapeRangeValueConvertError, kInputShapeRangeSample3); + GELOGE(PARAM_INVALID, "[Parse][Parameter] str:%s invalid, reason: %s, correct sample is %s.", + str.c_str(), kShapeRangeValueConvertError, kInputShapeRangeSample3); } return false; } @@ -299,9 +301,8 @@ bool ParseSingleShapeRange(std::string &shape_range, vector> shape_range_val; if (!ParseSingleShapeRange(shape_range_str, shape_range_val)) { - GELOGE(PARAM_INVALID, "Parse single shape range %s error.", shape_range_str.c_str()); + GELOGE(PARAM_INVALID, "[Parse][Param] shape_range_str: %s invalid.", shape_range_str.c_str()); return false; } shape_range_map.emplace(make_pair(StringUtils::Trim(shape_range_pair_vec[0]), shape_range_val)); @@ -392,15 +392,16 @@ bool ParseInputShapeRange(const std::string &shape_range, } Status CheckDynamicInputParamValid(string &dynamic_batch_size, string &dynamic_image_size, string &dynamic_dims, - const string input_shape, const string input_shape_range, const string input_format, - bool &is_dynamic_input) { - int32_t param_size = static_cast(!dynamic_batch_size.empty()) + - static_cast(!dynamic_image_size.empty()) + static_cast(!dynamic_dims.empty()); - if (param_size > 1) { - ErrorManager::GetInstance().ATCReportErrMessage("E10009", {"parameter0", "parameter1", "parameter2"}, + const string input_shape, const string input_shape_range, const string input_format,bool &is_dynamic_input) + { + int32_t param_size = static_cast(!dynamic_batch_size.empty()) + + static_cast(!dynamic_image_size.empty()) + static_cast(!dynamic_dims.empty()); + if (param_size > 1) { + ErrorManager::GetInstance().ATCReportErrMessage("E10009", {"parameter0", "parameter1", "parameter2"}, {"dynamic_batch_size", "dynamic_image_size", "dynamic_dims"}); - GELOGE(ge::PARAM_INVALID, "dynamic_batch_size, dynamic_image_size and dynamic_dims can only be set one"); - return ge::PARAM_INVALID; + GELOGE(ge::PARAM_INVALID, + "[Parse][Param]dynamic_batch_size, dynamic_image_size and dynamic_dims can only be set one"); + return ge::PARAM_INVALID; } if (param_size == 0) { @@ -419,33 +420,34 @@ Status CheckDynamicInputParamValid(string &dynamic_batch_size, string &dynamic_i is_dynamic_input = true; if (input_shape.empty()) { ErrorManager::GetInstance().ATCReportErrMessage("E10004", {"parameter"}, {"input_shape"}); - GELOGE(ge::PARAM_INVALID, "The input_shape can not be empty in dynamic input size scenario."); + GELOGE(ge::PARAM_INVALID, "[Check][Param]The input_shape can not be empty in dynamic input size scenario."); return ge::PARAM_INVALID; } if (!ParseInputShape(input_shape, shape_map, user_shape_map, is_dynamic_input)) { - GELOGE(ge::PARAM_INVALID, "Failed to parse input shape: %s", input_shape.c_str()); + GELOGE(ge::PARAM_INVALID, "[Parse][InputShape]input_shape: %s invalid.", input_shape.c_str()); return ge::PARAM_INVALID; } if (!dynamic_batch_size.empty()) { if (!CheckDynamicBatchSizeInputShapeValid(shape_map, dynamic_batch_size)) { - GELOGE(ge::PARAM_INVALID, "Check dynamic batch size input shape failed: %s", input_shape.c_str()); + GELOGE(ge::PARAM_INVALID, "[Check][DynamicBatchSizeInputShape] input_shape: %s invalid.", input_shape.c_str()); return ge::PARAM_INVALID; } } if (!dynamic_image_size.empty()) { if (!CheckDynamicImagesizeInputShapeValid(shape_map, input_format, dynamic_image_size)) { - GELOGE(ge::PARAM_INVALID, "Check dynamic image size input shape failed: %s", input_shape.c_str()); + GELOGE(ge::PARAM_INVALID, "[Check][DynamicImagesizeInputShape] %s invalid. dynamic_image_size:%s ", + input_shape.c_str(), dynamic_image_size.c_str()); return ge::PARAM_INVALID; } } if (!dynamic_dims.empty()) { if (!CheckDynamicDimsInputShapeValid(shape_map, input_format, dynamic_dims)) { - GELOGE(ge::PARAM_INVALID, "Check dynamic dims: %s of input shape: %s failed.", dynamic_dims.c_str(), - input_shape.c_str()); + GELOGE(ge::PARAM_INVALID, "[Check][DynamicDimsInputShape]: %s of input shape: %s failed.", dynamic_dims.c_str(), + input_shape.c_str()); return ge::PARAM_INVALID; } } @@ -496,7 +498,7 @@ bool ParseInputShape(const string &input_shape, map> &sh if (!isdigit(c)) { ErrorManager::GetInstance().ATCReportErrMessage("E10002", {"shape", "reason", "sample"}, {shape, kDigitError, kInputShapeSample2}); - GELOGE(PARAM_INVALID, "--input_shape's shape value[%s] is not digit", shape_value_str.c_str()); + GELOGE(PARAM_INVALID, "[Check][Param]input_shape:%s invalid", shape_value_str.c_str()); return false; } } @@ -519,7 +521,8 @@ bool ParseInputShape(const string &input_shape, map> &sh int64_t result = left_result; // - 1 is not currently supported if (!is_dynamic_input && result <= 0) { - ErrorManager::GetInstance().ATCReportErrMessage("E10011", {"shape", "result"}, {shape, std::to_string(result)}); + ErrorManager::GetInstance().ATCReportErrMessage("E10011", {"shape", "result"}, + {shape, std::to_string(result)}); GELOGW( "Input parameter[--input_shape]’s shape value[%s] is invalid, " "expect positive integer, but value is %ld.", @@ -541,7 +544,7 @@ Status CheckOutputTypeParamValid(const std::string output_type) { ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, {"--output_type", output_type, kOutputTypeSupport}); GELOGE(ge::PARAM_INVALID, - "Invalid value for --output_type[%s], %s.", output_type.c_str(), kOutputTypeSupport); + "[Check][Param]Invalid value for --output_type[%s], %s.", output_type.c_str(), kOutputTypeSupport); return ge::PARAM_INVALID; } return ge::SUCCESS; @@ -553,30 +556,33 @@ Status CheckBufferOptimizeParamValid(const std::string buffer_optimize) { ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, {"--buffer_optimize", buffer_optimize, kBufferOptimizeSupport}); GELOGE(ge::PARAM_INVALID, - "Invalid value for --buffer_optimize[%s], %s.", buffer_optimize.c_str(), kBufferOptimizeSupport); + "[Check][BufferOptimize]Invalid value for [%s], %s.", buffer_optimize.c_str(), kBufferOptimizeSupport); return ge::PARAM_INVALID; } return ge::SUCCESS; } -Status CheckCompressWeightParamValid(const std::string enable_compress_weight, const std::string compress_weight_conf) { +Status CheckCompressWeightParamValid(const std::string enable_compress_weight, + const std::string compress_weight_conf) { if ((!compress_weight_conf.empty()) && (!CheckInputPathValid(compress_weight_conf, "--compress_weight_conf"))) { - GELOGE(ge::PARAM_INVALID, "compress weight config file not found, file_name:%s", compress_weight_conf.c_str()); + GELOGE(ge::PARAM_INVALID, "[Check][CompressWeight]compress weight config file not found, file_name:%s", + compress_weight_conf.c_str()); return ge::PARAM_INVALID; } if ((enable_compress_weight != "") && (enable_compress_weight != "true") && (enable_compress_weight != "false")) { ErrorManager::GetInstance().ATCReportErrMessage( "E10005", {"parameter", "value"}, {"enable_compress_weight", enable_compress_weight}); GELOGE(ge::PARAM_INVALID, - "Input parameter[--enable_compress_weight]'s value[%s] must be true or false.", enable_compress_weight.c_str()); + "[Check][CompressWeight]enable_compress_weight:%s must be true or false.", enable_compress_weight.c_str()); return ge::PARAM_INVALID; } if ((enable_compress_weight == "true") && (!compress_weight_conf.empty())) { ErrorManager::GetInstance().ATCReportErrMessage("E10047", {"parameter0", "parameter1"}, {"enable_compress_weight", "compress_weight_conf"}); - GELOGE(ge::PARAM_INVALID, "enable_compress_weight and compress_weight_conf can not both exist!!"); + GELOGE(ge::PARAM_INVALID, + "[Check][CompressWeight]enable_compress_weight and compress_weight_conf can not both exist!!"); return ge::PARAM_INVALID; } return ge::SUCCESS; @@ -586,7 +592,7 @@ Status CheckKeepTypeParamValid(const std::string &keep_dtype) { if ((!keep_dtype.empty()) && (!CheckInputPathValid(keep_dtype, "--keep_dtype"))) { ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, {"--keep_dtype", keep_dtype, kKeepDtypeError}); - GELOGE(ge::PARAM_INVALID, "keep dtype config file not found, file_name:%s", keep_dtype.c_str()); + GELOGE(ge::PARAM_INVALID, "[Check][InputPath] file not found, file_name:%s", keep_dtype.c_str()); return ge::PARAM_INVALID; } @@ -608,11 +614,12 @@ int CheckLogParamValidAndSetLogLevel(const std::string log) { } else if (log == "error") { ret = dlog_setlevel(-1, DLOG_ERROR, 1); } else { - GELOGE(ge::PARAM_INVALID, "invalid value for log:%s, only support debug, info, warning, error, null", log.c_str()); + GELOGE(ge::PARAM_INVALID, + "[Check][LogParam]log:%s invalid, only support debug, info, warning, error, null", log.c_str()); return ret; } if (ret != 0) { - GELOGE(ge::PARAM_INVALID, "Log setlevel fail !"); + GELOGE(ge::PARAM_INVALID, "[Check][LogParam]Log setlevel fail !"); } return ret; } @@ -620,7 +627,7 @@ int CheckLogParamValidAndSetLogLevel(const std::string log) { Status CheckInsertOpConfParamValid(const std::string insert_op_conf) { if ((!insert_op_conf.empty()) && (!CheckInputPathValid(insert_op_conf, "--insert_op_conf"))) { - GELOGE(ge::PARAM_INVALID, "insert op config file not found: %s", insert_op_conf.c_str()); + GELOGE(ge::PARAM_INVALID, "[Check][InputPath]file not found: %s", insert_op_conf.c_str()); return ge::PARAM_INVALID; } return ge::SUCCESS; @@ -629,7 +636,7 @@ Status CheckInsertOpConfParamValid(const std::string insert_op_conf) { Status CheckDisableReuseMemoryParamValid(const std::string disable_reuse_memory) { if ((disable_reuse_memory != "") && (disable_reuse_memory != "0") && (disable_reuse_memory != "1")) { ErrorManager::GetInstance().ATCReportErrMessage("E10006", {"parameter"}, {"disable_reuse_memory"}); - GELOGE(ge::PARAM_INVALID, "Input parameter[--disable_reuse_memory]'s value must be 1 or 0."); + GELOGE(ge::PARAM_INVALID, "[Check][DisableReuseMemory]disable_reuse_memory must be 1 or 0."); return ge::PARAM_INVALID; } return ge::SUCCESS; @@ -639,8 +646,8 @@ Status CheckEnableSingleStreamParamValid(const std::string enable_single_stream) if ((enable_single_stream != "") && (enable_single_stream != "true") && (enable_single_stream != "false")) { ErrorManager::GetInstance().ATCReportErrMessage( "E10005", {"parameter", "value"}, {"enable_single_stream", enable_single_stream}); - GELOGE(ge::PARAM_INVALID, "Input parameter[--enable_single_stream]'s value[%s] must be true or false.", - enable_single_stream.c_str()); + GELOGE(ge::PARAM_INVALID, "[Check][EnableSingleStream]enable_single_stream:%s must be true or false.", + enable_single_stream.c_str()); return ge::PARAM_INVALID; } return ge::SUCCESS; @@ -651,8 +658,8 @@ Status CheckImplmodeParamValid(const std::string &optypelist_for_implmode, std:: if (optypelist_for_implmode != "" && op_select_implmode == "") { ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, {"--op_select_implmode", op_select_implmode.c_str(), kCompressWeightError}); - GELOGE(ge::PARAM_INVALID, "Invalid value for --op_select_implmode[%s], %s.", - op_select_implmode.c_str(), kCompressWeightError); + GELOGE(ge::PARAM_INVALID, "[Check][Implmode]op_select_implmode:%s invalid, %s.", + op_select_implmode.c_str(),kCompressWeightError); return ge::PARAM_INVALID; } // op_select_implmode default value is high_performance @@ -663,7 +670,7 @@ Status CheckImplmodeParamValid(const std::string &optypelist_for_implmode, std:: op_select_implmode != IR_OPTION_OP_SELECT_IMPLMODE_PRECISON) { ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, {"--op_select_implmode", op_select_implmode.c_str(), kSelectImplmodeError}); - GELOGE(ge::PARAM_INVALID, "Invalid value for --op_select_implmode[%s], %s.", + GELOGE(ge::PARAM_INVALID, "[Check][Implmode]Invalid value for --op_select_implmode[%s], %s.", op_select_implmode.c_str(), kSelectImplmodeError); return ge::PARAM_INVALID; } @@ -729,7 +736,7 @@ Status UpdateDataOpShapeRange(const OpDescPtr &op, if (iter != shape_range_map.end()) { auto cur_shape_range = iter->second; if (TensorUtils::CheckShapeByShapeRange(origin_shape, cur_shape_range) != SUCCESS) { - GELOGE(PARAM_INVALID, "[%s] Check shape by shape range failed.", op->GetName().c_str()); + GELOGE(PARAM_INVALID, "[Check][OpDescPtr][%s] Check shape by shape range failed.", data_op_name.c_str()); return PARAM_INVALID; } for (size_t idx = 0; idx < cur_shape_range.size(); idx++) { @@ -757,7 +764,7 @@ Status UpdateDynamicInputShapeRange(const ge::ComputeGraphPtr &compute_graph, co map>> shape_range_map; if (!ParseInputShapeRange(input_shape_range, shape_range_map)) { - GELOGE(PARAM_INVALID, "Parse input shape range failed."); + GELOGE(PARAM_INVALID, "[Parse][InputShapeRange] input_shape_range:%s invalid.", input_shape_range.c_str()); return PARAM_INVALID; } @@ -767,7 +774,7 @@ Status UpdateDynamicInputShapeRange(const ge::ComputeGraphPtr &compute_graph, co GE_CHECK_NOTNULL(op); if (op->GetType() == DATA) { if (UpdateDataOpShapeRange(op, shape_range_map) != SUCCESS) { - GELOGE(FAILED, "Update data op [%s] input shape range failed.", op->GetName().c_str()); + GELOGE(FAILED, "[Update][InputShapeRange] op[%s] invalid.", op->GetName().c_str()); return FAILED; } } diff --git a/ge/ir_build/ge_ir_build.cc b/ge/ir_build/ge_ir_build.cc index bd1be318..bbae61d4 100644 --- a/ge/ir_build/ge_ir_build.cc +++ b/ge/ir_build/ge_ir_build.cc @@ -85,21 +85,21 @@ static graphStatus CheckGlobalOptions(std::map &global ? IR_OPTION_DISABLE_REUSE_MEMORY_DEFAULT : global_options[ge::ir_option::EXEC_DISABLE_REUSED_MEMORY]; GE_CHK_BOOL_EXEC(ge::CheckDisableReuseMemoryParamValid(disable_reuse_memory) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check disable_reuse_memory failed!"); + return ge::GRAPH_PARAM_INVALID, "[Check][DisableReuseMemory] failed!"); global_options[ge::ir_option::EXEC_DISABLE_REUSED_MEMORY] = disable_reuse_memory; // check buffer_optimize std::string buffer_optimize = global_options.find(ge::ir_option::BUFFER_OPTIMIZE) == global_options.end() ? IR_OPTION_BUFFER_OPTIMIZE_DEFAULT : global_options[ge::ir_option::BUFFER_OPTIMIZE]; GE_CHK_BOOL_EXEC(ge::CheckBufferOptimizeParamValid(buffer_optimize) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check buffer optimize failed!"); + return ge::GRAPH_PARAM_INVALID, "[Check][BufferOptimize] failed!"); global_options[ge::ir_option::BUFFER_OPTIMIZE] = buffer_optimize; // check enable_single_stream std::string enable_single_stream = global_options.find(ge::ir_option::ENABLE_SINGLE_STREAM) == global_options.end() ? "" : global_options[ge::ir_option::ENABLE_SINGLE_STREAM]; GE_CHK_BOOL_EXEC(ge::CheckEnableSingleStreamParamValid(enable_single_stream) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check enable single stream failed!"); + return ge::GRAPH_PARAM_INVALID, "[Check][EnableSingleStream] failed!"); // check compress_weight std::string enable_compress_weight = global_options.find(ge::ir_option::ENABLE_COMPRESS_WEIGHT) == global_options.end() @@ -109,7 +109,7 @@ static graphStatus CheckGlobalOptions(std::map &global ? "" : global_options[ge::ir_option::COMPRESS_WEIGHT_CONF]; GE_CHK_BOOL_EXEC(ge::CheckCompressWeightParamValid(enable_compress_weight, compress_weight_conf) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check compress weight failed!"); + return ge::GRAPH_PARAM_INVALID, "[Check][CompressWeight] failed!"); global_options[ge::ir_option::ENABLE_COMPRESS_WEIGHT] = (enable_compress_weight == "true") ? ge::kEnableCompressWeightTrue : ge::kEnableCompressWeightFalse; @@ -124,7 +124,7 @@ static graphStatus CheckGlobalOptions(std::map &global : global_options[ge::ir_option::OP_SELECT_IMPL_MODE]; GE_CHK_BOOL_EXEC( ge::CheckImplmodeParamValid(optypelist_for_implmode, op_select_implmode) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check optypelist_for_implmode and op_select_implmode failed!"); + return ge::GRAPH_PARAM_INVALID, "[Check][Implmode] failed!"); global_options[ge::ir_option::OP_SELECT_IMPL_MODE] = op_select_implmode; // set precision mode default value @@ -144,7 +144,7 @@ static void GetOpsProtoPath(string &opsproto_path) { string path = path_env; string file_path = RealPath(path.c_str()); if (file_path.empty()) { - GELOGE(FAILED, "File path %s is invalid.", path.c_str()); + GELOGE(FAILED, "[Check][Path] %s is invalid.", path.c_str()); return; } opsproto_path = (path + "/op_proto/custom/" + ":") + (path + "/op_proto/built-in/"); @@ -172,7 +172,7 @@ graphStatus aclgrphBuildInitializeImpl(std::map &globa GELOGD("Enter aclgrphInitialize start!"); // check global options if (CheckGlobalOptions(global_options) != GRAPH_SUCCESS) { - GELOGE(GRAPH_PARAM_INVALID, "Check global options falied!"); + GELOGE(GRAPH_PARAM_INVALID, "[Check][Global Options] falied!"); return GRAPH_PARAM_INVALID; } @@ -186,7 +186,7 @@ graphStatus aclgrphBuildInitializeImpl(std::map &globa GELOGI("aclgrphInitialize start!"); auto ret = ge::GELib::Initialize(global_options); if (ret != ge::SUCCESS) { - GELOGE(ret, "GE initialize failed!"); + GELOGE(ret, "[Init][GELib] failed!"); return GRAPH_FAILED; } } @@ -211,7 +211,7 @@ graphStatus aclgrphBuildInitialize(std::map &global_ std::map tmp_global_options; for (auto &option : global_options) { if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { - GELOGE(GRAPH_FAILED, "AclgrphBuildInitialize option is nullptr."); + GELOGE(GRAPH_FAILED, "[Check][Options]AclgrphBuildInitialize option is nullptr."); return GRAPH_FAILED; } std::string key = option.first.GetString(); @@ -281,7 +281,7 @@ graphStatus Impl::InferShapePrepare(const ComputeGraphPtr &compute_graph) { auto ret = prepare_infershape.Run(compute_graph); if ((ret != SUCCESS) && (ret != NOT_CHANGED)) { - GELOGE(ret, "Prepair for infershape failed, ret:%d", ret); + GELOGE(ret, "[Prepair][InferShape] failed, ret:%d", ret); return ret; } GELOGD("Prepair for infershape success!"); @@ -297,12 +297,12 @@ graphStatus Impl::UpdateDataOpAttr(const Graph &graph) { vector>> user_shape_map; if (!input_shape.empty()) { GE_CHK_BOOL_EXEC(ParseInputShape(input_shape, shape_map, user_shape_map, true), - return GRAPH_PARAM_INVALID, "Parse input shape failed!"); + return GRAPH_PARAM_INVALID, "[Parse][InputShape] failed!"); } std::map>> shape_range_map; if (!input_shape_range.empty()) { GE_CHK_BOOL_EXEC(ParseInputShapeRange(input_shape_range, shape_range_map), - return GRAPH_PARAM_INVALID, "Parse input shape range failed."); + return GRAPH_PARAM_INVALID, "[Parse][InputShapeRange] failed."); } auto compute_graph = ge::GraphUtils::GetComputeGraph(graph); GE_CHECK_NOTNULL(compute_graph); @@ -312,11 +312,11 @@ graphStatus Impl::UpdateDataOpAttr(const Graph &graph) { GE_CHECK_NOTNULL(op); if (op->GetType() == DATA) { if (UpdateDataOpShape(op, shape_map) != SUCCESS) { - GELOGE(GRAPH_FAILED, "Update data op [%s] shape failed.", op->GetName().c_str()); + GELOGE(GRAPH_FAILED, "[Update][DataOpShape] op[%s] failed.", op->GetName().c_str()); return GRAPH_FAILED; } if (UpdateDataOpShapeRange(op, shape_range_map) != SUCCESS) { - GELOGE(GRAPH_FAILED, "Update data op [%s] shape range failed.", op->GetName().c_str()); + GELOGE(GRAPH_FAILED, "[Update][DataOpShapeRange] op[%s] failed.", op->GetName().c_str()); return GRAPH_FAILED; } } @@ -331,8 +331,8 @@ graphStatus Impl::CheckOptions(const std::map &options if (it == ge::ir_option::ir_builder_suppported_options.end()) { auto it_lx_fusion = ir_builder_supported_options_for_lx_fusion.find(ele.first); if (it_lx_fusion == ir_builder_supported_options_for_lx_fusion.end()) { - GELOGE(GRAPH_PARAM_INVALID, "input options include unsupported option(%s).Please check!", - ele.first.c_str()); + GELOGE(GRAPH_PARAM_INVALID, "[Check][Options] unsupported option(%s).Please check!", + ele.first.c_str()); return GRAPH_PARAM_INVALID; } } @@ -343,7 +343,7 @@ graphStatus Impl::CheckOptions(const std::map &options auto it = options_.find(BUILD_MODE); if (it != options_.end() && !(it->second.empty())) { if (build_mode_options.find(it->second) == build_mode_options.end()) { - GELOGE(GRAPH_PARAM_INVALID, "Build mode:%s is unsupported. Please check!", it->second.c_str()); + GELOGE(GRAPH_PARAM_INVALID, "[Check][Build Mode]:%s is unsupported. Please check!", it->second.c_str()); return GRAPH_PARAM_INVALID; } build_mode = it->second; @@ -351,12 +351,12 @@ graphStatus Impl::CheckOptions(const std::map &options it = options_.find(BUILD_STEP); if (it != options_.end() && !(it->second.empty())) { if (build_step_options.find(it->second) == build_step_options.end()) { - GELOGE(GRAPH_PARAM_INVALID, "Build step:%s is unsupported. Please check!", it->second.c_str()); + GELOGE(GRAPH_PARAM_INVALID, "[Check][Build Step]:%s is unsupported. Please check!", it->second.c_str()); return GRAPH_PARAM_INVALID; } } else { if (build_mode == BUILD_MODE_TUNING) { - GELOGE(GRAPH_PARAM_INVALID, "Build mode tuning must specify build step. Please check!"); + GELOGE(GRAPH_PARAM_INVALID, "[Check][Build Mode] tuning must specify build step. Please check!"); return GRAPH_PARAM_INVALID; } } @@ -376,7 +376,7 @@ graphStatus Impl::Init(const Graph &graph, const std::map(string(IR_OPTION_MODE), to_string(0))); @@ -448,7 +448,7 @@ graphStatus Impl::Init(const Graph &graph, const std::mapsecond; } else { - GELOGE(GRAPH_PARAM_INVALID, "Input format %s not support , expect ND/NCHW/NHWC/CHWN/NC1HWC0/NHWC1C0.", + GELOGE(GRAPH_PARAM_INVALID, "[Check][Param] %s not support , expect ND/NCHW/NHWC/CHWN/NC1HWC0/NHWC1C0.", input_format.c_str()); return GRAPH_PARAM_INVALID; } @@ -564,7 +564,7 @@ graphStatus Impl::InitDomiOmgContext(const string &input_shape, const string &in } if (!ParseInputShape(input_shape, omg_context_.input_dims, omg_context_.user_input_dims, is_dynamic_input)) { - GELOGE(GRAPH_PARAM_INVALID, "Failed to parse input shape: %s", input_shape.c_str()); + GELOGE(GRAPH_PARAM_INVALID, "[Parse][InputShape] Failed, shape: %s", input_shape.c_str()); return GRAPH_PARAM_INVALID; } return GRAPH_SUCCESS; @@ -585,7 +585,7 @@ graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map tmp_build_options; for (auto &option : build_options) { if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { - GELOGE(GRAPH_FAILED, "AclgrphBuildInitialize option is nullptr."); + GELOGE(GRAPH_FAILED, "[Check][Options]AclgrphBuildInitialize option is nullptr."); return GRAPH_FAILED; } std::string key = option.first.GetString(); @@ -601,7 +601,7 @@ graphStatus aclgrphSaveModel(const string &output_file, const ModelBufferData &m ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); GELOGD("Enter aclmdlSaveModel process!"); if (model.data.get() == nullptr || model.length == 0) { - GELOGE(GRAPH_PARAM_INVALID, "input model is illegal"); + GELOGE(GRAPH_PARAM_INVALID, "[Check][ModelBufferData] model is illegal"); return GRAPH_PARAM_INVALID; } return FileSaver::SaveToFile((output_file + ".om"), reinterpret_cast(model.data.get()), @@ -612,11 +612,11 @@ graphStatus aclgrphSaveModel(const char *output_file, const ModelBufferData &mod ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); GELOGD("Enter aclmdlSaveModel process!"); if (model.data.get() == nullptr || model.length == 0) { - GELOGE(GRAPH_PARAM_INVALID, "Input model is illegal"); + GELOGE(GRAPH_PARAM_INVALID, "[Check][ModelBufferData]model is illegal"); return GRAPH_PARAM_INVALID; } if (output_file == nullptr) { - GELOGE(GRAPH_PARAM_INVALID, "Output file is nullptr."); + GELOGE(GRAPH_PARAM_INVALID, "[Check][Output_File]file is nullptr."); return GRAPH_PARAM_INVALID; } std::string str_output_file = output_file; @@ -641,7 +641,7 @@ graphStatus aclgrphDumpGraph(const ge::Graph &graph, const char *file, const siz GE_CHECK_NOTNULL(file); if (len > PATH_MAX || len != strlen(file) || strlen(file) == 0) { - GELOGE(GRAPH_PARAM_INVALID, "File path invalid."); + GELOGE(GRAPH_PARAM_INVALID, "[Check][File Path]file invalid."); return GRAPH_PARAM_INVALID; } @@ -675,7 +675,7 @@ graphStatus aclgrphDumpGraph(const ge::Graph &graph, const char *file, const siz char path[PATH_MAX] = {0}; if (realpath(file_path.c_str(), path) == nullptr) { - GELOGE(GRAPH_PARAM_INVALID, "Dump file path:%s is invalid.", file); + GELOGE(GRAPH_PARAM_INVALID, "[Check][Dump File] path:%s is invalid.", file); return GRAPH_PARAM_INVALID; } @@ -710,7 +710,7 @@ graphStatus aclgrphGenerateForOp(const AscendString &op_type, const vectorAddInputDesc(tensor_desc) != ge::GRAPH_SUCCESS) { - GELOGE(ge::FAILED, "AddInputDesc fail."); + GELOGE(ge::FAILED, "[Add][InputDesc] fail."); return ge::FAILED; } input_tensors.emplace_back(tensor_desc); @@ -734,7 +734,7 @@ graphStatus aclgrphGenerateForOp(const AscendString &op_type, const vector(const_cast(content.c_str())), content.length()); if (ret == EN_ERROR) { - GELOGE(INTERNAL_ERROR, "write file fail, errno is %d", errno); + GELOGE(INTERNAL_ERROR, "[Write][File] errno is %d", errno); + REPORT_CALL_ERROR("E19999", "mmWrite failed. errno is %d", errno); ret = mmClose(fd); if (ret == EN_ERROR) { - GELOGE(INTERNAL_ERROR, "close file fail, error is %d", errno); + GELOGE(INTERNAL_ERROR, "[Close][File] error is %d", errno); + REPORT_CALL_ERROR("E19999", "mmClose failed. error is %d", errno); } return INTERNAL_ERROR; } ret = mmClose(fd); if (ret == EN_ERROR) { - GELOGE(INTERNAL_ERROR, "close file fail, error is %d", errno); + GELOGE(INTERNAL_ERROR, "[Close][File] error is %d", errno); + REPORT_CALL_ERROR("E19999", "mmClose failed. error is %d", errno); return INTERNAL_ERROR; } @@ -242,7 +252,8 @@ Status CsaInteract::MakePath(const std::string &file_name) { std::string pre_path = file_path.substr(0, found + 1); if (mmAccess(pre_path.c_str()) != EN_OK) { if (mmMkdir(pre_path.c_str(), M_IRWXU) != EN_OK) { - GELOGE(INTERNAL_ERROR, "csainteract mkdir fail, errno is %d", errno); + GELOGE(INTERNAL_ERROR, "[Create][File Dir] fail, errno is %d, pre_path:%s", errno, pre_path.c_str()); + REPORT_CALL_ERROR("E19999", "mmMkdir failed. errno is %d pre_path:%s", errno, pre_path.c_str()); return INTERNAL_ERROR; } } diff --git a/ge/opskernel_manager/ops_kernel_builder_manager.cc b/ge/opskernel_manager/ops_kernel_builder_manager.cc index 37bdcf7a..a556f740 100644 --- a/ge/opskernel_manager/ops_kernel_builder_manager.cc +++ b/ge/opskernel_manager/ops_kernel_builder_manager.cc @@ -50,7 +50,8 @@ Status OpsKernelBuilderManager::Initialize(const map & GE_CHK_STATUS_RET_NOLOG(GetLibPaths(options, lib_paths)); plugin_manager_.reset(new (std::nothrow)PluginManager()); GE_CHECK_NOTNULL(plugin_manager_); - GE_CHK_STATUS_RET(plugin_manager_->LoadSo(lib_paths), "Failed to load libs"); + GE_CHK_STATUS_RET(plugin_manager_->LoadSo(lib_paths), + "[Load][Libs]Failed, lib_paths=%s.", lib_paths.c_str()); } auto &kernel_builders = OpsKernelBuilderRegistry::GetInstance().GetAll(); @@ -61,8 +62,7 @@ Status OpsKernelBuilderManager::Initialize(const map & GELOGI("Initialize ops kernel util for %s", kernel_lib_name.c_str()); GE_CHECK_NOTNULL(it.second); GE_CHK_STATUS_RET(it.second->Initialize(options), - "Failed to invoke Initialize, kernel lib name = %s", - kernel_lib_name.c_str()); + "[Invoke][Initialize]failed, kernel lib name = %s", kernel_lib_name.c_str()); ops_kernel_builders_.emplace(kernel_lib_name, it.second); } @@ -100,7 +100,8 @@ OpsKernelBuilderPtr OpsKernelBuilderManager::GetOpsKernelBuilder(const string &n return nullptr; } -Status OpsKernelBuilderManager::GetLibPaths(const std::map &options, std::string &lib_paths) { +Status OpsKernelBuilderManager::GetLibPaths(const std::map &options, std::string &lib_paths) { GELOGD("Start to execute GetLibPaths"); std::string path_base = PluginManager::GetPath(); std::string so_path = "plugin/opskernel/"; @@ -128,18 +129,16 @@ Status OpsKernelBuilderManager::CalcOpRunningParam(Node &node) const { const std::string &lib_name = op_desc->GetOpKernelLibName(); auto it = ops_kernel_builders_.find(lib_name); if (it == ops_kernel_builders_.end()) { - GELOGE(INTERNAL_ERROR, - "Failed to get OpKernelStore. libName = %s, node = %s", - lib_name.c_str(), - op_desc->GetName().c_str()); + GELOGE(INTERNAL_ERROR,"[Check][Lib_Name] libName = %s, node = %s not exist.", + lib_name.c_str(), op_desc->GetName().c_str()); + REPORT_INNER_ERROR("E19999", "CalcOpRunningParam failed, libName = %s, node = %s not exist.", + lib_name.c_str(), op_desc->GetName().c_str()); return INTERNAL_ERROR; } GELOGD("To invoke CalcOpRunningParam, node = %s, lib name = %s", op_desc->GetName().c_str(), lib_name.c_str()); GE_CHK_STATUS_RET(it->second->CalcOpRunningParam(node), - "Failed to invoke CalcOpRunningParam, libName = %s, node = %s", - lib_name.c_str(), - op_desc->GetName().c_str()); + "[Invoke][CalcOpRunningParam]failed, libName = %s, node = %s", lib_name.c_str(), op_desc->GetName().c_str()); GELOGD("Done invoking CalcOpRunningParam successfully"); return SUCCESS; } @@ -152,18 +151,16 @@ Status OpsKernelBuilderManager::GenerateTask(const Node &node, const std::string &lib_name = op_desc->GetOpKernelLibName(); auto it = ops_kernel_builders_.find(lib_name); if (it == ops_kernel_builders_.end()) { - GELOGE(INTERNAL_ERROR, - "Failed to get OpKernelStore. libName = %s, node = %s", - lib_name.c_str(), - op_desc->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[Check][Lib_Name] libName = %s, node = %s not exist.", + lib_name.c_str(), op_desc->GetName().c_str()); + REPORT_INNER_ERROR("E19999", "GenerateTask failed, libName = %s, node = %s not exist.", + lib_name.c_str(), op_desc->GetName().c_str()); return INTERNAL_ERROR; } GELOGD("To invoke GenerateTask, node = %s, lib name = %s", op_desc->GetName().c_str(), lib_name.c_str()); GE_CHK_STATUS_RET(it->second->GenerateTask(node, context, tasks), - "Failed to invoke GenerateTask, libName = %s, node = %s", - lib_name.c_str(), - op_desc->GetName().c_str()); + "[Invoke][GenerateTask]failed, libName = %s, node = %s", lib_name.c_str(), op_desc->GetName().c_str()); GELOGD("Done invoking GenerateTask successfully"); return SUCCESS; } diff --git a/ge/opskernel_manager/ops_kernel_manager.cc b/ge/opskernel_manager/ops_kernel_manager.cc index 30f39c0d..d8a3e3a8 100644 --- a/ge/opskernel_manager/ops_kernel_manager.cc +++ b/ge/opskernel_manager/ops_kernel_manager.cc @@ -56,7 +56,7 @@ Status OpsKernelManager::Initialize(const map &options_const) { std::map options(options_const); Status ret = InitPluginOptions(options); if (ret != SUCCESS) { - GELOGE(ret, "[OpsKernelManager] [Initialize] parse pluginFlag from ge options failed."); + GELOGE(ret, "[Init][PluginOptions] parse pluginFlag from ge options failed."); return ret; } @@ -85,7 +85,8 @@ Status OpsKernelManager::Initialize(const map &options_const) { initialize_ = options; Status rst0 = plugin_manager_.InvokeAll &, Status>(kInitialize, initialize_); if (rst0 == FAILED) { - GELOGE(GE_OPS_GET_NO_VALID_SO, "There is invalid so about OpsKernelInfoStore."); + GELOGE(GE_OPS_GET_NO_VALID_SO, "[Invoke][OpsKernelInfo]PluginManager InvokeAll failed."); + REPORT_INNER_ERROR("E19999", "PluginManager InvokeAll failed.") return GE_OPS_GET_NO_VALID_SO; } Status rst1 = @@ -114,18 +115,20 @@ Status OpsKernelManager::Initialize(const map &options_const) { } ret = InitGraphOptimizerPriority(); if ((ret != SUCCESS)) { - GELOGE(ret, "Init graph optimizer priority failed."); + GELOGE(ret, "[Init][GraphOptimizerPriority] failed."); return ret; } init_flag_ = true; return SUCCESS; } else { - GELOGE(ret, "Failed to find any valid so file."); + GELOGE(ret, "[Check][So File] not find any valid so file."); + REPORT_INNER_ERROR("E19999", "OpsKernelManager::Initialize failed for not find any valid so file."); return ret; } } -void OpsKernelManager::GetExternalEnginePath(std::string &extern_engine_path, const std::map& options) { +void OpsKernelManager::GetExternalEnginePath(std::string &extern_engine_path, + const std::map& options) { GELOGI("Enter get external engine so path schedule"); const char *path_env = std::getenv("ASCEND_ENGINE_PATH"); if (path_env != nullptr) { @@ -175,21 +178,33 @@ Status OpsKernelManager::ParsePluginOptions(const map &options, } else if (flag == 1) { enable_flag = true; } else { - GELOGE(GE_GRAPH_OPTIONS_INVALID, "option_key:%s, its value %s is invalid, it must be 0 or 1.", - plugin_name.c_str(), iter->second.c_str()); + GELOGE(GE_GRAPH_OPTIONS_INVALID, "[Check][Data]option_key:%s, its value %s is invalid, it must be 0 or 1.", + plugin_name.c_str(), iter->second.c_str()); + REPORT_INNER_ERROR("E19999", "ParsePluginOptions failed, option_key:%s, " + "its value %s is invalid, it must be 0 or 1.", plugin_name.c_str(), iter->second.c_str()); return GE_GRAPH_OPTIONS_INVALID; } } catch (std::invalid_argument &) { - GELOGE(GE_GRAPH_OPTIONS_INVALID, "option_key:ge.feFlag, its value %s is invalid_argument, it must be 0 or 1.", - iter->second.c_str()); + GELOGE(GE_GRAPH_OPTIONS_INVALID, + "[Check][Data] failed, option_key:ge.feFlag, its value %s is invalid_argument, it must be 0 or 1.", + iter->second.c_str()); + REPORT_INNER_ERROR("E19999", + "ParsePluginOptions failed, option_key:ge.feFlag, its value %s is invalid_argument, it must be 0 or 1.", + iter->second.c_str()); return GE_GRAPH_OPTIONS_INVALID; } catch (std::out_of_range &) { - GELOGE(GE_GRAPH_OPTIONS_INVALID, "option_key:ge.feFlag, its value %s is out of range, it must be 0 or 1.", - iter->second.c_str()); + GELOGE(GE_GRAPH_OPTIONS_INVALID, + "[Check][Data]failed, option_key:ge.feFlag, its value %s is out of range, it must be 0 or 1.", + iter->second.c_str()); + REPORT_INNER_ERROR("E19999", + "ParsePluginOptions failed, option_key:ge.feFlag, its value %s is out of range, it must be 0 or 1.", + iter->second.c_str());option_key:ge.feFlag, return GE_GRAPH_OPTIONS_INVALID; } catch (...) { - GELOGE(GE_GRAPH_OPTIONS_INVALID, "option_key:%s, its value %s is invalid, it must be 0 or 1.", - plugin_name.c_str(), iter->second.c_str()); + GELOGE(GE_GRAPH_OPTIONS_INVALID, "[Check][Data]option_key:%s, its value %s is invalid, it must be 0 or 1.", + plugin_name.c_str(), iter->second.c_str()); + REPORT_INNER_ERROR("E19999", "ParsePluginOptions failed, option_key:%s, " + "its value %s is invalid, it must be 0 or 1.", plugin_name.c_str(), iter->second.c_str()); return GE_GRAPH_OPTIONS_INVALID; } } else { @@ -203,13 +218,15 @@ Status OpsKernelManager::ParsePluginOptions(const map &options, Status OpsKernelManager::CheckPluginPtr() const { for (auto iter = ops_kernel_store_.begin(); iter != ops_kernel_store_.end(); ++iter) { if (iter->second == nullptr) { - GELOGE(INTERNAL_ERROR, "CheckPluginPtr OpsKernelInfoStorePtr is null"); + GELOGE(INTERNAL_ERROR, "[Check][PluginPtr] OpsKernelInfoStorePtr key=%s is null", iter->first.c_str()); + REPORT_INNER_ERROR("E19999", "CheckPluginPtr OpsKernelInfoStorePtr key=%s is null", iter->first.c_str()); return FAILED; } } for (auto iter1 = graph_optimizers_.begin(); iter1 != graph_optimizers_.end(); ++iter1) { if (iter1->second == nullptr) { - GELOGE(INTERNAL_ERROR, "CheckPluginPtr GraphOptimizerPtr is null"); + GELOGE(INTERNAL_ERROR, "[Check][PluginPtr] GraphOptimizerPtr key=%s is null", iter1->first.c_str()); + REPORT_INNER_ERROR("E19999", "GraphOptimizerPtr key=%s is null", iter1->first.c_str()); return FAILED; } } @@ -222,7 +239,9 @@ Status OpsKernelManager::InitOpKernelInfoStores(const map &optio GELOGI("OpKernelInfoStore name: %s.", (it.first).c_str()); Status ret = it.second->Initialize(options); if (ret != SUCCESS) { - GELOGE(GE_OPS_KERNEL_STORE_INIT_FAILED, "OpKernelInfoStore: %s initialize failed.", (it.first).c_str()); + GELOGE(GE_OPS_KERNEL_STORE_INIT_FAILED, + "[Init][OpKernelLib]OpKernelInfoStore: %s initialize failed.", (it.first).c_str()); + REPORT_CALL_ERROR("E19999", "OpKernelInfoStore: %s initialize failed.", (it.first).c_str()); return GE_OPS_KERNEL_STORE_INIT_FAILED; } } @@ -247,7 +266,8 @@ void OpsKernelManager::InitOpsKernelInfo() { } std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "InitOpsKernelInfo failed."); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[Get][GELib]malloc instance_ptr failed."); + REPORT_INNER_ERROR("E19999", "InitOpsKernelInfo failed for new GELib failed."); return; } // sort opinfo of ops_kernel_info_ @@ -291,7 +311,8 @@ Status OpsKernelManager::InitGraphOptimzers(const map &options) GE_CHK_STATUS_RET(it.second->GetAttributes(attrs)) std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "InitGraphOptimzers failed."); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[Get][GELib]malloc instance_ptr failed."); + REPORT_INNER_ERROR("E19999", "InitGraphOptimzers failed for new GELib failed."); return GE_CLI_GE_NOT_INITIALIZED; } if (!instance_ptr->DNNEngineManagerObj().IsEngineRegistered(attrs.engineName)) { @@ -300,7 +321,9 @@ Status OpsKernelManager::InitGraphOptimzers(const map &options) } Status ret = it.second->Initialize(options); if (ret != SUCCESS) { - GELOGE(GE_OPS_GRAPH_OPTIMIZER_INIT_FAILED, "GraphOptimzer: %s initialize failed.", (it.first).c_str()); + GELOGE(GE_OPS_GRAPH_OPTIMIZER_INIT_FAILED, + "[Init][GraphOptimzer]GraphOptimzer: %s initialize failed.", (it.first).c_str()); + REPORT_CALL_ERROR("E19999", "InitGraphOptimzers failed. %s initialize failed.", (it.first).c_str()); return GE_OPS_GRAPH_OPTIMIZER_INIT_FAILED; } } @@ -317,7 +340,8 @@ Status OpsKernelManager::Finalize() { GELOGI("OpsKernelStore finalize, name: %s.", (iter->first).c_str()); Status status = iter->second->Finalize(); if (SUCCESS != status) { - GELOGE(status, "OpsKernelStore finalize failed, name: %s.", (iter->first).c_str()); + GELOGE(status, "[Check][Status]OpsKernelStore finalize failed, name: %s.", (iter->first).c_str()); + REPORT_CALL_ERROR("E19999", "OpsKernelStore finalize failed, name: %s.", (iter->first).c_str()); return status; } } @@ -325,14 +349,16 @@ Status OpsKernelManager::Finalize() { GELOGI("GraphOptimzers finalize, name: %s.", (iter->first).c_str()); Status status = iter->second->Finalize(); if (status != SUCCESS) { - GELOGE(status, "GraphOptimzers finalize failed, name: %s.", (iter->first).c_str()); + GELOGE(status, "[Check][Status]GraphOptimzers finalize failed, name: %s.", (iter->first).c_str()); + REPORT_CALL_ERROR("E19999", "GraphOptimzers finalize failed, name: %s.", (iter->first).c_str()); return status; } } Status ret = FinalizeOpsKernel(); if (ret != SUCCESS) { - GELOGE(ret, "free ops kernel resource failed."); + GELOGE(ret, "[Free][Ops kernel resource] failed."); + REPORT_CALL_ERROR("E19999", "FinalizeOpsKernel failed, Free Ops kernel resource failed."); return ret; } @@ -443,7 +469,8 @@ Status OpsKernelManager::FinalizeOpsKernel() { GELOGI("ge invoke ops kernal finalize."); Status ret = plugin_manager_.InvokeAll(kFinalize); if (ret != SUCCESS) { - GELOGE(ret, "[Finalize] invoke Fe finalize failed."); + GELOGE(ret, "[Finalize][Check][Status] invoke Fe finalize failed."); + REPORT_INNER_ERROR("E19999", "PluginManager InvokeAll failed."); return ret; } diff --git a/ge/plugin/engine/engine_manage.cc b/ge/plugin/engine/engine_manage.cc index a14c92ea..46288bce 100644 --- a/ge/plugin/engine/engine_manage.cc +++ b/ge/plugin/engine/engine_manage.cc @@ -29,7 +29,7 @@ std::unique_ptr> EngineManager::engine_map_; Status EngineManager::RegisterEngine(const std::string &engine_name, DNNEnginePtr engine_ptr) { if (engine_ptr == nullptr) { - GELOGE(FAILED, "enginePtr is nullptr"); + GELOGE(FAILED, "[Register][Engine] failed, as input engine_ptr is nullptr"); return FAILED; } @@ -64,7 +64,8 @@ void RegisterAiCoreEngine() { DNNEngineAttribute attr_aicore = {ai_core, mem_type_aicore, COST_0, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr aicore_engine_ptr = MakeShared(attr_aicore); if (aicore_engine_ptr == nullptr) { - GELOGE(ge::FAILED, "make aiCoreEnginePtr failed"); + GELOGE(ge::FAILED, "[Register][AiCoreEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterAiCoreEngine failed for new DNNEnginePtr failed."); return; } if (EngineManager::RegisterEngine(ai_core, aicore_engine_ptr) != SUCCESS) { @@ -80,7 +81,8 @@ void RegisterVectorEngine() { DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr vectorcore_engine_ptr = MakeShared(attr_vector_core); if (vectorcore_engine_ptr == nullptr) { - GELOGE(ge::FAILED, "make vectorCoreEnginePtr failed"); + GELOGE(ge::FAILED, "[Register][VectorEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterVectorEngine failed for new DNNEnginePtr failed."); return; } if (EngineManager::RegisterEngine(vector_core, vectorcore_engine_ptr) != SUCCESS) { @@ -95,7 +97,8 @@ void RegisterAiCpuEngine() { DNNEngineAttribute attr_aicpu = {vm_aicpu, mem_type_aicpu, COST_3, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr vm_engine_ptr = MakeShared(attr_aicpu); if (vm_engine_ptr == nullptr) { - GELOGE(ge::FAILED, "make vm_engine_ptr failed"); + GELOGE(ge::FAILED, "[Register][AiCpuEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterAiCpuEngine failed for new DNNEnginePtr failed."); return; } if (EngineManager::RegisterEngine(vm_aicpu, vm_engine_ptr) != SUCCESS) { @@ -107,10 +110,12 @@ void RegisterAiCpuTFEngine() { const std::string vm_aicpu_tf = "DNN_VM_AICPU"; std::vector mem_type_aicpu_tf; mem_type_aicpu_tf.emplace_back(GE_ENGINE_ATTR_MEM_TYPE_HBM); - DNNEngineAttribute attr_aicpu_tf = {vm_aicpu_tf, mem_type_aicpu_tf, COST_2, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; + DNNEngineAttribute attr_aicpu_tf = {vm_aicpu_tf, mem_type_aicpu_tf, COST_2, DEVICE, + FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr vm_engine_ptr = MakeShared(attr_aicpu_tf); if (vm_engine_ptr == nullptr) { - GELOGE(ge::FAILED, "make vm_engine_ptr failed"); + GELOGE(ge::FAILED, "[Register][AiCpuTFEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterAiCpuTFEngine failed for new DNNEnginePtr failed."); return; } if (EngineManager::RegisterEngine(vm_aicpu_tf, vm_engine_ptr) != SUCCESS) { @@ -126,7 +131,8 @@ void RegisterGeLocalEngine() { DNNEngineAttribute attr_ge_local = {vm_ge_local, mem_type_ge_local, COST_9, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr ge_local_engine = MakeShared(attr_ge_local); if (ge_local_engine == nullptr) { - GELOGE(ge::FAILED, "make ge_local_engine failed"); + GELOGE(ge::FAILED, "[Register][GeLocalEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterGeLocalEngine failed for new DNNEnginePtr failed."); return; } if (EngineManager::RegisterEngine(vm_ge_local, ge_local_engine) != SUCCESS) { @@ -139,10 +145,12 @@ void RegisterHostCpuEngine() { std::vector mem_type_host_cpu; mem_type_host_cpu.emplace_back(GE_ENGINE_ATTR_MEM_TYPE_HBM); // HostCpu use minimum priority, set it as 10 - DNNEngineAttribute attr_host_cpu = {vm_host_cpu, mem_type_host_cpu, COST_10, HOST, FORMAT_RESERVED, FORMAT_RESERVED}; + DNNEngineAttribute attr_host_cpu = {vm_host_cpu, mem_type_host_cpu, COST_10, + HOST, FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr host_cpu_engine = MakeShared(attr_host_cpu); if (host_cpu_engine == nullptr) { - GELOGE(ge::FAILED, "make host_cpu_engine failed"); + GELOGE(ge::FAILED, "[Register][HostCpuEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterHostCpuEngine failed for new DNNEnginePtr failed."); return; } if (EngineManager::RegisterEngine(vm_host_cpu, host_cpu_engine) != SUCCESS) { @@ -157,7 +165,8 @@ void RegisterRtsEngine() { DNNEngineAttribute attr_rts = {vm_rts, mem_type_rts, COST_1, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr rts_engine = MakeShared(attr_rts); if (rts_engine == nullptr) { - GELOGE(ge::FAILED, "make rts_engine failed"); + GELOGE(ge::FAILED, "[Register][RtsEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterRtsEngine failed for new DNNEnginePtr failed."); return; } if (EngineManager::RegisterEngine(vm_rts, rts_engine) != SUCCESS) { @@ -172,7 +181,8 @@ void RegisterHcclEngine() { DNNEngineAttribute attr_hccl = {dnn_hccl, mem_type_hccl, COST_1, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr hccl_engine = MakeShared(attr_hccl); if (hccl_engine == nullptr) { - GELOGE(ge::FAILED, "make hccl_engine failed"); + GELOGE(ge::FAILED, "[Register][HcclEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterHcclEngine failed for new DNNEnginePtr failed."); return; } if (EngineManager::RegisterEngine(dnn_hccl, hccl_engine) != SUCCESS) {