Shortcuts

torch.bitwise_and

torch.bitwise_and(input, other, *, out=None) 张量

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

Parameters
  • 输入 – 第一个输入张量

  • 其他 – 第二个输入张量

Keyword Arguments

输出 (张量, 可选) – 输出张量。

示例:

>>> 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])