ShiftLefts
产品支持情况
产品 |
是否支持 |
|---|---|
Atlas 350 加速卡 |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
功能说明
源操作数内每个元素做逻辑左移,逻辑左移的位数由输入参数scalarValue决定。
所谓逻辑左移,是指去掉最高位,最低位补0,例:二进制数 1010101010101010,逻辑左移一位结果为 0101010101010100。
函数原型
template <typename T = DefaultType, typename U, MaskMergeMode mode = MaskMergeMode::ZEROING, typename S> __simd_callee__ inline void ShiftLefts(S& dstReg, S& srcReg, U scalarValue, MaskReg& mask)
参数说明
参数名 |
描述 |
|---|---|
T |
矢量目的操作数和源操作数的数据类型。 Atlas 350 加速卡,支持的数据类型为:int8_t/uint8_t/int16_t/uint16_t/int32_t/uint32_t/int64_t/uint64_t |
U |
标量源操作数的数据类型。 Atlas 350 加速卡,支持的数据类型为:int16_t |
mode |
选择MERGING模式或ZEROING模式。当前仅支持ZEROING模式。
|
S |
目的操作数的RegTensor类型,例如RegTensor<half>,由编译器自动推导,用户不需要填写。 |
返回值说明
无
约束说明
无
调用示例
template<typename T, typename U>
__simd_vf__ inline void ShiftLeftsVF(__ubuf__ T* dstAddr, __ubuf__ T* src0Addr, U scalarValue, uint32_t count, uint32_t oneRepeatSize, uint16_t repeatTimes)
{
AscendC::Reg::RegTensor<T> srcReg;
AscendC::Reg::RegTensor<T> dstReg;
AscendC::Reg::MaskReg mask;
for (uint16_t i = 0; i < repeatTimes; i++) {
AscendC::Reg::LoadAlign(srcReg, src0Addr + i * oneRepeatSize);
mask = AscendC::Reg::UpdateMask<T>(count);
AscendC::Reg::ShiftLefts(dstReg, srcReg, scalarValue, mask);
AscendC::Reg::StoreAlign(dstAddr + i * oneRepeatSize, dstReg, mask);
}
}
父主题: 逻辑计算