Merged
feat: ConfusionMatrix 算子下一代实现 #5444
feat: ConfusionMatrix 算子下一代实现 #5444
Merged
shengleAdd on Sep 8
shengle
shengleCollaborators
Sep 8

描述

新增 ConfusionMatrix 算子 Ascend950(arch35)实现。

  • 功能:对每个索引 i,将 weights[i](缺省为 1)累加到输出矩阵 y[labels[i], predictions[i]],输出 num_classes×num_classes 混淆矩阵,兼容 TF tf.math.confusion_matrix。
  • kernel 侧:SIMT 范式(参照 bincount 骨架),2D scatter-add;按输出矩阵与 UB 容量关系分四种调度策略(full_load / batch_load / not_full_load / determine),determine 模式按输出行切核保证确定性,int8/uint8 输出固定走 determine(窄整型不走原子加)。
  • host 侧:arch35 tiling(策略选择 + 结构化宏校验 shape/dtype/num_classes);op_graph 双挂 InferShape + InferDataType(输出 dtype 由属性 dtype 字符串白名单映射)。
  • dtype 组合:labels/predictions(dtype 相同)× weights/output(dtype 相同)共 25 种组合,输出 dtype 由属性 dtype 决定;1 ≤ num_classes ≤ 4096。
  • 原型去重:common/inc/op_graph/op_math_proto_extend.h 中移除 ConfusionMatrix 的 REG_OP 声明——本算子目录 op_graph/confusion_matrix_proto.h 已提供带 OPS_PROTO_DEF_CONFUSIONMATRIX 去重宏保护的版本,避免同 TU 重复注册。
  • tf-plugin:由 common/src/framework/confusion_matrix_tf_plugin.cpp 统一提供(#5653 已合入),本 PR 不重复交付。

关联的Issue

#3211

测试

  • 泛化:kernel 模式 1000 例(25 dtype 组合 × num_classes 1~4096 探顶 × N 0~100000 × 4 调度分支),REAL_FAIL=0(995 PASS + 5 例 fp16 深累加顺序舍入差异,与 built-in TBE 同数值行为)。
  • 通路:GEIR 55 例全连通,浮点输出 23/23 三方比对(NPU / CPU golden / GPU)PASS;tf 通路经 pb 解析验证。
  • 精度:三方 12/12 PASS(含 int8/uint8 饱和回绕、inf/nan 传播,NPU-GPU bitwise 一致)。
  • 性能:150 例对标 A100(torch scatter_add 拼接基准),NPU 中位快约 2.6×,按 shape 分布如实呈现。
  • UT:tiling(arch35)+ infershape 单测随包;ST:tests/st/arch35/ttk_kernel_confusion_matrix_st.csv。

文档更新

  • 新增 math/confusion_matrix/README.md(产品支持情况/功能说明/参数说明/约束说明/调用说明)。
  • docs/zh/op_list.md 登记 confusion_matrix 条目。

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for shengle's contribution.)
shengleshengleCollaborators
Sep 8 Created pull request, commit d616f12f
shengleshengleCollaborators
Sep 8 Pre merge succeeded (commit_id: ed6ffd79baced0c22226ba0c964bebb6938cac95)
shengleshengleCollaborators
Sep 8 Force-pushed 275 commits:d616f12f-274 commits from branch master,360c9a50-feat: ConfusionMatrix 算子下一代实现
shengleshengleCollaborators
Sep 8 Pre merge succeeded (commit_id: 5cfd4c37e91063abf14531c4a798e824d140b9d6)
CANN-robotCANN-robotCollaborators
Sep 8 Added label: cann-cla/yes
98 messages are collapsed here。 See more
CANN-robotCANN-robotCollaborators
Oct 8 Added label: lgtm
CANN-robot
CANN-robotCollaborators
Oct 8 Comments:

The MR can not be merged, because of CodeReview discussion not resolved

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
TangPCTangPCCollaborators
Oct 8 Resolved final issue
CANN-robotCANN-robotCollaborators
Oct 8 Closed associated issue
CANN-robotCANN-robotCollaborators
Oct 8 Merged pull request