Merged
bitwise_and新增int8/uint8/uint32/uint64数据类型支持 [9.2.0同步] #5573
bitwise_and新增int8/uint8/uint32/uint64数据类型支持 [9.2.0同步] #5573
Merged
wangqi_aiAdd on Sep 10
wangqi_ai
wangqi_aiCollaborators
Sep 10

修改背景

本 PR 为 master 分支已合入的 PR #5321(bitwise_and新增int8/uint8/uint32/uint64数据类型支持)向 9.2.0 分支的同步迁移(backport)。

bitwise_and 系列算子(BitwiseAndTensor / BitwiseAndScalar / InplaceBitwiseAndTensor / InplaceBitwiseAndScalar)此前仅支持 int16 / uint16 / int32 / int64 四种整型,同族算子 bitwise_or 已支持全部 8 种整型;uint32 / uint64 等按位与场景(如权重打包、掩码计算)无法走 NPU AICore 加速路径。

修改内容

与 master 分支 PR #5321 完全一致(cherry-pick,patch-id 相同):

kernel 侧(Ascend 950 / arch35)

  • op_host/bitwise_and_def.cpp:x1/x2/y 类型注册从 4 种整型扩展为 8 种
  • op_host/config/ascend950/bitwise_and_binary.json:新增 int8/uint8/uint32/uint64 四个 binary 条目
  • op_host/arch35/bitwise_and_tiling.cpp:DoOpTiling 新增 4 个 dtype 模板分支

l0 层

  • op_api/bitwiseand.cpp:新增 ASCEND950_AICORE_DTYPE_SUPPORT_LIST(8 种整型全走 AICore),IsAiCoreSupport 按 910B(DAV_2201)/ RegBase(950)/ 其他 三类分别查表,对齐 bitwise_or 的既有分派结构;910B 与其余硬件的支持列表不变

aclnn 侧

  • aclnn_bitwise_and_tensor.cpp:接口 DTYPE_SUPPORT_LIST 扩展为 9 种(BOOL + 8 整型,与 bitwise_or 一致)
  • aclnn_bitwise_and_scalar.cpp:新增 REGBASE_DTYPE_SUPPORT_LIST(950 上 scalar 支持 uint32/uint64),非 RegBase 平台维持原 7 种列表,与 bitwise_or 一致
  • 计算与推导路径保持存量实现不变(按双输入推导类型计算后转换到 out)

测试与文档

  • UT 用例 12→26:新增 tensor uint32/uint64、950 scalar uint32/uint64 门禁(接受 / 910B 拒绝)、int→bool out 拒绝、混合无符号 u32|u64 拒绝、收窄 / 升宽 / inplace / 弱标量等接受面锚点
  • README 与 4 个 aclnn 接口文档同步 uint32/uint64 类型说明

验证情况

本 PR 与 master 合入代码完全对齐(math/bitwise_and/ 目录与 master 零差异),master 侧已完成的验证:

  1. 双平台 UT:--soc=ascend950 与 --soc=ascend910b 均 26/26 通过
  2. 950 真机 kernel ST(Ascend950PR,0 容差精确比对):新增 dtype 6/6 PASS(int8/uint8/uint32/uint64 + uint32/uint64 广播);存量 ST 回归 96/100 PASS,4 例 INPUT_GEN_FAILURE 为存量 csv 脏数据(int16/int32 输入配 int64 极值范围),已在 builtin 实现上复现确认与改动无关
  3. 950 真机 aclnn ST:7/7 PASS(BOOL 回归 + uint32/uint64 tensor/广播/scalar + inplace,torch 2.12 CPU golden 逐位比对)
  4. pre-commit 全 hooks 通过(clang-format / codespell / OAT 开源合规)

风险说明

  • 既有 7 种 dtype(含 BOOL)在所有平台的计算与执行路径与改动前完全一致,零回归;计算类型推导逻辑未做任何改动
  • tensor 接口 uint32/uint64 为全平台接受列表(950 走 AICore,其他硬件经 AICPU 路径),行为与 bitwise_or 既有分派结构一致
likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for wangqi_ai's contribution.)
wangqi_aiwangqi_aiCollaborators
Sep 10 Created pull request, commit 6133ad59
atomgit-bot
atomgit-bot
Sep 10 Comments:

变更摘要

