megengine.functional.left_shift

left_shift(x, y)[源代码]

逐元素计算 x << y。

例如:

import numpy as np
from megengine import tensor
import megengine.functional as F

x = tensor(np.arange(0, 6, dtype=np.int32).reshape(2, 3))
out = F.left_shift(x, 2)
print(out.numpy())

输出:

[[ 0  4  8]
 [12 16 20]]