已合并
add logit A5 #1097
LSYlsy0214创建于 1月28日
add logit A5 #1097
已合并
LSYlsy0214创建于 1月28日
5 个文件变更+118-2
@@ -0,0 +1,113 @@
1+{
2+ "op_type": "Logit",
3+ "op_list": [
4+ {
5+ "bin_filename": "Logit_089252cb34d0fed19df572552264c236",
6+ "inputs": [
7+ {
8+ "name": "input",
9+ "index": 0,
10+ "dtype": "bfloat16",
11+ "format": "ND",
12+ "paramType": "required",
13+ "shape": [
14+ -2
15+ ],
16+ "format_match_mode": "FormatAgnostic"
17+ }
18+ ],
19+ "outputs": [
20+ {
21+ "name": "output",
22+ "index": 0,
23+ "dtype": "bfloat16",
24+ "format": "ND",
25+ "paramType": "required",
26+ "shape": [
27+ -2
28+ ],
29+ "format_match_mode": "FormatAgnostic"
30+ }
31+ ],
32+ "attrs": [
33+ {
34+ "name": "eps",
35+ "dtype": "float",
36+ "value": 0.0
37+ }
38+ ]
39+ },
40+ {
41+ "bin_filename": "Logit_d54603fcb2b294656d0ea51ac8dd0265",
42+ "inputs": [
43+ {
44+ "name": "input",
45+ "index": 0,
46+ "dtype": "float32",
47+ "format": "ND",
48+ "paramType": "required",
49+ "shape": [
50+ -2
51+ ],
52+ "format_match_mode": "FormatAgnostic"
53+ }
54+ ],
55+ "outputs": [
56+ {
57+ "name": "output",
58+ "index": 0,
59+ "dtype": "float32",
60+ "format": "ND",
61+ "paramType": "required",
62+ "shape": [
63+ -2
64+ ],
65+ "format_match_mode": "FormatAgnostic"
66+ }
67+ ],
68+ "attrs": [
69+ {
70+ "name": "eps",
71+ "dtype": "float",
72+ "value": 0.0
73+ }
74+ ]
75+ },
76+ {
77+ "bin_filename": "Logit_ed4a2eb7d3d42daf7b2dff60e7014fda",
78+ "inputs": [
79+ {
80+ "name": "input",
81+ "index": 0,
82+ "dtype": "float16",
83+ "format": "ND",
84+ "paramType": "required",
85+ "shape": [
86+ -2
87+ ],
88+ "format_match_mode": "FormatAgnostic"
89+ }
90+ ],
91+ "outputs": [
92+ {
93+ "name": "output",
94+ "index": 0,
95+ "dtype": "float16",
96+ "format": "ND",
97+ "paramType": "required",
98+ "shape": [
99+ -2
100+ ],
101+ "format_match_mode": "FormatAgnostic"
102+ }
103+ ],
104+ "attrs": [
105+ {
106+ "name": "eps",
107+ "dtype": "float",
108+ "value": 0.0
109+ }
110+ ]
111+ }
112+ ]
113+ }
@@ -0,0 +1,2 @@
1+[Logit]
2+default=0
@@ -39,6 +39,7 @@ public:
39 39 
40 this->AICore().AddConfig("ascend910b");40 this->AICore().AddConfig("ascend910b");
41 this->AICore().AddConfig("ascend910_93");41 this->AICore().AddConfig("ascend910_93");
42+ this->AICore().AddConfig("ascend910_95");
CANN-robot
CANN-robotCANN-robot1月28日

代码结构与可维护性: 新增的配置项 'ascend910_95' 与现有配置项 'ascend910_93' 在命名上存在不一致性,缺乏明确的语义解释。'ascend910_93' 和 'ascend910_95' 看起来像是特定芯片型号或版本的内部代号,但未在代码中提供任何注释说明其含义、区别或使用场景。这种使用未解释的魔数(此处为字符串魔数)作为配置标识符的做法,降低了代码的可读性和可维护性,增加了后续维护人员理解代码意图的难度。

