三亩地 三亩地SAN MU DI · CODE DIARY
ARTICLE DETAIL

日记详情

真实记录编程学习的某一天,欢迎挑你感兴趣的翻一翻。

CANN/asc-devkit向量计算int32转int64函数

CANN/asc-devkit向量计算int32转int64函数

asc_int322int64

【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言,原生支持C和C++标准规范,主要由类库和语言扩展层构成,提供多层级API,满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit

产品支持情况

产品是否支持
Atlas A3 训练系列产品/Atlas A3 推理系列产品
Atlas A2 训练系列产品/Atlas A2 推理系列产品

功能说明

将int32_t类型数据转换为int64_t类型。

函数原型

  • 前n个数据计算

    __aicore__ inline void asc_int322int64(__ubuf__ int64_t* dst, __ubuf__ int32_t* src, uint32_t count)
  • 高维切分计算

    __aicore__ inline void asc_int322int64(__ubuf__ int64_t* dst, __ubuf__ int32_t* src, uint8_t repeat, uint16_t dst_block_stride, uint16_t src_block_stride, uint16_t dst_repeat_stride, uint16_t src_repeat_stride)
  • 同步计算

    __aicore__ inline void asc_int322int64_sync(__ubuf__ int64_t* dst, __ubuf__ int32_t* src, uint32_t count)

参数说明

参数名输入/输出描述
dst输出目的操作数(矢量)的起始地址。
src输入源操作数(矢量)的起始地址。
count输入参与计算的元素个数。
repeat输入迭代次数。
dst_block_stride输入目的操作数单次迭代内不同DataBlock间地址步长。
src_block_stride输入源操作数单次迭代内不同DataBlock间地址步长。
dst_repeat_stride输入目的操作数相邻迭代间相同DataBlock的地址步长。
src_repeat_stride输入源操作数相邻迭代间相同DataBlock的地址步长。

返回值说明

流水类型

PIPE_V

约束说明

  • dst、src的起始地址需要32字节对齐。
  • 操作数地址重叠约束请参考通用地址重叠约束。

调用示例

constexpr uint64_t total_length = 128; // total_length指参与计算的数据长度 __ubuf__ int32_t src[total_length]; __ubuf__ int64_t dst[total_length]; asc_int322int64(dst, src, total_length); // 将src转换为int64_t类型并存放到dst中

【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言,原生支持C和C++标准规范,主要由类库和语言扩展层构成,提供多层级API,满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

← 返回列表