TUTORIALAI & dataFETCHED

PyTorch torch.bitwise_and 函数

PyTorch torch.bitwise_and 函数 PyTorch torch.bitwise_and 函数 Pytorch torch 参考手册 torch.bitwise_and 是 PyTorch 中用于逐元素按位与的函数。 函数定义 torch.bitwise_and(input, other, *, out=None) 使用示例 实例 [mycode4 type='python'..

Updated 7/16/2026

Tutorial detail pages default to noindex.

PyTorch torch.bitwise_and 函数

PyTorch torch.bitwise_and 函数


Pytorch torch 参考手册 Pytorch torch 参考手册

torch.bitwise_and 是 PyTorch 中用于逐元素按位与的函数。

函数定义

torch.bitwise_and(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_and(x, y)
print(result)  # tensor([1, 3, 4], dtype=int8)

Pytorch torch 参考手册 Pytorch torch 参考手册