已合并
【质量加固】修改若干符合代码规范的问题 #4618
海洋504创建于 8 天前
【质量加固】修改若干符合代码规范的问题 #4618
已合并
海洋504创建于 8 天前
海洋504
海洋504
8 天前

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

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 海洋504 的贡献)
海洋504海洋504
8 天前 添加了label:enhancement
海洋504海洋504
8 天前 创建了 pull request,commit 509cd155
atomgit-bot
atomgit-bot
8 天前 评论:

变更摘要

本 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 中,为 GetStreamAllocationSummaryGetOutputShapesGetOutputDtypes 三个 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 修饰。
likedislike
CANN-robot
CANN-robot成员
8 天前 评论:

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.

likedislike
atomgit-bot
atomgit-bot
8 天前 评论:

代码审查

已完成全部三个变更文件的逐一审查。审查结论如下:

发现汇总(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

⛔ 需要修改

likedislike
此处折叠了47条消息 查看更多
CANN-robotCANN-robot成员
7 天前 添加了label:lgtm
张德鹏成员
6 天前 解决了最后一个问题
张德鹏成员
6 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
6 天前 添加了label:approved
CANN-robotCANN-robot成员
6 天前 合入了pull request