PyTorch torch.bitwise_left_shift 函数
torch.bitwise_left_shift 是 PyTorch 中用于逐元素左移位的函数。
函数定义
torch.bitwise_left_shift(input, other, *, out=None)
使用示例
实例
import torch
# 左移位示例
x = torch.tensor([1, 2, 3, 4], dtype=torch.int8)
result = torch.bitwise_left_shift(x, 1)
print(result) # tensor([2, 4, 6, 8], dtype=int8)
# 左移位示例
x = torch.tensor([1, 2, 3, 4], dtype=torch.int8)
result = torch.bitwise_left_shift(x, 1)
print(result) # tensor([2, 4, 6, 8], dtype=int8)

Pytorch torch 参考手册