本 PR 将 master 分支已合入的 bitwise_and 新增 int8/uint8/uint32/uint64 数据类型支持(#5321)通过 cherry-pick 同步(backport)至 9.2.0 分支。此前 BitwiseAndTensor / BitwiseAndScalar / InplaceBitwiseAndTensor / InplaceBitwiseAndScalar 仅支持 int16/uint16/int32/int64 四种整型,本次将 kernel 侧、l0 层与 aclnn 接口的类型注册和支持列表扩展为 8 种整型,使 uint32/uint64 等按位与场景(如权重打包、掩码计算)可在 Ascend 950 上走 NPU AICore 加速路径,整体分派结构对齐同族算子 bitwise_or;计算与类型推导逻辑保持存量实现不变。同时 README 与 4 个 aclnn 接口文档同步了 uint32/uint64 类型说明。

主要改动

  • kernel 侧类型注册扩展: op_host/bitwise_and_def.cpp 中 x1/x2/y 的 DataType/Format 注册由 4 种整型扩展为 8 种(新增 int8/uint8/uint32/uint64),op_host/config/ascend950/bitwise_and_binary.json 同步新增 BitwiseAnd_int8、BitwiseAnd_uint8、BitwiseAnd_uint32、BitwiseAnd_uint64 四个 binary 条目
  • tiling 模板分支扩展: op_host/arch35/bitwise_and_tiling.cpp 的 DoOpTiling 新增 DT_INT8/DT_UINT8/DT_UINT32/DT_UINT64 四个 dtype 分支,分别实例化对应 BitwiseAndCompute 模板执行 BroadcastBaseTiling
  • l0 层 AICore 分派调整: op_api/bitwiseand.cpp 新增 ASCEND950_AICORE_DTYPE_SUPPORT_LIST(8 种整型全走 AICore),IsAiCoreSupport 改为按 910B(DAV_2201)/ RegBase(950)/ 其他硬件三类分别查表,对齐 bitwise_or 的既有分派结构,910B 与其余硬件支持列表保持不变
  • aclnn 接口支持列表扩展: aclnn_bitwise_and_tensor.cpp 的 DTYPE_SUPPORT_LIST 扩展为 9 种(BOOL + 8 整型);aclnn_bitwise_and_scalar.cpp 新增 REGBASE_DTYPE_SUPPORT_LIST(950 上 scalar 支持 uint32/uint64),非 RegBase 平台维持原 7 种列表;计算与推导路径(双输入推导类型后转换到 out)保持存量实现不变
  • UT 用例扩展: 新增 tensor uint32/uint64 用例、950 scalar uint32/uint64 门禁(910B 拒绝)、int→bool out 拒绝、混合 uint32|uint64 推导拒绝,以及收窄 / 升宽 / inplace / 弱标量(int64 标量不抬升 int32 推导)等接受面锚点用例
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 10 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 10 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Sep 10 Comments:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
*/*/README.md ✅ 陈娇, 汤平川 (2/2) ✅ 陈娇 (1/1)
*/*/docs/acl*.md ✅ 陈娇, 汤平川 (2/2) ✅ 陈娇 (1/1)
*/*/op_host/*_def.cpp ✅ 王永光, 汤平川 (2/2) ✅ 王永光 (1/1)
math/bitwise_and ✅ 汤平川, 宋恺 (2/2) ✅ 汤平川, 宋恺 (2/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Sep 10 Set FelixTang7,yue-ma,zhou-qilong,gitee-duhuiping,wangrui_,rxtfeng,loov1,tang-lei01,zhangzijie,jia0liang,zl_hw,songkai111,gitcode-chenjiao,chenxingyu18,pingchuantang,llimwang,gubaocheng,andong_hw,wangyongguang,fengying555682,xuejinghui,zhanw_coding,caiwenwen,yanglu-1 as approver
CANN-robotCANN-robotCollaborators
Sep 10 Set FelixTang7,yue-ma,zhou-qilong,gitee-duhuiping,wangrui_,rxtfeng,loov1,tang-lei01,zhangzijie,zl_hw,songkai111,gitcode-chenjiao,chenxingyu18,pingchuantang,llimwang,gubaocheng,andong_hw,wangyongguang,fengying555682,xuejinghui,zhanw_coding,caiwenwen,yanglu-1 as approver
wangqi_ai
wangqi_aiCollaborators
Sep 10 Comments:

compile

likedislike
wangqi_aiwangqi_aiCollaborators
Sep 10 Pre merge succeeded (commit_id: d15535428071238e4cde865c14cd223460c25030)
CANN-robot
CANN-robotCollaborators
Sep 10 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 10 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 10 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 10 Added label: ci-pipeline-passed
wangyongguang
wangyongguangCollaborators
Sep 10 Comments:

/approve

likedislike
songkai111
songkai111Collaborators
Sep 10 Comments:

/approve

likedislike
sunchun
sunchunCollaborators
Sep 11 Comments:

您好,PR已满足合入指标,请尽快联系Committer进行合入。如暂时不需要合入,请在PR标题前加[WIP]

likedislike
TangPC
TangPCCollaborators
Sep 11 Comments:

/lgtm
/approve

likedislike
chenjiao
chenjiaoCollaborators
Sep 11 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 11 Added label: lgtmapproved
CANN-robotCANN-robotCollaborators
Sep 11 Merged pull request