已关闭
[Requirement|需求建议]: reduce_std_v2算子Ascend C实现 #1837
ava创建于  6月4日关闭于  6月22日
ava
ava
6月4日 创建

Thanks for sending an requirement! Please fill in the following template to help quickly solve your problem.

一、背景信息 (必填)

新增reduce_std_v2算子的Ascend C实现

二、价值/作用 (必填)

该需求用于提升 reduce_std_v2 的可维护性和可交付性,支持在 Ascend 910B3 环境完成本地编译、UT、安装和上板示例验证。

三、设计方案 (必填)

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

使能方式为 aclnn 直调接口:

  • 对外接口:aclnnStdGetWorkspaceSize / aclnnStd
  • 示例入口:experimental/math/reduce_std_v2/examples/test_aclnn_std.cpp
3.2 总体设计

aclnnStd host 侧完成参数校验、shape 推导、空 tensor/特殊 correction 处理,并根据平台选择执行路径。

3.2.1 算子支持的数据类型

当前 aclnnStd 支持:

  • Ascend 910B 系列:

    • float32
    • float16
    • bfloat16
  • Ascend 910 系列:

    • float32
    • float16

输入 self 与输出 out 需要满足 dtype 支持列表,并满足 dtype cast 约束。

3.2.2 host侧设计

host 侧主要包含:

  • 参数校验:

    • self/out 非空
    • dtype 支持检查
    • dim 范围检查
    • dim 去重检查
    • out shape 与 reduce 推导结果一致
  • shape 处理:

    • 支持 dim == nullptr 或空 dim,表示全维度 reduce
    • 支持负 dim 转正
    • 支持 0 维 tensor reshape 到 {1} 参与后续逻辑
  • 特殊值处理:

    • 空 tensor 输出 NaN
    • shapeProd <= correction 场景输出 NaN 或 Inf
  • 910B3 可用路径:

    • 走组合实现:ReduceMean + Expand + ReduceStdWithMean + Cast + ViewCopy
  • UT 支撑:

    • 在 tests/ut/op_api 增加 UT-only l0op stub,补齐 op_api UT 链接与 shape 推导,不影响正式 package 产物。
3.2.3 kernel侧设计

reduce_std_v2 当前保留 arch35 AICore kernel 实现,面向支持 arch35 的硬件路径。

3.3 支持硬件

当前设计支持:

  • Ascend 910B3:通过 aclnnStd 组合路径验证通过
  • Ascend 950 / arch35:保留原生 ReduceStdV2 AICore kernel 注册和配置

已验证环境:

  • CANN:8.5.0-beta.1
  • SoC:ascend910b
  • NPU:910B3
  • package 安装与 NPU 示例运行通过

3.4 算子约束限制

当前约束:

  • self/out 仅支持 float32、float16,910B 系列额外支持 bfloat16。
  • dim 必须在合法维度范围内,重复 dim 不支持。
  • out shape 必须与 dim/keepdim 推导结果一致。
  • 当前 reduce_std_v2 arch35 AICore kernel 不支持直接声明为 ascend910b 编译运行。
  • 910B3 上可用路径为 aclnnStd 组合实现,不是 custom ReduceStdV2 AICore kernel 直出。
likedislike
ava
ava
6月4日 评论:

/assign

likedislike
CANN-robotCANN-robot成员
6月4日 将 tieyutong 设为负责人
avaava
6月4日 关联了pull request:新增Ascend C实现的reduce_std_v2算子
CANN-robotCANN-robot成员
6月22日 关闭了 issue
CANN-robotCANN-robot成员
6月22日 添加了label:resolved