torch.bitwise_or¶
- torch.bitwise_or(input: Tensor, other: Tensor, *, out: Optional[Tensor]) Tensor ¶
計算
input
和other
的位元 OR 運算。輸入張量必須是整數或布林類型。對於布林張量,它計算邏輯 OR 運算。- 參數
input – 第一個輸入張量
other – 第二個輸入張量
- 關鍵字參數
out (Tensor, optional) – 輸出張量(可選)。
範例
>>> 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])