已合并
fix: 代码规范优化 - 精确头文件引用、const修饰、全局对象初始化顺序修复 #4854
yelongjian创建于 21 天前
fix: 代码规范优化 - 精确头文件引用、const修饰、全局对象初始化顺序修复 #4854
已合并
yelongjian创建于 21 天前
yelongjian成员
21 天前

Pull Request

描述

代码规范优化,修复头文件引用、const修饰和全局对象初始化顺序问题。

变更类型

关联的Issue

如何测试

  1. 编译验证:bash build.sh --ge_compiler
  2. 运行单元测试验证

核对清单

其他信息

变更详情:

  1. mem_assigner.h: 替换冗余include为精确头文件引用
  2. variable_op_pass: DealFusion/CheckVariableRefLegally添加const修饰
  3. parser_model_saver.h: 替换废弃头文件为精确引用
  4. reshape_remove_pass.cc: 全局对象改为construct on first use惯用法,避免跨编译单元初始化顺序问题
  5. task_producer.h: 替换废弃ge_api_types.h为精确头文件
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 yelongjian 的贡献)
Yyelongjian成员
21 天前 创建了 pull request,commit dd301d21
atomgit-bot
atomgit-bot
21 天前 评论:

变更摘要

本 PR 属于代码规范优化型重构,主要围绕三方面:将多处冗余或废弃的头文件引用替换为精确的 external/ge_common/ge_common_api_types.h;为 VariableOpPass 的成员函数补充 const 修饰;并将 reshape_remove_pass.cc 中的全局对象改为 construct on first use 惯用法,以规避跨编译单元的静态初始化顺序问题。

主要改动

  • 精确头文件引用替换:mem_assigner.h 将冗余的 framework/common/ge_inner_error_codes.h 替换为 external/ge_common/ge_common_api_types.h;parser_model_saver.h 与 task_producer.h 则用该精确头文件替换废弃的 ge/ge_api_types.h(parser_model_saver.h 同时移除 ge/ge_api_error_codes.h),收窄依赖范围。

  • reshape_remove_pass.cc 全局对象初始化顺序修复:将全局 std::map<std::string, OpHashValue> kToBeDeleteOp 和 std::set<std::string> kInputShapeContinue 改为函数内静态局部变量,通过新增的 GetToBeDeleteOp()、GetInputShapeContinue() 访问,采用 construct on first use 惯用法避免跨编译单元初始化顺序问题。

  • VariableOpPass 添加 const 修饰:在头文件与实现中同步为 DealFusion(const SameVarPtr &) 和 CheckVariableRefLegally(const SameVarPtr &, bool &) 添加 const 限定,明确成员函数不修改对象状态。

likedislike
不准确?
atomgit-bot
atomgit-bot
21 天前 评论:

代码审查

✅ 未发现问题

likedislike
不准确?
CANN-robotCANN-robot成员
21 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
21 天前 评论:

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 ✅ yangyongqiang0606, kobemini, zhanj (3/2) ✅ yangyongqiang0606 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

yelongjian, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robot
CANN-robot成员
21 天前 评论:

CLA Signature Pass

yelongjian, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robot成员
21 天前 将yangyongqiang0606,kobemini,ClarkXie,tangqunzhang,xchu42,hugo111,lining23666,depeng1994,wqtshg_wt,peiyang,shengnan666,zhangfan_hanq,zhanj,zhujingjing,Mexyy,wangxiaotian995,stevenaw0,yuht9设为评审人
CANN-robotCANN-robot成员
21 天前 将yangyongqiang0606,kobemini,ClarkXie,tangqunzhang,xchu42,hugo111,lining23666,depeng1994,wqtshg_wt,peiyang,shengnan666,zhangfan_hanq,zhanj,zhujingjing,Mexyy,wangxiaotian995,stevenaw0,yuht9设为审查人
yelongjian成员
21 天前 评论:

compile

likedislike
Yyelongjian成员
21 天前 预合并成功(commit_id: 07c1fa85a989402c7fb70e6309ac51855adac548)
Yyelongjian成员
21 天前 修改标题为 “fix: 代码规范优化 - 精确头文件引用、const修饰、全局对象初始化顺序修复”,原标题为“【PR】: 代码规范优化 - 精确头文件引用、const修饰、全局对象初始化顺序修复”
CANN-robot
CANN-robot成员
21 天前 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
21 天前 添加了label:ci-pipeline-running
此处折叠了6条事件消息 查看更多
CANN-robotCANN-robot成员
21 天前 添加了label:cann-cla/yes
yelongjian成员
21 天前 评论:

compile

likedislike
Yyelongjian成员
21 天前 预合并成功(commit_id: 9dbac77dd16f819a2947922abb5d237e645da249)
CANN-robot
CANN-robot成员
21 天前 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
21 天前 删除了label:ci-pipeline-failed
CANN-robotCANN-robot成员
21 天前 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
21 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
21 天前 添加了label:ci-pipeline-failed
yelongjian成员
21 天前 评论:

compile

likedislike
CANN-robot
CANN-robot成员
21 天前 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
21 天前 删除了label:ci-pipeline-failed
CANN-robotCANN-robot成员
21 天前 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
21 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
21 天前 添加了label:ci-pipeline-passed
zhanj
zhanj成员
21 天前 评论:

/lgtm

likedislike
GengChao
GengChao成员
21 天前 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
21 天前 添加了label:lgtm
yangyongqiang
yangyongqiang成员
21 天前 评论:

/approve

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