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: f6412 %f2 = arith.constant 2.0: f6413 %f3 = arith.constant 3.0: f6414 %v0 = vector.broadcast %f1 : f64 to vector<64xf64>15 %v1 = vector.insert %f2, %v0[11] : f64 into vector<64xf64>16 %v2 = vector.insert %f3, %v1[52] : f64 into vector<64xf64>17 vector.print %v2 : vector<64xf64>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<64xf64> into f6426 vector.print %0 : f6427 // CHECK: 6728 %1 = vector.reduction <mul>, %v2 : vector<64xf64> into f6429 vector.print %1 : f6430 // CHECK: 631 %2 = vector.reduction <minimumf>, %v2 : vector<64xf64> into f6432 vector.print %2 : f6433 // CHECK: 134 %3 = vector.reduction <maximumf>, %v2 : vector<64xf64> into f6435 vector.print %3 : f6436 // CHECK: 337 %4 = vector.reduction <minnumf>, %v2 : vector<64xf64> into f6438 vector.print %4 : f6439 // CHECK: 140 %5 = vector.reduction <maxnumf>, %v2 : vector<64xf64> into f6441 vector.print %5 : f6442 // CHECK: 343 44 return45}46