已合并
修复real_div不同soc支持逻辑 #3880
jiangjiawei创建于 7月7日
修复real_div不同soc支持逻辑 #3880
已合并
jiangjiawei创建于 7月7日
jiangjiawei成员
7月7日

描述

修复real_div支持逻辑

关联的Issue

https://gitcode.com/cann/ops-math/issues/2192

测试

image.png

文档更新

不涉及

类型标签

  • Bug修复
  • 新特性
  • 性能优化
  • 文档更新
  • 其他,请描述:
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 jiangjiawei 的贡献)
Jjiangjiawei成员
7月7日 创建了 pull request,commit 45d32570
atomgit-bot
atomgit-bot
7月7日 评论:

变更摘要

此 PR 移除了 RealDiv 算子中对芯片型号的运行时判断逻辑(IsInt32PrecisionSupported()),统一了所有芯片平台下 INT32 类型输入的处理行为:无论芯片是否为 Ascend910B/910C,当 self 为 INT32 或 BOOL 类型时,输出统一采用 DT_FLOAT 类型分配张量。这意味着之前仅在 910B/910C 上启用的 INT32→FLOAT 路径现已扩展到所有平台(包括 A5/Ascend950)。

主要改动

  • 移除 IsInt32PrecisionSupported() 函数:删除了判断当前芯片是否为 Ascend910B/910C 的辅助函数及其注释,不再按芯片型号区分行为。
  • 简化三参数 RealDiv 的输出类型分配条件:原条件要求 selfother 均为 DT_INT32 且芯片支持时输出 DT_FLOAT,现简化为只要 selfDT_INT32 即输出 DT_FLOAT
  • 简化带 mode 参数的重载中 isOutDtypeFloat 判定:同样移除了对 other 类型和芯片型号的依赖,仅检查 self 是否为 DT_BOOLDT_INT32
  • 统一标量/非标量重载中的张量分配逻辑:将 isInt32Precision 变量替换为直接判断 self->GetDataType() != op::DataType::DT_INT32,使得 INT32 输入在所有芯片上均走 DT_FLOAT 输出分支。
likedislike
atomgit-bot
atomgit-bot
7月7日 评论:

代码审查

审查总结

我已完成对 math/real_div/op_api/realdiv.cpp(本 PR 唯一变更文件)的逐行审查。

发现的问题

优先级 数量 说明
P1 1 AICPU 路径上 INT32 RealDiv 输出 DT_FLOAT 与 kernel 写入的 INT32 数据类型不匹配,导致静默数据损坏

各文件审查结果

  • math/real_div/op_api/realdiv.cpp:发现 1 个 P1 问题(见上述),其余变更逻辑正确、一致。

整体风险判断

中等风险。此 PR 的核心意图(为 A5/Ascend950 平台扩展 INT32 RealDiv 支持)方向正确,A5 走 AiCore 路径不受影响。但变更同时影响了落入 IsAiCoreSupport 默认分支的基础芯片:这些芯片上 INT32 RealDiv 走 AICPU 路径,op_api 分配 DT_FLOAT 输出而 AICPU kernel 写入 INT32 整数除法结果,造成静默数据损坏。建议在合入前确认基础芯片上是否存在 INT32 RealDiv 调用场景,若存在则需修复此类型不匹配问题。

类型 数量
🔴 阻塞 1
🟡 建议 0

⛔ 需要修改

likedislike
CANN-robotCANN-robot成员
7月7日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
7月7日 评论:

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


PR Approval Progress

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

Module Approval Details

module lgtm status approve status
math/real_div 周奇龙, 唐燕峰 (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

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

likedislike
此处折叠了98条消息 查看更多
CANN-robotCANN-robot成员
7月9日 添加了label:approved
FelixTang7成员
7月9日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
7月9日 添加了label:lgtm
CANN-robotCANN-robot成员
7月9日 关闭了关联的issue
CANN-robotCANN-robot成员
7月9日 合入了pull request