PyTorch torch.bitwise_or 函数
torch.bitwise_or 是 PyTorch 中用于逐元素按位或的函数。
函数定义
torch.bitwise_or(input, other, *, out=None)
使用示例
实例
import torch
# 按位或示例
x = torch.tensor([5, 3, 7], dtype=torch.int8)
y = torch.tensor([1, 3, 4], dtype=torch.int8)
result = torch.bitwise_or(x, y)
print(result) # tensor([5, 3, 7], dtype=int8)
# 按位或示例
x = torch.tensor([5, 3, 7], dtype=torch.int8)
y = torch.tensor([1, 3, 4], dtype=torch.int8)
result = torch.bitwise_or(x, y)
print(result) # tensor([5, 3, 7], dtype=int8)

Pytorch torch 参考手册