文件最后提交记录最后更新时间
fix: cleancode Co-authored-by: libohao6<libohao3@huawei.com> # message auto-generated for no-merge-commit merge: !5489 merge fix-cleancode-issues into master fix: cleancode Created-by: libohao6 Commit-by: libohao6 Merged-by: cann-robot Description: ## 描述 修复基础算子主线cleancode问题。 ## 关联的Issue [Bug-Report|缺陷反馈]: MC2基础算子主线存在cleancode问题 #2566 ## 测试 二级冒烟。 ## 文档更新 不涉及。 ## 类型标签 <!-- [x] 表示选中 --> - [x] 🐛 Bug 修复 - [ ] ✨ 新特性 - [ ] ⚡ 性能优化 - [ ] ♻️ 重构 - [ ] 🧪 测试 - [ ] 📦 构建/CI - [ ] 🔧 配置变更 - [ ] 📝 文档更新 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: # PR #5489 代码检视报告 **PR**: https://gitcode.com/cann/ops-transformer/pull/5489 **标题**: merge 'fix-cleancode-issues' into 'master' **作者**: libohao6 | **范围**: 19 files, +453 -531 | **日期**: 2026-05-21 --- ## 改动分类 | 类型 | 改动数 | 说明 | |------|-------|------| | 删除未使用函数 | 5个 | matmul_util.cpp删3个static函数 + aclnn_matmul_reduce_scatter_v2.cpp删CreateWinTensor | | 删除冗余变量 | 2个 | x1Dtype/biasDtype 在 aclnn_weight_quant_matmul_all_reduce.cpp | | const修饰添加 | 5处 | 多个Tiling函数context参数加const | | 位操作类型修复 | 1处 | int32_t code → uint32_t bitCode | | 魔法数字→常量 | 1处 | alignas(8) → alignas(L2_CACHE_ALIGNMENT) | | 变量重命名 | 多处 | Kernel侧blockLocCoord→blockLocCoord_等; Host侧index→idx/i | | 参数名拼写修正 | 1处 | rcfCfg→rcsCfg | | include guard | 1处 | matmul_reduce_scatter_v2_tiling_common.h | | 头文件清理 | 3处 | 移除冗余#include | | 未使用参数标记 | 5处 | (void)opType等 | | 注释风格更新 | 大量 | 决策树层级注释从======改为差异化标记 | | 代码格式修复 | 多处 | 空格/缩进/换行 | --- ## 假设检验检视结果 ### 1. 删除未使用函数 ✅ PASS **涉及文件**: matmul_util.cpp, aclnn_matmul_reduce_scatter_v2.cpp 删除5个static函数(CheckShapeValidWithTrans、ProcessEmptyTensor、ProcessEmptyTensorWithTrans、GetMatmulOpInfoWithTrans、CreateWinTensor)。均为static,无跨文件引用风险。 | 规范条款 | 检查项 | 结果 | |---------|--------|------| | cpp-secure 5.2 资源泄露防护 | 删除是否遗漏调用点 | ✅ static函数仅文件内可见 | ### 2. const修饰添加 ✅ PASS **涉及文件**: all_gather_matmul_tiling_base.cpp/.h, quant_all_reduce_tiling.cpp, quant_reduce_scatter_tiling.cpp gert::TilingContext *contextconst gert::TilingContext *context。GetNodeName()、GetAttrPointer()等方法为const兼容,头文件声明同步更新。 | 规范条款 | 检查项 | 结果 | |---------|--------|------| | cpp-secure 1.1 静态类型安全 | const修饰是否导致编译错误 | ✅ 方法兼容const | ### 3. 位操作类型修复 ✅ PASS **涉及文件**: matmul_reduce_scatter_v2_aiv_mode_tiling.cpp int32_t codeuint32_t bitCode。对有符号数做右移(>>=)存在符号扩展问题,改为uint32_t消除风险。 | 规范条款 | 检查项 | 结果 | |---------|--------|------| | cpp-secure 2.1 有符号整数不溢出 | int32_t右移符号扩展 | ✅ 修复正确 | | cpp-secure 2.2 无符号整数不回绕 | uint32_t位操作安全 | ✅ | ### 4. 魔法数字→常量 ✅ PASS **涉及文件**: unquant_matmul_all_reduce_tiling_data.h static constexpr size_t L2_CACHE_ALIGNMENT = 8; 替换 alignas(8)。值等价,不影响ABI。 | 规范条款 | 检查项 | 结果 | |---------|--------|------| | cpp-secure 10.4 结构体字段末尾添加 | 常量定义位置 | ✅ 不影响ABI | ### 5. 冗余变量删除 ✅ PASS **涉及文件**: aclnn_weight_quant_matmul_all_reduce.cpp 删除 const auto x1Dtype = x1->GetDataType(); const auto biasDtype = bias->GetDataType();。两变量后续无引用,OP_CHECK_DTYPE_NOT_SAME宏自行获取dtype。 | 规范条款 | 检查项 | 结果 | |---------|--------|------| | cpp-secure 3.1 禁止未初始化变量 | 删除后功能等价 | ✅ | ### 6. 参数名拼写修正 ✅ PASS **涉及文件**: matmul_reduce_scatter_tiling_base.cpp rcfCfgrcsCfg(RCS=ReduceScatter拼写修正)。所有引用已同步替换。 | 规范条款 | 检查项 | 结果 | |---------|--------|------| | MC2 MC2-13 CCU通信数据量限制 | AdjustHCCLLimit逻辑是否保留 | ✅ 256MB限制保留 | ### 7. include guard添加 ✅ PASS **涉及文件**: matmul_reduce_scatter_v2_tiling_common.h 新增 #ifndef MATMUL_REDUCE_SCATTER_V2_TILING_COMMON_H 保护。命名与文件路径一致。 ### 8. 未使用参数标记 ✅ PASS **涉及文件**: quant_reduce_scatter_util_tiling.cpp 添加 (void)opType; (void)context; (void)xDimNum; (void)outputDim; 消除编译器警告。注释声明"Reserved for future extension"。 | 规范条款 | 检查项 | 结果 | |---------|--------|------| | TOPK TOPK-7 外部输入校验 | 校验逻辑是否削弱 | ✅ 未削弱 | ### 9. LOG参数安全 ✅ PASS **涉及文件**: allto_allv_quant_grouped_mat_mul_tiling_base.cpp 循环变量 indexidx/isendCounts[%lu] should be in [0, %lu], but get %lu — 3个%lu对应3个uint64_t(idx, bsk_, sendCounts[idx]),类型和数量匹配。 | 规范条款 | 检查项 | 结果 | |---------|--------|------| | cpp-secure 11.2 参数数量与占位符匹配 | 3个%lu=3个uint64_t | ✅ | | cpp-secure 11.3 参数类型与格式化说明符匹配 | uint64_t用%lu | ✅ | | MC2 MC2-07 专家参数合法性校验 | sendCounts/recvCounts校验完整 | ✅ | ### 10. 头文件清理 ✅ PASS **涉及文件**: matmul_reduce_scatter_tiling_base.h, quant_reduce_scatter_util_tiling.h, all_gather_matmul_tiling_base.h 移除冗余 #include "ops_utils.h"#include "mc2_log.h"。 --- ## 规范条款引用汇总 | 规范来源 | 条款编号 | 条款名称 | 检查结果 | |---------|---------|---------|---------| | cpp-secure.md | 1.1 | 保证静态类型安全 | ✅ | | cpp-secure.md | 2.1 | 有符号整数运算不溢出 | ✅ | | cpp-secure.md | 2.2 | 无符号整数运算不回绕 | ✅ | | cpp-secure.md | 3.1 | 禁止使用未初始化的变量 | ✅ | | cpp-secure.md | 5.2 | 资源泄露防护 | ✅ | | cpp-secure.md | 10.4 | 结构体字段末尾添加 | ✅ | | cpp-secure.md | 11.2 | LOG参数数量与占位符必须匹配 | ✅ | | cpp-secure.md | 11.3 | LOG参数类型与格式化说明符必须匹配 | ✅ | | mc2-specific.md | MC2-07 | 专家参数合法性校验 | ✅ | | mc2-specific.md | MC2-13 | CCU通信数据量限制 | ✅ | | ascendc-topk.md | TOPK-1 | 必须校验函数返回值 | ✅ | | ascendc-topk.md | TOPK-7 | 融合规则/InferShape/Tiling外部输入校验 | ✅ | --- ## 总体结论 **✅ 无问题** — PR #5489 为代码清理类改动,所有10项检视均PASS。改动不引入安全风险,不削弱校验逻辑,规范合规性100%。 See merge request: cann/ops-transformer!54898 天前
add new ops: all_gather_mamtul_v2、matmul_reduce_scatter_v2;update all_gather_mamtul、matmul_reduce_scatter、matmul_all_reduce、moe_update_expert to support Ascend950 Co-authored-by: cann-robot<songchangxia@cann.team> Co-authored-by: lidongsheng<lidongsheng43@huawei.com> # message auto-generated for no-merge-commit merge: !986 merge develop into master add new ops: all_gather_mamtul_v2、matmul_reduce_scatter_v2;update all_gather_mamtul、matmul_reduce_scatter、matmul_all_reduce、moe_update_expert to support Ascend950 Created-by: qq_46353993 Commit-by: cann-robot;lidongsheng Merged-by: cann-robot Description: ## 描述 支持新算子all_gather_mamtul_v2、matmul_reduce_scatter_v2;all_gather_mamtul、matmul_reduce_scatter、matmul_all_reduce、moe_update_expert支持Ascend950 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-transformer!9863 个月前