CANN/asc-devkit:float转half函数 asc_float2half【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit产品支持情况产品是否支持Ascend 950PR/Ascend 950DT√功能说明将float类型转化为half类型并支持多种舍入模式。RINT舍入模式四舍六入五成双舍入ROUND舍入模式四舍五入舍入FLOOR舍入模式向负无穷舍入CEIL舍入模式向正无穷舍入TRUNC舍入模式向零舍入ODD舍入模式最近邻奇数舍入根据输入数据的大小分为非饱和模式和饱和模式。非饱和模式输入数据超过输出类型最值时返回输出类型的对应符号inf值。输入数据为/-inf时, 返回/-inf。输入数据为nan时返回nan。饱和模式输入数据超过输出类型最值时返回输出类型的对应最值。输入数据为/-inf时, 返回输出类型的对应最值。输入数据为nan时返回0。由于源操作数与目的操作数类型位宽比为2:1写入数据时需要将一个VL大小的数据分为两部分根据不同接口选取索引0或者索引1。函数原型// RINT舍入模式, 非饱和模式数据写入索引为偶数的位置 __simd_callee__ inline void asc_float2half_rn(vector_half dst, vector_float src, vector_bool mask) // RINT舍入模式, 饱和模式数据写入索引为偶数的位置 __simd_callee__ inline void asc_float2half_rn_sat(vector_half dst, vector_float src, vector_bool mask) // RINT舍入模式, 非饱和模式数据写入索引为奇数的位置 __simd_callee__ inline void asc_float2half_rn_v2(vector_half dst, vector_float src, vector_bool mask) // RINT舍入模式, 饱和模式数据写入索引为奇数的位置 __simd_callee__ inline void asc_float2half_rn_sat_v2(vector_half dst, vector_float src, vector_bool mask) // ROUND舍入模式, 非饱和模式数据写入索引为偶数的位置 __simd_callee__ inline void asc_float2half_rna(vector_half dst, vector_float src, vector_bool mask) // ROUND舍入模式, 饱和模式数据写入索引为偶数的位置 __simd_callee__ inline void asc_float2half_rna_sat(vector_half dst, vector_float src, vector_bool mask) // ROUND舍入模式, 非饱和模式数据写入索引为奇数的位置 __simd_callee__ inline void asc_float2half_rna_v2(vector_half dst, vector_float src, vector_bool mask) // ROUND舍入模式, 饱和模式数据写入索引为奇数的位置 __simd_callee__ inline void asc_float2half_rna_sat_v2(vector_half dst, vector_float src, vector_bool mask) // FLOOR舍入模式, 非饱和模式数据写入索引为偶数的位置 __simd_callee__ inline void asc_float2half_rd(vector_half dst, vector_float src, vector_bool mask) // FLOOR舍入模式, 饱和模式数据写入索引为偶数的位置 __simd_callee__ inline void asc_float2half_rd_sat(vector_half dst, vector_float src, vector_bool mask) // FLOOR舍入模式, 非饱和模式数据写入索引为奇数的位置 __simd_callee__ inline void asc_float2half_rd_v2(vector_half dst, vector_float src, vector_bool mask) // FLOOR舍入模式, 饱和模式数据写入索引为奇数的位置 __simd_callee__ inline void asc_float2half_rd_sat_v2(vector_half dst, vector_float src, vector_bool mask) // CEIL舍入模式, 非饱和模式数据写入索引为偶数的位置 __simd_callee__ inline void asc_float2half_ru(vector_half dst, vector_float src, vector_bool mask) // CEIL舍入模式, 饱和模式数据写入索引为偶数的位置 __simd_callee__ inline void asc_float2half_ru_sat(vector_half dst, vector_float src, vector_bool mask) // CEIL舍入模式, 非饱和模式数据写入索引为奇数的位置 __simd_callee__ inline void asc_float2half_ru_v2(vector_half dst, vector_float src, vector_bool mask) // CEIL舍入模式, 饱和模式数据写入索引为奇数的位置 __simd_callee__ inline void asc_float2half_ru_sat_v2(vector_half dst, vector_float src, vector_bool mask) // TRUNC舍入模式, 非饱和模式数据写入索引为偶数的位置 __simd_callee__ inline void asc_float2half_rz(vector_half dst, vector_float src, vector_bool mask) // TRUNC舍入模式, 饱和模式数据写入索引为偶数的位置 __simd_callee__ inline void asc_float2half_rz_sat(vector_half dst, vector_float src, vector_bool mask) // TRUNC舍入模式, 非饱和模式数据写入索引为奇数的位置 __simd_callee__ inline void asc_float2half_rz_v2(vector_half dst, vector_float src, vector_bool mask) // TRUNC舍入模式, 饱和模式数据写入索引为奇数的位置 __simd_callee__ inline void asc_float2half_rz_sat_v2(vector_half dst, vector_float src, vector_bool mask) // ODD舍入模式, 非饱和模式数据写入索引为偶数的位置 __simd_callee__ inline void asc_float2half_ro(vector_half dst, vector_float src, vector_bool mask) // ODD舍入模式, 饱和模式数据写入索引为偶数的位置 __simd_callee__ inline void asc_float2half_ro_sat(vector_half dst, vector_float src, vector_bool mask) // ODD舍入模式, 非饱和模式数据写入索引为奇数的位置 __simd_callee__ inline void asc_float2half_ro_v2(vector_half dst, vector_float src, vector_bool mask) // ODD舍入模式, 饱和模式数据写入索引为奇数的位置 __simd_callee__ inline void asc_float2half_ro_sat_v2(vector_half dst, vector_float src, vector_bool mask)参数说明参数名输入/输出描述dst输出目的操作数矢量数据寄存器。src输入源操作数矢量数据寄存器。mask输入源操作数掩码掩码寄存器用于指示在计算过程中哪些元素参与计算。对应位置为1时参与计算为0时不参与计算。mask未筛选的元素在输出中置零。矢量数据寄存器和掩码寄存器的详细说明请参见reg数据类型定义.md。返回值说明无流水类型PIPE_V约束说明无调用示例vector_float src; vector_half dst; vector_bool mask asc_create_mask_b32(PAT_ALL); asc_loadalign(src, src_addr); // src_addr是外部输入的UB内存空间地址。 asc_float2half_rn(dst, src, mask);【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考