评价此页

torch.bitwise_xor#

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

计算 inputother 的按位异或。输入张量必须是整数或布尔类型。对于布尔张量,它计算逻辑异或。

参数
  • input – 第一个输入张量

  • other – 第二个输入张量

关键字参数

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

示例

>>> torch.bitwise_xor(torch.tensor([-1, -2, 3], dtype=torch.int8), torch.tensor([1, 0, 3], dtype=torch.int8))
tensor([-2, -2,  0], dtype=torch.int8)
>>> torch.bitwise_xor(torch.tensor([True, True, False]), torch.tensor([False, True, False]))
tensor([ True, False, False])