已合并
refactor: unify transto5hd implementations #5146
refactor: unify transto5hd implementations #5146
已合并
leozjr创建于 20 天前
leozjr
leozjr成员
20 天前

描述

统一2201和3510架构的asc_transto5hd实现,消除函数宏并改为inline函数,保持原有AIV分支、底层指令调用和同步语义。公共头统一提供b8、b16、b32非同步接口声明;同步接口不再在公共头声明,并标记为废弃,同时补齐废弃接口文档和导航索引。

具体改动:

  • impl/c_api/instr_impl/npu_arch_2201/vector_compute_impl/asc_transto5hd_impl.h:将6个内部函数宏替换为__aicore__ inline函数。
  • impl/c_api/instr_impl/npu_arch_2201/vector_compute_impl.h:将6个对外wrapper宏替换为__aicore__ inline函数,并废弃3个sync接口。
  • impl/c_api/instr_impl/npu_arch_3510/vector_compute_impl/asc_transto5hd_impl.h:保持与2201一致的inline内部实现。
  • impl/c_api/instr_impl/npu_arch_3510/vector_compute_impl.h:保持与2201一致的inline wrapper实现,并废弃3个sync接口。
  • include/c_api/vector_compute/vector_compute.h:统一提供3个非同步公共函数声明,移除sync接口声明。
  • docs/zh/api/SIMD-API/c_api/deprecated_interface/asc_transto5hd_sync_deprecated.md:新增sync接口废弃文档。
  • docs/zh/api/SIMD-API/c_api/vector_compute/asc_transto5hd.md:移除sync接口原型。
  • docs/zh/api/README.mddocs/zh/api/SIMD-API/c_api/c_api.md和两个废弃接口索引:补充sync接口废弃文档入口。

关联的Issue

关联Issue #1521

测试

  • cmake --build build --target ascendc_ut_c_api_ascend910B1_AIV ascendc_ut_c_api_ascend950pr_9599_AIV -j8:2201和3510 C API AIV target构建并执行成功。
  • build/tests/api/c_api/ascendc_ut_c_api_ascend910B1_AIV --gtest_filter='TestTransdataTo5HDCAPI.*':6/6通过。
  • build/tests/api/c_api/ascendc_ut_c_api_ascend950pr_9599_AIV --gtest_filter='TestTransto5HDCAPI.*':6/6通过。
  • pre-commit run --files <相关Markdown文件>:Markdown链接检查通过。

文档更新

新增sync接口废弃文档并更新相关索引。

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 leozjr 的贡献)
leozjrleozjr成员
20 天前 创建了 pull request,commit 94eb998f
leozjrleozjr成员
20 天前 关联了issue:[Bug-Report|缺陷反馈]: 3510 TransTo5HD 接口使用宏实现
atomgit-bot
atomgit-bot
20 天前 评论:

变更摘要

本 PR 将 3510 架构下 asc_transto5hd 相关的 6 个内部实现宏和 6 个公共 wrapper 宏统一替换为 __aicore__ inline 函数,并保留原有的 ASC_IS_AIV 分支判断、底层 scatter_vnchwconv_b8/b16/b32 指令调用以及 asc_sync_post_process() 同步语义;同时在公共头文件 include/c_api/vector_compute/vector_compute.h 中补齐了仅适用于 3510 架构的 b8、b16、b32 及对应 _sync 接口声明,以避免与 2201 架构的既有宏定义发生冲突。

主要改动

  • 内部实现宏转 inline 函数:在 asc_transto5hd_impl.h 中,将 asc_transto5hd_b8_implasc_transto5hd_b8_sync_implasc_transto5hd_b16_implasc_transto5hd_b16_sync_implasc_transto5hd_b32_implasc_transto5hd_b32_sync_impl 这 6 个函数宏改为 __aicore__ inline 函数,if ASC_IS_AIV 条件分支与底层调用逻辑保持不变。

  • 公共 wrapper 宏转 inline 函数:在 vector_compute_impl.h 中,将 asc_transto5hd_b8asc_transto5hd_b8_syncasc_transto5hd_b16asc_transto5hd_b16_syncasc_transto5hd_b32asc_transto5hd_b32_sync 这 6 个对外宏替换为 __aicore__ inline 函数,并分别转发调用对应的 _impl 实现。

  • 补齐公共头文件声明并限定架构:在 include/c_api/vector_compute/vector_compute.h 中新增上述 6 个接口的 __aicore__ inline 声明,并通过 #if defined(__NPU_ARCH__) && (__NPU_ARCH__ == 3510) 将其限定在 3510 架构下,避免与 2201 的既有宏定义冲突。

likedislike
atomgit-bot
atomgit-bot
20 天前 评论:

代码审查

✅ 未发现问题

likedislike
gao_dafa成员
20 天前 评论:

leozjr,感谢您的提交,建议在完成PR充分自验证后,再触发线上构建任务。

若您的PR已具备检视条件,可根据下表的责任田,@对应的committer进行代码检视,我们会在第一时间对您的提交进行处理。

代码责任田:

module committer
adv_api chenyiyuan, wuyang_hw
basic_api chenyiyuan, wuyang_hw
c_api pangfd, haipingmao
cmake xun_zhuge, DragonBornHD84
docs munanhw, ai_xin
examples changxianyu, bianque
simt_api wulinyu, zhanghao_0689
scripts xun_zhuge, kevin365
tools YANXI_ZHAO, XuebinYang, sjtulxh

💡 如您不确定可以@谁,可以直接@我或者ascend-c sig的maintainer,xun_zhugeascendhjh,我们会为您分配合适的committer进行代码检视。

再次感谢您参与CANN的社区贡献。

likedislike
此处折叠了322条消息 查看更多
CANN-robotCANN-robot成员
2 天前 删除了label:cann-cla/yes
CANN-robotCANN-robot成员
2 天前 添加了label:cann-cla/yes
CANN-robotCANN-robot成员
2 天前 删除了label:ci-pipeline-passed
CANN-robotCANN-robot成员
2 天前 删除了label:lgtmapproved
CANN-robotCANN-robot成员
2 天前 合入了pull request