Pull Request已成功合入, 合并人@CANN-robot
(感谢 tangqunzhang 的贡献)变更摘要
该 PR 对 compiler/graph/build/memory/block_mem_assigner.cc 中 BlockMemAssigner::GetOutAndWorkSpaceMem 函数做性能优化:通过将 batch_all_memory_size[batch_label] 的查找结果缓存为局部引用 batch_mem,消除函数内两处重复的 operator[] 容器查找;同时将遍历输出锚点指针的循环变量由按值拷贝改为常量引用,规避 shared_ptr 按值拷贝带来的原子引用计数开销。该改动为纯重构,不改变既有功能逻辑。
主要改动
- 缓存
batch_mem引用: 在函数入口处新增auto &batch_mem = batch_all_memory_size[batch_label];,将后续两处batch_all_memory_size[batch_label]的重复operator[]查找替换为对batch_mem的直接使用(batch_mem.emplace_back(size)与batch_mem.insert(batch_mem.cend(), temp.cbegin(), temp.cend())),消除重复哈希查找开销。 - 遍历改为常量引用: 将
for (auto out_anchor : n->GetAllOutDataAnchorsPtr())改为for (const auto &out_anchor : ...),避免循环中对shared_ptr按值拷贝产生的原子引用计数增减开销。


🤖 本次改动均为数据 / 生成 / 二进制文件(如测试用例、锁文件、媒体资源),没有可审查的代码逻辑,已跳过 AI 代码审查。


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/ge | ✅ Mexyy, kobemini, 张德鹏 (3/2) | ✅ 张德鹏 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
tangqunzhang, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Pull Request
描述
优化
compiler/graph/build/memory/下连续节点生命期遍历和 batch 内存大小查找的性能。具体改动:
GetContinuousNodeLifeTimeBegin和SetContinuousNodeLifeTimeBegin从递归改为迭代式(std::stack+std::unordered_set防环),消除递归深度限制kMaxDepthNum,不再需要兜底处理org_node和depth参数(调用方始终传相同值),SetContinuousNodeLifeTimeBegin移除depth参数ATTR_NAME_NOPADDING_CONTINUOUS_INPUT只获取一次,is_continuous从循环中保存batch_all_memory_size[batch_label]缓存为局部引用,消除循环内重复operator[]查找NoPaddingContinuousCascadedLifeTimeBegin验证级联连续输入场景下生命期传播正确性变更类型
关联的Issue
无
如何测试
UtestBlockMemAssigner.*全部 68 个 UTut_libge_multiparts_utest全量 3065 个 UTBuildNoPaddingContinuousInCascadedGraph)上结果一致核对清单