Pull Request已成功合入, 合并人@CANN-robot
(感谢 chenfeng 的贡献)以下是根据您提交的修改文件推荐的Reviewer和Committer序列,需各模块评审通过后方可合入
| Module List | Reviewers | Committers |
|---|---|---|
| repo-cann/ops-math | N/A | gubaocheng, loov1, wangrui_, songkai111, zhou-qilong |
| */*/op_api/*.h | N/A | wangyongguang, tang-lei01 |


以下是根据您提交的修改文件推荐的Reviewer和Committer序列,需各模块评审通过后方可合入
| Module List | Reviewers | Committers |
|---|---|---|
| */*/op_api/*.h | N/A | wangyongguang, tang-lei01 |
| repo-cann/ops-math | N/A | songkai111, zhou-qilong, gubaocheng, loov1, wangrui_ |


🔵 source code change are detected, tasks labels is removed in this pull request!


问题/功能描述
本次PR旨在重构并统一平台的硬件架构识别逻辑。原有的实现基于SocVersion进行判断,存在逻辑不一致和依赖过时信息的问题,且难以支持新的硬件架构(如DAV_3510)。本次修改将核心判断逻辑切换为基于更准确的NpuArch枚举类型,为未来架构扩展提供了清晰、统一的接口。
修改方案描述
修改方案的核心是引入NpuArch抽象来替代SocVersion。主要工作包括:1) 在构建配置中新增头文件包含路径以支持新接口。2) 在aclnn_check.h中新增无参数的IsRegBase()函数,用于获取当前运行平台的架构信息。3) 在level2_base.h和tiling_util.cpp中,将原有的GetDtypeSupportListV1/V2/V3及IsRegbaseSocVersion等函数的内部实现,从判断SocVersion改为判断NpuArch,并利用新的IsRegBase(NpuArch)函数。整体上,通过这一重构统一并简化了跨不同硬件平台的数据类型支持列表判断逻辑。


compile


代码结构与可维护性: 代码中存在重复的静态常量定义。第136行和第142行都定义了相同的静态set容器regbaseArch,包含相同的值{NpuArch::DAV_3510}。这种重复违反了DRY(Don't Repeat Yourself)原则,增加了维护成本,如果未来需要修改支持的架构列表,需要在两个地方同时修改,容易遗漏。
问题类型: 代码结构与可维护性
文件路径: common/inc/op_api/aclnn_check.h
行号: 142
问题代码:
const static std::set<NpuArch> regbaseArch = {NpuArch::DAV_3510};
修改建议:
1. 将regbaseArch的定义提取为命名空间级的静态常量,在函数外部定义一次:
static const std::set<NpuArch> kRegBaseArchs = {NpuArch::DAV_3510};
2. 两个函数都引用这个公共常量,避免重复定义。
3. 如果未来需要支持更多架构,只需在一个地方修改。
此评论由代码审查工具自动生成


代码重复: 新增的IsRegBase()函数与已有的IsRegBase(NpuArch arch)函数存在代码重复。两个函数都定义了相同的静态集合regbaseArch = {NpuArch::DAV_3510},这违反了DRY(Don't Repeat Yourself)原则。当需要修改支持的架构列表时,需要在两个地方进行修改,增加了维护成本和出错风险。
问题类型: 代码重复
文件路径: common/inc/op_api/aclnn_check.h
行号: 140
问题代码:
static inline bool IsRegBase()
{
const static std::set<NpuArch> regbaseArch = {NpuArch::DAV_3510};
auto curArch = GetCurrentPlatformInfo().GetCurNpuArch();
return regbaseArch.find(curArch) != regbaseArch.end();
}
修改建议:
建议重构代码,消除重复。可以有以下几种方案:
1. 让无参数的IsRegBase()函数调用有参数的版本:
static inline bool IsRegBase() {
return IsRegBase(GetCurrentPlatformInfo().GetCurNpuArch());
}
2. 将支持的架构集合定义为一个公共的静态常量,供两个函数共享。
3. 如果无参数的版本使用频率更高,可以考虑只保留一个版本,并在需要时通过GetCurrentPlatformInfo().GetCurNpuArch()获取当前架构。
此评论由代码审查工具自动生成


流水线任务触发成功,任务链接 [eedc7da46baa423780808dce9c98b5f9]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| anti_virus | ✅ SUCCESS | >>>>> | |
| Check_Pr | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86 | ❌ FAILED | >>>>> | |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ❌ FAILED | >>>>> | |
| Compile_Ascend_X86_experimental | ❌ FAILED | >>>>> | |
| Compile_Ascend_ARM_experimental | ❌ FAILED | >>>>> | |
| Smoke_A900 | ✅ SUCCESS | >>>>> | >>>>> |
| API_Check | ❌ FAILED | >>>>> | |
| UT_Test | ⚪ ABORTED | ||
| UT_Test_experimental | ⚪ ABORTED |
[2026-01-20 10:33:43] CI执行失败


compile


流水线任务触发成功,任务链接 [6412dc8f15394ffb827cc3918c85c5e6]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| anti_virus | ✅ SUCCESS | >>>>> | |
| Check_Pr | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Smoke_A900 | ✅ SUCCESS | >>>>> | >>>>> |
| API_Check | ❌ FAILED | >>>>> | |
| UT_Test | ⚪ ABORTED | ||
| UT_Test_experimental | ⚪ ABORTED |
[2026-01-20 11:54:22] CI执行失败


compile


流水线任务触发成功,任务链接 [80ff383e5b6d431691f6631e5ff683af]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| codecheck | ✅ SUCCESS | >>>>> | |
| SCA | ✅ SUCCESS | >>>>> | |
| anti_virus | ✅ SUCCESS | >>>>> | |
| Check_Pr | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_experimental | ✅ SUCCESS | >>>>> | >>>>> |
| Smoke_A900 | ✅ SUCCESS | >>>>> | >>>>> |
| API_Check | ✅ SUCCESS | >>>>> | |
| UT_Test | ✅ SUCCESS | ||
| UT_Test_experimental | ✅ SUCCESS |
[2026-01-20 15:14:52] CI执行结束


/approve


/lgtm


/check-pr


The following labels are not ready.
lgtm: Please wait for reviewers to review the code.
approved: Please wait for committers to review the code.


/approve


/check-pr


The following label is not ready.
approved: Please wait for committers to review the code.


/approve


Review Guide
This Pull-Request Passes Review.
Committers who wrote a comment of /approve are: songkai111, zhou-qilong, wangyongguang.
Reviewers who wrote a comment of /lgtm are: zhou-qilong, songkai111, wangyongguang.


描述
关联的Issue
测试
文档更新
类型标签