已合并
fix: handle zero tensor src to avoid null pointer in aclrtMemcpy #33383
wuyouqi1创建于 4月9日
fix: handle zero tensor src to avoid null pointer in aclrtMemcpy #33383
已合并
从已删除 :v2.9.0-issue146合入到Ascend/pytorchv2.9.0
Pull Request已成功合入, 合并人@ascend-robot
(感谢 wuyouqi1 的贡献)ascend-robot
4月9日 评论:
4月9日 评论:
ascend-robot
4月9日 评论:
4月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/pytorch | ✅ liujunzhu, huangyunlong2022 (2/2) | ✅ liujunzhu (1/1) |
| test | ✅ liujunzhu, huangyunlong2022 (2/2) | ✅ liujunzhu (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
weixin_47897441, thanks for your pull request. All authors of the commits have signed the CLA. 👍


4月9日 添加了label:ascend-cla/yes
ascend-robot
4月9日 评论:
4月9日 评论:
此处折叠了53条消息 查看更多
huangyunlong
4月13日 评论:
4月13日 评论:
/lgtm


liujunzhu
4月13日 评论:
4月13日 评论:
/approve


4月13日 添加了label:approvedlgtm
ascend-robot
4月13日 评论:
4月13日 评论:
Review Guide
This pull-request passes review.
Committers who wrote a comment of /approve are: liujunzhu.
Reviewers who wrote a comment of /lgtm are: liujunzhu, huangyunlong2022.


4月13日 合入了pull request
【合入来源】
【修改方案】
torch_npu/csrc/aten/ops/op_api/CopyKernelOpApi.cpp的copy_()函数中添加src._is_zerotensor()检查data_ptr()为 null)时,直接调用self.zero_()而不走aclrtMemcpy,避免 null 指针传入触发 error code 100000aten/src/ATen/native/Copy.cpp中的_is_zerotensor()处理保持一致根因:
_efficientzerotensor算子 NPU 未实现回退 CPU,CPU 侧使用ZeroTensorAllocator创建惰性零张量不分配实际内存,data_ptr()为 null,copy_()直接调用aclrtMemcpy时传入 null src 指针报错。【资料变更】
不涉及
【接口变更】
不涉及
【功能验证】
test_linearize_composition_grad_npu_float32python test_eager_transforms.py -v -k test_linearize_composition_grad_npu_float32【CheckList】