brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.0 KiB · 9ae7161 Raw
139 lines · plain
1//--------------------------------------------------------------------------------------------------2// WHEN CREATING A NEW TEST, PLEASE JUST COPY & PASTE WITHOUT EDITS.3//4// Set-up that's shared across all tests in this directory. In principle, this5// config could be moved to lit.local.cfg. However, there are downstream users that6//  do not use these LIT config files. Hence why this is kept inline.7//8// DEFINE: %{sparsifier_opts} = enable-runtime-library=true9// DEFINE: %{sparsifier_opts_sve} = enable-arm-sve=true %{sparsifier_opts}10// DEFINE: %{compile} = mlir-opt %s --sparsifier="%{sparsifier_opts}"11// DEFINE: %{compile_sve} = mlir-opt %s --sparsifier="%{sparsifier_opts_sve}"12// DEFINE: %{run_libs} = -shared-libs=%mlir_c_runner_utils,%mlir_runner_utils13// DEFINE: %{run_libs_sve} = -shared-libs=%native_mlir_runner_utils,%native_mlir_c_runner_utils14// DEFINE: %{run_opts} = -e main -entry-point-result=void15// DEFINE: %{run} = mlir-runner %{run_opts} %{run_libs}16// DEFINE: %{run_sve} = %mcr_aarch64_cmd --march=aarch64 --mattr="+sve" %{run_opts} %{run_libs_sve}17//18// DEFINE: %{env} =19//--------------------------------------------------------------------------------------------------20 21// REDEFINE: %{env} = TENSOR0="%mlir_src_dir/test/Integration/data/ds.mtx"22// RUN: %{compile} | env %{env} %{run} | FileCheck %s23//24// Do the same run, but now with direct IR generation.25// REDEFINE: %{sparsifier_opts} = enable-runtime-library=false26// RUN: %{compile} | env %{env} %{run} | FileCheck %s27//28// Do the same run, but now with direct IR generation and vectorization.29// REDEFINE: %{sparsifier_opts} = enable-runtime-library=false enable-buffer-initialization=true vl=2 reassociate-fp-reductions=true enable-index-optimizations=true30// RUN: %{compile} | env %{env} %{run} | FileCheck %s31 32!Filename = !llvm.ptr33 34#CSR = #sparse_tensor.encoding<{35  map = (i, j) -> ( i : dense, j : compressed)36}>37 38#CSR_hi = #sparse_tensor.encoding<{39  map = (i, j) -> ( i : dense, j : loose_compressed)40}>41 42#NV_24 = #sparse_tensor.encoding<{43  map = ( i, j ) -> ( i            : dense,44                      j floordiv 4 : dense,45                      j mod 4      : structured[2, 4]),46  crdWidth = 847}>48 49#NV_58 = #sparse_tensor.encoding<{50  map = ( i, j ) -> ( i            : dense,51                      j floordiv 8 : dense,52                      j mod 8      : structured[5, 8]),53  crdWidth = 854}>55 56module {57 58  func.func private @getTensorFilename(index) -> (!Filename)59 60  //61  // Input matrix:62  //63  //  [[0.0,  0.0,  1.0,  2.0,  0.0,  3.0,  0.0,  4.0],64  //   [0.0,  5.0,  6.0,  0.0,  7.0,  0.0,  0.0,  8.0],65  //   [9.0,  0.0, 10.0,  0.0, 11.0, 12.0,  0.0,  0.0]]66  //67  func.func @main() {68    %c0 = arith.constant 0 : index69    %fileName = call @getTensorFilename(%c0) : (index) -> (!Filename)70 71    %A1 = sparse_tensor.new %fileName : !Filename to tensor<?x?xf64, #CSR>72    %A2 = sparse_tensor.new %fileName : !Filename to tensor<?x?xf64, #CSR_hi>73    %A3 = sparse_tensor.new %fileName : !Filename to tensor<?x?xf64, #NV_24>74    %A4 = sparse_tensor.new %fileName : !Filename to tensor<?x?xf64, #NV_58>75 76    //77    // CSR:78    //79    // CHECK:      ---- Sparse Tensor ----80    // CHECK-NEXT: nse = 1281    // CHECK-NEXT: dim = ( 3, 8 )82    // CHECK-NEXT: lvl = ( 3, 8 )83    // CHECK-NEXT: pos[1] : ( 0, 4, 8, 12 )84    // CHECK-NEXT: crd[1] : ( 2, 3, 5, 7, 1, 2, 4, 7, 0, 2, 4, 5 )85    // CHECK-NEXT: values : ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 )86    // CHECK-NEXT: ----87    //88    sparse_tensor.print %A1 : tensor<?x?xf64, #CSR>89 90    //91    // CSR_hi:92    //93    // CHECK-NEXT: ---- Sparse Tensor ----94    // CHECK-NEXT: nse = 1295    // CHECK-NEXT: dim = ( 3, 8 )96    // CHECK-NEXT: lvl = ( 3, 8 )97    // CHECK-NEXT: pos[1] : ( 0, 4, 4, 8, 8, 12, {{.*}} )98    // CHECK-NEXT: crd[1] : ( 2, 3, 5, 7, 1, 2, 4, 7, 0, 2, 4, 5 )99    // CHECK-NEXT: values : ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 )100    // CHECK-NEXT: ----101    //102    sparse_tensor.print %A2 : tensor<?x?xf64, #CSR_hi>103 104    //105    // NV_24:106    //107    // CHECK-NEXT: ---- Sparse Tensor ----108    // CHECK-NEXT: nse = 12109    // CHECK-NEXT: dim = ( 3, 8 )110    // CHECK-NEXT: lvl = ( 3, 2, 4 )111    // CHECK-NEXT: crd[2] : ( 2, 3, 1, 3, 1, 2, 0, 3, 0, 2, 0, 1 )112    // CHECK-NEXT: values : ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 )113    // CHECK-NEXT: ----114    // CHECK-NEXT: ---- Sparse Tensor ----115    //116    sparse_tensor.print %A3 : tensor<?x?xf64, #NV_24>117 118    //119    // NV_58:120    //121    // CHECK-NEXT: nse = 12122    // CHECK-NEXT: dim = ( 3, 8 )123    // CHECK-NEXT: lvl = ( 3, 1, 8 )124    // CHECK-NEXT: crd[2] : ( 2, 3, 5, 7, 1, 2, 4, 7, 0, 2, 4, 5 )125    // CHECK-NEXT: values : ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 )126    // CHECK-NEXT: ----127    //128    sparse_tensor.print %A4 : tensor<?x?xf64, #NV_58>129 130    // Release the resources.131    bufferization.dealloc_tensor %A1: tensor<?x?xf64, #CSR>132    bufferization.dealloc_tensor %A2: tensor<?x?xf64, #CSR_hi>133    bufferization.dealloc_tensor %A3: tensor<?x?xf64, #NV_24>134    bufferization.dealloc_tensor %A4: tensor<?x?xf64, #NV_58>135 136    return137  }138}139