|
@@ -43,20 +43,21 @@ using std::vector; |
|
|
namespace ge { |
|
|
namespace ge { |
|
|
namespace { |
|
|
namespace { |
|
|
const size_t kDataOutputNum = 1; |
|
|
const size_t kDataOutputNum = 1; |
|
|
} // namespace |
|
|
|
|
|
static Status IfInferDepend(GeModelPtr &ge_model, bool &flag) { |
|
|
|
|
|
auto comp_graph = GraphUtils::GetComputeGraph(ge_model->GetGraph()); |
|
|
|
|
|
for (const auto &node : comp_graph->GetAllNodes()) { |
|
|
|
|
|
auto op_desc = node->GetOpDesc(); |
|
|
|
|
|
GE_CHECK_NOTNULL(op_desc); |
|
|
|
|
|
const auto &depends = op_desc->GetOpInferDepends(); |
|
|
|
|
|
if (!depends.empty()) { |
|
|
|
|
|
flag = true; |
|
|
|
|
|
return SUCCESS; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool NeedHybridModel(GeModelPtr &ge_model) { |
|
|
|
|
|
auto tasks = ge_model->GetModelTaskDefPtr()->task(); |
|
|
|
|
|
int32_t kernel_task_num = 0; |
|
|
|
|
|
for (int i = 0; i < tasks.size(); ++i) { |
|
|
|
|
|
if (static_cast<rtModelTaskType_t>(tasks[i].type()) == RT_MODEL_TASK_KERNEL) { |
|
|
|
|
|
kernel_task_num++; |
|
|
|
|
|
if (kernel_task_num > 1) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return SUCCESS; |
|
|
|
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
} // namespace |
|
|
|
|
|
|
|
|
SingleOpModel::SingleOpModel(const std::string &model_name, const void *model_data, uint32_t model_size) |
|
|
SingleOpModel::SingleOpModel(const std::string &model_name, const void *model_data, uint32_t model_size) |
|
|
: model_name_(model_name), ori_model_data_(model_data), ori_model_size_(model_size) {} |
|
|
: model_name_(model_name), ori_model_data_(model_data), ori_model_size_(model_size) {} |
|
@@ -497,9 +498,7 @@ Status SingleOpModel::BuildDynamicOp(StreamResource &resource, DynamicSingleOp & |
|
|
|
|
|
|
|
|
auto ge_model = model_helper_.GetGeModel(); |
|
|
auto ge_model = model_helper_.GetGeModel(); |
|
|
GE_CHECK_NOTNULL(ge_model); |
|
|
GE_CHECK_NOTNULL(ge_model); |
|
|
bool infer_depend_flag = false; |
|
|
|
|
|
GE_CHK_STATUS_RET_NOLOG(IfInferDepend(ge_model, infer_depend_flag)); |
|
|
|
|
|
if (ge_model->GetModelTaskDefPtr()->task_size() > 1 || infer_depend_flag) { |
|
|
|
|
|
|
|
|
if (NeedHybridModel(ge_model)) { |
|
|
GELOGD("Build single op HybridModel."); |
|
|
GELOGD("Build single op HybridModel."); |
|
|
GE_CHK_STATUS_RET_NOLOG(hybrid::NodeExecutorManager::GetInstance().EnsureInitialized()); |
|
|
GE_CHK_STATUS_RET_NOLOG(hybrid::NodeExecutorManager::GetInstance().EnsureInitialized()); |
|
|
auto root_model = model_helper_.GetGeRootModel(); |
|
|
auto root_model = model_helper_.GetGeRootModel(); |
|
|