已合并
[Fix] AICPU 算子代码规范告警清理 #5856
[Fix] AICPU 算子代码规范告警清理 #5856
已合并
liu-wei创建于 9月20日
liu-wei
liu-wei成员
9月20日

告警清理

修复 6 条代码规范告警(G.FMT.14 / G.CNS.03 / G.FUN.02),共 7 个文件 +10/-10:

告警 文件 修复
G.FMT.14 ×1 greater_equal_aicpu.cpp char const* 统一为 const char* 风格(同一类型,纯风格修正)
G.CNS.03 ×1 tile_aicpu.cpp/.h GetMultiplesValue 补充 const 修饰
G.FUN.02 ×1 top_k_pq_distance_aicpu.cpp PopHeap 定义补充 * const 与声明一致
G.CNS.03 ×2 top_k_pq_distance_aicpu.h/.cpp MakeHeap/SortHeap 补充 const 修饰
G.CNS.03 ×1 top_k_v2_d_aicpu.h/.cpp DispatchByDtype 补充 const 修饰

未包含项(与初版正文的差异说明)

  • strided_slice 的 G.EXP.27 ×4(有符号数位运算 UB)不在本 PR 范围,将另行跟进修复
  • trans_data 的 G.CNS.04 ×2 为误报:DispatchDealData 的参数经 aicpu::PtrToPtr 写入,AICPU 公共头无 const 重载,加 const 编译失败(初版曾尝试修改,复检确认编译问题后已回退)

关联的Issue

https://gitcode.com/cann/ops-math/issues/3268

验证

  • 二进制级对比(父提交 vs 本提交,同路径同编译参数):4 个改动 TU 的全部机器码节(.text* 共 1254 节)逐字节相同,greater_equal/top_k_pq_distance 目标文件整体逐位相同;tile/top_k_v2_d 仅 const 成员函数符号修饰名(_ZN→_ZNK)及符号表/重定位元数据变化,均为 private 成员、无外部 ABI 影响——零功能影响
  • 平台风险复检:未发现可证明的功能或编译问题
  • CI 流水线通过

类型

