Merged
AscendC C API新增带返回值接口 #5266
AscendC C API新增带返回值接口 #5266
Merged
CruiterAdd on Aug 21
Cruiter
CruiterCollaborators
Aug 21

描述

AscendC C API新增带返回值接口

关联的Issue

测试

文档更新

类型标签

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for Cruiter's contribution.)
CruiterCruiterCollaborators
Aug 21 Created pull request, commit eced5ef8
atomgit-bot
atomgit-bot
Aug 21 Comments:

变更摘要

该 PR 为 AscendC C API 的向量计算与类型转换接口新增"带返回值"形式的重载:原有接口(如 asc_relu(vector_float& dst, ...))通过输出参数 dst 返回结果,本次改动新增直接以返回值形式(如 vector_float asc_relu(vector_float src, vector_bool mask))调用的版本,其实现方式为在函数内部定义 dst 变量、调用对应 *_impl 后返回结果。改动覆盖 vector_compute_impl.h、reg_vector.h、reg_convert.h 等核心头文件,并新增 asc_muls_cast 接口及对 asc_fma、asc_madd 的数据类型扩展,同时补充了相应测试。

主要改动

  • 新增带返回值的向量计算接口重载:在 vector_compute_impl.h 与 reg_vector.h 中,为 asc_relu、asc_select、asc_abs_sub、asc_abs、asc_axpy、asc_ln、asc_exp_sub、asc_exp_sub_half2float、asc_reduce_max/asc_reduce_min/asc_reduce_sum(含 *_datablock 变体)、asc_*_scalar(add/mul/min/max)以及 asc_ge_scalar/asc_gt_scalar/asc_ne_scalar 等接口新增直接返回 vector 结果的重载函数,将原"输出参数写结果"改为"返回结果"的调用方式。
  • 转换类接口新增带返回值重载:在 reg_convert.h 中为 asc_int322float_rd/ru/rz/rn/rna、asc_float2bfloat16_rd/rn/rna/ru/rz(含 _sat)、asc_int322int16/asc_int322uint16(含 _sat)、asc_int322int64、asc_uint82uint16 等类型转换接口补充返回类型重载,并支持 EVEN/ODD 位置模式参数。
  • 新增 asc_muls_cast 接口:新增实现文件 asc_muls_cast_impl.h,基于 vmulscvt 指令实现 float 数据乘标量并转换输出为 half,支持 EVEN/ODD 位置模式,同时在 vector_compute_impl.h 与 reg_vector.h 中提供声明及带返回值版本。
  • 扩展 asc_fma 与 asc_madd 数据类型:asc_fma_impl.h 新增 vector_int16_t/vector_uint16_t/vector_int32_t/vector_uint32_t 类型的 asc_fma_impl(基于 vmula),asc_madd_impl.h 新增 vector_bfloat16_t 的 asc_madd_impl(基于 vmadd),并在 reg_vector.h 与 vector_compute_impl.h 中补充声明与实现。
  • 补充接口测试:新增带返回值接口测试文件 test_asc_return_value.cpp 与 test_asc_muls_cast.cpp,为 asc_fma 新数据类型、asc_madd 的 vector_bfloat16_t、asc_muls_cast 的 EVEN/ODD 位置调用补充测试用例,并在 host_header_reg_compute_checker.cpp 中增加 asc_muls_cast 符号检查。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Aug 21 Comments:

代码审查

✅ 未发现问题

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Aug 21 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Aug 21 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
docs ✅ munanhw, houyuyang, wuyang_hw (3/2) ✅ munanhw (1/1)
impl/c_api ✅ pangfd, houyuyang, wuyang_hw (3/2) ✅ pangfd (1/1)
include/c_api/reg_compute ✅ horming, houyuyang, wuyang_hw (3/2) ✅ horming (1/1)
repo-cann/asc-devkit ✅ houyuyang, wuyang_hw (2/2) ✅ houyuyang (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

printfscanfmain, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
277 messages are collapsed here。 See more
houyuyang
houyuyangCollaborators
Aug 29 Comments:

/lgtm
/approve

likedislike
CANN-robotCANN-robotCollaborators
Aug 29 Added label: approved
吴洋
吴洋Collaborators
Aug 29 Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
Aug 29 Added label: lgtm
CANN-robotCANN-robotCollaborators
Aug 29 Merged pull request