45 lines · plain
1// RUN: mlir-opt %s -test-lower-to-llvm | \2// RUN: mlir-runner -e entry -entry-point-result=void \3// RUN: -shared-libs=%mlir_c_runner_utils | \4// RUN: FileCheck %s5 6func.func @entry() {7 %f1 = arith.constant 1.0: f328 %f2 = arith.constant 2.0: f329 %f3 = arith.constant 3.0: f3210 %f4 = arith.constant 4.0: f3211 %f5 = arith.constant 5.0: f3212 %f6 = arith.constant 6.0: f3213 14 // Construct test vector.15 %0 = vector.broadcast %f1 : f32 to vector<3x2xf32>16 %1 = vector.insert %f2, %0[0, 1] : f32 into vector<3x2xf32>17 %2 = vector.insert %f3, %1[1, 0] : f32 into vector<3x2xf32>18 %3 = vector.insert %f4, %2[1, 1] : f32 into vector<3x2xf32>19 %4 = vector.insert %f5, %3[2, 0] : f32 into vector<3x2xf32>20 %x = vector.insert %f6, %4[2, 1] : f32 into vector<3x2xf32>21 vector.print %x : vector<3x2xf32>22 // CHECK: ( ( 1, 2 ), ( 3, 4 ), ( 5, 6 ) )23 24 // Reshapes.25 %a = vector.shape_cast %x : vector<3x2xf32> to vector<3x2xf32>26 %b = vector.shape_cast %x : vector<3x2xf32> to vector<2x3xf32>27 %c = vector.shape_cast %x : vector<3x2xf32> to vector<6xf32>28 %d = vector.shape_cast %c : vector<6xf32> to vector<2x3xf32>29 %e = vector.shape_cast %c : vector<6xf32> to vector<3x2xf32>30 31 // Reshaped vectors:32 // CHECK: ( ( 1, 2 ), ( 3, 4 ), ( 5, 6 ) )33 // CHECK: ( ( 1, 2, 3 ), ( 4, 5, 6 ) )34 // CHECK: ( 1, 2, 3, 4, 5, 6 )35 // CHECK: ( ( 1, 2, 3 ), ( 4, 5, 6 ) )36 // CHECK: ( ( 1, 2 ), ( 3, 4 ), ( 5, 6 ) )37 vector.print %a : vector<3x2xf32>38 vector.print %b : vector<2x3xf32>39 vector.print %c : vector<6xf32>40 vector.print %d : vector<2x3xf32>41 vector.print %e : vector<3x2xf32>42 43 return44}45