问题类型: 代码结构与可维护性 文件路径: loss/logit/op_host/logit_def.cpp 行号: 42 问题代码:

this->AICore().AddConfig("ascend910_95");

修改建议:

1. 为这些配置字符串定义有意义的命名常量,并添加清晰的注释说明每个配置对应的具体硬件型号、架构版本或特性支持。例如:
   constexpr const char* kConfigAscend910B = "ascend910b";
   constexpr const char* kConfigAscend910V93 = "ascend910_93"; // 注释:Ascend 910, version 9.3
   constexpr const char* kConfigAscend910V95 = "ascend910_95"; // 注释:Ascend 910, version 9.5
   然后在代码中使用这些常量。
2. 如果这些配置项有特定的依赖关系或使用限制,应在注释中一并说明。
3. 考虑是否需要一个集中的配置定义文件来管理所有AICore支持的配置,以提高一致性和可维护性。

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

likedislike
42 }43 }
43};44};
44 45 
@@ -24,7 +24,7 @@ extern "C" __global__ __aicore__ void logit(GM_ADDR input, GM_ADDR output, GM_AD
24 24 
25 GM_ADDR userWs = nullptr;25 GM_ADDR userWs = nullptr;
26 26 
27-#if __CCE_AICORE__ == 220 || (defined(__NPU_ARCH__) && __NPU_ARCH__ == 3003)27+#if __CCE_AICORE__ == 220 || __CCE_AICORE__ == 310 || (defined(__NPU_ARCH__) && __NPU_ARCH__ == 3003)
28 if (TILING_KEY_IS(1)) {28 if (TILING_KEY_IS(1)) {
29 LogitND<half> op;29 LogitND<half> op;
30 op.Init(input, output, userWs, &tilingData);30 op.Init(input, output, userWs, &tilingData);
@@ -222,7 +222,7 @@
222 {"name":"ForeachMaximumScalarList", "compute_units": ["ascend910b", "ascend910_95", "kirinx90"], "auto_sync" : false},222 {"name":"ForeachMaximumScalarList", "compute_units": ["ascend910b", "ascend910_95", "kirinx90"], "auto_sync" : false},
223 {"name":"ForeachMinimumScalar", "compute_units": ["ascend910b", "ascend910_95", "kirinx90"], "auto_sync" : false},223 {"name":"ForeachMinimumScalar", "compute_units": ["ascend910b", "ascend910_95", "kirinx90"], "auto_sync" : false},
224 {"name":"ForeachMinimumScalarList", "compute_units": ["ascend910b", "ascend910_95", "kirinx90"], "auto_sync" : false},224 {"name":"ForeachMinimumScalarList", "compute_units": ["ascend910b", "ascend910_95", "kirinx90"], "auto_sync" : false},
225- {"name":"Logit", "compute_units": ["ascend910b", "ascend910_93"], "auto_sync" : false},225+ {"name":"Logit", "compute_units": ["ascend910b", "ascend910_93", "ascend910_95"], "auto_sync" : false},
226 {"name":"LogitGrad", "compute_units": ["ascend910b", "ascend910_93"], "auto_sync" : false},226 {"name":"LogitGrad", "compute_units": ["ascend910b", "ascend910_93"], "auto_sync" : false},
227 {"name":"SquaredRelu", "compute_units": ["ascend910b", "ascend910_93", "kirinx90"], "auto_sync" : false},227 {"name":"SquaredRelu", "compute_units": ["ascend910b", "ascend910_93", "kirinx90"], "auto_sync" : false},
228 {"name": "HardSwishGradV2", "compute_units": ["ascend910b", "ascend910_93", "ascend910"], "auto_sync": false},228 {"name": "HardSwishGradV2", "compute_units": ["ascend910b", "ascend910_93", "ascend910"], "auto_sync": false},