1// RUN: mlir-opt %s -convert-scf-to-std -convert-vector-to-llvm -convert-std-to-llvm | \ 2// RUN: mlir-cpu-runner -e entry -entry-point-result=void \ 3// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_c_runner_utils%shlibext | \ 4// RUN: FileCheck %s 5 6func @entry() { 7 // Construct test vector. 8 %f1 = constant 1.5: f64 9 %f2 = constant 2.0: f64 10 %f3 = constant 3.0: f64 11 %f4 = constant 4.0: f64 12 %f5 = constant 5.0: f64 13 %f6 = constant -1.0: f64 14 %f7 = constant -2.0: f64 15 %f8 = constant -4.0: f64 16 %f9 = constant -0.25: f64 17 %f10 = constant -16.0: f64 18 %v0 = vector.broadcast %f1 : f64 to vector<10xf64> 19 %v1 = vector.insert %f2, %v0[1] : f64 into vector<10xf64> 20 %v2 = vector.insert %f3, %v1[2] : f64 into vector<10xf64> 21 %v3 = vector.insert %f4, %v2[3] : f64 into vector<10xf64> 22 %v4 = vector.insert %f5, %v3[4] : f64 into vector<10xf64> 23 %v5 = vector.insert %f6, %v4[5] : f64 into vector<10xf64> 24 %v6 = vector.insert %f7, %v5[6] : f64 into vector<10xf64> 25 %v7 = vector.insert %f8, %v6[7] : f64 into vector<10xf64> 26 %v8 = vector.insert %f9, %v7[8] : f64 into vector<10xf64> 27 %v9 = vector.insert %f10, %v8[9] : f64 into vector<10xf64> 28 vector.print %v9 : vector<10xf64> 29 // 30 // test vector: 31 // 32 // CHECK: ( 1.5, 2, 3, 4, 5, -1, -2, -4, -0.25, -16 ) 33 34 // Various vector reductions. Not full functional unit tests, but 35 // a simple integration test to see if the code runs end-to-end. 36 %0 = vector.reduction "add", %v9 : vector<10xf64> into f64 37 vector.print %0 : f64 38 // CHECK: -7.75 39 %1 = vector.reduction "mul", %v9 : vector<10xf64> into f64 40 vector.print %1 : f64 41 // CHECK: -5760 42 %2 = vector.reduction "min", %v9 : vector<10xf64> into f64 43 vector.print %2 : f64 44 // CHECK: -16 45 %3 = vector.reduction "max", %v9 : vector<10xf64> into f64 46 vector.print %3 : f64 47 // CHECK: 5 48 49 return 50} 51