No session in tf_singleop_task and add cpu kernels cache.

pull/411/head
unknown 4 years ago
parent dc37412456
commit 71788dcc50

@ -31,6 +31,7 @@
#include "runtime/kernel.h"
#include "super_kernel/super_kernel.h"
#include "super_kernel/super_kernel_factory.h"
#include "cce/aicpu_engine_struct.h"
namespace {
const uint8_t kL2LoadToDdr = 1;
@ -958,12 +959,40 @@ Status KernelTaskInfo::InitAicpuTaskExtInfo(const std::string &ext_info) {
if (ext_info.empty()) {
return SUCCESS;
}
std::unique_ptr<uint8_t[]> copy_ext_info;
copy_ext_info.reset(new(std::nothrow)uint8_t[ext_info.size()]);
GE_CHECK_NOTNULL(copy_ext_info);
auto sec_ret = memcpy_s(copy_ext_info.get(), ext_info.size(), ext_info.c_str(), ext_info.size());
if (sec_ret != EOK) {
GELOGE(FAILED, "memcpy failed, ret: %d", sec_ret);
return FAILED;
}
auto ext_info_data = copy_ext_info.get();
size_t offset = 0;
while (offset + sizeof(aicpu::FWKAdapter::ExtInfo) <= ext_info.size()) {
auto aicpu_ext_info = reinterpret_cast<aicpu::FWKAdapter::ExtInfo *>(ext_info_data + offset);
GELOGD("Ext infoType=%d, infoLen=%u.", aicpu_ext_info->infoType, aicpu_ext_info->infoLen);
if (aicpu_ext_info->infoType == aicpu::FWKAdapter::FWK_ADPT_EXT_SESSION_INFO) {
GE_CHK_BOOL_RET_STATUS(aicpu_ext_info->infoLen == sizeof(SessionInfo), PARAM_INVALID,
"Parse ext session info failed as infoLen must be %zu but %u.",
sizeof(SessionInfo), aicpu_ext_info->infoLen);
SessionInfo *session_info = reinterpret_cast<SessionInfo *>(aicpu_ext_info->infoMsg);
session_info->sessionId = davinci_model_->GetSessionId();
session_info->sessFlag = true;
GELOGD("Update aicpu_task ext_info session_info session_id is %lu", session_info->sessionId);
}
offset += sizeof(aicpu::FWKAdapter::ExtInfo);
offset += aicpu_ext_info->infoLen;
}
auto rt_ret = rtMalloc(&aicpu_ext_info_addr_, ext_info.size(), RT_MEMORY_HBM);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "rtMalloc ext_info error: 0x%X, size=%zu", rt_ret, ext_info.size());
return RT_ERROR_TO_GE_STATUS(rt_ret);
}
rt_ret = rtMemcpy(aicpu_ext_info_addr_, ext_info.size(), ext_info.c_str(), ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE);
rt_ret = rtMemcpy(aicpu_ext_info_addr_, ext_info.size(), ext_info_data, ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "rtMemcpy ext_info error: 0x%X, size=%zu", rt_ret, ext_info.size());
return RT_ERROR_TO_GE_STATUS(rt_ret);

