torch.bitwise_and
- torch.bitwise_and(input, other, *, out=None) → Tensor
-
计算
input
和other
的按位与运算。输入张量的数据类型必须是整型或布尔型。对于布尔类型的张量,它计算逻辑与运算。- 参数
-
-
input – 输入的第一个张量
-
other – 第二个输入 tensor
-
- 关键字参数
-
out (Tensor, 可选) – 指定输出张量。
示例:
>>> torch.bitwise_and(torch.tensor([-1, -2, 3], dtype=torch.int8), torch.tensor([1, 0, 3], dtype=torch.int8)) tensor([1, 0, 3], dtype=torch.int8) >>> torch.bitwise_and(torch.tensor([True, True, False]), torch.tensor([False, True, False])) tensor([ False, True, False])