已合并
refactor: 将MemoryNoReuseScope和OpMemoryType改为枚举类 #4352
tangqunzhang创建于 8月12日
refactor: 将MemoryNoReuseScope和OpMemoryType改为枚举类 #4352
已合并
共 13 个文件变更+149-133
| @@ -205,8 +205,8 @@ Status AtomicMemoryAssigner::CollectAtomicNodeCleanMemInfos(const NodePtr &memse | |||
| 205 | for (const auto &in_ctl_anchor : all_peer_in_ctrl_anchors) { | 205 | for (const auto &in_ctl_anchor : all_peer_in_ctrl_anchors) { |
| 206 | const auto atomic_node = in_ctl_anchor->GetOwnerNode(); | 206 | const auto atomic_node = in_ctl_anchor->GetOwnerNode(); |
| 207 | GE_ASSERT_NOTNULL(atomic_node); | 207 | GE_ASSERT_NOTNULL(atomic_node); |
| 208 | - GE_ASSERT_NOTNULL(atomic_node->GetOpDescBarePtr()); | ||
| 209 | const auto atomic_op_desc = atomic_node->GetOpDescBarePtr(); | 208 | const auto atomic_op_desc = atomic_node->GetOpDescBarePtr(); |
| 209 | + GE_ASSERT_NOTNULL(atomic_op_desc); | ||
| 210 | bool is_atomic_node = false; | 210 | bool is_atomic_node = false; |
| 211 | // If GetBool fail, is_atomic_node is false. | 211 | // If GetBool fail, is_atomic_node is false. |
| 212 | (void)ge::AttrUtils::GetBool(atomic_op_desc, ATOMIC_ATTR_IS_ATOMIC_NODE, is_atomic_node); | 212 | (void)ge::AttrUtils::GetBool(atomic_op_desc, ATOMIC_ATTR_IS_ATOMIC_NODE, is_atomic_node); |
| @@ -539,12 +539,12 @@ Status AtomicMemoryAssigner::FilterAtomicNodes( | |||
| 539 | std::map<std::string, std::vector<NodePtr>> tmp_normal_atomic_nodes; | 539 | std::map<std::string, std::vector<NodePtr>> tmp_normal_atomic_nodes; |
| 540 | const auto &out_control_anchor = node->GetOutControlAnchor(); | 540 | const auto &out_control_anchor = node->GetOutControlAnchor(); |
| 541 | GE_CHECK_NOTNULL(out_control_anchor); | 541 | GE_CHECK_NOTNULL(out_control_anchor); |
| 542 | - for (const auto &peer_in_control_anchor : out_control_anchor->GetPeerInControlAnchors()) { | 542 | + for (const auto peer_in_control_anchor : out_control_anchor->GetPeerInControlAnchorsPtr()) { |
| 543 | GE_ASSERT_NOTNULL(peer_in_control_anchor); | 543 | GE_ASSERT_NOTNULL(peer_in_control_anchor); |
| 544 | auto peer_in_node = peer_in_control_anchor->GetOwnerNode(); | 544 | auto peer_in_node = peer_in_control_anchor->GetOwnerNode(); |
| 545 | GE_ASSERT_NOTNULL(peer_in_node); | 545 | GE_ASSERT_NOTNULL(peer_in_node); |
| 546 | - GE_ASSERT_NOTNULL(peer_in_node->GetOpDesc()); | 546 | + auto peer_in_node_desc = peer_in_node->GetOpDescBarePtr(); |
| 547 | - auto peer_in_node_desc = peer_in_node->GetOpDesc(); | 547 | + GE_ASSERT_NOTNULL(peer_in_node_desc); |
| 548 | bool is_atomic_node = false; | 548 | bool is_atomic_node = false; |
| 549 | // If GetBool fail, is_atomic_node is false. | 549 | // If GetBool fail, is_atomic_node is false. |
| 550 | (void)ge::AttrUtils::GetBool(peer_in_node_desc, ATOMIC_ATTR_IS_ATOMIC_NODE, is_atomic_node); | 550 | (void)ge::AttrUtils::GetBool(peer_in_node_desc, ATOMIC_ATTR_IS_ATOMIC_NODE, is_atomic_node); |
| @@ -559,8 +559,7 @@ Status AtomicMemoryAssigner::FilterAtomicNodes( | |||
| 559 | return ge::PARAM_INVALID; | 559 | return ge::PARAM_INVALID; |
| 560 | } | 560 | } |
| 561 | 561 | ||
| 562 | - std::string batch_label; | 562 | + const auto &batch_label = GetBatchLabel(peer_in_node_desc); |
| 563 | - (void)ge::AttrUtils::GetStr(peer_in_node_desc, ATTR_NAME_BATCH_LABEL, batch_label); | ||
| 564 | tmp_normal_atomic_nodes[batch_label].emplace_back(peer_in_node); | 563 | tmp_normal_atomic_nodes[batch_label].emplace_back(peer_in_node); |
| 565 | } | 564 | } |
| 566 | 565 | ||
| @@ -641,12 +640,12 @@ Status AtomicMemoryAssigner::AssignAtomicOutputAndWorkspaceMemory( | |||
| 641 | } | 640 | } |
| 642 | 641 | ||
| 643 | bool AtomicMemoryAssigner::CheckInputIsSupportAtomic(const ge::Node *node) { | 642 | bool AtomicMemoryAssigner::CheckInputIsSupportAtomic(const ge::Node *node) { |
| 644 | - for (auto &in_data_anchor : node->GetAllInDataAnchors()) { | 643 | + for (const auto in_data_anchor : node->GetAllInDataAnchorsPtr()) { |
| 645 | auto peer_out_data_anchor = in_data_anchor->GetPeerOutAnchor(); | 644 | auto peer_out_data_anchor = in_data_anchor->GetPeerOutAnchor(); |
| 646 | if (peer_out_data_anchor == nullptr) { | 645 | if (peer_out_data_anchor == nullptr) { |
| 647 | continue; | 646 | continue; |
| 648 | } | 647 | } |
| 649 | - auto peer_op_desc = peer_out_data_anchor->GetOwnerNode()->GetOpDesc(); | 648 | + auto peer_op_desc = peer_out_data_anchor->GetOwnerNodeBarePtr()->GetOpDescBarePtr(); |
| 650 | if (peer_op_desc == nullptr) { | 649 | if (peer_op_desc == nullptr) { |
| 651 | continue; | 650 | continue; |
| 652 | } | 651 | } |
| @@ -781,8 +780,7 @@ Status AtomicMemoryAssigner::AssignAtomicOutputMemory( | |||
| 781 | "graph_id:%u, graph_name:%s", | 780 | "graph_id:%u, graph_name:%s", |
| 782 | compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); | 781 | compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); |
| 783 | output_list[output_index] = iter->second.mem_offset_; | 782 | output_list[output_index] = iter->second.mem_offset_; |
| 784 | - std::string batch_label; | 783 | + const auto &batch_label = GetBatchLabel(op_desc.get()); |
| 785 | - (void)ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, batch_label); | ||
| 786 | iter->second.mem_offset_ += size; | 784 | iter->second.mem_offset_ += size; |
| 787 | AlignMemOffset(MEM_ALIGN_SIZE, memory_type); | 785 | AlignMemOffset(MEM_ALIGN_SIZE, memory_type); |
| 788 | mem_type_to_offset_end[memory_type].emplace_back(iter->second.mem_offset_); | 786 | mem_type_to_offset_end[memory_type].emplace_back(iter->second.mem_offset_); |
| @@ -846,8 +844,7 @@ Status AtomicMemoryAssigner::AssignOrdinaryAtomicWorkspaceMemory( | |||
| 846 | } | 844 | } |
| 847 | 845 | ||
| 848 | workspace_vector[workspace_index] = mem_type_iter->second.mem_offset_; | 846 | workspace_vector[workspace_index] = mem_type_iter->second.mem_offset_; |
| 849 | - std::string batch_label; | 847 | + const auto &batch_label = GetBatchLabel(op_desc.get()); |
| 850 | - (void)ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, batch_label); | ||
| 851 | size_t tmp_mem_offset = mem_type_iter->second.mem_offset_; | 848 | size_t tmp_mem_offset = mem_type_iter->second.mem_offset_; |
| 852 | mem_type_iter->second.mem_offset_ += workspace_size; | 849 | mem_type_iter->second.mem_offset_ += workspace_size; |
| 853 | AlignMemOffset(MEM_ALIGN_SIZE, RT_MEMORY_HBM); | 850 | AlignMemOffset(MEM_ALIGN_SIZE, RT_MEMORY_HBM); |
| @@ -899,8 +896,7 @@ Status AtomicMemoryAssigner::AssignFusionAtomicWorkspaceMemory( | |||
| 899 | auto workspace_size = info_iter.second; | 896 | auto workspace_size = info_iter.second; |
| 900 | 897 | ||
| 901 | size_t workspace_offset = mem_type_iter->second.mem_offset_; | 898 | size_t workspace_offset = mem_type_iter->second.mem_offset_; |
| 902 | - std::string batch_label; | 899 | + const auto &batch_label = GetBatchLabel(op_desc.get()); |
| 903 | - (void)ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL, batch_label); | ||
| 904 | GELOGI("[AtomicClean][IMAS]Atomic fusion workspace : Set %s name[%s] optype[%s] workspace[%" PRIu64 | 900 | GELOGI("[AtomicClean][IMAS]Atomic fusion workspace : Set %s name[%s] optype[%s] workspace[%" PRIu64 |
| 905 | "] offset to [%zu]" | 901 | "] offset to [%zu]" |
| 906 | " stream_id[%" PRId64 "] memtype[%u] ssize[%" PRId64 "] real_size[%" PRId64 "] batch[%s].", | 902 | " stream_id[%" PRId64 "] memtype[%u] ssize[%" PRId64 "] real_size[%" PRId64 "] batch[%s].", |
| @@ -1115,9 +1111,9 @@ Status AtomicMemoryAssigner::GetMemoryAssignmentStatus(const ge::NodePtr &node, | |||
| 1115 | } | 1111 | } |
| 1116 | auto out_data_anchor = node->GetAllOutDataAnchors().at(output_index); | 1112 | auto out_data_anchor = node->GetAllOutDataAnchors().at(output_index); |
| 1117 | GE_CHECK_NOTNULL(out_data_anchor); | 1113 | GE_CHECK_NOTNULL(out_data_anchor); |
| 1118 | - auto input_anchors = out_data_anchor->GetPeerInDataAnchors(); | 1114 | + const auto input_anchors = out_data_anchor->GetPeerInDataAnchorsPtr(); |
| 1119 | - for (auto &input_anchor : input_anchors) { | 1115 | + for (auto const input_anchor : input_anchors) { |
| 1120 | - auto output_node = input_anchor->GetOwnerNode(); | 1116 | + auto output_node = input_anchor->GetOwnerNodeBarePtr(); |
| 1121 | GE_CHECK_NOTNULL(output_node->GetOpDesc()); | 1117 | GE_CHECK_NOTNULL(output_node->GetOpDesc()); |
| 1122 | const auto continous_input = MemLayoutConflictUtil::IsContinuousInput(output_node); | 1118 | const auto continous_input = MemLayoutConflictUtil::IsContinuousInput(output_node); |
| 1123 | if (!continous_input) { | 1119 | if (!continous_input) { |
| @@ -1372,16 +1372,18 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(const NodePtr &n, const std::vector<b | |||
| 1372 | bool no_reuse = false; | 1372 | bool no_reuse = false; |
| 1373 | std::string symbol; | 1373 | std::string symbol; |
| 1374 | // model data output can't reuse other, but it can be reused | 1374 | // model data output can't reuse other, but it can be reused |
| 1375 | - const bool pre_reuse = | 1375 | + const bool pre_reuse = (param.mem_type == OpMemoryType::kOutput) |
| 1376 | - (param.mem_type == kOutput) ? IsPreReuse(NodeIndexIO(n.get(), param.out_index, kOut), symbol) : true; | 1376 | + ? IsPreReuse(NodeIndexIO(n.get(), param.out_index, kOut), symbol) |
| 1377 | + : true; | ||
| 1377 | const auto it_life_time_begin = cascade_min_life_time_.find(node_op_desc->GetNamePtr()); | 1378 | const auto it_life_time_begin = cascade_min_life_time_.find(node_op_desc->GetNamePtr()); |
| 1378 | (void)ge::AttrUtils::GetBool(node_op_desc, kOpNoReuseMem, no_reuse); | 1379 | (void)ge::AttrUtils::GetBool(node_op_desc, kOpNoReuseMem, no_reuse); |
| 1379 | - if ((!no_reuse) && (param.mem_type == kWorkspace)) { | 1380 | + if ((!no_reuse) && (param.mem_type == OpMemoryType::kWorkspace)) { |
| 1380 | no_reuse = ((workspace_reuse_flag.size() > param.out_index) && !workspace_reuse_flag[param.out_index]); | 1381 | no_reuse = ((workspace_reuse_flag.size() > param.out_index) && !workspace_reuse_flag[param.out_index]); |
| 1381 | } | 1382 | } |
| 1382 | - const bool mod_life_begin = ((param.mem_type != kWorkspace) && (it_life_time_begin != cascade_min_life_time_.end()) && | 1383 | + const bool mod_life_begin = |
| 1383 | - (it_life_time_begin->second < life_begin_)) || | 1384 | + ((param.mem_type != OpMemoryType::kWorkspace) && (it_life_time_begin != cascade_min_life_time_.end()) && |
| 1384 | - no_reuse || (!pre_reuse); | 1385 | + (it_life_time_begin->second < life_begin_)) || |
| 1386 | + no_reuse || (!pre_reuse); | ||
| 1385 | if (mod_life_begin) { | 1387 | if (mod_life_begin) { |
| 1386 | // no pre reuse set life time begin to 1 | 1388 | // no pre reuse set life time begin to 1 |
| 1387 | life_begin_ = ((!pre_reuse) || no_reuse) ? kMinLifeTime : it_life_time_begin->second; | 1389 | life_begin_ = ((!pre_reuse) || no_reuse) ? kMinLifeTime : it_life_time_begin->second; |
| @@ -1389,12 +1391,12 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(const NodePtr &n, const std::vector<b | |||
| 1389 | } | 1391 | } |
| 1390 | bool diff_stream_prior = false; | 1392 | bool diff_stream_prior = false; |
| 1391 | bool post_reuse_flag = IsPostReuse(symbol, diff_stream_prior); | 1393 | bool post_reuse_flag = IsPostReuse(symbol, diff_stream_prior); |
| 1392 | - if ((param.mem_type == kOutput) && (!post_reuse_flag)) { | 1394 | + if ((param.mem_type == OpMemoryType::kOutput) && (!post_reuse_flag)) { |
| 1393 | life_end_ = kMaxLifeTime; | 1395 | life_end_ = kMaxLifeTime; |
| 1394 | } | 1396 | } |
| 1395 | const auto has_diff_stream_same_out = | 1397 | const auto has_diff_stream_same_out = |
| 1396 | - (param.mem_type == kOutput) && HasSameOutAnchorWithDiffStream(n.get(), param.out_index); | 1398 | + (param.mem_type == OpMemoryType::kOutput) && HasSameOutAnchorWithDiffStream(n.get(), param.out_index); |
| 1397 | - is_reuse_memory = is_reuse_memory && is_ge_reuse_mem_ && (param.mem_type != kOutputDesc) && | 1399 | + is_reuse_memory = is_reuse_memory && is_ge_reuse_mem_ && (param.mem_type != OpMemoryType::kOutputDesc) && |
| 1398 | !node_op_desc->HasAttr(kL2FusionDynamicConvergeOp) && !no_reuse && param.is_op_reuse_mem; | 1400 | !node_op_desc->HasAttr(kL2FusionDynamicConvergeOp) && !no_reuse && param.is_op_reuse_mem; |
| 1399 | auto &reusable_blocks = reusable_blocks_[param.memory_type][stream_id]; | 1401 | auto &reusable_blocks = reusable_blocks_[param.memory_type][stream_id]; |
| 1400 | // continuous memory reuse in level2 reuse | 1402 | // continuous memory reuse in level2 reuse |
| @@ -1423,7 +1425,7 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(const NodePtr &n, const std::vector<b | |||
| 1423 | GELOGD("Node %s reuse block:%s", n->GetNamePtr(), GetName(*block).c_str()); | 1425 | GELOGD("Node %s reuse block:%s", n->GetNamePtr(), GetName(*block).c_str()); |
| 1424 | } | 1426 | } |
| 1425 | 1427 | ||
| 1426 | - if (param.mem_type == kOutput) { | 1428 | + if (param.mem_type == OpMemoryType::kOutput) { |
| 1427 | block->AddSymbol(symbol); | 1429 | block->AddSymbol(symbol); |
| 1428 | block->post_reuse_flag_ = block->post_reuse_flag_ && post_reuse_flag; | 1430 | block->post_reuse_flag_ = block->post_reuse_flag_ && post_reuse_flag; |
| 1429 | block->diff_stream_prior_ = diff_stream_prior; | 1431 | block->diff_stream_prior_ = diff_stream_prior; |
| @@ -1506,7 +1508,7 @@ void BlockMemAssigner::ContinuousOutRefCheck(bool &is_all_output_ref, bool &is_o | |||
| 1506 | is_all_output_ref = false; | 1508 | is_all_output_ref = false; |
| 1507 | break; | 1509 | break; |
| 1508 | } else { | 1510 | } else { |
| 1509 | - zero_memory_list_.emplace_back(n.get(), kOutput, index); | 1511 | + zero_memory_list_.emplace_back(n.get(), OpMemoryType::kOutput, index); |
| 1510 | is_output_has_ref = true; | 1512 | is_output_has_ref = true; |
| 1511 | } | 1513 | } |
| 1512 | } | 1514 | } |
| @@ -1546,7 +1548,7 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const std::vect | |||
| 1546 | for (uint32_t index = 0U; index < static_cast<uint32_t>(node_op_desc->GetOutputsSize()); index++) { | 1548 | for (uint32_t index = 0U; index < static_cast<uint32_t>(node_op_desc->GetOutputsSize()); index++) { |
| 1547 | auto output_op_desc = node_op_desc->MutableOutputDesc(index); | 1549 | auto output_op_desc = node_op_desc->MutableOutputDesc(index); |
| 1548 | if (CheckIsZeroMemNodeType(n->GetTypePtr()) || CheckIsZeroMemNodeOutputIndex(n, index)) { | 1550 | if (CheckIsZeroMemNodeType(n->GetTypePtr()) || CheckIsZeroMemNodeOutputIndex(n, index)) { |
| 1549 | - zero_memory_list_.emplace_back(n.get(), kOutput, index); | 1551 | + zero_memory_list_.emplace_back(n.get(), OpMemoryType::kOutput, index); |
| 1550 | continue; | 1552 | continue; |
| 1551 | } | 1553 | } |
| 1552 | 1554 | ||
| @@ -1562,7 +1564,7 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const std::vect | |||
| 1562 | 1564 | ||
| 1563 | // only apply total size in first output | 1565 | // only apply total size in first output |
| 1564 | if (index != 0U) { | 1566 | if (index != 0U) { |
| 1565 | - zero_memory_list_.emplace_back(n.get(), kOutput, index); | 1567 | + zero_memory_list_.emplace_back(n.get(), OpMemoryType::kOutput, index); |
| 1566 | continue; | 1568 | continue; |
| 1567 | } | 1569 | } |
| 1568 | NodeIndexIO node_index_io(n.get(), index, kOut); | 1570 | NodeIndexIO node_index_io(n.get(), index, kOut); |
| @@ -1583,8 +1585,8 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const std::vect | |||
| 1583 | 1585 | ||
| 1584 | auto block_size = GetBlockSize(total_size, ranges, reuse_strategy_.use_range_); | 1586 | auto block_size = GetBlockSize(total_size, ranges, reuse_strategy_.use_range_); |
| 1585 | std::vector<bool> workspace_reuse_flag; | 1587 | std::vector<bool> workspace_reuse_flag; |
| 1586 | - ApplyMemoryParam param = {block_size, total_size, total_size, kOutput, 0U, | 1588 | + ApplyMemoryParam param = {block_size, total_size, total_size, OpMemoryType::kOutput, 0U, is_op_reuse_mem, |
| 1587 | - is_op_reuse_mem, false, memory_type, false}; | 1589 | + false, memory_type, false}; |
| 1588 | block = ApplyMemory(n, workspace_reuse_flag, param); | 1590 | block = ApplyMemory(n, workspace_reuse_flag, param); |
| 1589 | if (block != nullptr) { | 1591 | if (block != nullptr) { |
| 1590 | // hccl task need align header and tail | 1592 | // hccl task need align header and tail |
| @@ -1632,7 +1634,7 @@ Status BlockMemAssigner::ApplyContinuousMemWithMng(const NodePtr &n, int32_t idx | |||
| 1632 | 1634 | ||
| 1633 | GE_ASSERT_TRUE(continuous_mem_mng_.IsFound(n.get(), idx)); | 1635 | GE_ASSERT_TRUE(continuous_mem_mng_.IsFound(n.get(), idx)); |
| 1634 | if (!continuous_mem_mng_.IsNeedAssignMemory(n.get(), idx)) { | 1636 | if (!continuous_mem_mng_.IsNeedAssignMemory(n.get(), idx)) { |
| 1635 | - zero_memory_list_.emplace_back(n.get(), kOutput, idx, false); | 1637 | + zero_memory_list_.emplace_back(n.get(), OpMemoryType::kOutput, idx, false); |
| 1636 | GELOGI("[ContinuousMem]node[%s] output %u, no need assign memory.", op_desc->GetNamePtr(), idx); | 1638 | GELOGI("[ContinuousMem]node[%s] output %u, no need assign memory.", op_desc->GetNamePtr(), idx); |
| 1637 | return SUCCESS; | 1639 | return SUCCESS; |
| 1638 | } | 1640 | } |
| @@ -1677,8 +1679,9 @@ Status BlockMemAssigner::ApplyContinuousMemWithMng(const NodePtr &n, int32_t idx | |||
| 1677 | const auto block_size = GetBlockSize(max_size, ranges, reuse_strategy_.use_range_); | 1679 | const auto block_size = GetBlockSize(max_size, ranges, reuse_strategy_.use_range_); |
| 1678 | std::vector<bool> workspace_reuse_flag; | 1680 | std::vector<bool> workspace_reuse_flag; |
| 1679 | const auto is_zeor_copy = IsZeroCopyBlock(n, idx, true, no_align_size); | 1681 | const auto is_zeor_copy = IsZeroCopyBlock(n, idx, true, no_align_size); |
| 1680 | - ApplyMemoryParam param = {block_size, max_size, no_align_size, kOutput, static_cast<uint32_t>(idx), | 1682 | + ApplyMemoryParam param = { |
| 1681 | - is_op_reuse_mem_, false, memory_type, is_zeor_copy}; | 1683 | + block_size, max_size, no_align_size, OpMemoryType::kOutput, static_cast<uint32_t>(idx), |
| 1684 | + is_op_reuse_mem_, false, memory_type, is_zeor_copy}; | ||
| 1682 | block = ApplyMemory(n, workspace_reuse_flag, param); | 1685 | block = ApplyMemory(n, workspace_reuse_flag, param); |
| 1683 | GE_ASSERT_NOTNULL(block); | 1686 | GE_ASSERT_NOTNULL(block); |
| 1684 | GE_ASSERT_SUCCESS(continuous_mem_mng_.PushBackBlock(n.get(), idx, block)); | 1687 | GE_ASSERT_SUCCESS(continuous_mem_mng_.PushBackBlock(n.get(), idx, block)); |
| @@ -1696,7 +1699,7 @@ Status BlockMemAssigner::ApplyContinuousMemWithMng(const NodePtr &n, int32_t idx | |||
| 1696 | block->is_fixed_addr_prior_ = (block->is_fixed_addr_prior_ || iter->second.is_fixed_addr_prior_); | 1699 | block->is_fixed_addr_prior_ = (block->is_fixed_addr_prior_ || iter->second.is_fixed_addr_prior_); |
| 1697 | } | 1700 | } |
| 1698 | MarkReuseZeroCopyBlockFlag(n, block, idx, is_feature_map_refreshable_); | 1701 | MarkReuseZeroCopyBlockFlag(n, block, idx, is_feature_map_refreshable_); |
| 1699 | - MarkZeroCopyBlockAttr(bool_attr_, op_desc, block->is_zero_copy_, kOutput, idx); | 1702 | + MarkZeroCopyBlockAttr(bool_attr_, op_desc, block->is_zero_copy_, OpMemoryType::kOutput, idx); |
| 1700 | GELOGI( | 1703 | GELOGI( |
| 1701 | "[ContinuousMem]Node name: %s index:%u size:%zu ref count: %d, zero copy:%d, fixed addr prior: %d, " | 1704 | "[ContinuousMem]Node name: %s index:%u size:%zu ref count: %d, zero copy:%d, fixed addr prior: %d, " |
| 1702 | "out_streams_cnt: %zu, memory_type: %d", | 1705 | "out_streams_cnt: %zu, memory_type: %d", |
| @@ -1951,9 +1954,9 @@ MemoryBlock *BlockMemAssigner::ApplyOutMemory(const NodePtr &n, uint32_t index, | |||
| 1951 | CalExitSymbolNodeLifeTime(node_index_io.node_ptr_, node_index_io.index_, symbol_life_time); | 1954 | CalExitSymbolNodeLifeTime(node_index_io.node_ptr_, node_index_io.index_, symbol_life_time); |
| 1952 | block->SetSymbolLifeEnd(symbol_life_time); | 1955 | block->SetSymbolLifeEnd(symbol_life_time); |
| 1953 | block->SetLifeTimeEnd(life_time_, block->stream_id_); | 1956 | block->SetLifeTimeEnd(life_time_, block->stream_id_); |
| 1954 | - block->AddNodeTypeIndex( | 1957 | + block->AddNodeTypeIndex({n.get(), OpMemoryType::kOutput, index, true, life_begin_, GetStreamId(node_op_desc), false, |
| 1955 | - {n.get(), kOutput, index, true, life_begin_, GetStreamId(node_op_desc), false, block->GetSymbolLifeEnd()}, size, | 1958 | + block->GetSymbolLifeEnd()}, |
| 1956 | - no_align_size, block->stream_id_); | 1959 | + size, no_align_size, block->stream_id_); |
| 1957 | block->has_sub_graph_in_out_node_ = block->has_sub_graph_in_out_node_ || | 1960 | block->has_sub_graph_in_out_node_ = block->has_sub_graph_in_out_node_ || |
| 1958 | MemReuseUtils::PeerIsSubGraphNetOutNode(n, out_data_anchor, compute_graph_) || | 1961 | MemReuseUtils::PeerIsSubGraphNetOutNode(n, out_data_anchor, compute_graph_) || |
| 1959 | MemReuseUtils::IsSubGraphInOrOutNode(n.get(), compute_graph_); | 1962 | MemReuseUtils::IsSubGraphInOrOutNode(n.get(), compute_graph_); |
| @@ -1968,7 +1971,7 @@ MemoryBlock *BlockMemAssigner::ApplyOutMemory(const NodePtr &n, uint32_t index, | |||
| 1968 | // after unfolding dynamic shape graph, const or variable may be in root graph and cannot be ref. | 1971 | // after unfolding dynamic shape graph, const or variable may be in root graph and cannot be ref. |
| 1969 | if (IsOutputIndexRef(node_op_desc, index) || | 1972 | if (IsOutputIndexRef(node_op_desc, index) || |
| 1970 | (IsSubgraphDataRefConstInput(n) && (!MemReuseUtils::IsDirectInputNode(n.get(), compute_graph_)))) { | 1973 | (IsSubgraphDataRefConstInput(n) && (!MemReuseUtils::IsDirectInputNode(n.get(), compute_graph_)))) { |
| 1971 | - zero_memory_list_.emplace_back(n.get(), kOutput, index, false); | 1974 | + zero_memory_list_.emplace_back(n.get(), OpMemoryType::kOutput, index, false); |
| 1972 | GELOGI("ref mode skip out block assign. node_name: %s, index:%d", n->GetNamePtr(), index); | 1975 | GELOGI("ref mode skip out block assign. node_name: %s, index:%d", n->GetNamePtr(), index); |
| 1973 | return nullptr; | 1976 | return nullptr; |
| 1974 | } | 1977 | } |
| @@ -1994,8 +1997,9 @@ MemoryBlock *BlockMemAssigner::ApplyOutMemory(const NodePtr &n, uint32_t index, | |||
| 1994 | std::vector<bool> workspace_reuse_flag; | 1997 | std::vector<bool> workspace_reuse_flag; |
| 1995 | bool as_input_continuous = is_separate_clean_continuous_inputs_ ? false : out_node_need_continuous_input; | 1998 | bool as_input_continuous = is_separate_clean_continuous_inputs_ ? false : out_node_need_continuous_input; |
| 1996 | bool is_zeor_copy = IsZeroCopyBlock(n, index, out_node_need_continuous_input, no_align_size); | 1999 | bool is_zeor_copy = IsZeroCopyBlock(n, index, out_node_need_continuous_input, no_align_size); |
| 1997 | - ApplyMemoryParam param = {block_size, max_size, no_align_size, kOutput, index, is_op_reuse_mem, | 2000 | + ApplyMemoryParam param = {block_size, max_size, no_align_size, OpMemoryType::kOutput, |
| 1998 | - as_input_continuous, memory_type, is_zeor_copy}; | 2001 | + index, is_op_reuse_mem, as_input_continuous, memory_type, |
| 2002 | + is_zeor_copy}; | ||
| 1999 | block = ApplyMemory(n, workspace_reuse_flag, param); | 2003 | block = ApplyMemory(n, workspace_reuse_flag, param); |
| 2000 | GE_CHECK_NOTNULL_EXEC(block, return nullptr); | 2004 | GE_CHECK_NOTNULL_EXEC(block, return nullptr); |
| 2001 | block->need_same_offset_in_batch_ = SizeIndependentOfBatch(n->GetTypePtr()); | 2005 | block->need_same_offset_in_batch_ = SizeIndependentOfBatch(n->GetTypePtr()); |
| @@ -2027,7 +2031,7 @@ MemoryBlock *BlockMemAssigner::ApplyOutMemory(const NodePtr &n, uint32_t index, | |||
| 2027 | } | 2031 | } |
| 2028 | 2032 | ||
| 2029 | MarkReuseZeroCopyBlockFlag(n, block, index, is_feature_map_refreshable_); | 2033 | MarkReuseZeroCopyBlockFlag(n, block, index, is_feature_map_refreshable_); |
| 2030 | - MarkZeroCopyBlockAttr(bool_attr_, node_op_desc, block->is_zero_copy_, kOutput, index); | 2034 | + MarkZeroCopyBlockAttr(bool_attr_, node_op_desc, block->is_zero_copy_, OpMemoryType::kOutput, index); |
| 2031 | GELOGI("Node name: %s index:%u size:%zu ref count: %d, out count: %d zero copy:%d, out node need continuous input %d", | 2035 | GELOGI("Node name: %s index:%u size:%zu ref count: %d, out count: %d zero copy:%d, out node need continuous input %d", |
| 2032 | n->GetNamePtr(), index, block_size, block->ref_count_, out_count, block->is_zero_copy_, | 2036 | n->GetNamePtr(), index, block_size, block->ref_count_, out_count, block->is_zero_copy_, |
| 2033 | out_node_need_continuous_input); | 2037 | out_node_need_continuous_input); |
| @@ -2051,10 +2055,12 @@ MemoryBlock *BlockMemAssigner::ApplyOutDescMemory(const NodePtr &n, uint32_t ind | |||
| 2051 | GELOGE(FAILED, "[Get][RefBlock]node_name:%s, symbol:%s", n->GetNamePtr(), node_index_io.ToString().c_str()); | 2055 | GELOGE(FAILED, "[Get][RefBlock]node_name:%s, symbol:%s", n->GetNamePtr(), node_index_io.ToString().c_str()); |
| 2052 | return nullptr); | 2056 | return nullptr); |
| 2053 | 2057 | ||
| 2054 | - block->AddNodeTypeIndex({n.get(), kOutputDesc, index, true, 0}, size, size, GetStreamId(n->GetOpDescBarePtr())); | 2058 | + block->AddNodeTypeIndex({n.get(), OpMemoryType::kOutputDesc, index, true, 0}, size, size, |
| 2059 | + GetStreamId(n->GetOpDescBarePtr())); | ||
| 2055 | GELOGD("Ref tensor desc, symbol[%s], anchor[%s].", symbol.c_str(), node_index_io.ToString().c_str()); | 2060 | GELOGD("Ref tensor desc, symbol[%s], anchor[%s].", symbol.c_str(), node_index_io.ToString().c_str()); |
| 2056 | } else { | 2061 | } else { |
| 2057 | - ApplyMemoryParam param = {block_size, size, size, kOutputDesc, index, false, false, RT_MEMORY_HBM, false}; | 2062 | + ApplyMemoryParam param = {block_size, size, size, OpMemoryType::kOutputDesc, index, false, |
| 2063 | + false, RT_MEMORY_HBM, false}; | ||
| 2058 | block = ApplyMemory(n, workspace_reuse_flag, param); | 2064 | block = ApplyMemory(n, workspace_reuse_flag, param); |
| 2059 | if (block == nullptr) { | 2065 | if (block == nullptr) { |
| 2060 | REPORT_INNER_ERR_MSG("E19999", "apply out desc Memory failed, node_name:%s, block_size:%" PRId64 ", out_index:%u", | 2066 | REPORT_INNER_ERR_MSG("E19999", "apply out desc Memory failed, node_name:%s, block_size:%" PRId64 ", out_index:%u", |
| @@ -2133,8 +2139,8 @@ void BlockMemAssigner::ReleaseMemory(MemoryBlock *const to_release, std::vector< | |||
| 2133 | } | 2139 | } |
| 2134 | int64_t max_life_time = life_time_; | 2140 | int64_t max_life_time = life_time_; |
| 2135 | if (!to_release->used_by_diff_streams_) { | 2141 | if (!to_release->used_by_diff_streams_) { |
| 2136 | - to_release->used_by_diff_streams_ = | 2142 | + to_release->used_by_diff_streams_ = (to_release->stream_id_ != stream_id) && |
| 2137 | - (to_release->stream_id_ != stream_id) && (to_release->NodeTypeIndexList().back().mem_type_ != kWorkspace); | 2143 | + (to_release->NodeTypeIndexList().back().mem_type_ != OpMemoryType::kWorkspace); |
| 2138 | } | 2144 | } |
| 2139 | 2145 | ||
| 2140 | int64_t max_node_life_time_by_symbol = life_time_; | 2146 | int64_t max_node_life_time_by_symbol = life_time_; |
| @@ -2202,7 +2208,7 @@ void BlockMemAssigner::ReleaseMemorys(StreamIdToBlocks &to_releases, StreamIdToB | |||
| 2202 | for (auto mem_block : stream_blocks.second) { | 2208 | for (auto mem_block : stream_blocks.second) { |
| 2203 | if (mem_block != nullptr) { // mem_block 不可能为空 | 2209 | if (mem_block != nullptr) { // mem_block 不可能为空 |
| 2204 | const bool output = (!mem_block->NodeTypeIndexList().empty()) && | 2210 | const bool output = (!mem_block->NodeTypeIndexList().empty()) && |
| 2205 | - (mem_block->NodeTypeIndexList().back().mem_type_ == kOutput) && | 2211 | + (mem_block->NodeTypeIndexList().back().mem_type_ == OpMemoryType::kOutput) && |
| 2206 | (!mem_block->SymbolList().empty()); | 2212 | (!mem_block->SymbolList().empty()); |
| 2207 | ReleaseMemory(mem_block, reusable_memory[stream_blocks.first], mem_block->stream_id_, | 2213 | ReleaseMemory(mem_block, reusable_memory[stream_blocks.first], mem_block->stream_id_, |
| 2208 | output ? mem_block->SymbolList().back() : "", false); | 2214 | output ? mem_block->SymbolList().back() : "", false); |
| @@ -2358,7 +2364,7 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, std::v | |||
| 2358 | IsNoNeedAssignMemory(node, node_index_io, i)); | 2364 | IsNoNeedAssignMemory(node, node_index_io, i)); |
| 2359 | } | 2365 | } |
| 2360 | if (no_need_assign_memory) { | 2366 | if (no_need_assign_memory) { |
| 2361 | - zero_memory_list_.emplace_back(node.get(), kOutput, i, false); | 2367 | + zero_memory_list_.emplace_back(node.get(), OpMemoryType::kOutput, i, false); |
| 2362 | GELOGI("node[%s] output %u, no need assign memory.", op_desc->GetNamePtr(), i); | 2368 | GELOGI("node[%s] output %u, no need assign memory.", op_desc->GetNamePtr(), i); |
| 2363 | continue; | 2369 | continue; |
| 2364 | } | 2370 | } |
| @@ -2459,12 +2465,13 @@ Status BlockMemAssigner::AssignWorkSpaceMemoryWithReuse(const NodePtr &node, std | |||
| 2459 | } | 2465 | } |
| 2460 | if (temp[i] == 0 || workspace_skip_flag || | 2466 | if (temp[i] == 0 || workspace_skip_flag || |
| 2461 | (!need_gentask_atomic && MemReuseUtils::IsAtomicWorkSpace(static_cast<int64_t>(i), atomic_workspace_info))) { | 2467 | (!need_gentask_atomic && MemReuseUtils::IsAtomicWorkSpace(static_cast<int64_t>(i), atomic_workspace_info))) { |
| 2462 | - zero_memory_list_.emplace_back(node.get(), kWorkspace, static_cast<uint32_t>(i), false); | 2468 | + zero_memory_list_.emplace_back(node.get(), OpMemoryType::kWorkspace, static_cast<uint32_t>(i), false); |
| 2463 | continue; | 2469 | continue; |
| 2464 | } | 2470 | } |
| 2465 | 2471 | ||
| 2466 | - const bool session_scope_memory = (has_workspace_no_reuse_scope) && (i < workspace_no_reuse_scope.size()) && | 2472 | + const bool session_scope_memory = |
| 2467 | - (workspace_no_reuse_scope[i] == kSessionNoReuse); | 2473 | + (has_workspace_no_reuse_scope) && (i < workspace_no_reuse_scope.size()) && |
| 2474 | + (static_cast<MemoryNoReuseScope>(workspace_no_reuse_scope[i]) == MemoryNoReuseScope::kSessionNoReuse); | ||
| 2468 | const bool is_p2p_memory = | 2475 | const bool is_p2p_memory = |
| 2469 | (has_workspace_type_list_attr) && (static_cast<uint64_t>(workspace_type_list[i]) == RT_MEMORY_P2P_DDR); | 2476 | (has_workspace_type_list_attr) && (static_cast<uint64_t>(workspace_type_list[i]) == RT_MEMORY_P2P_DDR); |
| 2470 | uint64_t memory_type = GetWorkSpaceMemoryType(workspace_no_reuse_scope.size(), i, is_p2p_memory, | 2477 | uint64_t memory_type = GetWorkSpaceMemoryType(workspace_no_reuse_scope.size(), i, is_p2p_memory, |
| @@ -2473,7 +2480,7 @@ Status BlockMemAssigner::AssignWorkSpaceMemoryWithReuse(const NodePtr &node, std | |||
| 2473 | ApplyMemoryParam param = {GetBlockSize(static_cast<size_t>(temp[i]), ranges, reuse_strategy_.use_range_), | 2480 | ApplyMemoryParam param = {GetBlockSize(static_cast<size_t>(temp[i]), ranges, reuse_strategy_.use_range_), |
| 2474 | static_cast<size_t>(temp[i]), | 2481 | static_cast<size_t>(temp[i]), |
| 2475 | static_cast<size_t>(temp[i]), | 2482 | static_cast<size_t>(temp[i]), |
| 2476 | - kWorkspace, | 2483 | + OpMemoryType::kWorkspace, |
| 2477 | static_cast<uint32_t>(i), | 2484 | static_cast<uint32_t>(i), |
| 2478 | is_op_reuse_mem_, | 2485 | is_op_reuse_mem_, |
| 2479 | false, | 2486 | false, |
| @@ -2853,7 +2860,7 @@ void BlockMemAssigner::SetOffsetSize(const NodeTypeIndex &node_type, const Memor | |||
| 2853 | std::vector<int64_t> memorys_type; | 2860 | std::vector<int64_t> memorys_type; |
| 2854 | int64_t offset = block.HeadOffset(); | 2861 | int64_t offset = block.HeadOffset(); |
| 2855 | bool has_mem_type_attr = ge::AttrUtils::GetListInt(op_desc, ATTR_NAME_OUTPUT_MEM_TYPE_LIST, memorys_type); | 2862 | bool has_mem_type_attr = ge::AttrUtils::GetListInt(op_desc, ATTR_NAME_OUTPUT_MEM_TYPE_LIST, memorys_type); |
| 2856 | - if (node_type.mem_type_ == kOutput) { | 2863 | + if (node_type.mem_type_ == OpMemoryType::kOutput) { |
| 2857 | std::vector<int64_t> output_list = op_desc->GetOutputOffset(); | 2864 | std::vector<int64_t> output_list = op_desc->GetOutputOffset(); |
| 2858 | for (auto i = static_cast<uint32_t>(output_list.size()); i < node_type.index_ + 1; i++) { | 2865 | for (auto i = static_cast<uint32_t>(output_list.size()); i < node_type.index_ + 1; i++) { |
| 2859 | output_list.emplace_back(kInvalidOffset); | 2866 | output_list.emplace_back(kInvalidOffset); |
| @@ -2878,7 +2885,7 @@ void BlockMemAssigner::SetOffsetSize(const NodeTypeIndex &node_type, const Memor | |||
| 2878 | } | 2885 | } |
| 2879 | } | 2886 | } |
| 2880 | op_desc->SetOutputOffset(output_list); | 2887 | op_desc->SetOutputOffset(output_list); |
| 2881 | - } else if ((node_type.mem_type_ == kWorkspace) && (!node_type.is_subgraph_workspace_)) { | 2888 | + } else if ((node_type.mem_type_ == OpMemoryType::kWorkspace) && (!node_type.is_subgraph_workspace_)) { |
| 2882 | std::vector<int64_t> workspace_list; | 2889 | std::vector<int64_t> workspace_list; |
| 2883 | workspace_list = op_desc->GetWorkspace(); | 2890 | workspace_list = op_desc->GetWorkspace(); |
| 2884 | for (auto i = static_cast<uint32_t>(workspace_list.size()); i < node_type.index_ + 1; i++) { | 2891 | for (auto i = static_cast<uint32_t>(workspace_list.size()); i < node_type.index_ + 1; i++) { |
| @@ -2894,7 +2901,7 @@ void BlockMemAssigner::SetOffsetSize(const NodeTypeIndex &node_type, const Memor | |||
| 2894 | workspace_list.at(node_type.index_) = offset; | 2901 | workspace_list.at(node_type.index_) = offset; |
| 2895 | } | 2902 | } |
| 2896 | op_desc->SetWorkspace(workspace_list); | 2903 | op_desc->SetWorkspace(workspace_list); |
| 2897 | - } else if (node_type.mem_type_ == kOutputDesc) { | 2904 | + } else if (node_type.mem_type_ == OpMemoryType::kOutputDesc) { |
| 2898 | auto tensor = op_desc->MutableOutputDesc(node_type.index_); | 2905 | auto tensor = op_desc->MutableOutputDesc(node_type.index_); |
| 2899 | GE_IF_BOOL_EXEC(tensor != nullptr, (void)AttrUtils::SetInt(tensor, ATTR_NAME_TENSOR_DESC_MEM_OFFSET, offset)); | 2906 | GE_IF_BOOL_EXEC(tensor != nullptr, (void)AttrUtils::SetInt(tensor, ATTR_NAME_TENSOR_DESC_MEM_OFFSET, offset)); |
| 2900 | } | 2907 | } |
| @@ -3025,7 +3032,7 @@ void BlockMemAssigner::SetOffsetForContinuousMem() const { | |||
| 3025 | MemReuseUtils::GetGraphNameId(compute_graph_.get()).c_str(), | 3032 | MemReuseUtils::GetGraphNameId(compute_graph_.get()).c_str(), |
| 3026 | op_desc->GetName().substr(0, kMaxLogLen).c_str(), op_desc->GetType().c_str(), node_index.index_, offset, | 3033 | op_desc->GetName().substr(0, kMaxLogLen).c_str(), op_desc->GetType().c_str(), node_index.index_, offset, |
| 3027 | op_desc->GetStreamId(), block->memory_type_, 0UL, align_size, false, | 3034 | op_desc->GetStreamId(), block->memory_type_, 0UL, align_size, false, |
| 3028 | - NodeMemAttrUtils::GetAttrStr({node_index.node_ptr_, kOutput, node_index.index_}).c_str()); | 3035 | + NodeMemAttrUtils::GetAttrStr({node_index.node_ptr_, OpMemoryType::kOutput, node_index.index_}).c_str()); |
| 3029 | offset += align_size; | 3036 | offset += align_size; |
| 3030 | } | 3037 | } |
| 3031 | } | 3038 | } |
| @@ -109,8 +109,8 @@ size_t GetOutputFlowToNetoutputNum(const ge::NodePtr &node, uint32_t output_inde | |||
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | void MarkZeroCopyBlockAttr(std::vector<TAttr<bool>> &bool_attr, const OpDesc *const op_desc, bool is_zero_copy, | 111 | void MarkZeroCopyBlockAttr(std::vector<TAttr<bool>> &bool_attr, const OpDesc *const op_desc, bool is_zero_copy, |
| 112 | - bool mem_type, uint32_t out_index) { | 112 | + OpMemoryType mem_type, uint32_t out_index) { |
| 113 | - if (is_zero_copy && (mem_type == kOutput)) { | 113 | + if (is_zero_copy && (mem_type == OpMemoryType::kOutput)) { |
| 114 | auto output_desc = op_desc->MutableOutputDesc(out_index); | 114 | auto output_desc = op_desc->MutableOutputDesc(out_index); |
| 115 | if (output_desc != nullptr) { | 115 | if (output_desc != nullptr) { |
| 116 | bool_attr.emplace_back(output_desc.get(), op_desc, out_index, ATTR_IS_ZERO_COPY_BLOCK, true); | 116 | bool_attr.emplace_back(output_desc.get(), op_desc, out_index, ATTR_IS_ZERO_COPY_BLOCK, true); |
| @@ -29,7 +29,7 @@ bool IsOutputBlock(const ge::InDataAnchor *const in_data_anchor); | |||
| 29 | bool IsKnownSubgraphData(const ge::Node *node); | 29 | bool IsKnownSubgraphData(const ge::Node *node); |
| 30 | void SetReleaseBlockLifeEnd(ge::MemoryBlock *to_release, int64_t stream_id); | 30 | void SetReleaseBlockLifeEnd(ge::MemoryBlock *to_release, int64_t stream_id); |
| 31 | void MarkZeroCopyBlockAttr(std::vector<TAttr<bool>> &bool_attr, const ge::OpDesc *const op_desc, bool is_zero_copy, | 31 | void MarkZeroCopyBlockAttr(std::vector<TAttr<bool>> &bool_attr, const ge::OpDesc *const op_desc, bool is_zero_copy, |
| 32 | - bool mem_type, uint32_t out_index); | 32 | + OpMemoryType mem_type, uint32_t out_index); |
| 33 | void MarkReuseZeroCopyBlockFlag(const NodePtr &n, MemoryBlock *const block, const uint32_t index, | 33 | void MarkReuseZeroCopyBlockFlag(const NodePtr &n, MemoryBlock *const block, const uint32_t index, |
| 34 | bool is_feature_map_refreshable); | 34 | bool is_feature_map_refreshable); |
| 35 | bool IsNodeAndPeerNodeTaskSupportZeroCopy(const ge::NodePtr &node, uint32_t output_index, | 35 | bool IsNodeAndPeerNodeTaskSupportZeroCopy(const ge::NodePtr &node, uint32_t output_index, |
| @@ -123,7 +123,7 @@ NodeMemAttrVector NodeMemAttrUtils::GetNodeMemAttrs(const NodeTypeIndex &node_ty | |||
| 123 | attrs.emplace_back(NodeMemAttr::kData); | 123 | attrs.emplace_back(NodeMemAttr::kData); |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | - if ((node_type_index.mem_type_ == kOutput) && | 126 | + if ((node_type_index.mem_type_ == OpMemoryType::kOutput) && |
| 127 | IsConcentrateAtomic(node_type_index.node_, static_cast<int32_t>(node_type_index.index_))) { | 127 | IsConcentrateAtomic(node_type_index.node_, static_cast<int32_t>(node_type_index.index_))) { |
| 128 | attrs.emplace_back(NodeMemAttr::kConcentrateAtomic); | 128 | attrs.emplace_back(NodeMemAttr::kConcentrateAtomic); |
| 129 | } | 129 | } |
| @@ -132,7 +132,7 @@ Status GetWorkspaceCleanAddrs(const Node *const node, AtomicNodeCleanTypeVals &t | |||
| 132 | if (has_workspace_type_list_attr && (index < workspace_type_list.size())) { | 132 | if (has_workspace_type_list_attr && (index < workspace_type_list.size())) { |
| 133 | mem_info.memory_type = workspace_type_list.at(index) == RT_MEMORY_P2P_DDR ? RT_MEMORY_P2P_DDR : RT_MEMORY_HBM; | 133 | mem_info.memory_type = workspace_type_list.at(index) == RT_MEMORY_P2P_DDR ? RT_MEMORY_P2P_DDR : RT_MEMORY_HBM; |
| 134 | } | 134 | } |
| 135 | - clean_addrs.emplace_back(CleanAddrSizeType{kWorkspace, static_cast<int64_t>(index), mem_info}); | 135 | + clean_addrs.emplace_back(CleanAddrSizeType{OpMemoryType::kWorkspace, static_cast<int64_t>(index), mem_info}); |
| 136 | } | 136 | } |
| 137 | } | 137 | } |
| 138 | return SUCCESS; | 138 | return SUCCESS; |
| @@ -317,7 +317,7 @@ Status AtomicCleanChecker::GetInputCleanAddrs(const Node *const node, | |||
| 317 | GE_ASSERT_SUCCESS(NodeCheckerUtils::GetInputSize(node, index, clean_mem.size)); | 317 | GE_ASSERT_SUCCESS(NodeCheckerUtils::GetInputSize(node, index, clean_mem.size)); |
| 318 | GE_ASSERT_SUCCESS(GetMemType(node, kIn, index, clean_mem.memory_type), | 318 | GE_ASSERT_SUCCESS(GetMemType(node, kIn, index, clean_mem.memory_type), |
| 319 | "node %s get output memory type failed, index: %lld", node->GetNamePtr(), index); | 319 | "node %s get output memory type failed, index: %lld", node->GetNamePtr(), index); |
| 320 | - clean_addrs.emplace_back(CleanAddrSizeType{kInput, index, clean_mem}); | 320 | + clean_addrs.emplace_back(CleanAddrSizeType{OpMemoryType::kInput, index, clean_mem}); |
| 321 | } | 321 | } |
| 322 | return SUCCESS; | 322 | return SUCCESS; |
| 323 | } | 323 | } |
| @@ -342,7 +342,7 @@ Status AtomicCleanChecker::GetOutputCleanAddrs(const Node *const node, AtomicNod | |||
| 342 | GE_ASSERT_SUCCESS(GetMemType(node, kOut, index, mem_info.memory_type), | 342 | GE_ASSERT_SUCCESS(GetMemType(node, kOut, index, mem_info.memory_type), |
| 343 | "node %s get input memory type failed, index: %lld", node->GetNamePtr(), index); | 343 | "node %s get input memory type failed, index: %lld", node->GetNamePtr(), index); |
| 344 | GE_ASSERT_SUCCESS(type_vals.GetNextAttr(mem_info.type_val), "get next attr failed"); | 344 | GE_ASSERT_SUCCESS(type_vals.GetNextAttr(mem_info.type_val), "get next attr failed"); |
| 345 | - clean_addrs.emplace_back(CleanAddrSizeType{kOutput, index, mem_info}); | 345 | + clean_addrs.emplace_back(CleanAddrSizeType{OpMemoryType::kOutput, index, mem_info}); |
| 346 | } | 346 | } |
| 347 | return SUCCESS; | 347 | return SUCCESS; |
| 348 | } | 348 | } |
| @@ -155,8 +155,9 @@ MemoryBlock *DynamicBatchMemAssigner::CreateContinuousBlock(std::vector<MemoryBl | |||
| 155 | continuous_block->stream_id_ = parent_node_stream_id; | 155 | continuous_block->stream_id_ = parent_node_stream_id; |
| 156 | continuous_block->batch_label_ = batch_label; | 156 | continuous_block->batch_label_ = batch_label; |
| 157 | continuous_block->memory_type_ = memory_type; | 157 | continuous_block->memory_type_ = memory_type; |
| 158 | - continuous_block->AddNodeTypeIndex({parent_node, kWorkspace, 0, false, life_begin, parent_node_stream_id, true}, | 158 | + continuous_block->AddNodeTypeIndex( |
| 159 | - continuous_block_size, continuous_block_size, parent_node_stream_id); | 159 | + {parent_node, OpMemoryType::kWorkspace, 0, false, life_begin, parent_node_stream_id, true}, continuous_block_size, |
| 160 | + continuous_block_size, parent_node_stream_id); | ||
| 160 | continuous_block->SetLifeTimeEnd(life_end, parent_node_stream_id); | 161 | continuous_block->SetLifeTimeEnd(life_end, parent_node_stream_id); |
| 161 | GELOGI("%s continuous block size:%zu memory_type:%lu", continuous_block->batch_label_.c_str(), | 162 | GELOGI("%s continuous block size:%zu memory_type:%lu", continuous_block->batch_label_.c_str(), |
| 162 | continuous_block->Size(), memory_type); | 163 | continuous_block->Size(), memory_type); |
| @@ -491,7 +491,8 @@ void GraphMemoryAssigner::RecordSubsequentReuseNodeInfo(const MemoryBlock *const | |||
| 491 | MemReuseInfo reuse_info; | 491 | MemReuseInfo reuse_info; |
| 492 | reuse_info.node.reset(const_cast<Node *>(node_type_index.node_), [](Node *) {}); | 492 | reuse_info.node.reset(const_cast<Node *>(node_type_index.node_), [](Node *) {}); |
| 493 | reuse_info.index = node_type_index.index_; | 493 | reuse_info.index = node_type_index.index_; |
| 494 | - reuse_info.mem_type = (node_type_index.mem_type_ == kOutput) ? MemType::OUTPUT_MEM : MemType::WORKSPACE_MEM; | 494 | + reuse_info.mem_type = |
| 495 | + (node_type_index.mem_type_ == OpMemoryType::kOutput) ? MemType::OUTPUT_MEM : MemType::WORKSPACE_MEM; | ||
| 495 | GELOGD("Level[%u] node[%s], op memory type[%s], index[%u], id[%" PRId64 "]", depth, | 496 | GELOGD("Level[%u] node[%s], op memory type[%s], index[%u], id[%" PRId64 "]", depth, |
| 496 | reuse_info.node->GetName().c_str(), node_type_index.GetMemType().c_str(), node_type_index.index_, | 497 | reuse_info.node->GetName().c_str(), node_type_index.GetMemType().c_str(), node_type_index.index_, |
| 497 | reuse_info.node->GetOpDesc()->GetId()); | 498 | reuse_info.node->GetOpDesc()->GetId()); |
| @@ -152,7 +152,7 @@ void SetChildTailOffset(size_t offset, std::vector<MemoryBlock *> &blocks) { | |||
| 152 | bool CanBlockLifeReuse(const BlockMemAssigner *const mem_assigner, const MemoryBlock &in_block, | 152 | bool CanBlockLifeReuse(const BlockMemAssigner *const mem_assigner, const MemoryBlock &in_block, |
| 153 | const MemoryBlock &out_block, DiffStreamEdgeLife &diff_stream_edge_life) { | 153 | const MemoryBlock &out_block, DiffStreamEdgeLife &diff_stream_edge_life) { |
| 154 | const auto first_node = out_block.NodeTypeIndexList().front(); | 154 | const auto first_node = out_block.NodeTypeIndexList().front(); |
| 155 | - if ((first_node.mem_type_ == kOutput) && | 155 | + if ((first_node.mem_type_ == OpMemoryType::kOutput) && |
| 156 | mem_assigner->HasSameOutAnchorWithDiffStream(first_node.node_, first_node.index_)) { | 156 | mem_assigner->HasSameOutAnchorWithDiffStream(first_node.node_, first_node.index_)) { |
| 157 | GELOGD("out_block first node %s(topoid: %lld) output %u use same memory with node on other stream, return false.", | 157 | GELOGD("out_block first node %s(topoid: %lld) output %u use same memory with node on other stream, return false.", |
| 158 | first_node.node_->GetNamePtr(), first_node.node_->GetOpDescBarePtr()->GetId(), first_node.index_); | 158 | first_node.node_->GetNamePtr(), first_node.node_->GetOpDescBarePtr()->GetId(), first_node.index_); |
| @@ -356,11 +356,9 @@ bool MemoryBlock::IsSameBatchLabel() const { | |||
| 356 | if (node_type_index_list_[index].node_ == nullptr) { | 356 | if (node_type_index_list_[index].node_ == nullptr) { |
| 357 | continue; | 357 | continue; |
| 358 | } | 358 | } |
| 359 | - std::string batch_label; | ||
| 360 | const auto index_op_desc = node_type_index_list_[index].node_->GetOpDescBarePtr(); | 359 | const auto index_op_desc = node_type_index_list_[index].node_->GetOpDescBarePtr(); |
| 361 | GE_IF_BOOL_EXEC(index_op_desc == nullptr, continue); | 360 | GE_IF_BOOL_EXEC(index_op_desc == nullptr, continue); |
| 362 | - // not all op has ATTR_NAME_BATCH_LABEL, no need check return value, only check out parameter | 361 | + const auto &batch_label = GetBatchLabel(index_op_desc); |
| 363 | - (void)ge::AttrUtils::GetStr(index_op_desc, ATTR_NAME_BATCH_LABEL, batch_label); | ||
| 364 | if (batch_label_ != batch_label) { | 362 | if (batch_label_ != batch_label) { |
| 365 | all_same_label = false; | 363 | all_same_label = false; |
| 366 | break; | 364 | break; |
| @@ -30,9 +30,17 @@ | |||
| 30 | #include "common/sgt_slice_type.h" | 30 | #include "common/sgt_slice_type.h" |
| 31 | #include "graph/build/memory/mem_reuse_strategy.h" | 31 | #include "graph/build/memory/mem_reuse_strategy.h" |
| 32 | #include "block_type_list.h" | 32 | #include "block_type_list.h" |
| 33 | +#include "graph/debug/ge_attr_define.h" | ||
| 34 | +#include "graph/utils/attr_utils.h" | ||
| 33 | 35 | ||
| 34 | namespace ge { | 36 | namespace ge { |
| 35 | 37 | ||
| 38 | +inline const std::string &GetBatchLabel(const ge::OpDesc *op_desc) { | ||
| 39 | + const auto *ptr = ge::AttrUtils::GetStr(op_desc, ATTR_NAME_BATCH_LABEL); | ||
| 40 | + static const std::string empty; | ||
| 41 | + return (ptr != nullptr) ? *ptr : empty; | ||
| 42 | +} | ||
| 43 | + | ||
| 36 | constexpr size_t kMaxLifeTime = 0xffffffffUL; | 44 | constexpr size_t kMaxLifeTime = 0xffffffffUL; |
| 37 | constexpr size_t kMinLifeTime = 1U; | 45 | constexpr size_t kMinLifeTime = 1U; |
| 38 | const size_t kDefaultLifeTime = 0xffffffffUL - 1; | 46 | const size_t kDefaultLifeTime = 0xffffffffUL - 1; |
| @@ -42,7 +50,7 @@ constexpr size_t kMaxLogLen = 512UL; | |||
| 42 | constexpr uint32_t kMaxDepthNum = 100U; | 50 | constexpr uint32_t kMaxDepthNum = 100U; |
| 43 | constexpr int64_t kParentNodeDefaultStreamId = -2; | 51 | constexpr int64_t kParentNodeDefaultStreamId = -2; |
| 44 | 52 | ||
| 45 | -enum MemoryNoReuseScope { kReuse, kSessionNoReuse, kGraphNoReuse }; | 53 | +enum class MemoryNoReuseScope { kReuse, kSessionNoReuse, kGraphNoReuse }; |
| 46 | 54 | ||
| 47 | using DependStreamLife = std::map<int32_t, std::map<int64_t, std::map<int64_t, size_t>>>; | 55 | using DependStreamLife = std::map<int32_t, std::map<int64_t, std::map<int64_t, size_t>>>; |
| 48 | 56 | ||
| @@ -59,7 +67,7 @@ struct CompareEdgeLife { | |||
| 59 | 67 | ||
| 60 | using DiffStreamEdgeLife = std::map<int64_t, std::map<int64_t, std::set<EdgeLife, CompareEdgeLife>>>; | 68 | using DiffStreamEdgeLife = std::map<int64_t, std::map<int64_t, std::set<EdgeLife, CompareEdgeLife>>>; |
| 61 | 69 | ||
| 62 | -enum OpMemoryType { kOutput, kWorkspace, kOutputDesc, kInput }; | 70 | +enum class OpMemoryType { kOutput, kWorkspace, kOutputDesc, kInput }; |
| 63 | 71 | ||
| 64 | struct ReuseStrategy { | 72 | struct ReuseStrategy { |
| 65 | explicit ReuseStrategy(bool use_range = false, bool ascending_sort = true, bool reuse_first_release = false, | 73 | explicit ReuseStrategy(bool use_range = false, bool ascending_sort = true, bool reuse_first_release = false, |
| @@ -116,7 +124,7 @@ struct NodeTypeIndex { | |||
| 116 | symbol_max_life_time_end_(symbol_end_time), | 124 | symbol_max_life_time_end_(symbol_end_time), |
| 117 | stream_id_(stream_id) { | 125 | stream_id_(stream_id) { |
| 118 | if ((node_ != nullptr) && (node_->GetOpDesc() != nullptr)) { | 126 | if ((node_ != nullptr) && (node_->GetOpDesc() != nullptr)) { |
| 119 | - is_subgraph_out_ = (node_->GetOpDesc()->GetType() == ge::PARTITIONEDCALL) && (mem_type_ == kOutput); | 127 | + is_subgraph_out_ = (node_->GetOpDesc()->GetType() == ge::PARTITIONEDCALL) && (mem_type_ == OpMemoryType::kOutput); |
| 120 | node_id_ = static_cast<size_t>(node_->GetOpDesc()->GetId()); | 128 | node_id_ = static_cast<size_t>(node_->GetOpDesc()->GetId()); |
| 121 | life_time_begin_is_min_ = (life_time_begin_ > 0) && (life_time_begin_ < node_id_); | 129 | life_time_begin_is_min_ = (life_time_begin_ > 0) && (life_time_begin_ < node_id_); |
| 122 | } else { | 130 | } else { |
| @@ -129,13 +137,13 @@ struct NodeTypeIndex { | |||
| 129 | } | 137 | } |
| 130 | static std::string GetMemType(const OpMemoryType &mem_type) { | 138 | static std::string GetMemType(const OpMemoryType &mem_type) { |
| 131 | switch (mem_type) { | 139 | switch (mem_type) { |
| 132 | - case kOutput: | 140 | + case OpMemoryType::kOutput: |
| 133 | return "output"; | 141 | return "output"; |
| 134 | - case kWorkspace: | 142 | + case OpMemoryType::kWorkspace: |
| 135 | return "workspace"; | 143 | return "workspace"; |
| 136 | - case kOutputDesc: | 144 | + case OpMemoryType::kOutputDesc: |
| 137 | return "output_desc"; | 145 | return "output_desc"; |
| 138 | - case kInput: | 146 | + case OpMemoryType::kInput: |
| 139 | return "input"; | 147 | return "input"; |
| 140 | default: | 148 | default: |
| 141 | return "unknown"; | 149 | return "unknown"; |
| @@ -221,7 +229,7 @@ struct NodeTypeIndex { | |||
| 221 | } | 229 | } |
| 222 | 230 | ||
| 223 | const ge::Node *node_ = nullptr; | 231 | const ge::Node *node_ = nullptr; |
| 224 | - OpMemoryType mem_type_ = kOutput; | 232 | + OpMemoryType mem_type_ = OpMemoryType::kOutput; |
| 225 | uint32_t index_ = 0; | 233 | uint32_t index_ = 0; |
| 226 | bool ref_input_ = false; | 234 | bool ref_input_ = false; |
| 227 | bool is_subgraph_workspace_ = false; | 235 | bool is_subgraph_workspace_ = false; |
| @@ -469,11 +469,11 @@ TEST_F(UtestBlockMemAssigner, GetLifeEnd) { | |||
| 469 | size_t block_size = 512; | 469 | size_t block_size = 512; |
| 470 | int64_t stream_id = 0; | 470 | int64_t stream_id = 0; |
| 471 | bool is_reuse_mem = false; | 471 | bool is_reuse_mem = false; |
| 472 | - OpMemoryType memory_type = kOutput; | 472 | + uint64_t memory_type = RT_MEMORY_HBM; |
| 473 | MemoryBlock block(reuse_strategy_, block_size, stream_id, is_reuse_mem, memory_type); | 473 | MemoryBlock block(reuse_strategy_, block_size, stream_id, is_reuse_mem, memory_type); |
| 474 | auto builder = std::make_shared<block_mem_ut::GraphBuilder>("graph"); | 474 | auto builder = std::make_shared<block_mem_ut::GraphBuilder>("graph"); |
| 475 | auto n = builder->AddNode("node", DATA, 1, 1); | 475 | auto n = builder->AddNode("node", DATA, 1, 1); |
| 476 | - NodeTypeIndex node_type_index{n.get(), memory_type, 0, false, 0, -1}; | 476 | + NodeTypeIndex node_type_index{n.get(), OpMemoryType::kOutput, 0, false, 0, -1}; |
| 477 | block.AddNodeTypeIndex(node_type_index, 512, 512, 0); | 477 | block.AddNodeTypeIndex(node_type_index, 512, 512, 0); |
| 478 | block.SetLifeTimeEnd(0, 1); | 478 | block.SetLifeTimeEnd(0, 1); |
| 479 | EXPECT_EQ(block.GetLifeEnd(1), 0); | 479 | EXPECT_EQ(block.GetLifeEnd(1), 0); |
| @@ -563,7 +563,7 @@ TEST_F(UtestBlockMemAssigner, SubgraphDataStreamIsDifferentWithInput_CheckReuse) | |||
| 563 | assigner.SetOpMemOffset(false); | 563 | assigner.SetOpMemOffset(false); |
| 564 | for (const auto block : blocks) { | 564 | for (const auto block : blocks) { |
| 565 | for (const auto &node : block->node_type_index_list_) { | 565 | for (const auto &node : block->node_type_index_list_) { |
| 566 | - if (node.mem_type_ != kOutput) { | 566 | + if (node.mem_type_ != OpMemoryType::kOutput) { |
| 567 | continue; | 567 | continue; |
| 568 | } | 568 | } |
| 569 | if (node.node_->GetOpDesc()->GetName() == "a") { | 569 | if (node.node_->GetOpDesc()->GetName() == "a") { |
| @@ -618,7 +618,7 @@ TEST_F(UtestBlockMemAssigner, SingleOutputConnectMultiStreamAndRefNode_CheckBloc | |||
| 618 | assigner.SetOpMemOffset(false); | 618 | assigner.SetOpMemOffset(false); |
| 619 | for (const auto block : blocks) { | 619 | for (const auto block : blocks) { |
| 620 | for (const auto &node : block->node_type_index_list_) { | 620 | for (const auto &node : block->node_type_index_list_) { |
| 621 | - if (node.mem_type_ != kOutput) { | 621 | + if (node.mem_type_ != OpMemoryType::kOutput) { |
| 622 | continue; | 622 | continue; |
| 623 | } | 623 | } |
| 624 | if (node.node_->GetOpDesc()->GetName() == "a") { | 624 | if (node.node_->GetOpDesc()->GetName() == "a") { |
| @@ -671,7 +671,7 @@ TEST_F(UtestBlockMemAssigner, SingleOutputConnectMultiStreamAndRefNode_LastRefNo | |||
| 671 | auto f = graph->FindNode("f"); | 671 | auto f = graph->FindNode("f"); |
| 672 | for (const auto block : blocks) { | 672 | for (const auto block : blocks) { |
| 673 | for (const auto &node : block->node_type_index_list_) { | 673 | for (const auto &node : block->node_type_index_list_) { |
| 674 | - if (node.mem_type_ != kOutput) { | 674 | + if (node.mem_type_ != OpMemoryType::kOutput) { |
| 675 | continue; | 675 | continue; |
| 676 | } | 676 | } |
| 677 | if (node.node_->GetOpDesc()->GetName() == "a") { | 677 | if (node.node_->GetOpDesc()->GetName() == "a") { |
| @@ -718,7 +718,7 @@ TEST_F(UtestBlockMemAssigner, SingleOutputConnectMultiStreamAndRefNode_LifeEndIs | |||
| 718 | auto e = graph->FindNode("e"); | 718 | auto e = graph->FindNode("e"); |
| 719 | for (const auto block : blocks) { | 719 | for (const auto block : blocks) { |
| 720 | for (const auto &node : block->node_type_index_list_) { | 720 | for (const auto &node : block->node_type_index_list_) { |
| 721 | - if (node.mem_type_ != kOutput) { | 721 | + if (node.mem_type_ != OpMemoryType::kOutput) { |
| 722 | continue; | 722 | continue; |
| 723 | } | 723 | } |
| 724 | if (node.node_->GetOpDesc()->GetName() == "a") { | 724 | if (node.node_->GetOpDesc()->GetName() == "a") { |
| @@ -786,7 +786,7 @@ TEST_F(UtestBlockMemAssigner, SeperateAtomicCleanAndContinousInput) { | |||
| 786 | bool has_checked = false; | 786 | bool has_checked = false; |
| 787 | for (const auto block : blocks) { | 787 | for (const auto block : blocks) { |
| 788 | for (const auto &node : block->node_type_index_list_) { | 788 | for (const auto &node : block->node_type_index_list_) { |
| 789 | - if (node.mem_type_ != kOutput) { | 789 | + if (node.mem_type_ != OpMemoryType::kOutput) { |
| 790 | continue; | 790 | continue; |
| 791 | } | 791 | } |
| 792 | if ((node.node_->GetOpDesc()->GetName() == "A") && (node.index_ == 1)) { | 792 | if ((node.node_->GetOpDesc()->GetName() == "A") && (node.index_ == 1)) { |
| @@ -884,7 +884,7 @@ TEST_F(UtestBlockMemAssigner, ContinousOutputResueLifeCheck) { | |||
| 884 | bool has_checked = false; | 884 | bool has_checked = false; |
| 885 | for (const auto block : blocks) { | 885 | for (const auto block : blocks) { |
| 886 | for (const auto &node : block->node_type_index_list_) { | 886 | for (const auto &node : block->node_type_index_list_) { |
| 887 | - if (node.mem_type_ != kOutput) { | 887 | + if (node.mem_type_ != OpMemoryType::kOutput) { |
| 888 | continue; | 888 | continue; |
| 889 | } | 889 | } |
| 890 | if ((node.node_->GetOpDesc()->GetName() == "A") && (node.index_ == 0)) { | 890 | if ((node.node_->GetOpDesc()->GetName() == "A") && (node.index_ == 0)) { |
| @@ -987,7 +987,7 @@ TEST_F(UtestBlockMemAssigner, DT_VARIANT_NotPostReuse) { | |||
| 987 | bool has_checked = false; | 987 | bool has_checked = false; |
| 988 | for (const auto block : blocks) { | 988 | for (const auto block : blocks) { |
| 989 | for (const auto &node : block->node_type_index_list_) { | 989 | for (const auto &node : block->node_type_index_list_) { |
| 990 | - if (node.mem_type_ != kOutput) { | 990 | + if (node.mem_type_ != OpMemoryType::kOutput) { |
| 991 | continue; | 991 | continue; |
| 992 | } | 992 | } |
| 993 | std::cout << block->String() << std::endl; | 993 | std::cout << block->String() << std::endl; |
| @@ -1007,7 +1007,7 @@ TEST_F(UtestBlockMemAssigner, Resize) { | |||
| 1007 | size_t block_size = 1024; | 1007 | size_t block_size = 1024; |
| 1008 | int64_t stream_id = 0; | 1008 | int64_t stream_id = 0; |
| 1009 | bool is_reuse_mem = false; | 1009 | bool is_reuse_mem = false; |
| 1010 | - OpMemoryType memory_type = kOutput; | 1010 | + uint64_t memory_type = RT_MEMORY_HBM; |
| 1011 | MemoryBlock parent(reuse_strategy_, block_size, stream_id, is_reuse_mem, memory_type); | 1011 | MemoryBlock parent(reuse_strategy_, block_size, stream_id, is_reuse_mem, memory_type); |
| 1012 | MemoryBlock child(reuse_strategy_, block_size, stream_id, is_reuse_mem, memory_type); | 1012 | MemoryBlock child(reuse_strategy_, block_size, stream_id, is_reuse_mem, memory_type); |
| 1013 | child.first_continuous_block_ = true; | 1013 | child.first_continuous_block_ = true; |
| @@ -1015,7 +1015,7 @@ TEST_F(UtestBlockMemAssigner, Resize) { | |||
| 1015 | parent.child_blocks_.emplace_back(&child); | 1015 | parent.child_blocks_.emplace_back(&child); |
| 1016 | auto builder = std::make_shared<block_mem_ut::GraphBuilder>("graph"); | 1016 | auto builder = std::make_shared<block_mem_ut::GraphBuilder>("graph"); |
| 1017 | auto n = builder->AddNode("node", DATA, 1, 1); | 1017 | auto n = builder->AddNode("node", DATA, 1, 1); |
| 1018 | - NodeTypeIndex node_type_index{n.get(), memory_type, 0, false, 0, -1}; | 1018 | + NodeTypeIndex node_type_index{n.get(), OpMemoryType::kOutput, 0, false, 0, -1}; |
| 1019 | parent.AddNodeTypeIndex(node_type_index, 1024, 1024, 0); | 1019 | parent.AddNodeTypeIndex(node_type_index, 1024, 1024, 0); |
| 1020 | child.AddNodeTypeIndex(node_type_index, 1024, 1024, 0); | 1020 | child.AddNodeTypeIndex(node_type_index, 1024, 1024, 0); |
| 1021 | parent.Resize(); | 1021 | parent.Resize(); |
| @@ -1108,7 +1108,7 @@ TEST_F(UtestBlockMemAssigner, ContinousInputToDiffStreamsNotPostReuse) { | |||
| 1108 | bool has_checked = false; | 1108 | bool has_checked = false; |
| 1109 | for (const auto block : blocks) { | 1109 | for (const auto block : blocks) { |
| 1110 | for (const auto &node : block->node_type_index_list_) { | 1110 | for (const auto &node : block->node_type_index_list_) { |
| 1111 | - if (node.mem_type_ != kOutput) { | 1111 | + if (node.mem_type_ != OpMemoryType::kOutput) { |
| 1112 | continue; | 1112 | continue; |
| 1113 | } | 1113 | } |
| 1114 | if ((node.node_->GetOpDesc()->GetName() == "A") && (node.index_ == 1)) { | 1114 | if ((node.node_->GetOpDesc()->GetName() == "A") && (node.index_ == 1)) { |
| @@ -1148,7 +1148,7 @@ TEST_F(UtestBlockMemAssigner, ContinuousOutputCanNotZeroCpy) { | |||
| 1148 | size_t block_size = 1024; | 1148 | size_t block_size = 1024; |
| 1149 | int64_t stream_id = 0; | 1149 | int64_t stream_id = 0; |
| 1150 | bool is_reuse_mem = false; | 1150 | bool is_reuse_mem = false; |
| 1151 | - OpMemoryType memory_type = kOutput; | 1151 | + uint64_t memory_type = RT_MEMORY_HBM; |
| 1152 | MemoryBlock parent(reuse_strategy_, block_size, stream_id, is_reuse_mem, memory_type); | 1152 | MemoryBlock parent(reuse_strategy_, block_size, stream_id, is_reuse_mem, memory_type); |
| 1153 | MemoryBlock child(reuse_strategy_, block_size, stream_id, is_reuse_mem, memory_type); | 1153 | MemoryBlock child(reuse_strategy_, block_size, stream_id, is_reuse_mem, memory_type); |
| 1154 | child.is_reuse_zero_copy_ = true; | 1154 | child.is_reuse_zero_copy_ = true; |
| @@ -1223,9 +1223,9 @@ TEST_F(UtestBlockMemAssigner, BlockContinueFlagCheck) { | |||
| 1223 | size_t block_size = 1024; | 1223 | size_t block_size = 1024; |
| 1224 | int64_t stream_id = 0; | 1224 | int64_t stream_id = 0; |
| 1225 | bool is_reuse_mem = false; | 1225 | bool is_reuse_mem = false; |
| 1226 | - OpMemoryType memory_type = kOutput; | 1226 | + uint64_t memory_type = RT_MEMORY_HBM; |
| 1227 | MemoryBlock parent(reuse_strategy_, block_size, stream_id, is_reuse_mem, memory_type); | 1227 | MemoryBlock parent(reuse_strategy_, block_size, stream_id, is_reuse_mem, memory_type); |
| 1228 | - NodeTypeIndex node_type_index{b.get(), memory_type, 0, false, 0, stream_id}; | 1228 | + NodeTypeIndex node_type_index{b.get(), OpMemoryType::kOutput, 0, false, 0, stream_id}; |
| 1229 | node_type_index.SetFirstContinuousNode(true); | 1229 | node_type_index.SetFirstContinuousNode(true); |
| 1230 | node_type_index.SetLastContinuousNode(true); | 1230 | node_type_index.SetLastContinuousNode(true); |
| 1231 | node_type_index.SetContinuousNode(true); | 1231 | node_type_index.SetContinuousNode(true); |
| @@ -1301,7 +1301,7 @@ TEST_F(UtestBlockMemAssigner, GetRealStreamIdForParentNode_Success) { | |||
| 1301 | assigner.SetOpMemOffset(false); | 1301 | assigner.SetOpMemOffset(false); |
| 1302 | for (const auto block : blocks) { | 1302 | for (const auto block : blocks) { |
| 1303 | for (const auto &node : block->node_type_index_list_) { | 1303 | for (const auto &node : block->node_type_index_list_) { |
| 1304 | - if (node.mem_type_ != kOutput) { | 1304 | + if (node.mem_type_ != OpMemoryType::kOutput) { |
| 1305 | continue; | 1305 | continue; |
| 1306 | } | 1306 | } |
| 1307 | if (node.node_->GetOpDesc()->GetName() == "partitioncall0") { | 1307 | if (node.node_->GetOpDesc()->GetName() == "partitioncall0") { |
| @@ -1346,7 +1346,7 @@ TEST_F(UtestBlockMemAssigner, KnownSubGraphOutputReuse) { | |||
| 1346 | assigner.SetOpMemOffset(false); | 1346 | assigner.SetOpMemOffset(false); |
| 1347 | for (const auto block : blocks) { | 1347 | for (const auto block : blocks) { |
| 1348 | for (const auto &node : block->node_type_index_list_) { | 1348 | for (const auto &node : block->node_type_index_list_) { |
| 1349 | - if (node.mem_type_ != kOutput) { | 1349 | + if (node.mem_type_ != OpMemoryType::kOutput) { |
| 1350 | continue; | 1350 | continue; |
| 1351 | } | 1351 | } |
| 1352 | if (node.node_->GetOpDesc()->GetName() == "d") { | 1352 | if (node.node_->GetOpDesc()->GetName() == "d") { |
| @@ -1384,7 +1384,7 @@ TEST_F(UtestBlockMemAssigner, RefNodeConnectContinuousNode) { | |||
| 1384 | assigner.SetOpMemOffset(false); | 1384 | assigner.SetOpMemOffset(false); |
| 1385 | for (const auto block : blocks) { | 1385 | for (const auto block : blocks) { |
| 1386 | for (const auto &node : block->node_type_index_list_) { | 1386 | for (const auto &node : block->node_type_index_list_) { |
| 1387 | - if (node.mem_type_ != kOutput) { | 1387 | + if (node.mem_type_ != OpMemoryType::kOutput) { |
| 1388 | continue; | 1388 | continue; |
| 1389 | } | 1389 | } |
| 1390 | if (node.node_->GetOpDesc()->GetName() == "b") { | 1390 | if (node.node_->GetOpDesc()->GetName() == "b") { |
| @@ -1422,7 +1422,7 @@ TEST_F(UtestBlockMemAssigner, SingleNoPaddingContinuousConnectContinuousNode) { | |||
| 1422 | assigner.SetOpMemOffset(false); | 1422 | assigner.SetOpMemOffset(false); |
| 1423 | for (const auto block : blocks) { | 1423 | for (const auto block : blocks) { |
| 1424 | for (const auto &node : block->node_type_index_list_) { | 1424 | for (const auto &node : block->node_type_index_list_) { |
| 1425 | - if (node.mem_type_ != kOutput) { | 1425 | + if (node.mem_type_ != OpMemoryType::kOutput) { |
| 1426 | continue; | 1426 | continue; |
| 1427 | } | 1427 | } |
| 1428 | if (node.node_->GetOpDesc()->GetName() == "a" || node.node_->GetOpDesc()->GetName() == "b") { | 1428 | if (node.node_->GetOpDesc()->GetName() == "a" || node.node_->GetOpDesc()->GetName() == "b") { |
| @@ -1571,7 +1571,7 @@ TEST_F(UtestBlockMemAssigner, GetRealStreamIdForParentNode_NestingAndDiffStream) | |||
| 1571 | assigner.SetOpMemOffset(false); | 1571 | assigner.SetOpMemOffset(false); |
| 1572 | for (const auto block : blocks) { | 1572 | for (const auto block : blocks) { |
| 1573 | for (const auto &node : block->node_type_index_list_) { | 1573 | for (const auto &node : block->node_type_index_list_) { |
| 1574 | - if (node.mem_type_ != kOutput) { | 1574 | + if (node.mem_type_ != OpMemoryType::kOutput) { |
| 1575 | continue; | 1575 | continue; |
| 1576 | } | 1576 | } |
| 1577 | if (node.node_->GetOpDesc()->GetName() == "if") { | 1577 | if (node.node_->GetOpDesc()->GetName() == "if") { |
| @@ -65,7 +65,8 @@ struct ReuseNode { | |||
| 65 | 65 | ||
| 66 | std::string ToString() { | 66 | std::string ToString() { |
| 67 | std::stringstream ss; | 67 | std::stringstream ss; |
| 68 | - ss << "Node:" << name << " type:" << mem_type << " index:" << index << " offset:" << offset << " size:" << size; | 68 | + ss << "Node:" << name << " type:" << static_cast<int>(mem_type) << " index:" << index << " offset:" << offset |
| 69 | + << " size:" << size; | ||
| 69 | return ss.str(); | 70 | return ss.str(); |
| 70 | } | 71 | } |
| 71 | }; | 72 | }; |
| @@ -2096,10 +2097,10 @@ class UtestMemoryAssignerTest : public testing::Test { | |||
| 2096 | auto node = graph->FindNode(reuse_node.name); | 2097 | auto node = graph->FindNode(reuse_node.name); |
| 2097 | int64_t size = 0; | 2098 | int64_t size = 0; |
| 2098 | int64_t offset = 0; | 2099 | int64_t offset = 0; |
| 2099 | - if (reuse_node.mem_type == kOutput) { | 2100 | + if (reuse_node.mem_type == OpMemoryType::kOutput) { |
| 2100 | ge::TensorUtils::GetSize(*(node->GetOpDesc()->MutableOutputDesc(reuse_node.index)), size); | 2101 | ge::TensorUtils::GetSize(*(node->GetOpDesc()->MutableOutputDesc(reuse_node.index)), size); |
| 2101 | offset = node->GetOpDesc()->GetOutputOffset()[reuse_node.index]; | 2102 | offset = node->GetOpDesc()->GetOutputOffset()[reuse_node.index]; |
| 2102 | - } else if (reuse_node.mem_type == kWorkspace) { | 2103 | + } else if (reuse_node.mem_type == OpMemoryType::kWorkspace) { |
| 2103 | offset = node->GetOpDesc()->GetWorkspace()[reuse_node.index]; | 2104 | offset = node->GetOpDesc()->GetWorkspace()[reuse_node.index]; |
| 2104 | size = node->GetOpDesc()->GetWorkspaceBytes()[reuse_node.index]; | 2105 | size = node->GetOpDesc()->GetWorkspaceBytes()[reuse_node.index]; |
| 2105 | } else { | 2106 | } else { |
| @@ -2342,7 +2343,7 @@ TEST_F(UtestMemoryAssignerTest, block_memory_assign_continuous_memory_out_diff_s | |||
| 2342 | assigner.SetOpMemOffset(false); | 2343 | assigner.SetOpMemOffset(false); |
| 2343 | for (const auto block : blocks) { | 2344 | for (const auto block : blocks) { |
| 2344 | for (const auto &node : block->node_type_index_list_) { | 2345 | for (const auto &node : block->node_type_index_list_) { |
| 2345 | - if (node.mem_type_ != kOutput) { | 2346 | + if (node.mem_type_ != OpMemoryType::kOutput) { |
| 2346 | continue; | 2347 | continue; |
| 2347 | } | 2348 | } |
| 2348 | if (node.node_->GetOpDesc()->GetName() == "E") { | 2349 | if (node.node_->GetOpDesc()->GetName() == "E") { |
| @@ -2964,8 +2965,8 @@ TEST_F(UtestMemoryAssignerTest, graph_hccl_ws_no_reuse_io) { | |||
| 2964 | EXPECT_EQ(memory_assigner.AssignMemory(mem_offset, zero_memory_size), GRAPH_SUCCESS); | 2965 | EXPECT_EQ(memory_assigner.AssignMemory(mem_offset, zero_memory_size), GRAPH_SUCCESS); |
| 2965 | 2966 | ||
| 2966 | MemoryBlock *reuse_block = nullptr; | 2967 | MemoryBlock *reuse_block = nullptr; |
| 2967 | - EXPECT_EQ(GetReuseBlock(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, {"B", kWorkspace, 0}, | 2968 | + EXPECT_EQ(GetReuseBlock(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 2968 | - &reuse_block), | 2969 | + {"B", OpMemoryType::kWorkspace, 0}, &reuse_block), |
| 2969 | GRAPH_SUCCESS); | 2970 | GRAPH_SUCCESS); |
| 2970 | 2971 | ||
| 2971 | EXPECT_NE(reuse_block, nullptr); | 2972 | EXPECT_NE(reuse_block, nullptr); |
| @@ -3060,7 +3061,7 @@ TEST_F(UtestMemoryAssignerTest, DiffStreamNoPaddingContinuousInputHasEdgeCanReus | |||
| 3060 | size_t zero_memory_size = 0; | 3061 | size_t zero_memory_size = 0; |
| 3061 | EXPECT_EQ(memory_assigner.AssignMemory(mem_offset, zero_memory_size), GRAPH_SUCCESS); | 3062 | EXPECT_EQ(memory_assigner.AssignMemory(mem_offset, zero_memory_size), GRAPH_SUCCESS); |
| 3062 | EXPECT_EQ(CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 3063 | EXPECT_EQ(CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 3063 | - {{"E", kOutput, 1}, {"B", kOutput, 0}}), | 3064 | + {{"E", OpMemoryType::kOutput, 1}, {"B", OpMemoryType::kOutput, 0}}), |
| 3064 | GRAPH_SUCCESS); | 3065 | GRAPH_SUCCESS); |
| 3065 | } | 3066 | } |
| 3066 | 3067 | ||
| @@ -3087,7 +3088,7 @@ TEST_F(UtestMemoryAssignerTest, DiffStreamNoPaddingContinuousInput_CanNotReuse_H | |||
| 3087 | size_t zero_memory_size = 0; | 3088 | size_t zero_memory_size = 0; |
| 3088 | EXPECT_EQ(memory_assigner.AssignMemory(mem_offset, zero_memory_size), GRAPH_SUCCESS); | 3089 | EXPECT_EQ(memory_assigner.AssignMemory(mem_offset, zero_memory_size), GRAPH_SUCCESS); |
| 3089 | EXPECT_EQ(CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 3090 | EXPECT_EQ(CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 3090 | - {{"G", kOutput, 1}, {"C", kOutput, 0}}), | 3091 | + {{"G", OpMemoryType::kOutput, 1}, {"C", OpMemoryType::kOutput, 0}}), |
| 3091 | GRAPH_SUCCESS); | 3092 | GRAPH_SUCCESS); |
| 3092 | } | 3093 | } |
| 3093 | 3094 | ||
| @@ -3109,7 +3110,7 @@ TEST_F(UtestMemoryAssignerTest, graph_diff_stream_memory_reuse) { | |||
| 3109 | size_t zero_memory_size = 0; | 3110 | size_t zero_memory_size = 0; |
| 3110 | EXPECT_EQ(memory_assigner.AssignMemory(mem_offset, zero_memory_size), GRAPH_SUCCESS); | 3111 | EXPECT_EQ(memory_assigner.AssignMemory(mem_offset, zero_memory_size), GRAPH_SUCCESS); |
| 3111 | EXPECT_EQ(CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 3112 | EXPECT_EQ(CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 3112 | - {{"C", kOutput, 0}, {"F", kOutput, 0}}), | 3113 | + {{"C", OpMemoryType::kOutput, 0}, {"F", OpMemoryType::kOutput, 0}}), |
| 3113 | GRAPH_SUCCESS); | 3114 | GRAPH_SUCCESS); |
| 3114 | } | 3115 | } |
| 3115 | 3116 | ||
| @@ -3657,7 +3658,7 @@ TEST_F(UtestMemoryAssignerTest, graph_continuous_input_memory_reuse) { | |||
| 3657 | offset = it->second; | 3658 | offset = it->second; |
| 3658 | } | 3659 | } |
| 3659 | EXPECT_EQ(CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 3660 | EXPECT_EQ(CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 3660 | - {{"A", kOutput, 0}, {"D", kOutput, 0}}), | 3661 | + {{"A", OpMemoryType::kOutput, 0}, {"D", OpMemoryType::kOutput, 0}}), |
| 3661 | GRAPH_SUCCESS); | 3662 | GRAPH_SUCCESS); |
| 3662 | EXPECT_EQ(offset, 9216); | 3663 | EXPECT_EQ(offset, 9216); |
| 3663 | } | 3664 | } |
| @@ -3677,7 +3678,10 @@ TEST_F(UtestMemoryAssignerTest, graph_continuous_input_memory_reuse_multi_ref) { | |||
| 3677 | offset = it->second; | 3678 | offset = it->second; |
| 3678 | } | 3679 | } |
| 3679 | EXPECT_EQ(CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 3680 | EXPECT_EQ(CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 3680 | - {{"A", kOutput, 0}, {"B", kOutput, 0}, {"F", kOutput, 0}, {"I", kOutput, 0}}), | 3681 | + {{"A", OpMemoryType::kOutput, 0}, |
| 3682 | + {"B", OpMemoryType::kOutput, 0}, | ||
| 3683 | + {"F", OpMemoryType::kOutput, 0}, | ||
| 3684 | + {"I", OpMemoryType::kOutput, 0}}), | ||
| 3681 | GRAPH_SUCCESS); | 3685 | GRAPH_SUCCESS); |
| 3682 | EXPECT_EQ(offset, 17408); | 3686 | EXPECT_EQ(offset, 17408); |
| 3683 | } | 3687 | } |
| @@ -4117,9 +4121,10 @@ TEST_F(UtestMemoryAssignerTest, SingleOutDiffStreamOptimize) { | |||
| 4117 | EXPECT_EQ(GetStreamId(graph, "C"), GetStreamId(graph, "A")); | 4121 | EXPECT_EQ(GetStreamId(graph, "C"), GetStreamId(graph, "A")); |
| 4118 | 4122 | ||
| 4119 | // A,C,E可以复用 | 4123 | // A,C,E可以复用 |
| 4120 | - EXPECT_EQ(CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 4124 | + EXPECT_EQ( |
| 4121 | - {{"A", kOutput, 0}, {"C", kOutput, 0}, {"E", kOutput, 0}}), | 4125 | + CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 4122 | - GRAPH_SUCCESS); | 4126 | + {{"A", OpMemoryType::kOutput, 0}, {"C", OpMemoryType::kOutput, 0}, {"E", OpMemoryType::kOutput, 0}}), |
| 4127 | + GRAPH_SUCCESS); | ||
| 4123 | EXPECT_EQ(offset, 1250304); | 4128 | EXPECT_EQ(offset, 1250304); |
| 4124 | } | 4129 | } |
| 4125 | /* | 4130 | /* |
| @@ -4199,9 +4204,9 @@ TEST_F(UtestMemoryAssignerTest, SingleOutDiffStream) { | |||
| 4199 | // A,C,F可以复用 | 4204 | // A,C,F可以复用 |
| 4200 | EXPECT_EQ(CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 4205 | EXPECT_EQ(CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 4201 | { | 4206 | { |
| 4202 | - {"A", kOutput, 0}, | 4207 | + {"A", OpMemoryType::kOutput, 0}, |
| 4203 | - {"C", kOutput, 0}, | 4208 | + {"C", OpMemoryType::kOutput, 0}, |
| 4204 | - {"F", kOutput, 0}, | 4209 | + {"F", OpMemoryType::kOutput, 0}, |
| 4205 | }), | 4210 | }), |
| 4206 | GRAPH_SUCCESS); | 4211 | GRAPH_SUCCESS); |
| 4207 | EXPECT_EQ(offset, 3346944); | 4212 | EXPECT_EQ(offset, 3346944); |
| @@ -4238,7 +4243,7 @@ TEST_F(UtestMemoryAssignerTest, SingleOutDiffStreamWithMerge) { | |||
| 4238 | bool has_checked = false; | 4243 | bool has_checked = false; |
| 4239 | for (const auto block : blocks) { | 4244 | for (const auto block : blocks) { |
| 4240 | for (const auto &node : block->node_type_index_list_) { | 4245 | for (const auto &node : block->node_type_index_list_) { |
| 4241 | - if (node.mem_type_ != kOutput) { | 4246 | + if (node.mem_type_ != OpMemoryType::kOutput) { |
| 4242 | continue; | 4247 | continue; |
| 4243 | } | 4248 | } |
| 4244 | if (node.node_->GetOpDesc()->GetName() == "A") { | 4249 | if (node.node_->GetOpDesc()->GetName() == "A") { |
| @@ -4278,7 +4283,7 @@ TEST_F(UtestMemoryAssignerTest, AtomicCleanNotReuseWithSubGraphData) { | |||
| 4278 | EXPECT_EQ(memory_assigner.AssignMemory(mem_offset, zero_memory_size), GRAPH_SUCCESS); | 4283 | EXPECT_EQ(memory_assigner.AssignMemory(mem_offset, zero_memory_size), GRAPH_SUCCESS); |
| 4279 | // a c 不复用 | 4284 | // a c 不复用 |
| 4280 | EXPECT_EQ(CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 4285 | EXPECT_EQ(CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 4281 | - {{"a", kOutput, 0}, {"c", kOutput, 0}}, false), | 4286 | + {{"a", OpMemoryType::kOutput, 0}, {"c", OpMemoryType::kOutput, 0}}, false), |
| 4282 | GRAPH_SUCCESS); | 4287 | GRAPH_SUCCESS); |
| 4283 | } | 4288 | } |
| 4284 | 4289 | ||
| @@ -4320,7 +4325,7 @@ TEST_F(UtestMemoryAssignerTest, DiffStreamEdgeExcludeData) { | |||
| 4320 | } | 4325 | } |
| 4321 | // A,E不复用 | 4326 | // A,E不复用 |
| 4322 | EXPECT_EQ(CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 4327 | EXPECT_EQ(CheckReuse(memory_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 4323 | - {{"A", kOutput, 0}, {"E", kOutput, 0}}, false), | 4328 | + {{"A", OpMemoryType::kOutput, 0}, {"E", OpMemoryType::kOutput, 0}}, false), |
| 4324 | GRAPH_SUCCESS); | 4329 | GRAPH_SUCCESS); |
| 4325 | 4330 | ||
| 4326 | EXPECT_EQ(offset, 1456128); | 4331 | EXPECT_EQ(offset, 1456128); |
| @@ -4426,7 +4431,7 @@ TEST_F(UtestMemoryAssignerTest, ContinuousOutIn_SUCCESS_OutAsHeader_SeparateClea | |||
| 4426 | MemoryAssigner mem_assigner(graph); | 4431 | MemoryAssigner mem_assigner(graph); |
| 4427 | EXPECT_EQ(mem_assigner.AssignMemory(mem_type_to_mem_offset, zero_copy_mem_size), SUCCESS); | 4432 | EXPECT_EQ(mem_assigner.AssignMemory(mem_type_to_mem_offset, zero_copy_mem_size), SUCCESS); |
| 4428 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 4433 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 4429 | - {{"hcom1", kOutput, 0}, {"c", kOutput, 0}}, true), | 4434 | + {{"hcom1", OpMemoryType::kOutput, 0}, {"c", OpMemoryType::kOutput, 0}}, true), |
| 4430 | GRAPH_SUCCESS); | 4435 | GRAPH_SUCCESS); |
| 4431 | } | 4436 | } |
| 4432 | 4437 | ||
| @@ -4450,7 +4455,7 @@ TEST_F(UtestMemoryAssignerTest, ContinuousOutIn_SUCCESS_OutAsHeaderAndTail_Separ | |||
| 4450 | MemoryAssigner mem_assigner(graph); | 4455 | MemoryAssigner mem_assigner(graph); |
| 4451 | EXPECT_EQ(mem_assigner.AssignMemory(mem_type_to_mem_offset, zero_copy_mem_size), SUCCESS); | 4456 | EXPECT_EQ(mem_assigner.AssignMemory(mem_type_to_mem_offset, zero_copy_mem_size), SUCCESS); |
| 4452 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 4457 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 4453 | - {{"hcom1", kOutput, 0}, {"c", kOutput, 0}}, false), | 4458 | + {{"hcom1", OpMemoryType::kOutput, 0}, {"c", OpMemoryType::kOutput, 0}}, false), |
| 4454 | GRAPH_SUCCESS); | 4459 | GRAPH_SUCCESS); |
| 4455 | } | 4460 | } |
| 4456 | 4461 | ||
| @@ -4474,10 +4479,10 @@ TEST_F(UtestMemoryAssignerTest, ContinuousOutIn_SUCCESS_InAsHeader_SeparateClean | |||
| 4474 | MemoryAssigner mem_assigner(graph); | 4479 | MemoryAssigner mem_assigner(graph); |
| 4475 | EXPECT_EQ(mem_assigner.AssignMemory(mem_type_to_mem_offset, zero_copy_mem_size), SUCCESS); | 4480 | EXPECT_EQ(mem_assigner.AssignMemory(mem_type_to_mem_offset, zero_copy_mem_size), SUCCESS); |
| 4476 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 4481 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 4477 | - {{"hcom1", kOutput, 0}, {"c", kOutput, 0}}, false), | 4482 | + {{"hcom1", OpMemoryType::kOutput, 0}, {"c", OpMemoryType::kOutput, 0}}, false), |
| 4478 | GRAPH_SUCCESS); | 4483 | GRAPH_SUCCESS); |
| 4479 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 4484 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 4480 | - {{"a", kOutput, 0}, {"c", kOutput, 0}}, false), | 4485 | + {{"a", OpMemoryType::kOutput, 0}, {"c", OpMemoryType::kOutput, 0}}, false), |
| 4481 | GRAPH_SUCCESS); | 4486 | GRAPH_SUCCESS); |
| 4482 | } | 4487 | } |
| 4483 | 4488 | ||
| @@ -4516,13 +4521,13 @@ TEST_F(UtestMemoryAssignerTest, ContinuousOutIn_SUCCESS_InAsHeaderAndTail_Separa | |||
| 4516 | MemoryAssigner mem_assigner(graph); | 4521 | MemoryAssigner mem_assigner(graph); |
| 4517 | EXPECT_EQ(mem_assigner.AssignMemory(mem_type_to_mem_offset, zero_copy_mem_size), SUCCESS); | 4522 | EXPECT_EQ(mem_assigner.AssignMemory(mem_type_to_mem_offset, zero_copy_mem_size), SUCCESS); |
| 4518 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 4523 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 4519 | - {{"c", kOutput, 0}, {"b", kOutput, 0}}, false), | 4524 | + {{"c", OpMemoryType::kOutput, 0}, {"b", OpMemoryType::kOutput, 0}}, false), |
| 4520 | GRAPH_SUCCESS); | 4525 | GRAPH_SUCCESS); |
| 4521 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 4526 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 4522 | - {{"c", kOutput, 0}, {"hcom1", kOutput, 0}}, false), | 4527 | + {{"c", OpMemoryType::kOutput, 0}, {"hcom1", OpMemoryType::kOutput, 0}}, false), |
| 4523 | GRAPH_SUCCESS); | 4528 | GRAPH_SUCCESS); |
| 4524 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 4529 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 4525 | - {{"c", kOutput, 0}, {"a", kOutput, 0}}, false), | 4530 | + {{"c", OpMemoryType::kOutput, 0}, {"a", OpMemoryType::kOutput, 0}}, false), |
| 4526 | GRAPH_SUCCESS); | 4531 | GRAPH_SUCCESS); |
| 4527 | } | 4532 | } |
| 4528 | 4533 | ||
| @@ -4561,7 +4566,7 @@ TEST_F(UtestMemoryAssignerTest, ContinuousOutIn_SUCCESS_TwoContinuousInNode_Sepa | |||
| 4561 | MemoryAssigner mem_assigner(graph); | 4566 | MemoryAssigner mem_assigner(graph); |
| 4562 | EXPECT_EQ(mem_assigner.AssignMemory(mem_type_to_mem_offset, zero_copy_mem_size), SUCCESS); | 4567 | EXPECT_EQ(mem_assigner.AssignMemory(mem_type_to_mem_offset, zero_copy_mem_size), SUCCESS); |
| 4563 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 4568 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 4564 | - {{"c", kOutput, 0}, {"hcom1", kOutput, 0}}, false), | 4569 | + {{"c", OpMemoryType::kOutput, 0}, {"hcom1", OpMemoryType::kOutput, 0}}, false), |
| 4565 | GRAPH_SUCCESS); | 4570 | GRAPH_SUCCESS); |
| 4566 | } | 4571 | } |
| 4567 | 4572 | ||
| @@ -4586,7 +4591,7 @@ TEST_F(UtestMemoryAssignerTest, ContinuousOutIn_SUCCESS_TwoContinuousInNodeAndRe | |||
| 4586 | InfoLog log; // 打印info日志才能覆盖到一些分支 | 4591 | InfoLog log; // 打印info日志才能覆盖到一些分支 |
| 4587 | EXPECT_EQ(mem_assigner.AssignMemory(mem_type_to_mem_offset, zero_copy_mem_size), SUCCESS); | 4592 | EXPECT_EQ(mem_assigner.AssignMemory(mem_type_to_mem_offset, zero_copy_mem_size), SUCCESS); |
| 4588 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, | 4593 | EXPECT_EQ(CheckReuse(mem_assigner.GetGraphMemoryAssigner()->GetMemAssignerPtr(), graph, |
| 4589 | - {{"e", kOutput, 0}, {"hcom1", kOutput, 0}}, false), | 4594 | + {{"e", OpMemoryType::kOutput, 0}, {"hcom1", OpMemoryType::kOutput, 0}}, false), |
| 4590 | GRAPH_SUCCESS); | 4595 | GRAPH_SUCCESS); |
| 4591 | } | 4596 | } |
| 4592 | /* | 4597 | /* |
| @@ -62,14 +62,14 @@ TEST_F(UtestBlockTypeListTest, NodeMemAttrUtils_GetNodeMemAttrs) { | |||
| 62 | ASSERT_NE(c, nullptr); | 62 | ASSERT_NE(c, nullptr); |
| 63 | ASSERT_NE(data, nullptr); | 63 | ASSERT_NE(data, nullptr); |
| 64 | { | 64 | { |
| 65 | - NodeTypeIndex node_type_index{data, kOutput, 0}; | 65 | + NodeTypeIndex node_type_index{data, OpMemoryType::kOutput, 0}; |
| 66 | auto attrs = NodeMemAttrUtils::GetNodeMemAttrs(node_type_index); | 66 | auto attrs = NodeMemAttrUtils::GetNodeMemAttrs(node_type_index); |
| 67 | ASSERT_EQ(attrs.size(), 1U); | 67 | ASSERT_EQ(attrs.size(), 1U); |
| 68 | EXPECT_EQ(attrs.front(), NodeMemAttr::kData); | 68 | EXPECT_EQ(attrs.front(), NodeMemAttr::kData); |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | { | 71 | { |
| 72 | - NodeTypeIndex node_type_index{c, kOutput, 0}; | 72 | + NodeTypeIndex node_type_index{c, OpMemoryType::kOutput, 0}; |
| 73 | auto attrs = NodeMemAttrUtils::GetNodeMemAttrs(node_type_index); | 73 | auto attrs = NodeMemAttrUtils::GetNodeMemAttrs(node_type_index); |
| 74 | ASSERT_EQ(attrs.size(), 1U); | 74 | ASSERT_EQ(attrs.size(), 1U); |
| 75 | EXPECT_EQ(attrs.front(), NodeMemAttr::kConcentrateAtomic); | 75 | EXPECT_EQ(attrs.front(), NodeMemAttr::kConcentrateAtomic); |
| @@ -161,11 +161,11 @@ TEST_F(UtestBlockTypeListTest, BlockTypeList_CheckConflict) { | |||
| 161 | BlockTypeList data_type; | 161 | BlockTypeList data_type; |
| 162 | BlockTypeList atomic_clean_type; | 162 | BlockTypeList atomic_clean_type; |
| 163 | 163 | ||
| 164 | - NodeTypeIndex data_node_type_index{data, kOutput, 0}; | 164 | + NodeTypeIndex data_node_type_index{data, OpMemoryType::kOutput, 0}; |
| 165 | data_type.WithAdded(data_node_type_index); | 165 | data_type.WithAdded(data_node_type_index); |
| 166 | EXPECT_STREQ(data_type.ToString().c_str(), "data "); | 166 | EXPECT_STREQ(data_type.ToString().c_str(), "data "); |
| 167 | 167 | ||
| 168 | - NodeTypeIndex atomic_node_type_index{c, kOutput, 0}; | 168 | + NodeTypeIndex atomic_node_type_index{c, OpMemoryType::kOutput, 0}; |
| 169 | atomic_clean_type.WithAdded(atomic_node_type_index); | 169 | atomic_clean_type.WithAdded(atomic_node_type_index); |
| 170 | EXPECT_STREQ(atomic_clean_type.ToString().c_str(), "concentrate_atomic "); | 170 | EXPECT_STREQ(atomic_clean_type.ToString().c_str(), "concentrate_atomic "); |
| 171 | EXPECT_STREQ(NodeMemAttrUtils::GetAttrStr(atomic_node_type_index).c_str(), "concentrate_atomic "); | 171 | EXPECT_STREQ(NodeMemAttrUtils::GetAttrStr(atomic_node_type_index).c_str(), "concentrate_atomic "); |
| @@ -176,7 +176,7 @@ TEST_F(UtestBlockTypeListTest, BlockTypeList_CheckConflict) { | |||
| 176 | 176 | ||
| 177 | ReuseStrategy strategy; | 177 | ReuseStrategy strategy; |
| 178 | MemoryBlock block{strategy, 1}; | 178 | MemoryBlock block{strategy, 1}; |
| 179 | - NodeTypeIndex normal{a, kOutput, 0}; | 179 | + NodeTypeIndex normal{a, OpMemoryType::kOutput, 0}; |
| 180 | block.AddNodeTypeIndex(normal, 1, 1, 1); | 180 | block.AddNodeTypeIndex(normal, 1, 1, 1); |
| 181 | data_type.WithDeleted(block, data_node_type_index); | 181 | data_type.WithDeleted(block, data_node_type_index); |
| 182 | EXPECT_STREQ(data_type.ToString().c_str(), ""); | 182 | EXPECT_STREQ(data_type.ToString().c_str(), ""); |