Pull Request已成功合入, 合并人@ascend-robot
(感谢 ascend-robot 的贡献)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 |
|---|---|---|
| torch_npu/utils | ✅ liangsongwei, htchu (2/2) | ✅ liangsongwei, htchu (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
ascend-ds-bot, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Ascend docs pipeline is running...


✅ 跳过 docs ci 检查,没有需要检查的文档文件


compile


Ascend docs pipeline is running...


Ascend docs pipeline is running...


✅ 跳过 docs ci 检查,没有需要检查的文档文件


✅ 跳过 docs ci 检查,没有需要检查的文档文件


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_ARM | ✅ | >>> | |
| Build_LibTorch_x86 | ✅ | >>> | |
| Build_LibTorch_ARM | ✅ | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| patch_test | 🛑 | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck | ✅ | >>> |
| check_error | ✅ | >>> | |
| CodeCheck_lintrunner | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | UT_X86_Part_01 | 🛑 | >>> |
| UT_X86_Part_02 | 🛑 | >>> | |
| UT_ARM_A3_Part_01 | 🛑 | >>> | |
| UT_ARM_A3_Part_02 | 🛑 | >>> | |
| UT_ARM_A2_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Part_02 | ✅ | >>> | |
| UT_ARM_A2_Part_03 | ✅ | >>> | |
| UT_inductor_Part_01 | 🛑 | >>> | |
| UT_inductor_Part_02 | 🛑 | >>> | |
| UT_inductor_Part_03 | 🛑 | >>> | |
| UT_inductor_Part_04 | 🛑 | >>> | |
| UT_DIST_ARM_Part_01 | 🛑 | >>> | |
| UT_DIST_ARM_Part_02 | 🛑 | >>> | |
| UT_DIST_ARM_Part_03 | 🛑 | >>> | |
| UT_DIST_ARM_Part_04 | 🛑 | >>> | |
| UT_ARM_A2_Select_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Select_Part_02 | ✅ | >>> | |
| 流水线 | PR-pipeline_pytorch | ✅ | >>> |


变更摘要
本 PR 主要修复 torch_npu/utils/combine_tensors.py 中 is_combined_tensor_valid 函数的连续性判断逻辑缺失问题。原函数仅检查 tensor 是否为空以及其数据指针是否落在合并 tensor 的地址范围内,但未验证 tensor 自身的连续性。该修复补充了对 tensor.is_contiguous() 的校验,使 is_combined_tensor_valid 与 npu_combine_tensors 中的连续性检查保持一致,确保合并 tensor 有效性判定的完整性。
主要改动
is_combined_tensor_valid函数新增连续性检查: 在遍历 tensor 列表的有效性判定条件中增加了not tensor.is_contiguous()条件,当 tensor 不连续时返回False,修复了此前仅检查地址范围而忽略连续性导致的判定漏洞。- 与
npu_combine_tensors的校验逻辑对齐:npu_combine_tensors在组合 tensor 前已要求输入 tensor 必须连续,本次修改使is_combined_tensor_valid的校验标准与之统一,避免出现组合时通过但验证时未检出的不一致情况。


/approve




1. Origin pull request:
https://gitcode.com/Ascend/pytorch/merge_requests/39043
2. Original pull request related issue(s):
https://gitcode.com/Ascend/pytorch/issues/2456
3. Original pull request related commit(s):
Signed-off-by: l1919_snow lixinyu68@huawei.com
Signed-off-by: l1919_snow lixinyu68@huawei.com
格式
Signed-off-by: l1919_snow lixinyu68@huawei.com
格式修改
Signed-off-by: l1919_snow lixinyu68@huawei.com