asc.language.basic.add【免费下载链接】pyasc本项目为Python用户提供算子编程接口支持在昇腾AI处理器上加速计算接口与Ascend C一一对应并遵守Python原生语法。项目地址: https://gitcode.com/cann/pyascasc.language.basic.add(dst: LocalTensor, src0: LocalTensor, src1: LocalTensor, count: int, is_set_mask: bool True) → Noneasc.language.basic.add(dst: LocalTensor, src0: LocalTensor, src1: LocalTensor, mask: int, repeat_times: int, repeat_params: BinaryRepeatParams, is_set_mask: bool True) → Noneasc.language.basic.add(dst: LocalTensor, src0: LocalTensor, src1: LocalTensor, mask: List[int], repeat_times: int, repeat_params: BinaryRepeatParams, is_set_mask: bool True) → None按元素求和。对应的Ascend C函数原型template typename T __aicore__ inline void Add(const LocalTensorT dst, const LocalTensorT src0, const LocalTensorT src1, const int32_t count);template typename T, bool isSetMask true __aicore__ inline void Add(const LocalTensorT dst, const LocalTensorT src0, const LocalTensorT src1, uint64_t mask[], const uint8_t repeatTimes, const BinaryRepeatParams repeatParams);template typename T, bool isSetMask true __aicore__ inline void Add(const LocalTensorT dst, const LocalTensorT src0, const LocalTensorT src1, uint64_t mask, const uint8_t repeatTimes, const BinaryRepeatParams repeatParams);参数说明dst目的操作数。类型为LocalTensor支持的TPosition为VECIN/VECCALC/VECOUT。src0, src1源操作数。类型为LocalTensor支持的TPosition为VECIN/VECCALC/VECOUT。count参与计算的元素个数。mask用于控制每次迭代内参与计算的元素。repeat_times重复迭代次数。params控制操作数地址步长的参数。is_set_mask: 是否在接口内部设置mask。约束说明操作数地址对齐要求请参见 《Ascend C算子开发接口》 中的“通用说明和约束-通用地址对齐约束”。操作数地址重叠约束请参考 《Ascend C算子开发接口》 中的“通用说明和约束-通用地址重叠约束”。使用整个tensor参与计算接口符号重载时运算量为目的LocalTensor的总长度。调用示例tensor高维切分计算样例-mask连续模式mask 128 # repeat_times 4一次迭代计算128个数共计算512个数 # dst_blk_stride, src0_blk_stride, src1_blk_stride 1单次迭代内数据连续读取和写入 # dst_rep_stride, src0_rep_stride, src1_rep_stride 8相邻迭代间数据连续读取和写入 params asc.BinaryRepeatParams(1, 1, 1, 8, 8, 8) asc.add(dst, src0, src1, maskmask, repeat_times4, repeat_paramsparams)tensor高维切分计算样例-mask逐bit模式mask [uint64_max, uint64_max] # repeat_times 4一次迭代计算128个数共计算512个数 # dst_blk_stride, src0_blk_stride, src1_blk_stride 1单次迭代内数据连续读取和写入 # dst_rep_stride, src0_rep_stride, src1_rep_stride 8相邻迭代间数据连续读取和写入 params asc.BinaryRepeatParams(1, 1, 1, 8, 8, 8) asc.add(dst, src0, src1, maskmask, repeat_times4, repeat_paramsparams)tensor前n个数据计算样例asc.add(dst, src0, src1, count512)【免费下载链接】pyasc本项目为Python用户提供算子编程接口支持在昇腾AI处理器上加速计算接口与Ascend C一一对应并遵守Python原生语法。项目地址: https://gitcode.com/cann/pyasc创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考