diff --git a/ge/client/ge_api.cc b/ge/client/ge_api.cc index 5d149920..f1760062 100644 --- a/ge/client/ge_api.cc +++ b/ge/client/ge_api.cc @@ -80,6 +80,12 @@ Status CheckOptionsValid(const std::map &options) { // Initialize GE, prepare for execution, call GELib::Initialize Status GEInitializeImpl(const std::map &options) { GELOGT(TRACE_INIT, "GEInitialize start"); + std::string path_base = ge::GELib::GetPath(); + auto ret = ErrorManager::GetInstance().Init(path_base); + if (ret != SUCCESS) { + GELOGE(GE_CLI_INIT_FAILED, "ErrorManager init fail"); + return ret; + } ErrorManager::GetInstance().GenWorkStreamIdDefault(); // 0.check init status @@ -114,7 +120,7 @@ Status GEInitializeImpl(const std::map &options) { // call Initialize GELOGT(TRACE_RUNNING, "Initializing environment"); GE_TIMESTAMP_START(GELibInitialize); - Status ret = ge::GELib::Initialize(options); + ret = ge::GELib::Initialize(options); GE_TIMESTAMP_END(GELibInitialize, "GEInitialize::GELibInitialize"); if (ret != SUCCESS) { GELOGE(GE_CLI_INIT_FAILED, "geInitialize failed, error code = %u", ret); diff --git a/ge/graph/load/model_manager/davinci_model.cc b/ge/graph/load/model_manager/davinci_model.cc index 180efac5..9ce4f595 100755 --- a/ge/graph/load/model_manager/davinci_model.cc +++ b/ge/graph/load/model_manager/davinci_model.cc @@ -2590,7 +2590,7 @@ void *DavinciModel::Run(DavinciModel *model) { bool seq_end_flag = false; uint32_t model_id = model->Id(); uint32_t device_id = model->GetDeviceId(); - GetContext().SetWorkStreamId(model->GetWorkStreamId()); + ErrorManager::GetInstance().SetErrorContext(model->GetErrorContext()); GELOGI("Model Run thread start, model_id:%u.", model_id); rtError_t rt_ret = rtSetDevice(static_cast(device_id)); @@ -2753,7 +2753,7 @@ Status DavinciModel::ModelRunStart() { int64_t maxDumpOpNum = std::strtol(opt.c_str(), nullptr, kDecimal); maxDumpOpNum_ = maxDumpOpNum; - work_stream_id_ = GetContext().WorkStreamId(); + error_context_ = ErrorManager::GetInstance().GetErrorContext(); CREATE_STD_THREAD(thread_id_, DavinciModel::Run, this); GELOGI("model tread create success, model id:%u.", model_id_); return SUCCESS; @@ -3988,7 +3988,7 @@ Status DavinciModel::InitOrigInputInfo(uint32_t index, const OpDescPtr &op_desc) vector inputs; if (AttrUtils::GetListStr(op_desc, ATTR_NAME_AIPP_INPUTS, inputs) && !inputs.empty()) { std::string input = inputs[kAippOriginInputIndex]; - GELOGI("origin input str: %s", input.c_str()); + GELOGI("origin input str: %s.", input.c_str()); std::vector infos = ge::StringUtils::Split(input, ':'); if (infos.size() != kAippInfoNum) { GELOGE(ACL_ERROR_GE_AIPP_MODE_INVALID, "origin input str is invalid[%zu, %u].", infos.size(), kAippInfoNum); @@ -4062,7 +4062,7 @@ Status DavinciModel::InitAippInputOutputDims(uint32_t index, const OpDescPtr &op ConstGeTensorDescPtr data_input_desc = op_desc->GetInputDescPtr(kDataIndex); int64_t data_input_size; (void)TensorUtils::GetSize(*(op_desc->GetInputDescPtr(kDataIndex)), data_input_size); - GELOGD("related Data[%d]: tensor_name: %s, dim_num: %zu, tensor_size: %zu, format: %s, data_type: %s, shape: %s", + GELOGD("related Data[%d]: tensor_name: %s, dim_num: %zu, tensor_size: %zu, format: %s, data_type: %s, shape: %s.", index, op_desc->GetName().c_str(), data_input_desc->GetShape().GetDimNum(), data_input_size, TypeUtils::FormatToSerialString(data_input_desc->GetFormat()).c_str(), TypeUtils::DataTypeToSerialString(data_input_desc->GetDataType()).c_str(), diff --git a/ge/graph/load/model_manager/davinci_model.h b/ge/graph/load/model_manager/davinci_model.h index 93f460b6..4e29a4f4 100755 --- a/ge/graph/load/model_manager/davinci_model.h +++ b/ge/graph/load/model_manager/davinci_model.h @@ -412,7 +412,7 @@ class DavinciModel { /// uint64_t GetSessionId() const { return session_id_; } - uint64_t GetWorkStreamId() const { return work_stream_id_; } + const struct ErrorMessage::Context &GetErrorContext() const { return error_context_; } /// /// @ingroup ge @@ -958,7 +958,7 @@ class DavinciModel { vector output_mbuf_list_; // output mbuf created by dequeue task. uint64_t session_id_; - uint64_t work_stream_id_; + struct ErrorMessage::Context error_context_; uint32_t device_id_; diff --git a/ge/graph/manager/graph_manager.cc b/ge/graph/manager/graph_manager.cc index b4b47f50..170460b9 100755 --- a/ge/graph/manager/graph_manager.cc +++ b/ge/graph/manager/graph_manager.cc @@ -353,10 +353,10 @@ Status GraphManager::AddGraph(const GraphId &graph_id, const Graph &graph, } GraphNodePtr graph_node = MakeShared(graph_id); - GE_IF_BOOL_EXEC(graph_node == nullptr, GELOGE(FAILED, "GraphNode make shared failed"); + GE_IF_BOOL_EXEC(graph_node == nullptr, GELOGE(FAILED, "GraphNode make shared failed."); return FAILED); std::shared_ptr graph_ptr = MakeShared(graph); - GE_IF_BOOL_EXEC(graph_ptr == nullptr, GELOGE(FAILED, "GraphPtr make shared failed"); + GE_IF_BOOL_EXEC(graph_ptr == nullptr, GELOGE(FAILED, "GraphPtr make shared failed."); return FAILED); graph_node->SetGraph(graph_ptr); @@ -542,7 +542,8 @@ Status GraphManager::OptimizeSubGraphWithMultiThreads(ComputeGraphPtr compute_gr } std::future f = executor.commit(GraphManager::ProcessSubGraphWithMultiThreads, this, compute_graph->GetGraphID(), subgraph, - compute_graph->GetName(), session_id, GetContext().WorkStreamId(), + compute_graph->GetName(), session_id, + ErrorManager::GetInstance().GetErrorContext(), GetThreadLocalContext()); if (!f.valid()) { GELOGE(FAILED, "Future is invalid"); @@ -558,7 +559,8 @@ Status GraphManager::OptimizeSubGraphWithMultiThreads(ComputeGraphPtr compute_gr } std::future f = executor.commit(GraphManager::ProcessSubGraphWithMultiThreads, this, compute_graph->GetGraphID(), subgraph, - compute_graph->GetName(), session_id, GetContext().WorkStreamId(), + compute_graph->GetName(), session_id, + ErrorManager::GetInstance().GetErrorContext(), GetThreadLocalContext()); if (!f.valid()) { GELOGE(FAILED, "Future is invalid"); @@ -735,7 +737,7 @@ Status GraphManager::PreRunAfterOptimizeSubGraph(const GraphNodePtr &graph_node, } Status GraphManager::SetRtContext(rtContext_t rt_context, rtCtxMode_t mode, uint64_t session_id, uint32_t graph_id) { - GELOGD("set rt_context, session id: %lu, graph id: %u, mode %d, device id:%u.", + GELOGD("set rt_context: session id: %lu, graph id: %u, mode %d, device id:%u.", session_id, graph_id, static_cast(mode), ge::GetContext().DeviceId()); rtError_t rt_ret = rtCtxCreate(&rt_context, mode, ge::GetContext().DeviceId()); @@ -777,7 +779,7 @@ Status GraphManager::PreRun(const GraphNodePtr &graph_node, const std::vectorBuildJsonObject(session_id, compute_graph->GetGraphID()), "BuildJsonObject Failed") - GEEVENT("PreRun start, graph node size %zu, session id %lu, graph id %u, graph name %s.", + GEEVENT("PreRun start: graph node size %zu, session id %lu, graph id %u, graph name %s.", compute_graph->GetDirectNodesSize(), session_id, compute_graph->GetGraphID(), compute_graph->GetName().c_str()); GE_DUMP(compute_graph, "PreRunBegin"); @@ -798,7 +800,7 @@ Status GraphManager::PreRun(const GraphNodePtr &graph_node, const std::vectorGetName().c_str()); + GELOGE(ret, "Run PreRunOptimizeOriginalGraph failed for graph:%s.", compute_graph->GetName().c_str()); return ret; } } @@ -870,7 +872,7 @@ Status GraphManager::StartForRunGraph(const GraphNodePtr &graph_node, const std: // release rts generate context RtContextUtil::GetInstance().DestroyRtContexts(session_id, graph_node->GetGraphId()); if (ret != SUCCESS) { - GELOGE(ret, "PreRun Failed. graph_id:%u", graph_node->GetGraphId()); + GELOGE(ret, "PreRun Failed. graph_id:%u.", graph_node->GetGraphId()); return ret; } } @@ -1210,7 +1212,7 @@ Status GraphManager::BuildGraphForUnregisteredOp(const GraphId &graph_id, const Status GraphManager::BuildGraph(const GraphId &graph_id, const std::vector &inputs, GeRootModelPtr &ge_root_model, uint64_t session_id, bool async) { - GELOGD("[BuildGraph] start to build graph, graph_id:%u.", graph_id); + GELOGD("[BuildGraph] start to build graph, graph_id:%u", graph_id); if (inputs.empty()) { GELOGW("[BuildGraph] BuildGraph warning: empty GeTensor inputs"); } @@ -1242,7 +1244,7 @@ Status GraphManager::BuildGraph(const GraphId &graph_id, const std::vectorSetRunFlag(false); if (ret != SUCCESS) { - GELOGE(GE_GRAPH_PRERUN_FAILED, "[BuildGraph] StartForRunGraph failed! graph_id:%u", graph_id); + GELOGE(GE_GRAPH_PRERUN_FAILED, "[BuildGraph] StartForRunGraph failed! graph_id:%u.", graph_id); return GE_GRAPH_PRERUN_FAILED; } @@ -1496,7 +1498,7 @@ Status GraphManager::ParseOptions(const std::map &opti ParseOption(options, INPUT_SHAPE, options_.input_shape); ParseOption(options, kDynamicDims, options_.dynamic_dims); ParseOption(options, DYNAMIC_NODE_TYPE, options_.dynamic_node_type); - GELOGD("Dynamic dims params: input shape is %s, dynamic dims is %s, dynamic node type is %d.", + GELOGD("Dynamic dims params: input shape is %s, dynamic dims is %s, dynamic node type is %d", options_.input_shape.c_str(), options_.dynamic_dims.c_str(), options_.dynamic_node_type); // Set Build model and step @@ -1509,7 +1511,7 @@ Status GraphManager::ParseOptions(const std::map &opti Status GraphManager::ParseTrainGraphFlag(bool &options, bool &option) { std::shared_ptr ge_instance_ptr = ge::GELib::GetInstance(); if (ge_instance_ptr == nullptr) { - GELOGW("[Initialize] set train_graph_flag_ to 0 when GE is not initialized or finalized."); + GELOGW("[Initialize] set train_graph_flag to 0 when GE is not initialized or finalized."); option = false; } else if (!ge_instance_ptr->isTrainMode()) { option = false; @@ -1526,7 +1528,8 @@ Status GraphManager::ParseTrainGraphFlag(bool &options, bool &option) { bool GraphManager::IsPerfLevelInvalid(int32_t perf_level) { return ((perf_level != static_cast(GEN_TASK_WITHOUT_L2FUSION)) && - (perf_level != static_cast(GEN_TASK_WITHOUT_FUSION)) && (perf_level != -1)); + (perf_level != static_cast(GEN_TASK_WITHOUT_FUSION)) && + (perf_level != -1)); } void GraphManager::ParseOption(const std::map &options, const std::string &key, @@ -2509,10 +2512,10 @@ Status GraphManager::ProcessSubGraphWithMultiThreads(GraphManager *graph_manager const SubGraphInfoPtr &sub_graph_info_ptr, const std::string &root_graph_name, uint64_t session_id, - uint64_t work_stream_id, + const struct ErrorMessage::Context &error_context, const GEThreadLocalContext &ge_context) { if (sub_graph_info_ptr != nullptr && graph_manager != nullptr) { - GetContext().SetWorkStreamId(work_stream_id); + ErrorManager::GetInstance().SetErrorContext(error_context); GetContext().SetSessionId(session_id); GetThreadLocalContext() = ge_context; graph_manager->UpdateLocalOmgContext(root_graph_id); @@ -2560,7 +2563,8 @@ Status GraphManager::RunGraphAsync(const GraphId &graph_id, const std::vectorUpdateLocalOmgContext(args.graph_id); @@ -2729,7 +2733,7 @@ void GraphManager::PreRunThread(GraphManager *graph_manager) { ge_root_model = graph_node->GetGeRootModel(); } - graph_manager->run_args_q_.Push(RunArgs( { graph_node, args.graph_id, args.session_id, args.work_stream_id, + graph_manager->run_args_q_.Push(RunArgs( { graph_node, args.graph_id, args.session_id, args.error_context, args.input_tensor, ge_root_model, GetThreadLocalContext(), args.callback })); GELOGI("Loop end."); } @@ -2829,7 +2833,7 @@ void GraphManager::RunThread(GraphManager *graph_manager) { GELOGI("A new loop start."); - GetContext().SetWorkStreamId(args.work_stream_id); + ErrorManager::GetInstance().SetErrorContext(args.error_context); GetContext().SetSessionId(args.session_id); GetThreadLocalContext() = args.context; graph_manager->UpdateLocalOmgContext(args.graph_id); diff --git a/ge/graph/manager/graph_manager.h b/ge/graph/manager/graph_manager.h index 90384b3c..661cf9d8 100644 --- a/ge/graph/manager/graph_manager.h +++ b/ge/graph/manager/graph_manager.h @@ -196,7 +196,7 @@ class GraphManager { GraphId graph_id; std::vector input_tensor; uint64_t session_id; - uint64_t work_stream_id; + struct ErrorMessage::Context error_context; GEThreadLocalContext context; RunAsyncCallback callback; }; @@ -205,7 +205,7 @@ class GraphManager { GraphNodePtr graph_node; GraphId graph_id; uint64_t session_id; - uint64_t work_stream_id; + struct ErrorMessage::Context error_context; std::vector input_tensor; GeRootModelPtr ge_root_model; GEThreadLocalContext context; @@ -223,7 +223,7 @@ class GraphManager { const SubGraphInfoPtr &sub_graph_info_ptr, const std::string &root_graph_name, uint64_t session_id, - uint64_t work_stream_id, + const struct ErrorMessage::Context &error_context, const GEThreadLocalContext &ge_context); Status ParseInputsDims(const std::vector &input_tensor); void ParseInputsDimsForData(const std::vector &input_tensor); diff --git a/metadef b/metadef index 29a779d0..711f8dae 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit 29a779d0b1e0482092e387ccce2886b36dc5e395 +Subproject commit 711f8dae37dfcc2db259c94edf2803986f12e2e3 diff --git a/tests/depends/error_manager/src/error_manager_stub.cc b/tests/depends/error_manager/src/error_manager_stub.cc index a57b2457..eadc8687 100644 --- a/tests/depends/error_manager/src/error_manager_stub.cc +++ b/tests/depends/error_manager/src/error_manager_stub.cc @@ -16,6 +16,8 @@ #include "common/util/error_manager/error_manager.h" +using namespace ErrorMessage; + ErrorManager &ErrorManager::GetInstance() { static ErrorManager instance; return instance; @@ -58,7 +60,7 @@ /// @param [in] value: vector parameter value /// void ErrorManager::ATCReportErrMessage(std::string error_code, const std::vector &key, - const std::vector &value) { + const std::vector &value) { } /// @@ -78,3 +80,17 @@ int ErrorManager::GetMstuneCompileFailedMsg(const std::string &graph_name, std::map> &msg_map) { return 0; } + void ErrorManager::GenWorkStreamIdDefault() {} + + void ErrorManager::GenWorkStreamIdBySessionGraph(uint64_t session_id, uint64_t graph_id) {} + + const std::string &ErrorManager::GetLogHeader() { return "[TEST][TEST]"; } + + struct Context &ErrorManager::GetErrorContext() { + struct Context error_context; + return error_context; + } + +void ErrorManager::SetErrorContext(struct Context error_context) {} + +void ErrorManager::SetStage(const std::string &first_stage, const std::string &second_stage) {}