已合并
soc整改math仓common同步到非dev仓 #802
chenfeng创建于 1月20日
soc整改math仓common同步到非dev仓 #802
已合并
chenfeng创建于 1月20日
chenfeng
chenfeng成员
1月20日

描述

关联的Issue

测试

文档更新

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 chenfeng 的贡献)
CANN-robot
CANN-robot成员
1月20日 评论:

Thank your for your pull-request.

The full list of commands accepted by me can be found at here.

You can get sig-info at here

likedislike
CANN-robot
CANN-robot成员
1月20日 评论:

Thank your for your pull-request.

The full list of commands accepted by me can be found at here.

You can get sig-info at here

likedislike
CANN-robot
CANN-robot成员
1月20日 评论:

以下是根据您提交的修改文件推荐的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
likedislike
CANN-robot
CANN-robot成员
1月20日 评论:

以下是根据您提交的修改文件推荐的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_
likedislike
CANN-robotCANN-robot成员
1月20日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
1月20日 评论:

CLA Signature Pass

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

likedislike
CANN-robot
CANN-robot成员
1月20日 评论:

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

likedislike
CANN-robot
CANN-robot成员
1月20日 评论:

问题/功能描述

本次PR旨在重构并统一平台的硬件架构识别逻辑。原有的实现基于SocVersion进行判断,存在逻辑不一致和依赖过时信息的问题,且难以支持新的硬件架构(如DAV_3510)。本次修改将核心判断逻辑切换为基于更准确的NpuArch枚举类型,为未来架构扩展提供了清晰、统一的接口。

修改方案描述

修改方案的核心是引入NpuArch抽象来替代SocVersion。主要工作包括:1) 在构建配置中新增头文件包含路径以支持新接口。2) 在aclnn_check.h中新增无参数的IsRegBase()函数,用于获取当前运行平台的架构信息。3) 在level2_base.htiling_util.cpp中,将原有的GetDtypeSupportListV1/V2/V3IsRegbaseSocVersion等函数的内部实现,从判断SocVersion改为判断NpuArch,并利用新的IsRegBase(NpuArch)函数。整体上,通过这一重构统一并简化了跨不同硬件平台的数据类型支持列表判断逻辑。

likedislike
chenfeng
chenfeng成员
1月20日 评论:

compile

likedislike
CANN-robot
CANN-robot成员1月20日进行代码检视1
common/inc/op_api/aclnn_check.h
@@ -140,2 +145,4 @@
145+ 
140146} // namespace op
141147#endif
CANN-robot
CANN-robot1月20日评论:

代码结构与可维护性: 代码中存在重复的静态常量定义。第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. 如果未来需要支持更多架构,只需在一个地方修改。

此评论由代码审查工具自动生成

likedislike
CANN-robot
CANN-robot成员1月20日进行代码检视1
common/inc/op_api/aclnn_check.h
@@ -137,5 +137,12 @@ static inline bool IsRegBase(NpuArch arch)
137137 return regbaseArch.find(arch) != regbaseArch.end();
138138}
139139 
140+static inline bool IsRegBase()
CANN-robot
CANN-robot1月20日评论:

代码重复: 新增的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()获取当前架构。

此评论由代码审查工具自动生成

likedislike
CANN-robotCANN-robot成员
1月20日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
1月20日 评论:

流水线任务触发成功,任务链接 [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执行失败

likedislike
CANN-robotCANN-robot成员
1月20日 添加了label:AscendC-SUCC
CANN-robotCANN-robot成员
1月20日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
1月20日 添加了label:ci-pipeline-failed
chenfeng
chenfeng成员
1月20日 评论:

compile

likedislike
CANN-robotCANN-robot成员
1月20日 删除了label:ci-pipeline-failed
CANN-robotCANN-robot成员
1月20日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
1月20日 评论:

流水线任务触发成功,任务链接 [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执行失败

likedislike
CANN-robotCANN-robot成员
1月20日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
1月20日 添加了label:ci-pipeline-failed
chenfeng
chenfeng成员
1月20日 评论:

compile

likedislike
CANN-robotCANN-robot成员
1月20日 删除了label:ci-pipeline-failed
CANN-robotCANN-robot成员
1月20日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
1月20日 评论:

流水线任务触发成功,任务链接 [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执行结束

likedislike
CANN-robotCANN-robot成员
1月20日 添加了label:api-check-pass
此处折叠了5条事件消息 查看更多
CANN-robotCANN-robot成员
1月20日 添加了label:ci-pipeline-passed
songkai111成员
1月20日 评论:

/approve

likedislike
wei-peng-1991成员
1月20日 评论:

/lgtm

likedislike
chenfeng
chenfeng成员
1月20日 评论:

/check-pr

likedislike
CANN-robot
CANN-robot成员
1月20日 评论:

The following labels are not ready.

lgtm: Please wait for reviewers to review the code.

approved: Please wait for committers to review the code.

likedislike
sunday成员
1月20日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
1月20日 添加了label:lgtm
chenfengchenfeng成员
1月20日 解决了最后一个问题
songkai111成员
1月20日 评论:

/approve

likedislike
chenfeng
chenfeng成员
1月20日 评论:

/check-pr

likedislike
CANN-robot
CANN-robot成员
1月20日 评论:

The following label is not ready.

approved: Please wait for committers to review the code.

likedislike
wangyongguang成员
1月20日 评论:

/approve

likedislike
CANN-robotCANN-robot成员
1月20日 添加了label:approved
CANN-robot
CANN-robot成员
1月20日 评论:

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.

likedislike
CANN-robotCANN-robot成员
1月20日 合入了pull request