LeftShift

English | 简体中文

Product Support Status

Product Supported
Ascend 950PR&950DT products √
Atlas A3 products √
Atlas A2 products √
Atlas 200I/500 A2 inference products ×
Atlas inference products ×
Atlas training products ×

Function Description

  • Operator function: performs the bitwise left shift operation on the input tensors x and y element-wise.

  • Computation formula:

zi=xi<<yiz_i = x_i << y_i

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
x Input The input x is a k-dimensional tensor and is the input parameter for the left_shift computation, which is x_i in the formula. INT8, INT16, INT32, INT64, UINT8, UINT16, UINT32, UINT64 ND
y Input Input parameter for the left_shift computation, which is y_i in the formula. INT8, INT16, INT32, INT64, UINT8, UINT16, UINT32, UINT64 ND
z Output Output parameter for the left_shift computation, which is z_i in the formula. INT8, INT16, INT32, INT64, UINT8, UINT16, UINT32, UINT64 ND

Constraint Description

If shiftBits is negative or is not less than the bit width of the x data type, the output is 0, which is consistent with torch.bitwise_left_shift of PyTorch.

Invocation Description

Invocation Method Invocation Sample Description
aclnn invocation test_aclnn_left_shift Invokes the left_shift operator through the aclnnLeftShift API.
aclnn invocation test_aclnn_left_shifts Invokes the left_shift operator through the aclnnLeftShifts API (shiftBits is a scalar).
Graph-mode invocation test_geir_left_shift Invokes the LeftShift operator by building a graph through the operator IR.