1// RUN: mlir-opt %s -convert-scf-to-std \ 2// RUN: -convert-vector-to-llvm='reassociate-fp-reductions' \ 3// RUN: -convert-std-to-llvm | \ 4// RUN: mlir-cpu-runner -e entry -entry-point-result=void \ 5// RUN: -shared-libs=%mlir_integration_test_dir/libmlir_c_runner_utils%shlibext | \ 6// RUN: FileCheck %s 7 8func @entry() { 9 // Construct test vector, numerically very stable. 10 %f1 = constant 1.0: f32 11 %f2 = constant 2.0: f32 12 %f3 = constant 3.0: f32 13 %v0 = vector.broadcast %f1 : f32 to vector<64xf32> 14 %v1 = vector.insert %f2, %v0[11] : f32 into vector<64xf32> 15 %v2 = vector.insert %f3, %v1[52] : f32 into vector<64xf32> 16 vector.print %v2 : vector<64xf32> 17 // 18 // test vector: 19 // 20 // 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 ) 21 22 // Various vector reductions. Not full functional unit tests, but 23 // a simple integration test to see if the code runs end-to-end. 24 %0 = vector.reduction "add", %v2 : vector<64xf32> into f32 25 vector.print %0 : f32 26 // CHECK: 67 27 %1 = vector.reduction "mul", %v2 : vector<64xf32> into f32 28 vector.print %1 : f32 29 // CHECK: 6 30 %2 = vector.reduction "min", %v2 : vector<64xf32> into f32 31 vector.print %2 : f32 32 // CHECK: 1 33 %3 = vector.reduction "max", %v2 : vector<64xf32> into f32 34 vector.print %3 : f32 35 // CHECK: 3 36 37 return 38} 39