已合并
【PR】: tefusion支持pcie #4276
wuqianqian24创建于 8月5日
【PR】: tefusion支持pcie #4276
已合并
共 4 个文件变更+117-0
| @@ -1704,6 +1704,13 @@ void TeJsonAssemble::GenerateSocInfoJson(const std::vector<ConstTbeOpInfoPtr> &t | |||
| 1704 | firstOpInfo->GetName().c_str(), deterministicLevel.c_str()); | 1704 | firstOpInfo->GetName().c_str(), deterministicLevel.c_str()); |
| 1705 | socInfoJson["deterministic_level"] = deterministicLevel; | 1705 | socInfoJson["deterministic_level"] = deterministicLevel; |
| 1706 | } | 1706 | } |
| 1707 | + | ||
| 1708 | + bool pcieThroughFlag = false; | ||
| 1709 | + (void)ge::AttrUtils::GetBool(firstOpInfo->GetNode()->GetOpDesc(), kPcieThroughFlag, pcieThroughFlag); | ||
| 1710 | + if (pcieThroughFlag) { | ||
| 1711 | + TE_DBGLOG("Node[%s] _pcie_through attr is true, set it to options.", firstOpInfo->GetName().c_str()); | ||
| 1712 | + socInfoJson["pcie_through_flag"] = pcieThroughFlag; | ||
| 1713 | + } | ||
| 1707 | } | 1714 | } |
| 1708 | } | 1715 | } |
| 1709 | 1716 | ||
| @@ -2165,6 +2172,13 @@ void TeJsonAssemble::SetCustomCoreCountAndLevel(const ConstTbeOpInfoPtr &firstTb | |||
| 2165 | firstTbeOpInfo->GetName().c_str(), deterministicLevel.c_str()); | 2172 | firstTbeOpInfo->GetName().c_str(), deterministicLevel.c_str()); |
| 2166 | options["deterministic_level"] = deterministicLevel; | 2173 | options["deterministic_level"] = deterministicLevel; |
| 2167 | } | 2174 | } |
| 2175 | + | ||
| 2176 | + bool pcieThroughFlag = false; | ||
| 2177 | + (void)ge::AttrUtils::GetBool(firstTbeOpInfo->GetNode()->GetOpDesc(), kPcieThroughFlag, pcieThroughFlag); | ||
| 2178 | + if (pcieThroughFlag) { | ||
| 2179 | + TE_DBGLOG("Node[%s] _pcie_through attr is true, set it to options.", firstTbeOpInfo->GetName().c_str()); | ||
| 2180 | + options["pcie_through_flag"] = STR_TRUE; | ||
| 2181 | + } | ||
| 2168 | } | 2182 | } |
| 2169 | } // namespace fusion | 2183 | } // namespace fusion |
| 2170 | } // namespace te | 2184 | } // namespace te |
| @@ -106,6 +106,7 @@ constexpr const char *kAicCntKeyOp = "_op_aicore_num"; | |||
| 106 | constexpr const char *kAivCntKeyOp = "_op_vectorcore_num"; | 106 | constexpr const char *kAivCntKeyOp = "_op_vectorcore_num"; |
| 107 | constexpr const char *kDeterministic = "_deterministic"; | 107 | constexpr const char *kDeterministic = "_deterministic"; |
| 108 | constexpr const char *kDeterministicLevel = "_deterministic_level"; | 108 | constexpr const char *kDeterministicLevel = "_deterministic_level"; |
| 109 | +constexpr const char *kPcieThroughFlag = "_pcie_through_flag"; | ||
| 109 | 110 | ||
| 110 | // python api function name | 111 | // python api function name |
| 111 | const std::string FUNC_GET_SPECIFIC_INFO = "get_op_specific_info"; | 112 | const std::string FUNC_GET_SPECIFIC_INFO = "get_op_specific_info"; |
| @@ -471,6 +471,32 @@ TEST(TEST_TEFUSION_ST, GenerateSocInfoJson4) { | |||
| 471 | EXPECT_EQ(socInfoJson["coreNum"], "5"); | 471 | EXPECT_EQ(socInfoJson["coreNum"], "5"); |
| 472 | } | 472 | } |
| 473 | 473 | ||
| 474 | +TEST(TEST_TEFUSION_ST, GenerateSocInfoJsonPcieThrough) { | ||
| 475 | + OpDescPtr op = std::make_shared<ge::OpDesc>("TestOp", "TestOp"); | ||
| 476 | + ComputeGraphPtr graphPtr = std::make_shared<ComputeGraph>("test"); | ||
| 477 | + NodePtr node = graphPtr->AddNode(op); | ||
| 478 | + TbeOpInfoPtr opInfo = std::make_shared<TbeOpInfo>("TestOp", "", "TestOp", ""); | ||
| 479 | + map<std::string, std::string> options; | ||
| 480 | + | ||
| 481 | + options["ge.aicoreNum"] = "5"; | ||
| 482 | + opInfo->SetOptions(options); | ||
| 483 | + opInfo->SetNode(node); | ||
| 484 | + TbeOpInfoCache::Instance().UpdateTbeOpInfo("TestOp", opInfo); | ||
| 485 | + std::vector<ConstTbeOpInfoPtr> tbeOpInfoVec = {opInfo}; | ||
| 486 | + | ||
| 487 | + // 未设置 _pcie_through_flag,默认 false,socInfoJson 不应包含该字段 | ||
| 488 | + nlohmann::json socInfoJson; | ||
| 489 | + te::fusion::TeJsonAssemble::GenerateSocInfoJson(tbeOpInfoVec, socInfoJson); | ||
| 490 | + EXPECT_EQ(socInfoJson.contains("pcie_through_flag"), false); | ||
| 491 | + | ||
| 492 | + // 设置 _pcie_through_flag 为 true,socInfoJson 应包含该字段 | ||
| 493 | + ge::AttrUtils::SetBool(node->GetOpDesc(), "_pcie_through_flag", true); | ||
| 494 | + socInfoJson = nlohmann::json{}; | ||
| 495 | + te::fusion::TeJsonAssemble::GenerateSocInfoJson(tbeOpInfoVec, socInfoJson); | ||
| 496 | + EXPECT_EQ(socInfoJson.contains("pcie_through_flag"), true); | ||
| 497 | + EXPECT_EQ(socInfoJson["pcie_through_flag"], true); | ||
| 498 | +} | ||
| 499 | + | ||
| 474 | TEST(TEST_TEFUSION_ST, GenerateOptionsMap) { | 500 | TEST(TEST_TEFUSION_ST, GenerateOptionsMap) { |
| 475 | OpDescPtr op = std::make_shared<ge::OpDesc>("TestOp", "TestOp"); | 501 | OpDescPtr op = std::make_shared<ge::OpDesc>("TestOp", "TestOp"); |
| 476 | ComputeGraphPtr graphPtr = std::make_shared<ComputeGraph>("test"); | 502 | ComputeGraphPtr graphPtr = std::make_shared<ComputeGraph>("test"); |
| @@ -492,6 +518,31 @@ TEST(TEST_TEFUSION_ST, GenerateOptionsMap) { | |||
| 492 | EXPECT_EQ(options["coreNum"], "5"); | 518 | EXPECT_EQ(options["coreNum"], "5"); |
| 493 | } | 519 | } |
| 494 | 520 | ||
| 521 | +TEST(TEST_TEFUSION_ST, GenerateOptionsMapPcieThrough) { | ||
| 522 | + OpDescPtr op = std::make_shared<ge::OpDesc>("TestOp", "TestOp"); | ||
| 523 | + ComputeGraphPtr graphPtr = std::make_shared<ComputeGraph>("test"); | ||
| 524 | + NodePtr node = graphPtr->AddNode(op); | ||
| 525 | + TbeOpInfoPtr opInfo = std::make_shared<TbeOpInfo>("TestOp", "", "TestOp", ""); | ||
| 526 | + map<std::string, std::string> options; | ||
| 527 | + | ||
| 528 | + options["ge.aicoreNum"] = "5"; | ||
| 529 | + opInfo->SetOptions(options); | ||
| 530 | + opInfo->SetNode(node); | ||
| 531 | + TbeOpInfoCache::Instance().UpdateTbeOpInfo("TestOp", opInfo); | ||
| 532 | + std::vector<ConstTbeOpInfoPtr> tbeOpInfoVec = {opInfo}; | ||
| 533 | + | ||
| 534 | + // 未设置 _pcie_through_flag,默认 false,options 中不应包含 pcie_through_flag | ||
| 535 | + map<std::string, std::string> optionsWithoutFlag; | ||
| 536 | + te::fusion::TeJsonAssemble::GenerateOptionsMap(tbeOpInfoVec, optionsWithoutFlag); | ||
| 537 | + EXPECT_EQ(optionsWithoutFlag.count("pcie_through_flag"), 0); | ||
| 538 | + | ||
| 539 | + // 设置 _pcie_through_flag 为 true,options 中应包含 pcie_through_flag = "true" | ||
| 540 | + ge::AttrUtils::SetBool(node->GetOpDesc(), "_pcie_through_flag", true); | ||
| 541 | + map<std::string, std::string> optionsWithFlag; | ||
| 542 | + te::fusion::TeJsonAssemble::GenerateOptionsMap(tbeOpInfoVec, optionsWithFlag); | ||
| 543 | + EXPECT_EQ(optionsWithFlag["pcie_through_flag"], "true"); | ||
| 544 | +} | ||
| 545 | + | ||
| 495 | TEST(TEFUSION, GenNodeDataJson) { | 546 | TEST(TEFUSION, GenNodeDataJson) { |
| 496 | OpDescPtr op = std::make_shared<ge::OpDesc>("TestOp", "TestOp"); | 547 | OpDescPtr op = std::make_shared<ge::OpDesc>("TestOp", "TestOp"); |
| 497 | ComputeGraphPtr graphPtr = std::make_shared<ComputeGraph>("test"); | 548 | ComputeGraphPtr graphPtr = std::make_shared<ComputeGraph>("test"); |
| @@ -608,6 +608,32 @@ TEST(TeFusionUTest, GenerateSocInfoJson5) { | |||
| 608 | EXPECT_EQ(socInfoJson["coreNum"], "5"); | 608 | EXPECT_EQ(socInfoJson["coreNum"], "5"); |
| 609 | } | 609 | } |
| 610 | 610 | ||
| 611 | +TEST(TeFusionUTest, GenerateSocInfoJsonPcieThrough) { | ||
| 612 | + OpDescPtr op = std::make_shared<ge::OpDesc>("TestOp", "TestOp"); | ||
| 613 | + ComputeGraphPtr graphPtr = std::make_shared<ComputeGraph>("test"); | ||
| 614 | + NodePtr node = graphPtr->AddNode(op); | ||
| 615 | + TbeOpInfoPtr opInfo = std::make_shared<TbeOpInfo>("TestOp", "", "TestOp", ""); | ||
| 616 | + map<std::string, std::string> options; | ||
| 617 | + | ||
| 618 | + options["ge.aicoreNum"] = "5"; | ||
| 619 | + opInfo->SetOptions(options); | ||
| 620 | + opInfo->SetNode(node); | ||
| 621 | + TbeOpInfoCache::Instance().UpdateTbeOpInfo("TestOp", opInfo); | ||
| 622 | + std::vector<ConstTbeOpInfoPtr> tbeOpInfoVec = {opInfo}; | ||
| 623 | + | ||
| 624 | + // 未设置 _pcie_through_flag,默认 false,socInfoJson 不应包含该字段 | ||
| 625 | + nlohmann::json socInfoJson; | ||
| 626 | + te::fusion::TeJsonAssemble::GenerateSocInfoJson(tbeOpInfoVec, socInfoJson); | ||
| 627 | + EXPECT_EQ(socInfoJson.contains("pcie_through_flag"), false); | ||
| 628 | + | ||
| 629 | + // 设置 _pcie_through_flag 为 true,socInfoJson 应包含该字段 | ||
| 630 | + ge::AttrUtils::SetBool(node->GetOpDesc(), "_pcie_through_flag", true); | ||
| 631 | + socInfoJson = nlohmann::json{}; | ||
| 632 | + te::fusion::TeJsonAssemble::GenerateSocInfoJson(tbeOpInfoVec, socInfoJson); | ||
| 633 | + EXPECT_EQ(socInfoJson.contains("pcie_through_flag"), true); | ||
| 634 | + EXPECT_EQ(socInfoJson["pcie_through_flag"], true); | ||
| 635 | +} | ||
| 636 | + | ||
| 611 | TEST(TeFusionUTest, GenerateOptionsMap) { | 637 | TEST(TeFusionUTest, GenerateOptionsMap) { |
| 612 | OpDescPtr op = std::make_shared<ge::OpDesc>("TestOp", "TestOp"); | 638 | OpDescPtr op = std::make_shared<ge::OpDesc>("TestOp", "TestOp"); |
| 613 | ComputeGraphPtr graphPtr = std::make_shared<ComputeGraph>("test"); | 639 | ComputeGraphPtr graphPtr = std::make_shared<ComputeGraph>("test"); |
| @@ -629,6 +655,31 @@ TEST(TeFusionUTest, GenerateOptionsMap) { | |||
| 629 | EXPECT_EQ(options["coreNum"], "5"); | 655 | EXPECT_EQ(options["coreNum"], "5"); |
| 630 | } | 656 | } |
| 631 | 657 | ||
| 658 | +TEST(TeFusionUTest, GenerateOptionsMapPcieThrough) { | ||
| 659 | + OpDescPtr op = std::make_shared<ge::OpDesc>("TestOp", "TestOp"); | ||
| 660 | + ComputeGraphPtr graphPtr = std::make_shared<ComputeGraph>("test"); | ||
| 661 | + NodePtr node = graphPtr->AddNode(op); | ||
| 662 | + TbeOpInfoPtr opInfo = std::make_shared<TbeOpInfo>("TestOp", "", "TestOp", ""); | ||
| 663 | + map<std::string, std::string> options; | ||
| 664 | + | ||
| 665 | + options["ge.aicoreNum"] = "5"; | ||
| 666 | + opInfo->SetOptions(options); | ||
| 667 | + opInfo->SetNode(node); | ||
| 668 | + TbeOpInfoCache::Instance().UpdateTbeOpInfo("TestOp", opInfo); | ||
| 669 | + std::vector<ConstTbeOpInfoPtr> tbeOpInfoVec = {opInfo}; | ||
| 670 | + | ||
| 671 | + // 未设置 _pcie_through_flag,默认 false,options 中不应包含 pcie_through_flag | ||
| 672 | + map<std::string, std::string> optionsWithoutFlag; | ||
| 673 | + te::fusion::TeJsonAssemble::GenerateOptionsMap(tbeOpInfoVec, optionsWithoutFlag); | ||
| 674 | + EXPECT_EQ(optionsWithoutFlag.count("pcie_through_flag"), 0); | ||
| 675 | + | ||
| 676 | + // 设置 _pcie_through_flag 为 true,options 中应包含 pcie_through_flag = "true" | ||
| 677 | + ge::AttrUtils::SetBool(node->GetOpDesc(), "_pcie_through_flag", true); | ||
| 678 | + map<std::string, std::string> optionsWithFlag; | ||
| 679 | + te::fusion::TeJsonAssemble::GenerateOptionsMap(tbeOpInfoVec, optionsWithFlag); | ||
| 680 | + EXPECT_EQ(optionsWithFlag["pcie_through_flag"], "true"); | ||
| 681 | +} | ||
| 682 | + | ||
| 632 | TEST(TeFusionUTest, GenNodeDataJson) { | 683 | TEST(TeFusionUTest, GenNodeDataJson) { |
| 633 | OpDescPtr op = std::make_shared<ge::OpDesc>("TestOp", "TestOp"); | 684 | OpDescPtr op = std::make_shared<ge::OpDesc>("TestOp", "TestOp"); |
| 634 | ComputeGraphPtr graphPtr = std::make_shared<ComputeGraph>("test"); | 685 | ComputeGraphPtr graphPtr = std::make_shared<ComputeGraph>("test"); |