捷徑

torch.bitwise_and

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

計算 inputother 的位元 AND 運算。輸入的張量必須為整數或布林類型。對於布林張量,它會計算邏輯 AND 運算。

參數
  • input – 第一個輸入張量

  • other – 第二個輸入張量

關鍵字參數

out (Tensor, optional) – 輸出張量 (可選)。

範例

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

文件

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources