# 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< 相对社区能力缺失且无法实现 1. Ascend 相比 GPU 缺失 uint 类型支持。 2. 右操作数 `other` 仅支持标量,不支持 tensor(即 `x << 2` 合法,`x << y`(`y` 为 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) ```