已合并
【质量加固】style: 为不可变局部变量补充 const 修饰(#238) #1867
【质量加固】style: 为不可变局部变量补充 const 修饰(#238) #1867
已合并
caiyu123123创建于 18 天前
caiyu123123
18 天前

Pull Request

描述

对应 Issue #238「质量加固」,按规则 3 在 autofuse/ascir/meta/ascir_utils.cpp 中为 10 个初始化后不再修改的局部变量补充 const 修饰。仅修改该文件,不改变运行逻辑、接口或数据结构。

变更类型

请选择本次引入的变更类型:

关联的Issue

https://gitcode.com/cann/graph-autofusion/issues/238

如何测试

  1. 代码检视确认 git diff 每处仅新增 const 限定,无行为变更。
  2. PR 评论区触发 compile

核对清单

其他信息

共 10 处修改:TrimParam(start/end)、InitDumpDirectories(base_path/autofuse_dir/pid_dir)、GetDumpGraphPrefixAndCreateDir(graph_dir)、NodeAttrStr(is_buf)、DumpGraphText(is_subgraph)、DumpPyCode(prefix/base_name)。

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 caiyu123123 的贡献)
Ccaiyu123123
18 天前 创建了 pull request,commit f6c6cf65
Ccaiyu123123
18 天前 关联了issue:【质量加固】AutoFusion定向“质量加固”社区有奖任务
atomgit-bot
atomgit-bot
18 天前 评论:

变更摘要

本 PR 为质量加固改动,依据两条规则对代码进行 const 修饰:规则 1 为不修改成员状态的只读成员函数补充 const(涉及 ArgListManager / ThreadLocalContext / ApiTilingGenRegistry / ExprManager 共 9 处),规则 2 将 Variable::Assign 的参数改为 const std::string &(1 处),合计 10 处;同时避开了已有质量加固 PR 修改过的文件,并在 ArgListManager 中顺带将重复的 find + operator[] 查找改写为复用迭代器,避免二次查找。

主要改动

  • ApiTilingGenRegistry 查询接口补充 const: 在 api_tiling_gen_register.h/.cpp 中为 GetApiTilingGenImplFuncGetApiTilingGenInvokeFuncGetApiTilingGenHeadFiles 三个只读查询函数补充 const 限定,声明与定义保持一致,明确其不修改注册表状态。

  • ArgListManager 只读成员函数补充 const 并优化查找: 在 arg_list_manager.h 中为 GetArgExpr(单参/多参重载)、GetArgList(两个重载)补充 const 限定;同时将 arg_list_map_.find(name) 后再次 operator[] 取值的方式改为复用迭代器 iter->second,减少重复查找。

  • ThreadLocalContext::GetOption 补充 const: 在 thread_local_context.h/.cpp 中为只读查询函数 GetOption 补充 const 限定,声明与定义同步更新。

  • Variable::Assign 参数改为 const 引用: 在 codegen_kernel.h/.cpp 中将 Assign 的参数由 std::string &value 改为 const std::string &value,使该只读参数可接受 const 及临时对象,且不影响函数行为。

  • ExprManager::GetPrinter 补充 const: 在 expr_print_manager.h 中为只读查询函数 GetPrinter 补充 const 限定,明确其不修改打印器注册表。

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

代码审查

✅ 未发现问题

likedislike
不准确?
caiyu123123
18 天前 评论:

/check-cla

likedislike
此处折叠了46条消息 查看更多
牛玉虎
牛玉虎成员
15 天前 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
15 天前 添加了label:lgtm
张德鹏成员
15 天前 评论:

/approve

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