diff --git a/inc/framework/ge_runtime/model_runner.h b/inc/framework/ge_runtime/model_runner.h index 8e312b093744c8035190afc68069a0bd9cef40bc..e495dfdfd6f290dba3a6eb7b9b44e06cc09a3b77 100644 --- a/inc/framework/ge_runtime/model_runner.h +++ b/inc/framework/ge_runtime/model_runner.h @@ -35,6 +35,9 @@ class ModelRunner { bool LoadDavinciModel(uint32_t device_id, uint64_t session_id, uint32_t model_id, std::shared_ptr davinci_model, std::shared_ptr listener); + + bool DistributeTask(uint32_t model_id); + bool LoadModelComplete(uint32_t model_id); const std::vector &GetTaskIdList(uint32_t model_id) const; @@ -43,6 +46,8 @@ class ModelRunner { const std::map> &GetRuntimeInfoMap(uint32_t model_id) const; + void *GetModelHandle(uint32_t model_id) const; + bool UnloadModel(uint32_t model_id); bool RunModel(uint32_t model_id, const InputData &input_data, OutputData *output_data); diff --git a/src/ge/ge_runtime/model_runner.cc b/src/ge/ge_runtime/model_runner.cc index b6e43dd5ea5fd80713dea2749756d96c8e52ee6f..9961ab4e6a718ccd627e76a91a9d8fa87cc83ee6 100644 --- a/src/ge/ge_runtime/model_runner.cc +++ b/src/ge/ge_runtime/model_runner.cc @@ -49,6 +49,15 @@ bool ModelRunner::LoadDavinciModel(uint32_t device_id, uint64_t session_id, uint return true; } +bool ModelRunner::DistributeTask(uint32_t model_id) { + auto model_iter = runtime_models_.find(model_id); + if (model_iter == runtime_models_.end()) { + GELOGE(PARAM_INVALID, "Model id %u not found.", model_id); + return false; + } + return model_iter->second->DistributeTask(); +} + bool ModelRunner::LoadModelComplete(uint32_t model_id) { auto model_iter = runtime_models_.find(model_id); if (model_iter == runtime_models_.end()) { @@ -91,6 +100,16 @@ const std::map> &ModelRunner::GetRunti return model_iter->second->GetRuntimeInfoMap(); } +void *ModelRunner::GetModelHandle(uint32_t model_id) const { + auto model_iter = runtime_models_.find(model_id); + if (model_iter == runtime_models_.end()) { + GELOGW("Model id %u not found.", model_id); + return nullptr; + } + + return model_iter->second->GetModelHandle(); +} + bool ModelRunner::UnloadModel(uint32_t model_id) { auto iter = runtime_models_.find(model_id); if (iter != runtime_models_.end()) { diff --git a/src/ge/ge_runtime/runtime_model.cc b/src/ge/ge_runtime/runtime_model.cc index bdf8f2a6b2cd78531a4db57eceb522fe26f86cdf..f04050565b733c014a796fea97773da9b7406623 100644 --- a/src/ge/ge_runtime/runtime_model.cc +++ b/src/ge/ge_runtime/runtime_model.cc @@ -283,14 +283,16 @@ bool RuntimeModel::Load(uint32_t device_id, uint64_t session_id, std::shared_ptr } GenerateTask(device_id, session_id, davinci_model); + return status; +} - status = LoadTask(); +bool RuntimeModel::DistributeTask() { + bool status = LoadTask(); if (!status) { GELOGE(FAILED, "DistributeTask failed"); - return status; + return false; } - - return status; + return true; } bool RuntimeModel::Run() { diff --git a/src/ge/ge_runtime/runtime_model.h b/src/ge/ge_runtime/runtime_model.h index 675352963b33e47a8c93a9be934abb679f9f9df7..d0c466d4e37edc82eead7141d2a21d6f159c64be 100644 --- a/src/ge/ge_runtime/runtime_model.h +++ b/src/ge/ge_runtime/runtime_model.h @@ -35,10 +35,12 @@ class RuntimeModel { ~RuntimeModel(); bool Load(uint32_t device_id, uint64_t session_id, std::shared_ptr &davinci_model); + bool DistributeTask(); bool LoadComplete(); const std::vector &GetTaskIdList() const; const std::vector &GetStreamIdList() const; const std::map> &GetRuntimeInfoMap() const { return runtime_info_map_; } + rtModel_t GetModelHandle() const { return rt_model_handle_; } bool Run(); bool CopyInputData(const InputData &input_data); bool GetInputOutputDescInfo(bool zero_copy, std::vector *input_desc,