docker: registry.mthreads.com/mcconline/inference/vllm:v0.20.2-ph1-4.3.5-torch2.7.1-v1.1.0
import torch
import triton
import triton.language as tl
import triton.experimental.tle.language as tle
@triton.jit
def _vec_kernel(
x_ptr,
y_ptr,
x_stride0,
y_stride0,
VEC: tl.constexpr,
BLOCK_SIZE: tl.constexpr,
):
row_id = tl.program_id(0)
x_ptr += row_id * x_stride0
y_ptr += row_id * y_stride0
vec = tl.arange(0, VEC)
lane = tl.arange(0, BLOCK_SIZE)
vals = tl.load(x_ptr + lane[:, None] * VEC + vec[None, :])
tl.store(y_ptr, tl.sum(vals)) # no vec
#tl.store(y_ptr + lane[:, None] * VEC + vec[None, :], vals) # vec
device='musa'
torch.manual_seed(42)
VEC = 4
BLOCK_SIZE = 512
num_rows = 2
num_elem = BLOCK_SIZE * VEC
X = torch.randn(num_rows, num_elem, device=device, dtype=torch.float32)
Y = torch.empty((num_rows, num_elem,), dtype=torch.float32, device=device)
_vec_kernel[(num_rows,)](
X,
Y,
X.stride(0),
Y.stride(0),
VEC=VEC,
BLOCK_SIZE=BLOCK_SIZE,
num_warps=BLOCK_SIZE // 32,
)
docker: registry.mthreads.com/mcconline/inference/vllm:v0.20.2-ph1-4.3.5-torch2.7.1-v1.1.0
flagtree: 0.6.0+mthreads.gitc64a4918(after the fix of #854)
description: VectorCombinePass replaces
load <4 x float>with fourload floattestcase:
IR after SROAPass runs:
mlir after SLPVectorizerPass.txt
IR after VectorCombinePass runs:
mlir after VectorCombinePass.txt