Pull Request已成功合入, 合并人@CANN-robot
(感谢 海洋504 的贡献)变更摘要
本 PR 为代码质量加固类改动,核心内容是依据代码规范对若干函数补充 const 限定:将部分以引用方式传入的 ComputeGraphPtr 参数改为 const ComputeGraphPtr &,并为若干只读成员函数(getter 与查询类函数)补充 const 修饰,以提升接口的只读语义表达,不涉及任何业务逻辑或行为变化。
主要改动
IsDataDirectConnNetoutput参数 const 化:在graph_builder.cc/graph_builder.h中,将该静态函数的参数由ComputeGraphPtr &改为const ComputeGraphPtr &,明确该函数不修改计算图对象。SummaryData查询接口补充const:在graph_compile_summary_impl.h中,为GetStreamAllocationSummary、GetOutputShapes、GetOutputDtypes三个 getter 方法补充const修饰,表达只读语义。CollectFunctionalNode参数 const 化:在label_allocator.cc/label_allocator.h中,将该私有成员函数参数改为const ComputeGraphPtr &,与函数本身的const限定保持一致。IsGraphNeedRebuild补充const:在graph_manager.cc/graph_manager.h中,为GraphManager::IsGraphNeedRebuild成员函数补充const修饰。IsVarPermitToChangeFormats补充const:在graph_rebuild_state_ctrl.h中,为GraphRebuildStateCtrl::IsVarPermitToChangeFormats查询类成员函数补充const修饰。


Hi @2402_87730846, 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 项,置信度 0.90):
compiler/graph/manager/util/graph_rebuild_state_ctrl.h:44— 将IsVarPermitToChangeFormats声明改为const,但唯一类外定义graph_rebuild_state_ctrl.cc:68未同步加const,声明与定义签名不一致,编译该 .cc 时必然报 out-of-line definition mismatch 错误,导致构建失败。
各文件审查结果
compiler/graph/manager/graph_manager.cc— 无问题。IsGraphNeedRebuild定义加const后,函数体仅调用同为 const 的GetGraphNode(cc:2836)与IsGraphNeedBuild(cc:3989),不修改任何成员,const 化合法且与头文件声明一致。compiler/graph/manager/graph_manager.h— 无问题。声明(h:179)与定义(cc:3971)同步加const,签名匹配;全局检索未发现任何调用方或成员函数指针使用者受签名(非 const→const)变化影响。compiler/graph/manager/util/graph_rebuild_state_ctrl.h— 发现 1 个 P0 构建失败问题(见上)。已核实该函数体(cc:68-74)为只读操作、mutex_为mutable,在 .cc 定义处补const即可编译通过;本 diff 仅改声明未改定义,属单侧修改引入的新不一致。
总体风险判断
本次变更为三处 const 修饰符的“代码规范加固”,其中 GraphManager::IsGraphNeedRebuild 的改动内部自洽、无回归风险;但 GraphRebuildStateCtrl::IsVarPermitToChangeFormats 的改动遗漏了对应的 .cc 定义同步,属于直接导致工程编译失败的一侧修改(P0)。建议在合入前补齐 .cc 定义处的 const 限定,或撤回该处修改。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 1 |
| 🟡 建议 | 0 |
⛔ 需要修改


修改若干符合代码规范的问题