CANN/asc-devkit Gatherb函数API文档
·
Gatherb(ISASI)
产品支持情况
功能说明
给定一个输入的张量和一个地址偏移张量,本接口根据偏移地址按照DataBlock的粒度将输入张量收集到结果张量中。

函数原型
template <typename T>
__aicore__ inline void Gatherb(const LocalTensor<T>& dst, const LocalTensor<T>& src, const LocalTensor<uint32_t>& offset, const uint8_t repeatTime, const GatherRepeatParams& repeatParams)
参数说明
表 1 模板参数说明
表 2 参数说明
|
类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
|
类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
|
类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
|
类型为GatherRepeatParams,具体定义可参考${INSTALL_DIR}/include/ascendc/basic_api/interface/kernel_struct_gather.h。${INSTALL_DIR}请替换为CANN软件安装后文件存储路径。 其中dstBlkStride、dstRepStride支持用户配置,参数说明参考表3。 |
表 3 GatherRepeatParams结构体参数说明
约束说明
无
调用示例
完整使用样例请参见Gather类样例场景四。
uint32_t bufferLen = 128;
AscendC::GatherRepeatParams params{1, 8};
uint8_t repeatTime = bufferLen * sizeof(uint16_t) / 256;
AscendC::Gatherb<uint16_t>(y_buf, x_buf, offset_buf, repeatTime, params); // repeatTime重复迭代次数,每次迭代完成8个datablock的数据收集
结果示例:
输入数据(offsetLocal): [224 192 160 128 96 64 32 0]
输入数据(srcLocal): [0 1 2 3 4 5 6 7 ... 120 121 122 123 124 125 126 127]
输出数据(dstGlobal):[
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
...
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
]
更多推荐



所有评论(0)