Browse Source

remove updation of session_id

tags/v1.3.0
wuweikang 3 years ago
parent
commit
3752b02e14
4 changed files with 0 additions and 106 deletions
  1. +0
    -2
      ge/executor/CMakeLists.txt
  2. +0
    -69
      ge/graph/load/model_manager/model_manager.cc
  3. +0
    -11
      ge/graph/load/model_manager/model_manager.h
  4. +0
    -24
      tests/ut/ge/graph/load/model_manager_unittest.cc

+ 0
- 2
ge/executor/CMakeLists.txt View File

@@ -19,7 +19,6 @@ set(SRC_LIST
"../common/dump/exception_dumper.cc" "../common/dump/exception_dumper.cc"
"../common/dump/dump_manager.cc" "../common/dump/dump_manager.cc"
"../common/dump/dump_op.cc" "../common/dump/dump_op.cc"
"../common/dump/dump_server.cc"
"../common/dump/opdebug_register.cc" "../common/dump/opdebug_register.cc"
"../common/profiling/ge_profiling.cc" "../common/profiling/ge_profiling.cc"
"../graph/load/graph_loader.cc" "../graph/load/graph_loader.cc"
@@ -251,7 +250,6 @@ target_include_directories(ge_executor_shared PRIVATE
${GE_CODE_DIR}/../inc/cce ${GE_CODE_DIR}/../inc/cce
#### blue zone #### #### blue zone ####
${GE_CODE_DIR}/third_party/fwkacllib/inc ${GE_CODE_DIR}/third_party/fwkacllib/inc
${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain
) )


target_link_options(ge_executor_shared PRIVATE target_link_options(ge_executor_shared PRIVATE


+ 0
- 69
ge/graph/load/model_manager/model_manager.cc View File

@@ -27,7 +27,6 @@
#include "graph/load/model_manager/davinci_model.h" #include "graph/load/model_manager/davinci_model.h"
#include "model/ge_root_model.h" #include "model/ge_root_model.h"
#include "common/formats/utils/formats_trans_utils.h" #include "common/formats/utils/formats_trans_utils.h"
#include "toolchain/adx_datadump_server.h"


namespace ge { namespace ge {
thread_local uint32_t device_count = 0; thread_local uint32_t device_count = 0;
@@ -49,7 +48,6 @@ const int kTimeSpecNano = 1000000000;
const int kTimeSpecMiro = 1000000; const int kTimeSpecMiro = 1000000;
const int kOpNameMaxSize = 100; const int kOpNameMaxSize = 100;
const uint64_t kInferSessionId = 0; const uint64_t kInferSessionId = 0;
const int32_t kDumpStatus = 0;
#pragma pack(push, 1) #pragma pack(push, 1)
struct CustAicpuSoBuf { struct CustAicpuSoBuf {
uint64_t kernelSoBuf; uint64_t kernelSoBuf;
@@ -320,59 +318,6 @@ bool ModelManager::IsNeedHybridLoad(ge::GeRootModel &ge_root_model) {
return is_shape_unknown || is_dsp_partitioned_graph || GetContext().GetHostExecFlag(); return is_shape_unknown || is_dsp_partitioned_graph || GetContext().GetHostExecFlag();
} }


bool ModelManager::IsDumpSeverInited(uint64_t session_id) {
auto it = session_id_to_dump_server_init_flag_.find(session_id);
return it != session_id_to_dump_server_init_flag_.end() && it->second;
}

Status ModelManager::AddDumpProperties(uint64_t session_id, const DumpProperties &dump_properties) {
if (!IsDumpSeverInited(session_id)) {
if (dump_properties.IsDumpOpen() || dump_properties.IsOpDebugOpen()) {
GE_IF_BOOL_EXEC(AdxDataDumpServerInit() != kDumpStatus,
GELOGE(PARAM_INVALID, "[Init][AdxDataDumpServer] failed, session_id:%lu.", session_id);
return PARAM_INVALID)
GELOGI("Init adx data dump server success");
session_id_to_dump_server_init_flag_[session_id] = true;
}
}
DumpManager::GetInstance().AddDumpProperties(session_id, dump_properties);
return SUCCESS;
}

Status ModelManager::InitDumPropertiesWithNewSessionId(uint64_t session_id) {
DumpProperties dump_properties;
dump_properties.InitByOptions();
GE_CHK_STATUS_RET(AddDumpProperties(session_id, dump_properties), "[Add][DumpProperties] failed.");
return SUCCESS;
}

Status ModelManager::UpdateSessionId(uint32_t model_id, GeModelPtr ge_model,
std::shared_ptr<DavinciModel> &davinci_model, uint64_t &session_id) {
uint64_t new_session_id;
Status ret = GenSessionId(new_session_id);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(ret != SUCCESS, return ret,
"[Generate][SessionId] for infer failed, model_id:%u.", model_id);
ret = davinci_model->UpdateSessionId(new_session_id);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(ret != SUCCESS, return ret,
"[Update][SessionId] for infer failed, model_id:%u.", model_id);
ge_model->InsertSessionMap(model_id, new_session_id);
GELOGD("Update new session id: %lu.", new_session_id);
session_id = new_session_id;
return SUCCESS;
}

bool ModelManager::HasVarNode(ComputeGraphPtr &compute_graph) const {
for (ge::NodePtr &node : compute_graph->GetAllNodes()) {
if (node == nullptr) {
continue;
}
if (node->GetType() == VARIABLE) {
return true;
}
}
return false;
}

/// ///
/// @ingroup domi_ome /// @ingroup domi_ome
/// @brief load model online /// @brief load model online
@@ -409,21 +354,7 @@ Status ModelManager::LoadModelOnline(uint32_t &model_id, const shared_ptr<ge::Ge
GE_IF_BOOL_EXEC(SUCCESS != (ret = davinci_model->Assign(ge_model)), GELOGW("assign model to modeldef failed."); GE_IF_BOOL_EXEC(SUCCESS != (ret = davinci_model->Assign(ge_model)), GELOGW("assign model to modeldef failed.");
break;); break;);
GE_TIMESTAMP_END(Assign, "GraphLoader::ModelAssign"); GE_TIMESTAMP_END(Assign, "GraphLoader::ModelAssign");
/// In multi-threaded inference, using the same session_id among multiple threads may cause some threads to fail.
/// These session_ids come from the same model, so the values of session_id are the same.
/// Update session_id for infer in load model to avoid the same session_id.
uint64_t session_id = GetContext().SessionId(); uint64_t session_id = GetContext().SessionId();
// Inference graph with variable node is not support for multi-threads scenario
if (!ge_root_model->GetTrainFlag() && !HasVarNode(root_graph)) {
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(UpdateSessionId(model_id, ge_model, davinci_model, session_id) != SUCCESS,
return ret,
"UpdateSessionId failed.");
GE_CHK_RT_RET(rtSetDevice(GetContext().DeviceId()));
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(InitDumPropertiesWithNewSessionId(session_id) != SUCCESS,
GE_CHK_RT(rtDeviceReset(static_cast<int32_t>(GetContext().DeviceId())));
return ret,
"Init DumProperties with new session_id failed.");
}


const DumpProperties &dump_properties = DumpManager::GetInstance().GetDumpProperties(session_id); const DumpProperties &dump_properties = DumpManager::GetInstance().GetDumpProperties(session_id);
davinci_model->SetDumpProperties(dump_properties); davinci_model->SetDumpProperties(dump_properties);


+ 0
- 11
ge/graph/load/model_manager/model_manager.h View File

@@ -345,17 +345,6 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager {


void GenModelId(uint32_t *id); void GenModelId(uint32_t *id);


Status InitDumPropertiesWithNewSessionId(uint64_t session_id);

bool IsDumpSeverInited(uint64_t session_id);

Status AddDumpProperties(uint64_t session_id, const DumpProperties &dump_properties);

Status UpdateSessionId(uint32_t model_id, GeModelPtr ge_model,
std::shared_ptr<DavinciModel> &davinci_model, uint64_t &session_id);

bool HasVarNode(ComputeGraphPtr &compute_graph) const;

std::map<uint32_t, std::shared_ptr<DavinciModel>> model_map_; std::map<uint32_t, std::shared_ptr<DavinciModel>> model_map_;
std::map<uint32_t, std::shared_ptr<hybrid::HybridDavinciModel>> hybrid_model_map_; std::map<uint32_t, std::shared_ptr<hybrid::HybridDavinciModel>> hybrid_model_map_;
std::map<std::string, std::vector<uint64_t>> model_aicpu_kernel_; std::map<std::string, std::vector<uint64_t>> model_aicpu_kernel_;


+ 0
- 24
tests/ut/ge/graph/load/model_manager_unittest.cc View File

@@ -438,28 +438,4 @@ TEST_F(UtestModelManagerModelManager, test_data_input_tensor) {
auto ret = mm.DataInputTensor(model_id,inputs); auto ret = mm.DataInputTensor(model_id,inputs);
EXPECT_EQ(PARAM_INVALID, ret); // HybridDavinciModel::impl_ is null. EXPECT_EQ(PARAM_INVALID, ret); // HybridDavinciModel::impl_ is null.
} }

TEST_F(UtestModelManagerModelManager, test_init_dump_properties_with_new_session_id) {
ModelManager model_manager;
uint64_t session_id = 1;
model_manager.InitDumPropertiesWithNewSessionId(session_id);
}

TEST_F(UtestModelManagerModelManager, test_update_session_id) {
ModelManager model_manager;
uint32_t model_id = 0;
uint64_t session_id = 0;
GeModelPtr ge_model = MakeShared<GeModel>();
std::shared_ptr<DavinciModel> davinci_model = MakeShared<DavinciModel>(0, nullptr);
model_manager.UpdateSessionId(model_id, ge_model, davinci_model, session_id);
}

TEST_F(UtestModelManagerModelManager, test_has_var_node) {
ModelManager model_manager;
uint64_t session_id = 1;
Graph graph("test");
CreateGraph(graph);
auto compute_graph = ge::GraphUtils::GetComputeGraph(graph);
model_manager.HasVarNode(compute_graph);
}
} // namespace ge } // namespace ge

Loading…
Cancel
Save