Merged
fix(operation): Make Round Behave Consistently With AscendC. #5889
刘奕哲Add on Sep 3
fix(operation): Make Round Behave Consistently With AscendC. #5889
Merged
刘奕哲Add on Sep 3
刘奕哲
Sep 3

描述

Round算子与AscendC对齐:

  1. 移除对int16数据类型的支持。
  2. 输入为整数类型时decimals参数仅支持默认值0。

测试

完成冒烟测试

关联Issue

#3211

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for 刘奕哲's contribution.)
刘奕哲刘奕哲
Sep 3 Created pull request, commit 77a1485e
atomgit-bot
atomgit-bot
Sep 3 Comments:

变更摘要

本 PR 旨在修复 Round 算子行为,使其与 AscendC 保持一致。核心改动集中在三处:在 C++ 接口 Round 中从内核支持的数据类型集合里移除 DT_INT16(仅保留 DT_FP32、DT_FP16、DT_BF16、DT_INT32 及按架构区分的 DT_INT64);在 Python 接口 round 中针对整数张量(DT_INT32、DT_INT64)新增约束——decimals 必须为 0,否则抛出 PyptoError,且 decimals == 0 时直接返回 add(input, 0)(恒等操作)而不再调用内核 Round;并同步更新/删除了对应的测试用例。

主要改动

  • 移除 DT_INT16 内核支持:在 framework/src/interface/operation/vector/unary_basic.cpp 的 Round 中,将 DT_INT16 从 ROUND_A2A3_TYPES 与 ROUND_A5_TYPES 两个支持类型集合中删除,收窄内核支持范围以对齐 AscendC 行为。
  • Python 侧整数 round 走恒等路径:在 python/pypto/op/math.py 的 round 中新增判断,当输入为 DT_INT32/DT_INT64 时要求 decimals == 0,否则以 ValueError 抛出 PyptoError;decimals == 0 时直接返回 add(input, 0),不再进入 pypto_impl.Round。
  • 调整并删除测试用例:在 round_test_case.py 中将 int32 用例的 decimals 由 -1 改为 0,并将 data_range 扩为 int32 全取值范围(-2147483648 至 2147483647);同时删除使用 int16、decimals: -2 的原 Round_test_14 用例。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Sep 3 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Sep 3 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Sep 3 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
docs ✅ lyz0328, 尹杰 (2/2) ✅ lyz0328 (1/1)
framework/src/interface/operation ✅ shi-dingkun, 尹杰 (2/2) ✅ shi-dingkun (1/1)
python/pypto/op ✅ shi-dingkun, 尹杰 (2/2) ✅ shi-dingkun (1/1)
repo-cann/pypto ✅ 尹杰, shi-dingkun (2/2) ✅ shi-dingkun (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
CANN-robotCANN-robotCollaborators
Sep 3 Set xinweiliu,lyz0328,cam_bxh,dai-zhentao,lululu40888,shi-dingkun,gguuaanngg,codehjp423,gaoxiang618,wangzheng97,DCGDDD,syfeng,jason_yuan_ye,foundea,ym-HW,hw_zhangzhiqi,yinjie27_,congqiannan,zhangyuebing,tsungl4,gaoxingwang,zhiweiyuan,caodongdong,make_pto,zhoubotcam,linjiashu,wangbing110,WenboCodes as approver
11 event messages are collapsed here。 See more
刘奕哲刘奕哲
Sep 3 Modify description of pull request
刘奕哲
刘奕哲
Sep 3 Comments:

compile

likedislike
刘奕哲刘奕哲
Sep 3 Pre merge succeeded (commit_id: 882aa1acbeb28dd605da3e612277dfeaea71ddea)
CANN-robot
CANN-robotCollaborators
Sep 3 Comments:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robotCollaborators
Sep 3 Added label: ci-pipeline-running
刘奕哲刘奕哲
Sep 3 Modify description of pull request
CANN-robotCANN-robotCollaborators
Sep 3 Removed label: ci-pipeline-running
CANN-robotCANN-robotCollaborators
Sep 3 Added label: ci-pipeline-passed
Jie Yin
Jie YinCollaborators
Sep 4 Comments:

/lgtm

likedislike
lyz0328
lyz0328Collaborators
Sep 4 Comments:

/approve

likedislike
shi-dingkun
shi-dingkunCollaborators
Sep 4 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Sep 4 Added label: lgtmapproved
CANN-robotCANN-robotCollaborators
Sep 4 Closed associated issue
CANN-robotCANN-robotCollaborators
Sep 4 Merged pull request