Closed
[Requirement|需求建议]: 长尾算子加固:ForeachDivList/ForeachAddcdivScalar 校验补齐与 Ascend350(DVLite) 适配 #7192
wenqi_wuAdd on  Oct 22Closed at  Oct 23
wenqi_wu
wenqi_wu
Oct 22 Create

Background(背景信息)

长尾算子加固工作的一部分:ForeachDivList 与 ForeachAddcdivScalar 属于 foreach 算子族,当前对非法输入缺少前置校验(列表长度不一致、负维度、标量 dtype/元素数非法等),存在静默截断或越界风险;同时两算子缺少 Ascend350(DVLite) 平台适配(CMakeLists 未纳入 ascend350、def.cpp 未注册、缺少 config/ascend350 二进制配置、中央 ascendc_config.json 未登记),无法在 Ascend350 上构建运行。

Origin(信息来源)

CANN ops-nn 仓库长尾算子加固工作项,验证方式:静态检查 + kernel + GEIR(对齐同族 Ascend350 适配模式,参考 PR#9834)。

Benefit / Necessity (价值/作用)

  • 非法输入在 host 侧(tiling/op_api)被明确拒绝,避免 kernel 侧静默截断或越界,提升算子鲁棒性
  • 消除单 Tensor >2^31 元素的截断与错误核切分(maxTensorElements 全链路 int64)
  • 使两算子可在 Ascend350(DVLite) 上编译、打包与执行,补齐新平台覆盖
  • 文档与用例同步补齐,便于同族算子对齐

Design(设计方案)

  • 前置校验:ForeachDivList 新增 CheckTensorListInfo(x2/y 列表长度、逐 Tensor rank/shape/dtype,y 放宽为元素数比较);ForeachAddcdivScalar 新增列表长度一致/rank<=8/形状非负/dtype 一致/标量元素数=1 校验,op_api v1/v2 同步收紧 scalar 与列表长度校验
  • 边界修复:maxTensorElements 全链路改 int64
  • 平台适配四件套:op_host/op_kernel CMakeLists COMPUTE_UNITS 增加 ascend350;def.cpp AddConfig("ascend350");新增 op_host/config/ascend350/*_binary.json;中央 scripts/kernel/binary_config/ascendc_config.json 对应用算子条目补充 ascend350

关联 PR:https://gitcode.com/cann/ops-nn/pull/12531

likedislike
wenqi_wuwenqi_wu
Oct 22 Added label: requirement
wenqi_wu
wenqi_wu
Oct 22 Comments:

/assign @wenqi_wu

likedislike
CANN-robotCANN-robotCollaborators
Oct 22 Assign wenqi_wu as responsible person
CANN-robotCANN-robotCollaborators
Oct 23 Close issue
CANN-robotCANN-robotCollaborators
Oct 23 Added label: resolved