Pull Request已成功合入, 合并人@CANN-robot
(感谢 WXQ123123 的贡献)变更摘要
本 PR 为质量加固改动(对应 Issue #517),旨在为不修改成员变量的只读成员函数补充 const 修饰,共涉及 10 处函数,分布在 BlockMemAssigner、EnginePartitioner、NotaskPassBase、VariableOpPass、L2MemPool、HostExecutorDumper、DflowGraphManager、TransOpWithoutReshapeFusionPass 等类中,声明(.h)与定义(.cc)同步修改,不改变任何函数行为逻辑,仅为接口签名层面的修饰符补充。
主要改动
- 内存分配与复用查询函数补充
const:为BlockMemAssigner::GetOutputNodeReuseMemFlagByIndex与BlockMemAssigner::GetInputNodeReuseMemFlag补充const修饰,表明这两类复用标志查询不修改成员状态。 - 图分区路径判定函数补充
const:为EnginePartitioner::HasSecondPath补充const修饰,其内部仅基于graph_info_判断簇间是否存在第二条路径,不改变成员变量。 - 优化 Pass 的判定函数补充
const:为NotaskPassBase::IsPreNodeTypeValid、NotaskPassBase::IsPreNodeAttrValid、VariableOpPass::GetRefVars及TransOpWithoutReshapeFusionPass::CheckIfHasSameOutControlEdge补充const,强化这些只读判定/查询接口的常量性约束。 - 运行时与执行框架接口补充
const:为L2MemPool::GetStream、HostExecutorDumper::IsInDumpStep补充const修饰,其中GetStream仅返回stream_成员,符合只读语义。 - dflow 模块查询接口补充
const:为DflowGraphManager::GetOptionsRunGraphFlag补充const修饰,该函数仅读取初始化标志并返回是否运行图,不改动DflowGraphManager内部状态。


Hi @WXQ123123, welcome to submitting your first PR to ge!
PR Merge Steps
1. CLA Signing
If the current PR label includes cann-cla/yes, it means you have signed the CLA and can proceed to the next step. If the label includes cann-cla/no, please sign the CLA first. If you have any questions, please refer to the FAQ.
2. CI Check
Please comment /compile to trigger the CI pipeline check. If the CI run is successful, the PR will be tagged with ci-pipeline-passed and you can proceed to the next step. If the CI run fails, the PR will be tagged with ci-pipeline-failed, please check the CI logs to fix the issues in the PR. If you have any questions, please refer to the FAQ.
3. Code Review
After CI passes, please refer to the PR Approval Progress and proactively @ the committers in the table to review the code. After approval, committers will comment /lgtm and /approve. Once the lgtm and approved labels are successfully added, the PR will be merged automatically.


代码审查
审查结论
发现的问题
共报告 1 个问题:
- P0(1 个,confidence 0.9):
compiler/graph/partition/engine_partitioner.cc—HasSecondPath增加const修饰后,函数体第 1224 行graph_info_.clusters_[cluster](对 conststd::unordered_map调用非 const 的operator[])无法编译,导致构建失败。需改为.at(cluster)或撤销 const。
各变更文件审查结果
| 文件 | 审查结果 |
|---|---|
| compiler/graph/partition/engine_partitioner.cc | 发现问题(P0,见上) |
| compiler/graph/partition/engine_partitioner.h | no issues(声明与定义一致,均为 const;graph_info_ 非 mutable,问题根因在 .cc 函数体) |
| compiler/graph/passes/format_optimize/transop_without_reshape_fusion_pass.cc | no issues(CheckIfHasSameOutControlEdge 函数体仅访问 Node/Anchor 对象,不触碰 pass 成员,const 安全) |
| compiler/graph/passes/format_optimize/transop_without_reshape_fusion_pass.h | no issues(声明一致) |
| compiler/graph/passes/memory_optimize/notask_pass_base.cc | no issues(IsPreNodeTypeValid/IsPreNodeAttrValid 仅只读访问 cur_pro_node_name_ 等成员,调用的 GetFirstNotRefNode 本身已是 const) |
| compiler/graph/passes/memory_optimize/notask_pass_base.h | no issues(声明一致) |
| compiler/graph/passes/variable_optimize/variable_op_pass.cc | no issues(GetRefVars 仅对 var_and_var_ref_map_ 调用 const 的 .find()) |
| compiler/graph/passes/variable_optimize/variable_op_pass.h | no issues(声明一致) |
| dflow/runner/compiler/model/dflow_graph_manager.cc | no issues(GetOptionsRunGraphFlag 仅只读 is_initialized_、options_.find()) |
| dflow/runner/compiler/model/dflow_graph_manager.h | no issues(声明一致) |
| runtime/v2/kernel/memory/l2_mem_pool.cc | no issues(GetStream 仅返回成员 stream_;非虚函数,无重写契约问题) |
| runtime/v2/kernel/memory/l2_mem_pool.h | no issues(声明一致) |
| runtime/v2/subscriber/dumper/host_executor_dumper.cc | no issues(IsInDumpStep 仅只读 step_set_/step_range_,const 兼容;非基类虚函数) |
| runtime/v2/subscriber/dumper/host_executor_dumper.h | no issues(声明一致) |
总体风险评估
本 PR 为纯 const 修饰加固改动,除 engine_partitioner.cc 外其余 9 处函数的 const 化均安全且声明/定义一致。EnginePartitioner::HasSecondPath 一处 const 化会导致编译失败(构建阻断),必须修复后才能合入;修复方式明确(将函数体内 clusters_[cluster] 改为 .at(cluster)),改动极小。整体风险集中在上述单点编译错误,修复后该 PR 无其他正确性/安全/性能风险。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 2 |
| 🟡 建议 | 0 |
⛔ 需要修改


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, zhanj (3/2) | ✅ 张德鹏 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
WXQ123123, thanks for your pull request. All authors of the commits have signed the CLA. 👍


CLA检查未通过,详情可参考这里


CLA检查已通过,详情可参考这里


🔴 Critical
变更行:engine_partitioner.h:165 为 HasSecondPath(size_t src, size_t dst, size_t upper_bound) 增加了 const 修饰,对应的定义(engine_partitioner.cc:1206)也同步改为 const。
受影响行为/契约:成员函数变为 const 后,函数体内 this 为 const EnginePartitioner*,因此成员 graph_info_(GraphPartitionInfo,engine_partitioner.h:191)在函数内是 const 对象。
失败模式:engine_partitioner.cc:1224 ClusterPtr cur_cluster = graph_info_.clusters_[cluster]; 对 std::unordered_map<size_t, ClusterPtr>(engine_partitioner.h:95)调用 operator[]。std::unordered_map::operator[] 只有非 const 重载,对 const 容器调用属于编译错误("passing 'const unordered_map' as 'this' argument discards qualifiers" / "no matching operator[]"),导致 engine_partitioner 模块无法编译,属于构建失败。注意同函数第 1208 行用的 clusters_.at(...) 有 const 重载,可以正常编译。
建议:将 engine_partitioner.cc:1224 的 graph_info_.clusters_[cluster] 改为 graph_info_.clusters_.at(cluster)(与第 1208 行一致);或撤销 engine_partitioner.h:165 的 const 修饰。二选一即可使模块恢复编译。


🔴 Critical
变更行:本 diff 将 EnginePartitioner::HasSecondPath(engine_partitioner.cc 第 1206 行)声明与定义同时加上 const 修饰。但该函数体(第 1224 行,未被本 diff 修改)仍执行 ClusterPtr cur_cluster = graph_info_.clusters_[cluster];。
受影响行为/契约:graph_info_ 是 EnginePartitioner 的非 mutable 成员(engine_partitioner.h 第 191 行 GraphPartitionInfo graph_info_;),其 clusters_ 是 std::unordered_map<size_t, ClusterPtr>(engine_partitioner.h 第 95 行)。std::unordered_map::operator[] 只有非 const 版本,没有 const 重载;一旦 HasSecondPath 变为 const 成员函数,this 为 const EnginePartitioner*,graph_info_ 变为 const,graph_info_.clusters_[cluster] 即以 const 对象调用非 const 成员函数,属于编译期错误(g++/clang 报 "passing 'const std::unordered_map<...>' as 'this' argument discards qualifiers")。第 1208 行使用的 clusters_.at() 有 const 重载,不受影响,仅第 1224 行的 [] 调用无法编译。
失败模式:本 PR 合入后 engine_partitioner.cc 无法通过编译,属于构建失败(P0)。PR 测试计划中 "CI compile 通过" 为未勾选状态,与本问题一致。
建议:将第 1224 行 graph_info_.clusters_[cluster] 改为 graph_info_.clusters_.at(cluster)(const 兼容且不会改变合法路径语义),或撤销 HasSecondPath 的 const 修饰。


流水线任务触发成功
任务链接 [999bb1ac646941bdbf0137330aaf67f6][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck_Pr | ✅ SUCCESS | ||
| antipoison | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| codecheck_dt | ✅ SUCCESS | >>>>> | |
| codecheck_precommit | ✅ SUCCESS | >>>>> | |
| StaticCheck_codespell | ✅ SUCCESS | ||
| StaticCheck_link_validity | ✅ SUCCESS | ||
| StaticCheck_resource_existence | ✅ SUCCESS | ||
| StaticCheck_tag_closed | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS |
[2026-08-28 11:13:58] CI执行结束


流水线任务触发成功
任务链接 [80ddda0f34d94df89395f619e7fe95f3][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_X86_compiler_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_executor_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_dflow_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_ARM_compiler_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_ARM_executor_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_ARM_dflow_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_ARM_compiler | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_ARM_executor | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_ARM_dflow | ✅ SUCCESS | >>>>> | >>>>> |
| API_Check | ✅ SUCCESS | >>>>> | |
| PreSmoke_A900_npupool | ✅ SUCCESS | >>>>> |
[2026-08-28 11:25:50] CI执行结束


流水线任务触发成功
任务链接 [df8b4a13192a49e993b17484ad78fea7][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_X86_compiler | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_executor | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_X86_dflow | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_dflow | ✅ SUCCESS | ||
| UT_Test_ge_common | ✅ SUCCESS | ||
| UT_Test_parser | ✅ SUCCESS | ||
| UT_Test_python | ✅ SUCCESS | >>>>> | |
| UT_Test_rt | ✅ SUCCESS | ||
| UT_Test_acl | ✅ SUCCESS | ||
| UT_Test_autofuse | ✅ SUCCESS | ||
| UT_Test_executor | ✅ SUCCESS | ||
| UT_Test_autofuse_ascendc_api | ✅ SUCCESS | ||
| ST_Test_dflow | ✅ SUCCESS | ||
| ST_Test_ge_common | ✅ SUCCESS | ||
| ST_Test_parser | ✅ SUCCESS | ||
| ST_Test_python | ✅ SUCCESS | >>>>> | |
| ST_Test_rt | ✅ SUCCESS | ||
| ST_Test_autofuse | ✅ SUCCESS | ||
| ST_Test_executor | ✅ SUCCESS | ||
| ST_Test_hetero | ✅ SUCCESS | ||
| ST_Test_autofuse_ascendc_api | ✅ SUCCESS | ||
| ST_Test_autofuse_e2e | ✅ SUCCESS | ||
| UT_Test_fe | ✅ SUCCESS | ||
| UT_Test_tefusion | ✅ SUCCESS | ||
| ST_Test_fe | ✅ SUCCESS | ||
| ST_Test_tefusion | ✅ SUCCESS | ||
| ST_Test_ge_common_atc | ✅ SUCCESS | ||
| UT_Test_Report_graphengine | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_ge_executor_c | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_ge_autofuse | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_graphengine | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_ge_executor_c | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_ge_autofuse | ✅ SUCCESS | >>>>> | |
| UT_Test_Report_fe | ✅ SUCCESS | >>>>> | |
| ST_Test_Report_fe | ✅ SUCCESS | >>>>> |
[2026-08-28 11:32:08] CI执行结束


流水线任务触发成功
任务链接 [e54c78eb9d9440efaf60a92f68a06e45][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck_Pr | ✅ SUCCESS | ||
| antipoison | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| codecheck_dt | ✅ SUCCESS | >>>>> | |
| codecheck_precommit | ✅ SUCCESS | >>>>> | |
| StaticCheck_codespell | ✅ SUCCESS | ||
| StaticCheck_link_validity | ✅ SUCCESS | ||
| StaticCheck_resource_existence | ✅ SUCCESS | ||
| StaticCheck_tag_closed | ✅ SUCCESS | ||
| StaticCheck_markdownlint | ✅ SUCCESS |
[2026-08-28 11:22:49] CI执行结束


/lgtm


Summary
const修饰(共 10 处)修改清单
EnginePartitioner::HasSecondPathBlockMemAssigner::GetOutputNodeReuseMemFlagByIndexBlockMemAssigner::GetInputNodeReuseMemFlagNotaskPassBase::IsPreNodeTypeValidNotaskPassBase::IsPreNodeAttrValidVariableOpPass::GetRefVarsL2MemPool::GetStreamHostExecutorDumper::IsInDumpStepDflowGraphManager::GetOptionsRunGraphFlagTransOpWithoutReshapeFusionPass::CheckIfHasSameOutControlEdgeTest plan