|
|
|
@@ -95,13 +95,6 @@ Status KnownNodeTask::UpdateArgs(TaskContext &context) { |
|
|
|
Status KnownNodeTask::Init(TaskContext &context) { |
|
|
|
// allocate output mem |
|
|
|
GE_CHK_STATUS_RET(context.AllocateOutputs(), "known node task allocate output failed."); |
|
|
|
|
|
|
|
// init davinicmodel |
|
|
|
if (!load_flag_) { |
|
|
|
davinci_model_->InitRuntimeParams(); |
|
|
|
GE_CHK_STATUS_RET(davinci_model_->InitVariableMem(), "init variable mem failed."); |
|
|
|
} |
|
|
|
|
|
|
|
// allocate mem base |
|
|
|
void *buffer = nullptr; |
|
|
|
if (davinci_model_->TotalMemSize() != 0) { |
|
|
|
@@ -129,14 +122,6 @@ Status KnownNodeTask::Init(TaskContext &context) { |
|
|
|
void *global_step = context.GetExecutionContext()->global_step; |
|
|
|
davinci_model_->SetKnownShapeGlobalStep(global_step); |
|
|
|
} |
|
|
|
int32_t device_id = 0; |
|
|
|
rtError_t rt_ret = rtGetDevice(&device_id); |
|
|
|
if (rt_ret != RT_ERROR_NONE || device_id < 0) { |
|
|
|
GELOGE(rt_ret, "Call rtGetDevice failed, ret = 0x%X, device_id = %d.", rt_ret, device_id); |
|
|
|
return RT_ERROR_TO_GE_STATUS(rt_ret); |
|
|
|
} |
|
|
|
davinci_model_->SetDeviceId(device_id); |
|
|
|
GE_CHK_STATUS_RET(davinci_model_->Init(), "KnownNodeExecutor::InitDavinciModel failed."); |
|
|
|
load_flag_ = true; |
|
|
|
} else { |
|
|
|
GE_CHK_STATUS_RET(ModelManager::GetInstance()->DestroyAicpuKernel(davinci_model_->GetSessionId(), |
|
|
|
@@ -146,6 +131,25 @@ Status KnownNodeTask::Init(TaskContext &context) { |
|
|
|
return SUCCESS; |
|
|
|
} |
|
|
|
|
|
|
|
Status KnownNodeTask::InitDavinciModel() { |
|
|
|
davinci_model_->InitRuntimeParams(); |
|
|
|
GE_CHK_STATUS_RET(davinci_model_->InitVariableMem(), "init variable mem failed"); |
|
|
|
auto mem_size = davinci_model_->TotalMemSize(); |
|
|
|
if (mem_size > 0) { |
|
|
|
auto buffer = TensorBuffer::Create(NpuMemoryAllocator::GetAllocator(), mem_size); |
|
|
|
GE_CHECK_NOTNULL(buffer); |
|
|
|
davinci_model_->UpdateMemBase(static_cast<uint8_t *>(buffer->GetData())); |
|
|
|
GELOGI("KnownNodeTask::Init mem base is %p, size %lu.", |
|
|
|
davinci_model_->GetRuntimeParam().mem_base, davinci_model_->GetRuntimeParam().mem_size); |
|
|
|
} |
|
|
|
|
|
|
|
int32_t device_id = 0; |
|
|
|
GE_CHK_RT_RET(rtGetDevice(&device_id)); |
|
|
|
davinci_model_->SetDeviceId(static_cast<uint32_t>(device_id)); |
|
|
|
GE_CHK_STATUS_RET(davinci_model_->Init(), "[Init][Model] Failed to init davinci model."); |
|
|
|
return SUCCESS; |
|
|
|
} |
|
|
|
|
|
|
|
Status KnownNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) const { |
|
|
|
GELOGD("[%s] KnownNodeExecutor::PrepareTask in.", context.GetNodeName()); |
|
|
|
RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[KnownNodeExecutorPrepareTask] Start"); |
|
|
|
@@ -182,9 +186,11 @@ Status KnownNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node |
|
|
|
|
|
|
|
GE_CHK_STATUS_RET(davinci_model->Assign(ge_model), "KnownNodeExecutor::LoadTask davincimodel assign failed."); |
|
|
|
|
|
|
|
task = MakeShared<KnownNodeTask>(davinci_model); |
|
|
|
GE_CHECK_NOTNULL(task); |
|
|
|
auto known_node_task = MakeShared<KnownNodeTask>(davinci_model); |
|
|
|
GE_CHECK_NOTNULL(known_node_task); |
|
|
|
GE_CHK_STATUS_RET_NOLOG(known_node_task->InitDavinciModel()); |
|
|
|
GELOGI("[%s] KnownNodeExecutor::LoadTask success.", node->GetName().c_str()); |
|
|
|
task = std::move(known_node_task); |
|
|
|
return SUCCESS; |
|
|
|
} |
|
|
|
|
|
|
|
|