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, this 5// config could be moved to lit.local.cfg. However, there are downstream users that 6// do not use these LIT config files. Hence why this is kept inline. 7// 8// DEFINE: %{sparsifier_opts} = enable-runtime-library=true 9// 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_utils 13// DEFINE: %{run_libs_sve} = -shared-libs=%native_mlir_runner_utils,%native_mlir_c_runner_utils 14// DEFINE: %{run_opts} = -e main -entry-point-result=void 15// 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} | %{run} | FileCheck %s 22// 23// Do the same run, but now with direct IR generation. 24// REDEFINE: %{sparsifier_opts} = enable-runtime-library=false 25// RUN: %{compile} | %{run} | FileCheck %s 26// 27// Do the same run, but now with direct IR generation and vectorization. 28// REDEFINE: %{sparsifier_opts} = enable-runtime-library=false vl=2 reassociate-fp-reductions=true enable-index-optimizations=true 29// RUN: %{compile} | %{run} | FileCheck %s 30// 31// Do the same run, but now with direct IR generation and VLA vectorization. 32// RUN: %if mlir_arm_sve_tests %{ %{compile_sve} | %{run_sve} | FileCheck %s %} 33 34#DCSR = #sparse_tensor.encoding<{ 35 map = (d0, d1) -> (d0 : compressed, d1 : compressed) 36}> 37 38module { 39 // 40 // Main driver. 41 // 42 func.func @main() { 43 %c0 = arith.constant 0 : index 44 %c1 = arith.constant 1 : index 45 %c2 = arith.constant 2 : index 46 %c3 = arith.constant 3 : index 47 %t1 = tensor.empty() : tensor<4x5xf64, #DCSR> 48 %t2 = tensor.empty(%c2, %c3) : tensor<?x?xf64, #DCSR> 49 50 %d1_0 = tensor.dim %t1, %c0 : tensor<4x5xf64, #DCSR> 51 %d2_0 = tensor.dim %t2, %c0 : tensor<?x?xf64, #DCSR> 52 %d1_1 = tensor.dim %t1, %c1 : tensor<4x5xf64, #DCSR> 53 %d2_1 = tensor.dim %t2, %c1 : tensor<?x?xf64, #DCSR> 54 55 // CHECK: 4 56 vector.print %d1_0 : index 57 // CHECK-NEXT: 2 58 vector.print %d2_0 : index 59 // CHECK-NEXT: 5 60 vector.print %d1_1 : index 61 // CHECK-NEXT: 3 62 vector.print %d2_1 : index 63 64 // Release resources. 65 bufferization.dealloc_tensor %t1 : tensor<4x5xf64, #DCSR> 66 bufferization.dealloc_tensor %t2 : tensor<?x?xf64, #DCSR> 67 68 return 69 } 70} 71 72