brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.0 KiB · 51dedaf Raw
65 lines · plain
1// RUN: toyc-ch6 %s -emit=mlir-affine 2>&1 | FileCheck %s2// RUN: toyc-ch6 %s -emit=mlir-affine -opt 2>&1 | FileCheck %s --check-prefix=OPT3 4toy.func @main() {5  %0 = toy.constant dense<[[1.000000e+00, 2.000000e+00, 3.000000e+00], [4.000000e+00, 5.000000e+00, 6.000000e+00]]> : tensor<2x3xf64>6  %2 = toy.transpose(%0 : tensor<2x3xf64>) to tensor<3x2xf64>7  %3 = toy.mul %2, %2 : tensor<3x2xf64>8  toy.print %3 : tensor<3x2xf64>9  toy.return10}11 12// CHECK-LABEL: func @main()13// CHECK-DAG:     [[VAL_0:%.*]] = arith.constant 1.000000e+00 : f6414// CHECK-DAG:     [[VAL_1:%.*]] = arith.constant 2.000000e+00 : f6415// CHECK-DAG:     [[VAL_2:%.*]] = arith.constant 3.000000e+00 : f6416// CHECK-DAG:     [[VAL_3:%.*]] = arith.constant 4.000000e+00 : f6417// CHECK-DAG:     [[VAL_4:%.*]] = arith.constant 5.000000e+00 : f6418// CHECK-DAG:     [[VAL_5:%.*]] = arith.constant 6.000000e+00 : f6419// CHECK:         [[VAL_6:%.*]] = memref.alloc() : memref<3x2xf64>20// CHECK:         [[VAL_7:%.*]] = memref.alloc() : memref<3x2xf64>21// CHECK:         [[VAL_8:%.*]] = memref.alloc() : memref<2x3xf64>22// CHECK:         affine.store [[VAL_0]], [[VAL_8]][0, 0] : memref<2x3xf64>23// CHECK:         affine.store [[VAL_1]], [[VAL_8]][0, 1] : memref<2x3xf64>24// CHECK:         affine.store [[VAL_2]], [[VAL_8]][0, 2] : memref<2x3xf64>25// CHECK:         affine.store [[VAL_3]], [[VAL_8]][1, 0] : memref<2x3xf64>26// CHECK:         affine.store [[VAL_4]], [[VAL_8]][1, 1] : memref<2x3xf64>27// CHECK:         affine.store [[VAL_5]], [[VAL_8]][1, 2] : memref<2x3xf64>28// CHECK:         affine.for [[VAL_9:%.*]] = 0 to 3 {29// CHECK:           affine.for [[VAL_10:%.*]] = 0 to 2 {30// CHECK:             [[VAL_11:%.*]] = affine.load [[VAL_8]]{{\[}}[[VAL_10]], [[VAL_9]]] : memref<2x3xf64>31// CHECK:             affine.store [[VAL_11]], [[VAL_7]]{{\[}}[[VAL_9]], [[VAL_10]]] : memref<3x2xf64>32// CHECK:         affine.for [[VAL_12:%.*]] = 0 to 3 {33// CHECK:           affine.for [[VAL_13:%.*]] = 0 to 2 {34// CHECK:             [[VAL_14:%.*]] = affine.load [[VAL_7]]{{\[}}[[VAL_12]], [[VAL_13]]] : memref<3x2xf64>35// CHECK:             [[VAL_16:%.*]] = arith.mulf [[VAL_14]], [[VAL_14]] : f6436// CHECK:             affine.store [[VAL_16]], [[VAL_6]]{{\[}}[[VAL_12]], [[VAL_13]]] : memref<3x2xf64>37// CHECK:         toy.print [[VAL_6]] : memref<3x2xf64>38// CHECK:         memref.dealloc [[VAL_8]] : memref<2x3xf64>39// CHECK:         memref.dealloc [[VAL_7]] : memref<3x2xf64>40// CHECK:         memref.dealloc [[VAL_6]] : memref<3x2xf64>41 42// OPT-LABEL: func @main()43// OPT-DAG:     [[VAL_0:%.*]] = arith.constant 1.000000e+00 : f6444// OPT-DAG:     [[VAL_1:%.*]] = arith.constant 2.000000e+00 : f6445// OPT-DAG:     [[VAL_2:%.*]] = arith.constant 3.000000e+00 : f6446// OPT-DAG:     [[VAL_3:%.*]] = arith.constant 4.000000e+00 : f6447// OPT-DAG:     [[VAL_4:%.*]] = arith.constant 5.000000e+00 : f6448// OPT-DAG:     [[VAL_5:%.*]] = arith.constant 6.000000e+00 : f6449// OPT:         [[VAL_6:%.*]] = memref.alloc() : memref<3x2xf64>50// OPT:         [[VAL_7:%.*]] = memref.alloc() : memref<2x3xf64>51// OPT:         affine.store [[VAL_0]], [[VAL_7]][0, 0] : memref<2x3xf64>52// OPT:         affine.store [[VAL_1]], [[VAL_7]][0, 1] : memref<2x3xf64>53// OPT:         affine.store [[VAL_2]], [[VAL_7]][0, 2] : memref<2x3xf64>54// OPT:         affine.store [[VAL_3]], [[VAL_7]][1, 0] : memref<2x3xf64>55// OPT:         affine.store [[VAL_4]], [[VAL_7]][1, 1] : memref<2x3xf64>56// OPT:         affine.store [[VAL_5]], [[VAL_7]][1, 2] : memref<2x3xf64>57// OPT:         affine.for [[VAL_8:%.*]] = 0 to 3 {58// OPT:           affine.for [[VAL_9:%.*]] = 0 to 2 {59// OPT:             [[VAL_10:%.*]] = affine.load [[VAL_7]]{{\[}}[[VAL_9]], [[VAL_8]]] : memref<2x3xf64>60// OPT:             [[VAL_11:%.*]] = arith.mulf [[VAL_10]], [[VAL_10]] : f6461// OPT:             affine.store [[VAL_11]], [[VAL_6]]{{\[}}[[VAL_8]], [[VAL_9]]] : memref<3x2xf64>62// OPT:         toy.print [[VAL_6]] : memref<3x2xf64>63// OPT:         memref.dealloc [[VAL_7]] : memref<2x3xf64>64// OPT:         memref.dealloc [[VAL_6]] : memref<3x2xf64>65