🧹 代码清理

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 liu-wei 的贡献)
liu-weiliu-wei成员
9月20日 创建了 pull request,commit 3179324e
CANN-robotCANN-robot成员
9月20日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
9月20日 评论:

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
math/greater_equal ✅ 王瑞, xuejinghui (2/2) ✅ xuejinghui, 王瑞 (2/1)
math/tile ✅ xuejinghui, 王瑞 (2/2) ✅ xuejinghui, 王瑞 (2/1)
repo-cann/ops-math ✅ xuejinghui, 王瑞 (2/2) ✅ xuejinghui, 王瑞 (2/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robot成员
9月20日 将FelixTang7,yue-ma,zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,jia0liang,zl_hw,songkai111,chenxingyu18,pingchuantang,llimwang,gubaocheng,andong_hw,xuejinghui,zhanw_coding设为评审人
CANN-robotCANN-robot成员
9月20日 将FelixTang7,yue-ma,zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,jia0liang,zl_hw,songkai111,chenxingyu18,pingchuantang,llimwang,gubaocheng,andong_hw,xuejinghui,zhanw_coding设为审查人
liu-wei
liu-wei成员9月20日进行代码检视3
conversion/trans_data/op_kernel_aicpu/trans_data_aicpu.cpp
已过期
@@ -78,7 +78,7 @@
7878}
7979 
8080void GetIndexMap(const std::vector<int64_t>& perm_arg, std::map<int32_t, int32_t>& index_map)
8181{
liu-wei
liu-wei9月20日评论:

🔴 Critical | 这里把 input_data_temp 改成 const void* 后,下面仍调用 aicpu::PtrToPtr<void, T>(input_data_temp)。当前 AICPU 公共头 utils/kernel_util.h 里的 PtrToPtr 只有 TI* const 入参版本,没有 const TI* 重载;const void* 传入会丢 const,C++ 编译会报 no matching function / would lose const qualifier。建议这里改为 PtrToPtr<const void, const T>(input_data_temp),或不要把 input_data_temp 改为 const void*。

likedislike
System
系统消息系统
9月20日 评论:

changed this line on 22d57055 view diff detail

liu-wei
liu-wei成员
9月20日 评论:

🔴 Critical | 这里把 input_data_temp 改成 const void* 后,下面仍调用 aicpu::PtrToPtr<void, T>(input_data_temp)。当前 AICPU 公共头 utils/kernel_util.h 里的 PtrToPtr 只有 TI* const 入参版本,没有 const TI* 重载;const void* 传入会丢 const,C++ 编译会报 no matching function / would lose const qualifier。建议这里改为 PtrToPtr<const void, const T>(input_data_temp),或不要把 input_data_temp 改为 const void*。

@liu-wei
已修改。

liu-wei
liu-wei成员
9月20日 评论:

PR 功能风险复检总结

PR: #5856 — [Fix] AICPU 算子代码规范告警清理
复检 head: 766e9fe8dcdc5e78a740f0acaeb0e8cb1bfbdc21
结论: 需要修改后再合入。

发现 1 个确定性编译问题,已发布 inline 评论:conversion/trans_data/op_kernel_aicpu/trans_data_aicpu.cpp 中 DispatchDealData 入参改为 const void*,但仍使用 aicpu::PtrToPtr<void, T>(input_data_temp)。当前 AICPU 公共头 utils/kernel_util.h 仅提供 TI* const 版本,没有 const TI* 重载,const void* 传入会丢 const 导致编译失败。

其余变更点如 const 成员函数补充、指针 const 修饰、bit mask 显式布尔比较、格式调整等,静态复查未发现功能逻辑变化。

本地验证: PR 范围 git diff --check 通过;使用最小 C++ 片段验证 const void* 调用 PtrToPtr<void, T> 会报 would lose const qualifier。未执行完整编译/UT。

likedislike
liu-weiliu-wei成员
9月20日 virtual merging failed, update merge request[project_id: 7649531, iid: 5856, target_commit_sha: 5876a0f4fea6510bb5e8f9997f5b652b7330ff4d], message: Conflict detected
此处折叠了7条事件消息 查看更多
CANN-robotCANN-robot成员
9月20日 添加了label:cann-cla/yes
liu-wei
liu-wei成员
9月20日 评论:

compile

likedislike
liu-weiliu-wei成员
9月20日 预合并成功(commit_id: a65a0aabe9e6e088cbb9ce59150c33bc77187760)
CANN-robot
CANN-robot成员
9月20日 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
9月20日 添加了label:ci-pipeline-running
liu-wei
liu-wei成员
9月20日 评论:

PR 功能风险复检总结

PR: #5856 — [Fix] AICPU 算子代码规范告警清理
复检 head: 29d54eb3d11e2337b1bb96faea9957b08d051f79
结论: ✅ 当前未发现可证明的功能或编译问题。

本轮相比上一轮已更新,TransDataCpuKernel::DispatchDealData 的 input_data_temp 已恢复为 void*,此前 const void* 调用 PtrToPtr<void, T> 导致的确定性编译问题已消除;当前 PR 文件列表也不再包含 conversion/trans_data 和 conversion/strided_slice。

当前剩余改动主要为:

  • greater_equal 指针声明风格调整,语义等价;
  • tile 的 GetMultiplesValue 补 const,实现未改;
  • top_k_pq_distance 的 MakeHeap / SortHeap 补 const,PopHeap 参数补顶层 const,堆逻辑未改;
  • top_k_v2_d 的 DispatchByDtype 补 const,分派逻辑未改。

验证:当前 PR 范围 git diff --check 通过。未执行完整编译/UT,最终仍建议以 CI 编译和相关 AICPU UT 为准。

likedislike
CANN-robotCANN-robot成员
9月20日 删除了label:ci-pipeline-running
此处折叠了5条事件消息 查看更多
CANN-robotCANN-robot成员
9月20日 删除了label:ci-pipeline-passedstat/needs-squash
CANN-robot
CANN-robot成员
9月20日 评论:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): ci-pipeline-passed, stat/needs-squash.

likedislike
CANN-robotCANN-robot成员
9月20日 添加了label:cann-cla/yes
liu-wei
liu-wei成员
9月21日 评论:

compile

likedislike
liu-weiliu-wei成员
9月21日 预合并成功(commit_id: ca8f39efdd4ddf249c0243344eb1b89656051d6c)
CANN-robot
CANN-robot成员
9月21日 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
9月21日 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
9月21日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
9月21日 添加了label:ci-pipeline-passed
sunchun成员
9月21日 评论:

您好,PR已满足合入指标,请尽快联系Committer进行合入。如暂时不需要合入,请在PR标题前加[WIP]

likedislike
liu-weiliu-wei成员
9月21日 修改了pull request 的描述
liu-weiliu-wei成员
9月21日 解决了最后一个问题
liu-weiliu-wei成员
9月21日 修改了pull request 的描述
RuiWang_成员
9月21日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
9月21日 添加了label:approved
xuejinghui成员
9月21日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
9月21日 添加了label:lgtm
CANN-robotCANN-robot成员
9月21日 合入了pull request