已合并
Fix test_torch index dfx checks #4885
Fix test_torch index dfx checks #4885
已合并
jiangna1111创建于 4月30日
jiangna1111
jiangna1111
4月30日

【合入来源】

如有社区issue,请关联issue链接
请勿携带内部流程信息(需求链接、问题单、内部issue等)

Fixes [Bug]: PyTorch test_torch 部分用例在NPU后端 DFX 行为未对齐

本 PR 目的为修复 PyTorch 官方 test/test_torch.py 社区用例在 NPU 后端上的 DFX 对齐问题。相关用例包括:

【修改方案】

请描述修改内容的具体实现,涉及哪些组件之间进行交互,可以用 1、2、3...进行罗列
如果是需求或者重构类的PR,需要补充详细设计文档(说明上下游组件关系、时序图、类图、DFX能力等内容)

    • op_plugin/ops/opapi/IndexAddKernelNpuOpApi.cpp
    • index_add_outindex_add 两个入口中,除了操作维度 dim 外,其他剩余维度 shape 也要验证一致。不一致抛出错误。
    • PyTorch 原生 index_func_meta_implindex_add 会检查 self_sizes == source_sizes,其中 self_sizes/source_sizes 已经排除了指定维度。
    • op_plugin/ops/opapi/IndexPutKernelNpuOpApi.cpp
    • op_plugin/ops/aclops/IndexPutKernelNpu.cpp
    • 检查 selfvalueindices,检查 self 和每个有效 index tensor 之间不能存在内存重叠。
    • torchnpugen/struct/struct_codegen.py

    • 增加 ${memory_overlap_checks} 占位,仅当生成函数名为 index_copy_ 时,注入以下检查:

      at_npu::native::assert_no_internal_overlap(self);
      at_npu::native::assert_no_overlap(self, index);
      at_npu::native::assert_no_overlap(self, source);
      
    • 为生成的 C++ 文件增加 NPUMemoryOverlap.h 头文件,否则 assert_no_overlap 等函数声明不可见,编译会失败。

  1. index_fill_npu_* 用例说明。

    • 当前 op-plugin master 已包含 complex scalar 到非 complex tensor 的提前拦截逻辑,本 PR 主要补齐 index_addindex_put_index_copy_ 相关 DFX 检查。

【资料变更】

请确认是否涉及资料变更。如涉及,需要在PR中体现,并简要说明修改内容。如不涉及,需填写“不涉及”

不涉及。

【接口变更】

请确认是否涉及跨代码仓或者客户面可见的接口变更。如涉及,需要详细说明接口以及对应的变更内容,同时需要在资料中体现。如不涉及,需填写“不涉及”

不涉及。

【功能验证】

说明测试场景,测试方法。如果本次测试方式与常规单元测试不同,请详细说明您的测试步骤
新增/变更内容是否已新增/适配UT测试用例看护,并补充测试自验证截图

验证环境:

  • CANN:cann8.3
  • PyTorch:2.7.1
  • op-plugin:master

验证测试用例:

  • test_index_add_cornercase
  • test_index_copy_mem_overlap_npu
  • test_index_put_mem_overlap_npu
  • test_index_fill_npu_bfloat16
  • test_index_fill_npu_bool
  • test_index_fill_npu_float16
  • test_index_fill_npu_float32
  • test_index_fill_npu_int32
  • test_index_fill_npu_int64

验证结果:
Result

  • [PASS] test_index_add_cornercase
  • [PASS] test_storage_error
  • [PASS] test_index_copy_mem_overlap_npu
  • [PASS] test_index_fill_npu_bfloat16
  • [PASS] test_index_fill_npu_bool
  • [PASS] test_index_fill_npu_float16
  • [PASS] test_index_fill_npu_float32
  • [PASS] test_index_fill_npu_int32
  • [PASS] test_index_fill_npu_int64
  • [PASS] test_index_put_mem_overlap_npu

【CheckList】

PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 jiangna1111 的贡献)
jiangna1111jiangna1111
4月30日 创建了 pull request,commit 4b6184a0
ascend-robot
ascend-robot成员
4月30日 评论:

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 culechan, zichun_ye (2/2) zichun_ye (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
ascend-robotascend-robot成员
4月30日 添加了label:ascend-cla/no
ascend-robot
ascend-robot成员
4月30日 评论:

Ascend docs pipeline is running...

likedislike
此处折叠了80条消息 查看更多
ascend-robotascend-robot成员
5月14日 添加了label:docs-ci-pipeline-success
culechan
culechan成员
5月25日 评论:

/lgtm

likedislike
ascend-robotascend-robot成员
5月25日 添加了label:lgtm
ascend-robot
ascend-robot成员
5月25日 评论:

Review Guide

This pull-request passes review.
Committers who wrote a comment of /approve are: zichun_ye.
Reviewers who wrote a comment of /lgtm are: culechan, zichun_ye.

likedislike
ascend-robotascend-robot成员
5月25日 合入了pull request