[Mlir-commits] [mlir] [mlir][sparse] add a 3-d block and fiber test (PR #78529)

Yinying Li llvmlistbot at llvm.org
Wed Jan 17 17:34:04 PST 2024


================
@@ -0,0 +1,122 @@
+//--------------------------------------------------------------------------------------------------
+// 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_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}
+//
+// DEFINE: %{env} =
+//--------------------------------------------------------------------------------------------------
+
+// RUN: %{compile} | %{run} | FileCheck %s
+//
+// 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
+//
+// Do the same run, but now with direct IR generation and vectorization.
+// REDEFINE: %{sparsifier_opts} = enable-runtime-library=false enable-buffer-initialization=true vl=2 reassociate-fp-reductions=true enable-index-optimizations=true
+// RUN: %{compile} | %{run} | FileCheck %s
+//
+// Do the same run, but now with direct IR generation and VLA vectorization.
+// RUN: %if mlir_arm_sve_tests %{ %{compile_sve} | %{run_sve} | FileCheck %s %}
+
+#Sparse1 = #sparse_tensor.encoding<{
+  map = (i, j, k) -> (
+    i : compressed,
+    j : compressed,
+    k : compressed
+  )
+}>
+
+#Sparse2 = #sparse_tensor.encoding<{
+  map = (i, j, k) -> (
+    i floordiv 2 : compressed,
+    j floordiv 2 : compressed,
+    k floordiv 2 : compressed,
+    i mod 2 : dense,
+    j mod 2 : dense,
+    k mod 2 : dense)
+}>
+
+module {
+
+  //
+  // Main driver that reads matrix from file and calls the sparse kernel.
+  //
+  func.func @main() {
+    %c0 = arith.constant 0 : index
+    %i0 = arith.constant 0 : i32
+
+    // Setup input sparse matrix from compressed constant.
----------------
yinying-lisa-li wrote:

Nit: tensor instead of matrix.

https://github.com/llvm/llvm-project/pull/78529


More information about the Mlir-commits mailing list