From a48a3fa01c13805616085c40200372f05cdff97b Mon Sep 17 00:00:00 2001 From: zhaozhixuan Date: Thu, 6 May 2021 20:39:31 +0800 Subject: [PATCH] MemcpyAsync in aicore executor. --- ge/graph/passes/reshape_recovery_pass.cc | 8 +++++++- ge/hybrid/node_executor/aicore/aicore_op_task.cc | 10 +++++----- .../ge/graph/passes/reshape_recovery_pass_unittest.cc | 8 ++++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/ge/graph/passes/reshape_recovery_pass.cc b/ge/graph/passes/reshape_recovery_pass.cc index 7a9d085b..ba12ba15 100644 --- a/ge/graph/passes/reshape_recovery_pass.cc +++ b/ge/graph/passes/reshape_recovery_pass.cc @@ -60,7 +60,7 @@ Status InsertReshapeIfNeed(const NodePtr &node) { node->GetName().c_str(), src_anchor->GetIdx(), dst_node->GetName().c_str(), dst_anchor->GetIdx()); GE_CHECK_NOTNULL(dst_node); GE_CHECK_NOTNULL(dst_node->GetOpDesc()); - auto dst_tensor = dst_node->GetOpDesc()->GetInputDescPtr(dst_anchor->GetIdx()); + auto dst_tensor = dst_node->GetOpDesc()->MutableInputDesc(dst_anchor->GetIdx()); GE_CHECK_NOTNULL(dst_tensor); bool is_dynamic = false; const auto &src_tensor_dims = src_tensor->GetShape().GetDims(); @@ -71,6 +71,12 @@ Status InsertReshapeIfNeed(const NodePtr &node) { dst_node->GetName().c_str()); is_dynamic = true; } + if (dst_node->GetType() == NETOUTPUT && is_dynamic) { + // NetOutput shape must be continuous when dynamic shape. + // Otherwise, there may be an error waiting for the shape refresh to time out during execution. + dst_tensor->SetShape(src_tensor->GetShape()); + continue; + } bool is_need_insert_reshape = src_tensor_dims != dst_tensor_dims && !is_dynamic; if (is_need_insert_reshape) { diff --git a/ge/hybrid/node_executor/aicore/aicore_op_task.cc b/ge/hybrid/node_executor/aicore/aicore_op_task.cc index 36f65bbe..68fbf93b 100644 --- a/ge/hybrid/node_executor/aicore/aicore_op_task.cc +++ b/ge/hybrid/node_executor/aicore/aicore_op_task.cc @@ -354,6 +354,8 @@ Status AiCoreOpTask::PrepareWithShape(TaskContext &context) { Status AiCoreOpTask::UpdateTilingInfo(TaskContext &context) { auto node = context.GetNodeItem().node; GE_CHECK_NOTNULL(node); + auto op_desc = node->GetOpDesc(); + GE_CHECK_NOTNULL(op_desc); GELOGD("[%s] Start to update tiling info for task: [%s]", node->GetName().c_str(), stub_name_.c_str()); OpRunInfo tiling_info; @@ -368,16 +370,14 @@ Status AiCoreOpTask::UpdateTilingInfo(TaskContext &context) { // update op args by tiling info block_dim_ = static_cast(tiling_info.block_dim); + op_desc->SetWorkspaceBytes(tiling_info.workspaces); clear_atomic_ = tiling_info.clear_atomic; + tiling_data_ = tiling_info.tiling_data.str(); tiling_key_ = tiling_info.tiling_key; GELOGD("Successfully getting [tiling_key] : %u", tiling_key_); - - auto op_desc = node->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - op_desc->SetWorkspaceBytes(tiling_info.workspaces); if (tiling_data_.empty()) { - GELOGD("[%s] Tiling data is empty.", op_desc->GetName().c_str()); + GELOGD("[%s] Tiling data is empty.", op_desc->GsetName().c_str()); return SUCCESS; } if (tiling_buffer_ == nullptr) { diff --git a/tests/ut/ge/graph/passes/reshape_recovery_pass_unittest.cc b/tests/ut/ge/graph/passes/reshape_recovery_pass_unittest.cc index af60021c..3be11452 100644 --- a/tests/ut/ge/graph/passes/reshape_recovery_pass_unittest.cc +++ b/tests/ut/ge/graph/passes/reshape_recovery_pass_unittest.cc @@ -42,8 +42,8 @@ ut::GraphBuilder Graph1Builder() { auto var1 = builder.AddNode("var1", "Variable", 0, 1, FORMAT_ND, DT_FLOAT, {-1}); auto const1 = builder.AddNode("const1", "Const", 0, 1, FORMAT_ND, DT_FLOAT, {1, 1, 224, 224}); auto transdata2 = builder.AddNode("transdata2", "Transdata", 1, 1, FORMAT_ND, DT_FLOAT, {224, 224}); - auto transdata1 = builder.AddNode("transdata1", "Transdata", 1, 1, FORMAT_ND, DT_FLOAT, {224, 224}); - auto netoutput1 = builder.AddNode("netoutput1", "Netoutput", 2, 0); + auto transdata1 = builder.AddNode("transdata1", "Transdata", 1, 1, FORMAT_ND, DT_FLOAT, {-1, 224}); + auto netoutput1 = builder.AddNode("netoutput1", "NetOutput", 2, 0); builder.AddDataEdge(var1, 0, transdata1, 0); builder.AddDataEdge(const1, 0, transdata2, 0); @@ -58,10 +58,10 @@ TEST_F(UtestReshapeRecoveryPass, reshape_recovery_with_dynamic_shape) { auto builder = Graph1Builder(); auto graph = builder.GetGraph(); ReshapeRecoveryPass reshape_recovery_pass; - EXPECT_EQ(graph->GetDirectNodesSize(),5); + EXPECT_EQ(graph->GetDirectNodesSize(), 5); Status ret = reshape_recovery_pass.Run(graph); EXPECT_EQ(ret, SUCCESS); - EXPECT_EQ(graph->GetDirectNodesSize(),8); + EXPECT_EQ(graph->GetDirectNodesSize(), 7); auto reshape1 = graph->FindNode("Reshape_ReshapeRecoveryPass_0"); EXPECT_NE(reshape1, nullptr);