| //-------------------------------------------------------------------------------------------------- |
| // WHEN CREATING A NEW TEST, PLEASE JUST COPY & PASTE WITHOUT EDITS. |
| // |
| // Set-up that's shared across all tests in this directory. In principle, this |
| // config could be moved to lit.local.cfg. However, there are downstream users that |
| // do not use these LIT config files. Hence why this is kept inline. |
| // |
| // DEFINE: %{sparsifier_opts} = enable-runtime-library=true |
| // DEFINE: %{sparsifier_opts_sve} = enable-arm-sve=true %{sparsifier_opts} |
| // DEFINE: %{compile} = mlir-opt %s --sparsifier="%{sparsifier_opts}" |
| // DEFINE: %{compile_sve} = mlir-opt %s --sparsifier="%{sparsifier_opts_sve}" |
| // DEFINE: %{run_libs} = -shared-libs=%mlir_c_runner_utils,%mlir_runner_utils |
| // DEFINE: %{run_libs_sve} = -shared-libs=%native_mlir_runner_utils,%native_mlir_c_runner_utils |
| // DEFINE: %{run_opts} = -e main -entry-point-result=void |
| // DEFINE: %{run} = mlir-cpu-runner %{run_opts} %{run_libs} |
| // DEFINE: %{run_sve} = %mcr_aarch64_cmd --march=aarch64 --mattr="+sve" %{run_opts} %{run_libs_sve} |
| // |
| // DEFINE: %{env} = |
| //-------------------------------------------------------------------------------------------------- |
| |
| // TODO: make this work with libgen |
| |
| // Do the same run, but now with direct IR generation. |
| // REDEFINE: %{sparsifier_opts} = enable-runtime-library=false enable-buffer-initialization=true |
| // RUN: %{compile} | %{run} | FileCheck %s |
| // |
| |
| #BatchedCSR = #sparse_tensor.encoding<{ |
| map = (d0, d1, d2) -> (d0 : batch, d1 : dense, d2 : compressed) |
| }> |
| |
| module { |
| |
| // |
| // Main driver that tests 3-D sparse tensor printing. |
| // |
| func.func @main() { |
| |
| %pos = arith.constant dense< |
| [[ 0, 8, 16, 24, 32], |
| [ 0, 8, 16, 24, 32]] |
| > : tensor<2x5xindex> |
| |
| %crd = arith.constant dense< |
| [[0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7], |
| [0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7]] |
| > : tensor<2x32xindex> |
| |
| %val = arith.constant dense< |
| [[ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., |
| 12., 13., 14., 15., 16., 17., 18., 19., 20., 21., 22., |
| 23., 24., 25., 26., 27., 28., 29., 30., 31., 32.], |
| [33., 34., 35., 36., 37., 38., 39., 40., 41., 42., 43., |
| 44., 45., 46., 47., 48., 49., 50., 51., 52., 53., 54., |
| 55., 56., 57., 58., 59., 60., 61., 62., 63., 64.]] |
| > : tensor<2x32xf64> |
| |
| %X = sparse_tensor.assemble (%pos, %crd), %val |
| : (tensor<2x5xindex>, tensor<2x32xindex>), tensor<2x32xf64> to tensor<2x4x8xf64, #BatchedCSR> |
| |
| // CHECK: ---- Sparse Tensor ---- |
| // CHECK-NEXT: nse = 32 |
| // CHECK-NEXT: dim = ( 2, 4, 8 ) |
| // CHECK-NEXT: lvl = ( 2, 4, 8 ) |
| // CHECK-NEXT: pos[2] : ( ( 0, 8, 16, 24, 32 )( 0, 8, 16, 24, 32 ) ) |
| // CHECK-NEXT: crd[2] : ( ( 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7 ) |
| // CHECK-SAME: ( 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7 ) ) |
| // CHECK-NEXT: values : ( ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 ) |
| // CHECK-SAME: ( 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 ) ) |
| // CHECK-NEXT: ---- |
| sparse_tensor.print %X : tensor<2x4x8xf64, #BatchedCSR> |
| |
| return |
| } |
| } |