BitwiseAnd
产品支持情况
功能说明
逐比特对两个输入进行与操作。

函数原型
template <const BitwiseAndConfig& config = DEFAULT_BITWISE_AND_CONFIG, typename T>
__aicore__ inline void BitwiseAnd(const LocalTensor<T>& dst, const LocalTensor<T>& src0, const LocalTensor<T>& src1, const uint32_t count)
参数说明
表 1 模板参数说明
BitwiseAnd算法的相关配置。此参数可选配,BitwiseAndConfig类型,具体定义如下方代码所示,其中参数的含义为: |
|
|
Ascend 950PR/Ascend 950DT,支持的数据类型为:int8_t、uint8_t、int16_t、uint16_t、int32_t、uint32_t、int64_t、uint64_t。 |
struct BitwiseAndConfig {
bool isReuseSource;
};
表 2 接口参数说明
|
类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
|
类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
返回值说明
无
约束说明
- 不支持源操作数与目的操作数地址重叠。
- 操作数地址对齐要求请参见通用地址对齐约束。
调用示例
AscendC::LocalTensor<uint16_t> dst, src0, src1;
uint32_t count = 512;
AscendC::BitwiseAnd(dst, src0, src1, count);
结果示例如下:
输入数据(src0):
[93, 87, 99, 1, 87, 58, 6, 16, 85, 66, 56, 65, 24, 98, 96, 50, 18, 37, 0, ... 66]
输入数据(src1):
[81, 12, 33, 47, 47, 18, 82, 44, 91, 34, 17, 99, 7, 82, 42, 85, 88, 99, 61, ... 81]
输出数据(dst):
[81, 4, 33, 1, 7, 18, 2, 0, 81, 2, 16, 65, 0, 66, 32, 16, 16, 33, 0, ... 64]