Merged
fix(operation): Fix Div operation using int64 dtype #6611
junnyleoAdd on Sep 22
fix(operation): Fix Div operation using int64 dtype #6611
Merged
junnyleoAdd on Sep 22
junnyleo
junnyleo
Sep 22

本次变更主要围绕 Div/Divs 算子对 int64 数据类型的支持进行修复。核心思路是将 int64 纳入整数除法的支持范围,并统一整数路径的处理逻辑:改为将输入 Cast 到 FP32 进行除法运算后再按 self 的数据类型回退转换;同时从平台支持的数据类型配置中移除 uint64,并同步调整了对应的 golden 生成逻辑。

Related Issue: #3416

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for junnyleo's contribution.)
junnyleojunnyleo
Sep 22 Created pull request, commit 13080452
atomgit-bot
atomgit-bot
Sep 22 Comments:

变更摘要

本 PR 修复了 Div 运算对 int64 数据类型的支持问题,涉及向量二元运算 Div 与张量-标量二元运算 Div(Divs)。核心做法是统一 A5 架构下支持的数据类型集合,将 DT_UINT64 从 DIV_A5_TYPES 中移除并纳入 DT_INT64,同时把整数参与运算的处理路径统一为先 Cast 到 DT_FP32 计算、再按需回转,并相应更新了 golden 测试的生成逻辑与错误提示信息。

主要改动

  • Div 支持类型集合调整(张量-张量): 在 framework/src/interface/operation/vector/binary.cpp 中,DIV_A5_TYPES 去掉 DT_UINT64、仅保留 DT_INT64,并将 isDivSupportedInt 判定扩展到 DT_INT64,同时移除了原先的 CheckInt64Broadcast 调用。
  • Div 整数路径统一为 FP32 计算(张量-标量): 在 framework/src/interface/operation/vector/binary_scalar.cpp 中,同样调整 DIV_A5_TYPES 与 isDivSupportedInt,删除 isDiv64Int 判定及其独立分支,整数参与时统一先将 self 与 other 转为 DT_FP32 计算,并通过 Cast(..., self.GetDataType(), CastMode::CAST_RINT, ...) 回转结果。
  • 浮点-整数标量分支处理简化: 删除了原 needPromoteToFp32 条件分支,改为对所有整数标量统一执行 self 转 DT_FP32、other 转 DT_FP32 后再做 TensorBinaryOperationScalarWithOp<BinaryOpType::DIV> 并回转类型。
  • 错误提示信息更新: 将整数场景下的 ERR_PARAM_DTYPE_UNSUPPORTED 报错文案由 DT_INT16/DT_INT32、DT_INT64/DT_UINT64 等描述统一为 DT_INT16/DT_INT32/DT_INT64。
  • golden 生成逻辑调整: 在 framework/tests/st/operation/python/vector_operator_golden.py 中,gen_div_op_golden 与 gen_divs_op_golden 改用 torch.div 配合 from_numpy/to_numpy 计算并返回结果,替换原先的直接除法表达式。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 22 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 22 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Sep 22 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
9.2.0 ✅ gcw_kUomxQ2l, wangzheng97 (2/2) ✅ gcw_kUomxQ2l (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Set xinweiliu,lyz0328,cam_bxh,dai-zhentao,TianXL,lululu40888,shi-dingkun,gguuaanngg,codehjp423,jiangtao_rts,gitcode-chenjiao,hanxiaolong,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,hw_zhangzhiqi,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,gcw_kUomxQ2l,Andy-lb,WenboCodes as approver
CANN-robotCANN-robotCollaborators
Sep 22 Set TianXL,jiangtao_rts,gitcode-chenjiao,hanxiaolong,gcw_kUomxQ2l,Andy-lb as approver
junnyleojunnyleo
Sep 22 Modify description of pull request
junnyleo
junnyleo
Sep 22 Comments:

compile

likedislike
junnyleojunnyleo
Sep 22 Pre merge succeeded (commit_id: 442d3b52f41b98219ca46feeab87bb41517e9c43)
CANN-robot
CANN-robotCollaborators
Sep 22 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 22 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 22 Added label: ci-pipeline-passed
lyz0328
lyz0328Collaborators
Sep 22 Comments:

/approve

likedislike
junnyleojunnyleo
Sep 22 Pre merge succeeded (commit_id: 14b5264109d3742a57023f4bf54fc7d7ea15a218)
junnyleojunnyleo
Sep 22 Force-pushed 1 commits:8610512e-fix(operation): Fix Div operation using int64 dtype
junnyleojunnyleo
Sep 22 Pre merge succeeded (commit_id: d958421a19b7051c4b34d346ffcfa4c604bf5247)
CANN-robotCANN-robotCollaborators
Sep 22 Removed label: cann-cla/yes
CANN-robotCANN-robotCollaborators
Sep 22 Removed label: ci-pipeline-passed
CANN-robot
CANN-robotCollaborators
Sep 22 Comments:

Notification

This pull request has been changed(code update) or closed, so removes the following label(s): ci-pipeline-passed.

likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Added label: cann-cla/yes
junnyleo
junnyleo
Sep 22 Comments:

compile

likedislike
junnyleojunnyleo
Sep 22 Pre merge succeeded (commit_id: fea2a38ac0715176d8a69c2fbc19b62d0828cb90)
CANN-robot
CANN-robotCollaborators
Sep 22 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Added label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 22 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 22 Added label: ci-pipeline-passed
CANN-robotCANN-robotCollaborators
Sep 22 Added label: AscendC-SUCC
liulun0308
liulun0308Collaborators
Sep 22 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Added label: approved
wangzheng97
wangzheng97Collaborators
Sep 22 Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
Sep 22 Added label: lgtm
CANN-robotCANN-robotCollaborators
Sep 22 Merged pull request