# triton.language.core.__lshift__ ## 1. OP 概述 简介:根据给定值 将tensor张量进行左移位。 ```python triton.language.core.__lshift__( input: tl.tensor, other: tl.tensor, builder: ir.builder ) -> tl.tensor ``` 作为`tensor`的内置运算符使用,如`x< 相对社区能力缺失且无法实现 Ascend 对比 GPU 缺失uint的支持能力,并且输入右参数为tensor时不支持。 ### 2.4 使用方法 以下示例实现了对三维张量`x0`、`x1`做左移位运算: ```python @triton.jit def triton_lshift_3d(in_ptr0, out_ptr0, L : tl.constexpr, M : tl.constexpr, N : tl.constexpr): loffs = tl.program_id(0) * L lblk_idx = tl.arange(0,L) + loffs mblk_idx = tl.arange(0,M) nblk_idx = tl.arange(0,N) idx = lblk_idx[:,None,None]*N*M+mblk_idx[None,:,None]*N+nblk_idx[None,None,:] x0=tl.load(in_ptr0+idx) ret = x0 << 2 odx = lblk_idx[:, None, None] * N * M + mblk_idx[None, :, None] * N + nblk_idx[None, None, :] tl.store(out_ptr0+odx, ret) ```