|
| 1 | +// NUMPLACEHOLDERS 3 NUMVARIANTS 3 |
| 2 | +// PLACEHOLDER DTYPE f32 f16 bf16 |
| 3 | +// PLACEHOLDER PRINTDTYPE @printMemrefF32 @printMemrefF16 @printMemrefBF16 |
| 4 | +// PLACEHOLDER CHECKDTYPE @printAllcloseF32 @printAllcloseF16 @printAllcloseBF16 |
| 5 | +// RUN: %python_executable %imex_runner -i %s --pass-pipeline-file=%p/linalg-to-cpu.pp \ |
| 6 | +// RUN: --runner imex-cpu-runner -e main \ |
| 7 | +// RUN: --shared-libs=%mlir_runner_utils,%mlir_c_runner_utils,%irunner_utils \ |
| 8 | +// RUN: --entry-point-result=void --filecheck |
| 9 | +// RUN: %python_executable %imex_runner --requires=l0-runtime -i %s --pass-pipeline-file=%p/linalg-to-llvm.pp \ |
| 10 | +// RUN: --runner imex-cpu-runner -e main \ |
| 11 | +// RUN: --entry-point-result=void \ |
| 12 | +// RUN: --shared-libs=%mlir_runner_utils,%mlir_c_runner_utils,%irunner_utils,%levelzero_runtime --filecheck |
| 13 | +// RUN: %python_executable %imex_runner --requires=sycl-runtime -i %s --pass-pipeline-file=%p/linalg-to-llvm.pp \ |
| 14 | +// RUN: --runner imex-cpu-runner -e main \ |
| 15 | +// RUN: --entry-point-result=void \ |
| 16 | +// RUN: --shared-libs=%mlir_runner_utils,%mlir_c_runner_utils,%irunner_utils,%sycl_runtime --filecheck |
| 17 | +#map0 = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)> |
| 18 | +#map1 = affine_map<(d0, d1, d2, d3, d4, d5, d6) -> (d0, d1 + d4, d2 + d5, d6)> |
| 19 | +#map2 = affine_map<(d0, d1, d2, d3, d4, d5, d6) -> (d4, d5, d6, d3)> |
| 20 | +#map3 = affine_map<(d0, d1, d2, d3, d4, d5, d6) -> (d0, d1, d2, d3)> |
| 21 | +module @convolution { |
| 22 | +func.func @test(%arg0: tensor<1x56x56x64x@DTYPE@>, %arg1: tensor<3x3x64x64x@DTYPE@>) -> tensor<1x56x56x64x@DTYPE@> { |
| 23 | + %cst = arith.constant 0.000000e+00 : @DTYPE@ |
| 24 | + %0 = tensor.empty() : tensor<1x56x56x64x@DTYPE@> |
| 25 | + %1 = linalg.generic {indexing_maps = [#map0, #map0], iterator_types = ["parallel", "parallel", "parallel", "parallel"]} ins(%arg0 : tensor<1x56x56x64x@DTYPE@>) outs(%0 : tensor<1x56x56x64x@DTYPE@>) { |
| 26 | + ^bb0(%arg2: @DTYPE@, %arg3: @DTYPE@): |
| 27 | + linalg.yield %arg2 : @DTYPE@ |
| 28 | + } -> tensor<1x56x56x64x@DTYPE@> |
| 29 | + %cst_0 = arith.constant 0.000000e+00 : @DTYPE@ |
| 30 | + %2 = tensor.pad %1 low[0, 1, 1, 0] high[0, 1, 1, 0] { |
| 31 | + ^bb0(%arg2: index, %arg3: index, %arg4: index, %arg5: index): |
| 32 | + tensor.yield %cst_0 : @DTYPE@ |
| 33 | + } : tensor<1x56x56x64x@DTYPE@> to tensor<1x58x58x64x@DTYPE@> |
| 34 | + %3 = tensor.empty() : tensor<1x56x56x64x@DTYPE@> |
| 35 | + %4 = linalg.fill ins(%cst : @DTYPE@) outs(%3 : tensor<1x56x56x64x@DTYPE@>) -> tensor<1x56x56x64x@DTYPE@> |
| 36 | + %5 = linalg.generic {indexing_maps = [#map1, #map2, #map3], iterator_types = ["parallel", "parallel", "parallel", "parallel", "reduction", "reduction", "reduction"]} ins(%2, %arg1 : tensor<1x58x58x64x@DTYPE@>, tensor<3x3x64x64x@DTYPE@>) outs(%4 : tensor<1x56x56x64x@DTYPE@>) attrs = {iterator_ranges = [1, 56, 56, 64, 3, 3, 64]} { |
| 37 | + ^bb0(%arg2: @DTYPE@, %arg3: @DTYPE@, %arg4: @DTYPE@): |
| 38 | + %6 = arith.mulf %arg2, %arg3 : @DTYPE@ |
| 39 | + %7 = arith.addf %arg4, %6 : @DTYPE@ |
| 40 | + linalg.yield %7 : @DTYPE@ |
| 41 | + } -> tensor<1x56x56x64x@DTYPE@> |
| 42 | + return %5 : tensor<1x56x56x64x@DTYPE@> |
| 43 | + } |
| 44 | + func.func @main() { |
| 45 | + %0 = arith.constant dense<1.0> : tensor<1x56x56x64x@DTYPE@> |
| 46 | + %1 = arith.constant dense<0.5> : tensor<3x3x64x64x@DTYPE@> |
| 47 | + %2 = call @test(%0, %1) : (tensor<1x56x56x64x@DTYPE@>, tensor<3x3x64x64x@DTYPE@>) -> tensor<1x56x56x64x@DTYPE@> |
| 48 | + %3 = tensor.extract_slice %2[0, 0, 0, 0][1, 1, 1, 64][1, 1, 1, 1] : tensor<1x56x56x64x@DTYPE@> to tensor<64x@DTYPE@> |
| 49 | + %unranked = tensor.cast %3 : tensor<64x@DTYPE@> to tensor<*x@DTYPE@> |
| 50 | + %ref = arith.constant dense<[128.0, 128.0, 128.0, 128.0, 128.0, 128.0, 128.0, 128.0,128.0, 128.0, 128.0, 128.0, 128.0, 128.0, 128.0, 128.0,128.0, 128.0, 128.0, 128.0, 128.0, 128.0, 128.0, 128.0,128.0, 128.0, 128.0, 128.0, 128.0, 128.0, 128.0, 128.0,128.0, 128.0, 128.0, 128.0, 128.0, 128.0, 128.0, 128.0,128.0, 128.0, 128.0, 128.0, 128.0, 128.0, 128.0, 128.0,128.0, 128.0, 128.0, 128.0, 128.0, 128.0, 128.0, 128.0,128.0, 128.0, 128.0, 128.0, 128.0, 128.0, 128.0, 128.0]>:tensor<64xf32> |
| 51 | + %unranked_ref = tensor.cast %ref : tensor<64xf32>to tensor<*xf32> |
| 52 | + call @CHECKDTYPE@(%unranked, %unranked_ref) : (tensor<*x@DTYPE@>, tensor<*xf32>) -> () |
| 53 | + call @PRINTDTYPE@(%unranked) : (tensor<*x@DTYPE@>) -> () |
| 54 | + return |
| 55 | + // CHECK: [ALLCLOSE: TRUE] |
| 56 | + } |
| 57 | +func.func private @PRINTDTYPE@(tensor<*x@DTYPE@>) |
| 58 | +func.func private @CHECKDTYPE@(tensor<*x@DTYPE@>, tensor<*xf32>) |
| 59 | +} |
0 commit comments