已合并
fix(op-plugin): identity round for integers; delegate round_ to round.out for op_api. #4917
Margaret_wangrui创建于 5月9日
fix(op-plugin): identity round for integers; delegate round_ to round.out for op_api. #4917
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 Margaret_wangrui 的贡献)5月9日 创建了 pull request,commit 60d9b708
ascend-robot
5月9日 评论:
5月9日 评论:
ascend-robot
5月9日 评论:
5月9日 评论:
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 |
|---|---|---|
| repo-Ascend/op-plugin | ✅ wangmin0104, sunyu-xuan (2/2) | ✅ wangmin0104 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
Margaret_wangrui, thanks for your pull request. All authors of the commits have signed the CLA. 👍


5月9日 添加了label:ascend-cla/yes
5月9日 修改了pull request 的描述
此处折叠了116条消息 查看更多
ascend-robot
5月15日 评论:
5月15日 评论:
流水线 PR-pipeline_op-plugin#1144 (重试第2次) [ commitID:c24d951e ] 已完成
>>>代码风格自动修复执行失败,具体请查看日志,不影响流水线执行及PR合入
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_master_ARM | ✅ | >>> |
| Build_v2_7_1_ARM | ✅ | >>> | |
| Build_v2_9_0_ARM | ✅ | >>> | |
| Build_v2_10_0_ARM | ✅ | >>> | |
| Build_v2_11_0_ARM | ✅ | >>> | |
| Build_master_x86 | ✅ | >>> | |
| Build_v2_7_1_x86 | ✅ | >>> | |
| Build_v2_9_0_x86 | ✅ | >>> | |
| Build_v2_10_0_x86 | ✅ | >>> | |
| Build_v2_11_0_x86 | ✅ | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck | ✅ | >>> |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | UT_master_ARM | ✅ | >>> |
| UT_v2_7_1_ARM | ✅ | >>> | |
| UT_v2_9_0_ARM | ✅ | >>> | |
| UT_v2_10_0_ARM | ✅ | >>> | |
| UT_v2_11_0_ARM | ✅ | >>> | |
| 流水线 | PR-pipeline_op-plugin | ✅ | >>> |
- compile : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


sunyu-xuan
5月15日 评论:
5月15日 评论:
/lgtm


5月15日 添加了label:lgtm
ascend-robot
5月15日 评论:
5月15日 评论:
Review Guide
This pull-request passes review.
Committers who wrote a comment of /approve are: wangmin0104.
Reviewers who wrote a comment of /lgtm are: sunyu-xuan, wangmin0104.


5月15日 合入了pull request
【合入来源】
如有社区 issue,请关联 issue 链接:无
请勿携带内部流程信息(需求链接、问题单、内部 issue 等)
https://gitcode.com/Ascend/pytorch/issues/1873
[Bug]:
aclnnInplaceRound/aclnnRound与整数 dtype 在 PyTorchtest_meta等场景下的语义对齐类型勾选(请按实际保留一项):
【修改方案】
CANN
aclnnRound/aclnnInplaceRound对部分整数 dtype(典型为 int8 / int16 / uint8)不支持或行为与 Pyorch 不一致,而在transfer_to_npu、调用test_meta.py中*_round_cuda_*用例 时会经 op_api 落到上述 aclnn 算子,导致失败。PyTorch 对整数张量的round/round_语义为恒等(无小数可取整),应与 CPU 一致。acl_op路径(RoundKernelNpu.cpp)round_integral_identity:at::isIntegralType(self.scalar_type(), false)(与 CPU 一致,排除 bool)。round_out:整数分支经copy_及既有 NPU format/contiguous 处理写回out,不再调用OpCommand("Round")。round:整数返回self.clone();非整数保持原路径。round_仍通过round_out(self, self),in-place 覆盖整数场景。op_api路径(op_plugin_functions.yaml+ torchnpugen 生成)round.out的gen_opapi增加integral_identity_tensor: self,在生成体最前插入整数早退,直接acl_op::round_out,避免整数走aclnnRound。round_的gen_opapi由exec: aclnnInplaceRound改为structured_inherit: round.out,生成round_out(self, self),统一走带整数早退的round_out,避免整数调用aclnnInplaceRound。torchnpugen/struct/model.py、struct_codegen.py)StructInfo.integral_identity_tensor;从gen_opapipop,避免参与out结果字段校验。INTEGRAL_IDENTITY_GUARD写入StructKernelNpuOpApi.cpp;ACLNN_EXTENSION分支补充#include <ATen/native/TypeProperties.h>。说明:
round(..., decimals=...)(aclnnRoundDecimals/RoundDecimalsKernelNpuOpApi)本 PR 不涉及。交互关系: 运行时调度 → op_api(生成) 或 acl_op;整数
round在 op_api 早退回acl_op::round_out;YAML ↔ torchnpugen ↔ StructKernelNpuOpApi.cpp 为构建期关系。【资料变更】
不涉及(若对外需声明「NPU 上整数
round与 PyTorch 一致为恒等」,可由资料接口人另单跟踪。)【接口变更】
不涉及
未新增/变更 Python API;
torch.round/tensor.round_(无 decimals 重载)对外语义与 PyTorch 对齐,属实现修正。【功能验证】
场景
round、round_、与round.out一致的 out 语义(由 op 组合覆盖)。round仍走 CANN / 原路径。方法
test_meta.py中与inplace_round相关的int8/int16/uint8等用例(若环境将 cuda 设备映射为 npu)。test/test_base_ops/test_round.py中test_round_integer_identity_npu。UT
test_round_integer_identity_npu,覆盖 int8 / uint8 / int16 / int32 / int64【CheckList】
(请提交人将
[ ]改为[x]并自检)