Merged
feat: 9201架构新增类型转换C API接口(half2int8/half2int4x2/bfloat162exmy及asc_cast/asc_cast_merge) #6189
zhangfeifan0709Add on Sep 18
feat: 9201架构新增类型转换C API接口(half2int8/half2int4x2/bfloat162exmy及asc_cast/asc_cast_merge) #6189
Merged
Pull Request has been successfully merged by CANN-robot.
(Thank you for zhangfeifan0709's contribution.)Sep 18 Created pull request, commit c64755f7
Sep 18 Added label: stat/needs-squash
Sep 18 Added label: cann-cla/yes
CANN-robot
Sep 18 Comments:
Sep 18 Comments:
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 |
|---|---|---|
| impl/c_api | ✅ wuyang_hw, Lycheeeee (2/2) | ✅ Lycheeeee (1/1) |
| include/c_api | ✅ wuzhaolin, Lycheeeee, wuyang_hw (3/2) | ✅ wuzhaolin (1/1) |
| include/c_api/reg_compute | ✅ horming, Lycheeeee, wuyang_hw (3/2) | ✅ horming (1/1) |
| repo-cann/asc-devkit | ✅ Lycheeeee, wuyang_hw (2/2) | ✅ Lycheeeee, wuyang_hw (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
zhangfeifan0709, thanks for your pull request. All authors of the commits have signed the CLA. 👍


Sep 18 Set zengjuan,zhanghao_0689,suqwe,wulinyu,horming,kong0808,dengjing_aoe,YeZZzzz1,bluesky901,yangbinhua,zhudi22,chenyiyuan,xun_zhuge,XuebinYang,sjtulxh,bianque,houyuyang,pangfd,Lycheeeee,YANXI_ZHAO,chentianyu19,shi_nanxiang,wuyang_hw,jiangxinyu3,ascendhjh,hujiawen_kaven,wangxiaozhi,DragonBornHD84,louyuxuan,hyolee,yukangchen,wuzhaolin as approver
Sep 18 Set zengjuan,zhanghao_0689,suqwe,wulinyu,horming,kong0808,dengjing_aoe,YeZZzzz1,bluesky901,yangbinhua,zhudi22,chenyiyuan,xun_zhuge,XuebinYang,sjtulxh,bianque,houyuyang,pangfd,Lycheeeee,YANXI_ZHAO,chentianyu19,shi_nanxiang,wuyang_hw,jiangxinyu3,ascendhjh,hujiawen_kaven,wangxiaozhi,DragonBornHD84,louyuxuan,hyolee,yukangchen,wuzhaolin as approver
317 messages are collapsed here。 See more
Oct 12 Added label: lgtm
horming
Oct 12 Comments:
Oct 12 Comments:
/approve


wuzhaolin
Oct 12 Comments:
Oct 12 Comments:
/approve


Oct 12 Added label: approved
Oct 12 Merged pull request
描述
变更概述
本PR为 9201 架构(a6) 新增 reg_compute 类型转换 C API 接口及配套指令级 UT,共引入 190 个转换接口重载(172 void + 18 return)与 1 个类型别名
vector_fp8_e6m2_t,提供「专用命名」与「泛型命名(asc_cast/asc_cast_merge)」两套语义等价的接口;全部新增声明统一纳入ASC_DEVKIT_VERSION_NUM >= 90200000版本宏门控,并已 rebase 至最新 master 解决合并冲突。新增接口明细
1. 专用命名接口(104 个重载,类型与舍入/饱和模式编入函数名)
half → int8 合并写入(20 重载)
asc_half2int8_{rd,rn,rna,ru,rz}{,_sat}_merge(MODE_MERGING,mask=false 处保留 dst 原值)vcvthalf → int4x2 合并写入(40 重载)
asc_half2int4x2_{rd,rn,rna,ru,rz}{,_sat}_mergevcvt_f162s4(PART_P0~P3)bfloat16 → FP8 系列(44 重载)
asc_bfloat162e4m3_rn{,_sat}vcvtasc_bfloat162e4m3_rn{,_sat}_mergevcvtasc_bfloat162e5m2_rn{,_sat}vcvtasc_bfloat162e5m2_rn{,_sat}_mergevcvtasc_bfloat162e6m2_rnvcvt_bf162e6m2(无饱和参数)asc_bfloat162e8m0_{ru,rz}{,_sat}vcvt_bf162e8m0其中 e6m2 为 9201 新增目标类型,配套在
include/c_api/defs/type.h新增类型别名vector_fp8_e6m2_t = vector_f8e6m2。2. 泛型命名接口(86 个重载,舍入/饱和/位置通过模板参数区分)
统一签名形态:
__simd_callee__ inline void asc_cast[_merge]( vector_<dst>& dst, vector_<src> src, vector_bool mask, std::integral_constant<asc_cast_round_mode, ...> round_mode, std::integral_constant<asc_cast_saturation_mode, ...> saturation_mode, // e6m2 无此项 std::integral_constant<asc_position(_quarter)_mode, ...> dst_pos);asc_cast_merge(68 重载,全新接口族,通用层此前无任何 merge 版 cast)vcvt_f162s4vcvtvcvtvcvtasc_cast(18 重载,既有接口族新增 9201 专属类型组合)vcvtvcvtvcvt_bf162e6m2vcvt_bf162e8m0两套命名接口已程序化核验:86 个 void 重载严格一一对应,每个配对发出的底层
vcvt*指令(含全部参数)逐字符一致;cast 族不提供返回值形态,是用户视角的唯一差异。舍入模式 → 指令参数映射:RD→ROUND_F、RN→ROUND_R、RNA→ROUND_A、RU→ROUND_C、RZ→ROUND_Z;饱和 → RS_ENABLE/RS_DISABLE;位置 → PART_EVEN/PART_ODD、PART_P0~P3。版本宏门控与冲突解决
include/c_api/reg_compute/reg_convert.h中 190 个新增声明整体置于#if (ASC_DEVKIT_VERSION_NUM >= 90200000)门控块,vector_fp8_e6m2_t别名同步纳入门控(include/c_api/defs/type.h),避免影响 9.2.0 之前版本的编译兼容性reg_convert.h的合并冲突(声明区块重排,接口集合不变)配套改动
impl/c_api/reg_base_impl/npu_arch_9201/reg_convert_intf_impl.himpl/c_api/reg_base_impl/reg_convert_intf_impl.h__NPU_ARCH__ == 9201impl 分发包含;5 处过时注释清理include/c_api/asc_simd.h、include/c_api/asc_reg_vector.h3510扩展为3510 || 9201,修复 9201 下 reg_compute 接口链不可达tests/api/c_api/stub/cce_stub.hFp8e6m2T/vector_f8e6m2类型与vcvt(f8e4m3/e5m2←bf16)、vcvt_bf162e6m2、vcvt_bf162e8m0stub(仅 UT 环境)设计决策
_merge:语义明确,区别于 MODE_ZEROING 常规写入(mask=false 处写 0)关联的Issue
无
测试
新增
tests/api/c_api/npu_arch_9201/utils/test_vcvt_instr_utils.h(指令级 UT 框架宏)与 8 个测试文件,mockcpp 指令级 mock,190 个用例与 190 个新重载 1:1 对应:test_asc_half2int4x2.cpptest_asc_half2int8.cpptest_asc_bfloat162e4m3.cpptest_asc_bfloat162e5m2.cpptest_asc_bfloat162e6m2.cpptest_asc_bfloat162e8m0.cpptest_asc_cast.cpptest_asc_cast_merge.cpp测试结果:
文档更新
无独立文档更新,接口以头文件声明为准。
类型标签