Closed
[Bug-Report|缺陷反馈]: PSROIPoolingGradV2D Golden 坐标精度不一致与 Host 格式校验缺失 #8502
Hu1L1Add on  11 days agoClosed at  8 days ago
Hu1L1
Hu1L1Collaborators
11 days ago Create

Describe the current behavior / 问题描述

PSROIPoolingGradV2D 存在以下问题(修复前基线:master 的 aad5504ab8):

  1. CPU Golden 使用 FP64 计算 ROI 坐标,在边界处可能得到与算子 FP32 语义不同的 bin 覆盖范围;Promote 输入也应保持坐标和 spatial_scale 的 FP32 语义。
  2. Host Tiling 入口缺少 storage format 校验,直接调用时不能拒绝不支持或 x/y 混用的格式。
  3. Host UT 仅有 5 项 InferShape 测试,缺少 tiling 分支及边界覆盖;GE 示例只检查输出元数据,数值错误仍可能通过。

Environment Information / 环境信息

  • 实现范围:Ascend950 arch35;Golden 复现使用 NumPy/PyTorch CPU,无需 NPU。
  • 修复后 Host UT:服务器容器,Ubuntu 24.04、g++ 13.3、真实 CANN 9.3 / OpBase / registry / 仓库 Faker。
  • 完整 GE 示例编译:服务器 CANN 9.2、g++ 9.4;本次未执行 GE/NPU 图。

Steps to reproduce the issue / 重现步骤

在修复前的算子仓根目录,用 NumPy/PyTorch 执行:

import runpy
import numpy as np

golden = runpy.run_path(
    "pooling/psroi_pooling_grad_v2_d/tests/assets/golden.py"
)["golden_ps_roi_pooling_grad_v2"]
x = np.zeros((1, 1, 31, 31), dtype=np.float32)
x[0, 0, 30, 30] = 1
rois = np.array([0, 1, 1, 1, 1], dtype=np.float32).reshape(1, 5, 1)
y = golden(x, rois, float(np.float32(31 / 61)), 1, 31, [2, 2])[0]
print(y[0, 960])

旧 FP64 坐标路径输出 [[0.25, 0.25], [0.25, 0.25]],而 FP32 分离乘加语义要求 [[0, 0], [0, 1]]。

格式问题可在真实 TilingContext Faker 中使用合法 shape/dtype/platform,将 x/y 的 storage format 改为 NHWC、NC1HWC0,或令 x/y 的 storage format 不一致。旧入口没有对应格式拒绝检查。原 GE 示例的 CheckOutput 只检查 shape、dtype、format、字节数及数据指针,不比较元素值。

Describe the expected behavior / 预期结果

  • Golden 在取整前将 ROI 转为 FP32,scale 属性和后续坐标计算使用 FP32,并保留现有梯度精度模式。
  • Tiling 使用 GetStorageFormat() 检查实际存储布局,要求 rois 为 ND、x/y 存储格式相同且为 ND 或 NCHW;origin 元数据差异不单独作为 tiling 拒绝条件。
  • Host UT 覆盖属性、shape、溢出、32/64 位索引选择和 workspace 回退;示例逐元素比较独立 CPU 参考结果。

storage format 调整前(e24378efc)的服务器真实框架 Host UT:

[==========] 25 tests from 2 test suites ran. (20 ms total)
[  PASSED  ] 25 tests.

其中 12 项 InferShape、13 项 Tiling,均为 CPU Host 验证。一次性 Golden CPU 回归的 28 个子用例通过,反向验证可检出修改前错误。示例在服务器完成目标文件编译,在本机通过参考计算/比较器检查;尚未链接运行示例或进行 GE/NPU 数值验收。

本次 storage format 调整已同步修改 Tiling UT,并通过静态检视和 git diff --check;尚未重新运行 Host UT 或 GE/NPU 图。

Special notes / 备注

修复 PR:ops-nn #14040。本 Issue 对应该 PR 当前的 Golden、Host 格式校验、Host UT 和示例修改。

likedislike
Hu1L1Hu1L1Collaborators
11 days ago Added label: bug-report
Hu1L1Hu1L1Collaborators
11 days ago Associated pull request
yuning_chenyuning_chenCollaborators
11 days ago Assign Hu1L1 as responsible person
Hu1L1Hu1L1Collaborators
11 days ago Modify description of issue
CANN-robotCANN-robotCollaborators
8 days ago Close issue
CANN-robotCANN-robotCollaborators
8 days ago changed custom state from 待办的 to 已完成
CANN-robotCANN-robotCollaborators
8 days ago Added label: resolved