torch.bitwise_or

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

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

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

  • other – 第二个输入 tensor

关键字参数

out (Tensor, 可选) – 指定输出张量。

示例:

>>> torch.bitwise_or(torch.tensor([-1, -2, 3], dtype=torch.int8), torch.tensor([1, 0, 3], dtype=torch.int8))
tensor([-1, -2,  3], dtype=torch.int8)
>>> torch.bitwise_or(torch.tensor([True, True, False]), torch.tensor([False, True, False]))
tensor([ True, True, False])
本页目录