BilinearInterpolation(ISASI)
产品支持情况
功能说明
功能分为水平迭代和垂直迭代。每个水平迭代顺序地从src0Offset读取8个偏移值,表示src0的偏移,每个偏移值指向src0的一个DataBlock的起始地址,如果repeatMode=false,从src1中取一个值,与src0中8个DataBlock中每个值进行乘操作;如果repeatMode=true,从src1中取8个值,按顺序与src0中8个DataBlock中的值进行乘操作,最后当前迭代的dst结果与前一个dst结果按DataBlock进行累加,存入目的地址,在同一个水平迭代内dst地址不变。然后进行垂直迭代,垂直迭代的dst起始地址为上一轮垂直迭代的dst起始地址加上vROffset,本轮垂直迭代占用dst空间为dst起始地址之后的8个DataBlock,每轮垂直迭代进行hRepeat次水平迭代。

函数原型
-
mask逐bit模式:
template <typename T> __aicore__ inline void BilinearInterpolation(const LocalTensor<T>& dst, const LocalTensor<T>& src0, const LocalTensor<uint32_t>& src0Offset, const LocalTensor<T>& src1, uint64_t mask[], uint8_t hRepeat, bool repeatMode, uint16_t dstBlkStride, uint16_t vROffset, uint8_t vRepeat, const LocalTensor<uint8_t> &sharedTmpBuffer) -
mask连续模式:
template <typename T> __aicore__ inline void BilinearInterpolation(const LocalTensor<T>& dst, const LocalTensor<T>& src0, const LocalTensor<uint32_t>& src0Offset, const LocalTensor<T>& src1, uint64_t mask, uint8_t hRepeat, bool repeatMode, uint16_t dstBlkStride, uint16_t vROffset, uint8_t vRepeat, const LocalTensor<uint8_t> &sharedTmpBuffer)
参数说明
表 1 模板参数说明
表 2 参数说明
|
类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
|
类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
|
类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
|
||
|
||
垂直迭代间,目的操作数地址偏移量,以元素为单位,取值范围为[128, 65535),vROffset * sizeof(T)需要保证32字节对齐 。 |
||
|
Atlas A2 训练系列产品/Atlas A2 推理系列产品,需要保证至少分配了src0.GetSize() * 32 + src1.GetSize() * 32字节的空间。 Atlas A3 训练系列产品/Atlas A3 推理系列产品,需要保证至少分配了src0.GetSize() * 32 + src1.GetSize() * 32字节的空间。 |
返回值说明
无
约束说明
-
操作数地址对齐要求请参见通用地址对齐约束。
-
src0、src1、src0Offset之间不允许地址重叠,且两个垂直repeat的目的地址之间不允许地址重叠。
调用示例
-
接口样例-mask连续模式
AscendC::LocalTensor<half> dstLocal, src0Local, src1Local; AscendC::LocalTensor<uint32_t> src0OffsetLocal; AscendC::LocalTensor<uint8_t> tmpLocal; uint64_t mask = 128; // mask连续模式 uint8_t hRepeat = 2; // 水平迭代2次 bool repeatMode = false; // 迭代模式 uint16_t dstBlkStride = 1; // 单次迭代内数据连续写入 uint16_t vROffset = 128; // 相邻迭代间数据连续写入 uint8_t vRepeat = 2; // 垂直迭代2次 AscendC::BilinearInterpolation(dstLocal, src0Local, src0OffsetLocal, src1Local, mask, hRepeat, repeatMode, dstBlkStride, vROffset, vRepeat, tmpLocal); -
接口样例-mask逐bit模式
AscendC::LocalTensor<half> dstLocal, src0Local, src1Local; AscendC::LocalTensor<uint32_t> src0OffsetLocal; AscendC::LocalTensor<uint8_t> tmpLocal; uint64_t mask[2] = { UINT64_MAX, UINT64_MAX }; // mask逐bit模式 uint8_t hRepeat = 2; // 水平迭代2次 bool repeatMode = false; // 迭代模式 uint16_t dstBlkStride = 1; // 单次迭代内数据连续写入 uint16_t vROffset = 128; // 相邻迭代间数据连续写入 uint8_t vRepeat = 2; // 垂直迭代2次 AscendC::BilinearInterpolation(dstLocal, src0Local, src0OffsetLocal, src1Local, mask, hRepeat, repeatMode, dstBlkStride, vROffset, vRepeat, tmpLocal);
结果示例如下:
输入数据(src0Local,half): [1,2,3,...,512]
输入数据(src1Local,half): [2,3,4,...,17]
输入数据(src0OffsetLocal,uint32_t): [0,32,64,...,992]
输出数据(dstLocal,half): [389, 394, 399, 404, ...,4096]