当前位置: 首页 > news >正文

CANN/asc-devkit:Ascend C SIMD API

asc_half2int16

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

产品支持情况

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

功能说明

将half类型数据转换为int16_t,并支持多种舍入模式。

  • RINT舍入模式:四舍六入五成双舍入
  • ROUND舍入模式:四舍五入舍入
  • FLOOR舍入模式:向负无穷舍入
  • CEIL舍入模式:向正无穷舍入
  • TRUNC舍入模式:向零舍入

函数原型

  • 前n个数据计算

    // RINT舍入模式 __aicore__ inline void asc_half2int16_rn(__ubuf__ int16_t* dst, __ubuf__ half* src, uint32_t count) // ROUND舍入模式 __aicore__ inline void asc_half2int16_rna(__ubuf__ int16_t* dst, __ubuf__ half* src, uint32_t count) //FLOOR舍入模式 __aicore__ inline void asc_half2int16_rd(__ubuf__ int16_t* dst, __ubuf__ half* src, uint32_t count) // CEIL舍入模式 __aicore__ inline void asc_half2int16_ru(__ubuf__ int16_t* dst, __ubuf__ half* src, uint32_t count) // TRUNC舍入模式 __aicore__ inline void asc_half2int16_rz(__ubuf__ int16_t* dst, __ubuf__ half* src, uint32_t count)
  • 高维切分计算

    // RINT舍入模式 __aicore__ inline void asc_half2int16_rn(__ubuf__ int16_t* dst, __ubuf__ half* src, uint8_t repeat, uint16_t dst_block_stride, uint16_t src_block_stride, uint16_t dst_repeat_stride, uint16_t src_repeat_stride) // ROUND舍入模式 __aicore__ inline void asc_half2int16_rna(__ubuf__ int16_t* dst, __ubuf__ half* src, uint8_t repeat, uint16_t dst_block_stride, uint16_t src_block_stride, uint16_t dst_repeat_stride, uint16_t src_repeat_stride) // FLOOR舍入模式 __aicore__ inline void asc_half2int16_rd(__ubuf__ int16_t* dst, __ubuf__ half* src, uint8_t repeat, uint16_t dst_block_stride, uint16_t src_block_stride, uint16_t dst_repeat_stride, uint16_t src_repeat_stride) // CEIL舍入模式 __aicore__ inline void asc_half2int16_ru(__ubuf__ int16_t* dst, __ubuf__ half* src, uint8_t repeat, uint16_t dst_block_stride, uint16_t src_block_stride, uint16_t dst_repeat_stride, uint16_t src_repeat_stride) // TRUNC舍入模式 __aicore__ inline void asc_half2int16_rz(__ubuf__ int16_t* dst, __ubuf__ half* src, uint8_t repeat, uint16_t dst_block_stride, uint16_t src_block_stride, uint16_t dst_repeat_stride, uint16_t src_repeat_stride)
  • 同步计算

    // RINT舍入模式 __aicore__ inline void asc_half2int16_rn_sync(__ubuf__ int16_t* dst, __ubuf__ half* src, uint32_t count) // ROUND舍入模式 __aicore__ inline void asc_half2int16_rna_sync(__ubuf__ int16_t* dst, __ubuf__ half* src, uint32_t count) // FLOOR舍入模式 __aicore__ inline void asc_half2int16_rd_sync(__ubuf__ int16_t* dst, __ubuf__ half* src, uint32_t count) // CEIL舍入模式 __aicore__ inline void asc_half2int16_ru_sync(__ubuf__ int16_t* dst, __ubuf__ half* src, uint32_t count) // TRUNC舍入模式 __aicore__ inline void asc_half2int16_rz_sync(__ubuf__ int16_t* dst, __ubuf__ half* 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 uint32_t total_length = 256; __ubuf__ half src[total_length]; __ubuf__ int16_t dst[total_length]; asc_half2int16_rn(dst, src, total_length);

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

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

http://www.jsqmd.com/news/953437/

相关文章:

  • 如何高效使用Puppet PadLocal:微信机器人开发的终极指南
  • 从课堂点名到芯片调度:用Round Robin算法解决FPGA设计中的‘公平性’难题
  • MuleSoft企业级AI编排:构建可审计、可治理的LLM服务中枢
  • 微博舆情实时分析工具包(含Python NLP代码+前后端可运行工程)
  • CyberpunkSaveEditor:赛博朋克2077存档编辑的终极指南
  • 比特币扩容技术解析:二层网络与阈值签名应用
  • 除了OBS推电影,你的Docker RTMP服务器还能这么玩:多场景应用指南
  • OmniCoder-2-9B社区贡献指南:如何参与项目开发和模型改进
  • Swagger转Word终极指南:3种方式实现API文档自动化生成
  • 百度网盘秒传脚本终极指南:5分钟实现永久文件分享的完整教程
  • 别再只画频谱图了!MATLAB中FFT2/IFFT2的abs()和real()到底该怎么选?
  • FLAN-T5-XXL 在中文场景下的应用:本地化使用技巧
  • 告别花屏卡顿:用匿名科创地面站+串口协议,给你的单片机数据做个“动态心电图”
  • ALMA毫米波偏振观测揭示恒星形成早期尘埃与磁场作用
  • T3Q-ko-solar-sft-dpo-v1.0-openmind:韩语AI模型开源生态完整贡献指南 [特殊字符]
  • 规避大模型结构化输出漏洞:防范提示词注入与安全越狱
  • 小白必看:ke-t5-base的5个核心功能及应用场景解析
  • 深入解析use-mcp:React钩子如何简化MCP服务器连接
  • KLayout性能优化:大型版图文件处理的7个最佳实践
  • CANN/Ascend C SIMD数据搬运API
  • 163MusicLyrics:网易云QQ音乐歌词下载终极指南,免费解决本地音乐无歌词困扰
  • 微信机器人开发终极指南:PadLocal协议深度解析与实战应用
  • 韶关黄金回收2026年6月实时报价及靠谱门店盘点 - 余生黄金回收
  • 零基础入门Hermes Agent:借助快马生成你的第一个“Hello Agent”
  • OptiScaler终极指南:开源AI超分技术打破GPU厂商壁垒
  • KLayout快速上手:如何在10分钟内开始查看GDSII和OASIS文件
  • 异地协同只是个梦?CRDE智橙跨地域跨组织跨终端协同功能让您梦想成真!
  • 别再只会用ode45了!Simulink直流电机调速仿真,6种算法对比实测(附模型)
  • Qwen2-7B-Instruct推理代码详解:30行Python实现智能对话的核心逻辑
  • 如何为虚幻引擎游戏注入Lua脚本:UE4SS完整模组开发指南