Where
产品支持情况
功能说明
根据指定的条件,从两个源操作数中选择元素,生成目标操作数。两个源操作数均可以是LocalTensor或标量。

函数原型
template <typename T, typename U, typename S, typename V>
__aicore__ inline void Where(const LocalTensor<T>& dst, const U& src0, const S& src1, const LocalTensor<V>& condition, const uint32_t count)
参数说明
表 1 模板参数说明
表 2 参数说明
|
类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
源操作数。类型为标量或LocalTensor,当类型为LocalTensor时,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
|
类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
返回值说明
无
约束说明
- 不支持源操作数与目的操作数地址重叠。
- 操作数地址偏移对齐要求请参见通用说明和约束。
调用示例
AscendC::LocalTensor<half> dst, src0, src1;
AscendC::LocalTensor<bool> condition;
uint32_t count = 512;
AscendC::Where(dst, src0, src1, condition, count);
结果示例如下:
输入数据(src0):
[1, 2, 3, ... 511, 512]
输入数据(src1):
[-1, -2, -3, ... -511, -512]
条件输入数据(condition):
[0, 1, 0, ... 0, 1]
输出数据(dst):
[-1, 2, -3, ... -511, 512]