46 lines · plain
1// RUN: mlir-opt %s -convert-vector-to-scf -convert-scf-to-cf \2// RUN: -convert-vector-to-llvm='reassociate-fp-reductions' \3// RUN: -convert-func-to-llvm -convert-arith-to-llvm \4// RUN: -convert-cf-to-llvm -reconcile-unrealized-casts | \5// RUN: mlir-runner -e entry -entry-point-result=void \6// RUN: -shared-libs=%mlir_c_runner_utils | \7// RUN: FileCheck %s8 9func.func @entry() {10 // Construct test vector, numerically very stable.11 %f1 = arith.constant 1.0: f3212 %f2 = arith.constant 2.0: f3213 %f3 = arith.constant 3.0: f3214 %v0 = vector.broadcast %f1 : f32 to vector<64xf32>15 %v1 = vector.insert %f2, %v0[11] : f32 into vector<64xf32>16 %v2 = vector.insert %f3, %v1[52] : f32 into vector<64xf32>17 vector.print %v2 : vector<64xf32>18 //19 // test vector:20 //21 // CHECK: ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 )22 23 // Various vector reductions. Not full functional unit tests, but24 // a simple integration test to see if the code runs end-to-end.25 %0 = vector.reduction <add>, %v2 : vector<64xf32> into f3226 vector.print %0 : f3227 // CHECK: 6728 %1 = vector.reduction <mul>, %v2 : vector<64xf32> into f3229 vector.print %1 : f3230 // CHECK: 631 %2 = vector.reduction <minimumf>, %v2 : vector<64xf32> into f3232 vector.print %2 : f3233 // CHECK: 134 %3 = vector.reduction <maximumf>, %v2 : vector<64xf32> into f3235 vector.print %3 : f3236 // CHECK: 337 %4 = vector.reduction <minnumf>, %v2 : vector<64xf32> into f3238 vector.print %4 : f3239 // CHECK: 140 %5 = vector.reduction <maxnumf>, %v2 : vector<64xf32> into f3241 vector.print %5 : f3242 // CHECK: 343 44 return45}46