评价此页

torch.bitwise_not#

torch.bitwise_not(input, *, out=None) Tensor#

计算给定输入张量的按位非(bitwise NOT)。输入张量必须是整数或布尔类型。对于布尔张量,它计算逻辑非(logical NOT)。

参数

input (Tensor) – 输入张量。

关键字参数

out (Tensor, optional) – 输出张量。

示例

>>> torch.bitwise_not(torch.tensor([-1, -2, 3], dtype=torch.int8))
tensor([ 0,  1, -4], dtype=torch.int8)