已关闭
[算子开发][内测体验][AscendC][Documentation|文档反馈]: GlobalTensor示例存在不兼容的指针类型 #1562
yc创建于  8月21日关闭于  8月22日
yc
8月21日 创建

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

Document Link(文档链接)

https://gitcode.com/cann/asc-devkit/blob/master/docs/zh/guide/programming_guide/programming_model/ai_core_simd_programming/cpp_tensor_programming/cpp_tensor_programming_overview.md

Issues Section(问题文档片段)

image.png
核函数参数是__gm__ uint8_t* x,随后直接传给:
AscendC::GlobalTensor xGm;
xGm.SetGlobalBuffer(x + block_idx * blockLength, blockLength);
但是GlobalTensor::SetGlobalBuffer 要求__gm__ float*,相关声明见include/basic_api/kernel_tensor.h(line265)
建议将核函数参数改为__gm__ float*

Existing Issues(存在的问题)

likedislike
Llihuaichao成员
8月21日 将 lihuaichao 设为负责人
lihuaichao成员
8月21日 评论:

感谢反馈,该问题已确认。

核函数的GM入参使用__gm__ uint8_t*是支持的,仓库样例通常也采用该形式。问题在于示例将uint8_t*直接传给了GlobalTensor<float>::SetGlobalBuffer,与接口要求的__gm__ float*类型不匹配。

计划保留核函数的U8类型入参,将示例修改为:

xGm.SetGlobalBuffer(reinterpret_cast<__gm__ float*>(x) + block_idx * blockLength, blockLength);

另外,将核函数参数改为__gm__ float*,也是可以的,当前并没有统一要求。

likedislike
lihuaichao成员
8月22日 评论:

您好,相关修改已合入。
我们先关闭此issue,如有其他问题,欢迎再提issue交流~

likedislike
Llihuaichao成员
8月22日 issue状态由 进行中 改变为 已解决
Llihuaichao成员
8月22日 关闭了 issue
CANN-robotCANN-robot成员
8月22日 添加了label:resolved
Llihuaichao成员
25 天前 添加了label:Accepted