已合并
fix(cleancode): AICPU算子告警整改(第三批) #10997
liu-wei创建于 22 天前
fix(cleancode): AICPU算子告警整改(第三批) #10997
已合并
Pull Request已成功合入, 合并人@CANN-robot
(感谢 liu-wei 的贡献)atomgit-bot
22 天前 评论:
22 天前 评论:
变更摘要
本 PR 是 ops-nn AICPU 算子告警整改第三批,针对多个算子的静态检查告警进行代码清理,改动以成员函数补充 const、条件表达式显式化为主,不改变运行逻辑。整改覆盖 log_softmax_v2、scatter_elements、sparse_segment_mean、sparse_segment_sum、sparse_to_dense、tensor_scatter_update、softmax_v2、reverse_sequence 等算子的 AICPU 实现,声明与定义同步修改。
主要改动
- 成员函数补充
const限定(G.CNS.03): 为LogSoftmaxV2Check、LogSoftmaxV2Compute、ScatterElementsCpuKernel::UpdateOutput/DispatchByDataType/DoCompute、SparseSegmentMeanCpuKernel::ComputeKernel/ComputeKernelWithType、SparseSegmentSumCpuKernel同名方法、SparseToDenseCpuKernel::ValidParam/ParallelSetDefaultValue、TensorScatterUpdateCpukernel::GetInputAndCheck等在头文件声明与.cpp定义中同步追加const,标识其不修改对象状态。 - 条件表达式显式化(G.EXP.27/36):
softmax_v2_aicpu.cpp中将SoftmaxV2Check与SoftmaxV2CpuKernel::Compute里以NormalCheck(...)、detail::SoftmaxV2Check(...)作为?:判断条件的写法改为显式!= KERNEL_STATUS_OK比较,语义保持一致。 - 取模判断显式化(G.EXP.27):
reverse_sequence_aicpu.cpp中将reverseNum % kEven改为(reverseNum % kEven) != 0,使布尔判断意图更明确。 - 只读指针参数补充
const(G.CNS.04):tensor_scatter_update_aicpu.cpp中GetBatchStrides的outer_shape参数由uint64_t*改为const uint64_t*,标明该参数仅被读取。
以上改动均为声明与定义同步的等价重构,不涉及接口语义、数据结构或配置变更。


不准确?
atomgit-bot
22 天前 评论:
22 天前 评论:
22 天前 修改了pull request 的描述
liu-wei
22 天前 评论:
22 天前 评论:
compile


此处折叠了41条消息 查看更多
21 天前 添加了label:approved
sgqt12
21 天前 评论:
21 天前 评论:
/lgtm


21 天前 添加了label:lgtm
21 天前 关闭了关联的issue
21 天前 合入了pull request
描述
ops-nn AICPU 算子告警整改第三批,修复 18 条告警(G.CNS.03 ×12 / G.EXP.27+36 ×5 / G.CNS.04 ×1),共 14 个文件 +29/-29:
const(声明与定义同步,被调成员均为 const 或自由函数)NormalCheck(...)/detail::SoftmaxV2Check(...)两处?:条件改为显式!= KERNEL_STATUS_OKreverseNum % kEven显式比较!= 0GetBatchStrides的outer_shape参数加const(仅读取)不处理项(附判定依据)
== static_cast<T>(0)×2(log_softmax_v2/softmax_v2 的除零防护):保持语义,建议工具豁免;char*为字节缓冲非字符串,误报;EigenSparseToDense的SparseTensor& st:st.ToDense<>()受 Eigen API 限制,疑似误报。验证
467b22d6cvs 本提交7f12ebcbc,同编译参数 g++ -O2 -std=c++14):8 个 TU 全部机器码/数据节内容多重集逐字节一致(合计 1298 节),仅 const 成员函数 mangled 名(符号表及 scatter_elements 15 节、sparse_to_dense 1 节的内嵌签名串ZN→ZNK)变化——零功能影响;关联的Issue
https://gitcode.com/cann/ops-nn/issues/6114
类型标签