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