87 lines · plain
1// RUN: mlir-opt %s --sparse-reinterpret-map -sparsification -cse -sparse-vectorization="vl=8" -cse | \2// RUN: FileCheck %s3 4#DenseVector = #sparse_tensor.encoding<{ map = (d0) -> (d0 : dense) }>5 6#trait = {7 indexing_maps = [8 affine_map<(i) -> (i)>, // a9 affine_map<(i) -> (i)>, // b10 affine_map<(i) -> (i)> // x (out)11 ],12 iterator_types = ["parallel"],13 doc = "x(i) = a(i) ops b(i)"14}15 16// CHECK-LABEL: func.func @vops17// CHECK-DAG: %[[C1:.*]] = arith.constant dense<2.000000e+00> : vector<8xf32>18// CHECK-DAG: %[[C2:.*]] = arith.constant dense<1.000000e+00> : vector<8xf32>19// CHECK-DAG: %[[C3:.*]] = arith.constant dense<255> : vector<8xi64>20// CHECK-DAG: %[[C4:.*]] = arith.constant dense<4> : vector<8xi32>21// CHECK-DAG: %[[C5:.*]] = arith.constant dense<1> : vector<8xi32>22// CHECK: scf.for23// CHECK: %[[VAL_14:.*]] = vector.load24// CHECK: %[[VAL_15:.*]] = math.absf %[[VAL_14]] : vector<8xf32>25// CHECK: %[[VAL_16:.*]] = math.ceil %[[VAL_15]] : vector<8xf32>26// CHECK: %[[VAL_17:.*]] = math.floor %[[VAL_16]] : vector<8xf32>27// CHECK: %[[VAL_18:.*]] = math.sqrt %[[VAL_17]] : vector<8xf32>28// CHECK: %[[VAL_19:.*]] = math.expm1 %[[VAL_18]] : vector<8xf32>29// CHECK: %[[VAL_20:.*]] = math.sin %[[VAL_19]] : vector<8xf32>30// CHECK: %[[VAL_21:.*]] = math.tanh %[[VAL_20]] : vector<8xf32>31// CHECK: %[[VAL_22:.*]] = arith.negf %[[VAL_21]] : vector<8xf32>32// CHECK: %[[VAL_23:.*]] = vector.load33// CHECK: %[[VAL_24:.*]] = arith.mulf %[[VAL_22]], %[[VAL_23]] : vector<8xf32>34// CHECK: %[[VAL_25:.*]] = arith.divf %[[VAL_24]], %[[C1]] : vector<8xf32>35// CHECK: %[[VAL_26:.*]] = arith.addf %[[VAL_25]], %[[C1]] : vector<8xf32>36// CHECK: %[[VAL_27:.*]] = arith.subf %[[VAL_26]], %[[C2]] : vector<8xf32>37// CHECK: %[[VAL_28:.*]] = arith.extf %[[VAL_27]] : vector<8xf32> to vector<8xf64>38// CHECK: %[[VAL_29:.*]] = arith.bitcast %[[VAL_28]] : vector<8xf64> to vector<8xi64>39// CHECK: %[[VAL_30:.*]] = arith.addi %[[VAL_29]], %[[VAL_29]] : vector<8xi64>40// CHECK: %[[VAL_31:.*]] = arith.andi %[[VAL_30]], %[[C3]] : vector<8xi64>41// CHECK: %[[VAL_32:.*]] = arith.trunci %[[VAL_31]] : vector<8xi64> to vector<8xi16>42// CHECK: %[[VAL_33:.*]] = arith.extsi %[[VAL_32]] : vector<8xi16> to vector<8xi32>43// CHECK: %[[VAL_34:.*]] = arith.shrsi %[[VAL_33]], %[[C4]] : vector<8xi32>44// CHECK: %[[VAL_35:.*]] = arith.shrui %[[VAL_34]], %[[C4]] : vector<8xi32>45// CHECK: %[[VAL_36:.*]] = arith.shli %[[VAL_35]], %[[C5]] : vector<8xi32>46// CHECK: %[[VAL_37:.*]] = arith.uitofp %[[VAL_36]] : vector<8xi32> to vector<8xf32>47// CHECK: vector.store %[[VAL_37]]48// CHECK: }49func.func @vops(%arga: tensor<1024xf32, #DenseVector>,50 %argb: tensor<1024xf32, #DenseVector>) -> tensor<1024xf32> {51 %init = tensor.empty() : tensor<1024xf32>52 %o = arith.constant 1.0 : f3253 %c = arith.constant 2.0 : f3254 %i = arith.constant 255 : i6455 %s = arith.constant 4 : i3256 %t = arith.constant 1 : i3257 %0 = linalg.generic #trait58 ins(%arga, %argb: tensor<1024xf32, #DenseVector>, tensor<1024xf32, #DenseVector>)59 outs(%init: tensor<1024xf32>) {60 ^bb(%a: f32, %b: f32, %x: f32):61 %0 = math.absf %a : f3262 %1 = math.ceil %0 : f3263 %2 = math.floor %1 : f3264 %3 = math.sqrt %2 : f3265 %4 = math.expm1 %3 : f3266 %5 = math.sin %4 : f3267 %6 = math.tanh %5 : f3268 %7 = arith.negf %6 : f3269 %8 = arith.mulf %7, %b : f3270 %9 = arith.divf %8, %c : f3271 %10 = arith.addf %9, %c : f3272 %11 = arith.subf %10, %o : f3273 %12 = arith.extf %11 : f32 to f6474 %13 = arith.bitcast %12 : f64 to i6475 %14 = arith.addi %13, %13 : i6476 %15 = arith.andi %14, %i : i6477 %16 = arith.trunci %15 : i64 to i1678 %17 = arith.extsi %16 : i16 to i3279 %18 = arith.shrsi %17, %s : i3280 %19 = arith.shrui %18, %s : i3281 %20 = arith.shli %19, %t : i3282 %21 = arith.uitofp %20 : i32 to f3283 linalg.yield %21 : f3284 } -> tensor<1024xf32>85 return %0 : tensor<1024xf32>86}87