已合并
add argmax(min)withvalue attr for dtype #1049
add argmax(min)withvalue attr for dtype #1049
已合并
lu-yukun创建于 1月31日
10 个文件变更+492-2
@@ -53,6 +53,7 @@ public:
53 .DataType(argMaxYDataType)53 .DataType(argMaxYDataType)
54 .Format(argMaxFormat)54 .Format(argMaxFormat)
55 .UnknownShapeFormat(argMaxFormat);55 .UnknownShapeFormat(argMaxFormat);
56+ this->Attr("dtype").AttrType(OPTIONAL).Int(3);
56 57 
57 OpAICoreConfig aicore_config;58 OpAICoreConfig aicore_config;
58 aicore_config.DynamicCompileStaticFlag(true)59 aicore_config.DynamicCompileStaticFlag(true)
@@ -39,6 +39,13 @@
39 ],39 ],
40 "format_match_mode": "FormatAgnostic"40 "format_match_mode": "FormatAgnostic"
41 }41 }
42+ ],
43+ "attrs": [
44+ {
45+ "name": "dtype",
46+ "dtype": "int",
47+ "value": 3
48+ }
42 ]49 ]
43 },50 },
44 {51 {
@@ -79,6 +86,13 @@
79 ],86 ],
80 "format_match_mode": "FormatAgnostic"87 "format_match_mode": "FormatAgnostic"
81 }88 }
89+ ],
90+ "attrs": [
91+ {
92+ "name": "dtype",
93+ "dtype": "int",
94+ "value": 3
95+ }
82 ]96 ]
83 },97 },
84 {98 {
@@ -119,6 +133,13 @@
119 ],133 ],
120 "format_match_mode": "FormatAgnostic"134 "format_match_mode": "FormatAgnostic"
121 }135 }
136+ ],
137+ "attrs": [
138+ {
139+ "name": "dtype",
140+ "dtype": "int",
141+ "value": 3
142+ }
122 ]143 ]
123 },144 },
124 {145 {
@@ -159,6 +180,13 @@
159 ],180 ],
160 "format_match_mode": "FormatAgnostic"181 "format_match_mode": "FormatAgnostic"
161 }182 }
183+ ],
184+ "attrs": [
185+ {
186+ "name": "dtype",
187+ "dtype": "int",
188+ "value": 3
189+ }
162 ]190 ]
163 },191 },
164 {192 {
@@ -199,6 +227,13 @@
199 ],227 ],
200 "format_match_mode": "FormatAgnostic"228 "format_match_mode": "FormatAgnostic"
201 }229 }
230+ ],
231+ "attrs": [
232+ {
233+ "name": "dtype",
234+ "dtype": "int",
235+ "value": 3
236+ }
202 ]237 ]
203 },238 },
204 {239 {
@@ -239,6 +274,13 @@
239 ],274 ],
240 "format_match_mode": "FormatAgnostic"275 "format_match_mode": "FormatAgnostic"
241 }276 }
277+ ],
278+ "attrs": [
279+ {
280+ "name": "dtype",
281+ "dtype": "int",
282+ "value": 3
283+ }
242 ]284 ]
243 },285 },
244 {286 {
@@ -279,6 +321,13 @@
279 ],321 ],
280 "format_match_mode": "FormatAgnostic"322 "format_match_mode": "FormatAgnostic"
281 }323 }
324+ ],
325+ "attrs": [
326+ {
327+ "name": "dtype",
328+ "dtype": "int",
329+ "value": 3
330+ }
282 ]331 ]
283 },332 },
284 {333 {
@@ -319,6 +368,13 @@
319 ],368 ],
320 "format_match_mode": "FormatAgnostic"369 "format_match_mode": "FormatAgnostic"
321 }370 }
371+ ],
372+ "attrs": [
373+ {
374+ "name": "dtype",
375+ "dtype": "int",
376+ "value": 3
377+ }
322 ]378 ]
323 },379 },
324 {380 {
@@ -359,6 +415,13 @@
359 ],415 ],
360 "format_match_mode": "FormatAgnostic"416 "format_match_mode": "FormatAgnostic"
361 }417 }
418+ ],
419+ "attrs": [
420+ {
421+ "name": "dtype",
422+ "dtype": "int",
423+ "value": 3
424+ }
362 ]425 ]
363 },426 },
364 {427 {
@@ -399,6 +462,13 @@
399 ],462 ],
400 "format_match_mode": "FormatAgnostic"463 "format_match_mode": "FormatAgnostic"
401 }464 }
465+ ],
466+ "attrs": [
467+ {
468+ "name": "dtype",
469+ "dtype": "int",
470+ "value": 3
471+ }
402 ]472 ]
403 },473 },
404 {474 {
@@ -439,6 +509,13 @@
439 ],509 ],
440 "format_match_mode": "FormatAgnostic"510 "format_match_mode": "FormatAgnostic"
441 }511 }
512+ ],
513+ "attrs": [
514+ {
515+ "name": "dtype",
516+ "dtype": "int",
517+ "value": 3
518+ }
442 ]519 ]
443 },520 },
444 {521 {
@@ -479,6 +556,13 @@
479 ],556 ],
480 "format_match_mode": "FormatAgnostic"557 "format_match_mode": "FormatAgnostic"
481 }558 }
559+ ],
560+ "attrs": [
561+ {
562+ "name": "dtype",
563+ "dtype": "int",
564+ "value": 3
565+ }
482 ]566 ]
483 },567 },
484 {568 {
@@ -519,6 +603,13 @@
519 ],603 ],
520 "format_match_mode": "FormatAgnostic"604 "format_match_mode": "FormatAgnostic"
521 }605 }
606+ ],
607+ "attrs": [
608+ {
609+ "name": "dtype",
610+ "dtype": "int",
611+ "value": 3
612+ }
522 ]613 ]
523 },614 },
524 {615 {
@@ -559,6 +650,13 @@
559 ],650 ],
560 "format_match_mode": "FormatAgnostic"651 "format_match_mode": "FormatAgnostic"
561 }652 }
653+ ],
654+ "attrs": [
655+ {
656+ "name": "dtype",
657+ "dtype": "int",
658+ "value": 3
659+ }
562 ]660 ]
563 },661 },
564 {662 {
@@ -599,6 +697,13 @@
599 ],697 ],
600 "format_match_mode": "FormatAgnostic"698 "format_match_mode": "FormatAgnostic"
601 }699 }
700+ ],
701+ "attrs": [
702+ {
703+ "name": "dtype",
704+ "dtype": "int",
705+ "value": 3
706+ }
602 ]707 ]
603 },708 },
604 {709 {
@@ -639,6 +744,13 @@
639 ],744 ],
640 "format_match_mode": "FormatAgnostic"745 "format_match_mode": "FormatAgnostic"
641 }746 }
747+ ],
748+ "attrs": [
749+ {
750+ "name": "dtype",
751+ "dtype": "int",
752+ "value": 3
753+ }
642 ]754 ]
643 },755 },
644 {756 {
@@ -679,6 +791,13 @@
679 ],791 ],
680 "format_match_mode": "FormatAgnostic"792 "format_match_mode": "FormatAgnostic"
681 }793 }
794+ ],
795+ "attrs": [
796+ {
797+ "name": "dtype",
798+ "dtype": "int",
799+ "value": 3
800+ }
682 ]801 ]
683 },802 },
684 {803 {
@@ -719,6 +838,13 @@
719 ],838 ],
720 "format_match_mode": "FormatAgnostic"839 "format_match_mode": "FormatAgnostic"
721 }840 }
841+ ],
842+ "attrs": [
843+ {
844+ "name": "dtype",
845+ "dtype": "int",
846+ "value": 3
847+ }
722 ]848 ]
723 },849 },
724 {850 {
@@ -759,6 +885,13 @@
759 ],885 ],
760 "format_match_mode": "FormatAgnostic"886 "format_match_mode": "FormatAgnostic"
761 }887 }
888+ ],
889+ "attrs": [
890+ {
891+ "name": "dtype",
892+ "dtype": "int",
893+ "value": 3
894+ }
762 ]895 ]
763 },896 },
764 {897 {
@@ -799,6 +932,13 @@
799 ],932 ],
800 "format_match_mode": "FormatAgnostic"933 "format_match_mode": "FormatAgnostic"
801 }934 }
935+ ],
936+ "attrs": [
937+ {
938+ "name": "dtype",
939+ "dtype": "int",
940+ "value": 3
941+ }
802 ]942 ]
803 }943 }
804 ]944 ]
@@ -32,7 +32,8 @@ namespace ge {
32*@li dimension: An integer of type int32, specifying the axis information of32*@li dimension: An integer of type int32, specifying the axis information of
33* the index with the maximum value. Required and no default value.33* the index with the maximum value. Required and no default value.
34*@li keep_dims: A bool, specifying whether to keep dimensions for the output34*@li keep_dims: A bool, specifying whether to keep dimensions for the output
35-* tensor. Optional and defaults to "false". \n35+* tensor. Optional and defaults to "false".
36+*@li indice_dtype: A Type, The output type, either "int32" or "int64". Defaults to "int32". \n
36 37 
37*@par Outputs:38*@par Outputs:
38* @li indice: A multi-dimensional tensor of type int32 or int64, specifying the index.39* @li indice: A multi-dimensional tensor of type int32 or int64, specifying the index.
@@ -58,6 +59,7 @@ REG_OP(ArgMaxWithValue)
58 .OUTPUT(values, TensorType({DT_FLOAT, DT_FLOAT16, DT_BF16, DT_INT64, DT_INT32}))59 .OUTPUT(values, TensorType({DT_FLOAT, DT_FLOAT16, DT_BF16, DT_INT64, DT_INT32}))
59 .REQUIRED_ATTR(dimension, Int)60 .REQUIRED_ATTR(dimension, Int)
60 .ATTR(keep_dims, Bool, false)61 .ATTR(keep_dims, Bool, false)
62+ .ATTR(indice_dtype, Type, DT_INT32)
CANN-robot
CANN-robotCANN-robot1月31日

代码结构与可维护性: 新增的 indice_dtype 属性与文档描述存在不一致。文档第38行明确说明 indice 输出是 'A multi-dimensional tensor of type int32 or int64',这表明输出数据类型应由计算决定或用户通过其他方式指定。然而,新增的属性 indice_dtype 是一个可选的属性(默认值为 DT_INT32),这允许用户在运行时指定索引输出的数据类型。这种设计可能导致以下问题:1. 文档未更新以反映此用户可配置的行为,造成文档与实现脱节。2. 如果用户设置了一个与输入张量 x 的数据类型不兼容的 indice_dtype(例如,x 为浮点型,indice_dtype 设置为 DT_INT64 是合理的,但若设置为 DT_FLOAT 则逻辑矛盾),算子实现需要处理这种无效配置,增加了复杂性。3. 属性名 indice_dtype 与输出名 indice 略有拼写差异('indice' vs 'indices' 常见复数形式),虽不影响功能但可能影响命名一致性。

问题类型: 代码结构与可维护性 文件路径: math/arg_max_with_value/op_graph/arg_max_with_value_proto.h 行号: 61 问题代码:

.ATTR(indice_dtype, Type, DT_INT32)

修改建议:

1. 同步更新代码头部注释中的 '@par Outputs' 部分,明确说明 `indice` 的数据类型可以通过 `indice_dtype` 属性进行指定,并说明其可选性及默认值。例如:'@li indice: A multi-dimensional tensor of type int32 or int64, specifying the index. The data type can be specified by the "indice_dtype" attribute (defaults to DT_INT32).' 2. 考虑在算子实现层面对 `indice_dtype` 的取值进行有效性校验,仅允许 DT_INT32 或 DT_INT64,并在文档中明确说明,以避免无效配置。3. 评估属性命名,考虑是否使用更常见的复数形式 `indices_dtype` 以保持与输出名称更好的对应关系(如果输出名 `indice` 是既定且不可更改的,则此点可忽略)。

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

likedislike
61 .OP_END_FACTORY_REG(ArgMaxWithValue)63 .OP_END_FACTORY_REG(ArgMaxWithValue)
62 64 
63} // namespace ge65} // namespace ge
@@ -43,6 +43,8 @@ public:
43 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,43 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,
44 ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});44 ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});
45 this->Attr("dimension").AttrType(REQUIRED).Int();45 this->Attr("dimension").AttrType(REQUIRED).Int();
46+ this->Attr("keep_dims").AttrType(OPTIONAL).Bool(false);
47+ this->Attr("indice_dtype").AttrType(OPTIONAL).Int(3);
46 48
47 OpAICoreConfig aicore_config; 49 OpAICoreConfig aicore_config;
48 aicore_config.DynamicCompileStaticFlag(true)50 aicore_config.DynamicCompileStaticFlag(true)
@@ -45,6 +45,16 @@
45 "name": "dimension",45 "name": "dimension",
46 "dtype": "int",46 "dtype": "int",
47 "value": 047 "value": 0
48+ },
49+ {
50+ "name": "keep_dims",
51+ "dtype": "bool",
52+ "value": null
53+ },
54+ {
55+ "name": "indice_dtype",
56+ "dtype": "int",
57+ "value": 3
48 }58 }
49 ]59 ]
50 },60 },
@@ -92,6 +102,16 @@
92 "name": "dimension",102 "name": "dimension",
93 "dtype": "int",103 "dtype": "int",
94 "value": 0104 "value": 0
105+ },
106+ {
107+ "name": "keep_dims",
108+ "dtype": "bool",
109+ "value": null
110+ },
111+ {
112+ "name": "indice_dtype",
113+ "dtype": "int",
114+ "value": 3
95 }115 }
96 ]116 ]
97 },117 },
@@ -139,6 +159,16 @@
139 "name": "dimension",159 "name": "dimension",
140 "dtype": "int",160 "dtype": "int",
141 "value": 0161 "value": 0
162+ },
163+ {
164+ "name": "keep_dims",
165+ "dtype": "bool",
166+ "value": null
167+ },
168+ {
169+ "name": "indice_dtype",
170+ "dtype": "int",
171+ "value": 3
142 }172 }
143 ]173 ]
144 },174 },
@@ -186,6 +216,16 @@
186 "name": "dimension",216 "name": "dimension",
187 "dtype": "int",217 "dtype": "int",
188 "value": 0218 "value": 0
219+ },
220+ {
221+ "name": "keep_dims",
222+ "dtype": "bool",
223+ "value": null
224+ },
225+ {
226+ "name": "indice_dtype",
227+ "dtype": "int",
228+ "value": 3
189 }229 }
190 ]230 ]
191 },231 },
@@ -233,6 +273,16 @@
233 "name": "dimension",273 "name": "dimension",
234 "dtype": "int",274 "dtype": "int",
235 "value": 0275 "value": 0
276+ },
277+ {
278+ "name": "keep_dims",
279+ "dtype": "bool",
280+ "value": null
281+ },
282+ {
283+ "name": "indice_dtype",
284+ "dtype": "int",
285+ "value": 3
236 }286 }
237 ]287 ]
238 },288 },
@@ -280,6 +330,16 @@
280 "name": "dimension",330 "name": "dimension",
281 "dtype": "int",331 "dtype": "int",
282 "value": 0332 "value": 0
333+ },
334+ {
335+ "name": "keep_dims",
336+ "dtype": "bool",
337+ "value": null
338+ },
339+ {
340+ "name": "indice_dtype",
341+ "dtype": "int",
342+ "value": 3
283 }343 }
284 ]344 ]
285 },345 },
@@ -327,6 +387,16 @@
327 "name": "dimension",387 "name": "dimension",
328 "dtype": "int",388 "dtype": "int",
329 "value": 0389 "value": 0
390+ },
391+ {
392+ "name": "keep_dims",
393+ "dtype": "bool",
394+ "value": null
395+ },
396+ {
397+ "name": "indice_dtype",
398+ "dtype": "int",
399+ "value": 3
330 }400 }
331 ]401 ]
332 },402 },
@@ -374,6 +444,16 @@
374 "name": "dimension",444 "name": "dimension",
375 "dtype": "int",445 "dtype": "int",
376 "value": 0446 "value": 0
447+ },
448+ {
449+ "name": "keep_dims",
450+ "dtype": "bool",
451+ "value": null
452+ },
453+ {
454+ "name": "indice_dtype",
455+ "dtype": "int",
456+ "value": 3
377 }457 }
378 ]458 ]
379 },459 },
@@ -421,6 +501,16 @@
421 "name": "dimension",501 "name": "dimension",
422 "dtype": "int",502 "dtype": "int",
423 "value": 0503 "value": 0
504+ },
505+ {
506+ "name": "keep_dims",
507+ "dtype": "bool",
508+ "value": null
509+ },
510+ {
511+ "name": "indice_dtype",
512+ "dtype": "int",
513+ "value": 3
424 }514 }
425 ]515 ]
426 },516 },
@@ -468,6 +558,16 @@
468 "name": "dimension",558 "name": "dimension",
469 "dtype": "int",559 "dtype": "int",
470 "value": 0560 "value": 0
561+ },
562+ {
563+ "name": "keep_dims",
564+ "dtype": "bool",
565+ "value": null
566+ },
567+ {
568+ "name": "indice_dtype",
569+ "dtype": "int",
570+ "value": 3
471 }571 }
472 ]572 ]
473 }573 }
@@ -53,6 +53,7 @@ public:
53 .DataType(argMinYDataType)53 .DataType(argMinYDataType)
54 .Format(argMinormat)54 .Format(argMinormat)
55 .UnknownShapeFormat(argMinormat);55 .UnknownShapeFormat(argMinormat);
56+ this->Attr("dtype").AttrType(OPTIONAL).Int(3);
56 57 
57 OpAICoreConfig aicore_config;58 OpAICoreConfig aicore_config;
58 aicore_config.DynamicCompileStaticFlag(true)59 aicore_config.DynamicCompileStaticFlag(true)
@@ -39,6 +39,13 @@
39 ],39 ],
40 "format_match_mode": "FormatAgnostic"40 "format_match_mode": "FormatAgnostic"
41 }41 }
42+ ],
43+ "attrs": [
44+ {
45+ "name": "dtype",
46+ "dtype": "int",
47+ "value": 3
48+ }
42 ]49 ]
43 },50 },
44 {51 {
@@ -79,6 +86,13 @@
79 ],86 ],
80 "format_match_mode": "FormatAgnostic"87 "format_match_mode": "FormatAgnostic"
81 }88 }
89+ ],
90+ "attrs": [
91+ {
92+ "name": "dtype",
93+ "dtype": "int",
94+ "value": 3
95+ }
82 ]96 ]
83 },97 },
84 {98 {
@@ -119,6 +133,13 @@
119 ],133 ],
120 "format_match_mode": "FormatAgnostic"134 "format_match_mode": "FormatAgnostic"
121 }135 }
136+ ],
137+ "attrs": [
138+ {
139+ "name": "dtype",
140+ "dtype": "int",
141+ "value": 3
142+ }
122 ]143 ]
123 },144 },
124 {145 {
@@ -159,6 +180,13 @@
159 ],180 ],
160 "format_match_mode": "FormatAgnostic"181 "format_match_mode": "FormatAgnostic"
161 }182 }
183+ ],
184+ "attrs": [
185+ {
186+ "name": "dtype",
187+ "dtype": "int",
188+ "value": 3
189+ }
162 ]190 ]
163 },191 },
164 {192 {
@@ -199,6 +227,13 @@
199 ],227 ],
200 "format_match_mode": "FormatAgnostic"228 "format_match_mode": "FormatAgnostic"
201 }229 }
230+ ],
231+ "attrs": [
232+ {
233+ "name": "dtype",
234+ "dtype": "int",
235+ "value": 3
236+ }
202 ]237 ]
203 },238 },
204 {239 {
@@ -239,6 +274,13 @@
239 ],274 ],
240 "format_match_mode": "FormatAgnostic"275 "format_match_mode": "FormatAgnostic"
241 }276 }
277+ ],
278+ "attrs": [
279+ {
280+ "name": "dtype",
281+ "dtype": "int",
282+ "value": 3
283+ }
242 ]284 ]
243 },285 },
244 {286 {
@@ -279,6 +321,13 @@
279 ],321 ],
280 "format_match_mode": "FormatAgnostic"322 "format_match_mode": "FormatAgnostic"
281 }323 }
324+ ],
325+ "attrs": [
326+ {
327+ "name": "dtype",
328+ "dtype": "int",
329+ "value": 3
330+ }
282 ]331 ]
283 },332 },
284 {333 {
@@ -319,6 +368,13 @@
319 ],368 ],
320 "format_match_mode": "FormatAgnostic"369 "format_match_mode": "FormatAgnostic"
321 }370 }
371+ ],
372+ "attrs": [
373+ {
374+ "name": "dtype",
375+ "dtype": "int",
376+ "value": 3
377+ }
322 ]378 ]
323 },379 },
324 {380 {
@@ -359,6 +415,13 @@
359 ],415 ],
360 "format_match_mode": "FormatAgnostic"416 "format_match_mode": "FormatAgnostic"
361 }417 }
418+ ],
419+ "attrs": [
420+ {
421+ "name": "dtype",
422+ "dtype": "int",
423+ "value": 3
424+ }
362 ]425 ]
363 },426 },
364 {427 {
@@ -399,6 +462,13 @@
399 ],462 ],
400 "format_match_mode": "FormatAgnostic"463 "format_match_mode": "FormatAgnostic"
401 }464 }
465+ ],
466+ "attrs": [
467+ {
468+ "name": "dtype",
469+ "dtype": "int",
470+ "value": 3
471+ }
402 ]472 ]
403 },473 },
404 {474 {
@@ -439,6 +509,13 @@
439 ],509 ],
440 "format_match_mode": "FormatAgnostic"510 "format_match_mode": "FormatAgnostic"
441 }511 }
512+ ],
513+ "attrs": [
514+ {
515+ "name": "dtype",
516+ "dtype": "int",
517+ "value": 3
518+ }
442 ]519 ]
443 },520 },
444 {521 {
@@ -479,6 +556,13 @@
479 ],556 ],
480 "format_match_mode": "FormatAgnostic"557 "format_match_mode": "FormatAgnostic"
481 }558 }
559+ ],
560+ "attrs": [
561+ {
562+ "name": "dtype",
563+ "dtype": "int",
564+ "value": 3
565+ }
482 ]566 ]
483 },567 },
484 {568 {
@@ -519,6 +603,13 @@
519 ],603 ],
520 "format_match_mode": "FormatAgnostic"604 "format_match_mode": "FormatAgnostic"
521 }605 }
606+ ],
607+ "attrs": [
608+ {
609+ "name": "dtype",
610+ "dtype": "int",
611+ "value": 3
612+ }
522 ]613 ]
523 },614 },
524 {615 {
@@ -559,6 +650,13 @@
559 ],650 ],
560 "format_match_mode": "FormatAgnostic"651 "format_match_mode": "FormatAgnostic"
561 }652 }
653+ ],
654+ "attrs": [
655+ {
656+ "name": "dtype",
657+ "dtype": "int",
658+ "value": 3
659+ }
562 ]660 ]
563 },661 },
564 {662 {
@@ -599,6 +697,13 @@
599 ],697 ],
600 "format_match_mode": "FormatAgnostic"698 "format_match_mode": "FormatAgnostic"
601 }699 }
700+ ],
701+ "attrs": [
702+ {
703+ "name": "dtype",
704+ "dtype": "int",
705+ "value": 3
706+ }
602 ]707 ]
603 },708 },
604 {709 {
@@ -639,6 +744,13 @@
639 ],744 ],
640 "format_match_mode": "FormatAgnostic"745 "format_match_mode": "FormatAgnostic"
641 }746 }
747+ ],
748+ "attrs": [
749+ {
750+ "name": "dtype",
751+ "dtype": "int",
752+ "value": 3
753+ }
642 ]754 ]
643 },755 },
644 {756 {
@@ -679,6 +791,13 @@
679 ],791 ],
680 "format_match_mode": "FormatAgnostic"792 "format_match_mode": "FormatAgnostic"
681 }793 }
794+ ],
795+ "attrs": [
796+ {
797+ "name": "dtype",
798+ "dtype": "int",
799+ "value": 3
800+ }
682 ]801 ]
683 },802 },
684 {803 {
@@ -719,6 +838,13 @@
719 ],838 ],
720 "format_match_mode": "FormatAgnostic"839 "format_match_mode": "FormatAgnostic"
721 }840 }
841+ ],
842+ "attrs": [
843+ {
844+ "name": "dtype",
845+ "dtype": "int",
846+ "value": 3
847+ }
722 ]848 ]
723 },849 },
724 {850 {
@@ -759,6 +885,13 @@
759 ],885 ],
760 "format_match_mode": "FormatAgnostic"886 "format_match_mode": "FormatAgnostic"
761 }887 }
888+ ],
889+ "attrs": [
890+ {
891+ "name": "dtype",
892+ "dtype": "int",
893+ "value": 3
894+ }
762 ]895 ]
763 },896 },
764 {897 {
@@ -799,6 +932,13 @@
799 ],932 ],
800 "format_match_mode": "FormatAgnostic"933 "format_match_mode": "FormatAgnostic"
801 }934 }
935+ ],
936+ "attrs": [
937+ {
938+ "name": "dtype",
939+ "dtype": "int",
940+ "value": 3
941+ }
802 ]942 ]
803 }943 }
804 ]944 ]
@@ -33,7 +33,8 @@ namespace ge {
33*@li dimension: An integer of type int32, specifying the axis information of33*@li dimension: An integer of type int32, specifying the axis information of
34* the index with the maximum value.34* the index with the maximum value.
35*@li keep_dims: A bool, specifying whether to keep dimensions for the output35*@li keep_dims: A bool, specifying whether to keep dimensions for the output
36-* Tensor. Defaults to "false". \n36+* Tensor. Defaults to "false".
37+*@li indice_dtype: A Type, The output type, either "int32" or "int64". Defaults to "int32". \n
37 38 
38*@par Outputs:39*@par Outputs:
39* @li indice: A multi-dimensional Tensor of type int32 or int64, specifying the index.40* @li indice: A multi-dimensional Tensor of type int32 or int64, specifying the index.
@@ -63,6 +64,7 @@ REG_OP(ArgMinWithValue)
63 .OUTPUT(values, TensorType({DT_FLOAT, DT_FLOAT16, DT_BF16, DT_INT64, DT_INT32}))64 .OUTPUT(values, TensorType({DT_FLOAT, DT_FLOAT16, DT_BF16, DT_INT64, DT_INT32}))
64 .REQUIRED_ATTR(dimension, Int)65 .REQUIRED_ATTR(dimension, Int)
65 .ATTR(keep_dims, Bool, false)66 .ATTR(keep_dims, Bool, false)
67+ .ATTR(indice_dtype, Type, DT_INT32)
CANN-robot
CANN-robotCANN-robot1月31日

命名规范/拼写错误: 属性名 indice_dtype 使用了单词 indice。在英文中,index 的复数形式通常是 indicesindice 是一个较少使用的单数形式或错误拼写。在整个代码片段中,输出变量名、文档描述都使用的是 indice(例如第39行、第62行),这保持了内部一致性,但可能不符合通用的英文技术术语习惯,可能给阅读代码的其他开发者带来困惑,或与项目中其他使用 indices 的算子产生命名风格上的不一致。

问题类型: 命名规范/拼写错误 文件路径: math/arg_min_with_value/op_graph/arg_min_with_value_proto.h 行号: 66 问题代码:

.ATTR(indice_dtype, Type, DT_INT32)

修改建议:

建议评估并统一项目内的命名规范。如果项目内普遍使用 `indices` 作为复数形式,则应考虑将本算子中的所有 `indice` 更名为 `indices`,包括输出变量名、属性名以及文档中的对应描述,以确保项目术语的一致性。如果 `indice` 是项目内特定且公认的命名,则可保留,但需确认其合理性。

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

likedislike
66 .OP_END_FACTORY_REG(ArgMinWithValue)68 .OP_END_FACTORY_REG(ArgMinWithValue)
67 69 
68} // namespace ge70} // namespace ge
@@ -43,6 +43,8 @@ public:
43 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,43 .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND,
44 ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});44 ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND});
45 this->Attr("dimension").AttrType(REQUIRED).Int();45 this->Attr("dimension").AttrType(REQUIRED).Int();
46+ this->Attr("keep_dims").AttrType(OPTIONAL).Bool(false);
47+ this->Attr("indice_dtype").AttrType(OPTIONAL).Int(3);
46 48
47 OpAICoreConfig aicore_config; 49 OpAICoreConfig aicore_config;
48 aicore_config.DynamicCompileStaticFlag(true)50 aicore_config.DynamicCompileStaticFlag(true)
@@ -45,6 +45,16 @@
45 "name": "dimension",45 "name": "dimension",
46 "dtype": "int",46 "dtype": "int",
47 "value": 047 "value": 0
48+ },
49+ {
50+ "name": "keep_dims",
51+ "dtype": "bool",
52+ "value": null
53+ },
54+ {
55+ "name": "indice_dtype",
56+ "dtype": "int",
57+ "value": 3
48 }58 }
49 ]59 ]
50 },60 },
@@ -92,6 +102,16 @@
92 "name": "dimension",102 "name": "dimension",
93 "dtype": "int",103 "dtype": "int",
94 "value": 0104 "value": 0
105+ },
106+ {
107+ "name": "keep_dims",
108+ "dtype": "bool",
109+ "value": null
110+ },
111+ {
112+ "name": "indice_dtype",
113+ "dtype": "int",
114+ "value": 3
95 }115 }
96 ]116 ]
97 },117 },
@@ -139,6 +159,16 @@
139 "name": "dimension",159 "name": "dimension",
140 "dtype": "int",160 "dtype": "int",
141 "value": 0161 "value": 0
162+ },
163+ {
164+ "name": "keep_dims",
165+ "dtype": "bool",
166+ "value": null
167+ },
168+ {
169+ "name": "indice_dtype",
170+ "dtype": "int",
171+ "value": 3
142 }172 }
143 ]173 ]
144 },174 },
@@ -186,6 +216,16 @@
186 "name": "dimension",216 "name": "dimension",
187 "dtype": "int",217 "dtype": "int",
188 "value": 0218 "value": 0
219+ },
220+ {
221+ "name": "keep_dims",
222+ "dtype": "bool",
223+ "value": null
224+ },
225+ {
226+ "name": "indice_dtype",
227+ "dtype": "int",
228+ "value": 3
189 }229 }
190 ]230 ]
191 },231 },
@@ -233,6 +273,16 @@
233 "name": "dimension",273 "name": "dimension",
234 "dtype": "int",274 "dtype": "int",
235 "value": 0275 "value": 0
276+ },
277+ {
278+ "name": "keep_dims",
279+ "dtype": "bool",
280+ "value": null
281+ },
282+ {
283+ "name": "indice_dtype",
284+ "dtype": "int",
285+ "value": 3
236 }286 }
237 ]287 ]
238 },288 },
@@ -280,6 +330,16 @@
280 "name": "dimension",330 "name": "dimension",
281 "dtype": "int",331 "dtype": "int",
282 "value": 0332 "value": 0
333+ },
334+ {
335+ "name": "keep_dims",
336+ "dtype": "bool",
337+ "value": null
338+ },
339+ {
340+ "name": "indice_dtype",
341+ "dtype": "int",
342+ "value": 3
283 }343 }
284 ]344 ]
285 },345 },
@@ -327,6 +387,16 @@
327 "name": "dimension",387 "name": "dimension",
328 "dtype": "int",388 "dtype": "int",
329 "value": 0389 "value": 0
390+ },
391+ {
392+ "name": "keep_dims",
393+ "dtype": "bool",
394+ "value": null
395+ },
396+ {
397+ "name": "indice_dtype",
398+ "dtype": "int",
399+ "value": 3
330 }400 }
331 ]401 ]
332 },402 },
@@ -374,6 +444,16 @@
374 "name": "dimension",444 "name": "dimension",
375 "dtype": "int",445 "dtype": "int",
376 "value": 0446 "value": 0
447+ },
448+ {
449+ "name": "keep_dims",
450+ "dtype": "bool",
451+ "value": null
452+ },
453+ {
454+ "name": "indice_dtype",
455+ "dtype": "int",
456+ "value": 3
377 }457 }
378 ]458 ]
379 },459 },
@@ -421,6 +501,16 @@
421 "name": "dimension",501 "name": "dimension",
422 "dtype": "int",502 "dtype": "int",
423 "value": 0503 "value": 0
504+ },
505+ {
506+ "name": "keep_dims",
507+ "dtype": "bool",
508+ "value": null
509+ },
510+ {
511+ "name": "indice_dtype",
512+ "dtype": "int",
513+ "value": 3
424 }514 }
425 ]515 ]
426 },516 },
@@ -468,6 +558,16 @@
468 "name": "dimension",558 "name": "dimension",
469 "dtype": "int",559 "dtype": "int",
470 "value": 0560 "value": 0
561+ },
562+ {
563+ "name": "keep_dims",
564+ "dtype": "bool",
565+ "value": null
566+ },
567+ {
568+ "name": "indice_dtype",
569+ "dtype": "int",
570+ "value": 3
471 }571 }
472 ]572 ]
473 }573 }