Browse Source

skip aicore operators whose output tensors are all empty

tags/v1.1.0
chuxing 3 years ago
parent
commit
ff6f8d8e46
3 changed files with 28 additions and 5 deletions
  1. +7
    -5
      ge/hybrid/executor/worker/execution_engine.cc
  2. +20
    -0
      ge/hybrid/node_executor/aicore/aicore_node_executor.cc
  3. +1
    -0
      ge/hybrid/node_executor/aicore/aicore_node_executor.h

+ 7
- 5
ge/hybrid/executor/worker/execution_engine.cc View File

@@ -120,11 +120,13 @@ Status NodeDoneCallback::PrepareConstInputs(const NodeItem &node_item) {
node_item.NodeName().c_str(),
output_idx,
output_tensor->GetSize());
GE_CHK_RT_RET(rtMemcpy(host_buffer.data(),
tensor_size,
output_tensor->GetData(),
tensor_size,
RT_MEMCPY_DEVICE_TO_HOST));
if (tensor_size > 0) {
GE_CHK_RT_RET(rtMemcpy(host_buffer.data(),
tensor_size,
output_tensor->GetData(),
tensor_size,
RT_MEMCPY_DEVICE_TO_HOST));
}
tensor.SetData(std::move(host_buffer));
string session_id = std::to_string(context_->GetSessionId());
RuntimeInferenceContext *runtime_infer_ctx = nullptr;


+ 20
- 0
ge/hybrid/node_executor/aicore/aicore_node_executor.cc View File

@@ -156,6 +156,13 @@ Status AiCoreNodeExecutor::CompileTask(const HybridModel &model,

Status AiCoreNodeTask::ExecuteAsync(TaskContext &context, std::function<void()> done_callback) {
RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[AiCoreNodeTaskExecuteAsync] Start");
if (IsNoOp(context)) {
GELOGD("[%s] Skipping execution for op with empty outputs", context.GetNodeName());
auto ret = context.TryExecuteCallback(done_callback);
RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[AiCoreNodeTaskExecuteAsync] End");
return ret;
}

auto op_desc = context.GetNodeItem().op_desc;
GE_CHECK_NOTNULL(op_desc);
GELOGI("[%s] ExecuteAsync Start.", op_desc->GetName().c_str());
@@ -219,5 +226,18 @@ bool AiCoreNodeTask::IsSupportDynamicShape() {

return true;
}

bool AiCoreNodeTask::IsNoOp(TaskContext &task_context) {
for (int i = 0; i < task_context.NumOutputs(); ++i) {
const auto &tensor_desc = task_context.MutableOutputDesc(i);
GE_CHECK_NOTNULL(tensor_desc);
const auto &shape = tensor_desc->MutableShape();
if (shape.IsScalar() || shape.GetShapeSize() > 0) {
return false;
}
}

return true;
}
} // namespace hybrid
} // namespace ge

+ 1
- 0
ge/hybrid/node_executor/aicore/aicore_node_executor.h View File

@@ -52,6 +52,7 @@ class AiCoreNodeTask : public NodeTask {
Status UpdateArgs(TaskContext &context) override;
Status ExecuteAsync(TaskContext &context, std::function<void()> done_callback) override;
private:
static bool IsNoOp(TaskContext &task_context);
std::vector<std::unique_ptr<AiCoreOpTask>> tasks_;
};



Loading…
Cancel
Save