brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 1af9dc6 Raw
63 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// RUN: %{compile} | env %{env} %{run} | FileCheck %s22//23// Do the same run, but now with direct IR generation.24// REDEFINE: %{sparsifier_opts} = enable-runtime-library=false25// RUN: %{compile} | env %{env} %{run} | FileCheck %s26 27#CSR_hi = #sparse_tensor.encoding<{28  map = (i, j) -> ( i : dense, j : loose_compressed)29}>30 31module {32  func.func @main() {33    %c0 = arith.constant 0 : index34    %f0 = arith.constant 0.0 : f6435    %d = arith.constant dense<[[ 1.0,  2.0,  3.0,  4.0 ],36                               [ 5.0,  6.0,  7.0,  8.0 ],37                               [ 0.0,  0.0,  5.5,  0.0 ],38                               [ 9.0, 10.0, 11.0, 12.0 ],39                               [13.0, 14.0, 15.0, 16.0 ]]> : tensor<5x4xf64>40    %s = sparse_tensor.convert %d : tensor<5x4xf64> to tensor<5x4xf64, #CSR_hi>41 42    //43    // Note: position for loose_compressed level can vary in the end,44    // therefore we loosely check it with {{.*}}.45    //46    // CHECK:   ---- Sparse Tensor ----47    // CHECK-NEXT: nse = 1748    // CHECK-NEXT: dim = ( 5, 4 )49    // CHECK-NEXT: lvl = ( 5, 4 )50    // CHECK-NEXT: pos[1] : ( 0, 4, 4, 8, 8, 9, 9, 13, {{.*}} )51    // CHECK-NEXT: crd[1] : ( 0, 1, 2, 3, 0, 1, 2, 3, 2, 0, 1, 2, 3, 0, 1, 2, 3 )52    // CHECK-NEXT: values : ( 1, 2, 3, 4, 5, 6, 7, 8, 5.5, 9, 10, 11, 12, 13, 14, 15, 16 )53    // CHECK-NEXT: ----54    //55    sparse_tensor.print %s : tensor<5x4xf64, #CSR_hi>56 57    // Release the resources.58    bufferization.dealloc_tensor %s: tensor<5x4xf64, #CSR_hi>59 60    return61  }62}63