130 lines · plain
1// RUN: mlir-opt %s \2// RUN: -one-shot-bufferize="bufferize-function-boundaries" --canonicalize \3// RUN: -buffer-deallocation-pipeline \4// RUN: -finalize-memref-to-llvm \5// RUN: -convert-func-to-llvm -reconcile-unrealized-casts |\6// RUN: mlir-runner \7// RUN: -e entry -entry-point-result=void \8// RUN: -shared-libs=%mlir_c_runner_utils,%mlir_runner_utils |\9// RUN: FileCheck %s10 11module {12 13 func.func private @printMemrefI8(%ptr : tensor<*xi8>) attributes { llvm.emit_c_interface }14 func.func private @printMemrefI16(%ptr : tensor<*xi16>) attributes { llvm.emit_c_interface }15 func.func private @printMemrefI32(%ptr : tensor<*xi32>) attributes { llvm.emit_c_interface }16 func.func private @printMemrefI64(%ptr : tensor<*xi64>) attributes { llvm.emit_c_interface }17 func.func private @printMemrefBF16(%ptr : tensor<*xbf16>) attributes { llvm.emit_c_interface }18 func.func private @printMemrefF16(%ptr : tensor<*xf16>) attributes { llvm.emit_c_interface }19 func.func private @printMemrefF32(%ptr : tensor<*xf32>) attributes { llvm.emit_c_interface }20 func.func private @printMemrefF64(%ptr : tensor<*xf64>) attributes { llvm.emit_c_interface }21 func.func private @printMemrefC32(%ptr : tensor<*xcomplex<f32>>) attributes { llvm.emit_c_interface }22 func.func private @printMemrefC64(%ptr : tensor<*xcomplex<f64>>) attributes { llvm.emit_c_interface }23 func.func private @printMemrefInd(%ptr : tensor<*xindex>) attributes { llvm.emit_c_interface }24 25 func.func @entry() {26 %i8 = arith.constant dense<90> : tensor<3x3xi8>27 %i16 = arith.constant dense<1> : tensor<3x3xi16>28 %i32 = arith.constant dense<2> : tensor<3x3xi32>29 %i64 = arith.constant dense<3> : tensor<3x3xi64>30 %f16 = arith.constant dense<1.5> : tensor<3x3xf16>31 %bf16 = arith.constant dense<2.5> : tensor<3x3xbf16>32 %f32 = arith.constant dense<3.5> : tensor<3x3xf32>33 %f64 = arith.constant dense<4.5> : tensor<3x3xf64>34 %c32 = arith.constant dense<(1.000000e+01,5.000000e+00)> : tensor<3x3xcomplex<f32>>35 %c64 = arith.constant dense<(2.000000e+01,5.000000e+00)> : tensor<3x3xcomplex<f64>>36 %ind = arith.constant dense<4> : tensor<3x3xindex>37 38 %1 = tensor.cast %i8 : tensor<3x3xi8> to tensor<*xi8>39 %2 = tensor.cast %i16 : tensor<3x3xi16> to tensor<*xi16>40 %3 = tensor.cast %i32 : tensor<3x3xi32> to tensor<*xi32>41 %4 = tensor.cast %i64 : tensor<3x3xi64> to tensor<*xi64>42 %5 = tensor.cast %f16 : tensor<3x3xf16> to tensor<*xf16>43 %6 = tensor.cast %bf16 : tensor<3x3xbf16> to tensor<*xbf16>44 %7 = tensor.cast %f32 : tensor<3x3xf32> to tensor<*xf32>45 %8 = tensor.cast %f64 : tensor<3x3xf64> to tensor<*xf64>46 %9 = tensor.cast %c32 : tensor<3x3xcomplex<f32>> to tensor<*xcomplex<f32>>47 %10 = tensor.cast %c64 : tensor<3x3xcomplex<f64>> to tensor<*xcomplex<f64>>48 %11 = tensor.cast %ind : tensor<3x3xindex> to tensor<*xindex>49 50 // CHECK: data = 51 // CHECK-NEXT: {{\[}}[Z, Z, Z],52 // CHECK-NEXT: [Z, Z, Z],53 // CHECK-NEXT: [Z, Z, Z]]54 //55 call @printMemrefI8(%1) : (tensor<*xi8>) -> ()56 57 // CHECK-NEXT: data = 58 // CHECK-NEXT: {{\[}}[1, 1, 1],59 // CHECK-NEXT: [1, 1, 1],60 // CHECK-NEXT: [1, 1, 1]]61 //62 call @printMemrefI16(%2) : (tensor<*xi16>) -> ()63 64 // CHECK-NEXT: data = 65 // CHECK-NEXT: {{\[}}[2, 2, 2],66 // CHECK-NEXT: [2, 2, 2],67 // CHECK-NEXT: [2, 2, 2]]68 //69 call @printMemrefI32(%3) : (tensor<*xi32>) -> ()70 71 // CHECK-NEXT: data =72 // CHECK-NEXT: {{\[}}[3, 3, 3],73 // CHECK-NEXT: [3, 3, 3],74 // CHECK-NEXT: [3, 3, 3]]75 //76 call @printMemrefI64(%4) : (tensor<*xi64>) -> ()77 78 // CHECK-NEXT: data = 79 // CHECK-NEXT: {{\[}}[1.5, 1.5, 1.5],80 // CHECK-NEXT: [1.5, 1.5, 1.5],81 // CHECK-NEXT: [1.5, 1.5, 1.5]]82 //83 call @printMemrefF16(%5) : (tensor<*xf16>) -> ()84 85 // CHECK-NEXT: data = 86 // CHECK-NEXT: {{\[}}[2.5, 2.5, 2.5],87 // CHECK-NEXT: [2.5, 2.5, 2.5],88 // CHECK-NEXT: [2.5, 2.5, 2.5]]89 //90 call @printMemrefBF16(%6) : (tensor<*xbf16>) -> ()91 92 // CHECK-NEXT: data = 93 // CHECK-NEXT: {{\[}}[3.5, 3.5, 3.5],94 // CHECK-NEXT: [3.5, 3.5, 3.5],95 // CHECK-NEXT: [3.5, 3.5, 3.5]]96 //97 call @printMemrefF32(%7) : (tensor<*xf32>) -> ()98 99 // CHECK-NEXT: data = 100 // CHECK-NEXT: {{\[}}[4.5, 4.5, 4.5],101 // CHECK-NEXT: [4.5, 4.5, 4.5],102 // CHECK-NEXT: [4.5, 4.5, 4.5]]103 //104 call @printMemrefF64(%8) : (tensor<*xf64>) -> ()105 106 // CHECK-NEXT: data = 107 // CHECK-NEXT: {{\[}}[(10,5), (10,5), (10,5)],108 // CHECK-NEXT: [(10,5), (10,5), (10,5)],109 // CHECK-NEXT: [(10,5), (10,5), (10,5)]]110 //111 call @printMemrefC32(%9) : (tensor<*xcomplex<f32>>) -> ()112 113 // CHECK-NEXT: data = 114 // CHECK-NEXT: {{\[}}[(20,5), (20,5), (20,5)],115 // CHECK-NEXT: [(20,5), (20,5), (20,5)],116 // CHECK-NEXT: [(20,5), (20,5), (20,5)]]117 //118 call @printMemrefC64(%10) : (tensor<*xcomplex<f64>>) -> ()119 120 // CHECK-NEXT: data = 121 // CHECK-NEXT: {{\[}}[4, 4, 4],122 // CHECK-NEXT: [4, 4, 4],123 // CHECK-NEXT: [4, 4, 4]]124 //125 call @printMemrefInd(%11) : (tensor<*xindex>) -> ()126 127 return128 }129}130