@ -57,6 +57,9 @@ Status AicpuExtInfoHandler::Parse(const std::string &ext_info) {
case aicpu::FWKAdapter::FWK_ADPT_EXT_OUTPUT_SHAPE:
GE_CHK_STATUS_RET(ParseExtOutputShape(aicpu_ext_info), "Parse ext output shape failed.");
break;
case aicpu::FWKAdapter::FWK_ADPT_EXT_SESSION_INFO:
GE_CHK_STATUS_RET(ParseExtSessionInfo(aicpu_ext_info), "Parse ext session info failed.");
break;
default:
GELOGD("Node[%s] ignore infoType=%d, infoLen=%u.",
node_name_.c_str(), aicpu_ext_info->infoType, aicpu_ext_info->infoLen);
@ -123,6 +126,39 @@ Status AicpuExtInfoHandler::ParseExtOutputShape(AicpuExtInfo *aicpu_ext_info) {
return SUCCESS;
}
Status AicpuExtInfoHandler::ParseExtSessionInfo(AicpuExtInfo *aicpu_ext_info) {
GE_CHK_BOOL_RET_STATUS(aicpu_ext_info->infoLen == sizeof(AicpuSessionInfo), PARAM_INVALID,
"Node[%s] parse ext session info failed as infoLen must be %zu but %u.",
node_name_.c_str(), sizeof(SessionInfo), aicpu_ext_info->infoLen);
session_info_ = reinterpret_cast<AicpuSessionInfo *>(aicpu_ext_info->infoMsg);
GELOGI("Node[%s] parse session info success infoLen=%u.", node_name_.c_str(), aicpu_ext_info->infoLen);
return SUCCESS;
}
Status AicpuExtInfoHandler::UpdateSessionInfo(uint64_t session_id, uint64_t kernel_id, bool sess_flag) {
if (session_info_ == nullptr) {
GELOGD("There is no session info in ext_info, no need update.");
return SUCCESS;
}
session_info_->sessionId = session_id;
session_info_->kernelId = kernel_id;
session_info_->sessFlag = sess_flag;
return SUCCESS;
}
Status AicpuExtInfoHandler::UpdateSessionInfoSessionId(uint64_t session_id) {
if (session_info_ == nullptr) {
GELOGD("There is no session info in ext_info, no need update.");
return SUCCESS;
}
session_info_->sessionId = session_id;
session_info_->sessFlag = true;
return SUCCESS;
}
Status AicpuExtInfoHandler::UpdateInputShapeAndType(uint32_t input_index, const GeTensorDesc &input_desc) {
GE_CHECK_LE(input_index, input_num_);
const auto &shape = input_desc.GetShape();

@ -19,6 +19,7 @@
#include "external/ge/ge_api_error_codes.h"
#include "cce/fwk_adpt_struct.h"
#include "cce/aicpu_engine_struct.h"
#include "graph/op_desc.h"
#include "graph/ge_tensor.h"
@ -26,6 +27,7 @@ namespace ge {
namespace hybrid {
using AicpuShapeAndType = aicpu::FWKAdapter::ShapeAndType;
using AicpuExtInfo = aicpu::FWKAdapter::ExtInfo;
using AicpuSessionInfo = SessionInfo;
class AicpuExtInfoHandler {
public:
@ -51,6 +53,10 @@ class AicpuExtInfoHandler {
Status UpdateOutputShapeAndType(uint32_t output_index, const GeTensorDesc &output_desc);
Status UpdateSessionInfo(uint64_t session_id, uint64_t kernel_id, bool sess_flag);
Status UpdateSessionInfoSessionId(uint64_t session_id);
Status GetOutputShapeAndType(uint32_t output_index, GeShape &shape, DataType &data_type);
private:
@ -58,6 +64,7 @@ class AicpuExtInfoHandler {
Status ParseExtShapeType(AicpuExtInfo *aicpu_ext_info);
Status ParseExtInputShape(AicpuExtInfo *aicpu_ext_info);
Status ParseExtOutputShape(AicpuExtInfo *aicpu_ext_info);
Status ParseExtSessionInfo(AicpuExtInfo *aicpu_ext_info);
static Status UpdateShapeAndType(const GeShape &shape,
DataType data_type,
@ -72,6 +79,7 @@ class AicpuExtInfoHandler {
const uint32_t input_num_;
const uint32_t output_num_;
UnknowShapeOpType unknown_type_;
AicpuSessionInfo *session_info_ = nullptr;
std::unique_ptr<uint8_t[]> ext_info_;
size_t ext_info_len_ = 0;

@ -40,29 +40,36 @@ Status AicpuNodeTaskBase::AllocTensorBuffer(size_t size, std::unique_ptr<TensorB
return SUCCESS;
}
Status AicpuNodeTaskBase::InitExtInfo(const std::string &kernel_ext_info) {
Status AicpuNodeTaskBase::InitExtInfo(const std::string &kernel_ext_info, int64_t session_id) {
if (kernel_ext_info.empty()) {
if (node_item_->is_dynamic) {
// dynamic node must have ext info
GE_CHK_STATUS_RET(aicpu_ext_handle_.Parse(kernel_ext_info),
"Node[%s] parse kernel ext info failed, kernel_ext_info_size=%zu.",
node_name_.c_str(), kernel_ext_info.size());
}
GELOGE(PARAM_INVALID, "Node[%s] parse ext info failed as ext info is empty.", node_name_.c_str());
return PARAM_INVALID;
} else {
// if no ext info no need copy to device.
if (kernel_ext_info.empty()) {
GELOGI("Node[%s] kernel_ext_info is empty, no need copy to device, is_dynamic=%s.",
node_name_.c_str(), node_item_->is_dynamic ? "true" : "false");
return SUCCESS;
}
}
GE_CHK_STATUS_RET(aicpu_ext_handle_.Parse(kernel_ext_info),
"Node[%s] parse kernel ext info failed, kernel_ext_info_size=%zu.",
node_name_.c_str(), kernel_ext_info.size());
GELOGD("To update aicpu_task ext_info session_info session_id to %lu", session_id);
GE_CHK_STATUS_RET(aicpu_ext_handle_.UpdateSessionInfoSessionId(session_id),
"UpdateSessionInfoSessionId failed.");
// copy task args buf
GE_CHK_STATUS_RET(AllocTensorBuffer(kernel_ext_info.size(), ext_info_addr_dev_),
GE_CHK_STATUS_RET(AllocTensorBuffer(aicpu_ext_handle_.GetExtInfoLen(), ext_info_addr_dev_),
"Node[%s] alloc kernel_ext_info buf failed, size=%zu",
node_name_.c_str(), kernel_ext_info.size());
node_name_.c_str(), aicpu_ext_handle_.GetExtInfoLen());
// copy default ext info to device
GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_->GetData(), ext_info_addr_dev_->GetSize(),
kernel_ext_info.data(), kernel_ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE));
aicpu_ext_handle_.GetExtInfo(), aicpu_ext_handle_.GetExtInfoLen(),
RT_MEMCPY_HOST_TO_DEVICE));
return SUCCESS;
}
@ -290,7 +297,8 @@ Status AicpuTfNodeTask::Init(const HybridModel &model) {
node_name_.c_str(), kernel_ext_info.size(), kernel_ext_info_size);
// init ext info
GE_CHK_STATUS_RET(InitExtInfo(kernel_ext_info), "Node[%s] init ext info failed.", node_name_.c_str());
uint64_t ext_session_id = model.GetSessionId();
GE_CHK_STATUS_RET(InitExtInfo(kernel_ext_info, ext_session_id), "Node[%s] init ext info failed.", node_name_.c_str());
GE_CHK_STATUS_RET(InitForDependComputeTask(), "Node[%s] init for depend compute task failed.", node_name_.c_str());
// build fwk_op_kernel.
@ -679,7 +687,8 @@ Status AicpuNodeTask::Init(const HybridModel &model) {
"Node[%s] task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.",
node_name.c_str(), kernel_ext_info.size(), kernel_ext_info_size);
GE_CHK_STATUS_RET(InitExtInfo(kernel_ext_info), "Node[%s] init ext info failed.", node_name.c_str());
uint64_t ext_session_id = model.GetSessionId();
GE_CHK_STATUS_RET(InitExtInfo(kernel_ext_info, ext_session_id), "Node[%s] init ext info failed.", node_name.c_str());
if (ext_info_addr_dev_ == nullptr) {
aicpu_param_head->extInfoLength = 0;

@ -43,7 +43,7 @@ class AicpuNodeTaskBase : public NodeTask {
Status ExecuteAsync(TaskContext &context, std::function<void()> done_callback) override;
protected:
virtual Status InitExtInfo(const std::string &kernel_ext_info);
virtual Status InitExtInfo(const std::string &kernel_ext_info, int64_t session_id);
virtual Status UpdateExtInfo();

@ -44,8 +44,6 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY SingleOp::~SingleOp() {
delete task;
task = nullptr;
}
GELOGI("SingleOp destory sessionId = %lu", aicpu_session_id_);
ModelManager::GetInstance()->DestroyAicpuSession(aicpu_session_id_);
}
Status SingleOp::ValidateArgs(const std::vector<DataBuffer> &inputs, const std::vector<DataBuffer> &outputs) {
@ -180,17 +178,11 @@ void SingleOp::SetStream(rtStream_t stream) {
stream_ = stream;
}
void SingleOp::SetSessionID(uint64_t session_id) {
aicpu_session_id_ = session_id;
}
DynamicSingleOp::DynamicSingleOp(uintptr_t resource_id, std::mutex *stream_mutex, rtStream_t stream)
: resource_id_(resource_id), stream_mutex_(stream_mutex), stream_(stream) {
}
DynamicSingleOp::~DynamicSingleOp() {
GELOGI("DynamicSingleOp destory sessionId = %lu", aicpu_session_id_);
ModelManager::GetInstance()->DestroyAicpuSession(aicpu_session_id_);
}
Status DynamicSingleOp::ValidateParams(const vector<GeTensorDesc> &input_desc,
@ -299,8 +291,4 @@ Status DynamicSingleOp::ExecuteAsync(const vector<GeTensorDesc> &input_desc,
return ACL_ERROR_GE_OP_TASK_TYPE_INVALID;
}
}
void DynamicSingleOp::SetSessionID(uint64_t session_id) {
aicpu_session_id_ = session_id;
}
} // namespace ge

@ -37,7 +37,6 @@ class SingleOp {
Status ExecuteAsync(const std::vector<DataBuffer> &inputs, const std::vector<DataBuffer> &outputs);
void SetStream(rtStream_t stream);
void SetSessionID(uint64_t session_id);
private:
Status ValidateArgs(const std::vector<DataBuffer> &inputs, const std::vector<DataBuffer> &outputs);
@ -52,7 +51,6 @@ class SingleOp {
std::vector<void *> output_addr_list_;
std::vector<size_t> output_sizes_;
std::vector<uintptr_t> args_;
uint64_t aicpu_session_id_ = 0;
std::vector<OpTask *> tasks_;
std::vector<std::vector<uintptr_t *>> arg_table_;
@ -66,7 +64,6 @@ class DynamicSingleOp {
const std::vector<DataBuffer> &inputs,
std::vector<GeTensorDesc> &output_desc,
std::vector<DataBuffer> &outputs);
void SetSessionID(uint64_t session_id);
private:
friend class SingleOpModel;
@ -89,7 +86,6 @@ class DynamicSingleOp {
rtStream_t stream_ = nullptr;
size_t num_inputs_ = 0;
size_t num_outputs_ = 0;
uint64_t aicpu_session_id_ = 0;
};
} // namespace ge
#endif // GE_SINGLE_OP_SINGLE_OP_H_

@ -32,7 +32,7 @@
#include "task/aicpu_kernel_task_builder.h"
#include "task/tbe_task_builder.h"
static std::atomic<std::uint64_t> aicpu_sessionid(0);
static std::atomic<std::uint64_t> aicpu_kernel_id(0);
using domi::TaskDef;
using std::unique_ptr;
@ -252,7 +252,9 @@ Status SingleOpModel::BuildTaskList(SingleOp &single_op) {
} else if (kernel_type == cce::ccKernelType::AI_CPU || kernel_type == cce::ccKernelType::CUST_AI_CPU) {
GELOGD("Building AICPU_CC task");
OpTask *task = nullptr;
auto ret = BuildCpuKernelTask(task_def.kernel(), &task);
uint64_t singleop_kernel_id = aicpu_kernel_id++;
GELOGI("Build singleOp CCTask, kernel_id = %lu", singleop_kernel_id);
auto ret = BuildCpuKernelTask(task_def.kernel(), &task, singleop_kernel_id);
if (ret != SUCCESS) {
return ret;
}
@ -265,14 +267,13 @@ Status SingleOpModel::BuildTaskList(SingleOp &single_op) {
GELOGD("Building AICPU_TF task");
AiCpuTask *aicpu_task = nullptr;
bool depend_compute_flag = false;
uint64_t singleop_sessionid = aicpu_sessionid++;
GELOGI("Build singleOp, sessionId = %lu", singleop_sessionid);
auto ret = BuildKernelExTask(task_def.kernel_ex(), &aicpu_task, false, depend_compute_flag, singleop_sessionid);
uint64_t singleop_kernel_id = aicpu_kernel_id++;
GELOGI("Build singleOp TfTask, kernel_id = %lu", singleop_kernel_id);
auto ret = BuildKernelExTask(task_def.kernel_ex(), &aicpu_task, false, depend_compute_flag, singleop_kernel_id);
if (ret != SUCCESS) {
return ret;
}
single_op.tasks_.emplace_back(aicpu_task);
single_op.SetSessionID(singleop_sessionid);
} else {
// skip
GELOGD("Skip task type: %d", static_cast<int>(task_type));
@ -329,7 +330,7 @@ Status SingleOpModel::BuildKernelTask(const domi::KernelDef &kernel_def, TbeOpTa
}
Status SingleOpModel::BuildKernelExTask(const domi::KernelExDef &kernel_def, AiCpuTask **task,
bool dynamic_flag, bool& depend_compute_flag, uint64_t session_id) {
bool dynamic_flag, bool& depend_compute_flag, uint64_t kernel_id) {
auto iter = op_list_.find(kernel_def.op_index());
if (iter == op_list_.end()) {
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "op desc not found. op index = %u", kernel_def.op_index());
@ -342,7 +343,7 @@ Status SingleOpModel::BuildKernelExTask(const domi::KernelExDef &kernel_def, AiC
return ACL_ERROR_GE_MEMORY_ALLOCATION;
}
auto builder = AiCpuTaskBuilder(iter->second->GetOpDesc(), kernel_def);
auto ret = builder.BuildTask(*aicpu_task, model_params_, dynamic_flag, session_id);
auto ret = builder.BuildTask(*aicpu_task, model_params_, dynamic_flag, kernel_id);
if (ret != SUCCESS) {
GELOGE(ret, "build aicpu_TF op task failed");
return ret;
@ -353,7 +354,7 @@ Status SingleOpModel::BuildKernelExTask(const domi::KernelExDef &kernel_def, AiC
return SUCCESS;
}
Status SingleOpModel::BuildCpuKernelTask(const domi::KernelDef &kernel_def, OpTask **task) {
Status SingleOpModel::BuildCpuKernelTask(const domi::KernelDef &kernel_def, OpTask **task, uint64_t kernel_id) {
const auto &context = kernel_def.context();
auto iter = op_list_.find(context.op_index());
if (iter == op_list_.end()) {
@ -367,7 +368,7 @@ Status SingleOpModel::BuildCpuKernelTask(const domi::KernelDef &kernel_def, OpTa
}
auto builder = AiCpuCCTaskBuilder(iter->second->GetOpDesc(), kernel_def);
auto ret = builder.BuildTask(*aicpucc_task);
auto ret = builder.BuildTask(*aicpucc_task, kernel_id);
if (ret != SUCCESS) {
GELOGE(ret, "build aicpu_CC op task failed");
return ret;
@ -396,7 +397,9 @@ Status SingleOpModel::BuildModelTaskKernel(const TaskDef &task_def, DynamicSingl
} else if (kernel_type == cce::ccKernelType::AI_CPU || kernel_type == cce::ccKernelType::CUST_AI_CPU) {
GELOGD("Building AICPU_CC task");
OpTask *task = nullptr;
GE_CHK_STATUS_RET_NOLOG(BuildCpuKernelTask(task_def.kernel(), &task));
uint64_t dynamic_singleop_kernel_id = aicpu_kernel_id++;
GELOGI("Build dynamic singleOp CCTask, kernel_id = %lu", dynamic_singleop_kernel_id);
GE_CHK_STATUS_RET_NOLOG(BuildCpuKernelTask(task_def.kernel(), &task, dynamic_singleop_kernel_id));
single_op.op_task_.reset(task);
} else {
GELOGE(ACL_ERROR_GE_OP_KERNEL_TYPE_INVALID,
@ -430,10 +433,10 @@ Status SingleOpModel::BuildTaskListForDynamicOp(DynamicSingleOp &single_op) {
GELOGD("Building AICPU_TF task");
AiCpuTask *aicpu_task = nullptr;
bool depend_compute_flag = false;
uint64_t dynamic_singleop_sessionid = aicpu_sessionid++;
GELOGI("Build dynamic singleOp, sessionId = %lu", dynamic_singleop_sessionid);
uint64_t dynamic_singleop_kernel_id = aicpu_kernel_id++;
GELOGI("Build dynamic singleOp TfTask, kernel_id = %lu", dynamic_singleop_kernel_id);
GE_CHK_STATUS_RET_NOLOG(BuildKernelExTask(task_def.kernel_ex(), &aicpu_task, true,
depend_compute_flag, dynamic_singleop_sessionid));
depend_compute_flag, dynamic_singleop_kernel_id));
if (depend_compute_flag) {
if (i >= tasks.size() - 1) {
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "The copy task of the fourth operator was not found.");
@ -444,7 +447,6 @@ Status SingleOpModel::BuildTaskListForDynamicOp(DynamicSingleOp &single_op) {
GE_CHK_STATUS_RET_NOLOG(aicpu_task->SetMemCopyTask(copy_task_def.kernel_ex()));
}
single_op.op_task_.reset(aicpu_task);
single_op.SetSessionID(dynamic_singleop_sessionid);
} else {
// skip
GELOGD("Skip task type: %d", static_cast<int>(task_type));

@ -69,8 +69,8 @@ class SingleOpModel {
Status BuildTaskListForDynamicOp(DynamicSingleOp &dynamic_single_op);
Status BuildKernelTask(const domi::KernelDef &kernel_def, TbeOpTask **task);
Status BuildKernelExTask(const domi::KernelExDef &kernel_def, AiCpuTask **task,
bool dynamic_flag, bool& depend_compute_flag, uint64_t session_id);
Status BuildCpuKernelTask(const domi::KernelDef &kernel_def, OpTask **task);
bool dynamic_flag, bool& depend_compute_flag, uint64_t kernel_id);
Status BuildCpuKernelTask(const domi::KernelDef &kernel_def, OpTask **task, uint64_t kernel_id);
Status BuildModelTaskKernel(const domi::TaskDef &task_def, DynamicSingleOp &single_op);
static void ParseOpModelParams(ModelHelper &model_helper, SingleOpModelParam &param);

@ -46,7 +46,7 @@ Status AiCpuCCTaskBuilder::SetKernelArgs(AiCpuCCTask &task) {
return SUCCESS;
}
Status AiCpuCCTaskBuilder::BuildTask(AiCpuCCTask &task) {
Status AiCpuCCTaskBuilder::BuildTask(AiCpuCCTask &task, uint64_t kernel_id) {
auto ret = SetKernelArgs(task);
if (ret != SUCCESS) {
return ret;
@ -76,7 +76,7 @@ Status AiCpuCCTaskBuilder::BuildTask(AiCpuCCTask &task) {
"task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.",
kernel_ext_info.size(), kernel_ext_info_size);
ret = task.SetExtInfoAndType(kernel_ext_info);
ret = task.SetExtInfoAndType(kernel_ext_info, kernel_id);
if (ret != SUCCESS) {
GELOGE(ret, "Init ext info failed.");
return ret;

@ -30,7 +30,7 @@ class AiCpuCCTaskBuilder {
explicit AiCpuCCTaskBuilder(const OpDescPtr &op_desc, const domi::KernelDef &kernel_def);
~AiCpuCCTaskBuilder() = default;
Status BuildTask(AiCpuCCTask &task);
Status BuildTask(AiCpuCCTask &task, uint64_t kernel_id);
private:
Status SetKernelArgs(AiCpuCCTask &task);

@ -111,7 +111,7 @@ namespace ge {
}
Status AiCpuTaskBuilder::BuildTask(ge::AiCpuTask &task, const SingleOpModelParam &param,
bool dynamic_flag, uint64_t session_id) {
bool dynamic_flag, uint64_t kernel_id) {
GE_CHK_STATUS_RET_NOLOG(InitWorkspaceAndIO(&task.io_addr_, &task.workspace_addr_, param, dynamic_flag));
STR_FWK_OP_KERNEL fwk_op_kernel = {0};
@ -130,7 +130,7 @@ namespace ge {
GE_CHK_BOOL_RET_STATUS(kernel_ext_info.size() == kernel_ext_info_size, FAILED,
"task def kernel_ext_info.size=%zu, but kernel_ext_info_size=%u.",
kernel_ext_info.size(), kernel_ext_info_size);
GE_CHK_STATUS_RET(task.SetExtInfoAndType(kernel_ext_info), "Init ext info failed.");
GE_CHK_STATUS_RET(task.SetExtInfoAndType(kernel_ext_info, kernel_id), "Init ext info failed.");
if (task.ext_info_addr_dev_ != nullptr) {
fwk_op_kernel.fwkKernelBase.fwk_kernel.extInfoAddr = reinterpret_cast<uintptr_t>(task.ext_info_addr_dev_);
@ -138,13 +138,9 @@ namespace ge {
}
GE_CHK_STATUS_RET(task.InitForSummaryAndCopy(), "AiCpuTask init for summary and copy task failed.");
// Create session
fwk_op_kernel.fwkKernelBase.fwk_kernel.sessionID = session_id;
GELOGI("Begin to CreateAicpuSession, session id: %lu", session_id);
GE_CHECK_NOTNULL(ModelManager::GetInstance());
GE_IF_BOOL_EXEC(ModelManager::GetInstance()->CreateAicpuSession(session_id) != SUCCESS,
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "CreateAicpuSession error. session id: %lu", session_id);
return ACL_ERROR_GE_INTERNAL_ERROR;)
fwk_op_kernel.fwkKernelBase.fwk_kernel.sessionID = ULLONG_MAX;
fwk_op_kernel.fwkKernelBase.fwk_kernel.kernelID = kernel_id;
fwk_op_kernel.fwkKernelBase.fwk_kernel.opType = aicpu::FWKAdapter::FWKOperateType::FWK_ADPT_KERNEL_RUN_NO_SESS;
ret = SetKernelArgs(&task.args_, fwk_op_kernel);
if (ret != SUCCESS) {
return ret;

@ -29,7 +29,7 @@ namespace ge {
AiCpuTaskBuilder(const OpDescPtr &op_desc, const domi::KernelExDef &kernel_def);
~AiCpuTaskBuilder() = default;
Status BuildTask(AiCpuTask &task, const SingleOpModelParam &param, bool dynamic_flag, uint64_t session_id);
Status BuildTask(AiCpuTask &task, const SingleOpModelParam &param, bool dynamic_flag, uint64_t kernel_id);
private:
static Status SetKernelArgs(void **args, STR_FWK_OP_KERNEL &kernel);

@ -245,7 +245,7 @@ AiCpuBaseTask::~AiCpuBaseTask() {
}
}
Status AiCpuBaseTask::SetExtInfoAndType(const std::string &kernel_ext_info) {
Status AiCpuBaseTask::SetExtInfoAndType(const std::string &kernel_ext_info, uint64_t kernel_id) {
if (kernel_ext_info.empty()) {
GELOGI("Kernel_ext_info is empty, no need copy to device.");
return SUCCESS;
@ -268,9 +268,13 @@ Status AiCpuBaseTask::SetExtInfoAndType(const std::string &kernel_ext_info) {
return ret;
}
GE_CHK_RT_RET(rtMalloc(&ext_info_addr_dev_, kernel_ext_info.size(), RT_MEMORY_HBM));
GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_, kernel_ext_info.size(),
kernel_ext_info.data(), kernel_ext_info.size(), RT_MEMCPY_HOST_TO_DEVICE));
GE_CHK_STATUS_RET(aicpu_ext_handle_->UpdateSessionInfo(ULLONG_MAX, kernel_id, false),
"UpdateSessionInfo failed.");
GE_CHK_RT_RET(rtMalloc(&ext_info_addr_dev_, aicpu_ext_handle_->GetExtInfoLen(), RT_MEMORY_HBM));
GE_CHK_RT_RET(rtMemcpy(ext_info_addr_dev_, aicpu_ext_handle_->GetExtInfoLen(),
aicpu_ext_handle_->GetExtInfo(), aicpu_ext_handle_->GetExtInfoLen(),
RT_MEMCPY_HOST_TO_DEVICE));
return SUCCESS;
}

@ -132,7 +132,7 @@ class AiCpuBaseTask : public OpTask {
const UnknowShapeOpType GetUnknownType() const { return unknown_type_; }
protected:
Status SetExtInfoAndType(const std::string &kernel_ext_info);
Status SetExtInfoAndType(const std::string &kernel_ext_info, uint64_t kernel_id);
Status UpdateExtInfo(const std::vector<GeTensorDesc> &input_desc,
std::vector<GeTensorDesc> &output_desc,

Loading…
Cancel
Save