32 lines · plain
1// RUN: mlir-opt %s -sparsifier="vl=8" | FileCheck %s2 3#Dense = #sparse_tensor.encoding<{4 map = (d0, d1) -> (d0 : dense, d1 : dense)5}>6 7#matvec = {8 indexing_maps = [9 affine_map<(i,j) -> (i,j)>, // A10 affine_map<(i,j) -> (j)>, // b11 affine_map<(i,j) -> (i)> // x (out)12 ],13 iterator_types = ["parallel", "reduction"],14 doc = "X(i) += A(i,j) * B(j)"15}16 17// CHECK-LABEL: llvm.func @kernel_matvec18// CHECK: llvm.intr.vector.reduce.fadd19func.func @kernel_matvec(%arga: tensor<?x?xf32, #Dense>,20 %argb: tensor<?xf32>,21 %argx: tensor<?xf32>) -> tensor<?xf32> {22 %x = linalg.generic #matvec23 ins(%arga, %argb: tensor<?x?xf32, #Dense>, tensor<?xf32>)24 outs(%argx: tensor<?xf32>) {25 ^bb(%a: f32, %b: f32, %x: f32):26 %0 = arith.mulf %a, %b : f3227 %1 = arith.addf %x, %0 : f3228 linalg.yield %1 : f3229 } -> tensor<?xf32>30 return %x : tensor<?xf32>31}32