評價此頁

torch.bitwise_left_shift#

torch.bitwise_left_shift(input, other, *, out=None) Tensor#

計算 input 左移 other 位的結果。輸入張量必須是整數型別。此運算子支援廣播到公共形狀型別提升

應用的操作是:

outi=inputi<<otheri\text{out}_i = \text{input}_i << \text{other}_i
引數
  • input (TensorScalar) – 第一個輸入張量

  • other (TensorScalar) – 第二個輸入張量

關鍵字引數

out (Tensor, optional) – 輸出張量。

示例

>>> torch.bitwise_left_shift(torch.tensor([-1, -2, 3], dtype=torch.int8), torch.tensor([1, 0, 3], dtype=torch.int8))
tensor([-2, -2, 24], dtype=torch.int8)