已合并
fix: 在cpu侧增加对bf16类型的数据校验 #2982
fix: 在cpu侧增加对bf16类型的数据校验 #2982
已合并
maohp_hw创建于 6月6日
maohp_hw
maohp_hw成员
6月6日

描述

在CPU模式下,TransDataTo5HD API的数据类型校验函数 CheckTransDataTo5HDParams 缺少对 bfloat16_t 类型的支持,导致使用bf16数据类型时触发错误的类型检查失败。这使得在CPU模式下执行examples/01_simd_cpp_api/02_features/03_basic_api/02_memory_vector_compute/transpose样例(输入改为bfloat16_t类型)会出现报错。

根本原因

CheckTransDataTo5HDParams 函数中的 SupportType 模板参数列表未包含 bfloat16_t 类型,当用户传入bf16类型数据时,会触发类型检查错误:

  • 错误信息提示支持的类型中缺少 bfloat16_t
  • 实际硬件支持该类型,但CPU侧校验阻止了合法操作

解决方案

在 impl/basic_api/kernel_operator_vec_transpose_intf_impl.h 文件中:

  1. 在 CheckTransDataTo5HDParams 函数的类型检查列表中添加 bfloat16_t 类型(具体修改在第60行,其余均为clang-format带来的格式调整)
  2. 更新错误提示信息,将 bfloat16_t 添加到支持的类型列表中
  3. 同时对 .pre-commit-config.yaml 进行格式化调整

关联的Issue

关联Issue #885

测试

Compile通过;
transpose.asc样例在CPU模式下执行通过。

文档更新

NA

类型标签

likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 maohp_hw 的贡献)
maohp_hwmaohp_hw成员
6月6日 创建了 pull request,commit 19f1d920
CANN-robotCANN-robot成员
6月6日 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
6月6日 评论:

CLA Signature Pass

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

likedislike
CANN-robot
CANN-robot成员
6月6日 评论:

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


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
impl/basic_api ✅ chenyiyuan, bianque (2/2) ✅ chenyiyuan (1/1)
repo-cann/asc-devkit ✅ chenyiyuan, bianque (2/2) ✅ chenyiyuan (1/1)

💡 Tip:

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

CLA Signature Pass

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

likedislike
maohp_hwmaohp_hw成员
6月6日 修改了pull request 的描述
此处折叠了96条消息 查看更多
CANN-robotCANN-robot成员
6月8日 添加了label:ci-pipeline-passed
bianque成员
6月8日 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
6月8日 添加了label:lgtm
CANN-robotCANN-robot成员
6月8日 关闭了关联的issue
CANN-robotCANN-robot成员
6月8日 合入了pull request