Interleave
Applicability
|
Product |
Supported |
|---|---|
|
Atlas 350 Accelerator Card |
√ |
|
|
x |
|
|
x |
|
|
x |
|
|
x |
|
|
x |
|
|
x |
Function Usage
Interleaves elements from the source operands src0 and src1 and stores them in the destination operands dst0 and dst1. The following figure shows the interleaving mode, where each square represents an element.

Prototype
template <typename T> __simd_callee__ inline void Interleave(MaskReg& dst0, MaskReg& dst1, MaskReg& src0, MaskReg& src1)
Parameters
|
Parameter |
Description |
|---|---|
|
T |
The data type supported by the MaskReg. It determines the bit width of the interleaving. For example, for the uint32_t type, interleaving is performed in groups of 4 bits. For the Atlas 350 Accelerator Card, the supported data types are b8, b16, and b32. |
|
Parameter |
Description |
|---|---|
|
dst0 |
Destination operand. |
|
dst1 |
Destination operand. |
|
src0 |
Source operand. |
|
src1 |
Source operand. |
Returns
None
Restrictions
None
Examples
template <typename T>
__simd_vf__ inline void MaskInterleaveDeInterleaveVF(__ubuf__ T* dstAddr, __ubuf__ T* srcAddr, uint32_t count, uint32_t oneRepeatSize, uint16_t repeatTimes)
{
AscendC::Reg::RegTensor<T> srcReg;
AscendC::Reg::MaskReg maskFull = AscendC::Reg::CreateMask<T, AscendC::Reg::MaskPattern::ALL>();
AscendC::Reg::MaskReg maskM3 = AscendC::Reg::CreateMask<T, AscendC::Reg::MaskPattern::M3>();
AscendC::Reg::MaskReg newMask0;
AscendC::Reg::MaskReg newMask1;
AscendC::Reg::Interleave<T>(newMask0, newMask1, maskFull, maskM3);
AscendC::Reg::DeInterleave<T>(newMask0, newMask1, newMask0, newMask1);
AscendC::Reg::MaskReg mask;
for (uint16_t i = 0; i < repeatTimes; ++i) {
mask = AscendC::Reg::UpdateMask<T>(count);
AscendC::Reg::LoadAlign(srcReg, srcAddr + i * oneRepeatSize);
AscendC::Reg::Adds(srcReg, srcReg, 0, newMask0);
AscendC::Reg::StoreAlign(dstAddr + i * oneRepeatSize, srcReg, mask);
}
}