已合并
fix: correct NetOutput type comparison in DAG adapter #4625
KenChow创建于 11 天前
fix: correct NetOutput type comparison in DAG adapter #4625
已合并
共 2 个文件变更+44-5
| @@ -281,7 +281,7 @@ graphStatus DAGAdapter::RefreshStreamIdsToGE(const minidag::DAGGraph &dag, const | |||
| 281 | const auto &node_type = op_desc->GetTypePtr(); | 281 | const auto &node_type = op_desc->GetTypePtr(); |
| 282 | bool rts_label_node = false; | 282 | bool rts_label_node = false; |
| 283 | (void)AttrUtils::GetBool(op_desc, ATTR_NAME_RTS_LABEL_NODE, rts_label_node); | 283 | (void)AttrUtils::GetBool(op_desc, ATTR_NAME_RTS_LABEL_NODE, rts_label_node); |
| 284 | - if ((node_type == "NetOutput") || rts_label_node) { | 284 | + if ((strcmp(node_type, "NetOutput") == 0) || rts_label_node) { |
| 285 | GELOGD("Skip special node: %s", dag_node->GetName().c_str()); | 285 | GELOGD("Skip special node: %s", dag_node->GetName().c_str()); |
| 286 | ++filtered_count; | 286 | ++filtered_count; |
| 287 | continue; | 287 | continue; |
| @@ -650,7 +650,46 @@ TEST_F(DAGAdapterGEIntegrationTest, RefreshStreamIdsToGE_NormalFlow) { | |||
| 650 | } | 650 | } |
| 651 | 651 | ||
| 652 | /** | 652 | /** |
| 653 | - * 场景 6-4: INVALID_STREAM_ID 节点跳过 | 653 | + * 场景 6-4: NetOutput 节点跳过刷新 |
| 654 | + * 验证:普通节点的 stream_id 被刷新,NetOutput 节点保持原始 stream_id | ||
| 655 | + */ | ||
| 656 | +TEST_F(DAGAdapterGEIntegrationTest, RefreshStreamIdsToGE_SkipNetOutput) { | ||
| 657 | + auto ge_graph = BuildGraphWithNodes(); | ||
| 658 | + ASSERT_NE(ge_graph, nullptr); | ||
| 659 | + | ||
| 660 | + auto add_gnode = ge_graph->FindNodeByName(AscendString("add1")); | ||
| 661 | + ASSERT_NE(add_gnode, nullptr); | ||
| 662 | + auto add_compute_node = NodeAdapter::GNode2Node(*add_gnode); | ||
| 663 | + ASSERT_NE(add_compute_node, nullptr); | ||
| 664 | + add_compute_node->GetOpDesc()->SetStreamId(0); | ||
| 665 | + | ||
| 666 | + auto netoutput_gnode = ge_graph->FindNodeByName(AscendString("NetOutput")); | ||
| 667 | + ASSERT_NE(netoutput_gnode, nullptr); | ||
| 668 | + auto netoutput_compute_node = NodeAdapter::GNode2Node(*netoutput_gnode); | ||
| 669 | + ASSERT_NE(netoutput_compute_node, nullptr); | ||
| 670 | + netoutput_compute_node->GetOpDesc()->SetStreamId(0); | ||
| 671 | + | ||
| 672 | + std::shared_ptr<minidag::DAGGraph> dag; | ||
| 673 | + auto ret = CallFromGEGraph(ge_graph, dag); | ||
| 674 | + ASSERT_EQ(ret, ge::GRAPH_SUCCESS); | ||
| 675 | + ASSERT_NE(dag, nullptr); | ||
| 676 | + | ||
| 677 | + auto dag_add_node = dag->FindNode("add1"); | ||
| 678 | + ASSERT_NE(dag_add_node, nullptr); | ||
| 679 | + dag_add_node->SetStreamId(1); | ||
| 680 | + auto dag_netoutput_node = dag->FindNode("NetOutput"); | ||
| 681 | + ASSERT_NE(dag_netoutput_node, nullptr); | ||
| 682 | + dag_netoutput_node->SetStreamId(1); | ||
| 683 | + | ||
| 684 | + ge::StreamPassContext context(10); | ||
| 685 | + ret = DAGAdapter::RefreshStreamIdsToGE(*dag, ge_graph, context); | ||
| 686 | + EXPECT_EQ(ret, ge::GRAPH_SUCCESS); | ||
| 687 | + EXPECT_EQ(add_compute_node->GetOpDesc()->GetStreamId(), 1); | ||
| 688 | + EXPECT_EQ(netoutput_compute_node->GetOpDesc()->GetStreamId(), 0); | ||
| 689 | +} | ||
| 690 | + | ||
| 691 | +/** | ||
| 692 | + * 场景 6-5: INVALID_STREAM_ID 节点跳过 | ||
| 654 | */ | 693 | */ |
| 655 | TEST_F(DAGAdapterGEIntegrationTest, RefreshStreamIdsToGE_InvalidStreamId) { | 694 | TEST_F(DAGAdapterGEIntegrationTest, RefreshStreamIdsToGE_InvalidStreamId) { |
| 656 | auto ge_graph = BuildGraphWithNodes(); | 695 | auto ge_graph = BuildGraphWithNodes(); |
| @@ -672,7 +711,7 @@ TEST_F(DAGAdapterGEIntegrationTest, RefreshStreamIdsToGE_InvalidStreamId) { | |||
| 672 | } | 711 | } |
| 673 | 712 | ||
| 674 | /** | 713 | /** |
| 675 | - * 场景 6-5: 节点不在 GE 图中时跳过 | 714 | + * 场景 6-6: 节点不在 GE 图中时跳过 |
| 676 | */ | 715 | */ |
| 677 | TEST_F(DAGAdapterGEIntegrationTest, RefreshStreamIdsToGE_NodeNotInGE) { | 716 | TEST_F(DAGAdapterGEIntegrationTest, RefreshStreamIdsToGE_NodeNotInGE) { |
| 678 | auto ge_graph = BuildGraphWithNodes(); | 717 | auto ge_graph = BuildGraphWithNodes(); |
| @@ -688,7 +727,7 @@ TEST_F(DAGAdapterGEIntegrationTest, RefreshStreamIdsToGE_NodeNotInGE) { | |||
| 688 | } | 727 | } |
| 689 | 728 | ||
| 690 | /** | 729 | /** |
| 691 | - * 场景 6-6: stream_id 超出范围时返回失败 | 730 | + * 场景 6-7: stream_id 超出范围时返回失败 |
| 692 | */ | 731 | */ |
| 693 | TEST_F(DAGAdapterGEIntegrationTest, RefreshStreamIdsToGE_StreamIdOutOfRange) { | 732 | TEST_F(DAGAdapterGEIntegrationTest, RefreshStreamIdsToGE_StreamIdOutOfRange) { |
| 694 | auto ge_graph = BuildGraphWithNodes(); | 733 | auto ge_graph = BuildGraphWithNodes(); |
| @@ -710,7 +749,7 @@ TEST_F(DAGAdapterGEIntegrationTest, RefreshStreamIdsToGE_StreamIdOutOfRange) { | |||
| 710 | } | 749 | } |
| 711 | 750 | ||
| 712 | /** | 751 | /** |
| 713 | - * 场景 6-7: GE 节点原始 stream_id 为 INVALID 时跳过刷新 | 752 | + * 场景 6-8: GE 节点原始 stream_id 为 INVALID 时跳过刷新 |
| 714 | * 验证:DAG 节点有有效 stream_id,但 GE 节点原始 stream_id 为 INVALID_STREAM_ID 时, | 753 | * 验证:DAG 节点有有效 stream_id,但 GE 节点原始 stream_id 为 INVALID_STREAM_ID 时, |
| 715 | * 该节点不会被刷新,函数返回成功 | 754 | * 该节点不会被刷新,函数返回成功 |
| 716 | */ | 755 | */ |