LogicalAnd
产品支持情况
功能说明
按元素进行与操作。当输入的数据类型不是bool时,零被视为False,非零数据被视为True。

函数原型
template <const LogicalAndConfig& config = DEFAULT_LOGICAL_AND_CONFIG, typename T, typename U>
__aicore__ inline void LogicalAnd(const LocalTensor<T>& dst, const LocalTensor<U>& src0, const LocalTensor<U>& src1, const uint32_t count)
参数说明
表 1 模板参数说明
LogicalAnd算法的相关配置。此参数可选配,LogicalAndConfig类型,具体定义如下方代码所示,其中参数的含义为: |
|
|
Ascend 950PR/Ascend 950DT,支持的数据类型为:bool、int8_t、uint8_t、int16_t、uint16_t、half、bfloat16_t、int32_t、uint32_t、float、int64_t、uint64_t。 |
struct LogicalAndConfig {
bool isReuseSource;
};
表 2 接口参数说明
|
类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
|
类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
返回值说明
无
约束说明
- 不支持源操作数与目的操作数地址重叠。
- 操作数地址对齐要求请参见通用地址对齐约束。
调用示例
AscendC::LocalTensor<bool> dst;
AscendC::LocalTensor<half> src0, src1;
uint32_t count = 512;
AscendC::LogicalAnd(dst, src0, src1, count);
结果示例如下:
输入数据(src0):
[0.4646, 0.2520, 0.3884, 0.0000, 0.2904, 0.0000, 0.5690, 0.2191, 0.7354,
0.0000, 0.8093, 0.5932, 0.2688, 0.0830, 0.5074, 0.5595, 0.1468, 0.7020,
... 0.0238]
输入数据(src1):
[0.0487, 0.9719, 0.0709, 0.0000, 0.3846, 0.0000, 0.5885, 0.0000, 0.5291,
0.2143, 0.1416, 0.0575, 0.2645, 0.8900, 0.7628, 0.2034, 0.4929, 0.7901,
... 0.2804]
输出数据(dst):
[ True, True, True, False, True, False, True, False, True, False,
True, True, True, True, True, True, True, True, ... True]