Browse Source

fix ut

pull/1816/head
guopeian 4 years ago
parent
commit
8817c42cb5
2 changed files with 35 additions and 28 deletions
  1. +33
    -26
      ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc
  2. +2
    -2
      ge/hybrid/node_executor/aicpu/aicpu_node_executor.h

+ 33
- 26
ge/hybrid/node_executor/aicpu/aicpu_node_executor.cc View File

@@ -772,34 +772,41 @@ Status AicpuNodeTask::SetMemCopyTask(const domi::TaskDef &task_def) {
} }


GELOGD("Start to set memcpy task for node[%s].", node_name_.c_str()); GELOGD("Start to set memcpy task for node[%s].", node_name_.c_str());
const domi::KernelExDef &kernel_def = task_def.kernel_ex();
if (kernel_def.args_size() > sizeof(STR_FWK_OP_KERNEL)) {
GELOGE(PARAM_INVALID, "[Check][Size]sizeof STR_FWK_OP_KERNEL is:%lu, but args_size:%d is bigger",
sizeof(STR_FWK_OP_KERNEL), kernel_def.args_size());
REPORT_INNER_ERROR("E19999", "sizeof STR_FWK_OP_KERNEL is:%lu, but args_size:%d is bigger.",
sizeof(STR_FWK_OP_KERNEL), kernel_def.args_size());
return PARAM_INVALID;
}
STR_FWK_OP_KERNEL aicpu_task = {0};
auto sec_ret = memcpy_s(&aicpu_task, sizeof(STR_FWK_OP_KERNEL),
kernel_def.args().data(), kernel_def.args_size());
if (sec_ret != EOK) {
GELOGE(FAILED, "[Update][aicpu_task] failed, ret: %d", sec_ret);
REPORT_CALL_ERROR("E19999", "update aicpu_task failed, ret: %d.", sec_ret);
return FAILED;
}

GE_CHK_STATUS_RET(AllocTensorBuffer(kernel_def.task_info_size(), copy_workspace_buf_),
"[Alloc][TensorBuffer] for Node[%s] to copy task workspace buf, size=%u.",
node_name_.c_str(), kernel_def.task_info_size());
const domi::KernelDef &kernel_def = task_def.kernel();
auto &memcpy_args = kernel_def.args();
uint32_t memcpy_args_size = kernel_def.args_size();
GE_IF_BOOL_EXEC(memcpy_args.size() != memcpy_args_size,
REPORT_INNER_ERROR("E19999", "MemCopy task def args.size=%zu, but args_size=%u not equal.",
memcpy_args.size(), memcpy_args_size);
GELOGE(FAILED, "[Check][Size]MemCopy task def args.size=%zu, but args_size=%u not equal.",
memcpy_args.size(), memcpy_args_size);
return FAILED;);
GE_IF_BOOL_EXEC(memcpy_args_size < sizeof(aicpu::AicpuParamHead),
REPORT_INNER_ERROR("E19999",
"Task def args_size=%u is less than aicpu param head len=%zu.",
memcpy_args_size, sizeof(aicpu::AicpuParamHead));
GELOGE(FAILED,
"[Check][Size] Task def args_size=%u is less than aicpu param head len=%zu.",
memcpy_args_size, sizeof(aicpu::AicpuParamHead));
return FAILED;);


GE_CHK_RT_RET(rtMemcpy(copy_workspace_buf_->GetData(), kernel_def.task_info_size(),
kernel_def.task_info().data(), kernel_def.task_info_size(), RT_MEMCPY_HOST_TO_DEVICE));
std::unique_ptr<uint8_t[]> memcpy_task;
memcpy_task.reset(new(std::nothrow) uint8_t[memcpy_args_size]());
GE_IF_BOOL_EXEC(memcpy_task == nullptr,
REPORT_INNER_ERROR("E19999", "new memory failed for Node[MemCopy], task_size[%u].",
memcpy_args_size);
GELOGE(FAILED, "[Malloc][Memory] failed for Node[MemCopy], task_size[%u].",
memcpy_args_size);
return FAILED;);


aicpu_task.fwkKernelBase.fwk_kernel.inputOutputAddr = reinterpret_cast<uintptr_t>(copy_ioaddr_dev_->GetData());
aicpu_task.fwkKernelBase.fwk_kernel.workspaceBaseAddr = reinterpret_cast<uintptr_t>(copy_workspace_buf_->GetData());
aicpu_task.fwkKernelBase.fwk_kernel.extInfoAddr = 0;
aicpu_task.fwkKernelBase.fwk_kernel.extInfoLen = 0;
errno_t sec_ret = memcpy_s(memcpy_task.get(), memcpy_args_size, memcpy_args.c_str(), memcpy_args.size());
GE_IF_BOOL_EXEC(sec_ret != EOK,
REPORT_INNER_ERROR("E19999",
"memcpy_s argc_ failed for Node[MemCopy], ret: %d", sec_ret);
GELOGE(INTERNAL_ERROR,
"[Update][args] failed for Node[MemCopy], ret: %d", sec_ret);
return sec_ret;);


GE_CHK_RT_RET(rtMemcpy(copy_task_args_buf_->GetData(), sizeof(STR_FWK_OP_KERNEL), GE_CHK_RT_RET(rtMemcpy(copy_task_args_buf_->GetData(), sizeof(STR_FWK_OP_KERNEL),
&aicpu_task, sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE)); &aicpu_task, sizeof(STR_FWK_OP_KERNEL), RT_MEMCPY_HOST_TO_DEVICE));


+ 2
- 2
ge/hybrid/node_executor/aicpu/aicpu_node_executor.h View File

@@ -98,8 +98,6 @@ class AicpuNodeTaskBase : public NodeTask {
std::unique_ptr<TensorBuffer> copy_input_src_dev_; std::unique_ptr<TensorBuffer> copy_input_src_dev_;
std::unique_ptr<TensorBuffer> copy_input_dst_dev_; std::unique_ptr<TensorBuffer> copy_input_dst_dev_;
bool need_sync_ = false; bool need_sync_ = false;

std::unique_ptr<TensorBuffer> copy_workspace_buf_;
}; };


class AicpuTfNodeTask : public AicpuNodeTaskBase { class AicpuTfNodeTask : public AicpuNodeTaskBase {
@@ -148,6 +146,8 @@ class AicpuTfNodeTask : public AicpuNodeTaskBase {


// input and output addr, device mem // input and output addr, device mem
std::unique_ptr<TensorBuffer> input_output_addr_; std::unique_ptr<TensorBuffer> input_output_addr_;

std::unique_ptr<TensorBuffer> copy_workspace_buf_;
}; };


class AicpuNodeTask : public AicpuNodeTaskBase { class AicpuNodeTask : public AicpuNodeTaskBase {


Loading…
Cancel
Save