Pull Request has been successfully merged by CANN-robot.
(Thank you for jayshu's contribution.)变更摘要
本次变更在 aclnnNpuFormatCast 接口中新增了对 FLOAT8_E8M0 数据类型从 ND 格式到 FRACTAL_NZ(Nn)存储格式的转换支持。该场景主要用于 MX scale 数据的 Nn 布局转换:逻辑 shape 为 (..., KScale, N, 2),Nn 存储 shape 为 (..., ceil(N/16), KScale, 16, 2)。实现上通过新增的 TransFloat8E8m0NdToNn 函数,采用 Reshape + Transpose 组合操作完成转换,并配套增加了 shape 校验、目标 shape 计算以及 Ascend950 L2 单元测试用例。
主要改动
- 新增
FLOAT8_E8M0类型支持与路由逻辑:在ASCEND950_WEIGHT_DTYPE_SUPPORT_LIST和WEIGHT_DTYPE_SUPPORT_LIST中加入DT_FLOAT8_E8M0;新增IsFloat8E8m0NdToNn判断函数,并在aclnnNpuFormatCastCalculateSizeAndFormat和aclnnNpuFormatCastGetWorkspaceSize中优先路由到 E8M0 ND→Nn 专用处理分支。 - 新增 E8M0 Nn shape 校验与计算:新增
CheckFloat8E8m0NnShape校验输入必须为 3D 或 4D、最后一维为 2、N 维对齐 16;新增ValidFloat8E8m0NnDstShape校验输出存储 shape 符合(..., ceil(N/16), KScale, 16, 2);新增CalcFloat8E8m0NdToNn计算目标 shape 并设置 actualFormat 为FORMAT_FRACTAL_NZ。 - 新增基于 Reshape + Transpose 的转置实现:新增
TransFloat8E8m0NdToNn,将输入先 Reshape 为(..., KScale, N/16, 16, 2),再通过 Transpose 交换 KScale 轴与 N/16 轴,得到 Nn 存储布局,并正确设置输出 tensor 的 view/ storage/ original 的 format 与 shape。 - API 文档更新:在
aclnn_npu_format_cast.h中为aclnnNpuFormatCast和aclnnNpuFormatCastCalculateSizeAndFormat的注释补充了FLOAT8_E8M0数据类型及 MX scale Nn 转换场景说明,additionalDtype参数增加ACL_FLOAT8_E8M0。 - 新增 Ascend950 L2 单元测试:在
test_aclnn_npu_format_cast_l2.cpp中新增三个测试用例,覆盖合法 4D/3D 形状转换以及 N 维未对齐 16 时返回ACLNN_ERR_PARAM_INVALID的错误路径。


Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| */*/docs/acl*.md | ✅ 陈娇, 周奇龙, zhangzijie (3/2) | ✅ 陈娇 (1/1) |
| */*/op_host/op_api/*.h | ✅ zhangzijie, 周奇龙, 王永光 (3/2) | ✅ 王永光 (1/1) |
| conversion/npu_format_cast | ✅ zhangzijie, 周奇龙 (2/2) | ✅ 周奇龙, zhangzijie (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
jayshu, thanks for your pull request. All authors of the commits have signed the CLA. 👍


/lgtm
/approve


描述
aclnnNpuFormatCast中支持FLOAT8_E8M0从 ND 转换到 scale NZ 昇腾亲和格式。(..., ceil(N/16), KScale, 16, 2)。FLOAT8_E8M0、非目标格式转换等存量路径保持不变。关联的Issue
测试
二级冒烟+泛化验证
文档更新
aclnnNpuFormatCast.md,补充FLOAT8_E8M0scale NZ 昇腾亲和格式转换说明。类型标签