SetCmpMask(ISASI)
功能说明
为Select不传入mask参数的接口设置比较寄存器。配合不同的selMode传入不同的数据。
函数原型
1 2 | template <typename T> __aicore__ inline void SetCmpMask(const LocalTensor<T>& src) |
参数说明
参数名 |
输入/输出 |
描述 |
---|---|---|
src |
输入 |
类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 LocalTensor的起始地址需要32字节对齐。 |
返回值
无
支持的型号
约束说明
无
调用示例
- 当selMode为模式0或模式2时:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
AscendC::LocalTensor<float> dst; AscendC::LocalTensor<uint8_t> sel; AscendC::LocalTensor<float> src0; AscendC::LocalTensor<float> src1; uint8_t repeat = 4; uint32_t mask = 64; AscendC::BinaryRepeatParams repeatParams = { 1, 1, 1, 8, 8, 8 }; // selMode为模式0(SELMODE::VSEL_CMPMASK_SPR) AscendC::SetCmpMask(sel); AscendC::PipeBarrier<PIPE_V>(); AscendC::SetVectorMask<float>(mask); AscendC::Select<float, AscendC::SELMODE::VSEL_CMPMASK_SPR>(dst, src0, src1, repeat, repeatParams); // selMode为模式2(SELMODE::VSEL_TENSOR_TENSOR_MODE) AscendC::LocalTensor<int32_t> tempBuf; #if defined(ASCENDC_CPU_DEBUG) && (ASCENDC_CPU_DEBUG == 1) // cpu调试 tempBuf.ReinterpretCast<int64_t>().SetValue(0, reinterpret_cast<int64_t>(reinterpret_cast<__ubuf__ int64_t*>(sel.GetPhyAddr()))); event_t eventIdSToV = static_cast<event_t>(AscendC::GetTPipePtr()->FetchEventID(AscendC::HardEvent::S_V)); AscendC::SetFlag<AscendC::HardEvent::S_V>(eventIdSToV); AscendC::WaitFlag<AscendC::HardEvent::S_V>(eventIdSToV); #else // npu调试 uint32_t selAddr = static_cast<uint32_t>(reinterpret_cast<int64_t>(reinterpret_cast<__ubuf__ int64_t*>(sel.GetPhyAddr()))); AscendC::SetVectorMask<uint32_t>(32); AscendC::Duplicate<uint32_t, false>(tempBuf.ReinterpretCast<uint32_t>(), selAddr, AscendC::MASK_PLACEHOLDER, 1, 1, 8); AscendC::PipeBarrier<PIPE_V>(); #endif AscendC::SetCmpMask<int64_t>(tempBuf.ReinterpretCast<int64_t>()); AscendC::PipeBarrier<PIPE_V>(); AscendC::SetVectorMask<float>(mask); AscendC::Select<float, AscendC::SELMODE::VSEL_TENSOR_TENSOR_MODE>(dst, src0, src1, repeat, repeatParams);
- 当selMode为模式1时:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
AscendC::LocalTensor<float> dst; AscendC::LocalTensor<uint8_t> sel; AscendC::LocalTensor<float> src0; AscendC::LocalTensor<float> tmpScalar; uint8_t repeat = 4; uint32_t mask = 64; AscendC::BinaryRepeatParams repeatParams = { 1, 1, 1, 8, 8, 8 }; // selMode为模式1(SELMODE::VSEL_TENSOR_SCALAR_MODE) AscendC::SetVectorMask<uint32_t>(32); AscendC::Duplicate<float, false>(tmpScalar, static_cast<float>(1.0), MASK_PLACEHOLDER, 1, 1, 8); AscendC::PipeBarrier<PIPE_V>(); AscendC::SetCmpMask(tmpScalar); AscendC::PipeBarrier<PIPE_V>(); AscendC::SetVectorMask<float>(mask); AscendC::Select<float, uint8_t>(dst, sel, src0, repeat, repeatParams);
父主题: 比较指令