Closed
[Bug-Report|缺陷反馈]: 长尾算子质量加固-space_to_batch_nd: 修复padding越界拷贝、空张量golden异常及静态检查治理 #4421
gylAdd on  7 days agoClosed at  3 days ago
gyl
gylCollaborators
7 days ago Create

一、问题描述

长尾算子质量加固中,对 space_to_batch_nd(Ascend950 / arch35)完成功能修复与静态检查/告警治理。

A. 功能缺陷(已修复)

  1. padding 区被写入输入数据(越界拷贝):有效范围计算 absMax、bcEnd 使用 C++ 截断除法,底部 padding 块(padTop + spatial - 1 - blockIdx < 0)被截断为 0 而误判为有效,导致越界读取输入并写入 padding 区。
  2. CopyInKey4 未按有效范围裁剪 dim(ubAxis+1):直接按 outShape[ubAxis+1] 复制多个平面,padding 平面被相邻行数据填充。
  3. 空张量 golden 失败:L0_empty_037/038 报 GOLDEN_FAILURE,golden 对 0 尺寸维调用 PyTorch F.pad,抛 "negative output size"。

B. 静态检查 / 健壮性治理

  1. 溢出保护:新增 SafeAddI64 / SafeMulI64 / SafeMulU64 检查算术;tiling 辅助函数改为返回 ge::graphStatus 并通过 OP_CHECK_IF 传播错误。
  2. 类型与编译告警:对 rank、numSpatialDims、blockShapeLen、paddings shape 等显式 static_cast,消除有符号/无符号及窄化告警;kernel 的 DataCopy/LoopMode 参数由 uint32 改为 int64,避免 stride 截断。
  3. 参数校验:paddings 必须为 [M,2] 且元素非负;block_shape 长度须在 [1, MAX_SPATIAL] 且小于 x rank;padded 空间维须能被 block_shape 整除;输入 rank 限制在 [2, MAX_INPUT_RANK]。
  4. 常量与定义:拆分 MAX_INPUT_RANK、MAX_RANK = MAX_SPATIAL + 2;proto 补充 bool / complex32 类型声明与 namespace ge;def 修正 opFile.value 为 space_to_batch_nd。

二、环境信息

  • 昇腾硬件:Ascend950PR(9579 / 957c)
  • CANN:9.2.0-beta.2
  • 算子路径:ops-math conversion/space_to_batch_nd(arch35)
likedislike
gylgylCollaborators
7 days ago Added label: bug-report
gylgylCollaborators
7 days ago Assign guyunlong1 as responsible person
gylgylCollaborators
7 days ago Associated pull request
gyl
gylCollaborators
7 days ago Comments:

已提交修复 PR:https://gitcode.com/cann/ops-math/merge_requests/7036

  • 修复 padding 越界拷贝:absMax / bcEnd 截断除法,以及 CopyInKey4 未按有效范围裁剪 dim(ubAxis+1)
  • 修复空张量 golden:避免对 0 尺寸维调用 PyTorch F.pad
  • 静态检查 / 健壮性治理:溢出保护、类型告警清理、参数校验等
  • 验证:TTK Kernel 与 GEIR 动态 shape L0_001~005 均 5/5 PASS
likedislike
CANN-robotCANN-robotCollaborators
3 days ago Close issue
CANN-robotCANN-robotCollaborators
3 days ago changed custom state from 进行中 to 已完成
CANN-robotCANN-robotCollaborators
3 days ago Added label: resolved