torch.logical_and¶
- torch.logical_and(input, other, *, out=None) Tensor ¶
计算给定输入张量的逐元素逻辑与。零被视为
False
,非零被视为True
。示例
>>> torch.logical_and(torch.tensor([True, False, True]), torch.tensor([True, False, False])) tensor([ True, False, False]) >>> a = torch.tensor([0, 1, 10, 0], dtype=torch.int8) >>> b = torch.tensor([4, 0, 1, 0], dtype=torch.int8) >>> torch.logical_and(a, b) tensor([False, False, True, False]) >>> torch.logical_and(a.double(), b.double()) tensor([False, False, True, False]) >>> torch.logical_and(a.double(), b) tensor([False, False, True, False]) >>> torch.logical_and(a, b, out=torch.empty(4, dtype=torch.bool)) tensor([False, False, True, False])