产品 |
是否支持 |
|---|---|
Ascend 950PR/Ascend 950DT |
√ |
x |
|
x |
|
x |
|
x |
|
x |
|
x |
获取RegTensor位宽VL(Vector Length)的大小。
1 | __aicore__ inline constexpr uint32_t GetVecLen() |
无
Vector Length的大小,单位为byte。
无
如下样例通过GetVecLen获取循环迭代次数:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | template <typename T> __aicore__ inline void AddCustomImpl(__local_mem__ T *dst, __local_mem__ T *src0, __local_mem__ T *src1, uint32_t calCount) { AscendC::Reg::RegTensor<T> reg0; AscendC::Reg::RegTensor<T> reg1; AscendC::Reg::RegTensor<T> reg2; AscendC::Reg::MaskReg mask; constexpr uint32_t repeatElm = AscendC::GetVecLen() / sizeof(T); uint16_t repeatTime = AscendC::CeilDivision(calCount, repeatElm); for (uint16_t i = 0; i < repeatTime; ++i) { mask = AscendC::Reg::UpdateMask<T>(calCount); AscendC::Reg::LoadAlign(reg0, src0 + i * repeatElm); AscendC::Reg::LoadAlign(reg1, src1 + i * repeatElm); AscendC::Reg::Add(reg2, reg0, reg1, mask); AscendC::Reg::StoreAlign(dst + i * repeatElm, reg2, mask); } } |