
asc.language.basic.compare_scalar【免费下载链接】pyasc本项目为Python用户提供算子编程接口支持在昇腾AI处理器上加速计算接口与Ascend C一一对应并遵守Python原生语法。项目地址: https://gitcode.com/cann/pyascasc.language.basic.compare_scalar(dst: LocalTensor, src0: LocalTensor, src1_scalar: int | float, cmp_mode: CMPMODE, count: int) → Noneasc.language.basic.compare_scalar(dst: LocalTensor, src0: LocalTensor, src1_scalar: int | float, cmp_mode: CMPMODE, mask: int, repeat_times: int, repeat_params: UnaryRepeatParams, is_set_mask: bool True) → Noneasc.language.basic.compare_scalar(dst: LocalTensor, src0: LocalTensor, src1_scalar: int | float, cmp_mode: CMPMODE, mask: List[int], repeat_times: int, repeat_params: UnaryRepeatParams, is_set_mask: bool True) → None逐元素比较一个tensor中的元素和另一个scalar的大小如果比较后的结果为真则输出的结果的对应比特位为1否则为0。对应的Ascend C函数原型template typename T, typename U __aicore__ inline void CompareScalar(const LocalTensorU dst, const LocalTensorT src0, const T src1Scalar, CMPMODE cmpMode, uint32_t count);template typename T, typename U, bool isSetMask true __aicore__ inline void CopmareScalar(const LocalTensorU dst, const LocalTensorT src0, const T src1Scalar, CMPMODE cmpMode, const uint64_t mask[], uint8_t repeatTimes, const UnaryRepeatParams repeatParams);template typename T, typename U, bool isSetMask true __aicore__ inline void CompareScalar(const LocalTensorU dst, const LocalTensorT src0, const T src1Scalar, CMPMODE cmpMode, const uint64_t mask, uint8_t repeatTimes, const UnaryRepeatParams repeatParams);参数说明dst: 目的操作数。类型为LocalTensor支持的TPosition为VECIN/VECCALC/VECOUT。src0: 源操作数。类型为LocalTensor支持的TPosition为VECIN/VECCALC/VECOUT。src1_scalar: 源操作数Scalar标量。数据类型和src0保持一致。cmp_mode: CMPMODE类型表示比较模式。LT: src0小于less thansrc1GT: src0大于greater thansrc1GE: src0大于或等于greater than or equal tosrc1EQ: src0等于equal tosrc1NE: src0不等于not equal tosrc1LE: src0小于或等于less than or equal tosrc1count: 参与计算的元素个数。mask: 用于控制每次迭代内参与计算的元素。repeat_times: 重复迭代次数。repeat_params: 控制操作数地址步长的参数。is_set_mask: 是否在接口内部设置mask。约束说明操作数地址对齐要求请参见 《Ascend C算子开发接口》 中的“通用说明和约束-通用地址对齐约束”。dst按照小端顺序排序成二进制结果对应src中相应位置的数据比较结果。使用tensor前n个数据参与计算的接口设置count时需要保证count个元素所占空间256字节对齐。调用示例tensor高维切分计算样例-mask连续模式mask 128 # repeat_times 1一次迭代计算128个数 params asc.BinaryRepeatParams(1, 1, 1, 8, 8, 8) asc.compare_scalar(dst, src0, src1_scalar, cmp_modeasc.CMPMODE.LT, maskmask, repeat_times1, repeat_paramsparams)tensor高维切分计算样例-mask逐bit模式mask [uint64_max, uint64_max] # repeat_times 1一次迭代计算128个数 params asc.BinaryRepeatParams(1, 1, 1, 8, 8, 8) asc.compare_scalar(dst, src0, src1_scalar, cmp_modeasc.CMPMODE.LT, maskmask, repeat_times1, repeat_paramsparams)tensor前n个数据计算样例asc.compare_scalar(dst, src0, src1_scalar, cmp_modeasc.CMPMODE.LT, count512)【免费下载链接】pyasc本项目为Python用户提供算子编程接口支持在昇腾AI处理器上加速计算接口与Ascend C一一对应并遵守Python原生语法。项目地址: https://gitcode.com/cann/pyasc创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考