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 %f0 = constant 0.0: f32 8 %f1 = constant 1.0: f32 9 %f2 = constant 2.0: f32 10 %f3 = constant 3.0: f32 11 %f4 = constant 4.0: f32 12 %f5 = constant 5.0: f32 13 %f6 = constant 6.0: f32 14 %f7 = constant 7.0: f32 15 %f8 = constant 8.0: f32 16 %f9 = constant 9.0: f32 17 %f10 = constant 10.0: f32 18 %f11 = constant 11.0: f32 19 %f12 = constant 12.0: f32 20 %f13 = constant 13.0: f32 21 %f14 = constant 14.0: f32 22 %f15 = constant 15.0: f32 23 24 %a0 = vector.broadcast %f0 : f32 to vector<4x4xf32> 25 %a1 = vector.insert %f0, %a0[0, 0] : f32 into vector<4x4xf32> 26 %a2 = vector.insert %f1, %a1[0, 1] : f32 into vector<4x4xf32> 27 %a3 = vector.insert %f2, %a2[0, 2] : f32 into vector<4x4xf32> 28 %a4 = vector.insert %f3, %a3[0, 3] : f32 into vector<4x4xf32> 29 %a5 = vector.insert %f4, %a4[1, 0] : f32 into vector<4x4xf32> 30 %a6 = vector.insert %f5, %a5[1, 1] : f32 into vector<4x4xf32> 31 %a7 = vector.insert %f6, %a6[1, 2] : f32 into vector<4x4xf32> 32 %a8 = vector.insert %f7, %a7[1, 3] : f32 into vector<4x4xf32> 33 %a9 = vector.insert %f8, %a8[2, 0] : f32 into vector<4x4xf32> 34 %a10 = vector.insert %f9, %a9[2, 1] : f32 into vector<4x4xf32> 35 %a11 = vector.insert %f10, %a10[2, 2] : f32 into vector<4x4xf32> 36 %a12 = vector.insert %f11, %a11[2, 3] : f32 into vector<4x4xf32> 37 %a13 = vector.insert %f12, %a12[3, 0] : f32 into vector<4x4xf32> 38 %a14 = vector.insert %f13, %a13[3, 1] : f32 into vector<4x4xf32> 39 %a15 = vector.insert %f14, %a14[3, 2] : f32 into vector<4x4xf32> 40 %a16 = vector.insert %f15, %a15[3, 3] : f32 into vector<4x4xf32> 41 42 vector.print %a16 : vector<4x4xf32> 43 // 44 // test matrix: 45 // 46 // CHECK: ( ( 0, 1, 2, 3 ), ( 4, 5, 6, 7 ), ( 8, 9, 10, 11 ), ( 12, 13, 14, 15 ) ) 47 48 // Tile 4x4 with 3x3 as follows: 49 // 50 // +--------+--+ 51 // +0 1 2| 3| 52 // |4 5 6| 7| 53 // |8 9 10|11| 54 // +--------+--+ 55 // |12 13 14|15| 56 // +--------+--+ 57 // 58 %es = vector.extract_slices %a16, [3, 3], [1, 1] : 59 vector<4x4xf32> into tuple<vector<3x3xf32>, vector<3x1xf32>, vector<1x3xf32>, vector<1x1xf32>> 60 61 %0 = vector.tuple_get %es, 0 : tuple<vector<3x3xf32>, vector<3x1xf32>, vector<1x3xf32>, vector<1x1xf32>> 62 %1 = vector.tuple_get %es, 1 : tuple<vector<3x3xf32>, vector<3x1xf32>, vector<1x3xf32>, vector<1x1xf32>> 63 %2 = vector.tuple_get %es, 2 : tuple<vector<3x3xf32>, vector<3x1xf32>, vector<1x3xf32>, vector<1x1xf32>> 64 %3 = vector.tuple_get %es, 3 : tuple<vector<3x3xf32>, vector<3x1xf32>, vector<1x3xf32>, vector<1x1xf32>> 65 66 vector.print %0 : vector<3x3xf32> 67 vector.print %1 : vector<3x1xf32> 68 vector.print %2 : vector<1x3xf32> 69 vector.print %3 : vector<1x1xf32> 70 // 71 // extract slices: 72 // 73 // CHECK: ( ( 0, 1, 2 ), ( 4, 5, 6 ), ( 8, 9, 10 ) ) 74 // CHECK: ( ( 3 ), ( 7 ), ( 11 ) ) 75 // CHECK: ( ( 12, 13, 14 ) ) 76 // CHECK: ( ( 15 ) ) 77 78 return 79} 80