Pull Request已成功合入, 合并人@ascend-robot
(感谢 wuyouqi1 的贡献)变更摘要
本 PR 修复 910B/910_93 设备上 npu_format_cast 对 view 张量(reshape/transpose/slice 产生的逻辑形状与存储描述不一致的张量)的格式转换问题:在 MaybeUseAclnnNpuFormatCast 的非 aclnn-only 分支中,新增文件内 IsViewTensor 判定,将原先仅针对 ND->NZ N×1 列向量的窄守卫泛化为通用的 sizes 守卫,使 view 张量统一回退 aclop 路径,避免 aclnn 路径可能导致的 OOM/精度问题并恢复 PR 前行为;同形异构的 stride view(shape 一致、stride 不一致)经实测可被 aclnn 正确处理,故守卫仅按 sizes 判定、不改变其原有路径。同时新增 UT 用例(test_npu_format_cast.py Group 8,5 个用例)覆盖 reshape/transpose/as_strided 三类 view 的回退行为与数值正确性。
主要改动
- 新增
IsViewTensor判定函数: 在FormatCastKernelNpu.cpp中新增IsViewTensor,通过比较src.sizes()与存储描述npu_desc_.base_sizes_的维度数和各维度大小,判定张量是否为 view(维度不一致或任一维 sizes 不一致即视为 view)。 - 守卫由窄条件泛化为通用 sizes 守卫: 删除原先仅针对 2D contiguous ND->NZ 且
sizes()[1] == 1的列向量特判,替换为if (IsViewTensor(src))回退aclop,使 910B/910_93 非 aclnn-only 分支上所有 view 张量统一回退、恢复 PR 前行为。 - stride view 路径保持不变: 守卫仅按 sizes 判定、不涉及 stride 比较,同形异构 stride view(shape 一致、stride 不一致)仍走
aclnn路径,行为不受影响。 - 新增 Group 8 UT 用例: 在
test_npu_format_cast.py中新增 5 个用例(test_view_reshape_internal_to_base_fallback、test_view_reshape_nd_to_nz_fallback、test_view_transpose_nd_to_nz_fallback、test_view_strided_same_shape_nd_to_nz、test_view_strided_same_shape_internal_to_base),覆盖 reshape/transpose/as_strided 三类 view 的回退与数值正确性,通过@SupportedDevices(['Ascend910B', 'Ascend910_93'])限定适配设备。 - 补充格式常量定义: 在测试文件中新增
ACL_FORMAT_NCHW、ACL_FORMAT_NC1HWC0常量,供新用例引用内部格式转换场景。


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.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-Ascend/pytorch | ✅ wanglijun55, chengpeng25 (2/2) | ✅ chengpeng25 (1/1) |
| test | ✅ chengpeng25, wanglijun55 (2/2) | ✅ chengpeng25 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
wuyouqi1, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Linking Issue Notice
@wuyouqi1 , the pull request must be linked to at least one issue.
If an issue has already been linked, but the needs-issue label remains, you can remove the label by commenting /check-issue .


当前仓库存在以下 保护分支 :
| Protected Branch | Version | Release |
|---|---|---|
| master | ||
| v2.7.1 | ||
| v2.12.0 | ||
| v2.11.0 | ||
| v2.10.0 | ||
| v2.9.0 | ||
| v2.7.1-26.1.0 | ||
| v2.12.0-26.1.0 | ||
| v2.10.0-26.1.0 | ||
| v2.11.0-26.1.0 | ||
| v2.9.0-26.1.0 | ||
| ci-test |
评论 /sync <branch1> <branch2> ... 可将当前 PR 修改同步到其它分支(创建同步 PR):
a) 如果当前 PR 是 Open 状态,同步操作将延迟到 PR 被合并时执行
b) 如果当前 PR 已经 Merged,将立即执行同步操作
注意:
- /sync 命令可以指定同步到多个分支,仅最后一个 /sync 命令生效
- 如果创建的同步 PR 不正确,可通过向同步 PR 的源分支提交轻量级 PR 完善,或使用 /close 命令关闭


ascend docs pipeline is running...


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


| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_ARM | ✅ | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| patch_test | 🛑 | >>> | |
| Build_X86_213 | 🛑 | >>> | |
| Build_ARM_213 | 🛑 | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | codecheck_pre-commit | ✅ | >>> |
| check_error | ✅ | >>> | |
| lintrunner | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | 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 | ✅ | >>> | |
| UT_ARM_A2_Part_01_213 | 🛑 | >>> | |
| UT_ARM_A2_Part_02_213 | 🛑 | >>> | |
| UT_ARM_A2_Part_03_213 | 🛑 | >>> | |
| UT_inductor_Part_01_213 | 🛑 | >>> | |
| UT_inductor_Part_02_213 | 🛑 | >>> | |
| UT_inductor_Part_03_213 | 🛑 | >>> | |
| UT_inductor_Part_04_213 | 🛑 | >>> | |
| UT_DIST_ARM_Part_01_213 | 🛑 | >>> | |
| UT_DIST_ARM_Part_02_213 | 🛑 | >>> | |
| UT_DIST_ARM_Part_03_213 | 🛑 | >>> | |
| UT_DIST_ARM_Part_04_213 | 🛑 | >>> | |
| UT_ARM_A2_Select_Part_01_213 | 🛑 | >>> | |
| UT_ARM_A2_Select_Part_02_213 | 🛑 | >>> | |
| 流水线 | PR-pipeline_pytorch | ✅ | >>> |
- compile、compile_inductor、compile_torchair : 运行流水线
- retry : 重试流水线所有失败子任务
- retry <任务名> : 仅重试指定失败子任务
- stop : 停止流水线


/approve


/lgtm




【合入来源】
【修改方案】
【资料变更】
不涉及
【接口变更】
不涉及
【功能验证】
【CheckList】