Closed
[Requirement|需求建议]: pad_v2 支持 COMPLEX64/COMPLEX128,constant_values 调整为可选 #4016
tan_xinAdd on  15 days agoClosed at  13 days ago
tan_xinCollaborators
15 days ago Create

一、背景信息 (必填)

pad_v2 算子当前不支持 COMPLEX64/COMPLEX128 复数数据类型,且 constant_values 被文档描述为必选 Tensor,Tiling 侧存在冗余的前置校验(paddings 空数据拦截、constant_values dtype 一致性及标量形状校验),限制了算子在复数张量填充场景下的使用。circular_pad_grad 反向算子的 shape 校验过于严格(padding 必须小于对应维度、gradOutput 前导维度必须与 self 一致),与实际允许场景不符。

二、价值/作用 (必填)

  • 使 pad_v2 算子支持 COMPLEX64/COMPLEX128 复数数据类型,补齐复数张量填充能力
  • 将 constant_values 调整为可选输入(仅在 constant 模式下用于指定填充值,缺省为 0),简化调用并降低使用门槛
  • 移除 pad_v2 Tiling 冗余前置校验,与 PadV3 共享 Tiling 的契约保持一致
  • 放宽 circular_pad_grad 的 shape 校验,使参数约束与算子实际行为一致

三、设计方案 (必填)

3.1 使能方式(涉及哪些框架:如Aclnn直调、Pytorch训练等)

GE 图模式(通过算子 IR 接口方式调用),aclnn 直调。

3.2 总体设计
3.2.1 算子支持的数据类型

pad_v2 的 x、constant_values、y 在原有 FLOAT、FLOAT16、INT32、INT64、INT16、INT8、UINT8、UINT16、UINT32、UINT64、BOOL、DOUBLE、BFLOAT16、HIFLOAT8、FLOAT8_E5M2、FLOAT8_E4M3FN、FLOAT8_E8M0、FLOAT4_E2M1、FLOAT4_E1M2 基础上新增 COMPLEX64、COMPLEX128;paddings 支持 INT32、INT64。

3.2.2 host侧设计
  • pad_v2:移除 Tiling 前置校验(paddings 空数据拦截、constant_values dtype 一致性校验、constant_values 必须为标量校验),constant_values 文档描述由必选改为可选;example 增加 mode 属性并简化样例缓冲区管理
  • circular_pad_grad:移除 padding 各值小于对应 self 维度校验、gradOutput 前导维度与 self 一致性校验,错误码由 ACLNN_ERR_PARAM_NULLPTR 修正为 ACLNN_ERR_INNER_NULLPTR
3.2.3 kernel侧设计

pad_v2 复用 PadV3 的 Tiling 类实现,kernel 侧无结构变更;circular_pad_grad kernel 侧无变更。

3.3 支持硬件
  • pad_v2:ascend350、ascend950、ascend960dt
  • circular_pad_grad:ascend350、ascend910_93、ascend910b、ascend950、ascend960dt、ascend960pr

3.4 算子约束限制

  • x、constant_values、y 必须使用相同的数据类型
  • paddings 必须使用 INT32 或 INT64
  • 负填充(slice)时,输出 shape = x.shape[d] + left + right >= 0

💡 备注(选填)

关联 PR:https://gitcode.com/cann/ops-math/pull/6513

likedislike
Ttan_xinCollaborators
15 days ago Added label: requirement
tan_xinCollaborators
15 days ago Comments:

/assign @tan_xin

likedislike
CANN-robotCANN-robotCollaborators
15 days ago Assign tan_xin as responsible person
CANN-robotCANN-robotCollaborators
13 days ago Close issue
CANN-robotCANN-robotCollaborators
13 days ago Added label: resolved