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

函数原型
template <const LogicalNotConfig& config = DEFAULT_LOGICAL_NOT_CONFIG, typename T, typename U>
__aicore__ inline void LogicalNot(const LocalTensor<T>& dst, const LocalTensor<U>& src, const uint32_t count)
参数说明
表 1 模板参数说明
LogicalNot算法的相关配置。此参数可选配,LogicalNotConfig类型,具体定义如下方代码所示,其中参数的含义为: |
|
|
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 LogicalNotConfig {
bool isReuseSource;
};
表 2 接口参数说明
|
类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
|
类型为LocalTensor,支持的TPosition为VECIN/VECCALC/VECOUT。 |
||
返回值说明
无
约束说明
- 不支持源操作数与目的操作数地址重叠。
- 操作数地址对齐要求请参见通用地址对齐约束。
调用示例
AscendC::LocalTensor<bool> dst;
AscendC::LocalTensor<half> src;
uint32_t count = 512;
AscendC::LogicalNot(dst, src, count);
结果示例如下:
输入数据(src):
[0.8021, 0.7420, 0.1562, 0.0000, 0.7931, 0.0000, 0.0373, 0.3973, 0.3829,
0.6405, 0.3147, 0.9409, 0.8814, 0.0946, 0.2162, 0.3011, 0.4583, 0.5666,
... 0.2754]
输出数据(dst):
[False, False, False, True, False, True, False, False, False, False,
False, False, False, False, False, False, False, False, ... False]