CANN/asc-devkit SIMD矢量加法

CANN/asc-devkit SIMD矢量加法 Adds【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit产品支持情况产品是否支持Ascend 950PR/Ascend 950DT√Atlas A3 训练系列产品 / Atlas A3 推理系列产品xAtlas A2 训练系列产品 / Atlas A2 推理系列产品xAtlas 200I/500 A2 推理产品xAtlas 推理系列产品 AI CorexAtlas 推理系列产品 Vector CorexAtlas 训练系列产品x功能说明矢量内每个元素与标量求和计算公式如下其中VL_T表示矢量计算单元一个迭代能够处理的元素个数。VL_T的取值参考RegTensor。函数原型template typename T DefaultType, typename U, MaskMergeMode mode MaskMergeMode::ZEROING, typename S __simd_callee__ inline void Adds(S dstReg, S srcReg, U scalarValue, MaskReg mask)参数说明表 1模板参数说明参数名描述T矢量目的操作数和源操作数的数据类型。Ascend 950PR/Ascend 950DT支持的数据类型为int8_t/uint8_t/int16_t/uint16_t/half/bfloat16_t/int32_t/uint32_t/float/complex32/int64_t/uint64_t/complex64U标量源操作数的数据类型。Ascend 950PR/Ascend 950DT支持的数据类型为int8_t/uint8_t/int16_t/uint16_t/half/bfloat16_t/int32_t/uint32_t/float/complex32/int64_t/uint64_t/complex64mode选择MERGING模式或ZEROING模式。ZEROINGmask未筛选的元素在dstReg中置零。MERGING暂不支持。SdstReg为RegTensor类型 例如RegTensorhalf由编译器自动推导用户不需要填写。表 2参数说明参数名输入/输出描述dstReg输出目的操作数。类型为RegTensor。srcReg输入源操作数。类型为RegTensor。数据类型需要与目的操作数保持一致。scalarValue输入源操作数。类型为标量。数据类型需要与目的操作数保持一致。mask输入mask寄存器用于指示源操作数元素操作是否有效详细说明请参考MaskReg。返回值说明无约束说明无调用示例templatetypename T __simd_vf__ inline void AddsVF(__ubuf__ T* dstAddr, __ubuf__ T* srcAddr, T scalarValue, uint32_t count, uint32_t oneRepeatSize, uint16_t repeatTimes) { AscendC::Reg::RegTensorT srcReg; AscendC::Reg::RegTensorT dstReg; AscendC::Reg::MaskReg mask; ; for (uint16_t i 0; i repeatTimes; i) { mask AscendC::Reg::UpdateMaskT(count); AscendC::Reg::LoadAlign(srcReg, srcAddr i * oneRepeatSize); AscendC::Reg::Adds(dstReg, srcReg, scalarValue, mask); AscendC::Reg::StoreAlign(dstAddr i * oneRepeatSize, dstReg, mask); } }【免费下载链接】asc-devkit本项目是CANN 推出的昇腾AI处理器专用的算子程序开发语言原生支持C和C标准规范主要由类库和语言扩展层构成提供多层级API满足多维场景算子开发诉求。项目地址: https://gitcode.com/cann/asc-devkit创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考